diff options
author | Andreas Schultz <andreas.schultz@travelping.com> | 2019-07-15 15:40:56 +0200 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2019-07-18 15:07:26 +0000 |
commit | 58b2eb1af562c292feb6d3cdce4656746e61da75 (patch) | |
tree | ba2d239dd4a2d4673ef1352143d1133a9f88ccd4 /src/vlib/node_funcs.h | |
parent | a0cb32cb9fba93ec4b91e7d227c07d1b2099091b (diff) |
vlib: convert frame_index into real pointers
The fast path almost always has to deal with the real
pointers. Deriving the frame pointer from a frame_index requires a
load of the 32bit frame_index from memory, another 64bit load of the
heap base pointer and some calculations.
Lets store the full pointer instead and do a single 64bit load only.
This helps avoiding problems when the heap is grown and frames are
allocated below vm->heap_aligned_base.
Type: refactor
Change-Id: Ifa6e6e984aafe1e2755bff80f0a4dfcddee3623c
Signed-off-by: Andreas Schultz <andreas.schultz@travelping.com>
Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlib/node_funcs.h')
-rw-r--r-- | src/vlib/node_funcs.h | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h index c9ff93d6124..d6d04fb16c2 100644 --- a/src/vlib/node_funcs.h +++ b/src/vlib/node_funcs.h @@ -212,32 +212,10 @@ vlib_get_process_from_node (vlib_main_t * vm, vlib_node_t * node) return vec_elt (nm->processes, node->runtime_index); } -/* Fetches frame with given handle. */ always_inline vlib_frame_t * -vlib_get_frame_no_check (vlib_main_t * vm, uword frame_index) +vlib_get_frame (vlib_main_t * vm, vlib_frame_t * f) { - vlib_frame_t *f; - f = vm->heap_aligned_base + (frame_index * VLIB_FRAME_ALIGN); - return f; -} - -always_inline u32 -vlib_frame_index_no_check (vlib_main_t * vm, vlib_frame_t * f) -{ - uword i; - - ASSERT (((uword) f & (VLIB_FRAME_ALIGN - 1)) == 0); - - i = ((u8 *) f - (u8 *) vm->heap_aligned_base); - ASSERT ((i / VLIB_FRAME_ALIGN) <= 0xFFFFFFFFULL); - - return i / VLIB_FRAME_ALIGN; -} - -always_inline vlib_frame_t * -vlib_get_frame (vlib_main_t * vm, uword frame_index) -{ - vlib_frame_t *f = vlib_get_frame_no_check (vm, frame_index); + ASSERT (f != NULL); ASSERT (f->frame_flags & VLIB_FRAME_IS_ALLOCATED); return f; } @@ -248,14 +226,6 @@ vlib_frame_no_append (vlib_frame_t * f) f->frame_flags |= VLIB_FRAME_NO_APPEND; } -always_inline u32 -vlib_frame_index (vlib_main_t * vm, vlib_frame_t * f) -{ - uword i = vlib_frame_index_no_check (vm, f); - ASSERT (vlib_get_frame (vm, i) == f); - return i; -} - /* Byte alignment for vector arguments. */ #define VLIB_FRAME_VECTOR_ALIGN (1 << 4) |