Skip to contentSkip to conversation

net: mvpp2: Add extra ethtool stats

PATCH In review Maxime Chevallier 2 participants 5 messages Jun 10, 2019

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

cover net: mvpp2: Add extra ethtool stats

This series adds support for more ethtool counters in PPv2 :
- Per port counters, including one indicating the classifier drops
- Per RXQ and per TXQ counters

The first 2 patches perform some light rework and renaming, and the 3rd adds the extra counters.

Maxime Chevallier (3):
net: mvpp2: Only clear the stat counters at port init
net: mvpp2: Rename mvpp2_ethtool_counters to
mvpp2_ethtool_mib_counters
net: mvpp2: Add support for more ethtool counters

 drivers/net/ethernet/marvell/mvpp2/mvpp2.h    |  18 +++
 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   | 134 +++++++++++++++---
 2 files changed, 133 insertions(+), 19 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/3 net: mvpp2: Only clear the stat counters at port init

When first configuring a port on PPv2, we want to clear the internal counters so that we don't get values from previous boot stages.

However, we can't really clear these counters when resetting the MAC, since there are valid reasons to do so while the port is being used, such as when reconfiguring the interface mode with the PHY.

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +5 -6
index 4b4d79611339..ee653125194e 100644
@@ -1359,13 +1359,8 @@ static int mvpp2_ethtool_get_sset_count(struct net_device *dev, int sset)
 
 static void mvpp2_mac_reset_assert(struct mvpp2_port *port)
 {
-	unsigned int i;
 	u32 val;
 
-	/* Read the GOP statistics to reset the hardware counters */
-	for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
-		mvpp2_read_count(port, &mvpp2_ethtool_regs[i]);
-
 	val = readl(port->base + MVPP2_GMAC_CTRL_2_REG) |
 	      MVPP2_GMAC_PORT_RESET_MASK;
 	writel(val, port->base + MVPP2_GMAC_CTRL_2_REG);
@@ -4265,7 +4260,7 @@ static int mvpp2_port_init(struct mvpp2_port *port)
 	struct mvpp2 *priv = port->priv;
 	struct mvpp2_txq_pcpu *txq_pcpu;
 	unsigned int thread;
-	int queue, err;
+	int queue, err, i;
 
 	/* Checks for hardware constraints */
 	if (port->first_rxq + port->nrxqs >
@@ -4372,6 +4367,10 @@ static int mvpp2_port_init(struct mvpp2_port *port)
 	if (err)
 		goto err_free_percpu;
 
+	/* Read the GOP statistics to reset the hardware counters */
+	for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
+		mvpp2_read_count(port, &mvpp2_ethtool_regs[i]);
+
 	return 0;
 
 err_free_percpu:
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/3 net: mvpp2: Rename mvpp2_ethtool_counters to mvpp2_ethtool_mib_counters

In reply to Maxime Chevallier

Since we'll be adding support for other kind of internal counters, make clear that the currently supported counters are the MIB counters.

---
 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   | 21 ++++++++++---------
 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +11 -10
index ee653125194e..01380ccb2139 100644
@@ -1267,7 +1267,7 @@ static u64 mvpp2_read_count(struct mvpp2_port *port,
  * Hence, statistics gathered from userspace with ifconfig (software) and
  * ethtool (hardware) cannot be compared.
  */
-static const struct mvpp2_ethtool_counter mvpp2_ethtool_regs[] = {
+static const struct mvpp2_ethtool_counter mvpp2_ethtool_mib_regs[] = {
 	{ MVPP2_MIB_GOOD_OCTETS_RCVD, "good_octets_received", true },
 	{ MVPP2_MIB_BAD_OCTETS_RCVD, "bad_octets_received" },
 	{ MVPP2_MIB_CRC_ERRORS_SENT, "crc_errors_sent" },
@@ -1303,9 +1303,10 @@ static void mvpp2_ethtool_get_strings(struct net_device *netdev, u32 sset,
 	if (sset == ETH_SS_STATS) {
 		int i;
 
-		for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
+		for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_mib_regs); i++)
 			strscpy(data + i * ETH_GSTRING_LEN,
-			        mvpp2_ethtool_regs[i].string, ETH_GSTRING_LEN);
+				mvpp2_ethtool_mib_regs[i].string,
+				ETH_GSTRING_LEN);
 	}
 }
 
@@ -1320,8 +1321,8 @@ static void mvpp2_gather_hw_statistics(struct work_struct *work)
 	mutex_lock(&port->gather_stats_lock);
 
 	pstats = port->ethtool_stats;
-	for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
-		*pstats++ += mvpp2_read_count(port, &mvpp2_ethtool_regs[i]);
+	for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_mib_regs); i++)
+		*pstats++ += mvpp2_read_count(port, &mvpp2_ethtool_mib_regs[i]);
 
 	/* No need to read again the counters right after this function if it
 	 * was called asynchronously by the user (ie. use of ethtool).
@@ -1345,14 +1346,14 @@ static void mvpp2_ethtool_get_stats(struct net_device *dev,
 
 	mutex_lock(&port->gather_stats_lock);
 	memcpy(data, port->ethtool_stats,
-	       sizeof(u64) * ARRAY_SIZE(mvpp2_ethtool_regs));
+	       sizeof(u64) * ARRAY_SIZE(mvpp2_ethtool_mib_regs));
 	mutex_unlock(&port->gather_stats_lock);
 }
 
 static int mvpp2_ethtool_get_sset_count(struct net_device *dev, int sset)
 {
 	if (sset == ETH_SS_STATS)
-		return ARRAY_SIZE(mvpp2_ethtool_regs);
+		return ARRAY_SIZE(mvpp2_ethtool_mib_regs);
 
 	return -EOPNOTSUPP;
 }
@@ -4368,8 +4369,8 @@ static int mvpp2_port_init(struct mvpp2_port *port)
 		goto err_free_percpu;
 
 	/* Read the GOP statistics to reset the hardware counters */
-	for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
-		mvpp2_read_count(port, &mvpp2_ethtool_regs[i]);
+	for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_mib_regs); i++)
+		mvpp2_read_count(port, &mvpp2_ethtool_mib_regs[i]);
 
 	return 0;
 
@@ -5052,7 +5053,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
 	}
 
 	port->ethtool_stats = devm_kcalloc(&pdev->dev,
-					   ARRAY_SIZE(mvpp2_ethtool_regs),
+					   ARRAY_SIZE(mvpp2_ethtool_mib_regs),
 					   sizeof(u64), GFP_KERNEL);
 	if (!port->ethtool_stats) {
 		err = -ENOMEM;
Signature · 1 line
2.20.1
#3 lore raw

PATCH 3/3 net: mvpp2: Add support for more ethtool counters

In reply to Maxime Chevallier

Besides the MIB counters, some other useful counters can be exposed to the user. This commit adds support for :

- Per-port counters, that indicate FIFO drops and classifier drops,
- Per-rxq counters,
- Per-txq counters

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h    |  18 +++
 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   | 132 +++++++++++++++---
 2 files changed, 132 insertions(+), 18 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +18 -0
index d67c970f02e5..4d9564ba68f6 100644
@@ -329,8 +329,26 @@
 #define     MVPP22_BM_ADDR_HIGH_VIRT_RLS_MASK	0xff00
 #define     MVPP22_BM_ADDR_HIGH_VIRT_RLS_SHIFT	8
 
+/* Packet Processor per-port counters */
+#define MVPP2_OVERRUN_ETH_DROP			0x7000
+#define MVPP2_CLS_ETH_DROP			0x7020
+
 /* Hit counters registers */
 #define MVPP2_CTRS_IDX				0x7040
+#define     MVPP22_CTRS_TX_CTR(port, txq)	((txq) | ((port) << 3) | BIT(7))
+#define MVPP2_TX_DESC_ENQ_CTR			0x7100
+#define MVPP2_TX_DESC_ENQ_TO_DDR_CTR		0x7104
+#define MVPP2_TX_BUFF_ENQ_TO_DDR_CTR		0x7108
+#define MVPP2_TX_DESC_ENQ_HW_FWD_CTR		0x710c
+#define MVPP2_RX_DESC_ENQ_CTR			0x7120
+#define MVPP2_TX_PKTS_DEQ_CTR			0x7130
+#define MVPP2_TX_PKTS_FULL_QUEUE_DROP_CTR	0x7200
+#define MVPP2_TX_PKTS_EARLY_DROP_CTR		0x7204
+#define MVPP2_TX_PKTS_BM_DROP_CTR		0x7208
+#define MVPP2_TX_PKTS_BM_MC_DROP_CTR		0x720c
+#define MVPP2_RX_PKTS_FULL_QUEUE_DROP_CTR	0x7220
+#define MVPP2_RX_PKTS_EARLY_DROP_CTR		0x7224
+#define MVPP2_RX_PKTS_BM_DROP_CTR		0x7228
 #define MVPP2_CLS_DEC_TBL_HIT_CTR		0x7700
 #define MVPP2_CLS_FLOW_TBL_HIT_CTR		0x7704
 
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +114 -18

189 lines not on this page · raw message

Signature · 1 line
2.20.1
maintainer
#4 lore raw
In reply to Maxime Chevallier

From: Maxime Chevallier <[email protected]>
Date: Mon, 10 Jun 2019 10:55:26 +0200

Quoted 6 lines

This series adds support for more ethtool counters in PPv2 :
- Per port counters, including one indicating the classifier drops
- Per RXQ and per TXQ counters

The first 2 patches perform some light rework and renaming, and the 3rd adds the extra counters.

Series applied, thanks.