[1/3] linux-gen: pool: combine duplicate struct pool_t members

Message ID 1496216614-1147-1-git-send-email-matias.elo@nokia.com
State New
Headers show
Series
  • [1/3] linux-gen: pool: combine duplicate struct pool_t members
Related show

Commit Message

Elo, Matias (Nokia - FI/Espoo) May 31, 2017, 7:43 a.m.
Struct pool_t members 'data_size' and 'max_seg_len' were both used to store
the same value. Replace them with a single 'seg_len' member.

Signed-off-by: Matias Elo <matias.elo@nokia.com>

---
 platform/linux-generic/include/odp_pool_internal.h |  3 +--
 platform/linux-generic/odp_packet.c                |  6 ++---
 platform/linux-generic/odp_pool.c                  | 28 ++++++++++------------
 platform/linux-generic/pktio/socket_mmap.c         |  2 +-
 4 files changed, 17 insertions(+), 22 deletions(-)

-- 
2.7.4

Patch hide | download patch | download mbox

diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h
index ebb779d..9d943e6 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -58,9 +58,8 @@  typedef struct pool_t {
 	uint32_t         align;
 	uint32_t         headroom;
 	uint32_t         tailroom;
-	uint32_t         data_size;
+	uint32_t         seg_len;
 	uint32_t         max_len;
-	uint32_t         max_seg_len;
 	uint32_t         uarea_size;
 	uint32_t         block_size;
 	uint32_t         shm_size;
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index e2bb842..e715970 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -393,8 +393,8 @@  static inline odp_packet_hdr_t *add_segments(odp_packet_hdr_t *pkt_hdr,
 	if (new_hdr == NULL)
 		return NULL;
 
-	seg_len = len - ((num - 1) * pool->max_seg_len);
-	offset  = pool->max_seg_len - seg_len;
+	seg_len = len - ((num - 1) * pool->seg_len);
+	offset  = pool->seg_len - seg_len;
 
 	if (head) {
 		/* add into the head*/
@@ -632,7 +632,7 @@  int odp_packet_reset(odp_packet_t pkt, uint32_t len)
 	odp_packet_hdr_t *const pkt_hdr = packet_hdr(pkt);
 	pool_t *pool = pool_entry_from_hdl(pkt_hdr->buf_hdr.pool_hdl);
 
-	if (len > pool->headroom + pool->data_size + pool->tailroom)
+	if (len > pool->headroom + pool->seg_len + pool->tailroom)
 		return -1;
 
 	packet_init(pkt_hdr, len, 0);
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index 9dba734..317f113 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -253,7 +253,7 @@  static void init_buffers(pool_t *pool)
 
 		memset(buf_hdr, 0, (uintptr_t)data - (uintptr_t)buf_hdr);
 
-		seg_size = pool->headroom + pool->data_size + pool->tailroom;
+		seg_size = pool->headroom + pool->seg_len + pool->tailroom;
 
 		/* Initialize buffer metadata */
 		buf_hdr->size = seg_size;
@@ -268,11 +268,11 @@  static void init_buffers(pool_t *pool)
 		/* Pointer to data start (of the first segment) */
 		buf_hdr->seg[0].hdr       = buf_hdr;
 		buf_hdr->seg[0].data      = &data[offset];
-		buf_hdr->seg[0].len       = pool->data_size;
+		buf_hdr->seg[0].len       = pool->seg_len;
 
 		/* Store base values for fast init */
 		buf_hdr->base_data = buf_hdr->seg[0].data;
-		buf_hdr->buf_end   = &data[offset + pool->data_size +
+		buf_hdr->buf_end   = &data[offset + pool->seg_len +
 				     pool->tailroom];
 
 		buf_hdl = form_buffer_handle(pool->pool_idx, i);
@@ -289,8 +289,8 @@  static odp_pool_t pool_create(const char *name, odp_pool_param_t *params,
 	pool_t *pool;
 	uint32_t uarea_size, headroom, tailroom;
 	odp_shm_t shm;
-	uint32_t data_size, align, num, hdr_size, block_size;
-	uint32_t max_len, max_seg_len;
+	uint32_t seg_len, align, num, hdr_size, block_size;
+	uint32_t max_len;
 	uint32_t ring_size;
 	int name_len;
 	const char *postfix = "_uarea";
@@ -318,15 +318,14 @@  static odp_pool_t pool_create(const char *name, odp_pool_param_t *params,
 
 	headroom    = 0;
 	tailroom    = 0;
-	data_size   = 0;
+	seg_len     = 0;
 	max_len     = 0;
-	max_seg_len = 0;
 	uarea_size  = 0;
 
 	switch (params->type) {
 	case ODP_POOL_BUFFER:
 		num  = params->buf.num;
-		data_size = params->buf.size;
+		seg_len = params->buf.size;
 		break;
 
 	case ODP_POOL_PACKET:
@@ -334,9 +333,8 @@  static odp_pool_t pool_create(const char *name, odp_pool_param_t *params,
 		tailroom    = CONFIG_PACKET_TAILROOM;
 		num         = params->pkt.num;
 		uarea_size  = params->pkt.uarea_size;
-		data_size   = CONFIG_PACKET_MAX_SEG_LEN;
-		max_seg_len = CONFIG_PACKET_MAX_SEG_LEN;
-		max_len     = CONFIG_PACKET_MAX_SEGS * max_seg_len;
+		seg_len     = CONFIG_PACKET_MAX_SEG_LEN;
+		max_len     = CONFIG_PACKET_MAX_SEGS * seg_len;
 		break;
 
 	case ODP_POOL_TIMEOUT:
@@ -376,7 +374,7 @@  static odp_pool_t pool_create(const char *name, odp_pool_param_t *params,
 	hdr_size = ROUNDUP_CACHE_LINE(hdr_size);
 
 	block_size = ROUNDUP_CACHE_LINE(hdr_size + align + headroom +
-					data_size + tailroom);
+					seg_len + tailroom);
 
 	if (num <= RING_SIZE_MIN)
 		ring_size = RING_SIZE_MIN;
@@ -387,9 +385,8 @@  static odp_pool_t pool_create(const char *name, odp_pool_param_t *params,
 	pool->num            = num;
 	pool->align          = align;
 	pool->headroom       = headroom;
-	pool->data_size      = data_size;
+	pool->seg_len        = seg_len;
 	pool->max_len        = max_len;
-	pool->max_seg_len    = max_seg_len;
 	pool->tailroom       = tailroom;
 	pool->block_size     = block_size;
 	pool->uarea_size     = uarea_size;
@@ -856,9 +853,8 @@  void odp_pool_print(odp_pool_t pool_hdl)
 	printf("  num             %u\n", pool->num);
 	printf("  align           %u\n", pool->align);
 	printf("  headroom        %u\n", pool->headroom);
-	printf("  data size       %u\n", pool->data_size);
+	printf("  seg len         %u\n", pool->seg_len);
 	printf("  max data len    %u\n", pool->max_len);
-	printf("  max seg len     %u\n", pool->max_seg_len);
 	printf("  tailroom        %u\n", pool->tailroom);
 	printf("  block size      %u\n", pool->block_size);
 	printf("  uarea size      %u\n", pool->uarea_size);
diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c
index fdf8cca..6d2181d 100644
--- a/platform/linux-generic/pktio/socket_mmap.c
+++ b/platform/linux-generic/pktio/socket_mmap.c
@@ -354,7 +354,7 @@  static void mmap_fill_ring(struct ring *ring, odp_pool_t pool_hdl, int fanout)
 	pool = pool_entry_from_hdl(pool_hdl);
 
 	/* Frame has to capture full packet which can fit to the pool block.*/
-	ring->req.tp_frame_size = (pool->data_size +
+	ring->req.tp_frame_size = (pool->seg_len +
 				   TPACKET_HDRLEN + TPACKET_ALIGNMENT +
 				   + (pz - 1)) & (-pz);