From patchwork Mon May 15 21:00:12 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: 99835 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1724800qge; Mon, 15 May 2017 14:00:47 -0700 (PDT) X-Received: by 10.200.48.98 with SMTP id g31mr7240794qte.119.1494882047431; Mon, 15 May 2017 14:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494882047; cv=none; d=google.com; s=arc-20160816; b=UUcEEXY+nyrLD4ehXRodKxtQU1fWxzYEogH/OHXDrnwYbLx/5j6MgFSO/u9S1iFTX8 2JgatOfnYhOZbP9HO+QCr2tPeiJO6TJp3RjaOeqeC8CsJ3qzz+tEy1JRweD1k1ycoDom Gz9f1+cVjYdNwKtFvN7DiPJI6Cq+Tjlv/vkg/nETA01s5yD0jB7kxkzGZkhXyOqKZrh8 jyXax8b3JZ82to2jClwKFfS65gyl8hErSeuyDZPWJWpjIf4QG5X0QqdLghNKMIrTIxHs FYZKu8pr0JxbrGUU98GkzqqbVloAARcs8DG8CCb0pyhAiB7+bZ1IWfrrtLDHGyubP2M5 abLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=uwxsBMabuSjuY9bfQa3CkdM02G2nhAWqcX0JaG6UlQM=; b=DOUvijyTc8EtTM0ezKd36zCseJPhxotm+PRzKGm2vplbLE/mmPZOcwYiQUPtVh3Wr7 1snMhXbGR7aTbc2vzRcd683hJKTM0wfsGf+cTXJiLTYpBf2i1fh+HAiUK1i3RbKt/1Ah XxTVRjglI3BdUxV42YSAaKlNvKXfDo09prDo86qx+hb+msJqnlmg+CyP0dDFVbYxfi4W v7A4bumcUVfee11oSvAm75Pt6DxLLj0Az4MvxTCMBx28LvYGDzphl2GjtYfftttgrLgm yaHArEs1QmPauzO5ryLsxbuXvJuRMHxaS/fTXz82RY7Ymf0ARzjHY0XDnD0DibvnDyKk anzg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v33si11815028qtb.96.2017.05.15.14.00.47; Mon, 15 May 2017 14:00:47 -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 1BB5B6063C; Mon, 15 May 2017 21:00:47 +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 8F8316093D; Mon, 15 May 2017 21:00:23 +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 D86EF608ED; Mon, 15 May 2017 21:00:20 +0000 (UTC) Received: from forward5o.cmail.yandex.net (forward5o.cmail.yandex.net [37.9.109.249]) by lists.linaro.org (Postfix) with ESMTPS id E3C54608E5 for ; Mon, 15 May 2017 21:00:18 +0000 (UTC) Received: from smtp2h.mail.yandex.net (smtp2h.mail.yandex.net [84.201.187.145]) by forward5o.cmail.yandex.net (Yandex) with ESMTP id A2DFA20F7C for ; Tue, 16 May 2017 00:00:16 +0300 (MSK) Received: from smtp2h.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2h.mail.yandex.net (Yandex) with ESMTP id 710D7781A0A for ; Tue, 16 May 2017 00:00:15 +0300 (MSK) Received: by smtp2h.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id k4LJbEzdOr-0FtCZbhD; Tue, 16 May 2017 00:00:15 +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: Tue, 16 May 2017 00:00:12 +0300 Message-Id: <1494882012-30270-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494882012-30270-1-git-send-email-odpbot@yandex.ru> References: <1494882012-30270-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 18 Subject: [lng-odp] [PATCH API-NEXT v1 1/1] linux-generic: packet: add functions to optimize memset and memcmp paths 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 Add function implementing memset and memcmp on packet object. 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: 900dd9e2d3d2ae751ab2bc4e11dbd48ea7ed7030 ** Merge commit sha: 2c8f402e929c8d49c62dede47add2b8046672607 **/ .../linux-generic/include/odp_packet_internal.h | 6 +++ platform/linux-generic/odp_packet.c | 48 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index d0db700..a480a74 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -237,6 +237,12 @@ int packet_parse_common(packet_parser_t *pkt_hdr, const uint8_t *ptr, int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr); +int _odp_packet_set_data(odp_packet_t pkt, uint32_t offset, + uint8_t c, uint32_t len); + +int _odp_packet_cmp_data(odp_packet_t pkt, uint32_t offset, + const void *s, uint32_t len); + #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 9ff642b..6799c6e 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1634,6 +1634,54 @@ int odp_packet_move_data(odp_packet_t pkt, uint32_t dst_offset, pkt, src_offset, len); } +int _odp_packet_set_data(odp_packet_t pkt, uint32_t offset, + uint8_t c, uint32_t len) +{ + void *mapaddr; + uint32_t seglen = 0; /* GCC */ + uint32_t setlen; + 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); + setlen = len > seglen ? seglen : len; + memset(mapaddr, c, setlen); + offset += setlen; + len -= setlen; + } + + return 0; +} + +int _odp_packet_cmp_data(odp_packet_t pkt, uint32_t offset, + const void *s, uint32_t len) +{ + const uint8_t *ptr = s; + void *mapaddr; + uint32_t seglen = 0; /* GCC */ + uint32_t cmplen; + int ret; + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); + + ODP_ASSERT(offset + len <= pkt_hdr->frame_len); + + while (len > 0) { + mapaddr = packet_map(pkt_hdr, offset, &seglen, NULL); + cmplen = len > seglen ? seglen : len; + ret = memcmp(mapaddr, ptr, cmplen); + if (ret != 0) + return ret; + offset += cmplen; + len -= cmplen; + ptr += cmplen; + } + + return 0; +} + /* * * Debugging