Skip to content

Commit d6e9c89

Browse files
Shahed Shaikhdavem330
authored andcommitted
qlcnic: Fix ethtool statistics length calculation
o Consider number of Tx queues while calculating the length of Tx statistics as part of ethtool stats. o Calculate statistics lenght properly for 82xx and 83xx adapter Signed-off-by: Shahed Shaikh <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1ac6762 commit d6e9c89

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -167,27 +167,35 @@ static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = {
167167

168168
#define QLCNIC_TEST_LEN ARRAY_SIZE(qlcnic_gstrings_test)
169169

170-
static inline int qlcnic_82xx_statistics(void)
170+
static inline int qlcnic_82xx_statistics(struct qlcnic_adapter *adapter)
171171
{
172-
return ARRAY_SIZE(qlcnic_device_gstrings_stats) +
173-
ARRAY_SIZE(qlcnic_83xx_mac_stats_strings);
172+
return ARRAY_SIZE(qlcnic_gstrings_stats) +
173+
ARRAY_SIZE(qlcnic_83xx_mac_stats_strings) +
174+
QLCNIC_TX_STATS_LEN * adapter->drv_tx_rings;
174175
}
175176

176-
static inline int qlcnic_83xx_statistics(void)
177+
static inline int qlcnic_83xx_statistics(struct qlcnic_adapter *adapter)
177178
{
178-
return ARRAY_SIZE(qlcnic_83xx_tx_stats_strings) +
179+
return ARRAY_SIZE(qlcnic_gstrings_stats) +
180+
ARRAY_SIZE(qlcnic_83xx_tx_stats_strings) +
179181
ARRAY_SIZE(qlcnic_83xx_mac_stats_strings) +
180-
ARRAY_SIZE(qlcnic_83xx_rx_stats_strings);
182+
ARRAY_SIZE(qlcnic_83xx_rx_stats_strings) +
183+
QLCNIC_TX_STATS_LEN * adapter->drv_tx_rings;
181184
}
182185

183186
static int qlcnic_dev_statistics_len(struct qlcnic_adapter *adapter)
184187
{
185-
if (qlcnic_82xx_check(adapter))
186-
return qlcnic_82xx_statistics();
187-
else if (qlcnic_83xx_check(adapter))
188-
return qlcnic_83xx_statistics();
189-
else
190-
return -1;
188+
int len = -1;
189+
190+
if (qlcnic_82xx_check(adapter)) {
191+
len = qlcnic_82xx_statistics(adapter);
192+
if (adapter->flags & QLCNIC_ESWITCH_ENABLED)
193+
len += ARRAY_SIZE(qlcnic_device_gstrings_stats);
194+
} else if (qlcnic_83xx_check(adapter)) {
195+
len = qlcnic_83xx_statistics(adapter);
196+
}
197+
198+
return len;
191199
}
192200

193201
#define QLCNIC_TX_INTR_NOT_CONFIGURED 0X78563412
@@ -920,18 +928,13 @@ static int qlcnic_eeprom_test(struct net_device *dev)
920928

921929
static int qlcnic_get_sset_count(struct net_device *dev, int sset)
922930
{
923-
int len;
924931

925932
struct qlcnic_adapter *adapter = netdev_priv(dev);
926933
switch (sset) {
927934
case ETH_SS_TEST:
928935
return QLCNIC_TEST_LEN;
929936
case ETH_SS_STATS:
930-
len = qlcnic_dev_statistics_len(adapter) + QLCNIC_STATS_LEN;
931-
if ((adapter->flags & QLCNIC_ESWITCH_ENABLED) ||
932-
qlcnic_83xx_check(adapter))
933-
return len;
934-
return qlcnic_82xx_statistics();
937+
return qlcnic_dev_statistics_len(adapter);
935938
default:
936939
return -EOPNOTSUPP;
937940
}

0 commit comments

Comments
 (0)