From patchwork Mon Oct 23 10:00:23 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: 116673 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4459997qgn; Mon, 23 Oct 2017 03:07:48 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Srb5S1gfj21Dl0WNlzeaGzi8p3afJ+CG5bJN4D5kMw/o5JmmyPv5VEvpHkQTmqm63eK4Bc X-Received: by 10.55.50.71 with SMTP id y68mr18459487qky.136.1508753268029; Mon, 23 Oct 2017 03:07:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508753268; cv=none; d=google.com; s=arc-20160816; b=cfnmlbf94wFOCLRNSoKnoG5rxPGdQu3voYIHY0bmYIcz+FaE/CuYvB/FfedJmeuzn6 RaVTBXBNFy1kEmqZyvYxtBrZGsujoCvQPCiX5LZJaKSgmpViRtOqaNaslgyhC4EvKXOR KiZ7OHu178IWCqXyStMEVESFtbjxfu919IQIsrPOwsfrrWPrDt5fjuOKMTEkm9VZknKi Kcd24BekOTInVoEC7yaXmE1YwYeomW0ca2mRjdTv/kD7vdSs+SfBzQsBCHs9/EE84sXi p8yzlQcl+QXsOqe3Q2lH/A39kVCGXGNd7BScW5wYkCFqLue9Vhn79M8Khc5iDcrNEj6n en3g== 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=w4x9JTnfznqLyqquWGRZprq/8Sk//oDB4fLT9E3ONAg=; b=uoVFgvFI+0VegvfWBNZpBT1KX55AXGoH1zv7panMh+o7d/jpbR6lQQaCPCGe5f63LV pV8XnXkTyUrS1HuPCmel1PwhH0Z9rANMLiX9i/GCbKS59oSbG+4yCNyCBAQ9Ta66xdI6 bJV1mJovrTDHx1mcGDkwBXUJ3fFsnLA7HjzewS7i03IHvkQHNMK5GG3MuFWVIQDxd09m kae9w52Zskm93Nff2ip0JpvXUu+QA99hUSr/DNpTZ6lGva4RjTVIrnNzEbJE2rlFgttE KLuims7qOTXhA0l6zpH6GsYsD1gwF+1npbSDjvWogN1VsuIRbJrdLQMscCc65lDNJ8kz l0UQ== 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 k34si5879079qtb.61.2017.10.23.03.07.47; Mon, 23 Oct 2017 03:07:48 -0700 (PDT) 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 B519C61D23; Mon, 23 Oct 2017 10:07: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,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 58F2B619C5; Mon, 23 Oct 2017 10:03:31 +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 4481561DE2; Mon, 23 Oct 2017 10:03:18 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 0F37F6185A for ; Mon, 23 Oct 2017 10:00:42 +0000 (UTC) Received: from mxback5j.mail.yandex.net (mxback5j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10e]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 760074304803 for ; Mon, 23 Oct 2017 13:00:40 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback5j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Py9FE40C0G-0eF4OWu4; Mon, 23 Oct 2017 13:00:40 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id AuFEnCuXXk-0dRiekXi; Mon, 23 Oct 2017 13:00:39 +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, 23 Oct 2017 13:00:23 +0300 Message-Id: <1508752825-12017-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508752825-12017-1-git-send-email-odpbot@yandex.ru> References: <1508752825-12017-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 242 Subject: [lng-odp] [PATCH API-NEXT v2 1/3] api: packet: ones complement sum 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: Petri Savolainen Added packet metadata for ones complement sum over IP payload in a packet. Some NICs calculate the sum during packet input (at least for IP fragments) and store the value into the packet descriptor. This offloads L4 checksum calculation for IP fragments as SW does not need sum all payload data, but just combine pre-calculated sums from packet descriptors and remove extra header fields from the sum. Signed-off-by: Petri Savolainen --- /** Email created from pull request 242 (psavol:next-checksum-metadata) ** https://github.com/Linaro/odp/pull/242 ** Patch: https://github.com/Linaro/odp/pull/242.patch ** Base sha: ec6510b33e8b96d6d6670efb9dc3c9101baed6c6 ** Merge commit sha: 19351e51472213736d5301c666500b459ccabff7 **/ include/odp/api/spec/packet.h | 17 +++++++++++++++++ include/odp/api/spec/packet_flags.h | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index 62ecf70e1..55793ff20 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -1437,6 +1437,23 @@ void odp_packet_l3_chksum_insert(odp_packet_t pkt, int l3); void odp_packet_l4_chksum_insert(odp_packet_t pkt, int l4); /** + * Ones' complement sum of IP payload data + * + * Returns 16-bit ones' complement sum calculated over IP payload data in the + * packet (includes L4 headers, excludes Ethernet CRC). In case of odd number of + * bytes, calculation uses a zero byte as padding at the end. The sum may be + * used as part of e.g. UDP/TCP checksum checking, especially with IP + * fragments. + * + * Use odp_packet_has_ones_comp() to check if the sum has been set. + * + * @param pkt Packet handle + * + * @return Ones' complement sum of IP payload data + */ +uint16_t odp_packet_ones_comp(odp_packet_t pkt); + +/** * Packet flow hash value * * Returns the hash generated from the packet header. Use diff --git a/include/odp/api/spec/packet_flags.h b/include/odp/api/spec/packet_flags.h index 377b75ba0..31979ac4b 100644 --- a/include/odp/api/spec/packet_flags.h +++ b/include/odp/api/spec/packet_flags.h @@ -277,6 +277,15 @@ int odp_packet_has_sctp(odp_packet_t pkt); int odp_packet_has_icmp(odp_packet_t pkt); /** + * Check for ones' complement sum + * + * @param pkt Packet handle + * @retval non-zero if packet contains ones' complement sum + * @retval 0 if packet does not contain ones' complement sum + */ +int odp_packet_has_ones_comp(odp_packet_t pkt); + +/** * Check for packet flow hash * * @param pkt Packet handle