From patchwork Wed Apr 26 14:00:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 98265 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp339233qgf; Wed, 26 Apr 2017 07:00:42 -0700 (PDT) X-Received: by 10.237.52.5 with SMTP id w5mr26338124qtd.22.1493215242319; Wed, 26 Apr 2017 07:00:42 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i140si258546qke.82.2017.04.26.07.00.41; Wed, 26 Apr 2017 07:00:42 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id B4DF060854; Wed, 26 Apr 2017 14:00:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id F0F2A606A6; Wed, 26 Apr 2017 14:00:26 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id D92A060510; Wed, 26 Apr 2017 14:00:17 +0000 (UTC) Received: from forward2j.cmail.yandex.net (forward2j.cmail.yandex.net [5.255.227.20]) by lists.linaro.org (Postfix) with ESMTPS id AB4FA60510 for ; Wed, 26 Apr 2017 14:00:16 +0000 (UTC) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [77.88.29.85]) by forward2j.cmail.yandex.net (Yandex) with ESMTP id CA4F921184 for ; Wed, 26 Apr 2017 17:00:14 +0300 (MSK) Received: from smtp2p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2p.mail.yandex.net (Yandex) with ESMTP id 538E31A800A1 for ; Wed, 26 Apr 2017 17:00:12 +0300 (MSK) Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id TueArsLD53-0BnWTaep; Wed, 26 Apr 2017 17:00:11 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 26 Apr 2017 17:00:05 +0300 Message-Id: <1493215206-6131-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493215206-6131-1-git-send-email-odpbot@yandex.ru> References: <1493215206-6131-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 18 Subject: [lng-odp] [PATCH 2/3] linux-generic: packet: implement odp_packet_zero_data() X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 18 (lumag:packet-zero) ** https://github.com/Linaro/odp/pull/18 ** Patch: https://github.com/Linaro/odp/pull/18.patch ** Base sha: bac3806356694060d30bf3c83e4133410fecd9ab ** Merge commit sha: a44d13fa3221bf63f7cfe5a00acb07d49dd6abc9 **/ platform/linux-generic/odp_packet.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 9ff642b..1a4b99f 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1634,6 +1634,27 @@ int odp_packet_move_data(odp_packet_t pkt, uint32_t dst_offset, pkt, src_offset, len); } +int odp_packet_zero_data(odp_packet_t pkt, uint32_t offset, uint32_t len) +{ + void *mapaddr; + uint32_t seglen = 0; /* GCC */ + uint32_t zerolen; + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); + + if (offset + len > pkt_hdr->frame_len) + return -1; + + while (len > 0) { + mapaddr = packet_map(pkt_hdr, offset, &seglen, NULL); + zerolen = len > seglen ? seglen : len; + memset(mapaddr, 0, zerolen); + offset += zerolen; + len -= zerolen; + } + + return 0; +} + /* * * Debugging From patchwork Wed Apr 26 14:00:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 98266 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp339711qgf; Wed, 26 Apr 2017 07:01:28 -0700 (PDT) X-Received: by 10.55.24.96 with SMTP id j93mr11996970qkh.133.1493215287933; Wed, 26 Apr 2017 07:01:27 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a41si265104qte.176.2017.04.26.07.01.27; Wed, 26 Apr 2017 07:01:27 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 8CB4D61CA5; Wed, 26 Apr 2017 14:01:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 757FA60749; Wed, 26 Apr 2017 14:00:33 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 241C5606A6; Wed, 26 Apr 2017 14:00:19 +0000 (UTC) Received: from forward1h.cmail.yandex.net (forward1h.cmail.yandex.net [87.250.230.16]) by lists.linaro.org (Postfix) with ESMTPS id CE5B5606A6 for ; Wed, 26 Apr 2017 14:00:16 +0000 (UTC) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:7]) by forward1h.cmail.yandex.net (Yandex) with ESMTP id 7155221400 for ; Wed, 26 Apr 2017 17:00:15 +0300 (MSK) Received: from smtp2p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2p.mail.yandex.net (Yandex) with ESMTP id 190951A80036 for ; Wed, 26 Apr 2017 17:00:14 +0300 (MSK) Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id TueArsLD53-0DnWacJP; Wed, 26 Apr 2017 17:00:13 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 26 Apr 2017 17:00:06 +0300 Message-Id: <1493215206-6131-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493215206-6131-1-git-send-email-odpbot@yandex.ru> References: <1493215206-6131-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 18 Subject: [lng-odp] [PATCH 3/3] validation: packet: add tests for odp_packet_zero_data() X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Check that odp_packet_zero_data() works with single-segment packets and with segmented packets. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 18 (lumag:packet-zero) ** https://github.com/Linaro/odp/pull/18 ** Patch: https://github.com/Linaro/odp/pull/18.patch ** Base sha: bac3806356694060d30bf3c83e4133410fecd9ab ** Merge commit sha: a44d13fa3221bf63f7cfe5a00acb07d49dd6abc9 **/ test/common_plat/validation/api/packet/packet.c | 39 +++++++++++++++++++++++++ test/common_plat/validation/api/packet/packet.h | 1 + 2 files changed, 40 insertions(+) diff --git a/test/common_plat/validation/api/packet/packet.c b/test/common_plat/validation/api/packet/packet.c index 284aaeb..5d3ad83 100644 --- a/test/common_plat/validation/api/packet/packet.c +++ b/test/common_plat/validation/api/packet/packet.c @@ -1292,6 +1292,44 @@ void packet_test_copydata(void) odp_packet_free(pkt); } +static +void packet_test_zerodata_pkt(odp_packet_t pkt) +{ + uint32_t pkt_len = odp_packet_len(pkt); + uint8_t *data_buf; + uint32_t i; + int correct_memory; + + CU_ASSERT_FATAL(pkt_len > 0); + + data_buf = malloc(pkt_len); + CU_ASSERT_PTR_NOT_NULL_FATAL(data_buf); + + for (i = 0; i < pkt_len; i++) + data_buf[i] = (uint8_t)i; + + CU_ASSERT(!odp_packet_copy_from_mem(pkt, 0, pkt_len, data_buf)); + CU_ASSERT(!odp_packet_zero_data(pkt, 0, pkt_len)); + memset(data_buf, 0xff, pkt_len); + CU_ASSERT(!odp_packet_copy_to_mem(pkt, 0, pkt_len, data_buf)); + + correct_memory = 1; + for (i = 0; i < pkt_len; i++) + if (data_buf[i] != 0) { + correct_memory = 0; + break; + } + CU_ASSERT(correct_memory); + + free(data_buf); +} + +void packet_test_zerodata(void) +{ + packet_test_zerodata_pkt(test_packet); + packet_test_zerodata_pkt(segmented_test_packet); +} + void packet_test_concatsplit(void) { odp_packet_t pkt, pkt2; @@ -2412,6 +2450,7 @@ odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_add_rem_data), ODP_TEST_INFO(packet_test_copy), ODP_TEST_INFO(packet_test_copydata), + ODP_TEST_INFO(packet_test_zerodata), ODP_TEST_INFO(packet_test_concatsplit), ODP_TEST_INFO(packet_test_concat_small), ODP_TEST_INFO(packet_test_concat_extend_trunc), diff --git a/test/common_plat/validation/api/packet/packet.h b/test/common_plat/validation/api/packet/packet.h index 783b7a1..42d2f4c 100644 --- a/test/common_plat/validation/api/packet/packet.h +++ b/test/common_plat/validation/api/packet/packet.h @@ -29,6 +29,7 @@ void packet_test_error_flags(void); void packet_test_add_rem_data(void); void packet_test_copy(void); void packet_test_copydata(void); +void packet_test_zerodata(void); void packet_test_concatsplit(void); void packet_test_concat_small(void); void packet_test_concat_extend_trunc(void);