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 <maxime.coquelin at redhat.com> > --- > 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