From patchwork Tue Feb 3 12:59:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 44224 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8C0BD2034D for ; Tue, 3 Feb 2015 13:00:30 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gm9sf20711283lab.0 for ; Tue, 03 Feb 2015 05:00:29 -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=9e5Dr1G59zq48at06K6TcwIpry7wZk9z7kn4oKhDf3Y=; b=PCNObAI3iadnhe+zhxxgKkr/Gqe0xOqbujAWjwF7vV5152Q8Dau1iDhrMR0y3xKB/W LKua+blOjapir7nbiSSsBQw0LQK5Yge/lUiYNKQVi9Pj2PnQXKFMBvw6hAUmUy7Uf31+ TO6zMBF8v24CByM0hkKaug6GpRBjWtYoKkrL23wkIGbtoqFnv/k43LOcmSnLOQpRzVFK 1m16ioYkXuNUr1sxBReUd8Y4a5GvG76tzAyRT8K7xqPhXj3Ge6dNq/fiwmkLLKl117V/ iM1y9SAPkj2MlIsau45zghG9p3sy07R4aKsuc9qtmuKBYIzM0n9tV8d9YwUrrRs1pexr 8gYQ== X-Gm-Message-State: ALoCoQmWdAQQo4MFyDVYu6h2HktmfI8dnMsOlo4+MTRs/Ev3UnBUyCGO2V3+Na7y9cyGiWk2W/GE X-Received: by 10.112.154.233 with SMTP id vr9mr3162795lbb.9.1422968429490; Tue, 03 Feb 2015 05:00:29 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.232 with SMTP id h8ls182401lam.30.gmail; Tue, 03 Feb 2015 05:00:29 -0800 (PST) X-Received: by 10.112.202.227 with SMTP id kl3mr9905686lbc.81.1422968429339; Tue, 03 Feb 2015 05:00:29 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id q3si18542508lbh.43.2015.02.03.05.00.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 05:00:28 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gq15so51300440lab.12 for ; Tue, 03 Feb 2015 05:00:28 -0800 (PST) X-Received: by 10.152.203.230 with SMTP id kt6mr23436900lac.38.1422968428706; Tue, 03 Feb 2015 05:00:28 -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 h5csp1920992lbj; Tue, 3 Feb 2015 05:00:27 -0800 (PST) X-Received: by 10.229.89.196 with SMTP id f4mr9017503qcm.3.1422968426567; Tue, 03 Feb 2015 05:00:26 -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 e5si27951803qcm.34.2015.02.03.05.00.24 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 03 Feb 2015 05:00:26 -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 1YId5a-00048d-Il; Tue, 03 Feb 2015 13:00:22 +0000 Received: from mail-qg0-f49.google.com ([209.85.192.49]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YId5S-00046a-J8 for lng-odp@lists.linaro.org; Tue, 03 Feb 2015 13:00:14 +0000 Received: by mail-qg0-f49.google.com with SMTP id i50so52076882qgf.8 for ; Tue, 03 Feb 2015 05:00:09 -0800 (PST) X-Received: by 10.224.30.145 with SMTP id u17mr52068207qac.46.1422968409320; Tue, 03 Feb 2015 05:00:09 -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 n4sm21194037qas.20.2015.02.03.05.00.07 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 05:00:08 -0800 (PST) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Tue, 3 Feb 2015 14:59:27 +0200 Message-Id: <1422968368-14340-2-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422968368-14340-1-git-send-email-petri.savolainen@linaro.org> References: <1422968368-14340-1-git-send-email-petri.savolainen@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v2 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.53 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 03dab50..de623ab 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 03f2419..4211e22 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); @@ -1252,10 +1252,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 7a520fb..6e07738 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -354,10 +354,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 28ed98c..b3e6cd7 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -331,10 +331,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 0a5d32e..218d07a 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 84121f5..ac68b58 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);