From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 6205A58F7 for ; Wed, 27 Jul 2016 11:52:46 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP; 27 Jul 2016 02:52:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,429,1464678000"; d="scan'208";a="146205657" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 27 Jul 2016 02:52:45 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 27 Jul 2016 02:52:45 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.8]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.116]) with mapi id 14.03.0248.002; Wed, 27 Jul 2016 17:52:43 +0800 From: "Wang, Xiao W" To: Olivier Matz , "dev@dpdk.org" , "yuanhan.liu@linux.intel.com" , "Ananyev, Konstantin" CC: "Chandran, Sugesh" , "Richardson, Bruce" , "Tan, Jianfeng" , "Zhang, Helin" , "adrien.mazarguil@6wind.com" Thread-Topic: [dpdk-dev] [PATCH 09/12] virtio: add Rx checksum offload support Thread-Index: AQHR4yfDeHD2nkK1C0GuNCIS2w2RUaAsEC0A Date: Wed, 27 Jul 2016 09:52:42 +0000 Message-ID: References: <1469088510-7552-1-git-send-email-olivier.matz@6wind.com> <1469088510-7552-10-git-send-email-olivier.matz@6wind.com> In-Reply-To: <1469088510-7552-10-git-send-email-olivier.matz@6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYmMwODA3MGQtNmYwYS00NWVjLTkwYjEtNzRhOWE0MTEyMzQ4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlRxTmo2WGg4azJFQzFcL2F5MUZoelpoYUFTdjhldk9NbkxrdE1aTnJjMzhZPSJ9 x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 09/12] virtio: add Rx checksum offload support 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: Wed, 27 Jul 2016 09:52:46 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Olivier Matz > Sent: Thursday, July 21, 2016 4:08 PM > To: dev@dpdk.org; yuanhan.liu@linux.intel.com; Ananyev, Konstantin > > Cc: Chandran, Sugesh ; Richardson, Bruce > ; Tan, Jianfeng ; Zha= ng, > Helin ; adrien.mazarguil@6wind.com > Subject: [dpdk-dev] [PATCH 09/12] virtio: add Rx checksum offload support >=20 > Signed-off-by: Olivier Matz > --- > drivers/net/virtio/virtio_ethdev.c | 14 ++++---- > drivers/net/virtio/virtio_ethdev.h | 2 +- > drivers/net/virtio/virtio_rxtx.c | 66 > ++++++++++++++++++++++++++++++++++++++ > drivers/net/virtio/virtqueue.h | 1 + > 4 files changed, 75 insertions(+), 8 deletions(-) >=20 > diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virt= io_ethdev.c > index 02eae94..c0f1f21 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -1262,7 +1262,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) > eth_dev->data->dev_flags =3D dev_flags; >=20 > /* reset device and negotiate default features */ > - ret =3D virtio_init_device(eth_dev, VIRTIO_PMD_GUEST_FEATURES); > + ret =3D virtio_init_device(eth_dev, > VIRTIO_PMD_DEFAULT_GUEST_FEATURES); > if (ret < 0) > return ret; >=20 > @@ -1351,13 +1351,10 @@ virtio_dev_configure(struct rte_eth_dev *dev) > int ret; >=20 > PMD_INIT_LOG(DEBUG, "configure"); > + req_features =3D VIRTIO_PMD_DEFAULT_GUEST_FEATURES; > + if (rxmode->hw_ip_checksum) > + req_features |=3D (1ULL << VIRTIO_NET_F_GUEST_CSUM); >=20 .... > diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio= _rxtx.c > index 9aba044..a18798f 100644 > --- a/drivers/net/virtio/virtio_rxtx.c > +++ b/drivers/net/virtio/virtio_rxtx.c > @@ -613,6 +613,54 @@ virtio_update_packet_stats(struct virtnet_stats *sta= ts, > struct rte_mbuf *mbuf) > } > } >=20 > +/* Optionally fill offload information in structure */ static int > +virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr) { > + struct rte_mbuf_hdr_lens hdr_lens; > + uint32_t hdrlen, ptype; > + int l4_supported =3D 0; > + > + /* nothing to do */ > + if (hdr->flags =3D=3D 0 && hdr->gso_type =3D=3D VIRTIO_NET_HDR_GSO_NONE= ) > + return 0; > + > + m->ol_flags |=3D PKT_RX_IP_CKSUM_UNKNOWN; > + > + ptype =3D rte_pktmbuf_get_ptype(m, &hdr_lens, RTE_PTYPE_ALL_MASK); > + m->packet_type =3D ptype; > + if ((ptype & RTE_PTYPE_L4_MASK) =3D=3D RTE_PTYPE_L4_TCP || > + (ptype & RTE_PTYPE_L4_MASK) =3D=3D RTE_PTYPE_L4_UDP || > + (ptype & RTE_PTYPE_L4_MASK) =3D=3D RTE_PTYPE_L4_SCTP) > + l4_supported =3D 1; > + > + if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { > + hdrlen =3D hdr_lens.l2_len + hdr_lens.l3_len + hdr_lens.l4_len; > + if (hdr->csum_start <=3D hdrlen && l4_supported) { > + m->ol_flags |=3D PKT_RX_L4_CKSUM_NONE; > + } else { > + /* Unknown proto or tunnel, do sw cksum. We can > assume > + * the cksum field is in the first segment since the > + * buffers we provided to the host are large enough. > + * In case of SCTP, this will be wrong since it's a CRC > + * but there's nothing we can do. > + */ > + uint16_t csum, off; > + > + csum =3D ~rte_pktmbuf_cksum(m, hdr->csum_start, > + rte_pktmbuf_pkt_len(m) - hdr->csum_start); 1. When translate raw_cksum to the final cksum, it should be like "(cksum = =3D=3D 0xffff) ? cksum : ~cksum". 2. How about making this function inline as it's called in fast path? Best Regards, Xiao