2023-06-19 17:17:35

by Jisheng Zhang

[permalink] [raw]
Subject: [PATCH net-next v3 0/2] net: stmmac: fix & improve driver statistics

improve the stmmac driver statistics:

1. don't clear network driver statistics in .ndo_close() and
.ndo_open() cycle
2. avoid some network driver statistics overflow on 32 bit platforms
3. use pcpu statistics where necessary to remove frequent cacheline
ping pongs.

NOTE: v1 and v2 are back ported from an internal LTS tree, I made
some mistakes when backporting and squashing. Now, net-next + v3
has been well tested with 'ethtool -s' and 'ip -s link show'.

Since v2:
- fix ethtool .get_sset_count, .get_strings and per queue stats
couting.
- fix .ndo_get_stats64 only counts the last cpu's pcpu stats.
- fix typo: s/iff/if in commit msg.
- remove unnecessary if statement brackets since we have removed
one LoC.

Since v1:
- rebase on net-next
- fold two original patches into one patch
- fix issues found by lkp
- update commit msg


Jisheng Zhang (2):
net: stmmac: don't clear network statistics in .ndo_open()
net: stmmac: use pcpu 64 bit statistics where necessary

drivers/net/ethernet/stmicro/stmmac/common.h | 54 +++--
.../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 15 +-
.../ethernet/stmicro/stmmac/dwmac100_dma.c | 7 +-
.../ethernet/stmicro/stmmac/dwmac4_descs.c | 16 +-
.../net/ethernet/stmicro/stmmac/dwmac4_lib.c | 15 +-
.../net/ethernet/stmicro/stmmac/dwmac_lib.c | 10 +-
.../ethernet/stmicro/stmmac/dwxgmac2_descs.c | 6 +-
.../ethernet/stmicro/stmmac/dwxgmac2_dma.c | 13 +-
.../net/ethernet/stmicro/stmmac/enh_desc.c | 20 +-
drivers/net/ethernet/stmicro/stmmac/hwif.h | 12 +-
.../net/ethernet/stmicro/stmmac/norm_desc.c | 15 +-
.../ethernet/stmicro/stmmac/stmmac_ethtool.c | 108 +++++++---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 190 +++++++++++++-----
13 files changed, 312 insertions(+), 169 deletions(-)

--
2.40.1



2023-06-19 17:17:58

by Jisheng Zhang

[permalink] [raw]
Subject: [PATCH net-next v3 1/2] net: stmmac: don't clear network statistics in .ndo_open()

FWICT, the common style in other network drivers: the network
statistics are not cleared since initialization, follow the common
style for stmmac.

Signed-off-by: Jisheng Zhang <[email protected]>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 5c645b6d5660..eb83396d6971 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3827,10 +3827,6 @@ static int __stmmac_open(struct net_device *dev,
}
}

- /* Extra statistics */
- memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats));
- priv->xstats.threshold = tc;
-
priv->rx_copybreak = STMMAC_RX_COPYBREAK;

buf_sz = dma_conf->dma_buf_sz;
@@ -7315,6 +7311,8 @@ int stmmac_dvr_probe(struct device *device,
#endif
priv->msg_enable = netif_msg_init(debug, default_msg_level);

+ priv->xstats.threshold = tc;
+
/* Initialize RSS */
rxq = priv->plat->rx_queues_to_use;
netdev_rss_key_fill(priv->rss.key, sizeof(priv->rss.key));
--
2.40.1