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>]",
695 u32 sw_if_index, tmp;
700 u8 dmac_set = 0, smac_set = 0;
709 else if (
unformat (input,
"disable"))
716 &&
unformat (input,
"translate_pbb_stag %d", &outer_tag))
722 else if (
unformat (input,
"b_vlanid %d", &tmp))
724 else if (
unformat (input,
"s_id %d", &s_id))
729 "expecting [disable | pop | push | translate_pbb_stag <outer_tag>\n" 730 "dmac <address> smac <address> s_id <nn> [b_vlanid <nn>]]");
736 && (!dmac_set || !smac_set || s_id == ~0))
739 "expecting dmac <address> smac <address> s_id <nn> [b_vlanid <nn>]");
744 (vm, vnm, sw_if_index, vtr_op, dmac, smac, b_vlanid, s_id, outer_tag))
748 "pbb tag rewrite is not compatible with interface");
758 .path =
"set interface l2 pbb-tag-rewrite",
759 .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.
struct ptr_config_t::@206::@210 raw_data
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...
vnet_main_t * vnet_get_main(void)
#define VLIB_INIT_FUNCTION(x)
struct vnet_sub_interface_t::@154::@155::@157 flags
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_warning(format, args...)
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
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_memcpy(a, b, c)
#define VLIB_CLI_COMMAND(x,...)
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)
struct vnet_sub_interface_t::@154 eth
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.
#define clib_error_return(e, args...)