Skip to content

Commit

Permalink
mlx4: add pause frame stats
Browse files Browse the repository at this point in the history
Check if the pause stats are reported by HW by checking the bitmap.
Calculation is based on the order of strings in main_strings from
ethtool -S. Hopefully the semantics of these stats match the standard..

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed Sep 15, 2020
1 parent 098d9ed commit 12d342f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
19 changes: 19 additions & 0 deletions drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,24 @@ static int mlx4_en_set_pauseparam(struct net_device *dev,
return err;
}

static void mlx4_en_get_pause_stats(struct net_device *dev,
struct ethtool_pause_stats *stats)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct bitmap_iterator it;

bitmap_iterator_init(&it, priv->stats_bitmap.bitmap, NUM_ALL_STATS);

spin_lock_bh(&priv->stats_lock);
if (test_bit(FLOW_PRIORITY_STATS_IDX_TX_FRAMES,
priv->stats_bitmap.bitmap))
stats->tx_pause_frames = priv->tx_flowstats.tx_pause;
if (test_bit(FLOW_PRIORITY_STATS_IDX_RX_FRAMES,
priv->stats_bitmap.bitmap))
stats->rx_pause_frames = priv->rx_flowstats.rx_pause;
spin_unlock_bh(&priv->stats_lock);
}

static void mlx4_en_get_pauseparam(struct net_device *dev,
struct ethtool_pauseparam *pause)
{
Expand Down Expand Up @@ -2138,6 +2156,7 @@ const struct ethtool_ops mlx4_en_ethtool_ops = {
.set_msglevel = mlx4_en_set_msglevel,
.get_coalesce = mlx4_en_get_coalesce,
.set_coalesce = mlx4_en_set_coalesce,
.get_pause_stats = mlx4_en_get_pause_stats,
.get_pauseparam = mlx4_en_get_pauseparam,
.set_pauseparam = mlx4_en_set_pauseparam,
.get_ringparam = mlx4_en_get_ringparam,
Expand Down
12 changes: 12 additions & 0 deletions drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ struct mlx4_en_flow_stats_rx {
MLX4_NUM_PRIORITIES)
};

#define FLOW_PRIORITY_STATS_IDX_RX_FRAMES (NUM_MAIN_STATS + \
NUM_PORT_STATS + \
NUM_PF_STATS + \
NUM_FLOW_PRIORITY_STATS_RX)

struct mlx4_en_flow_stats_tx {
u64 tx_pause;
u64 tx_pause_duration;
Expand All @@ -93,6 +98,13 @@ struct mlx4_en_flow_stats_tx {
MLX4_NUM_PRIORITIES)
};

#define FLOW_PRIORITY_STATS_IDX_TX_FRAMES (NUM_MAIN_STATS + \
NUM_PORT_STATS + \
NUM_PF_STATS + \
NUM_FLOW_PRIORITY_STATS_RX + \
NUM_FLOW_STATS_RX + \
NUM_FLOW_PRIORITY_STATS_TX)

#define NUM_FLOW_STATS (NUM_FLOW_STATS_RX + NUM_FLOW_STATS_TX + \
NUM_FLOW_PRIORITY_STATS_TX + \
NUM_FLOW_PRIORITY_STATS_RX)
Expand Down

0 comments on commit 12d342f

Please sign in to comment.