From patchwork Thu Sep 28 01: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: 114386 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp128404qgf; Wed, 27 Sep 2017 18:01:52 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA6TCPghdB1vZApXnsDmNooTiJKwZY5JBcXKdgVRP59pBRFeP/Tw5CiyvH4KT2zbAFJqpIx X-Received: by 10.107.107.11 with SMTP id g11mr5061683ioc.161.1506560512004; Wed, 27 Sep 2017 18:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506560511; cv=none; d=google.com; s=arc-20160816; b=O60vpvWXT0fl6F+/zg0fMYnsmAjZ7FJjtsOuo/GeL2f2C+g8fi73030O2QKW+tbS87 HzRi35ZZkXCzaTO1trARQQKXZZK7uZJT5Udm6BUMjssOjyb7WODF+Bd7eO3Y8FAEPSUP pnSIBT38X8nrf93CJ3Ubq/jCa+9LeMmjlmIuq8ytUkW+2FrILl+soGDNtHuIj2MBecma N1K3km5DJNypCW2ElS8AAKI2kGz1gv7on7//JieEU44hEnepVcoh93NQr+xrV5Lch+sc 3WSoSPXsg865uN/6G4Z8dZIoDnfOZv9wdcFDgYKFz62xDoXls3D2x2QaeYVcAaM6GAug aeHw== 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:cc:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=CdOo+Z9vW0NXWV+yYcIPLyvZpNvX6Z41tQVgidyGsUY=; b=w/51+s660eEoeX1zgulv5jo5erK+I+npBWeCWPRjZ7MhoubZWZctbLcy39w05B816g ymkfye7loIfkZ9hxYIuaUCZPVGrl90nQqwSyW04mQXQagnDHdZMSaMi9qq7vmEvq9FXw yarljTytmAX3JDIFzsLzuaokZIW2bRJaRcdJteFWr+VOPGl6+R9av/3DZeYx31Jop514 tT6DzZ7p2TQItev0/Oj2xnnYZ6P8yA63UCYOZusQnqL/0E2LXJzoAHlVEZQnoaG2oH9Y uPm+00Om+vXbLDoBwnW9letLUEDVHb4wB1E3nYDwN6rQLIYNq8RKh4DXq9/nz3Gcc4Me iEmg== 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 d184si648566ita.50.2017.09.27.18.01.51; Wed, 27 Sep 2017 18:01:51 -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 7C26F60C11; Thu, 28 Sep 2017 01:01:51 +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, 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 4F6BA60C2F; Thu, 28 Sep 2017 01:00:50 +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 6A36560C16; Thu, 28 Sep 2017 01:00:43 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id 1BFDE60893 for ; Thu, 28 Sep 2017 01:00:21 +0000 (UTC) Received: from mxback7j.mail.yandex.net (mxback7j.mail.yandex.net [IPv6:2a02:6b8:0:1619::110]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 52B041804C9D; Thu, 28 Sep 2017 04:00:18 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback7j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id tUy9WeUbMu-0IvmKiNp; Thu, 28 Sep 2017 04:00:18 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id njRnNC6VTo-0HjWUe5l; Thu, 28 Sep 2017 04:00:17 +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: Thu, 28 Sep 2017 04:00:05 +0300 Message-Id: <1506560407-16273-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506560407-16273-1-git-send-email-odpbot@yandex.ru> References: <1506560407-16273-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 193 Cc: Petri Savolainen Subject: [lng-odp] [PATCH API-NEXT v3 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: 35da9ad1d0193b6fbd07e2de97d9569279e68cf8 **/ 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 From patchwork Thu Sep 28 01:00:06 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: 114385 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp127872qgf; Wed, 27 Sep 2017 18:01:20 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCfi05DS6spbF87d90qePY2LchbN6o/LD8GZvAE93vUtnV/NzQjQaHt6+f55auy1XLtqY9N X-Received: by 10.107.131.155 with SMTP id n27mr4741348ioi.200.1506560480164; Wed, 27 Sep 2017 18:01:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506560480; cv=none; d=google.com; s=arc-20160816; b=cgeBFegz9HaezJrqmeMaEEr3VhGv+t9iZLGWF5pwTrmuge4F+3SUOI59ZP/GoNRo0A qw06sFUKSAq4jKnUmoDvM9aFlWgC37iiLIOczSwHHo1ECnhrroU/kW/uCh8rDE7GYYSq qAdUYJIVYhM5SPWvgUnwMXpY5aOF70R6TqKHAEfWbGI/S0t3jMBgeBuq8Js+NZH+C99E XLN+jYwJqnPZWmwixjr10hR9jQGYp7j2jHwNwobtj7Sa+MLKTzUfloDOxx21boKQNmVJ WealZy0SQI5QP6e4MBQztq5ESrX9wW7JwB6xQ93SNg4N8f1AdnuraMw+RZd3PbHuQ2pd sxZA== 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:cc:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=0ksmshUSKY2ewShR9fNw5VFPuJLB39hJGEZ8ewwdZHA=; b=EeamnQSief4FL48Nui/eNj5RQPGtqF5ArkNtIzz99rsy3qxO30znuxP1pvjXM61xkw /rEhRKSf/u9eAuAYXrkV7qEaZdLVFbJZz37WtIXxhxoxroXmEI5RlD4d4B4thGtxDl6o sVezOToaWhv32B1DcPaS4C8Wn+YPjoUjZB/4ZB+FEca4kk5WF+ukRXlG4L+SCaUy2+FG yg+RWZTEYY3biAjB8+0xRpRRZlcA6vS4uKlmbZ2hJxkxCs2R5Oizctm+D0/MttZ9XECQ 5TNwRsQLuNlwcSTLuhhlGYokHu9mNqJ5y7j3D6BQCKO7GeOEkLtMUbTcbMeZR1ZkEE9M Adjw== 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 q188si631337itb.25.2017.09.27.18.01.19; Wed, 27 Sep 2017 18:01:20 -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 B2009609B5; Thu, 28 Sep 2017 01:01:19 +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 CBE5360C18; Thu, 28 Sep 2017 01:00:45 +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 578E6609B5; Thu, 28 Sep 2017 01:00:42 +0000 (UTC) Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [5.45.198.241]) by lists.linaro.org (Postfix) with ESMTPS id 35C4260C26 for ; Thu, 28 Sep 2017 01:00:20 +0000 (UTC) Received: from mxback2j.mail.yandex.net (mxback2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10b]) by forward101j.mail.yandex.net (Yandex) with ESMTP id F26DA12423C2; Thu, 28 Sep 2017 04:00:18 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id ddI2PLNmhD-0IMeEFc6; Thu, 28 Sep 2017 04:00:18 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id njRnNC6VTo-0IjmMFoo; Thu, 28 Sep 2017 04:00:18 +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: Thu, 28 Sep 2017 04:00:06 +0300 Message-Id: <1506560407-16273-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506560407-16273-1-git-send-email-odpbot@yandex.ru> References: <1506560407-16273-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 193 Cc: Petri Savolainen Subject: [lng-odp] [PATCH API-NEXT v3 2/3] linux-gen: chksum: implement 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 Add implementation of 16 bit ones complement sum function. This is non-performance optimized but simple and based on RFC 1071 and its errata. 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: 35da9ad1d0193b6fbd07e2de97d9569279e68cf8 **/ platform/linux-generic/Makefile.am | 1 + platform/linux-generic/odp_chksum.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 platform/linux-generic/odp_chksum.c diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 994bbbeee..1117e3470 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -236,6 +236,7 @@ __LIB__libodp_linux_la_SOURCES = \ odp_bitmap.c \ odp_buffer.c \ odp_byteorder.c \ + odp_chksum.c \ odp_classification.c \ odp_cpu.c \ odp_cpumask.c \ diff --git a/platform/linux-generic/odp_chksum.c b/platform/linux-generic/odp_chksum.c new file mode 100644 index 000000000..349bdaf46 --- /dev/null +++ b/platform/linux-generic/odp_chksum.c @@ -0,0 +1,36 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include + +/* Simple implementation of ones complement sum. + * Based on RFC1071 and its errata. + */ +uint16_t odp_chksum_ones_comp16(const void *p, uint32_t len) +{ + uint32_t sum = 0; + const uint16_t *data = p; + + while (len > 1) { + sum += *data++; + len -= 2; + } + + /* Add left-over byte, if any */ + if (len > 0) { + uint16_t left_over; + + *(uint8_t *)&left_over = *(const uint8_t *)data; + sum += left_over; + } + + /* Fold 32-bit sum to 16 bits */ + while (sum >> 16) + sum = (sum & 0xffff) + (sum >> 16); + + return sum; +} From patchwork Thu Sep 28 01:00:07 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: 114387 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp129298qgf; Wed, 27 Sep 2017 18:02:44 -0700 (PDT) X-Google-Smtp-Source: AOwi7QC0fRb63cS5ns+6smXKFlxB0aQ2ssB44zP/eTzwuehcRVw8l57pp7CgJ3GTS8re0VevsWUN X-Received: by 10.36.230.1 with SMTP id e1mr3581762ith.36.1506560564887; Wed, 27 Sep 2017 18:02:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506560564; cv=none; d=google.com; s=arc-20160816; b=rSWyVv0GRTLrcI8ACLZRyvKUKg/sInqMJPVH2FXcom4mjdksFOABavGkbNUUsiY92H uWoTSHXlni7uTTyHOfz9j1cWCnXqJrgnx4XWmXTULGwjM28suymVY2mbuptG7N4h/ZUa 6A0MdIFxqi8q835EwqOQQwx0Ajjs8bef4Nldx+N8KNf4SZ493JkZAxulwhRi+x1iPOpl 9N9pbzmGk64dCDlHOdXcwUtkq6O8fGpliG0Sl4XS1fDXWZuqCHo3feqFSO5j8EYueioE qLU51Y58yGEoLyPjC+WhB3qCd59MsF63sfH2YqiS+ryo5CBJuoFa+zlPLuxUfLFUo65r mnpA== 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:cc:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=rBs19UUBb77XCZ4BkINPBNBP32pzYdTYMptdgWeE5as=; b=vmAY5ZR73qQ7Qr8WhPbNp37gg5Nhy5HnryxEwu+20RDSB1qDzOEB3a8kfTjZPpY2bU QOvReUy5IMREPDkZikxpJPzE9cHIMmWv5NLy+k+l/I8ezqUKI49pK+GEP/I4jbZpiIxh A/YCYouBM+ZAATi5rMVQRhAa3P6P4NMGBza2W95wYPG4Dmc2CDILgrDXl0LYKNKY0KK2 UNt/43o9n6Yyu4qPNIW0YR3jCH2XjK+vYe023otJyAgNrMemeZnsZOknQYIXV57FglST U37WA4JvIXAFHUMqoonIq8Igmq5YtKxCyGTBmZk053odWhBo7aGSnGfauUdCAh5fBALq Ng1w== 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 h125si604539itb.110.2017.09.27.18.02.44; Wed, 27 Sep 2017 18:02:44 -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 61D3360C29; Thu, 28 Sep 2017 01:02:44 +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 946AD60C71; Thu, 28 Sep 2017 01:00:55 +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 5622E608E4; Thu, 28 Sep 2017 01:00:44 +0000 (UTC) Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by lists.linaro.org (Postfix) with ESMTPS id BA74060C29 for ; Thu, 28 Sep 2017 01:00:22 +0000 (UTC) Received: from mxback2g.mail.yandex.net (mxback2g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:163]) by forward105j.mail.yandex.net (Yandex) with ESMTP id AE62D1813D0; Thu, 28 Sep 2017 04:00:19 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback2g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id OSJxBWO4JU-0JVOYPIo; Thu, 28 Sep 2017 04:00:19 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id njRnNC6VTo-0JjKCqMn; Thu, 28 Sep 2017 04:00:19 +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: Thu, 28 Sep 2017 04:00:07 +0300 Message-Id: <1506560407-16273-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506560407-16273-1-git-send-email-odpbot@yandex.ru> References: <1506560407-16273-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 193 Cc: Petri Savolainen Subject: [lng-odp] [PATCH API-NEXT v3 3/3] validation: chksum: add test chksum suite 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 Create chksum test suite and ones complement sum test in there. 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: 35da9ad1d0193b6fbd07e2de97d9569279e68cf8 **/ test/common_plat/m4/configure.m4 | 1 + test/common_plat/validation/api/Makefile.am | 1 + test/common_plat/validation/api/chksum/.gitignore | 1 + test/common_plat/validation/api/chksum/Makefile.am | 5 + test/common_plat/validation/api/chksum/chksum.c | 134 +++++++++++++++++++++ test/common_plat/validation/api/chksum/chksum.h | 25 ++++ .../validation/api/chksum/chksum_main.c | 12 ++ test/linux-generic/Makefile.am | 1 + 8 files changed, 180 insertions(+) create mode 100644 test/common_plat/validation/api/chksum/.gitignore create mode 100644 test/common_plat/validation/api/chksum/Makefile.am create mode 100644 test/common_plat/validation/api/chksum/chksum.c create mode 100644 test/common_plat/validation/api/chksum/chksum.h create mode 100644 test/common_plat/validation/api/chksum/chksum_main.c diff --git a/test/common_plat/m4/configure.m4 b/test/common_plat/m4/configure.m4 index 13a13bd50..c06daea28 100644 --- a/test/common_plat/m4/configure.m4 +++ b/test/common_plat/m4/configure.m4 @@ -11,6 +11,7 @@ AC_CONFIG_FILES([test/common_plat/Makefile test/common_plat/validation/api/atomic/Makefile test/common_plat/validation/api/barrier/Makefile test/common_plat/validation/api/buffer/Makefile + test/common_plat/validation/api/chksum/Makefile test/common_plat/validation/api/classification/Makefile test/common_plat/validation/api/cpumask/Makefile test/common_plat/validation/api/crypto/Makefile diff --git a/test/common_plat/validation/api/Makefile.am b/test/common_plat/validation/api/Makefile.am index b00fb2e95..65b2e3b9c 100644 --- a/test/common_plat/validation/api/Makefile.am +++ b/test/common_plat/validation/api/Makefile.am @@ -1,6 +1,7 @@ ODP_MODULES = atomic \ barrier \ buffer \ + chksum \ classification \ cpumask \ crypto \ diff --git a/test/common_plat/validation/api/chksum/.gitignore b/test/common_plat/validation/api/chksum/.gitignore new file mode 100644 index 000000000..c69e8c470 --- /dev/null +++ b/test/common_plat/validation/api/chksum/.gitignore @@ -0,0 +1 @@ +chksum_main diff --git a/test/common_plat/validation/api/chksum/Makefile.am b/test/common_plat/validation/api/chksum/Makefile.am new file mode 100644 index 000000000..46f3643ef --- /dev/null +++ b/test/common_plat/validation/api/chksum/Makefile.am @@ -0,0 +1,5 @@ +include ../Makefile.inc + +test_PROGRAMS = chksum_main$(EXEEXT) +chksum_main_SOURCES = chksum_main.c chksum.c chksum.h +chksum_main_LDADD = $(LIBCUNIT_COMMON) $(LIBODP) diff --git a/test/common_plat/validation/api/chksum/chksum.c b/test/common_plat/validation/api/chksum/chksum.c new file mode 100644 index 000000000..b05f3bf01 --- /dev/null +++ b/test/common_plat/validation/api/chksum/chksum.c @@ -0,0 +1,134 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include "chksum.h" + +#define NUM_IP_HDR 5 +#define IP_HDR_LEN 20 + +#define NUM_UDP 4 +#define MAX_UDP_LEN 128 + +uint8_t ip_hdr_test_vect[NUM_IP_HDR][IP_HDR_LEN] ODP_ALIGNED(4) = { + { 0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, + 0xAB, 0x33, 0xC0, 0xA8, 0x2C, 0xA2, 0xC0, 0xA8, 0x21, 0x99 + }, + { 0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, + 0xAB, 0xCA, 0xC0, 0xA8, 0x2C, 0x5E, 0xC0, 0xA8, 0x21, 0x46 + }, + { 0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, + 0xAB, 0x64, 0xC0, 0xA8, 0x2C, 0x20, 0xC0, 0xA8, 0x21, 0xEA + }, + { 0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, + 0xAB, 0x59, 0xC0, 0xA8, 0x2C, 0xD2, 0xC0, 0xA8, 0x21, 0x43 + }, + { 0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, + 0xAC, 0x06, 0xC0, 0xA8, 0x2C, 0x5C, 0xC0, 0xA8, 0x21, 0x0C + } +}; + +struct udp_test_vect_s { + uint32_t len; + + uint8_t data[MAX_UDP_LEN]; +}; + +struct udp_test_vect_s udp_test_vect[NUM_UDP] ODP_ALIGNED(4) = { + {.len = 38, + .data = { 0x00, 0x11, 0x00, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x1A, 0xFF, 0x3C, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, + 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xC7, 0xBF + } }, + + {.len = 39, + .data = { 0x00, 0x11, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x40, 0x09, 0x35, 0x00, 0x1B, 0xD6, 0x43, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, + 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0xBF, 0xB7 + } }, + + {.len = 59, + .data = { 0x00, 0x11, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x32, 0x5F, 0x01, 0x71, 0x00, 0x2F, 0xCB, 0xC0, + 0x09, 0x8B, 0x61, 0x3E, 0x3A, 0x7F, 0x30, 0x0F, 0x4D, 0xEE, + 0x2D, 0x7D, 0x11, 0xBB, 0xBB, 0x34, 0x0E, 0x9E, 0xC5, 0x3D, + 0xBB, 0x81, 0x9A, 0x7F, 0xF2, 0x2A, 0xFC, 0x85, 0xA0, 0x1B, + 0x73, 0x81, 0xC1, 0xB6, 0xE8, 0x91, 0x8C, 0xD8, 0x7F + } }, + + {.len = 109, + .data = { 0x00, 0x11, 0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x32, 0x5F, 0x01, 0x71, 0x00, 0x61, 0xCB, 0x5C, + 0x61, 0xAD, 0xFD, 0xE7, 0x4E, 0x98, 0x69, 0x59, 0x12, 0x3F, + 0xDF, 0xF6, 0x79, 0x8B, 0xB3, 0x94, 0x94, 0x9F, 0x8C, 0x0B, + 0x67, 0xBA, 0xBA, 0x3C, 0xE2, 0x5F, 0xCA, 0x52, 0x13, 0xB4, + 0x57, 0x48, 0x99, 0x29, 0x23, 0xAC, 0x5C, 0x59, 0x66, 0xA2, + 0x7B, 0x35, 0x65, 0x2B, 0x86, 0x5F, 0x47, 0xA7, 0xEE, 0xD4, + 0x24, 0x99, 0xB9, 0xCE, 0x60, 0xAB, 0x7A, 0xE9, 0x37, 0xF2, + 0x81, 0x84, 0x98, 0x72, 0x4F, 0x6A, 0x37, 0xE5, 0x4D, 0xB2, + 0xDE, 0xB8, 0xBD, 0xE3, 0x03, 0x57, 0xF0, 0x5C, 0xA0, 0xAA, + 0xB9, 0xF3, 0x3F, 0xDF, 0x23, 0xDD, 0x54, 0x2F, 0xCE + } } +}; + +/* Test ones complement sum with IPv4 headers */ +void chksum_ones_complement_ip(void) +{ + int i; + uint16_t sum, res; + + for (i = 0; i < NUM_IP_HDR; i++) { + sum = odp_chksum_ones_comp16(ip_hdr_test_vect[i], IP_HDR_LEN); + res = ~sum; + + CU_ASSERT(res == 0); + } +} + +/* Test ones complement sum with various length pseudo UDP packets */ +void chksum_ones_complement_udp(void) +{ + int i; + uint16_t sum, res; + + for (i = 0; i < NUM_UDP; i++) { + sum = odp_chksum_ones_comp16(udp_test_vect[i].data, + udp_test_vect[i].len); + res = ~sum; + + CU_ASSERT(res == 0); + } +} + +odp_testinfo_t chksum_suite[] = { + ODP_TEST_INFO(chksum_ones_complement_ip), + ODP_TEST_INFO(chksum_ones_complement_udp), + ODP_TEST_INFO_NULL, +}; + +odp_suiteinfo_t chksum_suites[] = { + {"Checksum", NULL, NULL, chksum_suite}, + ODP_SUITE_INFO_NULL +}; + +int chksum_main(int argc, char *argv[]) +{ + int ret; + + /* parse common options: */ + if (odp_cunit_parse_options(argc, argv)) + return -1; + + ret = odp_cunit_register(chksum_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; +} diff --git a/test/common_plat/validation/api/chksum/chksum.h b/test/common_plat/validation/api/chksum/chksum.h new file mode 100644 index 000000000..886f15c28 --- /dev/null +++ b/test/common_plat/validation/api/chksum/chksum.h @@ -0,0 +1,25 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _ODP_TEST_CHKSUM_H_ +#define _ODP_TEST_CHKSUM_H_ + +#include + +/* test functions: */ +void chksum_ones_complement_ip(void); +void chksum_ones_complement_udp(void); + +/* test arrays: */ +extern odp_testinfo_t chksum_suite[]; + +/* test registry: */ +extern odp_suiteinfo_t chksum_suites[]; + +/* main test program: */ +int chksum_main(int argc, char *argv[]); + +#endif diff --git a/test/common_plat/validation/api/chksum/chksum_main.c b/test/common_plat/validation/api/chksum/chksum_main.c new file mode 100644 index 000000000..bec10ddd4 --- /dev/null +++ b/test/common_plat/validation/api/chksum/chksum_main.c @@ -0,0 +1,12 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "chksum.h" + +int main(int argc, char *argv[]) +{ + return chksum_main(argc, argv); +} diff --git a/test/linux-generic/Makefile.am b/test/linux-generic/Makefile.am index 4be5d94e9..0d3635880 100644 --- a/test/linux-generic/Makefile.am +++ b/test/linux-generic/Makefile.am @@ -13,6 +13,7 @@ TESTS = validation/api/pktio/pktio_run.sh \ $(ALL_API_VALIDATION_DIR)/atomic/atomic_main$(EXEEXT) \ $(ALL_API_VALIDATION_DIR)/barrier/barrier_main$(EXEEXT) \ $(ALL_API_VALIDATION_DIR)/buffer/buffer_main$(EXEEXT) \ + $(ALL_API_VALIDATION_DIR)/chksum/chksum_main$(EXEEXT) \ $(ALL_API_VALIDATION_DIR)/classification/classification_main$(EXEEXT) \ $(ALL_API_VALIDATION_DIR)/cpumask/cpumask_main$(EXEEXT) \ $(ALL_API_VALIDATION_DIR)/crypto/crypto_main$(EXEEXT) \