Skip to content

Commit 64430f7

Browse files
jjagielskanguy11
authored andcommitted
iavf: Fix displaying queue statistics shown by ethtool
Driver provided too many lines as an output to ethtool -S command. Return actual length of string set of ethtool stats. Instead of predefined maximal value use the actual value on netdev, iterate over active queues. Without this patch, ethtool -S report would produce additional erroneous lines of queues that are not configured. Signed-off-by: Witold Fijalkowski <[email protected]> Signed-off-by: Przemyslaw Patynowski <[email protected]> Signed-off-by: Mateusz Palczewski <[email protected]> Signed-off-by: Jedrzej Jagielski <[email protected]> Tested-by: Konrad Jankowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent c2fbcc9 commit 64430f7

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

drivers/net/ethernet/intel/iavf/iavf_ethtool.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,16 @@ static int iavf_get_link_ksettings(struct net_device *netdev,
331331
**/
332332
static int iavf_get_sset_count(struct net_device *netdev, int sset)
333333
{
334+
/* Report the maximum number queues, even if not every queue is
335+
* currently configured. Since allocation of queues is in pairs,
336+
* use netdev->real_num_tx_queues * 2. The real_num_tx_queues is set
337+
* at device creation and never changes.
338+
*/
339+
334340
if (sset == ETH_SS_STATS)
335341
return IAVF_STATS_LEN +
336-
(IAVF_QUEUE_STATS_LEN * 2 * IAVF_MAX_REQ_QUEUES);
342+
(IAVF_QUEUE_STATS_LEN * 2 *
343+
netdev->real_num_tx_queues);
337344
else if (sset == ETH_SS_PRIV_FLAGS)
338345
return IAVF_PRIV_FLAGS_STR_LEN;
339346
else
@@ -360,17 +367,18 @@ static void iavf_get_ethtool_stats(struct net_device *netdev,
360367
iavf_add_ethtool_stats(&data, adapter, iavf_gstrings_stats);
361368

362369
rcu_read_lock();
363-
for (i = 0; i < IAVF_MAX_REQ_QUEUES; i++) {
370+
/* As num_active_queues describe both tx and rx queues, we can use
371+
* it to iterate over rings' stats.
372+
*/
373+
for (i = 0; i < adapter->num_active_queues; i++) {
364374
struct iavf_ring *ring;
365375

366-
/* Avoid accessing un-allocated queues */
367-
ring = (i < adapter->num_active_queues ?
368-
&adapter->tx_rings[i] : NULL);
376+
/* Tx rings stats */
377+
ring = &adapter->tx_rings[i];
369378
iavf_add_queue_stats(&data, ring);
370379

371-
/* Avoid accessing un-allocated queues */
372-
ring = (i < adapter->num_active_queues ?
373-
&adapter->rx_rings[i] : NULL);
380+
/* Rx rings stats */
381+
ring = &adapter->rx_rings[i];
374382
iavf_add_queue_stats(&data, ring);
375383
}
376384
rcu_read_unlock();
@@ -407,10 +415,10 @@ static void iavf_get_stat_strings(struct net_device *netdev, u8 *data)
407415

408416
iavf_add_stat_strings(&data, iavf_gstrings_stats);
409417

410-
/* Queues are always allocated in pairs, so we just use num_tx_queues
411-
* for both Tx and Rx queues.
418+
/* Queues are always allocated in pairs, so we just use
419+
* real_num_tx_queues for both Tx and Rx queues.
412420
*/
413-
for (i = 0; i < netdev->num_tx_queues; i++) {
421+
for (i = 0; i < netdev->real_num_tx_queues; i++) {
414422
iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,
415423
"tx", i);
416424
iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,

0 commit comments

Comments
 (0)