diff options
author | Steven <sluong@cisco.com> | 2018-05-11 11:06:23 -0700 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2018-05-25 11:46:05 +0000 |
commit | 0d88301a576191a0e330e539cf1dcb3837ee1bf6 (patch) | |
tree | 2bf42dd2935161d6cdb982371015e94a52d74e62 /src/vnet/bonding/node.c | |
parent | 0053de63ec4bf8b9bce7817f1b61c9791baf6c26 (diff) |
bond: performance harvesting
- hash is great. But it is a bit too slow for the DP. Use direct array indexing
to quickly retrieve the slave interface.
- the algorithm used by flow hash is great. But it is a bit too slow for the DP.
Use l2_hash_hash() extracted from lb_hash.h which ECMP is using. It makes use
of intrinsic crc32 instruction set.
- shortcut modulo arithmetic when the operand is 2**x (where x up to 4) to
avoid division instruction.
- special case for link count == 1 in bond_tx_fn()
- use clib_mem_unaligned to access data for the packet to avoid alignment error
- Fix some typos for packet tracing.
Change-Id: I8eae3ad497061c5473aa675ba894ee0211120d25
Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vnet/bonding/node.c')
-rw-r--r-- | src/vnet/bonding/node.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/vnet/bonding/node.c b/src/vnet/bonding/node.c index 65d3ba10470..ec251f550cf 100644 --- a/src/vnet/bonding/node.c +++ b/src/vnet/bonding/node.c @@ -90,20 +90,21 @@ bond_sw_if_index_rewrite (vlib_main_t * vm, vlib_node_runtime_t * node, if (PREDICT_TRUE (sif != 0)) { - bif = bond_get_master_by_sw_if_index (sif->group); + bif = bond_get_master_by_dev_instance (sif->bif_dev_instance); if (PREDICT_TRUE (bif != 0)) { if (PREDICT_TRUE (vec_len (bif->slaves) >= 1)) { if (PREDICT_TRUE (bif->admin_up == 1)) { - if (!ethernet_frame_is_tagged (ntohs (eth->type))) + ethertype = clib_mem_unaligned (ð->type, u16); + if (!ethernet_frame_is_tagged (ntohs (ethertype))) { // Let some layer2 packets pass through. - if (PREDICT_TRUE ((eth->type != + if (PREDICT_TRUE ((ethertype != htons (ETHERNET_TYPE_SLOW_PROTOCOLS)) && !packet_is_cdp (eth) - && (eth->type != + && (ethertype != htons (ETHERNET_TYPE_802_1_LLDP)))) { @@ -128,12 +129,13 @@ bond_sw_if_index_rewrite (vlib_main_t * vm, vlib_node_runtime_t * node, { vlan = (void *) (eth + 1); ethertype_p = &vlan->type; - if (*ethertype_p == ntohs (ETHERNET_TYPE_VLAN)) + ethertype = clib_mem_unaligned (ethertype_p, u16); + if (ethertype == ntohs (ETHERNET_TYPE_VLAN)) { vlan++; ethertype_p = &vlan->type; } - ethertype = *ethertype_p; + ethertype = clib_mem_unaligned (ethertype_p, u16); if (PREDICT_TRUE ((ethertype != htons (ETHERNET_TYPE_SLOW_PROTOCOLS)) && (ethertype != @@ -226,10 +228,10 @@ bond_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, b6 = vlib_get_buffer (vm, from[6]); b7 = vlib_get_buffer (vm, from[7]); - vlib_prefetch_buffer_header (b4, STORE); - vlib_prefetch_buffer_header (b5, STORE); - vlib_prefetch_buffer_header (b6, STORE); - vlib_prefetch_buffer_header (b7, STORE); + vlib_prefetch_buffer_header (b4, LOAD); + vlib_prefetch_buffer_header (b5, LOAD); + vlib_prefetch_buffer_header (b6, LOAD); + vlib_prefetch_buffer_header (b7, LOAD); CLIB_PREFETCH (b4->data, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (b5->data, CLIB_CACHE_LINE_BYTES, LOAD); @@ -314,7 +316,7 @@ bond_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, if (PREDICT_TRUE (n_trace > 0)) { - vlib_trace_buffer (vm, node, next1, b2, + vlib_trace_buffer (vm, node, next2, b2, 0 /* follow_chain */ ); vlib_set_trace_count (vm, node, --n_trace); t0 = vlib_add_trace (vm, node, b2, sizeof (*t0)); @@ -325,7 +327,7 @@ bond_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, if (PREDICT_TRUE (n_trace > 0)) { - vlib_trace_buffer (vm, node, next1, b2, + vlib_trace_buffer (vm, node, next3, b3, 0 /* follow_chain */ ); vlib_set_trace_count (vm, node, --n_trace); t0 = vlib_add_trace (vm, node, b3, sizeof (*t0)); @@ -358,7 +360,7 @@ bond_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_buffer_t *p2; p2 = vlib_get_buffer (vm, from[1]); - vlib_prefetch_buffer_header (p2, STORE); + vlib_prefetch_buffer_header (p2, LOAD); CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, LOAD); } |