Re: [PATCH net-next] net: mellanox: use ethtool string helpers
From: Ido Schimmel
Date: Wed Oct 30 2024 - 09:29:26 EST
Wasn't able to apply the patch. Seems to be corrupted. See below.
On Tue, Oct 29, 2024 at 04:54:22PM -0700, Rosen Penev wrote:
[...]
> static void mlxsw_sp_port_get_strings(struct net_device *dev,
> u32 stringset, u8 *data)
> {
> struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
> - u8 *p = data;
> int i;
>
> - switch (stringset) {
> - case ETH_SS_STATS:
> - for (i = 0; i < MLXSW_SP_PORT_HW_STATS_LEN; i++) {
> - memcpy(p, mlxsw_sp_port_hw_stats[i].str,
> - ETH_GSTRING_LEN);
> - p += ETH_GSTRING_LEN;
> - }
> + if (stringset != ETH_SS_STATS)
> + return;
>
> - for (i = 0; i < MLXSW_SP_PORT_HW_RFC_2863_STATS_LEN; i++) {
> - memcpy(p, mlxsw_sp_port_hw_rfc_2863_stats[i].str,
> - ETH_GSTRING_LEN);
> - p += ETH_GSTRING_LEN;
> - }
> + for (i = 0; i < MLXSW_SP_PORT_HW_STATS_LEN; i++)
> + ethtool_puts(&data, mlxsw_sp_port_hw_stats[i].str);
>
> - for (i = 0; i < MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN; i++) {
> - memcpy(p, mlxsw_sp_port_hw_rfc_2819_stats[i].str,
> - ETH_GSTRING_LEN);
> - p += ETH_GSTRING_LEN;
> - }
> + for (i = 0; i < MLXSW_SP_PORT_HW_RFC_2863_STATS_LEN; i++)
> + ethtool_puts(&data, mlxsw_sp_port_hw_rfc_2863_stats[i].str);
>
> - for (i = 0; i < MLXSW_SP_PORT_HW_RFC_3635_STATS_LEN; i++) {
> - memcpy(p, mlxsw_sp_port_hw_rfc_3635_stats[i].str,
> - ETH_GSTRING_LEN);
> - p += ETH_GSTRING_LEN;
> - }
> + for (i = 0; i < MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN; i++)
> + ethtool_puts(&data, mlxsw_sp_port_hw_rfc_2819_stats[i].str);
>
> - for (i = 0; i < MLXSW_SP_PORT_HW_EXT_STATS_LEN; i++) {
> - memcpy(p, mlxsw_sp_port_hw_ext_stats[i].str,
> - ETH_GSTRING_LEN);
> - p += ETH_GSTRING_LEN;
> - }
> + for (i = 0; i < MLXSW_SP_PORT_HW_RFC_3635_STATS_LEN; i++)
> + ethtool_puts(&data, mlxsw_sp_port_hw_rfc_3635_stats[i].str);
>
> - for (i = 0; i < MLXSW_SP_PORT_HW_DISCARD_STATS_LEN; i++) {
> - memcpy(p, mlxsw_sp_port_hw_discard_stats[i].str,
> - ETH_GSTRING_LEN);
> - p += ETH_GSTRING_LEN;
> - }
> + for (i = 0; i < MLXSW_SP_PORT_HW_EXT_STATS_LEN; i++)
> + ethtool_puts(&data, mlxsw_sp_port_hw_ext_stats[i].str);
>
> - for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
> - mlxsw_sp_port_get_prio_strings(&data, i);
s/data/p/ in current code
> + for (i = 0; i < MLXSW_SP_PORT_HW_DISCARD_STATS_LEN; i++)
> + ethtool_puts(&data, mlxsw_sp_port_hw_discard_stats[i].str);
>
> - for (i = 0; i < TC_MAX_QUEUE; i++)
> - mlxsw_sp_port_get_tc_strings(&data, i);
Likewise
> + for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
> + mlxsw_sp_port_get_prio_strings(&data, i);
>
> - mlxsw_sp_port->mlxsw_sp->ptp_ops->get_stats_strings(&data);
Likewise
> + for (i = 0; i < TC_MAX_QUEUE; i++)
> + mlxsw_sp_port_get_tc_strings(&data, i);
>
> - for (i = 0; i < MLXSW_SP_PORT_HW_TRANSCEIVER_STATS_LEN; i++) {
> - memcpy(p, mlxsw_sp_port_transceiver_stats[i].str,
> - ETH_GSTRING_LEN);
> - p += ETH_GSTRING_LEN;
> - }
> - break;
> - }
> + mlxsw_sp_port->mlxsw_sp->ptp_ops->get_stats_strings(&data);
> +
> + for (i = 0; i < MLXSW_SP_PORT_HW_TRANSCEIVER_STATS_LEN; i++)
> + ethtool_puts(&data, mlxsw_sp_port_transceiver_stats[i].str);
> }