From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.net, kuba@kernel.org
Cc: Jedrzej Jagielski <jedrzej.jagielski@intel.com>,
netdev@vger.kernel.org, anthony.l.nguyen@intel.com,
sassmann@redhat.com,
Witold Fijalkowski <witoldx.fijalkowski@intel.com>,
Przemyslaw Patynowski <przemyslawx.patynowski@intel.com>,
Mateusz Palczewski <mateusz.palczewski@intel.com>,
Konrad Jankowski <konrad0.jankowski@intel.com>
Subject: [PATCH net-next 12/12] iavf: Fix displaying queue statistics shown by ethtool
Date: Wed, 24 Nov 2021 09:16:52 -0800 [thread overview]
Message-ID: <20211124171652.831184-13-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20211124171652.831184-1-anthony.l.nguyen@intel.com>
From: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
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 <witoldx.fijalkowski@intel.com>
Signed-off-by: Przemyslaw Patynowski <przemyslawx.patynowski@intel.com>
Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
.../net/ethernet/intel/iavf/iavf_ethtool.c | 30 ++++++++++++-------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
index ddb3f9f1c58e..8db3e8b68bf1 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
@@ -331,9 +331,16 @@ static int iavf_get_link_ksettings(struct net_device *netdev,
**/
static int iavf_get_sset_count(struct net_device *netdev, int sset)
{
+ /* Report the maximum number queues, even if not every queue is
+ * currently configured. Since allocation of queues is in pairs,
+ * use netdev->real_num_tx_queues * 2. The real_num_tx_queues is set
+ * at device creation and never changes.
+ */
+
if (sset == ETH_SS_STATS)
return IAVF_STATS_LEN +
- (IAVF_QUEUE_STATS_LEN * 2 * IAVF_MAX_REQ_QUEUES);
+ (IAVF_QUEUE_STATS_LEN * 2 *
+ netdev->real_num_tx_queues);
else if (sset == ETH_SS_PRIV_FLAGS)
return IAVF_PRIV_FLAGS_STR_LEN;
else
@@ -357,17 +364,18 @@ static void iavf_get_ethtool_stats(struct net_device *netdev,
iavf_add_ethtool_stats(&data, adapter, iavf_gstrings_stats);
rcu_read_lock();
- for (i = 0; i < IAVF_MAX_REQ_QUEUES; i++) {
+ /* As num_active_queues describe both tx and rx queues, we can use
+ * it to iterate over rings' stats.
+ */
+ for (i = 0; i < adapter->num_active_queues; i++) {
struct iavf_ring *ring;
- /* Avoid accessing un-allocated queues */
- ring = (i < adapter->num_active_queues ?
- &adapter->tx_rings[i] : NULL);
+ /* Tx rings stats */
+ ring = &adapter->tx_rings[i];
iavf_add_queue_stats(&data, ring);
- /* Avoid accessing un-allocated queues */
- ring = (i < adapter->num_active_queues ?
- &adapter->rx_rings[i] : NULL);
+ /* Rx rings stats */
+ ring = &adapter->rx_rings[i];
iavf_add_queue_stats(&data, ring);
}
rcu_read_unlock();
@@ -404,10 +412,10 @@ static void iavf_get_stat_strings(struct net_device *netdev, u8 *data)
iavf_add_stat_strings(&data, iavf_gstrings_stats);
- /* Queues are always allocated in pairs, so we just use num_tx_queues
- * for both Tx and Rx queues.
+ /* Queues are always allocated in pairs, so we just use
+ * real_num_tx_queues for both Tx and Rx queues.
*/
- for (i = 0; i < netdev->num_tx_queues; i++) {
+ for (i = 0; i < netdev->real_num_tx_queues; i++) {
iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,
"tx", i);
iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,
--
2.31.1
next prev parent reply other threads:[~2021-11-24 17:25 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 17:16 [PATCH net-next 00/12][pull request] 40GbE Intel Wired LAN Driver Updates 2021-11-24 Tony Nguyen
2021-11-24 17:16 ` [PATCH net-next 01/12] iavf: restore MSI state on reset Tony Nguyen
2021-11-24 23:42 ` Jakub Kicinski
2021-11-29 18:41 ` Nguyen, Anthony L
2021-11-24 17:16 ` [PATCH net-next 02/12] iavf: Add change MTU message Tony Nguyen
2021-11-24 23:46 ` Jakub Kicinski
2021-11-29 18:43 ` Nguyen, Anthony L
2021-11-30 0:53 ` Jakub Kicinski
2021-11-24 17:16 ` [PATCH net-next 04/12] iavf: return errno code instead of status code Tony Nguyen
2021-11-24 17:16 ` [PATCH net-next 05/12] iavf: don't be so alarming Tony Nguyen
2021-11-25 6:45 ` Stefan Assmann
2021-11-29 18:44 ` Nguyen, Anthony L
2021-11-24 17:16 ` [PATCH net-next 06/12] iavf: Add trace while removing device Tony Nguyen
2021-11-24 23:48 ` Jakub Kicinski
2021-11-25 6:50 ` Stefan Assmann
2021-11-25 15:13 ` Jakub Kicinski
2021-11-25 15:43 ` Stefan Assmann
2021-11-25 15:57 ` Jakub Kicinski
2021-11-25 16:46 ` Stefan Assmann
2021-11-24 17:16 ` [PATCH net-next 07/12] iavf: Enable setting RSS hash key Tony Nguyen
2021-11-24 17:16 ` [PATCH net-next 08/12] iavf: Refactor iavf_mac_filter struct memory usage Tony Nguyen
2021-11-24 23:49 ` Jakub Kicinski
2021-11-26 10:13 ` Jagielski, Jedrzej
2021-11-24 17:16 ` [PATCH net-next 09/12] iavf: Fix static code analysis warning Tony Nguyen
2021-11-24 17:16 ` [PATCH net-next 10/12] iavf: Refactor text of informational message Tony Nguyen
2021-11-24 17:16 ` [PATCH net-next 11/12] iavf: Refactor string format to avoid static analysis warnings Tony Nguyen
2021-11-24 17:16 ` Tony Nguyen [this message]
2021-11-24 23:42 ` [PATCH net-next 00/12][pull request] 40GbE Intel Wired LAN Driver Updates 2021-11-24 Jakub Kicinski
2021-11-29 18:46 ` Nguyen, Anthony L
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211124171652.831184-13-anthony.l.nguyen@intel.com \
--to=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=jedrzej.jagielski@intel.com \
--cc=konrad0.jankowski@intel.com \
--cc=kuba@kernel.org \
--cc=mateusz.palczewski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=przemyslawx.patynowski@intel.com \
--cc=sassmann@redhat.com \
--cc=witoldx.fijalkowski@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox