diff mbox

[v2,4/5] linux-generic: buffer: ifdef ipc_addr_offset member from odp_buffer_hdr_t

Message ID 1463392220-22856-5-git-send-email-matias.elo@nokia.com
State Accepted
Commit b41d91453dd73cc377e0ae2317520e459f394b19
Headers show

Commit Message

Elo, Matias (Nokia - FI/Espoo) May 16, 2016, 9:50 a.m. UTC
Define ipc_addr_offset member of struct odp_buffer_hdr_t
only if ipc pktio is enabled to reduce struct size.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
---
 platform/linux-generic/include/odp_buffer_internal.h |  8 +++++---
 platform/linux-generic/pktio/ipc.c                   | 13 +++++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h
index 727abb4..47f41c6 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -132,9 +132,6 @@  struct odp_buffer_hdr_t {
 	uint32_t                 uarea_size; /* size of user area */
 	uint32_t                 segcount;   /* segment count */
 	uint32_t                 segsize;    /* segment size */
-	/* ipc mapped process can not walk over pointers,
-	 * offset has to be used */
-	uint64_t		 ipc_addr_offset[ODP_BUFFER_MAX_SEG];
 	void                    *addr[ODP_BUFFER_MAX_SEG]; /* block addrs */
 	uint64_t                 order;      /* sequence for ordered queues */
 	queue_entry_t           *origin_qe;  /* ordered queue origin */
@@ -142,6 +139,11 @@  struct odp_buffer_hdr_t {
 		queue_entry_t   *target_qe;  /* ordered queue target */
 		uint64_t         sync[ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE];
 	};
+#ifdef _ODP_PKTIO_IPC
+	/* ipc mapped process can not walk over pointers,
+	 * offset has to be used */
+	uint64_t		 ipc_addr_offset[ODP_BUFFER_MAX_SEG];
+#endif
 };
 
 /** @internal Compile time assert that the
diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c
index 12cc286..f1cd21c 100644
--- a/platform/linux-generic/pktio/ipc.c
+++ b/platform/linux-generic/pktio/ipc.c
@@ -436,8 +436,15 @@  static inline void *_ipc_buffer_map(odp_buffer_hdr_t *buf,
 {
 	int seg_index  = offset / buf->segsize;
 	int seg_offset = offset % buf->segsize;
+#ifdef _ODP_PKTIO_IPC
 	void *addr = (char *)buf - buf->ipc_addr_offset[seg_index];
+#else
+	/** buf_hdr.ipc_addr_offset defined only when ipc is
+	 *  enabled. */
+	void *addr = NULL;
 
+	(void)seg_index;
+#endif
 	if (seglen) {
 		uint32_t buf_left = limit - offset;
 		*seglen = seg_offset + buf_left <= buf->segsize ?
@@ -631,8 +638,14 @@  static int ipc_pktio_send(pktio_entry_t *pktio_entry,
 		 * convert it to offset
 		 */
 		for (j = 0; j < ODP_BUFFER_MAX_SEG; j++) {
+#ifdef _ODP_PKTIO_IPC
 			pkt_hdr->buf_hdr.ipc_addr_offset[j] = (char *)pkt_hdr -
 				(char *)pkt_hdr->buf_hdr.addr[j];
+#else
+			/** buf_hdr.ipc_addr_offset defined only when ipc is
+			 *  enabled. */
+			(void)pkt_hdr;
+#endif
 		}
 	}