Commit f26d0d25 authored by Eran Ben Elisha's avatar Eran Ben Elisha Committed by David S. Miller

net/mlx4_en: Add physical RX/TX bytes/packets counters

Add physical RX/TX packets/bytes counters into ethtool output to monitor
all traffic that was received and transmitted on the port. These
counters are available only for none Virtual Function.
Signed-off-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 431c7ec3
...@@ -199,6 +199,10 @@ static const char main_strings[][ETH_GSTRING_LEN] = { ...@@ -199,6 +199,10 @@ static const char main_strings[][ETH_GSTRING_LEN] = {
"rx_xdp_drop", "rx_xdp_drop",
"rx_xdp_tx", "rx_xdp_tx",
"rx_xdp_tx_full", "rx_xdp_tx_full",
/* phy statistics */
"rx_packets_phy", "rx_bytes_phy",
"tx_packets_phy", "tx_bytes_phy",
}; };
static const char mlx4_en_test_names[][ETH_GSTRING_LEN]= { static const char mlx4_en_test_names[][ETH_GSTRING_LEN]= {
...@@ -411,6 +415,10 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev, ...@@ -411,6 +415,10 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
if (bitmap_iterator_test(&it)) if (bitmap_iterator_test(&it))
data[index++] = ((unsigned long *)&priv->xdp_stats)[i]; data[index++] = ((unsigned long *)&priv->xdp_stats)[i];
for (i = 0; i < NUM_PHY_STATS; i++, bitmap_iterator_inc(&it))
if (bitmap_iterator_test(&it))
data[index++] = ((unsigned long *)&priv->phy_stats)[i];
for (i = 0; i < priv->tx_ring_num[TX]; i++) { for (i = 0; i < priv->tx_ring_num[TX]; i++) {
data[index++] = priv->tx_ring[TX][i]->packets; data[index++] = priv->tx_ring[TX][i]->packets;
data[index++] = priv->tx_ring[TX][i]->bytes; data[index++] = priv->tx_ring[TX][i]->bytes;
...@@ -490,6 +498,12 @@ static void mlx4_en_get_strings(struct net_device *dev, ...@@ -490,6 +498,12 @@ static void mlx4_en_get_strings(struct net_device *dev,
strcpy(data + (index++) * ETH_GSTRING_LEN, strcpy(data + (index++) * ETH_GSTRING_LEN,
main_strings[strings]); main_strings[strings]);
for (i = 0; i < NUM_PHY_STATS; i++, strings++,
bitmap_iterator_inc(&it))
if (bitmap_iterator_test(&it))
strcpy(data + (index++) * ETH_GSTRING_LEN,
main_strings[strings]);
for (i = 0; i < priv->tx_ring_num[TX]; i++) { for (i = 0; i < priv->tx_ring_num[TX]; i++) {
sprintf(data + (index++) * ETH_GSTRING_LEN, sprintf(data + (index++) * ETH_GSTRING_LEN,
"tx%d_packets", i); "tx%d_packets", i);
......
...@@ -3256,6 +3256,10 @@ void mlx4_en_set_stats_bitmap(struct mlx4_dev *dev, ...@@ -3256,6 +3256,10 @@ void mlx4_en_set_stats_bitmap(struct mlx4_dev *dev,
bitmap_set(stats_bitmap->bitmap, last_i, NUM_XDP_STATS); bitmap_set(stats_bitmap->bitmap, last_i, NUM_XDP_STATS);
last_i += NUM_XDP_STATS; last_i += NUM_XDP_STATS;
if (!mlx4_is_slave(dev))
bitmap_set(stats_bitmap->bitmap, last_i, NUM_PHY_STATS);
last_i += NUM_PHY_STATS;
} }
int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
......
...@@ -275,19 +275,31 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset) ...@@ -275,19 +275,31 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
priv->port_stats.xmit_more += READ_ONCE(ring->xmit_more); priv->port_stats.xmit_more += READ_ONCE(ring->xmit_more);
} }
if (mlx4_is_master(mdev->dev)) { if (!mlx4_is_slave(mdev->dev)) {
stats->rx_packets = en_stats_adder(&mlx4_en_stats->RTOT_prio_0, struct mlx4_en_phy_stats *p_stats = &priv->phy_stats;
p_stats->rx_packets_phy =
en_stats_adder(&mlx4_en_stats->RTOT_prio_0,
&mlx4_en_stats->RTOT_prio_1, &mlx4_en_stats->RTOT_prio_1,
NUM_PRIORITIES); NUM_PRIORITIES);
stats->tx_packets = en_stats_adder(&mlx4_en_stats->TTOT_prio_0, p_stats->tx_packets_phy =
en_stats_adder(&mlx4_en_stats->TTOT_prio_0,
&mlx4_en_stats->TTOT_prio_1, &mlx4_en_stats->TTOT_prio_1,
NUM_PRIORITIES); NUM_PRIORITIES);
stats->rx_bytes = en_stats_adder(&mlx4_en_stats->ROCT_prio_0, p_stats->rx_bytes_phy =
en_stats_adder(&mlx4_en_stats->ROCT_prio_0,
&mlx4_en_stats->ROCT_prio_1, &mlx4_en_stats->ROCT_prio_1,
NUM_PRIORITIES); NUM_PRIORITIES);
stats->tx_bytes = en_stats_adder(&mlx4_en_stats->TOCT_prio_0, p_stats->tx_bytes_phy =
en_stats_adder(&mlx4_en_stats->TOCT_prio_0,
&mlx4_en_stats->TOCT_prio_1, &mlx4_en_stats->TOCT_prio_1,
NUM_PRIORITIES); NUM_PRIORITIES);
if (mlx4_is_master(mdev->dev)) {
stats->rx_packets = p_stats->rx_packets_phy;
stats->tx_packets = p_stats->tx_packets_phy;
stats->rx_bytes = p_stats->rx_bytes_phy;
stats->tx_bytes = p_stats->tx_bytes_phy;
}
} }
/* net device stats */ /* net device stats */
......
...@@ -608,6 +608,7 @@ struct mlx4_en_priv { ...@@ -608,6 +608,7 @@ struct mlx4_en_priv {
struct mlx4_en_flow_stats_tx tx_flowstats; struct mlx4_en_flow_stats_tx tx_flowstats;
struct mlx4_en_port_stats port_stats; struct mlx4_en_port_stats port_stats;
struct mlx4_en_xdp_stats xdp_stats; struct mlx4_en_xdp_stats xdp_stats;
struct mlx4_en_phy_stats phy_stats;
struct mlx4_en_stats_bitmap stats_bitmap; struct mlx4_en_stats_bitmap stats_bitmap;
struct list_head mc_list; struct list_head mc_list;
struct list_head curr_list; struct list_head curr_list;
......
...@@ -63,6 +63,14 @@ struct mlx4_en_xdp_stats { ...@@ -63,6 +63,14 @@ struct mlx4_en_xdp_stats {
#define NUM_XDP_STATS 3 #define NUM_XDP_STATS 3
}; };
struct mlx4_en_phy_stats {
unsigned long rx_packets_phy;
unsigned long rx_bytes_phy;
unsigned long tx_packets_phy;
unsigned long tx_bytes_phy;
#define NUM_PHY_STATS 4
};
#define NUM_MAIN_STATS 21 #define NUM_MAIN_STATS 21
#define MLX4_NUM_PRIORITIES 8 #define MLX4_NUM_PRIORITIES 8
...@@ -116,7 +124,7 @@ enum { ...@@ -116,7 +124,7 @@ enum {
#define NUM_ALL_STATS (NUM_MAIN_STATS + NUM_PORT_STATS + NUM_PKT_STATS + \ #define NUM_ALL_STATS (NUM_MAIN_STATS + NUM_PORT_STATS + NUM_PKT_STATS + \
NUM_FLOW_STATS + NUM_PERF_STATS + NUM_PF_STATS + \ NUM_FLOW_STATS + NUM_PERF_STATS + NUM_PF_STATS + \
NUM_XDP_STATS) NUM_XDP_STATS + NUM_PHY_STATS)
#define MLX4_FIND_NETDEV_STAT(n) (offsetof(struct net_device_stats, n) / \ #define MLX4_FIND_NETDEV_STAT(n) (offsetof(struct net_device_stats, n) / \
sizeof(((struct net_device_stats *)0)->n)) sizeof(((struct net_device_stats *)0)->n))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment