From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from lfbn-1-5996-232.w90-110.abo.wanadoo.fr ([90.110.195.232] helo=[192.168.1.13]) by mail.droids-corp.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1brkrY-0001Nw-Fb; Wed, 05 Oct 2016 13:59:52 +0200 To: Maxime Coquelin , dev@dpdk.org, yuanhan.liu@linux.intel.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> 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 From: Olivier Matz Message-ID: <98db7fbb-42bd-512f-1d40-a1f3304a895e@6wind.com> Date: Wed, 5 Oct 2016 13:56:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0 MIME-Version: 1.0 In-Reply-To: <1da0b2c2-931b-3164-d211-4ceee7fd6864@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2 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, 05 Oct 2016 11:56:52 -0000 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