b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From a5e4a018cf5c7ed9709141c41ba7b262aa79870d Mon Sep 17 00:00:00 2001 |
| 2 | From: Claudiu Manoil <claudiu.manoil@nxp.com> |
| 3 | Date: Tue, 22 Oct 2019 20:23:38 +0300 |
| 4 | Subject: [PATCH] enetc: Clean up of ehtool stats len |
| 5 | |
| 6 | Just refactoring stats len code to make it easier to |
| 7 | add new stats counters. |
| 8 | |
| 9 | Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com> |
| 10 | --- |
| 11 | drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 20 +++++++++++++------- |
| 12 | 1 file changed, 13 insertions(+), 7 deletions(-) |
| 13 | |
| 14 | --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c |
| 15 | +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c |
| 16 | @@ -199,15 +199,21 @@ static const char tx_ring_stats[][ETH_GS |
| 17 | static int enetc_get_sset_count(struct net_device *ndev, int sset) |
| 18 | { |
| 19 | struct enetc_ndev_priv *priv = netdev_priv(ndev); |
| 20 | + int len; |
| 21 | |
| 22 | - if (sset == ETH_SS_STATS) |
| 23 | - return ARRAY_SIZE(enetc_si_counters) + |
| 24 | - ARRAY_SIZE(tx_ring_stats) * priv->num_tx_rings + |
| 25 | - ARRAY_SIZE(rx_ring_stats) * priv->num_rx_rings + |
| 26 | - (enetc_si_is_pf(priv->si) ? |
| 27 | - ARRAY_SIZE(enetc_port_counters) : 0); |
| 28 | + if (sset != ETH_SS_STATS) |
| 29 | + return -EOPNOTSUPP; |
| 30 | |
| 31 | - return -EOPNOTSUPP; |
| 32 | + len = ARRAY_SIZE(enetc_si_counters) + |
| 33 | + ARRAY_SIZE(tx_ring_stats) * priv->num_tx_rings + |
| 34 | + ARRAY_SIZE(rx_ring_stats) * priv->num_rx_rings; |
| 35 | + |
| 36 | + if (!enetc_si_is_pf(priv->si)) |
| 37 | + return len; |
| 38 | + |
| 39 | + len += ARRAY_SIZE(enetc_port_counters); |
| 40 | + |
| 41 | + return len; |
| 42 | } |
| 43 | |
| 44 | static void enetc_get_strings(struct net_device *ndev, u32 stringset, u8 *data) |