From patchwork Thu Aug 24 12: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: 110893 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp5561852qge; Thu, 24 Aug 2017 05:04:30 -0700 (PDT) X-Received: by 10.55.76.17 with SMTP id z17mr7848366qka.8.1503576270715; Thu, 24 Aug 2017 05:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503576270; cv=none; d=google.com; s=arc-20160816; b=zJSwXSpM8nVdOlsHV2sW4W3Prnsdd0BmU0faD+X9jF4mg94a+fXtDhg2VNJJYCxTBe bxlzIODQ1cXcrHstrE6a5WZQEns4q+BHFf45C8Cf6KLZtD1tg2oqAJ+sPUrTX9w3RkKH x9XrLtnASVPfRViQSm86rC9v6YZUj2Zt9L7a7faT5sEhRWE5ldW7yYtzGbXhQvMzKJxj piBMCgxHXa5bmTIu8L1jXv7yNuJ7XYiphlAv2FIEWPQyg5I8WngaPA7UMd/UKkgHUKnI JU86dAHKawb8P0tmf9isv0f8rmSqEBrqsouUogcKk+aXIsueijLKL1YgxOQRbCMSmgwF PjOQ== 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=qbRLZDDSl3NIKcV6OcV+pj3riqGV6kPacWPXQUX0Wpg=; b=zvL+YR1oJvtRqL6GFTHrfJLvAEZulKjWL/OLgRU1OI+w+P5E74+N+j++MDsgHfvLqW xOVsrRU2FuX/SIC0eoHN9bHkJeiIbDBqqyoQQyYcnPKYdXJLHHpjyOZCmf6eFpCY972j 7ZyP6b6Q/DnWFemjGeIARwgsLXuGBuaSR/SyMMn99WX/XgN8fCQTjlg9YrfPBaVulCZP GZTbTp5NT4zr8MaPnGarSLdsgCKb4JB8O2fns3zwhvncokHH01tMfnrR2yh3pO1VEen8 baNEfSKQg73UY0mY1XGyyzSNnNC4dTcrr8HMn2ihBhMlxh9kYUQ+nn+P0Avz/uvEPvIA M/vA== 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 n192si439791qkn.515.2017.08.24.05.04.30; Thu, 24 Aug 2017 05:04:30 -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 2D02F64479; Thu, 24 Aug 2017 12:04:30 +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 0B9C062D19; Thu, 24 Aug 2017 12:01: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 1E70C60D7C; Thu, 24 Aug 2017 12:01:31 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id B300E62D19 for ; Thu, 24 Aug 2017 12:00:30 +0000 (UTC) Received: from mxback15j.mail.yandex.net (mxback15j.mail.yandex.net [IPv6:2a02:6b8:0:1619::91]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 237991345C52 for ; Thu, 24 Aug 2017 15:00:23 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback15j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id OBdzNLPNPH-0Mrq1Xxb; Thu, 24 Aug 2017 15:00:22 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 1AcxP7MKsj-0MwCdwp4; Thu, 24 Aug 2017 15:00:22 +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, 24 Aug 2017 15:00:06 +0300 Message-Id: <1503576008-15890-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503576008-15890-1-git-send-email-odpbot@yandex.ru> References: <1503576008-15890-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 132 Subject: [lng-odp] [PATCH v5 1/3] helper: chksum: calculate checksum in network byte order 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 All examples and usecases assumed network byte order for odph_chksum() return value. Instead of changing this convention, rather document that odph_chksum returns value in network byte order. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 132 (lumag:fix-checksum) ** https://github.com/Linaro/odp/pull/132 ** Patch: https://github.com/Linaro/odp/pull/132.patch ** Base sha: 8705e548f330d23173283fcca62f4afb835a6380 ** Merge commit sha: e256e0810a3feee8b1b91b8d61f21bdfdd339dff **/ helper/include/odp/helper/chksum.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helper/include/odp/helper/chksum.h b/helper/include/odp/helper/chksum.h index 520e9275..2da0303e 100644 --- a/helper/include/odp/helper/chksum.h +++ b/helper/include/odp/helper/chksum.h @@ -40,16 +40,16 @@ typedef enum { * @param buffer calculate chksum for buffer * @param len buffer length * - * @return checksum value in host cpu order + * @return checksum value in network order */ static inline odp_u16sum_t odph_chksum(void *buffer, int len) { - uint16_t *buf = (uint16_t *)buffer; + odp_u16be_t *buf = (odp_u16be_t *)buffer; uint32_t sum = 0; uint16_t result; for (sum = 0; len > 1; len -= 2) - sum += *buf++; + sum += odp_be_to_cpu_16(*buf++); if (len == 1) sum += *(unsigned char *)buf; @@ -58,7 +58,7 @@ static inline odp_u16sum_t odph_chksum(void *buffer, int len) sum += (sum >> 16); result = ~sum; - return (__odp_force odp_u16sum_t) result; + return odp_cpu_to_be_16(result); } /**