From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 1F68B6CBC for ; Tue, 11 Oct 2016 15:33:52 +0200 (CEST) Received: from [10.16.0.195] (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id C64D624B1B; Tue, 11 Oct 2016 15:33:51 +0200 (CEST) To: Maxime Coquelin , dev@dpdk.org, yuanhan.liu@linux.intel.com References: <1469088510-7552-1-git-send-email-olivier.matz@6wind.com> <1475485223-30566-1-git-send-email-olivier.matz@6wind.com> <1475485223-30566-5-git-send-email-olivier.matz@6wind.com> Cc: konstantin.ananyev@intel.com, sugesh.chandran@intel.com, bruce.richardson@intel.com, jianfeng.tan@intel.com, helin.zhang@intel.com, adrien.mazarguil@6wind.com, stephen@networkplumber.org, dprovan@bivio.net, xiao.w.wang@intel.com From: Olivier MATZ Message-ID: <57FCEA3B.3020601@6wind.com> Date: Tue, 11 Oct 2016 15:33:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2 04/12] net: add function to calculate a checksum in a mbuf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 13:33:52 -0000 Hi Maxime, On 10/11/2016 03:25 PM, Maxime Coquelin wrote: >> /** >> + * Compute the raw (non complemented) checksum of a packet. >> + * >> + * @param m >> + * The pointer to the mbuf. >> + * @param off >> + * The offset in bytes to start the checksum. >> + * @param len >> + * The length in bytes of the data to ckecksum. >> + */ >> +static inline uint16_t >> +rte_raw_cksum_mbuf(const struct rte_mbuf *m, uint32_t off, uint32_t len) >> +{ >> + const struct rte_mbuf *seg; >> + const char *buf; >> + uint32_t sum, tmp; >> + uint32_t seglen, done; >> + >> + /* easy case: all data in the first segment */ >> + if (off + len <= rte_pktmbuf_data_len(m)) >> + return rte_raw_cksum(rte_pktmbuf_mtod_offset(m, >> + const char *, off), len); >> + >> + if (off + len > rte_pktmbuf_pkt_len(m)) > unlikely? Yes, will add it. >> + return 0; /* invalid params, return a dummy value */ > Couldn't be better to return an error, so that the caller has a chance > to see it is passing wrong arguments? > The csum would be passed as an arg. Looks much better indeed. I'll change it for next revision. Thanks, Olivier