From patchwork Tue Jul 15 08:54:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weilong Chen X-Patchwork-Id: 33648 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1637B201F1 for ; Tue, 15 Jul 2014 08:56:03 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id rl12sf22826542iec.1 for ; Tue, 15 Jul 2014 01:56:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=evMPOs3vEOf2OOPZvSh1ZYrPINwhXVU+aHvgKPNdzcw=; b=C3DakcIaYHHQ6QBwvyayiuKbY2tD4SL7yCvWbReQwxZ0AKvqDqdoPtzgNLKJdFz2Jm 6RIKz7Y6tgNioqYQsg9EJYLcMjwPHnjt9/pXmFy++eK1RKWZ189m/2mgDpUV7c+lXUXx 1QuIQYrITRQ1ueJTvAW423Zjlf6eu08gtiAXSjvkJG8yubJB6JW8Yoe+aL9FL8Rom2xE 4Rl7zDGWS99FYBwvbQlutsOHJVTzXyOBT7XFe17EqY4VzAcyKhiGTgr+V4wW9AmffuBG JJPhXz/oHCq/+UzKkQkSMeZ9j52zOsp6ma0J5TXpkmYmT7/7FVN1b0wAN6tuYyzWIzuh C/vg== X-Gm-Message-State: ALoCoQmmQxb30o3FXB0QQn9leXg1jgKxZYeYD3i/BHNxK0avAqaST3P4JWjdt18vdh6MS7jNTa16 X-Received: by 10.182.102.34 with SMTP id fl2mr10971047obb.16.1405414562459; Tue, 15 Jul 2014 01:56:02 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.107 with SMTP id 98ls29441qga.80.gmail; Tue, 15 Jul 2014 01:56:02 -0700 (PDT) X-Received: by 10.52.30.9 with SMTP id o9mr17478926vdh.15.1405414562372; Tue, 15 Jul 2014 01:56:02 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id ah1si6427274vec.13.2014.07.15.01.56.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jul 2014 01:56:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id ik5so9435348vcb.21 for ; Tue, 15 Jul 2014 01:56:02 -0700 (PDT) X-Received: by 10.220.190.197 with SMTP id dj5mr20681040vcb.19.1405414562218; Tue, 15 Jul 2014 01:56:02 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp197920vcb; Tue, 15 Jul 2014 01:56:01 -0700 (PDT) X-Received: by 10.140.28.245 with SMTP id 108mr22597555qgz.45.1405414561699; Tue, 15 Jul 2014 01:56:01 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id b4si19190116qae.77.2014.07.15.01.56.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 15 Jul 2014 01:56:01 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1X6yUR-0000nw-OO; Tue, 15 Jul 2014 08:53:35 +0000 Received: from mail-pa0-f42.google.com ([209.85.220.42]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1X6yUN-0000nr-4N for lng-odp@lists.linaro.org; Tue, 15 Jul 2014 08:53:31 +0000 Received: by mail-pa0-f42.google.com with SMTP id lf10so3029308pab.1 for ; Tue, 15 Jul 2014 01:55:50 -0700 (PDT) X-Received: by 10.68.220.170 with SMTP id px10mr16720593pbc.33.1405414549910; Tue, 15 Jul 2014 01:55:49 -0700 (PDT) Received: from localhost.localdomain ([183.247.163.231]) by mx.google.com with ESMTPSA id pp2sm17706685pdb.59.2014.07.15.01.55.48 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jul 2014 01:55:49 -0700 (PDT) From: Weilong Chen To: lng-odp@lists.linaro.org Date: Tue, 15 Jul 2014 16:54:20 +0800 Message-Id: <1405414460-13833-1-git-send-email-weilong.chen@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Topics: patch Subject: [lng-odp] [PATCH] Revert "Fix uint16be_t sparse checksum errors" X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: weilong.chen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This reverts commit acdbb05449d8d6f80caf39d035e6a6c7a5e2dabb. According to https://www.ietf.org/rfc/rfc1071.txt. The checksum algorithm is "Byte Order Independence". Signed-off-by: Weilong Chen --- include/helper/odp_chksum.h | 5 +---- include/helper/odp_ip.h | 11 ++++------- include/helper/odp_udp.h | 2 +- test/generator/odp_generator.c | 6 +++--- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/include/helper/odp_chksum.h b/include/helper/odp_chksum.h index 37078b6..12ef61f 100644 --- a/include/helper/odp_chksum.h +++ b/include/helper/odp_chksum.h @@ -22,13 +22,10 @@ extern "C" { /** * Checksum * - * @note when using this api to populate data destined for the wire - * odp_cpu_to_be_16() can be used to remove sparse warnings - * * @param buffer calculate chksum for buffer * @param len buffer length * - * @return checksum value in host cpu order + * @return checksum value */ static inline uint16_t odp_chksum(void *buffer, int len) { diff --git a/include/helper/odp_ip.h b/include/helper/odp_ip.h index d8366bb..a364049 100644 --- a/include/helper/odp_ip.h +++ b/include/helper/odp_ip.h @@ -94,16 +94,13 @@ static inline int odp_ipv4_csum_valid(odp_packet_t pkt) /** * Calculate and fill in IPv4 checksum * - * @note when using this api to populate data destined for the wire - * odp_cpu_to_be_16() can be used to remove sparse warnings - * * @param pkt ODP packet * - * @return IPv4 checksum in host cpu order, or 0 on failure + * @return IPv4 checksum, or 0 on failure */ -static inline uint16_t odp_ipv4_csum_update(odp_packet_t pkt) +static inline uint16be_t odp_ipv4_csum_update(odp_packet_t pkt) { - uint16_t res = 0; + uint16be_t res = 0; uint16_t *w; odp_ipv4hdr_t *ip; int nleft = sizeof(odp_ipv4hdr_t); @@ -114,7 +111,7 @@ static inline uint16_t odp_ipv4_csum_update(odp_packet_t pkt) ip = (odp_ipv4hdr_t *)odp_packet_l3(pkt); w = (uint16_t *)(void *)ip; res = odp_chksum(w, nleft); - ip->chksum = odp_cpu_to_be_16(res); + ip->chksum = res; return res; } diff --git a/include/helper/odp_udp.h b/include/helper/odp_udp.h index ae31f6b..5aedb36 100644 --- a/include/helper/odp_udp.h +++ b/include/helper/odp_udp.h @@ -89,7 +89,7 @@ static inline uint16_t odp_ipv4_udp_chksum(odp_packet_t pkt) /* set computation result */ sum = (sum == 0x0) ? 0xFFFF : sum; - return sum; + return (uint16_t)sum; } /** @internal Compile time assert */ diff --git a/test/generator/odp_generator.c b/test/generator/odp_generator.c index 8f6ad49..fd85455 100644 --- a/test/generator/odp_generator.c +++ b/test/generator/odp_generator.c @@ -212,7 +212,7 @@ static void pack_udp_pkt(odp_buffer_t obuf) udp->dst_port = 0; udp->length = odp_cpu_to_be_16(args->appl.payload + ODP_UDPHDR_LEN); udp->chksum = 0; - udp->chksum = odp_cpu_to_be_16(odp_ipv4_udp_chksum(pkt)); + udp->chksum = odp_ipv4_udp_chksum(pkt); odp_packet_set_len(pkt, args->appl.payload + ODP_UDPHDR_LEN + ODP_IPV4HDR_LEN + ODP_ETHHDR_LEN); } @@ -275,8 +275,8 @@ static void pack_icmp_pkt(odp_buffer_t obuf) gettimeofday(&tval, NULL); memcpy(tval_d, &tval, sizeof(struct timeval)); icmp->chksum = 0; - icmp->chksum = odp_cpu_to_be_16(odp_chksum(icmp, args->appl.payload + - ODP_ICMPHDR_LEN)); + icmp->chksum = odp_chksum(icmp, args->appl.payload + + ODP_ICMPHDR_LEN); odp_packet_set_len(pkt, args->appl.payload + ODP_ICMPHDR_LEN + ODP_IPV4HDR_LEN + ODP_ETHHDR_LEN);