Skip to contentSkip to conversation

net: netronome: use double ptr for gstrings

PATCH In review Rosen Penev 2 participants 2 messages Nov 8, 2024 – Nov 9, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: netronome: use double ptr for gstrings

Currently the code copies a pointer and propagates increments that way.

Instead of doing that, increment with a double pointer, which the ethtool string helpers expect.

Also converted some memcpy calls to ethtool_puts, as they should be.

---
 drivers/net/ethernet/netronome/nfp/abm/main.c |  12 +-
 drivers/net/ethernet/netronome/nfp/nfp_app.c  |   6 +-
 drivers/net/ethernet/netronome/nfp/nfp_app.h  |   6 +-
 .../ethernet/netronome/nfp/nfp_net_ethtool.c  | 119 ++++++++----------
 4 files changed, 65 insertions(+), 78 deletions(-)
drivers/net/ethernet/netronome/nfp/abm/main.c +5 -7
index 5d3df28c648f..ee6dbe4f8c42 100644
@@ -407,22 +407,20 @@ nfp_abm_port_get_stats_count(struct nfp_app *app, struct nfp_port *port)
 	return alink->vnic->dp.num_r_vecs * 2;
 }
 
-static u8 *
-nfp_abm_port_get_stats_strings(struct nfp_app *app, struct nfp_port *port,
-			       u8 *data)
+static void nfp_abm_port_get_stats_strings(struct nfp_app *app,
+					   struct nfp_port *port, u8 **data)
 {
 	struct nfp_repr *repr = netdev_priv(port->netdev);
 	struct nfp_abm_link *alink;
 	unsigned int i;
 
 	if (port->type != NFP_PORT_PF_PORT)
-		return data;
+		return;
 	alink = repr->app_priv;
 	for (i = 0; i < alink->vnic->dp.num_r_vecs; i++) {
-		ethtool_sprintf(&data, "q%u_no_wait", i);
-		ethtool_sprintf(&data, "q%u_delayed", i);
+		ethtool_sprintf(data, "q%u_no_wait", i);
+		ethtool_sprintf(data, "q%u_delayed", i);
 	}
-	return data;
 }
 
 static int nfp_abm_fw_init_reset(struct nfp_abm *abm)
drivers/net/ethernet/netronome/nfp/nfp_app.c +3 -3
index bb3f46c74f77..294181c7ebad 100644
@@ -92,11 +92,11 @@ int nfp_app_port_get_stats_count(struct nfp_port *port)
 	return port->app->type->port_get_stats_count(port->app, port);
 }
 
-u8 *nfp_app_port_get_stats_strings(struct nfp_port *port, u8 *data)
+void nfp_app_port_get_stats_strings(struct nfp_port *port, u8 **data)
 {
 	if (!port || !port->app || !port->app->type->port_get_stats_strings)
-		return data;
-	return port->app->type->port_get_stats_strings(port->app, port, data);
+		return;
+	port->app->type->port_get_stats_strings(port->app, port, data);
 }
 
 struct sk_buff *
drivers/net/ethernet/netronome/nfp/nfp_app.h +3 -3
index 90707346a4ef..fc4dbcc8c7e1 100644
@@ -116,8 +116,8 @@ struct nfp_app_type {
 	u64 *(*port_get_stats)(struct nfp_app *app,
 			       struct nfp_port *port, u64 *data);
 	int (*port_get_stats_count)(struct nfp_app *app, struct nfp_port *port);
-	u8 *(*port_get_stats_strings)(struct nfp_app *app,
-				      struct nfp_port *port, u8 *data);
+	void (*port_get_stats_strings)(struct nfp_app *app,
+				       struct nfp_port *port, u8 **data);
 
 	int (*start)(struct nfp_app *app);
 	void (*stop)(struct nfp_app *app);
@@ -421,7 +421,7 @@ struct nfp_app *nfp_app_from_netdev(struct net_device *netdev);
 
 u64 *nfp_app_port_get_stats(struct nfp_port *port, u64 *data);
 int nfp_app_port_get_stats_count(struct nfp_port *port);
-u8 *nfp_app_port_get_stats_strings(struct nfp_port *port, u8 *data);
+void nfp_app_port_get_stats_strings(struct nfp_port *port, u8 **data);
 
 struct nfp_reprs *
 nfp_reprs_get_locked(struct nfp_app *app, enum nfp_repr_type type);
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +54 -65

194 lines not on this page · raw message

Signature · 1 line
2.47.0
maintainer
#1 lore raw
Quoted 6 lines · On Fri, 8 Nov 2024 12:41:54 -0800 Rosen Penev wrote:

Currently the code copies a pointer and propagates increments that way.

Instead of doing that, increment with a double pointer, which the ethtool string helpers expect.

Also converted some memcpy calls to ethtool_puts, as they should be.

Let's not "convert" a driver which already uses the ethtool_ print helpers. Replace the memcpy but leave the rest be, please.

Signature · 1 line
pw-bot: cr