From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxime Coquelin Subject: Re: [PATCH] vhost: Only access header if offloading is supported in dequeue path Date: Thu, 6 Oct 2016 19:06:11 +0200 Message-ID: <302508c8-ce7d-aa55-ca03-62d3ddcb6420@redhat.com> References: <1475773241-5714-1-git-send-email-maxime.coquelin@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: mst@redhat.com, jianfeng.tan@intel.com, olivier.matz@6wind.com, stephen@networkplumber.org To: yuanhan.liu@linux.intel.com, dev@dpdk.org Return-path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id B6A086AE0 for ; Thu, 6 Oct 2016 19:06:16 +0200 (CEST) In-Reply-To: <1475773241-5714-1-git-send-email-maxime.coquelin@redhat.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 10/06/2016 07:00 PM, Maxime Coquelin wrote: > If offloading features are not negotiated, parsing the virtio header > is not needed. > > Micro-benchmark with testpmd shows that the gain is +4% with indirect > descriptors, +1% when using direct descriptors. > > Signed-off-by: Maxime Coquelin > --- > lib/librte_vhost/virtio_net.c | 47 ++++++++++++++++++++++++++++++++----------- > 1 file changed, 35 insertions(+), 12 deletions(-) > > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c > index a59c39b..5d51693 100644 > --- a/lib/librte_vhost/virtio_net.c > +++ b/lib/librte_vhost/virtio_net.c > @@ -548,6 +548,18 @@ rte_vhost_enqueue_burst(int vid, uint16_t queue_id, > return virtio_dev_rx(dev, queue_id, pkts, count); > } > > +static inline bool > +virtio_net_with_host_offload(struct virtio_net *dev) > +{ > + if (dev->features & > + (VIRTIO_NET_F_CSUM | VIRTIO_NET_F_HOST_ECN | > + VIRTIO_NET_F_HOST_TSO4 | VIRTIO_NET_F_HOST_TSO6 | > + VIRTIO_NET_F_HOST_UFO)) > + return true; > + > + return false; > +} > + > static void > parse_ethernet(struct rte_mbuf *m, uint16_t *l4_proto, void **l4_hdr) > { > @@ -600,6 +612,9 @@ vhost_dequeue_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *m) > void *l4_hdr = NULL; > struct tcp_hdr *tcp_hdr = NULL; > > + if (hdr->flags == 0 || hdr->gso_type == VIRTIO_NET_HDR_GSO_NONE) > + return; > + Oops, just noticed I forgot to amend a fix I did. Of course, the above test should be: if (hdr->flags == 0 && hdr->gso_type == VIRTIO_NET_HDR_GSO_NONE) It will be fixed in the v2. Regards, Maxime