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 92078A04DD for ; Wed, 18 Nov 2020 17:38:38 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 275E5C908; Wed, 18 Nov 2020 17:38:02 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id 49CDEC908 for ; Wed, 18 Nov 2020 17:38:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605717478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZyZishJ5IvqCvRN9OnECoIyUq6QLqlTOswN0AZVOL3k=; b=XVUHiJgCtwRKpTg3mNlMk4gKk4W/+YIH3fcZhd0jxx8G4E6ebNKTmQMpEiFiQJlIWPs+SO w4MVRwp3SR0Do08AkQX8TBNdL14I3ably3jbk0uRtMUksA8620JFswCZcfjpoTaARfDNaW PtOcpqFYv96dqACsjWu9R7OypNZQuD4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-478-8LNCM9aBPri3aMPvgF38og-1; Wed, 18 Nov 2020 11:37:55 -0500 X-MC-Unique: 8LNCM9aBPri3aMPvgF38og-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F2A34805F15; Wed, 18 Nov 2020 16:37:53 +0000 (UTC) Received: from rh.redhat.com (ovpn-113-249.ams2.redhat.com [10.36.113.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5F345C1A3; Wed, 18 Nov 2020 16:37:48 +0000 (UTC) From: Kevin Traynor To: David Christensen Cc: Chenbo Xia , Maxime Coquelin , dpdk stable Date: Wed, 18 Nov 2020 16:35:42 +0000 Message-Id: <20201118163558.1101823-56-ktraynor@redhat.com> In-Reply-To: <20201118163558.1101823-1-ktraynor@redhat.com> References: <20201118163558.1101823-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-stable] patch 'net/vhost: fix xstats after clearing stats' has been queued to LTS release 18.11.11 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.11 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/24/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/7ff9bbe37c5ec9664a099b6a1c8d7a3361926942 Thanks. Kevin. --- >From 7ff9bbe37c5ec9664a099b6a1c8d7a3361926942 Mon Sep 17 00:00:00 2001 From: David Christensen Date: Thu, 15 Oct 2020 10:49:37 -0700 Subject: [PATCH] net/vhost: fix xstats after clearing stats [ upstream commit d4fbb27459954bdbb9240d16b47bdfccf47c6e34 ] The PMD API allows stats and xstats values to be cleared separately. This is a problem for the vhost PMD since some of the xstats values are derived from existing stats values. For example: testpmd> show port xstats all ... tx_unicast_packets: 17562959 ... testpmd> clear port stats all ... show port xstats all ... tx_unicast_packets: 18446744073709551615 ... Modify the driver so that stats and xstats values are stored, updated, and cleared separately. Fixes: 4d6cf2ac93dc ("net/vhost: add extended statistics") Signed-off-by: David Christensen Reviewed-by: Chenbo Xia Reviewed-by: Maxime Coquelin --- drivers/net/vhost/rte_eth_vhost.c | 76 +++++++++++++++---------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 93ca8ebe4b..88e3915503 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -67,4 +67,7 @@ enum vhost_xstats_pkts { VHOST_MULTICAST_PKT, VHOST_UNICAST_PKT, + VHOST_PKT, + VHOST_BYTE, + VHOST_MISSED_PKT, VHOST_ERRORS_PKT, VHOST_ERRORS_FRAGMENTED, @@ -140,9 +143,9 @@ struct vhost_xstats_name_off { static const struct vhost_xstats_name_off vhost_rxport_stat_strings[] = { {"good_packets", - offsetof(struct vhost_queue, stats.pkts)}, + offsetof(struct vhost_queue, stats.xstats[VHOST_PKT])}, {"total_bytes", - offsetof(struct vhost_queue, stats.bytes)}, + offsetof(struct vhost_queue, stats.xstats[VHOST_BYTE])}, {"missed_pkts", - offsetof(struct vhost_queue, stats.missed_pkts)}, + offsetof(struct vhost_queue, stats.xstats[VHOST_MISSED_PKT])}, {"broadcast_packets", offsetof(struct vhost_queue, stats.xstats[VHOST_BROADCAST_PKT])}, @@ -180,9 +183,9 @@ static const struct vhost_xstats_name_off vhost_rxport_stat_strings[] = { static const struct vhost_xstats_name_off vhost_txport_stat_strings[] = { {"good_packets", - offsetof(struct vhost_queue, stats.pkts)}, + offsetof(struct vhost_queue, stats.xstats[VHOST_PKT])}, {"total_bytes", - offsetof(struct vhost_queue, stats.bytes)}, + offsetof(struct vhost_queue, stats.xstats[VHOST_BYTE])}, {"missed_pkts", - offsetof(struct vhost_queue, stats.missed_pkts)}, + offsetof(struct vhost_queue, stats.xstats[VHOST_MISSED_PKT])}, {"broadcast_packets", offsetof(struct vhost_queue, stats.xstats[VHOST_BROADCAST_PKT])}, @@ -276,21 +279,4 @@ vhost_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, return nxstats; - for (i = 0; i < dev->data->nb_rx_queues; i++) { - vq = dev->data->rx_queues[i]; - if (!vq) - continue; - vq->stats.xstats[VHOST_UNICAST_PKT] = vq->stats.pkts - - (vq->stats.xstats[VHOST_BROADCAST_PKT] - + vq->stats.xstats[VHOST_MULTICAST_PKT]); - } - for (i = 0; i < dev->data->nb_tx_queues; i++) { - vq = dev->data->tx_queues[i]; - if (!vq) - continue; - vq->stats.xstats[VHOST_UNICAST_PKT] = vq->stats.pkts - + vq->stats.missed_pkts - - (vq->stats.xstats[VHOST_BROADCAST_PKT] - + vq->stats.xstats[VHOST_MULTICAST_PKT]); - } for (t = 0; t < VHOST_NB_XSTATS_RXPORT; t++) { xstats[count].value = 0; @@ -323,5 +309,5 @@ vhost_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, static inline void -vhost_count_multicast_broadcast(struct vhost_queue *vq, +vhost_count_xcast_packets(struct vhost_queue *vq, struct rte_mbuf *mbuf) { @@ -335,11 +321,13 @@ vhost_count_multicast_broadcast(struct vhost_queue *vq, else pstats->xstats[VHOST_MULTICAST_PKT]++; + } else { + pstats->xstats[VHOST_UNICAST_PKT]++; } } static void -vhost_update_packet_xstats(struct vhost_queue *vq, - struct rte_mbuf **bufs, - uint16_t count) +vhost_update_packet_xstats(struct vhost_queue *vq, struct rte_mbuf **bufs, + uint16_t count, uint64_t nb_bytes, + uint64_t nb_missed) { uint32_t pkt_len = 0; @@ -348,5 +336,10 @@ vhost_update_packet_xstats(struct vhost_queue *vq, struct vhost_stats *pstats = &vq->stats; + pstats->xstats[VHOST_BYTE] += nb_bytes; + pstats->xstats[VHOST_MISSED_PKT] += nb_missed; + pstats->xstats[VHOST_UNICAST_PKT] += nb_missed; + for (i = 0; i < count ; i++) { + pstats->xstats[VHOST_PKT]++; pkt_len = bufs[i]->pkt_len; if (pkt_len == 64) { @@ -364,5 +357,5 @@ vhost_update_packet_xstats(struct vhost_queue *vq, pstats->xstats[VHOST_1523_TO_MAX_PKT]++; } - vhost_count_multicast_broadcast(vq, bufs[i]); + vhost_count_xcast_packets(vq, bufs[i]); } } @@ -374,4 +367,5 @@ eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) uint16_t i, nb_rx = 0; uint16_t nb_receive = nb_bufs; + uint64_t nb_bytes = 0; if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0)) @@ -408,8 +402,9 @@ eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) rte_vlan_strip(bufs[i]); - r->stats.bytes += bufs[i]->pkt_len; + nb_bytes += bufs[i]->pkt_len; } - vhost_update_packet_xstats(r, bufs, nb_rx); + r->stats.bytes += nb_bytes; + vhost_update_packet_xstats(r, bufs, nb_rx, nb_bytes, 0); out: @@ -425,4 +420,6 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) uint16_t i, nb_tx = 0; uint16_t nb_send = 0; + uint64_t nb_bytes = 0; + uint64_t nb_missed = 0; if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0)) @@ -465,18 +462,21 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) } + for (i = 0; likely(i < nb_tx); i++) + nb_bytes += bufs[i]->pkt_len; + + nb_missed = nb_bufs - nb_tx; + r->stats.pkts += nb_tx; + r->stats.bytes += nb_bytes; r->stats.missed_pkts += nb_bufs - nb_tx; - for (i = 0; likely(i < nb_tx); i++) - r->stats.bytes += bufs[i]->pkt_len; + vhost_update_packet_xstats(r, bufs, nb_tx, nb_bytes, nb_missed); - vhost_update_packet_xstats(r, bufs, nb_tx); - - /* According to RFC2863 page42 section ifHCOutMulticastPkts and - * ifHCOutBroadcastPkts, the counters "multicast" and "broadcast" - * are increased when packets are not transmitted successfully. + /* According to RFC2863, ifHCOutUcastPkts, ifHCOutMulticastPkts and + * ifHCOutBroadcastPkts counters are increased when packets are not + * transmitted successfully. */ for (i = nb_tx; i < nb_bufs; i++) - vhost_count_multicast_broadcast(r, bufs[i]); + vhost_count_xcast_packets(r, bufs[i]); for (i = 0; likely(i < nb_tx); i++) -- 2.26.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-11-18 16:33:38.996340986 +0000 +++ 0056-net-vhost-fix-xstats-after-clearing-stats.patch 2020-11-18 16:33:37.981215095 +0000 @@ -1 +1 @@ -From d4fbb27459954bdbb9240d16b47bdfccf47c6e34 Mon Sep 17 00:00:00 2001 +From 7ff9bbe37c5ec9664a099b6a1c8d7a3361926942 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit d4fbb27459954bdbb9240d16b47bdfccf47c6e34 ] + @@ -25 +26,0 @@ -Cc: stable@dpdk.org @@ -35 +36 @@ -index f2712036fc..5845bb15f3 100644 +index 93ca8ebe4b..88e3915503 100644 @@ -38 +39 @@ -@@ -72,4 +72,7 @@ enum vhost_xstats_pkts { +@@ -67,4 +67,7 @@ enum vhost_xstats_pkts { @@ -46 +47 @@ -@@ -148,9 +151,9 @@ struct vhost_xstats_name_off { +@@ -140,9 +143,9 @@ struct vhost_xstats_name_off { @@ -59 +60 @@ -@@ -188,9 +191,9 @@ static const struct vhost_xstats_name_off vhost_rxport_stat_strings[] = { +@@ -180,9 +183,9 @@ static const struct vhost_xstats_name_off vhost_rxport_stat_strings[] = { @@ -72 +73 @@ -@@ -286,21 +289,4 @@ vhost_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, +@@ -276,21 +279,4 @@ vhost_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, @@ -94 +95 @@ -@@ -333,5 +319,5 @@ vhost_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, +@@ -323,5 +309,5 @@ vhost_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, @@ -101 +102 @@ -@@ -345,11 +331,13 @@ vhost_count_multicast_broadcast(struct vhost_queue *vq, +@@ -335,11 +321,13 @@ vhost_count_multicast_broadcast(struct vhost_queue *vq, @@ -118 +119 @@ -@@ -358,5 +346,10 @@ vhost_update_packet_xstats(struct vhost_queue *vq, +@@ -348,5 +336,10 @@ vhost_update_packet_xstats(struct vhost_queue *vq, @@ -129 +130 @@ -@@ -374,5 +367,5 @@ vhost_update_packet_xstats(struct vhost_queue *vq, +@@ -364,5 +357,5 @@ vhost_update_packet_xstats(struct vhost_queue *vq, @@ -136 +137 @@ -@@ -384,4 +377,5 @@ eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) +@@ -374,4 +367,5 @@ eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) @@ -142 +143 @@ -@@ -418,8 +412,9 @@ eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) +@@ -408,8 +402,9 @@ eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) @@ -154 +155 @@ -@@ -435,4 +430,6 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) +@@ -425,4 +420,6 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) @@ -161 +162 @@ -@@ -475,18 +472,21 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) +@@ -465,18 +462,21 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)