aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2017-11-06 12:52:04 +0200
committerMaxim Uvarov <maxim.uvarov@linaro.org>2017-11-16 18:45:06 +0300
commit4459e1bd35534dd1b6a313890c74086c0e86c617 (patch)
tree9d4ecaeac303cc88ffa718b7767236994af02b7a
parent163f57de92d66336433cf5638538828e10053655 (diff)
downloadodp-4459e1bd35534dd1b6a313890c74086c0e86c617.tar.gz
linux-gen: buffer: remove data size member from odp_buffer_hdr_t
Data size is constant for all buffers from the same pool, so there is no need to store the value in the buffer header. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r--platform/linux-generic/include/odp_buffer_internal.h3
-rw-r--r--platform/linux-generic/include/odp_pool_internal.h1
-rw-r--r--platform/linux-generic/odp_buffer.c5
-rw-r--r--platform/linux-generic/odp_packet.c6
-rw-r--r--platform/linux-generic/odp_pool.c5
5 files changed, 9 insertions, 11 deletions
diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h
index aefb135..ac18930 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -107,9 +107,6 @@ struct odp_buffer_hdr_t {
/* User area size */
uint32_t uarea_size;
- /* Max data size */
- uint32_t size;
-
/* ipc mapped process can not walk over pointers,
* offset has to be used */
uint64_t ipc_data_offset;
diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h
index 48945ee..61ec5cc 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -61,6 +61,7 @@ typedef struct pool_t {
uint32_t headroom;
uint32_t tailroom;
uint32_t seg_len;
+ uint32_t max_seg_len;
uint32_t max_len;
uint32_t uarea_size;
uint32_t block_size;
diff --git a/platform/linux-generic/odp_buffer.c b/platform/linux-generic/odp_buffer.c
index 1b14848..a0e0cd1 100644
--- a/platform/linux-generic/odp_buffer.c
+++ b/platform/linux-generic/odp_buffer.c
@@ -36,8 +36,9 @@ void *odp_buffer_addr(odp_buffer_t buf)
uint32_t odp_buffer_size(odp_buffer_t buf)
{
odp_buffer_hdr_t *hdr = buf_hdl_to_hdr(buf);
+ pool_t *pool = hdr->pool_ptr;
- return hdr->size;
+ return pool->seg_len;
}
int odp_buffer_snprint(char *str, uint32_t n, odp_buffer_t buf)
@@ -62,7 +63,7 @@ int odp_buffer_snprint(char *str, uint32_t n, odp_buffer_t buf)
len += snprintf(&str[len], n-len,
" addr %p\n", hdr->seg[0].data);
len += snprintf(&str[len], n-len,
- " size %" PRIu32 "\n", hdr->size);
+ " size %" PRIu32 "\n", odp_buffer_size(buf));
len += snprintf(&str[len], n-len,
" type %i\n", hdr->type);
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 68a6eef..6d1f1bd 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -957,8 +957,9 @@ odp_event_t odp_packet_to_event(odp_packet_t pkt)
uint32_t odp_packet_buf_len(odp_packet_t pkt)
{
odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+ pool_t *pool = pkt_hdr->buf_hdr.pool_ptr;
- return pkt_hdr->buf_hdr.size * pkt_hdr->buf_hdr.segcount;
+ return pool->max_seg_len * pkt_hdr->buf_hdr.segcount;
}
void *odp_packet_tail(odp_packet_t pkt)
@@ -1404,6 +1405,7 @@ int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len,
uint32_t shift;
uint32_t seglen = 0; /* GCC */
odp_packet_hdr_t *pkt_hdr = packet_hdr(*pkt);
+ pool_t *pool = pkt_hdr->buf_hdr.pool_ptr;
void *addr = packet_map(pkt_hdr, offset, &seglen, NULL);
uint64_t uaddr = (uint64_t)(uintptr_t)addr;
uint64_t misalign;
@@ -1420,7 +1422,7 @@ int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len,
return 0;
shift = align - misalign;
} else {
- if (len > pkt_hdr->buf_hdr.size)
+ if (len > pool->max_seg_len)
return -1;
shift = len - seglen;
uaddr -= shift;
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index 3e47993..7d7a423 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -236,7 +236,6 @@ static void init_buffers(pool_t *pool)
ring_t *ring;
uint32_t mask;
int type;
- uint32_t seg_size;
uint64_t page_size;
int skipped_blocks = 0;
@@ -285,11 +284,8 @@ static void init_buffers(pool_t *pool)
memset(buf_hdr, 0, (uintptr_t)data - (uintptr_t)buf_hdr);
- seg_size = pool->headroom + pool->seg_len + pool->tailroom;
-
/* Initialize buffer metadata */
buf_hdr->index = i;
- buf_hdr->size = seg_size;
buf_hdr->type = type;
buf_hdr->event_type = type;
buf_hdr->pool_hdl = pool->pool_hdl;
@@ -469,6 +465,7 @@ static odp_pool_t pool_create(const char *name, odp_pool_param_t *params,
pool->align = align;
pool->headroom = headroom;
pool->seg_len = seg_len;
+ pool->max_seg_len = headroom + seg_len + tailroom;
pool->max_len = max_len;
pool->tailroom = tailroom;
pool->block_size = block_size;