aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-10-22 13:07:02 +0200
committerDamjan Marion <dmarion@me.com>2018-10-22 13:01:19 +0000
commit8f49936b20508d57968f01dcb18f8d31b1a58f3f (patch)
treeedb3ee5da2457b345274f69eab70d05123ada08e /src/vlib
parent6f3f1cbf7760efb17c5754c3dbccdefd433675cb (diff)
vlib: introduce vlib_buffer_get_{pa,va,current_va,current_pa} inlines
Change-Id: I0b42ac6b05bc9910904a97924ea4bebc84507d4d Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/buffer.h12
-rw-r--r--src/vlib/buffer_funcs.h13
2 files changed, 20 insertions, 5 deletions
diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h
index 651e7f0dc8f..0d24779e52b 100644
--- a/src/vlib/buffer.h
+++ b/src/vlib/buffer.h
@@ -187,6 +187,12 @@ vlib_buffer_struct_is_sane (vlib_buffer_t * b)
ASSERT (b->pre_data + VLIB_BUFFER_PRE_DATA_SIZE == b->data);
}
+always_inline uword
+vlib_buffer_get_va (vlib_buffer_t * b)
+{
+ return pointer_to_uword (b->data);
+}
+
/** \brief Get pointer to current data to process
@param b - (vlib_buffer_t *) pointer to the buffer
@@ -201,6 +207,12 @@ vlib_buffer_get_current (vlib_buffer_t * b)
return b->data + b->current_data;
}
+always_inline uword
+vlib_buffer_get_current_va (vlib_buffer_t * b)
+{
+ return vlib_buffer_get_va (b) + b->current_data;
+}
+
/** \brief Advance current data pointer by the supplied (signed!) amount
@param b - (vlib_buffer_t *) pointer to the buffer
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h
index 438bf7e5ee4..1110c206e52 100644
--- a/src/vlib/buffer_funcs.h
+++ b/src/vlib/buffer_funcs.h
@@ -314,18 +314,21 @@ vlib_buffer_contents (vlib_main_t * vm, u32 buffer_index, u8 * contents)
return content_len;
}
-/* Return physical address of buffer->data start. */
-always_inline u64
-vlib_get_buffer_data_physical_address (vlib_main_t * vm, u32 buffer_index)
+always_inline uword
+vlib_buffer_get_pa (vlib_main_t * vm, vlib_buffer_t * b)
{
vlib_buffer_main_t *bm = &buffer_main;
- vlib_buffer_t *b = vlib_get_buffer (vm, buffer_index);
vlib_buffer_pool_t *pool = vec_elt_at_index (bm->buffer_pools,
b->buffer_pool_index);
-
return vlib_physmem_virtual_to_physical (vm, pool->physmem_region, b->data);
}
+always_inline uword
+vlib_buffer_get_current_pa (vlib_main_t * vm, vlib_buffer_t * b)
+{
+ return vlib_buffer_get_pa (vm, b) + b->current_data;
+}
+
/** \brief Prefetch buffer metadata by buffer index
The first 64 bytes of buffer contains most header information