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;
238 in_config->
tags[1].
type = push_outer_et;
245 in_config->
tags[0].
type = push_outer_et;
247 in_config->
tags[1].
type = push_inner_et;
253 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
259 in_config->
tags[1].
type = push_outer_et;
265 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
271 in_config->
tags[0].
type = push_outer_et;
273 in_config->
tags[1].
type = push_inner_et;
279 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
285 in_config->
tags[1].
type = push_outer_et;
291 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
297 in_config->
tags[0].
type = push_outer_et;
299 in_config->
tags[1].
type = push_inner_et;
313 clib_net_to_host_u16 (si->
sub.
eth.
flags.dot1ad ? ETHERNET_TYPE_DOT1AD :
315 push_inner_et = clib_net_to_host_u16 (ETHERNET_TYPE_VLAN);
322 out_config->
tags[1].
type = push_outer_et;
327 out_config->
tags[0].
type = push_outer_et;
329 out_config->
tags[1].
type = push_inner_et;
355 if (!vtr_op || !push_dot1q || !vtr_tag1 || !vtr_tag2)
358 error = VNET_API_ERROR_INVALID_ARGUMENT;
404 (ETHERNET_TYPE_VLAN ==
405 clib_host_to_net_u16 (in_config->
tags[1].
type));
414 (ETHERNET_TYPE_VLAN ==
415 clib_host_to_net_u16 (in_config->
tags[0].
type));
420 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
436 (ETHERNET_TYPE_VLAN ==
437 clib_host_to_net_u16 (in_config->
tags[1].
type));
446 (ETHERNET_TYPE_VLAN ==
447 clib_host_to_net_u16 (in_config->
tags[0].
type));
452 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
468 (ETHERNET_TYPE_VLAN ==
469 clib_host_to_net_u16 (in_config->
tags[1].
type));
478 (ETHERNET_TYPE_VLAN ==
479 clib_host_to_net_u16 (in_config->
tags[0].
type));
484 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
491 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
515 u32 tag1 = 0, tag2 = 0;
539 else if (
unformat (input,
"push dot1q %d %d", &tag1, &tag2))
544 else if (
unformat (input,
"push dot1ad %d %d", &tag1, &tag2))
549 else if (
unformat (input,
"push dot1q %d", &tag1))
554 else if (
unformat (input,
"push dot1ad %d", &tag1))
559 else if (
unformat (input,
"translate 1-1 dot1q %d", &tag1))
564 else if (
unformat (input,
"translate 1-1 dot1ad %d", &tag1))
569 else if (
unformat (input,
"translate 2-1 dot1q %d", &tag1))
574 else if (
unformat (input,
"translate 2-1 dot1ad %d", &tag1))
579 else if (
unformat (input,
"translate 2-2 dot1q %d %d", &tag1, &tag2))
584 else if (
unformat (input,
"translate 2-2 dot1ad %d %d", &tag1, &tag2))
589 else if (
unformat (input,
"translate 1-2 dot1q %d %d", &tag1, &tag2))
594 else if (
unformat (input,
"translate 1-2 dot1ad %d %d", &tag1, &tag2))
603 "expecting [disable | pop 1 | pop 2 | push {dot1q|dot1ah} <tag> [<tag>]\n" 604 " | translate {1|2}-{1|2} {dot1q|dot1ah} <tag> [<tag>]] but got `%U'",
609 if (
l2vtr_configure (vm, vnm, sw_if_index, vtr_op, push_dot1q, tag1, tag2))
613 "vlan tag rewrite is not compatible with interface");
675 .path =
"set interface l2 tag-rewrite",
676 .short_help =
"set interface l2 tag-rewrite <interface> [disable | pop {1|2} | push {dot1q|dot1ad} <tag> <tag>]",
688 u16 * b_vlanid,
u32 * i_sid)
693 if (!vtr_op || !outer_tag || !b_vlanid || !i_sid)
696 error = VNET_API_ERROR_INVALID_ARGUMENT;
737 clib_host_to_net_u32 (in_config->
macs_tags.
738 priority_dei_uca_res_sid) & 0xFFFFF;
756 u32 sw_if_index, tmp;
761 u8 dmac_set = 0, smac_set = 0;
770 else if (
unformat (input,
"disable"))
777 &&
unformat (input,
"translate_pbb_stag %d", &outer_tag))
783 else if (
unformat (input,
"b_vlanid %d", &tmp))
785 else if (
unformat (input,
"s_id %d", &s_id))
790 "expecting [disable | pop | push | translate_pbb_stag <outer_tag>\n" 791 "dmac <address> smac <address> s_id <nn> [b_vlanid <nn>]]");
797 && (!dmac_set || !smac_set || s_id == ~0))
800 "expecting dmac <address> smac <address> s_id <nn> [b_vlanid <nn>]");
805 (vm, vnm, sw_if_index, vtr_op, dmac, smac, b_vlanid, s_id, outer_tag))
809 "pbb tag rewrite is not compatible with interface");
819 .path =
"set interface l2 pbb-tag-rewrite",
820 .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) ...
struct vnet_sub_interface_t::@153 eth
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...
#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 ptr_config_t::@199::@203 raw_data
#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.
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
ptr_config_t input_pbb_vtr
ethernet_vlan_header_tv_t tags[2]
struct vnet_sub_interface_t::@153::@154::@156 flags
#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.