From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH 5/5] net/virtio: fix Tso when mbuf is shared Date: Mon, 9 Jan 2017 09:59:40 -0800 Message-ID: <20170109095940.1a6df6ac@xeon-e3> References: <1479977798-13417-1-git-send-email-olivier.matz@6wind.com> <1479977798-13417-6-git-send-email-olivier.matz@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org, yuanhan.liu@linux.intel.com, maxime.coquelin@redhat.com, huawei.xie@intel.com To: Olivier Matz Return-path: Received: from mail-pf0-f176.google.com (mail-pf0-f176.google.com [209.85.192.176]) by dpdk.org (Postfix) with ESMTP id C26E61E2B for ; Mon, 9 Jan 2017 18:59:43 +0100 (CET) Received: by mail-pf0-f176.google.com with SMTP id 189so20012616pfu.3 for ; Mon, 09 Jan 2017 09:59:43 -0800 (PST) In-Reply-To: <1479977798-13417-6-git-send-email-olivier.matz@6wind.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, 24 Nov 2016 09:56:38 +0100 Olivier Matz wrote: > diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c > index 22d97a4..577c775 100644 > --- a/drivers/net/virtio/virtio_rxtx.c > +++ b/drivers/net/virtio/virtio_rxtx.c > @@ -211,43 +211,73 @@ virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf *cookie) > > /* 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. > + * expected. Fix the mbuf or a copy if the mbuf is shared. > */ > -static void > -virtio_tso_fix_cksum(struct rte_mbuf *m) > +static unsigned int > +virtio_tso_fix_cksum(struct rte_mbuf *m, char *hdr, size_t hdr_sz) > { > - /* common case: header is not fragmented */ > - if (likely(rte_pktmbuf_data_len(m) >= m->l2_len + m->l3_len + > - m->l4_len)) { > - struct ipv4_hdr *iph; > - struct ipv6_hdr *ip6h; > - struct tcp_hdr *th; > - uint16_t prev_cksum, new_cksum, ip_len, ip_paylen; > - uint32_t tmp; > - > - iph = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, m->l2_len); > - th = RTE_PTR_ADD(iph, m->l3_len); > - if ((iph->version_ihl >> 4) == 4) { > - iph->hdr_checksum = 0; > - iph->hdr_checksum = rte_ipv4_cksum(iph); > - ip_len = iph->total_length; > - ip_paylen = rte_cpu_to_be_16(rte_be_to_cpu_16(ip_len) - > - m->l3_len); > - } else { > - ip6h = (struct ipv6_hdr *)iph; > - ip_paylen = ip6h->payload_len; > + struct ipv4_hdr *iph, iph_copy; > + struct ipv6_hdr *ip6h = NULL, ip6h_copy; > + struct tcp_hdr *th, th_copy; > + size_t hdrlen = m->l2_len + m->l3_len + m->l4_len; > + uint16_t prev_cksum, new_cksum, ip_len, ip_paylen; > + uint32_t tmp; > + int shared = 0; Minor nit, uses bool instead of int for shared?