From patchwork Fri Jan 30 13:10:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 44042 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1669B20CA8 for ; Fri, 30 Jan 2015 13:11:22 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id n3sf995797wiv.0 for ; Fri, 30 Jan 2015 05:11:21 -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=kWfLgi4PJegiIjpf2R18LLfGPMp87/X34km3mnTzT44=; b=J/1u4AYTJEQ6XkWESRhRkCJ3o/fbwK3YNmb70B3nbSXEa2H3eXfc2gE329EaKPPrqF OjrjK19oxnS7kpTnUsUB+j2+3UWsYSw84ylPW+0kZQlrbJEq4fPImJOcL7eQhnLR3JkA xV77dFyjrn0EmOyGwthRA7gLdvqDFM4pinSkhmYqOw5uGB9VQ5o1kqmiTrhjc/SgSc/Y 3wuBByfwkITq6vlWN5tvhgqJcazdjA86vMbeA6CKcspeaWgro95LUA5XKQ7kkSw0MCoi qHO78qdpTf1lYs/IsPhcKH6B0UShdpw4nkjWNMy2944RFhuV2GuOLJ+zI0Ln0KXCEgxo t6sw== X-Gm-Message-State: ALoCoQl6udviJ9dF+OQVAHQB2ZVr9mBG6cTvgiA1KmZui4NTc6EazrqdP2SNjEXpKhWRcIDSDwus X-Received: by 10.180.76.44 with SMTP id h12mr348654wiw.2.1422623481422; Fri, 30 Jan 2015 05:11:21 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.166 with SMTP id t6ls88048lat.89.gmail; Fri, 30 Jan 2015 05:11:21 -0800 (PST) X-Received: by 10.112.183.197 with SMTP id eo5mr6124046lbc.81.1422623481253; Fri, 30 Jan 2015 05:11:21 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id ay12si10072548lab.62.2015.01.30.05.11.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 Jan 2015 05:11:21 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id hs14so23472649lab.9 for ; Fri, 30 Jan 2015 05:11:21 -0800 (PST) X-Received: by 10.152.23.195 with SMTP id o3mr6346734laf.70.1422623481154; Fri, 30 Jan 2015 05:11:21 -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 h5csp278771lbj; Fri, 30 Jan 2015 05:11:20 -0800 (PST) X-Received: by 10.52.146.138 with SMTP id tc10mr2453545vdb.41.1422623479409; Fri, 30 Jan 2015 05:11:19 -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 x16si4997571vcf.24.2015.01.30.05.11.17 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 30 Jan 2015 05:11:19 -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 1YHBLv-0006k4-NX; Fri, 30 Jan 2015 13:11:15 +0000 Received: from mail-qg0-f44.google.com ([209.85.192.44]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YHBLn-0006jh-AX for lng-odp@lists.linaro.org; Fri, 30 Jan 2015 13:11:07 +0000 Received: by mail-qg0-f44.google.com with SMTP id l89so38024424qgf.3 for ; Fri, 30 Jan 2015 05:11:02 -0800 (PST) X-Received: by 10.140.29.138 with SMTP id b10mr11590136qgb.34.1422623462140; Fri, 30 Jan 2015 05:11:02 -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 l10sm9970837qay.22.2015.01.30.05.10.59 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 Jan 2015 05:11:01 -0800 (PST) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Fri, 30 Jan 2015 15:10:05 +0200 Message-Id: <1422623405-11667-2-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422623405-11667-1-git-send-email-petri.savolainen@linaro.org> References: <1422623405-11667-1-git-send-email-petri.savolainen@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 2/2] 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.50 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 | 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(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index ed5396d..ead9775 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -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); diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index a4dc63d..1a25448 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -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); diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c index 195d3d0..f78e4ef 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -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); diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 83992b6..b5858a2 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -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); diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index 3e13e6f..6f2f79e 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 = 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; diff --git a/test/validation/buffer/odp_buffer_pool_test.c b/test/validation/buffer/odp_buffer_pool_test.c index c018b59..f02747e 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.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; diff --git a/test/validation/buffer/odp_packet_test.c b/test/validation/buffer/odp_packet_test.c index c2e0861..53f3677 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, + .seg_align = ODP_CACHE_LINE_SIZE, + .seg_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 e4b3260..56463d4 100644 --- a/test/validation/classification/odp_classification_tests.c +++ b/test/validation/classification/odp_classification_tests.c @@ -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", diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c index d8db114..1e00e33 100644 --- a/test/validation/odp_crypto.c +++ b/test/validation/odp_crypto.c @@ -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); diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c index 371db42..feea10f 100644 --- a/test/validation/odp_pktio.c +++ b/test/validation/odp_pktio.c @@ -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);