diff options
author | Benoît Ganne <bganne@cisco.com> | 2019-03-01 14:14:10 +0100 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2019-03-26 10:06:57 +0000 |
commit | 4af1a7f938207f713c249270ed98a0c12f72cd3f (patch) | |
tree | 42c93b22e20228641de844d553819f400676cc5e /src/vnet/adj/rewrite.c | |
parent | 50d5069a80fd763f4270d61d991febbdfa88aed3 (diff) |
Simplify adjacency rewrite code
Using memcpy instead of complex specific copy logic. This simplify
the implementation and also improve perf slightly.
Also move adjacency data from tail to head of buffer, which improves
cache locality (header and data share the same cacheline)
Finally, fix VxLAN which used to workaround vnet_rewrite logic.
Change-Id: I770ddad9846f7ee505aa99ad417e6a61d5cbbefa
Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vnet/adj/rewrite.c')
-rw-r--r-- | src/vnet/adj/rewrite.c | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/src/vnet/adj/rewrite.c b/src/vnet/adj/rewrite.c index 975dc4ab817..95671b06930 100644 --- a/src/vnet/adj/rewrite.c +++ b/src/vnet/adj/rewrite.c @@ -40,30 +40,6 @@ #include <vnet/vnet.h> #include <vnet/ip/lookup.h> -void -vnet_rewrite_copy_slow_path (vnet_rewrite_data_t * p0, - vnet_rewrite_data_t * rw0, - word n_left, uword most_likely_size) -{ - uword n_done = - round_pow2 (most_likely_size, sizeof (rw0[0])) / sizeof (rw0[0]); - - p0 -= n_done; - rw0 -= n_done; - - /* As we enter the cleanup loop, p0 and rw0 point to the last chunk written - by the fast path. Hence, the constant 1, which the - vnet_rewrite_copy_one macro renders as p0[-1] = rw0[-1]. */ - - while (n_left > 0) - { - vnet_rewrite_copy_one (p0, rw0, 1); - p0--; - rw0--; - n_left--; - } -} - u8 * format_vnet_rewrite (u8 * s, va_list * args) { @@ -72,6 +48,8 @@ format_vnet_rewrite (u8 * s, va_list * args) CLIB_UNUSED (u32 indent) = va_arg (*args, u32); vnet_main_t *vnm = vnet_get_main (); + ASSERT (rw->data_bytes <= max_data_bytes); + if (rw->sw_if_index != ~0) { vnet_sw_interface_t *si; @@ -86,9 +64,7 @@ format_vnet_rewrite (u8 * s, va_list * args) /* Format rewrite string. */ if (rw->data_bytes > 0) - s = format (s, " %U", - format_hex_bytes, - rw->data + max_data_bytes - rw->data_bytes, rw->data_bytes); + s = format (s, " %U", format_hex_bytes, rw->data, rw->data_bytes); return s; } |