From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <yuanhan.liu@linux.intel.com>
Received: from mga14.intel.com (mga14.intel.com [192.55.52.115])
 by dpdk.org (Postfix) with ESMTP id EC2412B8C
 for <dev@dpdk.org>; Thu, 13 Oct 2016 10:18:05 +0200 (CEST)
Received: from fmsmga003.fm.intel.com ([10.253.24.29])
 by fmsmga103.fm.intel.com with ESMTP; 13 Oct 2016 01:18:04 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.31,339,1473145200"; d="scan'208";a="772086625"
Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162])
 by FMSMGA003.fm.intel.com with ESMTP; 13 Oct 2016 01:17:47 -0700
Date: Thu, 13 Oct 2016 16:18:39 +0800
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: dev@dpdk.org, 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
Message-ID: <20161013081839.GT16751@yliu-dev.sh.intel.com>
References: <1475485223-30566-1-git-send-email-olivier.matz@6wind.com>
 <1475485223-30566-13-git-send-email-olivier.matz@6wind.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1475485223-30566-13-git-send-email-olivier.matz@6wind.com>
User-Agent: Mutt/1.5.23 (2014-03-12)
Subject: Re: [dpdk-dev] [PATCH v2 12/12] virtio: add Tso support
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 13 Oct 2016 08:18:06 -0000

On Mon, Oct 03, 2016 at 11:00:23AM +0200, Olivier Matz wrote:
> +/* When doing TSO, the IP length is not included in the pseudo header
> + * checksum of the packet given to the PMD, but for virtio it is
> + * expected.
> + */
> +static void
> +virtio_tso_fix_cksum(struct rte_mbuf *m)
> +{
> +	/* common case: header is not fragmented */
> +	if (likely(rte_pktmbuf_data_len(m) >= m->l2_len + m->l3_len +
> +			m->l4_len)) {
...
> +		/* replace it in the packet */
> +		th->cksum = new_cksum;
> +	} else {
...
> +		/* replace it in the packet */
> +		*rte_pktmbuf_mtod_offset(m, uint8_t *,
> +			m->l2_len + m->l3_len + 16) = new_cksum.u8[0];
> +		*rte_pktmbuf_mtod_offset(m, uint8_t *,
> +			m->l2_len + m->l3_len + 17) = new_cksum.u8[1];
> +	}

The tcp header will always be in the mbuf, right? Otherwise, you can't
update the cksum field here. What's the point of introducing the "else
clause" then?

	--yliu