From patchwork Mon Nov 20 15:00:11 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: 119288 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3962318qgn; Mon, 20 Nov 2017 07:01:46 -0800 (PST) X-Google-Smtp-Source: AGs4zMbx8OiPI+va/NrWUoIrt/XEgYpOPiExZXpy75hB83MtfXxf5F+oO5DwRZsurxmHEvd6cUAd X-Received: by 10.200.45.168 with SMTP id p37mr21713652qta.247.1511190106338; Mon, 20 Nov 2017 07:01:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511190106; cv=none; d=google.com; s=arc-20160816; b=gPfRxiHdjbMuR3olyIXE04Wb83GU3i8qo/hDe32a3Cs983nv1QXy0r/GR6sanD7N4G c4eSymYF/hdOtqkVNr0rf4AipJG6xQLDb0DXNedFNUN86jtGthVsjiF8GOdVtYEOz4Jw E0dcKy9YS/KJYSl+XdtVUZMDqX0JO9YGqT34IaKc1P4QRtnCDYf1cVKnekvpMP+k9n8y QTugXjIJMyo46vkLboeKs0QuW122QzETJW7L3ymnXYn3ZwcD2P8diFJQ8nQMuF4q5N2M x525sOa+R7Y/awjRCmjpGU1zHWPiaOqeuFstL/BDoNQ/6AUJjpkEE1aBHrm4fZ80DX8Y jyDQ== 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=PbYOaYFF1/JKZdVasGFPJTybU/jdzb/jz5uwKUrcpxU=; b=yoQOwhIoU1gLa3jAG5RL0kgl/e5XGwgdJyZGngdy//NuddWjvW20NjAgjYOmxqdP5/ dP8UtuRLc4ZhTBRvfgYJvBwsMF/qn+GrQZIbBfnJ04HJOS5BTZts32hlxpZxMyEZW6gM MqedvNwodepn/eZTfH1zhjN4uiAVf9vkTQLzogi2k8f+SaID4FwMyQ4BBmpL+tngd4Mp sGNSyfx5L9UzbinPrdKZUFlSTLYQL9s6lA3U9ao06TXca4R3D5cCsuWkbtwPG/3UBBro bHLpee/i18+ws6+t2bHYIw1cfdLFHDQiXOtIyyMEym3XhWH2o1jkLeu3c4GbDoqEC2Dm +e3g== 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 i65si583768qkb.21.2017.11.20.07.01.46; Mon, 20 Nov 2017 07:01:46 -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 0239E608BC; Mon, 20 Nov 2017 15:01:46 +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 03B9D605D7; Mon, 20 Nov 2017 15:00:46 +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 D71E9607A0; Mon, 20 Nov 2017 15:00:28 +0000 (UTC) Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by lists.linaro.org (Postfix) with ESMTPS id 36FAE60389 for ; Mon, 20 Nov 2017 15:00:22 +0000 (UTC) Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward105j.mail.yandex.net (Yandex) with ESMTP id B6431183A41 for ; Mon, 20 Nov 2017 18:00:20 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id GtKmxMmdUN-0EAukQrA; Mon, 20 Nov 2017 18:00:14 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hPBG8CmQZ0-0EBKK3Un; Mon, 20 Nov 2017 18:00:14 +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:11 +0300 Message-Id: <1511190013-8520-2-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 1/3] example: switch to using ODP chksum 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 ODP now provides odp_chksum_ones_comp16, switch examples to use it instead of odph_chksum helper function. 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 **/ example/generator/odp_generator.c | 7 ++++--- example/ipsec/odp_ipsec_stream.c | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 912fe7e9e..e1d98539f 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -355,7 +355,7 @@ static int setup_udp_pkt(odp_packet_t pkt, odp_pktout_config_opt_t *pktout_cfg) ip->id = odp_cpu_to_be_16(seq); if (!pktout_cfg->bit.ipv4_chksum) { ip->chksum = 0; - ip->chksum = odph_chksum(ip, ODPH_IPV4HDR_LEN); + ip->chksum = ~odp_chksum_ones_comp16(ip, ODPH_IPV4HDR_LEN); } if (pktout_cfg->bit.ipv4_chksum || pktout_cfg->bit.udp_chksum) { @@ -453,7 +453,7 @@ static int setup_icmp_pkt(odp_packet_t pkt, ip->id = odp_cpu_to_be_16(seq); if (!pktout_cfg->bit.ipv4_chksum) { ip->chksum = 0; - ip->chksum = odph_chksum(ip, ODPH_IPV4HDR_LEN); + ip->chksum = ~odp_chksum_ones_comp16(ip, ODPH_IPV4HDR_LEN); } /* icmp */ @@ -466,7 +466,8 @@ static int setup_icmp_pkt(odp_packet_t pkt, memcpy(tval_d, &tval, sizeof(uint64_t)); icmp->chksum = 0; - icmp->chksum = odph_chksum(icmp, args->appl.payload + ODPH_ICMPHDR_LEN); + icmp->chksum = ~odp_chksum_ones_comp16(icmp, args->appl.payload + + ODPH_ICMPHDR_LEN); if (pktout_cfg->bit.ipv4_chksum) { odp_packet_l2_offset_set(pkt, 0); diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c index e37fbee29..bc5d572f0 100644 --- a/example/ipsec/odp_ipsec_stream.c +++ b/example/ipsec/odp_ipsec_stream.c @@ -269,7 +269,8 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream, inner_ip->frag_offset = 0; inner_ip->src_addr = odp_cpu_to_be_32(stream->src_ip); inner_ip->dst_addr = odp_cpu_to_be_32(stream->dst_ip); - inner_ip->chksum = odph_chksum(inner_ip, sizeof(*inner_ip)); + inner_ip->chksum = ~odp_chksum_ones_comp16(inner_ip, + sizeof(*inner_ip)); data += sizeof(*inner_ip); } @@ -290,7 +291,7 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream, /* Close ICMP */ icmp->chksum = 0; - icmp->chksum = odph_chksum(icmp, data - (uint8_t *)icmp); + icmp->chksum = ~odp_chksum_ones_comp16(icmp, data - (uint8_t *)icmp); /* Close ESP if specified */ if (esp) { From patchwork Mon Nov 20 15: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: 119289 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3963869qgn; Mon, 20 Nov 2017 07:02:47 -0800 (PST) X-Google-Smtp-Source: AGs4zMZQdB6q+ivvH8SdGlt3t08YyAQ8OgG9Tag500x9GQPUIFt+ggyWhMP7c/eN9lMiHurLaebX X-Received: by 10.200.37.61 with SMTP id 58mr22116118qtm.187.1511190167168; Mon, 20 Nov 2017 07:02:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511190167; cv=none; d=google.com; s=arc-20160816; b=mcx1BxnoeNR9DVqTrrsuKoH0tBXympH0DzwXahZmzKopiUY5wWrcpL2NY/X7VcpQwY 0nTSZo/tLhwdd4qr9O6gspnjFMZe+4beddAshCulvL0hu9Gdgy/144ApnHhe/1jvB/XA qQZjNeMG6J7nGdjWHDXJd5AHbWmQNWzvmzW2BmKnl3S0/Ei+42/EJD7JjSoL4xmONmGH WLh3GdpWBJYiQRvetiTHFKwqYOwbm8Jo/yOnF3UB7WI4dGmqh6yBrf65OLlQm2kpYOQU 0f10IZ7e98iP2Kb4qzjSCtbAMSFrohKIP3lc8U+5KcgUuWPhX1g0nFSfRAVnjFa3Q/nL Psag== 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=XxqpPFsWk3feZhhvn5XtYyV57fhtrLIfecBKCjMZcds=; b=RHS0kX8/kt16HxljDbx9jn5kDP40grYcFyJyvVK6cOahYWx9KRCBkvVazKLH00YMKf fapu9NDLVVbr45Agpgem3VojVv5Sc/82iIBdPIjGxABthq9HDo6ibZ4cckgKOX7cykov HEXejmtZA2/mHp07n7PcMs7hZUInyYgZM9dVjzd4zvJeqzX38iB+xQg9SLwQbc45HznA 9ftuzOqU3kI+lvHbqbcrApzgwQH0Zt0pzl1fULZSal5Jb1xiwlUcDhmx+VZatDLi29cU kwZBmONTbaEse7/C9B5bRaqQmA0n22kbkNV7yowJOi8SDYq/nubDUnRltSYZ3LHSqtya tCzg== 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 144si2626000qki.207.2017.11.20.07.02.46; Mon, 20 Nov 2017 07:02:47 -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 76CE3608E6; Mon, 20 Nov 2017 15:02:46 +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 831216084B; Mon, 20 Nov 2017 15:00:52 +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 5063860695; Mon, 20 Nov 2017 15:00:29 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id B15446038B for ; Mon, 20 Nov 2017 15:00:22 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 5BCEB2182D31 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 mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id vafllc4jHg-0LreuDMA; Mon, 20 Nov 2017 18:00:21 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hPBG8CmQZ0-0KBK543e; Mon, 20 Nov 2017 18:00:20 +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:12 +0300 Message-Id: <1511190013-8520-3-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 2/3] helper: 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. This removes now unnecessary odph_cksum() function. 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 **/ helper/include/odp/helper/chksum.h | 27 --------------------------- helper/include/odp/helper/ip.h | 2 +- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/helper/include/odp/helper/chksum.h b/helper/include/odp/helper/chksum.h index 1bf950c8b..ed2de91fb 100644 --- a/helper/include/odp/helper/chksum.h +++ b/helper/include/odp/helper/chksum.h @@ -34,33 +34,6 @@ typedef enum { ODPH_CHKSUM_RETURN /**< Don't generate or verify chksum */ } odph_chksum_op_t; -/** - * Checksum - * - * @param buffer calculate chksum for buffer - * @param len buffer length - * - * @return checksum value in network order - */ -static inline odp_u16sum_t odph_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; -} - /** * General Purpose TCP/UDP checksum function * diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h index c6eb9d767..b96aab280 100644 --- a/helper/include/odp/helper/ip.h +++ b/helper/include/odp/helper/ip.h @@ -125,7 +125,7 @@ static inline int odph_ipv4_csum(odp_packet_t pkt, if (odp_unlikely(res < 0)) return res; - *chksum = odph_chksum(buf, nleft); + *chksum = ~odp_chksum_ones_comp16(buf, nleft); return 0; } 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; }