[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241108204154.305560-1-rosenp@gmail.com>
Date: Fri, 8 Nov 2024 12:41:54 -0800
From: Rosen Penev <rosenp@...il.com>
To: netdev@...r.kernel.org
Cc: Louis Peens <louis.peens@...igine.com>,
Jakub Kicinski <kuba@...nel.org>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>,
oss-drivers@...igine.com (open list:NETRONOME ETHERNET DRIVERS),
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH] 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.
Signed-off-by: Rosen Penev <rosenp@...il.com>
---
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(-)
diff --git a/drivers/net/ethernet/netronome/nfp/abm/main.c b/drivers/net/ethernet/netronome/nfp/abm/main.c
index 5d3df28c648f..ee6dbe4f8c42 100644
--- a/drivers/net/ethernet/netronome/nfp/abm/main.c
+++ b/drivers/net/ethernet/netronome/nfp/abm/main.c
@@ -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)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_app.c b/drivers/net/ethernet/netronome/nfp/nfp_app.c
index bb3f46c74f77..294181c7ebad 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_app.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_app.c
@@ -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 *
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_app.h b/drivers/net/ethernet/netronome/nfp/nfp_app.h
index 90707346a4ef..fc4dbcc8c7e1 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_app.h
+++ b/drivers/net/ethernet/netronome/nfp/nfp_app.h
@@ -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);
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
index fbca8d0efd85..6dfaaca737e2 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
@@ -848,37 +848,35 @@ static unsigned int nfp_vnic_get_sw_stats_count(struct net_device *netdev)
NN_CTRL_PATH_STATS;
}
-static u8 *nfp_vnic_get_sw_stats_strings(struct net_device *netdev, u8 *data)
+static void nfp_vnic_get_sw_stats_strings(struct net_device *netdev, u8 **data)
{
struct nfp_net *nn = netdev_priv(netdev);
int i;
for (i = 0; i < nn->max_r_vecs; i++) {
- ethtool_sprintf(&data, "rvec_%u_rx_pkts", i);
- ethtool_sprintf(&data, "rvec_%u_tx_pkts", i);
- ethtool_sprintf(&data, "rvec_%u_tx_busy", i);
- }
-
- ethtool_puts(&data, "hw_rx_csum_ok");
- ethtool_puts(&data, "hw_rx_csum_inner_ok");
- ethtool_puts(&data, "hw_rx_csum_complete");
- ethtool_puts(&data, "hw_rx_csum_err");
- ethtool_puts(&data, "rx_replace_buf_alloc_fail");
- ethtool_puts(&data, "rx_tls_decrypted_packets");
- ethtool_puts(&data, "hw_tx_csum");
- ethtool_puts(&data, "hw_tx_inner_csum");
- ethtool_puts(&data, "tx_gather");
- ethtool_puts(&data, "tx_lso");
- ethtool_puts(&data, "tx_tls_encrypted_packets");
- ethtool_puts(&data, "tx_tls_ooo");
- ethtool_puts(&data, "tx_tls_drop_no_sync_data");
-
- ethtool_puts(&data, "hw_tls_no_space");
- ethtool_puts(&data, "rx_tls_resync_req_ok");
- ethtool_puts(&data, "rx_tls_resync_req_ign");
- ethtool_puts(&data, "rx_tls_resync_sent");
-
- return data;
+ ethtool_sprintf(data, "rvec_%u_rx_pkts", i);
+ ethtool_sprintf(data, "rvec_%u_tx_pkts", i);
+ ethtool_sprintf(data, "rvec_%u_tx_busy", i);
+ }
+
+ ethtool_puts(data, "hw_rx_csum_ok");
+ ethtool_puts(data, "hw_rx_csum_inner_ok");
+ ethtool_puts(data, "hw_rx_csum_complete");
+ ethtool_puts(data, "hw_rx_csum_err");
+ ethtool_puts(data, "rx_replace_buf_alloc_fail");
+ ethtool_puts(data, "rx_tls_decrypted_packets");
+ ethtool_puts(data, "hw_tx_csum");
+ ethtool_puts(data, "hw_tx_inner_csum");
+ ethtool_puts(data, "tx_gather");
+ ethtool_puts(data, "tx_lso");
+ ethtool_puts(data, "tx_tls_encrypted_packets");
+ ethtool_puts(data, "tx_tls_ooo");
+ ethtool_puts(data, "tx_tls_drop_no_sync_data");
+
+ ethtool_puts(data, "hw_tls_no_space");
+ ethtool_puts(data, "rx_tls_resync_req_ok");
+ ethtool_puts(data, "rx_tls_resync_req_ign");
+ ethtool_puts(data, "rx_tls_resync_sent");
}
static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data)
@@ -937,8 +935,8 @@ static unsigned int nfp_vnic_get_hw_stats_count(unsigned int num_vecs)
return NN_ET_GLOBAL_STATS_LEN + num_vecs * 4;
}
-static u8 *
-nfp_vnic_get_hw_stats_strings(u8 *data, unsigned int num_vecs, bool repr)
+static void nfp_vnic_get_hw_stats_strings(u8 **data, unsigned int num_vecs,
+ bool repr)
{
int swap_off, i;
@@ -950,22 +948,20 @@ nfp_vnic_get_hw_stats_strings(u8 *data, unsigned int num_vecs, bool repr)
swap_off = repr * NN_ET_SWITCH_STATS_LEN;
for (i = 0; i < NN_ET_SWITCH_STATS_LEN; i++)
- ethtool_puts(&data, nfp_net_et_stats[i + swap_off].name);
+ ethtool_puts(data, nfp_net_et_stats[i + swap_off].name);
for (i = NN_ET_SWITCH_STATS_LEN; i < NN_ET_SWITCH_STATS_LEN * 2; i++)
- ethtool_puts(&data, nfp_net_et_stats[i - swap_off].name);
+ ethtool_puts(data, nfp_net_et_stats[i - swap_off].name);
for (i = NN_ET_SWITCH_STATS_LEN * 2; i < NN_ET_GLOBAL_STATS_LEN; i++)
- ethtool_puts(&data, nfp_net_et_stats[i].name);
+ ethtool_puts(data, nfp_net_et_stats[i].name);
for (i = 0; i < num_vecs; i++) {
- ethtool_sprintf(&data, "rxq_%u_pkts", i);
- ethtool_sprintf(&data, "rxq_%u_bytes", i);
- ethtool_sprintf(&data, "txq_%u_pkts", i);
- ethtool_sprintf(&data, "txq_%u_bytes", i);
+ ethtool_sprintf(data, "rxq_%u_pkts", i);
+ ethtool_sprintf(data, "rxq_%u_bytes", i);
+ ethtool_sprintf(data, "txq_%u_pkts", i);
+ ethtool_sprintf(data, "txq_%u_bytes", i);
}
-
- return data;
}
static u64 *
@@ -991,7 +987,7 @@ static unsigned int nfp_vnic_get_tlv_stats_count(struct nfp_net *nn)
return nn->tlv_caps.vnic_stats_cnt + nn->max_r_vecs * 4;
}
-static u8 *nfp_vnic_get_tlv_stats_strings(struct nfp_net *nn, u8 *data)
+static void nfp_vnic_get_tlv_stats_strings(struct nfp_net *nn, u8 **data)
{
unsigned int i, id;
u8 __iomem *mem;
@@ -1006,22 +1002,18 @@ static u8 *nfp_vnic_get_tlv_stats_strings(struct nfp_net *nn, u8 *data)
id_word >>= 16;
if (id < ARRAY_SIZE(nfp_tlv_stat_names) &&
- nfp_tlv_stat_names[id][0]) {
- memcpy(data, nfp_tlv_stat_names[id], ETH_GSTRING_LEN);
- data += ETH_GSTRING_LEN;
- } else {
- ethtool_sprintf(&data, "dev_unknown_stat%u", id);
- }
+ nfp_tlv_stat_names[id][0])
+ ethtool_puts(data, nfp_tlv_stat_names[id]);
+ else
+ ethtool_sprintf(data, "dev_unknown_stat%u", id);
}
for (i = 0; i < nn->max_r_vecs; i++) {
- ethtool_sprintf(&data, "rxq_%u_pkts", i);
- ethtool_sprintf(&data, "rxq_%u_bytes", i);
- ethtool_sprintf(&data, "txq_%u_pkts", i);
- ethtool_sprintf(&data, "txq_%u_bytes", i);
+ ethtool_sprintf(data, "rxq_%u_pkts", i);
+ ethtool_sprintf(data, "rxq_%u_bytes", i);
+ ethtool_sprintf(data, "txq_%u_pkts", i);
+ ethtool_sprintf(data, "txq_%u_bytes", i);
}
-
- return data;
}
static u64 *nfp_vnic_get_tlv_stats(struct nfp_net *nn, u64 *data)
@@ -1056,19 +1048,17 @@ static unsigned int nfp_mac_get_stats_count(struct net_device *netdev)
return ARRAY_SIZE(nfp_mac_et_stats);
}
-static u8 *nfp_mac_get_stats_strings(struct net_device *netdev, u8 *data)
+static void nfp_mac_get_stats_strings(struct net_device *netdev, u8 **data)
{
struct nfp_port *port;
unsigned int i;
port = nfp_port_from_netdev(netdev);
if (!__nfp_port_get_eth_port(port) || !port->eth_stats)
- return data;
+ return;
for (i = 0; i < ARRAY_SIZE(nfp_mac_et_stats); i++)
- ethtool_sprintf(&data, "mac.%s", nfp_mac_et_stats[i].name);
-
- return data;
+ ethtool_sprintf(data, "mac.%s", nfp_mac_et_stats[i].name);
}
static u64 *nfp_mac_get_stats(struct net_device *netdev, u64 *data)
@@ -1093,15 +1083,14 @@ static void nfp_net_get_strings(struct net_device *netdev,
switch (stringset) {
case ETH_SS_STATS:
- data = nfp_vnic_get_sw_stats_strings(netdev, data);
+ nfp_vnic_get_sw_stats_strings(netdev, &data);
if (!nn->tlv_caps.vnic_stats_off)
- data = nfp_vnic_get_hw_stats_strings(data,
- nn->max_r_vecs,
- false);
+ nfp_vnic_get_hw_stats_strings(&data, nn->max_r_vecs,
+ false);
else
- data = nfp_vnic_get_tlv_stats_strings(nn, data);
- data = nfp_mac_get_stats_strings(netdev, data);
- data = nfp_app_port_get_stats_strings(nn->port, data);
+ nfp_vnic_get_tlv_stats_strings(nn, &data);
+ nfp_mac_get_stats_strings(netdev, &data);
+ nfp_app_port_get_stats_strings(nn->port, &data);
break;
case ETH_SS_TEST:
nfp_get_self_test_strings(netdev, data);
@@ -1155,10 +1144,10 @@ static void nfp_port_get_strings(struct net_device *netdev,
switch (stringset) {
case ETH_SS_STATS:
if (nfp_port_is_vnic(port))
- data = nfp_vnic_get_hw_stats_strings(data, 0, true);
+ nfp_vnic_get_hw_stats_strings(&data, 0, true);
else
- data = nfp_mac_get_stats_strings(netdev, data);
- data = nfp_app_port_get_stats_strings(port, data);
+ nfp_mac_get_stats_strings(netdev, &data);
+ nfp_app_port_get_stats_strings(port, &data);
break;
case ETH_SS_TEST:
nfp_get_self_test_strings(netdev, data);
--
2.47.0
Powered by blists - more mailing lists