From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Matz Subject: Re: [PATCH v2 09/12] virtio: add Rx checksum offload support Date: Wed, 5 Oct 2016 13:56:36 +0200 Message-ID: <98db7fbb-42bd-512f-1d40-a1f3304a895e@6wind.com> References: <1469088510-7552-1-git-send-email-olivier.matz@6wind.com> <1475485223-30566-1-git-send-email-olivier.matz@6wind.com> <1475485223-30566-10-git-send-email-olivier.matz@6wind.com> <1da0b2c2-931b-3164-d211-4ceee7fd6864@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: 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 To: Maxime Coquelin , dev@dpdk.org, yuanhan.liu@linux.intel.com Return-path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 197348D91 for ; Wed, 5 Oct 2016 13:56:52 +0200 (CEST) In-Reply-To: <1da0b2c2-931b-3164-d211-4ceee7fd6864@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" Hi Maxime, On 10/03/2016 02:51 PM, Maxime Coquelin wrote: >> --- a/drivers/net/virtio/virtio_rxtx.c >> +++ b/drivers/net/virtio/virtio_rxtx.c >> @@ -50,6 +50,7 @@ >> #include >> #include >> #include >> +#include >> >> #include "virtio_logs.h" >> #include "virtio_ethdev.h" >> @@ -627,6 +628,56 @@ virtio_update_packet_stats(struct virtnet_stats >> *stats, struct rte_mbuf *mbuf) >> } >> } >> >> +/* Optionally fill offload information in structure */ >> +static int >> +virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr) >> +{ >> + struct rte_net_hdr_lens hdr_lens; >> + uint32_t hdrlen, ptype; >> + int l4_supported = 0; >> + >> + /* nothing to do */ >> + if (hdr->flags == 0 && hdr->gso_type == VIRTIO_NET_HDR_GSO_NONE) >> + return 0; > Maybe we could first check whether offload features were negotiated? > Doing this, we could return before accessing the header and so avoid a > cache miss. Yes, doing this would avoid reading the virtio header when the rx function is virtio_recv_pkts(). When using virtio_recv_mergeable_pkts(), it won't have a big impact since we already need to read hdr->num_buffers. I plan to do something like this in both recv functions: @@ -854,6 +854,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) int error; uint32_t i, nb_enqueued; uint32_t hdr_size; + uint64_t features; struct virtio_net_hdr *hdr; nb_used = VIRTQUEUE_NUSED(vq); @@ -872,6 +873,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) nb_rx = 0; nb_enqueued = 0; hdr_size = hw->vtnet_hdr_size; + features = hw->guest_features; for (i = 0; i < num ; i++) { rxm = rcv_pkts[i]; @@ -903,7 +905,8 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rte_vlan_strip(rxm); /* Update offload features */ - if (virtio_rx_offload(rxm, hdr) < 0) { + if ((features & VIRTIO_NET_F_GUEST_CSUM) && + virtio_rx_offload(rxm, hdr) < 0) { virtio_discard_rxbuf(vq, rxm); rxvq->stats.errors++; continue; Thank you for the feedback. Olivier