summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEyal Bari <ebari@cisco.com>2017-06-13 08:42:35 +0300
committerJohn Lo <loj@cisco.com>2017-07-07 16:40:01 +0000
commit9a1ae1ac76ca43e799e8281da1177c186e49d4f7 (patch)
tree5c7281da8e879e66826f81ed91c8a83738c0b555 /src
parent7968e6cad5fac28568162945e2e57556740013fd (diff)
ETH:optimized double is_tagged check
a double version of is_tagged, uses "free lanes" in _mm_cmpeq_epi16 to check a second tag this code was not yet tested for performance Change-Id: I640017e1cc75c85a33d196ee911a7e4a512d9849 Signed-off-by: Eyal Bari <ebari@cisco.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/vnet/ethernet/node.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/vnet/ethernet/node.c b/src/vnet/ethernet/node.c
index 4529ca6a572..ce5b2c5bea7 100755
--- a/src/vnet/ethernet/node.c
+++ b/src/vnet/ethernet/node.c
@@ -285,6 +285,29 @@ determine_next_node (ethernet_main_t * em,
}
}
+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_istagged (type1);
+#endif
+}
+
static_always_inline uword
ethernet_input_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
@@ -377,8 +400,7 @@ ethernet_input_inline (vlib_main_t * vm,
/* 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;