Skip to contentSkip to conversation

net: mellanox: use ethtool string helpers

PATCH Superseded Rosen Penev 2 participants 2 messages Nov 12, 2024 – Nov 13, 2024

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 net: mellanox: use ethtool string helpers

These are the preferred way to copy ethtool strings.

Avoids incrementing pointers all over the place.

---
v3: also convert memcpy.
v2: rebase to make it apply.

 .../mellanox/mlxbf_gige/mlxbf_gige_ethtool.c  |  5 +-
 .../mellanox/mlxsw/spectrum_ethtool.c         | 83 +++++++------------
 .../ethernet/mellanox/mlxsw/spectrum_ptp.c    |  7 +-
 3 files changed, 33 insertions(+), 62 deletions(-)
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_ethtool.c +3 -2
index 8b63968bbee9..a430d35d4727 100644
@@ -74,8 +74,9 @@ static void mlxbf_gige_get_strings(struct net_device *netdev, u32 stringset,
 {
 	if (stringset != ETH_SS_STATS)
 		return;
-	memcpy(buf, &mlxbf_gige_ethtool_stats_keys,
-	       sizeof(mlxbf_gige_ethtool_stats_keys));
+
+	for (int i = 0; i < ARRAY_SIZE(mlxbf_gige_ethtool_stats_keys); i++)
+		ethtool_puts(&buf, mlxbf_gige_ethtool_stats_keys[i].string);
 }
 
 static void mlxbf_gige_get_ethtool_stats(struct net_device *netdev,
drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c +28 -55

112 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +2 -5
index d94081c7658e..a8c0b84ffc28 100644
@@ -1327,11 +1327,8 @@ void mlxsw_sp1_get_stats_strings(u8 **p)
 {
 	int i;
 
-	for (i = 0; i < MLXSW_SP_PTP_PORT_STATS_LEN; i++) {
-		memcpy(*p, mlxsw_sp_ptp_port_stats[i].str,
-		       ETH_GSTRING_LEN);
-		*p += ETH_GSTRING_LEN;
-	}
+	for (i = 0; i < MLXSW_SP_PTP_PORT_STATS_LEN; i++)
+		ethtool_puts(p, mlxsw_sp_ptp_port_stats[i].str);
 }
 
 void mlxsw_sp1_get_stats(struct mlxsw_sp_port *mlxsw_sp_port,
Signature · 1 line
2.47.0
maintainer
#1 lore raw

Thanks for the patch, but there are a few process issues.

Quoted 6 lines · Rosen Penev

These are the preferred way to copy ethtool strings.

Avoids incrementing pointers all over the place.

I only tagged the mlxsw change. The mlxbf change is new.

Quoted 4 lines

---
v3: also convert memcpy.
v2: rebase to make it apply.

 .../mellanox/mlxbf_gige/mlxbf_gige_ethtool.c  |  5 +-

Please split the mlxbf change to a different patch and copy the relevant maintainers:

[email protected]
[email protected]

Use "mlxbf_gige:" prefix for the mlxbf patch and "mlxsw:" for the mlxsw patch. You can keep my tag on the latter.

Quoted 3 lines
 .../mellanox/mlxsw/spectrum_ethtool.c         | 83 +++++++------------
 .../ethernet/mellanox/mlxsw/spectrum_ptp.c    |  7 +-
 3 files changed, 33 insertions(+), 62 deletions(-)