summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhiyong Yang <zhiyong.yang@intel.com>2020-04-23 15:21:30 +0000
committerJohn Lo <loj@cisco.com>2020-04-27 15:31:48 +0000
commitba6deb96e923f71aa9387c06000412c3fb1362fa (patch)
treeb4027e4a59b077ff5144c021280b7962970d4a73
parent6d6711b5f0b3a6e809822f5f9f67744718166143 (diff)
l2: merge two clib_memcpy_fast into one
Merge two memcpy into one by swapping src and dst address in l2fwd_trace_t. Type: improvement Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com> Change-Id: I71c5ecad0b453a434b1cb292ef03d88a760255c8
-rw-r--r--src/vnet/l2/l2_fwd.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/vnet/l2/l2_fwd.c b/src/vnet/l2/l2_fwd.c
index 93e69db31e9..f440778417f 100644
--- a/src/vnet/l2/l2_fwd.c
+++ b/src/vnet/l2/l2_fwd.c
@@ -61,8 +61,8 @@ typedef struct
typedef struct
{
/* per-pkt trace data */
- u8 src[6];
u8 dst[6];
+ u8 src[6];
u32 sw_if_index;
u16 bd_index;
l2fib_entry_result_t result;
@@ -324,8 +324,9 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (b[0])->l2.bd_index;
- clib_memcpy_fast (t->src, h0->src_address, 6);
- clib_memcpy_fast (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address,
+ sizeof (h0->dst_address) +
+ sizeof (h0->src_address));
t->result = result0;
}
if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
@@ -333,8 +334,9 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[1], sizeof (*t));
t->sw_if_index = sw_if_index1;
t->bd_index = vnet_buffer (b[1])->l2.bd_index;
- clib_memcpy_fast (t->src, h1->src_address, 6);
- clib_memcpy_fast (t->dst, h1->dst_address, 6);
+ clib_memcpy_fast (t->dst, h1->dst_address,
+ sizeof (h1->dst_address) +
+ sizeof (h1->src_address));
t->result = result1;
}
if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
@@ -342,8 +344,9 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[2], sizeof (*t));
t->sw_if_index = sw_if_index2;
t->bd_index = vnet_buffer (b[2])->l2.bd_index;
- clib_memcpy_fast (t->src, h2->src_address, 6);
- clib_memcpy_fast (t->dst, h2->dst_address, 6);
+ clib_memcpy_fast (t->dst, h2->dst_address,
+ sizeof (h2->dst_address) +
+ sizeof (h2->src_address));
t->result = result2;
}
if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
@@ -351,8 +354,9 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[3], sizeof (*t));
t->sw_if_index = sw_if_index3;
t->bd_index = vnet_buffer (b[3])->l2.bd_index;
- clib_memcpy_fast (t->src, h3->src_address, 6);
- clib_memcpy_fast (t->dst, h3->dst_address, 6);
+ clib_memcpy_fast (t->dst, h3->dst_address,
+ sizeof (h3->dst_address) +
+ sizeof (h3->src_address));
t->result = result3;
}
}
@@ -387,8 +391,9 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (b[0])->l2.bd_index;
- clib_memcpy_fast (t->src, h0->src_address, 6);
- clib_memcpy_fast (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address,
+ sizeof (h0->dst_address) +
+ sizeof (h0->src_address));
t->result = result0;
}