From patchwork Tue Sep 26 19: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: 114280 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4175308qgf; Tue, 26 Sep 2017 12:02:39 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDwkBq3znOsfEHXc41b3MOIEGvxuZRGrxRQED9wTa5Be6j5l/0Hx2E8igr4yt/HFFXyNABH X-Received: by 10.157.52.145 with SMTP id g17mr2781664otc.84.1506452559853; Tue, 26 Sep 2017 12:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506452559; cv=none; d=google.com; s=arc-20160816; b=iN4BgRhhthb1w2eeCf56B3bQHbsG8X5TYePLvmNi9aptw72XLFJyys/8qMbUPzVGUC yX0hj4VmOijcT3KsXzUBn8hoSq1pMlMkDmQYDDSogTjLLja31UDr5npzvWi5uk+nZc8e sFobSoJcYvZ3AZOVnW02JRWCT7MEE4/zn9KWRc6iWgX7gW5UTLw7jsA5iF5WN7Ba9va3 OJtCXv44+g+gVE6ZaDiICaCo6KPgfUlneIi81Q5HIHdtT/ys6MAU7qZRpjHZMuXd91lU 7WQZdwjQq0TAX6raOrt/HeqQkFt2ZUVOMV2wEbWRh4YfubdgW1xwIJUPONSb3ZnXo7ck tkwg== 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=IECcLevOdJ5ZXQ7hhAinbM3sK++RofoGHP1jwo+t3H8=; b=0minIbq/DxuJkkISHrAHfSg8i5HE95Q0hOp3UlgI/VM+8AQoPPiKI9A4iBDm78ybvw oEmETHLu2cdHxFqtL4xGhn74FFMAc2uoHu0T2dBoO55SOYMcC+yvjQqUA/C5p6hvktxI toqFBCJU426aMawSvmmQU5oKOljww+pmbmiBKsqdN3iiy3cAXOF1hx7g2nvemtjAtdZ/ xCwgXUfjjn62F3niUP0p54UUg6KQXkZW4xx0Bm5Fq/U6OWqd0ZuOsg4cHLx7oLU3WcOB LSyQj369OlKLsVUEnE+jjlVGue124dOq1xZhKOuA3UT10G8mBoZGuu4q5Ywi8C7i2Y9+ rJgA== 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 i14si7789449ioo.368.2017.09.26.12.02.39; Tue, 26 Sep 2017 12:02:39 -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 5029B60DB2; Tue, 26 Sep 2017 19:02:39 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 C8C0260DBD; Tue, 26 Sep 2017 19:00:42 +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 9636F60D72; Tue, 26 Sep 2017 19:00:19 +0000 (UTC) Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [5.45.198.241]) by lists.linaro.org (Postfix) with ESMTPS id 1D39A60D6F for ; Tue, 26 Sep 2017 19:00:13 +0000 (UTC) Received: from mxback9j.mail.yandex.net (mxback9j.mail.yandex.net [IPv6:2a02:6b8:0:1619::112]) by forward101j.mail.yandex.net (Yandex) with ESMTP id E9FE4124149C for ; Tue, 26 Sep 2017 22:00:11 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback9j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 2VTbEwiXnO-0BZSS4P4; Tue, 26 Sep 2017 22:00:11 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 7XQL04xJi6-0BL0pKuo; Tue, 26 Sep 2017 22:00:11 +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: Tue, 26 Sep 2017 22:00:05 +0300 Message-Id: <1506452407-23070-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506452407-23070-1-git-send-email-odpbot@yandex.ru> References: <1506452407-23070-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 193 Subject: [lng-odp] [PATCH API-NEXT v2 1/3] api: chksum: add ones complement sum function 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 This is a low level function for IP/UDP/TCP checksum calculations on SW. HW cannot always calculate checksums, for that or other reasons application may need calculate ones compelement sums. This kind of low level function is easy to optimize e.g. with CPU vector instructions. In addition to this, there may be higher (packet) level functions introduced later. Signed-off-by: Petri Savolainen --- /** Email created from pull request 193 (psavol:next-ip-checksum) ** https://github.com/Linaro/odp/pull/193 ** Patch: https://github.com/Linaro/odp/pull/193.patch ** Base sha: e04e5f90df69e3031622b77fb5273b85d47eb966 ** Merge commit sha: 18d37c68b9d3a13db328316de06eed14113d0fc2 **/ include/odp/api/spec/chksum.h | 53 +++++++++++++++++++++++++ include/odp_api.h | 1 + platform/Makefile.inc | 1 + platform/linux-generic/Makefile.am | 1 + platform/linux-generic/include/odp/api/chksum.h | 34 ++++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 include/odp/api/spec/chksum.h create mode 100644 platform/linux-generic/include/odp/api/chksum.h diff --git a/include/odp/api/spec/chksum.h b/include/odp/api/spec/chksum.h new file mode 100644 index 000000000..e523ac286 --- /dev/null +++ b/include/odp/api/spec/chksum.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP Hash functions + */ + +#ifndef ODP_API_CHKSUM_H_ +#define ODP_API_CHKSUM_H_ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** @defgroup odp_chksum ODP CHECKSUM + * ODP checksum functions + * @{ + */ + +/** + * Ones' complement sum of 16-bit words + * + * Calculates 16-bit ones' complement sum over the data. In case of odd number + * of bytes, calculation uses a zero byte as padding at the end. This algorithm + * may be used as part of e.g. IPv4/UDP/TCP checksum generation and checking. + * + * @param data Pointer to data. Data address must be 16-bit aligned + * in minimum. + * @param data_len Data length in bytes. In case of an odd number, calculation + * includes one byte of padding. + * + * @return Ones' complement sum + */ +uint16_t odp_chksum_ones_comp16(const void *data, uint32_t data_len); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#include +#endif diff --git a/include/odp_api.h b/include/odp_api.h index 86232ee10..069ec9d1e 100644 --- a/include/odp_api.h +++ b/include/odp_api.h @@ -24,6 +24,7 @@ extern "C" { #include #include #include +#include #include #include #include diff --git a/platform/Makefile.inc b/platform/Makefile.inc index ac5cd765d..2699142db 100644 --- a/platform/Makefile.inc +++ b/platform/Makefile.inc @@ -22,6 +22,7 @@ odpapispecinclude_HEADERS = \ $(top_srcdir)/include/odp/api/spec/barrier.h \ $(top_srcdir)/include/odp/api/spec/buffer.h \ $(top_srcdir)/include/odp/api/spec/byteorder.h \ + $(top_srcdir)/include/odp/api/spec/chksum.h \ $(top_srcdir)/include/odp/api/spec/classification.h \ $(top_srcdir)/include/odp/api/spec/compiler.h \ $(top_srcdir)/include/odp/api/spec/cpu.h \ diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 3e26aab4c..994bbbeee 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -36,6 +36,7 @@ odpapiinclude_HEADERS = \ $(srcdir)/include/odp/api/byteorder.h \ $(srcdir)/include/odp/api/classification.h \ $(srcdir)/include/odp/api/compiler.h \ + $(srcdir)/include/odp/api/chksum.h \ $(srcdir)/include/odp/api/cpu.h \ $(srcdir)/include/odp/api/cpumask.h \ $(srcdir)/include/odp/api/crypto.h \ diff --git a/platform/linux-generic/include/odp/api/chksum.h b/platform/linux-generic/include/odp/api/chksum.h new file mode 100644 index 000000000..18dcb6d11 --- /dev/null +++ b/platform/linux-generic/include/odp/api/chksum.h @@ -0,0 +1,34 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP checksum functions + */ + +#ifndef ODP_PLAT_CHKSUM_H_ +#define ODP_PLAT_CHKSUM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @ingroup odp_chksum + * @{ + */ + +/** + * @} + */ + +#include + +#ifdef __cplusplus +} +#endif + +#endif