Skip to contentSkip to conversation

net: stmmac: Add ethtool per-queue statistic

PATCH Applied Vijayakannan Ayyathurai 3 participants 8 messages Aug 16, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net: stmmac: Add ethtool per-queue statistic

Adding generic ethtool per-queue statistic framework to display the statistics for each rx/tx queue. In future, users can avail it to add more per-queue specific counters. Number of rx/tx queues displayed is depending on the available rx/tx queues in that particular MAC config and this number is limited up to the MTL_MAX_{RX|TX}_QUEUES defined in the driver.

Ethtool per-queue statistic display will look like below, when users start adding more counters.

Example - 1:
q0_tx_statA:
q0_tx_statB:
q0_tx_statC:
|
q0_tx_statX:
.
.
.
qMAX_tx_statA:
qMAX_tx_statB:
qMAX_tx_statC:
|
qMAX_tx_statX:

q0_rx_statA:
q0_rx_statB:
q0_rx_statC:
|
q0_rx_statX:
.
.
.
qMAX_rx_statA:
qMAX_rx_statB:
qMAX_rx_statC:
|
qMAX_rx_statX:

Example - 2: Ping test using the tx queue 3.

$ tc qdisc add dev enp0s30f4 root mqprio num_tc 2 map 1 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 queues 3@0 1@3 hw 0

Statistic before ping:
---------------------

$ ethtool -S enp0s30f4

[ snip ]

     q3_tx_pkt_n: 7916
     q3_tx_irq_n: 316

[ snip ]

$ cat /proc/interrupts

[ snip ]
143: 0 0 0 316 0 0

         0          0  IR-PCI-MSI 499719-edge      enp0s30f4:tx-3

[ snip ]

$ ping -I enp0s30f4 192.168.1.10 -i 0.01 -c 100 > /dev/null

Statistic after ping:
---------------------

$ ethtool -S enp0s30f4

[ snip ]

     q3_tx_pkt_n: 8016
     q3_tx_irq_n: 320

[ snip ]

$ cat /proc/interrupts

[ snip ]
143: 0 0 0 320 0 0

         0          0  IR-PCI-MSI 499719-edge      enp0s30f4:tx-3

[ snip ]

Vijayakannan Ayyathurai (2):
net: stmmac: add ethtool per-queue statistic framework
net: stmmac: add ethtool per-queue irq statistic support

Voon Weifeng (1):
net: stmmac: fix INTR TBU status affecting irq count statistic

 drivers/net/ethernet/stmicro/stmmac/common.h  | 13 ++++
 .../net/ethernet/stmicro/stmmac/dwmac4_lib.c  |  7 +-
 .../ethernet/stmicro/stmmac/stmmac_ethtool.c  | 67 ++++++++++++++++++-
 .../net/ethernet/stmicro/stmmac/stmmac_main.c |  5 ++
 4 files changed, 89 insertions(+), 3 deletions(-)

base-commit: e4637f621203cb482f3ddb590cfe9f65045d92a6

Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 net: stmmac: fix INTR TBU status affecting irq count statistic

From: Voon Weifeng <[email protected]>

DMA channel status "Transmit buffer unavailable(TBU)" bit is not considered as a successful dma tx. Hence, it should not affect all the irq count statistic.

Fixes 1103d3a5531c ("net: stmmac: dwmac4: Also use TBU interrupt to clean TX path")
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +3 -2
index e63270267578..f83db62938dd 100644
@@ -172,11 +172,12 @@ int dwmac4_dma_interrupt(void __iomem *ioaddr,
 		x->rx_normal_irq_n++;
 		ret |= handle_rx;
 	}
-	if (likely(intr_status & (DMA_CHAN_STATUS_TI |
-		DMA_CHAN_STATUS_TBU))) {
+	if (likely(intr_status & DMA_CHAN_STATUS_TI)) {
 		x->tx_normal_irq_n++;
 		ret |= handle_tx;
 	}
+	if (unlikely(intr_status & DMA_CHAN_STATUS_TBU))
+		ret |= handle_tx;
 	if (unlikely(intr_status & DMA_CHAN_STATUS_ERI))
 		x->rx_early_irq++;
 
Signature · 1 line
2.17.1
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH net-next v1 1/3] net: stmmac: fix INTR TBU status affecting irq count statistic

Quoted 6 lines · Vijayakannan Ayyathurai

From: Voon Weifeng <[email protected]>

DMA channel status "Transmit buffer unavailable(TBU)" bit is not considered as a successful dma tx. Hence, it should not affect all the irq count statistic.

Quoted 26 lines
Fixes 1103d3a5531c ("net: stmmac: dwmac4: Also use TBU interrupt to clean TX path")
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +3 -2
index e63270267578..f83db62938dd 100644
@@ -172,11 +172,12 @@ int dwmac4_dma_interrupt(void __iomem *ioaddr,
 		x->rx_normal_irq_n++;
 		ret |= handle_rx;
 	}
-	if (likely(intr_status & (DMA_CHAN_STATUS_TI |
-		DMA_CHAN_STATUS_TBU))) {
+	if (likely(intr_status & DMA_CHAN_STATUS_TI)) {
 		x->tx_normal_irq_n++;
 		ret |= handle_tx;
 	}
+	if (unlikely(intr_status & DMA_CHAN_STATUS_TBU))
+		ret |= handle_tx;
 	if (unlikely(intr_status & DMA_CHAN_STATUS_ERI))
 		x->rx_early_irq++;
 
#3 lore raw

PATCH 2/3 net: stmmac: add ethtool per-queue statistic framework

In reply to Vijayakannan Ayyathurai

Adding generic ethtool per-queue statistic framework to display the statistics for each rx/tx queue. In future, users can avail it to add more per-queue specific counters. Number of rx/tx queues displayed is depending on the available rx/tx queues in that particular MAC config and this number is limited up to the MTL_MAX_{RX|TX}_QUEUES defined in the driver.

Ethtool per-queue statistic display will look like below, when users start adding more counters.

Example:
q0_tx_statA:
q0_tx_statB:
q0_tx_statC:
|
q0_tx_statX:
.
.
.
qMAX_tx_statA:
qMAX_tx_statB:
qMAX_tx_statC:
|
qMAX_tx_statX:

q0_rx_statA:
q0_rx_statB:
q0_rx_statC:
|
q0_rx_statX:
.
.
.
qMAX_rx_statA:
qMAX_rx_statB:
qMAX_rx_statC:
|
qMAX_rx_statX:

In addition, this patch has the support on displaying the number of packets received and transmitted per queue.

---
 drivers/net/ethernet/stmicro/stmmac/common.h  | 11 ++++
 .../ethernet/stmicro/stmmac/stmmac_ethtool.c  | 65 ++++++++++++++++++-
 .../net/ethernet/stmicro/stmmac/stmmac_main.c |  5 ++
 3 files changed, 80 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/common.h +11 -0
index 5fecc83f175b..79333deef2e2 100644
@@ -58,6 +58,14 @@
 #undef FRAME_FILTER_DEBUG
 /* #define FRAME_FILTER_DEBUG */
 
+struct stmmac_txq_stats {
+	unsigned long tx_pkt_n;
+};
+
+struct stmmac_rxq_stats {
+	unsigned long rx_pkt_n;
+};
+
 /* Extra statistic and debug information exposed by ethtool */
 struct stmmac_extra_stats {
 	/* Transmit errors */
@@ -189,6 +197,9 @@ struct stmmac_extra_stats {
 	unsigned long mtl_est_hlbf;
 	unsigned long mtl_est_btre;
 	unsigned long mtl_est_btrlm;
+	/* per queue statistics */
+	struct stmmac_txq_stats txq_stats[MTL_MAX_TX_QUEUES];
+	struct stmmac_rxq_stats rxq_stats[MTL_MAX_RX_QUEUES];
 };
 
 /* Safety Feature statistics exposed by ethtool */
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +64 -1

104 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 -0
index a2aa75cb184e..7b3fcf558603 100644
@@ -2500,6 +2500,7 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue)
 			} else {
 				priv->dev->stats.tx_packets++;
 				priv->xstats.tx_pkt_n++;
+				priv->xstats.txq_stats[queue].tx_pkt_n++;
 			}
 			if (skb)
 				stmmac_get_tx_hwtstamp(priv, p, skb);
@@ -5000,6 +5001,9 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
 
 	stmmac_finalize_xdp_rx(priv, xdp_status);
 
+	priv->xstats.rx_pkt_n += count;
+	priv->xstats.rxq_stats[queue].rx_pkt_n += count;
+
 	if (xsk_uses_need_wakeup(rx_q->xsk_pool)) {
 		if (failure || stmmac_rx_dirty(priv, queue) > 0)
 			xsk_set_rx_need_wakeup(rx_q->xsk_pool);
@@ -5287,6 +5291,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 	stmmac_rx_refill(priv, queue);
 
 	priv->xstats.rx_pkt_n += count;
+	priv->xstats.rxq_stats[queue].rx_pkt_n += count;
 
 	return count;
 }
Signature · 1 line
2.17.1
Acked-by on v1 2/3
#4 lore raw

Re: [PATCH net-next v1 2/3] net: stmmac: add ethtool per-queue statistic framework

Quoted 39 lines · Vijayakannan Ayyathurai

Adding generic ethtool per-queue statistic framework to display the statistics for each rx/tx queue. In future, users can avail it to add more per-queue specific counters. Number of rx/tx queues displayed is depending on the available rx/tx queues in that particular MAC config and this number is limited up to the MTL_MAX_{RX|TX}_QUEUES defined in the driver.

Ethtool per-queue statistic display will look like below, when users start adding more counters.

Example:
q0_tx_statA:
q0_tx_statB:
q0_tx_statC:
|
q0_tx_statX:
.
.
.
qMAX_tx_statA:
qMAX_tx_statB:
qMAX_tx_statC:
|
qMAX_tx_statX:

q0_rx_statA:
q0_rx_statB:
q0_rx_statC:
|
q0_rx_statX:
.
.
.
qMAX_rx_statA:
qMAX_rx_statB:
qMAX_rx_statC:
|
qMAX_rx_statX:

Quoted 3 lines

In addition, this patch has the support on displaying the number of packets received and transmitted per queue.

Quoted 2 lines

---

#5 lore raw

PATCH 3/3 net: stmmac: add ethtool per-queue irq statistic support

In reply to Vijayakannan Ayyathurai

Adding ethtool per-queue statistics support to show number of interrupts generated at DMA tx and DMA rx. All the counters are incremented at dwmac4_dma_interrupt function.

---
 drivers/net/ethernet/stmicro/stmmac/common.h         | 2 ++
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c     | 2 ++
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 2 ++
 3 files changed, 6 insertions(+)
drivers/net/ethernet/stmicro/stmmac/common.h +2 -0
index 79333deef2e2..b6d945ea903d 100644
@@ -60,10 +60,12 @@
 
 struct stmmac_txq_stats {
 	unsigned long tx_pkt_n;
+	unsigned long tx_normal_irq_n;
 };
 
 struct stmmac_rxq_stats {
 	unsigned long rx_pkt_n;
+	unsigned long rx_normal_irq_n;
 };
 
 /* Extra statistic and debug information exposed by ethtool */
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +2 -0
index f83db62938dd..9292a1fab7d3 100644
@@ -170,10 +170,12 @@ int dwmac4_dma_interrupt(void __iomem *ioaddr,
 		x->normal_irq_n++;
 	if (likely(intr_status & DMA_CHAN_STATUS_RI)) {
 		x->rx_normal_irq_n++;
+		x->rxq_stats[chan].rx_normal_irq_n++;
 		ret |= handle_rx;
 	}
 	if (likely(intr_status & DMA_CHAN_STATUS_TI)) {
 		x->tx_normal_irq_n++;
+		x->txq_stats[chan].tx_normal_irq_n++;
 		ret |= handle_tx;
 	}
 	if (unlikely(intr_status & DMA_CHAN_STATUS_TBU))
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +2 -0
index 10c0895d0b43..595c3ccdcbb7 100644
@@ -263,11 +263,13 @@ static const struct stmmac_stats stmmac_mmc[] = {
 
 static const char stmmac_qstats_tx_string[][ETH_GSTRING_LEN] = {
 	"tx_pkt_n",
+	"tx_irq_n",
 #define STMMAC_TXQ_STATS ARRAY_SIZE(stmmac_qstats_tx_string)
 };
 
 static const char stmmac_qstats_rx_string[][ETH_GSTRING_LEN] = {
 	"rx_pkt_n",
+	"rx_irq_n",
 #define STMMAC_RXQ_STATS ARRAY_SIZE(stmmac_qstats_rx_string)
 };
 
Signature · 1 line
2.17.1
Acked-by on v1 3/3
#6 lore raw

Re: [PATCH net-next v1 3/3] net: stmmac: add ethtool per-queue irq statistic support

Quoted 4 lines · Vijayakannan Ayyathurai

Adding ethtool per-queue statistics support to show number of interrupts generated at DMA tx and DMA rx. All the counters are incremented at dwmac4_dma_interrupt function.

Quoted 59 lines
---
 drivers/net/ethernet/stmicro/stmmac/common.h         | 2 ++
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c     | 2 ++
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 2 ++
 3 files changed, 6 insertions(+)
drivers/net/ethernet/stmicro/stmmac/common.h +2 -0
index 79333deef2e2..b6d945ea903d 100644
@@ -60,10 +60,12 @@
 
 struct stmmac_txq_stats {
 	unsigned long tx_pkt_n;
+	unsigned long tx_normal_irq_n;
 };
 
 struct stmmac_rxq_stats {
 	unsigned long rx_pkt_n;
+	unsigned long rx_normal_irq_n;
 };
 
 /* Extra statistic and debug information exposed by ethtool */
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +2 -0
index f83db62938dd..9292a1fab7d3 100644
@@ -170,10 +170,12 @@ int dwmac4_dma_interrupt(void __iomem *ioaddr,
 		x->normal_irq_n++;
 	if (likely(intr_status & DMA_CHAN_STATUS_RI)) {
 		x->rx_normal_irq_n++;
+		x->rxq_stats[chan].rx_normal_irq_n++;
 		ret |= handle_rx;
 	}
 	if (likely(intr_status & DMA_CHAN_STATUS_TI)) {
 		x->tx_normal_irq_n++;
+		x->txq_stats[chan].tx_normal_irq_n++;
 		ret |= handle_tx;
 	}
 	if (unlikely(intr_status & DMA_CHAN_STATUS_TBU))
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +2 -0
index 10c0895d0b43..595c3ccdcbb7 100644
@@ -263,11 +263,13 @@ static const struct stmmac_stats stmmac_mmc[] = {
 
 static const char stmmac_qstats_tx_string[][ETH_GSTRING_LEN] = {
 	"tx_pkt_n",
+	"tx_irq_n",
 #define STMMAC_TXQ_STATS ARRAY_SIZE(stmmac_qstats_tx_string)
 };
 
 static const char stmmac_qstats_rx_string[][ETH_GSTRING_LEN] = {
 	"rx_pkt_n",
+	"rx_irq_n",
 #define STMMAC_RXQ_STATS ARRAY_SIZE(stmmac_qstats_rx_string)
 };
 
#7 lore raw
In reply to Vijayakannan Ayyathurai
This series was applied to netdev/net-next.git (refs/heads/master):

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

Quoted 8 lines · On Mon, 16 Aug 2021 14:15:57 +0800 you wrote:

Adding generic ethtool per-queue statistic framework to display the statistics for each rx/tx queue. In future, users can avail it to add more per-queue specific counters. Number of rx/tx queues displayed is depending on the available rx/tx queues in that particular MAC config and this number is limited up to the MTL_MAX_{RX|TX}_QUEUES defined in the driver.

[...]

Here is the summary with links:
- [net-next,v1,1/3] net: stmmac: fix INTR TBU status affecting irq count statistic

    https://git.kernel.org/netdev/net-next/c/1975df880b95
  - [net-next,v1,2/3] net: stmmac: add ethtool per-queue statistic framework
    https://git.kernel.org/netdev/net-next/c/68e9c5dee1cf
  - [net-next,v1,3/3] net: stmmac: add ethtool per-queue irq statistic support
    https://git.kernel.org/netdev/net-next/c/af9bf70154eb

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html