@@ -603,10 +603,10 @@ int main(int argc, char *argv[])
printf("cpu mask: %s\n", cpumaskstr);
/* Create packet pool */
- params.buf.size = SHM_PKT_POOL_BUF_SIZE;
- params.buf.align = 0;
- params.buf.num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE;
- params.type = ODP_POOL_PACKET;
+ params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE;
+ params.pkt.seg_align = 0;
+ params.pkt.seg_num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE;
+ params.type = ODP_POOL_PACKET;
pool = odp_pool_create("packet_pool", ODP_SHM_NULL, ¶ms);
@@ -399,10 +399,10 @@ void ipsec_init_pre(void)
}
/* Create output buffer pool */
- params.buf.size = SHM_OUT_POOL_BUF_SIZE;
- params.buf.align = 0;
- params.buf.num = SHM_PKT_POOL_BUF_COUNT;
- params.type = ODP_POOL_PACKET;
+ params.pkt.seg_len = SHM_OUT_POOL_BUF_SIZE;
+ params.pkt.seg_align = 0;
+ params.pkt.seg_num = SHM_PKT_POOL_BUF_COUNT;
+ params.type = ODP_POOL_PACKET;
out_pool = odp_pool_create("out_pool", ODP_SHM_NULL, ¶ms);
@@ -1234,10 +1234,10 @@ main(int argc, char *argv[])
odp_barrier_init(&sync_barrier, num_workers);
/* Create packet buffer pool */
- params.buf.size = SHM_PKT_POOL_BUF_SIZE;
- params.buf.align = 0;
- params.buf.num = SHM_PKT_POOL_BUF_COUNT;
- params.type = ODP_POOL_PACKET;
+ params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE;
+ params.pkt.seg_align = 0;
+ params.pkt.seg_num = SHM_PKT_POOL_BUF_COUNT;
+ params.type = ODP_POOL_PACKET;
pkt_pool = odp_pool_create("packet_pool", ODP_SHM_NULL,
¶ms);
@@ -352,10 +352,10 @@ int main(int argc, char *argv[])
}
/* Create packet pool */
- params.buf.size = SHM_PKT_POOL_BUF_SIZE;
- params.buf.align = 0;
- params.buf.num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE;
- params.type = ODP_POOL_PACKET;
+ params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE;
+ params.pkt.seg_align = 0;
+ params.pkt.seg_num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE;
+ params.type = ODP_POOL_PACKET;
pool = odp_pool_create("packet pool", ODP_SHM_NULL, ¶ms);
@@ -329,10 +329,10 @@ int main(int argc, char *argv[])
printf("cpu mask: %s\n", cpumaskstr);
/* Create packet pool */
- params.buf.size = SHM_PKT_POOL_BUF_SIZE;
- params.buf.align = 0;
- params.buf.num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE;
- params.type = ODP_POOL_PACKET;
+ params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE;
+ params.pkt.seg_align = 0;
+ params.pkt.seg_num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE;
+ params.type = ODP_POOL_PACKET;
pool = odp_pool_create("packet_pool", ODP_SHM_NULL, ¶ms);
@@ -126,7 +126,7 @@ odp_pool_t odp_pool_create(const char *name,
return ODP_POOL_INVALID;
/* Restriction for v1.0: All non-packet buffers are unsegmented */
- int unsegmented = 1;
+ int unseg = 1;
/* Restriction for v1.0: No zeroization support */
const int zeroized = 0;
@@ -137,7 +137,12 @@ odp_pool_t odp_pool_create(const char *name,
0;
uint32_t blk_size, buf_stride;
- uint32_t buf_align = params->buf.align;
+ uint32_t buf_align;
+
+ if (params->type == ODP_POOL_PACKET)
+ buf_align = params->pkt.seg_align;
+ else
+ buf_align = params->buf.align;
/* Validate requested buffer alignment */
if (buf_align > ODP_CONFIG_BUFFER_ALIGN_MAX ||
@@ -168,15 +173,15 @@ odp_pool_t odp_pool_create(const char *name,
case ODP_POOL_PACKET:
headroom = ODP_CONFIG_PACKET_HEADROOM;
tailroom = ODP_CONFIG_PACKET_TAILROOM;
- unsegmented = params->buf.size > ODP_CONFIG_PACKET_BUF_LEN_MAX;
+ unseg = params->pkt.seg_len > ODP_CONFIG_PACKET_BUF_LEN_MAX;
- if (unsegmented)
+ if (unseg)
blk_size = ODP_ALIGN_ROUNDUP(
- headroom + params->buf.size + tailroom,
+ headroom + params->pkt.seg_len + tailroom,
buf_align);
else
blk_size = ODP_ALIGN_ROUNDUP(
- headroom + params->buf.size + tailroom,
+ headroom + params->pkt.seg_len + tailroom,
ODP_CONFIG_PACKET_BUF_LEN_MIN);
buf_stride = params->type == ODP_POOL_PACKET ?
@@ -276,9 +281,9 @@ odp_pool_t odp_pool_create(const char *name,
/* Now safe to unlock since pool entry has been allocated */
POOL_UNLOCK(&pool->s.lock);
- pool->s.flags.unsegmented = unsegmented;
+ pool->s.flags.unsegmented = unseg;
pool->s.flags.zeroized = zeroized;
- pool->s.seg_size = unsegmented ?
+ pool->s.seg_size = unseg ?
blk_size : ODP_CONFIG_PACKET_BUF_LEN_MIN;
@@ -10,23 +10,39 @@ static int pool_name_number = 1;
static const int default_buffer_size = 1500;
static const int default_buffer_num = 1000;
-odp_pool_t pool_create(int buf_num, int buf_size, int buf_type)
+odp_pool_t pool_create(int num, int size, int type)
{
odp_pool_t pool;
char pool_name[ODP_POOL_NAME_LEN];
- odp_pool_param_t params = {
- .buf = {
- .size = buf_size,
- .align = ODP_CACHE_LINE_SIZE,
- .num = buf_num,
- },
- .type = buf_type,
- };
+ odp_pool_param_t param;
+
+ memset(¶m, 0, sizeof(param));
+
+ switch (type) {
+ case ODP_POOL_BUFFER:
+ param.buf.size = size;
+ param.buf.align = ODP_CACHE_LINE_SIZE,
+ param.buf.num = num;
+ break;
+ case ODP_POOL_PACKET:
+ param.pkt.seg_len = size;
+ param.pkt.seg_align = ODP_CACHE_LINE_SIZE,
+ param.pkt.seg_num = num;
+ break;
+ case ODP_POOL_TIMEOUT:
+ param.tmo.num = num;
+ break;
+ default:
+ CU_FAIL("Bad pool type");
+ return ODP_POOL_INVALID;
+ }
+
+ param.type = type;
snprintf(pool_name, sizeof(pool_name),
"test_buffer_pool-%d", pool_name_number++);
- pool = odp_pool_create(pool_name, ODP_SHM_INVALID, ¶ms);
+ pool = odp_pool_create(pool_name, ODP_SHM_INVALID, ¶m);
CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
return pool;
@@ -22,10 +22,10 @@ odp_packet_t test_packet;
int packet_testsuite_init(void)
{
odp_pool_param_t params = {
- .buf = {
- .size = PACKET_BUF_LEN,
- .align = ODP_CACHE_LINE_SIZE,
- .num = 100,
+ .pkt = {
+ .seg_len = PACKET_BUF_LEN,
+ .seg_align = ODP_CACHE_LINE_SIZE,
+ .seg_num = 100,
},
.type = ODP_POOL_PACKET,
};
@@ -247,9 +247,9 @@ int classification_tests_init(void)
char queuename[ODP_QUEUE_NAME_LEN];
int i;
- param.buf.size = SHM_PKT_BUF_SIZE;
- param.buf.num = SHM_PKT_NUM_BUFS;
- param.buf.align = 0;
+ param.pkt.seg_len = SHM_PKT_BUF_SIZE;
+ param.pkt.seg_align = 0;
+ param.pkt.seg_num = SHM_PKT_NUM_BUFS;
param.type = ODP_POOL_PACKET;
pool = odp_pool_create("classification_pool",
@@ -29,10 +29,10 @@ int tests_global_init(void)
odp_pool_t pool;
odp_queue_t out_queue;
- params.buf.size = SHM_PKT_POOL_BUF_SIZE;
- params.buf.align = 0;
- params.buf.num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE;
- params.type = ODP_POOL_PACKET;
+ params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE;
+ params.pkt.seg_align = 0;
+ params.pkt.seg_num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE;
+ params.type = ODP_POOL_PACKET;
pool = odp_pool_create("packet_pool", ODP_SHM_NULL, ¶ms);
@@ -185,10 +185,10 @@ static int default_pool_create(void)
if (default_pkt_pool != ODP_POOL_INVALID)
return -1;
- params.buf.size = PKT_BUF_SIZE;
- params.buf.align = 0;
- params.buf.num = PKT_BUF_NUM;
- params.type = ODP_POOL_PACKET;
+ params.pkt.seg_len = PKT_BUF_SIZE;
+ params.pkt.seg_align = 0;
+ params.pkt.seg_num = PKT_BUF_NUM;
+ params.type = ODP_POOL_PACKET;
default_pkt_pool = odp_pool_create("pkt_pool_default",
ODP_SHM_NULL, ¶ms);
@@ -205,10 +205,10 @@ static odp_pktio_t create_pktio(const char *iface)
char pool_name[ODP_POOL_NAME_LEN];
odp_pool_param_t params;
- params.buf.size = PKT_BUF_SIZE;
- params.buf.align = 0;
- params.buf.num = PKT_BUF_NUM;
- params.type = ODP_POOL_PACKET;
+ params.pkt.seg_len = PKT_BUF_SIZE;
+ params.pkt.seg_align = 0;
+ params.pkt.seg_num = PKT_BUF_NUM;
+ params.type = ODP_POOL_PACKET;
snprintf(pool_name, sizeof(pool_name), "pkt_pool_%s", iface);
pool = odp_pool_lookup(pool_name);
Change implementation, examples and test to use the new packet pool parameters with ODP_POOL_PACKET type pools (instead of using buffer pool parameters). Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> --- example/generator/odp_generator.c | 8 ++--- example/ipsec/odp_ipsec.c | 16 +++++----- example/l2fwd/odp_l2fwd.c | 8 ++--- example/packet/odp_pktio.c | 8 ++--- platform/linux-generic/odp_buffer_pool.c | 21 ++++++++----- test/validation/buffer/odp_buffer_pool_test.c | 36 ++++++++++++++++------ test/validation/buffer/odp_packet_test.c | 8 ++--- .../classification/odp_classification_tests.c | 6 ++-- test/validation/odp_crypto.c | 8 ++--- test/validation/odp_pktio.c | 16 +++++----- 10 files changed, 78 insertions(+), 57 deletions(-)