diff mbox series

[v3,2/10] linux-generic: packet: add packet fields needed for references

Message ID 1501599610-28388-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v3,1/10] linux-generic: packet: restructure inline routines to use macros | expand

Commit Message

Github ODP bot Aug. 1, 2017, 3 p.m. UTC
From: Bill Fischofer <bill.fischofer@linaro.org>


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>

---
/** Email created from pull request 90 (Bill-Fischofer-Linaro:pktrefs)
 ** https://github.com/Linaro/odp/pull/90
 ** Patch: https://github.com/Linaro/odp/pull/90.patch
 ** Base sha: bb0ca193f8c28036fdf8b3d6c8aa5d4f11980e6c
 ** Merge commit sha: dfef320840f96825686124135a6e509db80b7b82
 **/
 .../linux-generic/include/odp/api/plat/packet_types.h     |  8 ++++++++
 platform/linux-generic/include/odp_packet_internal.h      | 15 ++++++++++++++-
 platform/linux-generic/odp_packet.c                       |  4 ++++
 3 files changed, 26 insertions(+), 1 deletion(-)
diff mbox series

Patch

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 41468bec..1554c3af 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_types.h
@@ -84,6 +84,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 f77987c8..0542dd10 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -106,7 +106,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;
 
@@ -122,6 +122,19 @@  typedef struct {
 	uint32_t headroom;
 	uint32_t tailroom;
 
+	/* Fields used to support packet references */
+	uint32_t unshared_len;
+	/* Next pkt_hdr in reference chain */
+	struct odp_packet_hdr_t *ref_hdr;
+	/* Offset into next pkt_hdr that ref was created at */
+	uint32_t ref_offset;
+	/* frame_len in next pkt_hdr at time ref was created. This
+	 * allows original offset to be maintained when base pkt len
+	 * is changed */
+	uint32_t ref_len;
+	/* Incremented on refs, decremented on frees. */
+	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 dbde7280..af8c442e 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -33,6 +33,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),