56 u8 * b_dmac,
u8 * b_smac,
57 u16 b_vlanid,
u32 i_sid,
u16 vlan_outer_tag)
68 error = VNET_API_ERROR_INVALID_INTERFACE;
90 in_config->
pop_bytes =
sizeof (ethernet_pbb_header_packed_t);
99 clib_net_to_host_u16 (ETHERNET_TYPE_DOT1AD);
101 clib_net_to_host_u16 (b_vlanid & 0xFFF);
103 clib_net_to_host_u16 (ETHERNET_TYPE_DOT1AH);
105 clib_net_to_host_u32 (i_sid & 0xFFFFF);
106 in_config->
push_bytes =
sizeof (ethernet_pbb_header_packed_t);
155 error = VNET_API_ERROR_INVALID_INTERFACE;
174 clib_net_to_host_u16 (push_dot1q ? ETHERNET_TYPE_VLAN :
175 ETHERNET_TYPE_DOT1AD);
176 push_inner_et = clib_net_to_host_u16 (ETHERNET_TYPE_VLAN);
177 vtr_tag1 = clib_net_to_host_u16 (vtr_tag1);
178 vtr_tag2 = clib_net_to_host_u16 (vtr_tag2);
217 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
227 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
241 in_config->
tags[1].
type = push_outer_et;
248 in_config->
tags[0].
type = push_outer_et;
250 in_config->
tags[1].
type = push_inner_et;
256 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
262 in_config->
tags[1].
type = push_outer_et;
268 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
274 in_config->
tags[0].
type = push_outer_et;
276 in_config->
tags[1].
type = push_inner_et;
282 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
288 in_config->
tags[1].
type = push_outer_et;
294 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
300 in_config->
tags[0].
type = push_outer_et;
302 in_config->
tags[1].
type = push_inner_et;
316 clib_net_to_host_u16 (si->
sub.
eth.
flags.dot1ad ? ETHERNET_TYPE_DOT1AD :
318 push_inner_et = clib_net_to_host_u16 (ETHERNET_TYPE_VLAN);
325 out_config->
tags[1].
type = push_outer_et;
330 out_config->
tags[0].
type = push_outer_et;
332 out_config->
tags[1].
type = push_inner_et;
358 if (!vtr_op || !push_dot1q || !vtr_tag1 || !vtr_tag2)
361 error = VNET_API_ERROR_INVALID_ARGUMENT;
407 (ETHERNET_TYPE_VLAN ==
408 clib_host_to_net_u16 (in_config->
tags[1].
type));
417 (ETHERNET_TYPE_VLAN ==
418 clib_host_to_net_u16 (in_config->
tags[0].
type));
423 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
439 (ETHERNET_TYPE_VLAN ==
440 clib_host_to_net_u16 (in_config->
tags[1].
type));
449 (ETHERNET_TYPE_VLAN ==
450 clib_host_to_net_u16 (in_config->
tags[0].
type));
455 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
471 (ETHERNET_TYPE_VLAN ==
472 clib_host_to_net_u16 (in_config->
tags[1].
type));
481 (ETHERNET_TYPE_VLAN ==
482 clib_host_to_net_u16 (in_config->
tags[0].
type));
487 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
494 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
518 u32 tag1 = 0, tag2 = 0;
542 else if (
unformat (input,
"push dot1q %d %d", &tag1, &tag2))
547 else if (
unformat (input,
"push dot1ad %d %d", &tag1, &tag2))
552 else if (
unformat (input,
"push dot1q %d", &tag1))
557 else if (
unformat (input,
"push dot1ad %d", &tag1))
562 else if (
unformat (input,
"translate 1-1 dot1q %d", &tag1))
567 else if (
unformat (input,
"translate 1-1 dot1ad %d", &tag1))
572 else if (
unformat (input,
"translate 2-1 dot1q %d", &tag1))
577 else if (
unformat (input,
"translate 2-1 dot1ad %d", &tag1))
582 else if (
unformat (input,
"translate 2-2 dot1q %d %d", &tag1, &tag2))
587 else if (
unformat (input,
"translate 2-2 dot1ad %d %d", &tag1, &tag2))
592 else if (
unformat (input,
"translate 1-2 dot1q %d %d", &tag1, &tag2))
597 else if (
unformat (input,
"translate 1-2 dot1ad %d %d", &tag1, &tag2))
606 "expecting [disable | pop 1 | pop 2 | push {dot1q|dot1ah} <tag> [<tag>]\n" 607 " | translate {1|2}-{1|2} {dot1q|dot1ah} <tag> [<tag>]] but got `%U'",
612 if (
l2vtr_configure (vm, vnm, sw_if_index, vtr_op, push_dot1q, tag1, tag2))
616 "vlan tag rewrite is not compatible with interface");
678 .path =
"set interface l2 tag-rewrite",
679 .short_help =
"set interface l2 tag-rewrite <interface> [disable | pop {1|2} | push {dot1q|dot1ad} <tag> <tag>]",
691 u16 * b_vlanid,
u32 * i_sid)
696 if (!vtr_op || !outer_tag || !b_vlanid || !i_sid)
699 error = VNET_API_ERROR_INVALID_ARGUMENT;
740 clib_host_to_net_u32 (in_config->
macs_tags.
741 priority_dei_uca_res_sid) & 0xFFFFF;
759 u32 sw_if_index, tmp;
764 u8 dmac_set = 0, smac_set = 0;
773 else if (
unformat (input,
"disable"))
780 &&
unformat (input,
"translate_pbb_stag %d", &outer_tag))
786 else if (
unformat (input,
"b_vlanid %d", &tmp))
788 else if (
unformat (input,
"s_id %d", &s_id))
793 "expecting [disable | pop | push | translate_pbb_stag <outer_tag>\n" 794 "dmac <address> smac <address> s_id <nn> [b_vlanid <nn>]]");
800 && (!dmac_set || !smac_set || s_id == ~0))
803 "expecting dmac <address> smac <address> s_id <nn> [b_vlanid <nn>]");
808 (vm, vnm, sw_if_index, vtr_op, dmac, smac, b_vlanid, s_id, outer_tag))
812 "pbb tag rewrite is not compatible with interface");
822 .path =
"set interface l2 pbb-tag-rewrite",
823 .short_help =
"set interface l2 pbb-tag-rewrite <interface> [disable | pop | push | translate_pbb_stag <outer_tag> dmac <address> smac <address> s_id <nn> [b_vlanid <nn>]]",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u32 l2vtr_configure(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 vtr_op, u32 push_dot1q, u32 vtr_tag1, u32 vtr_tag2)
Configure vtag tag rewrite on the given interface.
clib_error_t * l2_vtr_init(vlib_main_t *vm)
Just a placeholder; ensures file is not eliminated by linker.
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
Per-interface vlan tag rewrite configuration There will be one instance of this struct for each sw_if...
struct vnet_sub_interface_t::@117::@118::@120 flags
#define VLIB_INIT_FUNCTION(x)
ptr_config_t output_pbb_vtr
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
l2output_main_t l2output_main
vnet_hw_interface_class_t ethernet_hw_interface_class
u32 l2pbb_configure(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 vtr_op, u8 *b_dmac, u8 *b_smac, u16 b_vlanid, u32 i_sid, u16 vlan_outer_tag)
#define clib_warning(format, args...)
#define clib_memcpy(a, b, c)
struct vnet_sub_interface_t::@117 eth
struct ptr_config_t::@163::@167 raw_data
#define VLIB_CLI_COMMAND(x,...)
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
static clib_error_t * int_l2_vtr(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set subinterface vtr enable/disable.
ptr_config_t input_pbb_vtr
ethernet_vlan_header_tv_t tags[2]
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
l2_output_config_t * configs
ethernet_pbb_header_t macs_tags
u32 l2vtr_get(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 *vtr_op, u32 *push_dot1q, u32 *vtr_tag1, u32 *vtr_tag2)
Get vtag tag rewrite on the given interface.
vnet_sw_interface_type_t type
static clib_error_t * int_l2_pbb_vtr(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set subinterface pbb vtr enable/disable.
u32 l2pbb_get(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 *vtr_op, u16 *outer_tag, ethernet_header_t *eth_hdr, u16 *b_vlanid, u32 *i_sid)
Get pbb tag rewrite on the given interface.