From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A338C3A5A2 for ; Tue, 10 Sep 2019 05:47:37 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id E02992171F for ; Tue, 10 Sep 2019 05:47:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E02992171F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F07A31EBA6; Tue, 10 Sep 2019 07:47:35 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 3231C1EBA5 for ; Tue, 10 Sep 2019 07:47:34 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Sep 2019 22:47:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,487,1559545200"; d="scan'208";a="178569937" Received: from dpdk-virtio-tbie-2.sh.intel.com (HELO ___) ([10.67.104.71]) by orsmga008.jf.intel.com with ESMTP; 09 Sep 2019 22:47:31 -0700 Date: Tue, 10 Sep 2019 13:45:02 +0800 From: Tiwei Bie To: Marvin Liu Cc: dev@dpdk.org, maxime.coquelin@redhat.com, zhihong.wang@intel.com Message-ID: <20190910054502.GA12825@___> References: <20190827102407.65106-1-yong.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190827102407.65106-1-yong.liu@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH 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 Tue, Aug 27, 2019 at 06:24:06PM +0800, Marvin Liu wrote: > When doing xmit in-order enqueue, packets are buffered and then flushed > into avail ring. It has possibility that no free room in avail ring, > thus some buffered packets can't be transmitted. So move stats update > just after successful avail ring updates. > > Signed-off-by: Marvin Liu > --- > drivers/net/virtio/virtio_rxtx.c | 86 ++++++++++++++++---------------- > 1 file changed, 43 insertions(+), 43 deletions(-) > > diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c > index 27ead19fb..5d4ed524e 100644 > --- a/drivers/net/virtio/virtio_rxtx.c > +++ b/drivers/net/virtio/virtio_rxtx.c > @@ -575,6 +575,48 @@ virtqueue_xmit_offload(struct virtio_net_hdr *hdr, > } > } > > +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); > +} If we move above helpers, it's better to just move them to the top of this file. Thanks, Tiwei