Skip to content

Commit 80f1241

Browse files
Amir TzinSaeed Mahameed
authored andcommitted
net/mlx5e: Fix VF representors reporting zero counters to "ip -s" command
Although vf_vport entry of struct mlx5e_stats is never updated, its values are mistakenly copied to the caller structure in the VF representor .ndo_get_stat_64 callback mlx5e_rep_get_stats(). Remove redundant entry and use the updated one, rep_stats, instead. Fixes: 64b68e3 ("net/mlx5: Refactor and expand rep vport stat group") Reviewed-by: Patrisious Haddad <[email protected]> Signed-off-by: Amir Tzin <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 06b4eac commit 80f1241

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ mlx5e_rep_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
701701

702702
/* update HW stats in background for next time */
703703
mlx5e_queue_update_stats(priv);
704-
memcpy(stats, &priv->stats.vf_vport, sizeof(*stats));
704+
mlx5e_stats_copy_rep_stats(stats, &priv->stats.rep_stats);
705705
}
706706

707707
static int mlx5e_rep_change_mtu(struct net_device *netdev, int new_mtu)

drivers/net/ethernet/mellanox/mlx5/core/en_stats.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,20 @@ struct mlx5e_stats {
484484
struct mlx5e_vnic_env_stats vnic;
485485
struct mlx5e_vport_stats vport;
486486
struct mlx5e_pport_stats pport;
487-
struct rtnl_link_stats64 vf_vport;
488487
struct mlx5e_pcie_stats pcie;
489488
struct mlx5e_rep_stats rep_stats;
490489
};
491490

491+
static inline void mlx5e_stats_copy_rep_stats(struct rtnl_link_stats64 *vf_vport,
492+
struct mlx5e_rep_stats *rep_stats)
493+
{
494+
memset(vf_vport, 0, sizeof(*vf_vport));
495+
vf_vport->rx_packets = rep_stats->vport_rx_packets;
496+
vf_vport->tx_packets = rep_stats->vport_tx_packets;
497+
vf_vport->rx_bytes = rep_stats->vport_rx_bytes;
498+
vf_vport->tx_bytes = rep_stats->vport_tx_bytes;
499+
}
500+
492501
extern mlx5e_stats_grp_t mlx5e_nic_stats_grps[];
493502
unsigned int mlx5e_nic_stats_grps_num(struct mlx5e_priv *priv);
494503

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4972,7 +4972,8 @@ static int scan_tc_matchall_fdb_actions(struct mlx5e_priv *priv,
49724972
if (err)
49734973
return err;
49744974

4975-
rpriv->prev_vf_vport_stats = priv->stats.vf_vport;
4975+
mlx5e_stats_copy_rep_stats(&rpriv->prev_vf_vport_stats,
4976+
&priv->stats.rep_stats);
49764977
break;
49774978
default:
49784979
NL_SET_ERR_MSG_MOD(extack, "mlx5 supports only police action for matchall");
@@ -5012,7 +5013,7 @@ void mlx5e_tc_stats_matchall(struct mlx5e_priv *priv,
50125013
u64 dbytes;
50135014
u64 dpkts;
50145015

5015-
cur_stats = priv->stats.vf_vport;
5016+
mlx5e_stats_copy_rep_stats(&cur_stats, &priv->stats.rep_stats);
50165017
dpkts = cur_stats.rx_packets - rpriv->prev_vf_vport_stats.rx_packets;
50175018
dbytes = cur_stats.rx_bytes - rpriv->prev_vf_vport_stats.rx_bytes;
50185019
rpriv->prev_vf_vport_stats = cur_stats;

0 commit comments

Comments
 (0)