[API-NEXT,v1,1/5] linux-gen: packet: single user ptr field

Message ID 1515772811-30441-2-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series
  • User pointer init to NULL
Related show

Commit Message

Github ODP bot Jan. 12, 2018, 4 p.m.
From: Petri Savolainen <petri.savolainen@linaro.org>


Remove unnecessary union of user context u64/pointer. Rename
the field for better code readability.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 388 (psavol:next-user-ptr-init)
 ** https://github.com/Linaro/odp/pull/388
 ** Patch: https://github.com/Linaro/odp/pull/388.patch
 ** Base sha: 6303c7d0e98fafe0f14c8c4dd9989b3b7633ebf4
 ** Merge commit sha: 9eaabe631329dd5cc41960f7cfb5592d60ff0499
 **/
 platform/linux-generic/include/odp_buffer_internal.h |  8 +-------
 platform/linux-generic/odp_packet.c                  | 10 +++++-----
 2 files changed, 6 insertions(+), 12 deletions(-)

Patch

diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h
index c56c5b01b..5252dc808 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -84,13 +84,7 @@  struct odp_buffer_hdr_t {
 	struct odp_buffer_hdr_t *burst[BUFFER_BURST_SIZE];
 
 	/* --- Mostly read only data --- */
-
-	/* User context pointer or u64 */
-	union {
-		uint64_t    buf_u64;
-		void       *buf_ctx;
-		const void *buf_cctx; /* const alias for ctx */
-	};
+	const void *user_ptr;
 
 	/* Reference count */
 	odp_atomic_u32_t ref_cnt;
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 83a880947..2a977f064 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -35,7 +35,7 @@  const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
 	.pool           = offsetof(odp_packet_hdr_t, buf_hdr.pool_ptr),
 	.input          = offsetof(odp_packet_hdr_t, input),
 	.segcount       = offsetof(odp_packet_hdr_t, buf_hdr.segcount),
-	.user_ptr       = offsetof(odp_packet_hdr_t, buf_hdr.buf_ctx),
+	.user_ptr       = offsetof(odp_packet_hdr_t, buf_hdr.user_ptr),
 	.user_area      = offsetof(odp_packet_hdr_t, buf_hdr.uarea_addr),
 	.l2_offset      = offsetof(odp_packet_hdr_t, p.l2_offset),
 	.l3_offset      = offsetof(odp_packet_hdr_t, p.l3_offset),
@@ -265,7 +265,7 @@  static inline void packet_seg_copy_md(odp_packet_hdr_t *dst,
 	dst->timestamp = src->timestamp;
 
 	/* buffer header side packet metadata */
-	dst->buf_hdr.buf_u64    = src->buf_hdr.buf_u64;
+	dst->buf_hdr.user_ptr   = src->buf_hdr.user_ptr;
 	dst->buf_hdr.uarea_addr = src->buf_hdr.uarea_addr;
 
 	/* segmentation data is not copied:
@@ -1258,9 +1258,9 @@  int odp_packet_input_index(odp_packet_t pkt)
 	return odp_pktio_index(packet_hdr(pkt)->input);
 }
 
-void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ctx)
+void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ptr)
 {
-	packet_hdr(pkt)->buf_hdr.buf_cctx = ctx;
+	packet_hdr(pkt)->buf_hdr.user_ptr = ptr;
 }
 
 int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset)
@@ -1931,7 +1931,7 @@  int _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, odp_packet_t dstpkt)
 
 	dsthdr->input = srchdr->input;
 	dsthdr->dst_queue = srchdr->dst_queue;
-	dsthdr->buf_hdr.buf_u64 = srchdr->buf_hdr.buf_u64;
+	dsthdr->buf_hdr.user_ptr = srchdr->buf_hdr.user_ptr;
 	if (dsthdr->buf_hdr.uarea_addr != NULL &&
 	    srchdr->buf_hdr.uarea_addr != NULL) {
 		memcpy(dsthdr->buf_hdr.uarea_addr, srchdr->buf_hdr.uarea_addr,