Skip to content

Commit 47c97e6

Browse files
Ron DiskinSaeed Mahameed
authored andcommitted
net/mlx5e: Fix multicast counter not up-to-date in "ip -s"
Currently the FW does not generate events for counters other than error counters. Unlike ".get_ethtool_stats", ".ndo_get_stats64" (which ip -s uses) might run in atomic context, while the FW interface is non atomic. Thus, 'ip' is not allowed to issue FW commands, so it will only display cached counters in the driver. Add a SW counter (mcast_packets) in the driver to count rx multicast packets. The counter also counts broadcast packets, as we consider it a special case of multicast. Use the counter value when calling "ip -s"/"ifconfig". Fixes: f62b8bb ("net/mlx5: Extend mlx5_core to support ConnectX-4 Ethernet functionality") Signed-off-by: Ron Diskin <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Reviewed-by: Moshe Shemesh <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 82198d8 commit 47c97e6

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ enum mlx5e_icosq_wqe_type {
2020
};
2121

2222
/* General */
23+
static inline bool mlx5e_skb_is_multicast(struct sk_buff *skb)
24+
{
25+
return skb->pkt_type == PACKET_MULTICAST || skb->pkt_type == PACKET_BROADCAST;
26+
}
27+
2328
void mlx5e_trigger_irq(struct mlx5e_icosq *sq);
2429
void mlx5e_completion_event(struct mlx5_core_cq *mcq, struct mlx5_eqe *eqe);
2530
void mlx5e_cq_error_event(struct mlx5_core_cq *mcq, enum mlx5_event event);

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3569,6 +3569,7 @@ void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s)
35693569

35703570
s->rx_packets += rq_stats->packets + xskrq_stats->packets;
35713571
s->rx_bytes += rq_stats->bytes + xskrq_stats->bytes;
3572+
s->multicast += rq_stats->mcast_packets + xskrq_stats->mcast_packets;
35723573

35733574
for (j = 0; j < priv->max_opened_tc; j++) {
35743575
struct mlx5e_sq_stats *sq_stats = &channel_stats->sq[j];
@@ -3584,7 +3585,6 @@ void
35843585
mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
35853586
{
35863587
struct mlx5e_priv *priv = netdev_priv(dev);
3587-
struct mlx5e_vport_stats *vstats = &priv->stats.vport;
35883588
struct mlx5e_pport_stats *pstats = &priv->stats.pport;
35893589

35903590
/* In switchdev mode, monitor counters doesn't monitor
@@ -3619,12 +3619,6 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
36193619
stats->rx_errors = stats->rx_length_errors + stats->rx_crc_errors +
36203620
stats->rx_frame_errors;
36213621
stats->tx_errors = stats->tx_aborted_errors + stats->tx_carrier_errors;
3622-
3623-
/* vport multicast also counts packets that are dropped due to steering
3624-
* or rx out of buffer
3625-
*/
3626-
stats->multicast =
3627-
VPORT_COUNTER_GET(vstats, received_eth_multicast.packets);
36283622
}
36293623

36303624
static void mlx5e_set_rx_mode(struct net_device *dev)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include "en/xsk/rx.h"
5454
#include "en/health.h"
5555
#include "en/params.h"
56+
#include "en/txrx.h"
5657

5758
static struct sk_buff *
5859
mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
@@ -1080,6 +1081,9 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe,
10801081
mlx5e_enable_ecn(rq, skb);
10811082

10821083
skb->protocol = eth_type_trans(skb, netdev);
1084+
1085+
if (unlikely(mlx5e_skb_is_multicast(skb)))
1086+
stats->mcast_packets++;
10831087
}
10841088

10851089
static inline void mlx5e_complete_rx_cqe(struct mlx5e_rq *rq,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ struct mlx5e_sw_stats {
119119
u64 tx_nop;
120120
u64 rx_lro_packets;
121121
u64 rx_lro_bytes;
122+
u64 rx_mcast_packets;
122123
u64 rx_ecn_mark;
123124
u64 rx_removed_vlan_packets;
124125
u64 rx_csum_unnecessary;
@@ -298,6 +299,7 @@ struct mlx5e_rq_stats {
298299
u64 csum_none;
299300
u64 lro_packets;
300301
u64 lro_bytes;
302+
u64 mcast_packets;
301303
u64 ecn_mark;
302304
u64 removed_vlan_packets;
303305
u64 xdp_drop;

0 commit comments

Comments
 (0)