[PATCHv2,04/11] linux-generic: packet: add packet fields needed for references

Message ID 20170312123045.3852-5-bill.fischofer@linaro.org
State New
Headers show
Series
  • Optimized Packet References
Related show

Commit Message

Bill Fischofer March 12, 2017, 12:30 p.m.
Add new fields to the odp_packet_hdr_t used for support of zero-copy
references. Also added are the offsets needed to access them from
inlined functions.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
 platform/linux-generic/include/odp/api/plat/packet_types.h | 8 ++++++++
 platform/linux-generic/include/odp_packet_internal.h       | 9 ++++++++-
 platform/linux-generic/odp_packet.c                        | 4 ++++
 3 files changed, 20 insertions(+), 1 deletion(-)

-- 
2.12.0.rc1

Patch hide | download patch | download mbox

diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h b/platform/linux-generic/include/odp/api/plat/packet_types.h
index b8f665d2..16e4b467 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_types.h
@@ -70,6 +70,14 @@  typedef struct _odp_packet_inline_offset_t {
 	/** @internal field offset */
 	size_t tailroom;
 	/** @internal field offset */
+	size_t unshared_len;
+	/** @internal field offset */
+	size_t ref_hdr;
+	/** @internal field offset */
+	size_t ref_offset;
+	/** *internal field offset */
+	size_t ref_len;
+	/** @internal field offset */
 	size_t pool;
 	/** @internal field offset */
 	size_t input;
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 589e204a..31d46df4 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -119,7 +119,7 @@  typedef struct {
  * packet_init(). Because of this any new fields added must be reviewed for
  * initialization requirements.
  */
-typedef struct {
+typedef struct odp_packet_hdr_t {
 	/* common buffer header */
 	odp_buffer_hdr_t buf_hdr;
 
@@ -135,6 +135,13 @@  typedef struct {
 	uint32_t headroom;
 	uint32_t tailroom;
 
+	/* Fields used to support packet references */
+	uint32_t unshared_len;
+	struct odp_packet_hdr_t *ref_hdr;
+	uint32_t ref_offset;
+	uint32_t ref_len;
+	odp_atomic_u32_t ref_count;
+
 	/*
 	 * Members below are not initialized by packet_init()
 	 */
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index d0f76332..067d0fcb 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -31,6 +31,10 @@  const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
 	.frame_len      = offsetof(odp_packet_hdr_t, frame_len),
 	.headroom       = offsetof(odp_packet_hdr_t, headroom),
 	.tailroom       = offsetof(odp_packet_hdr_t, tailroom),
+	.unshared_len   = offsetof(odp_packet_hdr_t, unshared_len),
+	.ref_hdr        = offsetof(odp_packet_hdr_t, ref_hdr),
+	.ref_offset     = offsetof(odp_packet_hdr_t, ref_offset),
+	.ref_len        = offsetof(odp_packet_hdr_t, ref_len),
 	.pool           = offsetof(odp_packet_hdr_t, buf_hdr.pool_hdl),
 	.input          = offsetof(odp_packet_hdr_t, input),
 	.segcount       = offsetof(odp_packet_hdr_t, buf_hdr.segcount),