Netdev List
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.duyck@gmail.com>
To: davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
	simon.horman@netronome.com, yisen.zhuang@huawei.com,
	salil.mehta@huawei.com, intel-wired-lan@lists.osuosl.org,
	jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com,
	drivers@pensando.io, snelson@pensando.io, netanel@amazon.com,
	akiyano@amazon.com, gtzalik@amazon.com, saeedb@amazon.com,
	GR-Linux-NIC-Dev@marvell.com, skalluru@marvell.com,
	rmody@marvell.com, kys@microsoft.com, haiyangz@microsoft.com,
	sthemmin@microsoft.com, wei.liu@kernel.org, mst@redhat.com,
	jasowang@redhat.com, pv-drivers@vmware.com, doshir@vmware.com,
	alexanderduyck@fb.com, Kernel-team@fb.com
Subject: [net-next PATCH 08/10] vmxnet3: Update driver to use ethtool_sprintf
Date: Fri, 12 Mar 2021 09:48:52 -0800	[thread overview]
Message-ID: <161557133283.10304.4658224540485154078.stgit@localhost.localdomain> (raw)
In-Reply-To: <161557111604.10304.1798900949114188676.stgit@localhost.localdomain>

From: Alexander Duyck <alexanderduyck@fb.com>

So this patch actually does 3 things.

First it removes a stray white space at the start of the variable
declaration in vmxnet3_get_strings.

Second it flips the logic for the string test so that we exit immediately
if we are not looking for the stats strings. Doing this we can avoid
unnecessary indentation and line wrapping.

Then finally it updates the code to use ethtool_sprintf rather than a
memcpy and pointer increment to write the ethtool strings.

Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
---
 drivers/net/vmxnet3/vmxnet3_ethtool.c |   53 ++++++++++++---------------------
 1 file changed, 19 insertions(+), 34 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index 7ec8652f2c26..c0bd9cbc43b1 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -218,43 +218,28 @@ vmxnet3_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
 static void
 vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf)
 {
-	 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
-	if (stringset == ETH_SS_STATS) {
-		int i, j;
-		for (j = 0; j < adapter->num_tx_queues; j++) {
-			for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) {
-				memcpy(buf, vmxnet3_tq_dev_stats[i].desc,
-				       ETH_GSTRING_LEN);
-				buf += ETH_GSTRING_LEN;
-			}
-			for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats);
-			     i++) {
-				memcpy(buf, vmxnet3_tq_driver_stats[i].desc,
-				       ETH_GSTRING_LEN);
-				buf += ETH_GSTRING_LEN;
-			}
-		}
+	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
+	int i, j;
 
-		for (j = 0; j < adapter->num_rx_queues; j++) {
-			for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) {
-				memcpy(buf, vmxnet3_rq_dev_stats[i].desc,
-				       ETH_GSTRING_LEN);
-				buf += ETH_GSTRING_LEN;
-			}
-			for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats);
-			     i++) {
-				memcpy(buf, vmxnet3_rq_driver_stats[i].desc,
-				       ETH_GSTRING_LEN);
-				buf += ETH_GSTRING_LEN;
-			}
-		}
+	if (stringset != ETH_SS_STATS)
+		return;
 
-		for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) {
-			memcpy(buf, vmxnet3_global_stats[i].desc,
-				ETH_GSTRING_LEN);
-			buf += ETH_GSTRING_LEN;
-		}
+	for (j = 0; j < adapter->num_tx_queues; j++) {
+		for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++)
+			ethtool_sprintf(&buf, vmxnet3_tq_dev_stats[i].desc);
+		for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++)
+			ethtool_sprintf(&buf, vmxnet3_tq_driver_stats[i].desc);
+	}
+
+	for (j = 0; j < adapter->num_rx_queues; j++) {
+		for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++)
+			ethtool_sprintf(&buf, vmxnet3_rq_dev_stats[i].desc);
+		for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++)
+			ethtool_sprintf(&buf, vmxnet3_rq_driver_stats[i].desc);
 	}
+
+	for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++)
+		ethtool_sprintf(&buf, vmxnet3_global_stats[i].desc);
 }
 
 netdev_features_t vmxnet3_fix_features(struct net_device *netdev,



  parent reply	other threads:[~2021-03-12 17:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12 17:48 [net-next PATCH 00/10] ethtool: Factor out common code related to writing ethtool strings Alexander Duyck
2021-03-12 17:48 ` [net-next PATCH 01/10] ethtool: Add common function for filling out strings Alexander Duyck
2021-03-12 17:48 ` [net-next PATCH 02/10] intel: Update drivers to use ethtool_sprintf Alexander Duyck
2021-03-16  6:56   ` [Intel-wired-lan] " Wang, Haiyue
2021-03-12 17:48 ` [net-next PATCH 03/10] nfp: Replace nfp_pr_et with ethtool_sprintf Alexander Duyck
2021-03-12 17:48 ` [net-next PATCH 04/10] hisilicon: Update drivers to use ethtool_sprintf Alexander Duyck
2021-03-12 17:48 ` [net-next PATCH 05/10] ena: Update driver " Alexander Duyck
2021-03-14  8:30   ` Kiyanovski, Arthur
2021-03-12 17:48 ` [net-next PATCH 06/10] netvsc: " Alexander Duyck
2021-03-12 17:48 ` [net-next PATCH 07/10] virtio_net: " Alexander Duyck
2021-03-14  8:56   ` Michael S. Tsirkin
2021-03-15  3:52   ` Jason Wang
2021-03-12 17:48 ` Alexander Duyck [this message]
2021-03-12 17:48 ` [net-next PATCH 09/10] bna: " Alexander Duyck
2021-03-12 17:49 ` [net-next PATCH 10/10] ionic: " Alexander Duyck

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=161557133283.10304.4658224540485154078.stgit@localhost.localdomain \
    --to=alexander.duyck@gmail.com \
    --cc=GR-Linux-NIC-Dev@marvell.com \
    --cc=Kernel-team@fb.com \
    --cc=akiyano@amazon.com \
    --cc=alexanderduyck@fb.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=doshir@vmware.com \
    --cc=drivers@pensando.io \
    --cc=gtzalik@amazon.com \
    --cc=haiyangz@microsoft.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jasowang@redhat.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=kuba@kernel.org \
    --cc=kys@microsoft.com \
    --cc=mst@redhat.com \
    --cc=netanel@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    --cc=pv-drivers@vmware.com \
    --cc=rmody@marvell.com \
    --cc=saeedb@amazon.com \
    --cc=salil.mehta@huawei.com \
    --cc=simon.horman@netronome.com \
    --cc=skalluru@marvell.com \
    --cc=snelson@pensando.io \
    --cc=sthemmin@microsoft.com \
    --cc=wei.liu@kernel.org \
    --cc=yisen.zhuang@huawei.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