From patchwork Wed Jun 25 22:00:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 32510 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5DBB220C88 for ; Wed, 25 Jun 2014 22:00:58 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id n15sf2222882wiw.6 for ; Wed, 25 Jun 2014 15:00:57 -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=+zdLIFLof81h4PMcVpGvMCXfSXkeSYVfQWytZiCltQs=; b=gKDEU2bOWTtygCXQ+mU79B2s3c0r3Fwse0Z6i0l0CEHbCWuPJ1eKblQ49T85ZyrXBi XsD0K8a6HJ6dkCkm25rh2UcbqWVfYOVlWAY0qqKGqY6UpF+r3m6CGcm+p/8xGkabCh69 Ll1yi40evvjK4FDg6j/YzalD/DaBXpybkFfXAwBa9kzEjFoUuyf/Z+ybse9Z+Nym94Xp WkP93P1y9HyujDEw5R95mSgJYhyQGzqrtrhVtbZxppZiy4nS17L4HpqzVyuWinIObceV qfKuCwufWIp5lMZ7kod/prVLIScHmoHwvJQypM2TROaRpPTfNdKbm8YacxMyE5Fp7VlG f1eg== X-Gm-Message-State: ALoCoQkbFIwxA17vePbqEDj1qGh7IUd9usplMEthaY/zD39QI8pIwFLVjmCmi9gA8ws1h7KMJAwr X-Received: by 10.180.72.97 with SMTP id c1mr1547994wiv.2.1403733657393; Wed, 25 Jun 2014 15:00:57 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.39.85 with SMTP id u79ls2818337qgu.61.gmail; Wed, 25 Jun 2014 15:00:57 -0700 (PDT) X-Received: by 10.58.46.141 with SMTP id v13mr9330162vem.18.1403733657273; Wed, 25 Jun 2014 15:00:57 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id gm6si3194576vec.75.2014.06.25.15.00.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 25 Jun 2014 15:00:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.171 as permitted sender) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id jz11so2756715veb.16 for ; Wed, 25 Jun 2014 15:00:57 -0700 (PDT) X-Received: by 10.58.243.1 with SMTP id wu1mr9470460vec.27.1403733657164; Wed, 25 Jun 2014 15:00:57 -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 tc5csp321232vcb; Wed, 25 Jun 2014 15:00:56 -0700 (PDT) X-Received: by 10.52.121.112 with SMTP id lj16mr7825571vdb.29.1403733656857; Wed, 25 Jun 2014 15:00:56 -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 se2si3204196vec.35.2014.06.25.15.00.56 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 25 Jun 2014 15:00:56 -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 1WzvDY-0005Pz-J1; Wed, 25 Jun 2014 21:59:00 +0000 Received: from mail-qc0-f177.google.com ([209.85.216.177]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WzvDT-0005Pk-E4 for lng-odp@lists.linaro.org; Wed, 25 Jun 2014 21:58:55 +0000 Received: by mail-qc0-f177.google.com with SMTP id r5so2327157qcx.8 for ; Wed, 25 Jun 2014 15:00:45 -0700 (PDT) X-Received: by 10.224.168.13 with SMTP id s13mr15488406qay.14.1403733645306; Wed, 25 Jun 2014 15:00:45 -0700 (PDT) Received: from fedora1.holmesfamily.ws (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by mx.google.com with ESMTPSA id q10sm7938548qah.9.2014.06.25.15.00.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jun 2014 15:00:44 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 25 Jun 2014 18:00:18 -0400 Message-Id: <1403733620-8426-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH 1/3] 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: mike.holmes@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.128.171 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 Signed-off-by: Mike Holmes --- 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, 15 insertions(+), 9 deletions(-) diff --git a/include/helper/odp_chksum.h b/include/helper/odp_chksum.h index 12ef61f..37078b6 100644 --- a/include/helper/odp_chksum.h +++ b/include/helper/odp_chksum.h @@ -22,10 +22,13 @@ 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 + * @return checksum value in host cpu order */ 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 a364049..d8366bb 100644 --- a/include/helper/odp_ip.h +++ b/include/helper/odp_ip.h @@ -94,13 +94,16 @@ 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, or 0 on failure + * @return IPv4 checksum in host cpu order, or 0 on failure */ -static inline uint16be_t odp_ipv4_csum_update(odp_packet_t pkt) +static inline uint16_t odp_ipv4_csum_update(odp_packet_t pkt) { - uint16be_t res = 0; + uint16_t res = 0; uint16_t *w; odp_ipv4hdr_t *ip; int nleft = sizeof(odp_ipv4hdr_t); @@ -111,7 +114,7 @@ static inline uint16be_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 = res; + ip->chksum = odp_cpu_to_be_16(res); return res; } diff --git a/include/helper/odp_udp.h b/include/helper/odp_udp.h index 5aedb36..ae31f6b 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 (uint16_t)sum; + return sum; } /** @internal Compile time assert */ diff --git a/test/generator/odp_generator.c b/test/generator/odp_generator.c index ca84e4c..68c119e 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_ipv4_udp_chksum(pkt); + udp->chksum = odp_cpu_to_be_16(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_chksum(icmp, args->appl.payload + - ODP_ICMPHDR_LEN); + icmp->chksum = odp_cpu_to_be_16(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);