From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 44962A2EFC for ; Wed, 18 Sep 2019 06:20:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7A4711BF57; Wed, 18 Sep 2019 06:20:56 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 27CE21BEDC for ; Wed, 18 Sep 2019 06:20:54 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2019 21:20:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,519,1559545200"; d="scan'208";a="177597826" Received: from dpdk-virtio-tbie-2.sh.intel.com (HELO ___) ([10.67.104.71]) by orsmga007.jf.intel.com with ESMTP; 17 Sep 2019 21:20:53 -0700 Date: Wed, 18 Sep 2019 12:18:10 +0800 From: Tiwei Bie To: "Liu, Yong" Cc: "maxime.coquelin@redhat.com" , "dev@dpdk.org" Message-ID: <20190918041809.GA26915@___> References: <20190827102407.65106-1-yong.liu@intel.com> <20190910161446.36361-1-yong.liu@intel.com> <20190918023433.GA20995@___> <86228AFD5BCD8E4EBFD2B90117B5E81E633A4DA3@SHSMSX103.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <86228AFD5BCD8E4EBFD2B90117B5E81E633A4DA3@SHSMSX103.ccr.corp.intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v2 1/2] net/virtio: update stats when in order xmit done X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Sep 18, 2019 at 11:19:03AM +0800, Liu, Yong wrote: > > -----Original Message----- > > From: Bie, Tiwei > > Sent: Wednesday, September 18, 2019 10:35 AM > > To: Liu, Yong > > Cc: maxime.coquelin@redhat.com; dev@dpdk.org > > Subject: Re: [PATCH v2 1/2] net/virtio: update stats when in order xmit > > done > > > > On Wed, Sep 11, 2019 at 12:14:45AM +0800, Marvin Liu wrote: > > > When doing xmit in-order enqueue, packets are buffered and then flushed > > > into avail ring. Buffered packets can be dropped due to insufficient > > > space. Moving stats update action just after successful avail ring > > > updates can guarantee correctness. > > > > > > Signed-off-by: Marvin Liu > > > --- > > > drivers/net/virtio/virtio_rxtx.c | 87 ++++++++++++++++---------------- > > > 1 file changed, 44 insertions(+), 43 deletions(-) > > > > > > diff --git a/drivers/net/virtio/virtio_rxtx.c > > b/drivers/net/virtio/virtio_rxtx.c > > > index 27ead19fb..d3ca36831 100644 > > > --- a/drivers/net/virtio/virtio_rxtx.c > > > +++ b/drivers/net/virtio/virtio_rxtx.c > > > @@ -106,6 +106,48 @@ vq_ring_free_id_packed(struct virtqueue *vq, > > uint16_t id) > > > dxp->next = VQ_RING_DESC_CHAIN_END; > > > } > > > > > > +static inline void > > > +virtio_update_packet_stats(struct virtnet_stats *stats, struct rte_mbuf > > *mbuf) > > > +{ > > > + uint32_t s = mbuf->pkt_len; > > > + struct rte_ether_addr *ea; > > > + > > > + stats->bytes += s; > > > + > > > + if (s == 64) { > > > + stats->size_bins[1]++; > > > + } else if (s > 64 && s < 1024) { > > > + uint32_t bin; > > > + > > > + /* count zeros, and offset into correct bin */ > > > + bin = (sizeof(s) * 8) - __builtin_clz(s) - 5; > > > + stats->size_bins[bin]++; > > > + } else { > > > + if (s < 64) > > > + stats->size_bins[0]++; > > > + else if (s < 1519) > > > + stats->size_bins[6]++; > > > + else > > > + stats->size_bins[7]++; > > > + } > > > + > > > + ea = rte_pktmbuf_mtod(mbuf, struct rte_ether_addr *); > > > + if (rte_is_multicast_ether_addr(ea)) { > > > + if (rte_is_broadcast_ether_addr(ea)) > > > + stats->broadcast++; > > > + else > > > + stats->multicast++; > > > + } > > > +} > > > + > > > +static inline void > > > +virtio_rx_stats_updated(struct virtnet_rx *rxvq, struct rte_mbuf *m) > > > +{ > > > + VIRTIO_DUMP_PACKET(m, m->data_len); > > > + > > > + virtio_update_packet_stats(&rxvq->stats, m); > > > +} > > > + > > > static uint16_t > > > virtqueue_dequeue_burst_rx_packed(struct virtqueue *vq, > > > struct rte_mbuf **rx_pkts, > > > @@ -317,7 +359,7 @@ virtio_xmit_cleanup(struct virtqueue *vq, uint16_t > > num) > > > } > > > > > > /* Cleanup from completed inorder transmits. */ > > > -static void > > > +static __rte_always_inline void > > > virtio_xmit_cleanup_inorder(struct virtqueue *vq, uint16_t num) > > > { > > > uint16_t i, idx = vq->vq_used_cons_idx; > > > @@ -596,6 +638,7 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx > > *txvq, > > > dxp = &vq->vq_descx[vq->vq_avail_idx & (vq->vq_nentries - 1)]; > > > dxp->cookie = (void *)cookies[i]; > > > dxp->ndescs = 1; > > > + virtio_update_packet_stats(&txvq->stats, cookies[i]); > > > > The virtio_update_packet_stats() call in virtio_xmit_pkts_inorder() > > should be removed. > > > > Hi Tiwei, > Function remained in virtio_xmit_pkts_inorder is for those packets not handled by burst enqueue function. > Statistic of packets which handled in burst in_order enqueue function is updated in inner loop. I mean below virtio_update_packet_stats() call in virtio_xmit_pkts_inorder() should be removed while doing above change: https://github.com/DPDK/dpdk/blob/master/drivers/net/virtio/virtio_rxtx.c#L2201 I saw above line is removed by PATCH v2 2/2, but it should be done in this patch. > > Thanks, > Marvin > > > > > > > > > hdr = (struct virtio_net_hdr *) > > > rte_pktmbuf_prepend(cookies[i], head_size); > > > @@ -1083,48 +1126,6 @@ virtio_discard_rxbuf_inorder(struct virtqueue *vq, > > struct rte_mbuf *m) > > > } > > > } > > > > > > -static inline void > > > -virtio_update_packet_stats(struct virtnet_stats *stats, struct rte_mbuf > > *mbuf) > > > -{ > > > - uint32_t s = mbuf->pkt_len; > > > - struct rte_ether_addr *ea; > > > - > > > - stats->bytes += s; > > > - > > > - if (s == 64) { > > > - stats->size_bins[1]++; > > > - } else if (s > 64 && s < 1024) { > > > - uint32_t bin; > > > - > > > - /* count zeros, and offset into correct bin */ > > > - bin = (sizeof(s) * 8) - __builtin_clz(s) - 5; > > > - stats->size_bins[bin]++; > > > - } else { > > > - if (s < 64) > > > - stats->size_bins[0]++; > > > - else if (s < 1519) > > > - stats->size_bins[6]++; > > > - else > > > - stats->size_bins[7]++; > > > - } > > > - > > > - ea = rte_pktmbuf_mtod(mbuf, struct rte_ether_addr *); > > > - if (rte_is_multicast_ether_addr(ea)) { > > > - if (rte_is_broadcast_ether_addr(ea)) > > > - stats->broadcast++; > > > - else > > > - stats->multicast++; > > > - } > > > -} > > > - > > > -static inline void > > > -virtio_rx_stats_updated(struct virtnet_rx *rxvq, struct rte_mbuf *m) > > > -{ > > > - VIRTIO_DUMP_PACKET(m, m->data_len); > > > - > > > - virtio_update_packet_stats(&rxvq->stats, m); > > > -} > > > - > > > /* Optionally fill offload information in structure */ > > > static inline int > > > virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr) > > > -- > > > 2.17.1 > > >