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