tag = clib_net_to_host_u16 (h0->priority_cfi_and_id);
*outer_id = tag & 0xfff;
+ if (0 == *outer_id)
+ *match_flags &= ~SUBINT_CONFIG_MATCH_1_TAG;
*type = clib_net_to_host_u16 (h0->type);
vlib_buffer_advance (b0, sizeof (h0[0]));
vlan_count = 2;
-
if (*type == ETHERNET_TYPE_VLAN)
{
// More than double tagged packet
*match_flags = SUBINT_CONFIG_VALID | SUBINT_CONFIG_MATCH_3_TAG;
+
+ vlib_buffer_advance (b0, sizeof (h0[0]));
vlan_count = 3; // "unknown" number, aka, 3-or-more
}
}
// record the L2 len and reset the buffer so the L2 header is preserved
u32 eth_start = vnet_buffer (b0)->ethernet.start_of_ethernet_header;
vnet_buffer (b0)->l2.l2_len = b0->current_data - eth_start;
+ ASSERT (vnet_buffer (b0)->l2.l2_len ==
+ ethernet_buffer_header_size (b0));
vlib_buffer_advance (b0, -ethernet_buffer_header_size (b0));
// check for common IP/MPLS ethertypes
}
}
+static_always_inline int
+ethernet_frame_is_any_tagged (u16 type0, u16 type1)
+{
+#if __SSE4_2__
+ const __m128i ethertype_mask = _mm_set_epi16 (ETHERNET_TYPE_VLAN,
+ ETHERNET_TYPE_DOT1AD,
+ ETHERNET_TYPE_VLAN_9100,
+ ETHERNET_TYPE_VLAN_9200,
+ /* duplicate for type1 */
+ ETHERNET_TYPE_VLAN,
+ ETHERNET_TYPE_DOT1AD,
+ ETHERNET_TYPE_VLAN_9100,
+ ETHERNET_TYPE_VLAN_9200);
+
+ __m128i r =
+ _mm_set_epi16 (type0, type0, type0, type0, type1, type1, type1, type1);
+ r = _mm_cmpeq_epi16 (ethertype_mask, r);
+ return !_mm_test_all_zeros (r, r);
+#else
+ return ethernet_frame_is_tagged (type0) || ethernet_frame_is_tagged (type1);
+#endif
+}
+
static_always_inline uword
ethernet_input_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
/* Speed-path for the untagged case */
if (PREDICT_TRUE (variant == ETHERNET_INPUT_VARIANT_ETHERNET
- && !ethernet_frame_is_tagged (type0)
- && !ethernet_frame_is_tagged (type1)))
+ && !ethernet_frame_is_any_tagged (type0, type1)))
{
main_intf_t *intf0;
subint_config_t *subint0;