From patchwork Mon Nov 20 15:00:13 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: 119290 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3964011qgn; Mon, 20 Nov 2017 07:02:53 -0800 (PST) X-Google-Smtp-Source: AGs4zMZH1Hf1501EXYtmZIas4ytRmoQT7UXKkjtl3AUsCl2VkBkduqKTPlWVKmq31mwRqNvZhpFV X-Received: by 10.129.153.87 with SMTP id q84mr9046419ywg.350.1511190173155; Mon, 20 Nov 2017 07:02:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511190173; cv=none; d=google.com; s=arc-20160816; b=BKT2VNpSKjh8ugbLuQOhNQkmzKqCyBijD8zDPM/JVwh0fON9ZqGgm/8EnSXW+NvPXU sb9iRHrT6DbEoXt1FDAgMPUsl5Oy/meFrzlaUlhV7hTTJCY3fQhGPrUYGN8hCkWBR8pT xU7F8CpDmLs0ZZYzmh24MdJXrVfEtXRBdeyxCgNw7WJOHLmAE0lXV+wXbQZTmmzJKbV7 wVxvl5wl/n9cqKAQ+l3ixVW48jP3gPQzRNCdbJ2Q7hZ9ouuEek7+SGe4EtLI4Un+6dgN PabIPrVAf4/vhOptHPc8jsKTXXZHo9wPj2kt16tqSWAsWtJdGsBKsngYZ4mMFyuxVPKQ ya9g== 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=IAz6fmzZWvFqUyTS1NajnD+tojQCzwSJiebXAOXqZx4=; b=E/uOYChOchTdMqvrHuu6VyQInebpCxeWnpGLxkpF0GAMi8yguGV76EQ4SiHDcJFGG5 cE7cYt43TsVbNbn8wYonngn9eLrvXNBqU70FWGKEJSJp4t1pAT3PCHj88z+XosqqUblI id8cB3ALGeM4iP2nXbpgxNKoiv1g69sYpalD6cv7xL2shtr+wk2zqGjlwJ+Klxqac8Ju cH7hsHvDnjeTfVqim2S+JanxnRrkv7dCC5UQnA5uFfCEd+vCfL2YL5XhLDqF7Ktlorsd kirouz5DdILfBKqZrJqFw5QAI6v7JOt1e/8yaB+howZ4h7hpsmLvQ4wctZTUUiGdT7zh CjOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id f6si2888443qkc.271.2017.11.20.07.02.52; Mon, 20 Nov 2017 07:02:53 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 BE67C6084B; Mon, 20 Nov 2017 15:02:52 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 BD9FF6087F; Mon, 20 Nov 2017 15:00:54 +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 4706D60593; Mon, 20 Nov 2017 15:00:37 +0000 (UTC) Received: from forward104p.mail.yandex.net (forward104p.mail.yandex.net [77.88.28.107]) by lists.linaro.org (Postfix) with ESMTPS id 8045A6038C for ; Mon, 20 Nov 2017 15:00:23 +0000 (UTC) Received: from mxback3g.mail.yandex.net (mxback3g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:164]) by forward104p.mail.yandex.net (Yandex) with ESMTP id 1B5A91837C8 for ; Mon, 20 Nov 2017 18:00:21 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback3g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id JTRvT2Oxx3-0LTSX89S; Mon, 20 Nov 2017 18:00:21 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hPBG8CmQZ0-0LBe37ii; Mon, 20 Nov 2017 18:00:21 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Mon, 20 Nov 2017 18:00:13 +0300 Message-Id: <1511190013-8520-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511190013-8520-1-git-send-email-odpbot@yandex.ru> References: <1511190013-8520-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 280 Subject: [lng-odp] [PATCH API-NEXT v3 3/3] linux-gen: ipsec: use new odp checksum API 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 Use odp_chksum_ones_comp16 which may be platform-optimized. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 280 (lumag:chksum) ** https://github.com/Linaro/odp/pull/280 ** Patch: https://github.com/Linaro/odp/pull/280.patch ** Base sha: d4b364849c4abb4c71e0c5260e1a793ebb8dc97d ** Merge commit sha: 9fda6f107cef0c4074880995a90b30cbeac27ce8 **/ platform/linux-generic/odp_ipsec.c | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index 0ebc65341..32aae1719 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -7,6 +7,7 @@ #include "config.h" #include +#include #include @@ -103,34 +104,6 @@ static odp_ipsec_packet_result_t *ipsec_pkt_result(odp_packet_t packet) return &odp_packet_hdr(packet)->ipsec_ctx; } -/** - * Checksum - * - * @param buffer calculate chksum for buffer - * @param len buffer length - * - * @return checksum value in network order - */ -static inline -odp_u16sum_t _odp_chksum(void *buffer, int len) -{ - uint16_t *buf = (uint16_t *)buffer; - uint32_t sum = 0; - uint16_t result; - - for (sum = 0; len > 1; len -= 2) - sum += *buf++; - - if (len == 1) - sum += *(unsigned char *)buf; - - sum = (sum >> 16) + (sum & 0xFFFF); - sum += (sum >> 16); - result = ~sum; - - return (__odp_force odp_u16sum_t) result; -} - static inline int _odp_ipv4_csum(odp_packet_t pkt, uint32_t offset, _odp_ipv4hdr_t *ip, @@ -150,7 +123,7 @@ static inline int _odp_ipv4_csum(odp_packet_t pkt, if (odp_unlikely(res < 0)) return res; - *chksum = _odp_chksum(buf, nleft); + *chksum = ~odp_chksum_ones_comp16(buf, nleft); return 0; }