From patchwork Fri Feb 13 03:32:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 44642 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 921E321527 for ; Fri, 13 Feb 2015 03:33:32 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id d17sf9485778eek.2 for ; Thu, 12 Feb 2015 19:33:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=nBXB1u+RXRxsqOi+K4bYAPzrTbV4IKJ/n8V0pznRoGg=; b=PhZq6HaQ3T2AnGKO5VbFj2keIvJP49e0tltvpKd2x+5Myg9lUTzXEqKfE9arnLvvBA 3Hej4u2p3nylA+f/idcMBAw9OtVYpFhdNc9qJLSyeIlV5YaqegmZrhbOm/HIQAswZez0 k+UCUJJfKi4s71P9rQOHrjGqDko8p5o/ffE4fZYOn62awi/ofOvvpxjNrzNSGlT+uZ7h 1gNN1R5edRevObkqfd+XQHPhmSt5BJGJOksGrVOA+KyiyuQyApJP0bvMQ0G7GAG2vlTK ozbbdDkTGLqVIaZ4ofHs5maB/rdRTA7Loq8GE6+n+RWisFWxvHbfvsm/T5v1BkUm0hOk crOg== X-Gm-Message-State: ALoCoQlwSkiLpq7R5is/+8BWrt9Kh57atkaMomRUvSLyib3CM2Bza6kqfHfIpZsOhzVGDeSrHFgU X-Received: by 10.180.13.83 with SMTP id f19mr931698wic.7.1423798411853; Thu, 12 Feb 2015 19:33:31 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.9 with SMTP id p9ls254178lag.86.gmail; Thu, 12 Feb 2015 19:33:31 -0800 (PST) X-Received: by 10.112.35.194 with SMTP id k2mr6153936lbj.40.1423798411528; Thu, 12 Feb 2015 19:33:31 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id ls7si625832lac.25.2015.02.12.19.33.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Feb 2015 19:33:31 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by labgd6 with SMTP id gd6so14021514lab.7 for ; Thu, 12 Feb 2015 19:33:31 -0800 (PST) X-Received: by 10.112.67.41 with SMTP id k9mr6116224lbt.35.1423798411428; Thu, 12 Feb 2015 19:33:31 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp819550lbj; Thu, 12 Feb 2015 19:33:30 -0800 (PST) X-Received: by 10.140.104.228 with SMTP id a91mr17839763qgf.46.1423798410250; Thu, 12 Feb 2015 19:33:30 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id 45si1429220qgf.98.2015.02.12.19.33.29 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 12 Feb 2015 19:33:30 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YM70R-0001qo-Dl; Fri, 13 Feb 2015 03:33:27 +0000 Received: from mail-qg0-f43.google.com ([209.85.192.43]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YM70K-0001qM-5Y for lng-odp@lists.linaro.org; Fri, 13 Feb 2015 03:33:20 +0000 Received: by mail-qg0-f43.google.com with SMTP id i50so11473060qgf.2 for ; Thu, 12 Feb 2015 19:33:15 -0800 (PST) X-Received: by 10.140.20.226 with SMTP id 89mr17627697qgj.16.1423798395024; Thu, 12 Feb 2015 19:33:15 -0800 (PST) Received: from mcpro03.emea.nsn-net.net (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id s63sm5991798qgd.26.2015.02.12.19.33.12 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Feb 2015 19:33:13 -0800 (PST) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Fri, 13 Feb 2015 05:32:47 +0200 Message-Id: <1423798368-16597-2-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1423798368-16597-1-git-send-email-petri.savolainen@linaro.org> References: <1423798368-16597-1-git-send-email-petri.savolainen@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v3 2/3] api: pool: Move from buffer to packet pool parameters X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: petri.savolainen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 --- example/generator/odp_generator.c | 9 +++--- example/ipsec/odp_ipsec.c | 18 ++++++----- example/l2fwd/odp_l2fwd.c | 9 +++--- example/packet/odp_pktio.c | 9 +++--- 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 | 9 +++--- test/validation/odp_crypto.c | 9 +++--- test/validation/odp_pktio.c | 18 ++++++----- 10 files changed, 88 insertions(+), 58 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 38b6ca0..db9e0c2 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -607,10 +607,11 @@ 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; + memset(¶ms, 0, sizeof(params)); + params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE; + params.pkt.len = SHM_PKT_POOL_BUF_SIZE; + params.pkt.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); diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 302097e..1aa68db 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -399,10 +399,11 @@ 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; + memset(¶ms, 0, sizeof(params)); + params.pkt.seg_len = SHM_OUT_POOL_BUF_SIZE; + params.pkt.len = SHM_OUT_POOL_BUF_SIZE; + params.pkt.num = SHM_PKT_POOL_BUF_COUNT; + params.type = ODP_POOL_PACKET; out_pool = odp_pool_create("out_pool", ODP_SHM_NULL, ¶ms); @@ -1256,10 +1257,11 @@ 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; + memset(¶ms, 0, sizeof(params)); + params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE; + params.pkt.len = SHM_PKT_POOL_BUF_SIZE; + params.pkt.num = SHM_PKT_POOL_BUF_COUNT; + params.type = ODP_POOL_PACKET; pkt_pool = odp_pool_create("packet_pool", ODP_SHM_NULL, ¶ms); diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c index 183043f..0326a3c 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -357,10 +357,11 @@ 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; + memset(¶ms, 0, sizeof(params)); + params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE; + params.pkt.len = SHM_PKT_POOL_BUF_SIZE; + params.pkt.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); diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 194173c..5eec796 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -337,10 +337,11 @@ 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; + memset(¶ms, 0, sizeof(params)); + params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE; + params.pkt.len = SHM_PKT_POOL_BUF_SIZE; + params.pkt.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); diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index 69acf1b..18ad358 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -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 = 0; + 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; diff --git a/test/validation/buffer/odp_buffer_pool_test.c b/test/validation/buffer/odp_buffer_pool_test.c index c018b59..ebeae75 100644 --- a/test/validation/buffer/odp_buffer_pool_test.c +++ b/test/validation/buffer/odp_buffer_pool_test.c @@ -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.len = size; + param.pkt.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; diff --git a/test/validation/buffer/odp_packet_test.c b/test/validation/buffer/odp_packet_test.c index b8995f7..f5830cc 100644 --- a/test/validation/buffer/odp_packet_test.c +++ b/test/validation/buffer/odp_packet_test.c @@ -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, + .len = PACKET_BUF_LEN, + .num = 100, }, .type = ODP_POOL_PACKET, }; diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c index 45822d3..564455c 100644 --- a/test/validation/classification/odp_classification_tests.c +++ b/test/validation/classification/odp_classification_tests.c @@ -247,10 +247,11 @@ 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.type = ODP_POOL_PACKET; + memset(¶m, 0, sizeof(param)); + param.pkt.seg_len = SHM_PKT_BUF_SIZE; + param.pkt.len = SHM_PKT_BUF_SIZE; + param.pkt.num = SHM_PKT_NUM_BUFS; + param.type = ODP_POOL_PACKET; pool = odp_pool_create("classification_pool", ODP_SHM_NULL, ¶m); diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c index d8db114..b109a75 100644 --- a/test/validation/odp_crypto.c +++ b/test/validation/odp_crypto.c @@ -29,10 +29,11 @@ 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; + memset(¶ms, 0, sizeof(params)); + params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE; + params.pkt.len = SHM_PKT_POOL_BUF_SIZE; + params.pkt.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); diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c index fef4eaa..3f9de3c 100644 --- a/test/validation/odp_pktio.c +++ b/test/validation/odp_pktio.c @@ -186,10 +186,11 @@ 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; + memset(¶ms, 0, sizeof(params)); + params.pkt.seg_len = PKT_BUF_SIZE; + params.pkt.len = PKT_BUF_SIZE; + params.pkt.num = PKT_BUF_NUM; + params.type = ODP_POOL_PACKET; default_pkt_pool = odp_pool_create("pkt_pool_default", ODP_SHM_NULL, ¶ms); @@ -206,10 +207,11 @@ 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; + memset(¶ms, 0, sizeof(params)); + params.pkt.seg_len = PKT_BUF_SIZE; + params.pkt.len = PKT_BUF_SIZE; + params.pkt.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);