From: Matias Elo <matias....@nokia.com> 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....@nokia.com> --- /** Email created from pull request 233 (matiaselo:dev/pool_dyn_seg_len) ** https://github.com/Linaro/odp/pull/233 ** Patch: https://github.com/Linaro/odp/pull/233.patch ** Base sha: ec0c3145fcafa09ae3a79875e7e07dd4794583cc ** Merge commit sha: ada95db815e81074651bb5a5fd0d751fdb17a97c **/ platform/linux-generic/include/odp_pool_internal.h | 3 +-- platform/linux-generic/odp_packet.c | 6 ++--- platform/linux-generic/odp_pool.c | 30 ++++++++++------------ platform/linux-generic/pktio/dpdk.c | 6 ++--- platform/linux-generic/pktio/socket_mmap.c | 2 +- 5 files changed, 21 insertions(+), 26 deletions(-) diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h index edf75d6e0..48945ee1d 100644 --- a/platform/linux-generic/include/odp_pool_internal.h +++ b/platform/linux-generic/include/odp_pool_internal.h @@ -60,9 +60,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 fff01ad9d..c330c629e 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -476,8 +476,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*/ @@ -906,7 +906,7 @@ int odp_packet_reset(odp_packet_t pkt, uint32_t len) pool_t *pool = pkt_hdr->buf_hdr.pool_ptr; int num = pkt_hdr->buf_hdr.segcount; - if (odp_unlikely(len > (pool->max_seg_len * num))) + if (odp_unlikely(len > (pool->seg_len * num))) return -1; reset_seg(pkt_hdr, 0, num); diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 40cbb397c..44a40e83e 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -285,7 +285,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->index = i; @@ -305,13 +305,13 @@ 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; odp_atomic_init_u32(&buf_hdr->ref_cnt, 0); /* 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]; /* Store buffer index into the global pool */ @@ -341,8 +341,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; uint32_t num_extra = 0; int name_len; @@ -371,15 +371,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: @@ -387,9 +386,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: @@ -428,8 +426,8 @@ static odp_pool_t pool_create(const char *name, odp_pool_param_t *params, hdr_size = sizeof(odp_packet_hdr_t); hdr_size = ROUNDUP_CACHE_LINE(hdr_size); - block_size = ROUNDUP_CACHE_LINE(hdr_size + align + headroom + - data_size + tailroom); + block_size = ROUNDUP_CACHE_LINE(hdr_size + align + headroom + seg_len + + tailroom); /* Allocate extra memory for skipping packet buffers which cross huge * page boundaries. */ @@ -449,9 +447,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; @@ -924,9 +921,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/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 26ca0d6b4..2e50a55f5 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -174,7 +174,7 @@ static struct rte_mempool *mbuf_pool_create(const char *name, } num = pool_entry->num; - data_room_size = pool_entry->max_seg_len + CONFIG_PACKET_HEADROOM; + data_room_size = pool_entry->seg_len + CONFIG_PACKET_HEADROOM; elt_size = sizeof(struct rte_mbuf) + (unsigned)data_room_size; mbp_priv.mbuf_data_room_size = data_room_size; mbp_priv.mbuf_priv_size = 0; @@ -231,7 +231,7 @@ static int pool_dequeue_bulk(struct rte_mempool *mp, void **obj_table, int pkts; int i; - pkts = packet_alloc_multi(pool, pool_entry->max_seg_len, packet_tbl, + pkts = packet_alloc_multi(pool, pool_entry->seg_len, packet_tbl, num); if (odp_unlikely(pkts != (int)num)) { @@ -1230,7 +1230,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, data_room = rte_pktmbuf_data_room_size(pkt_dpdk->pkt_pool) - RTE_PKTMBUF_HEADROOM; - pkt_dpdk->data_room = RTE_MIN(pool_entry->max_seg_len, data_room); + pkt_dpdk->data_room = RTE_MIN(pool_entry->seg_len, data_room); /* Mbuf chaining not yet supported */ pkt_dpdk->mtu = RTE_MIN(pkt_dpdk->mtu, pkt_dpdk->data_room); diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index f71180238..42f4a2628 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -357,7 +357,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->headroom + pool->data_size + + ring->req.tp_frame_size = (pool->headroom + pool->seg_len + pool->tailroom + TPACKET_HDRLEN + TPACKET_ALIGNMENT + + (pz - 1)) & (-pz);