Skip to content

Commit 3f5a683

Browse files
committed
Merge branch 'mlx4-misc'
Tariq Toukan says: ==================== mlx4_en misc for 4.17 This patchset contains misc enhancements from the team to the mlx4 Eth driver. Patch 1 by Eran adds physical layer counters. Patch 2 by Eran cleans-up a redundant warn print. Patch 3 combines the checks of two end cases into a single if statement. Patch 4 takes common code structures out of the #ifdef, following your comment on a previous patch. Series generated against net-next commit: f74290f Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 431c7ec + a970d8d commit 3f5a683

File tree

6 files changed

+61
-28
lines changed

6 files changed

+61
-28
lines changed

drivers/net/ethernet/mellanox/mlx4/en_ethtool.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ static const char main_strings[][ETH_GSTRING_LEN] = {
199199
"rx_xdp_drop",
200200
"rx_xdp_tx",
201201
"rx_xdp_tx_full",
202+
203+
/* phy statistics */
204+
"rx_packets_phy", "rx_bytes_phy",
205+
"tx_packets_phy", "tx_bytes_phy",
202206
};
203207

204208
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,
411415
if (bitmap_iterator_test(&it))
412416
data[index++] = ((unsigned long *)&priv->xdp_stats)[i];
413417

418+
for (i = 0; i < NUM_PHY_STATS; i++, bitmap_iterator_inc(&it))
419+
if (bitmap_iterator_test(&it))
420+
data[index++] = ((unsigned long *)&priv->phy_stats)[i];
421+
414422
for (i = 0; i < priv->tx_ring_num[TX]; i++) {
415423
data[index++] = priv->tx_ring[TX][i]->packets;
416424
data[index++] = priv->tx_ring[TX][i]->bytes;
@@ -490,6 +498,12 @@ static void mlx4_en_get_strings(struct net_device *dev,
490498
strcpy(data + (index++) * ETH_GSTRING_LEN,
491499
main_strings[strings]);
492500

501+
for (i = 0; i < NUM_PHY_STATS; i++, strings++,
502+
bitmap_iterator_inc(&it))
503+
if (bitmap_iterator_test(&it))
504+
strcpy(data + (index++) * ETH_GSTRING_LEN,
505+
main_strings[strings]);
506+
493507
for (i = 0; i < priv->tx_ring_num[TX]; i++) {
494508
sprintf(data + (index++) * ETH_GSTRING_LEN,
495509
"tx%d_packets", i);

drivers/net/ethernet/mellanox/mlx4/en_netdev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3256,6 +3256,10 @@ void mlx4_en_set_stats_bitmap(struct mlx4_dev *dev,
32563256

32573257
bitmap_set(stats_bitmap->bitmap, last_i, NUM_XDP_STATS);
32583258
last_i += NUM_XDP_STATS;
3259+
3260+
if (!mlx4_is_slave(dev))
3261+
bitmap_set(stats_bitmap->bitmap, last_i, NUM_PHY_STATS);
3262+
last_i += NUM_PHY_STATS;
32593263
}
32603264

32613265
int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
@@ -3630,10 +3634,6 @@ int mlx4_en_reset_config(struct net_device *dev,
36303634
mlx4_en_stop_port(dev, 1);
36313635
}
36323636

3633-
en_warn(priv, "Changing device configuration rx filter(%x) rx vlan(%x)\n",
3634-
ts_config.rx_filter,
3635-
!!(features & NETIF_F_HW_VLAN_CTAG_RX));
3636-
36373637
mlx4_en_safe_replace_resources(priv, tmp);
36383638

36393639
if (DEV_FEATURE_CHANGED(dev, features, NETIF_F_HW_VLAN_CTAG_RX)) {

drivers/net/ethernet/mellanox/mlx4/en_port.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -275,19 +275,31 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
275275
priv->port_stats.xmit_more += READ_ONCE(ring->xmit_more);
276276
}
277277

278-
if (mlx4_is_master(mdev->dev)) {
279-
stats->rx_packets = en_stats_adder(&mlx4_en_stats->RTOT_prio_0,
280-
&mlx4_en_stats->RTOT_prio_1,
281-
NUM_PRIORITIES);
282-
stats->tx_packets = en_stats_adder(&mlx4_en_stats->TTOT_prio_0,
283-
&mlx4_en_stats->TTOT_prio_1,
284-
NUM_PRIORITIES);
285-
stats->rx_bytes = en_stats_adder(&mlx4_en_stats->ROCT_prio_0,
286-
&mlx4_en_stats->ROCT_prio_1,
287-
NUM_PRIORITIES);
288-
stats->tx_bytes = en_stats_adder(&mlx4_en_stats->TOCT_prio_0,
289-
&mlx4_en_stats->TOCT_prio_1,
290-
NUM_PRIORITIES);
278+
if (!mlx4_is_slave(mdev->dev)) {
279+
struct mlx4_en_phy_stats *p_stats = &priv->phy_stats;
280+
281+
p_stats->rx_packets_phy =
282+
en_stats_adder(&mlx4_en_stats->RTOT_prio_0,
283+
&mlx4_en_stats->RTOT_prio_1,
284+
NUM_PRIORITIES);
285+
p_stats->tx_packets_phy =
286+
en_stats_adder(&mlx4_en_stats->TTOT_prio_0,
287+
&mlx4_en_stats->TTOT_prio_1,
288+
NUM_PRIORITIES);
289+
p_stats->rx_bytes_phy =
290+
en_stats_adder(&mlx4_en_stats->ROCT_prio_0,
291+
&mlx4_en_stats->ROCT_prio_1,
292+
NUM_PRIORITIES);
293+
p_stats->tx_bytes_phy =
294+
en_stats_adder(&mlx4_en_stats->TOCT_prio_0,
295+
&mlx4_en_stats->TOCT_prio_1,
296+
NUM_PRIORITIES);
297+
if (mlx4_is_master(mdev->dev)) {
298+
stats->rx_packets = p_stats->rx_packets_phy;
299+
stats->tx_packets = p_stats->tx_packets_phy;
300+
stats->rx_bytes = p_stats->rx_bytes_phy;
301+
stats->tx_bytes = p_stats->tx_bytes_phy;
302+
}
291303
}
292304

293305
/* net device stats */

drivers/net/ethernet/mellanox/mlx4/en_rx.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,12 @@ static int check_csum(struct mlx4_cqe *cqe, struct sk_buff *skb, void *va,
649649
return get_fixed_ipv4_csum(hw_checksum, skb, hdr);
650650
}
651651

652+
#if IS_ENABLED(CONFIG_IPV6)
653+
#define MLX4_CQE_STATUS_IP_ANY (MLX4_CQE_STATUS_IPV4 | MLX4_CQE_STATUS_IPV6)
654+
#else
655+
#define MLX4_CQE_STATUS_IP_ANY (MLX4_CQE_STATUS_IPV4)
656+
#endif
657+
652658
int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int budget)
653659
{
654660
struct mlx4_en_priv *priv = netdev_priv(dev);
@@ -662,12 +668,9 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
662668
int polled = 0;
663669
int index;
664670

665-
if (unlikely(!priv->port_up))
671+
if (unlikely(!priv->port_up || budget <= 0))
666672
return 0;
667673

668-
if (unlikely(budget <= 0))
669-
return polled;
670-
671674
ring = priv->rx_ring[cq_ring];
672675

673676
/* Protect accesses to: ring->xdp_prog, priv->mac_hash list */
@@ -838,12 +841,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
838841
ring->csum_ok++;
839842
} else {
840843
if (!(priv->flags & MLX4_EN_FLAG_RX_CSUM_NON_TCP_UDP &&
841-
(cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPV4 |
842-
#if IS_ENABLED(CONFIG_IPV6)
843-
MLX4_CQE_STATUS_IPV6))))
844-
#else
845-
0))))
846-
#endif
844+
(cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IP_ANY))))
847845
goto csum_none;
848846
if (check_csum(cqe, skb, va, dev->features))
849847
goto csum_none;

drivers/net/ethernet/mellanox/mlx4/mlx4_en.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ struct mlx4_en_priv {
608608
struct mlx4_en_flow_stats_tx tx_flowstats;
609609
struct mlx4_en_port_stats port_stats;
610610
struct mlx4_en_xdp_stats xdp_stats;
611+
struct mlx4_en_phy_stats phy_stats;
611612
struct mlx4_en_stats_bitmap stats_bitmap;
612613
struct list_head mc_list;
613614
struct list_head curr_list;

drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ struct mlx4_en_xdp_stats {
6363
#define NUM_XDP_STATS 3
6464
};
6565

66+
struct mlx4_en_phy_stats {
67+
unsigned long rx_packets_phy;
68+
unsigned long rx_bytes_phy;
69+
unsigned long tx_packets_phy;
70+
unsigned long tx_bytes_phy;
71+
#define NUM_PHY_STATS 4
72+
};
73+
6674
#define NUM_MAIN_STATS 21
6775

6876
#define MLX4_NUM_PRIORITIES 8
@@ -116,7 +124,7 @@ enum {
116124

117125
#define NUM_ALL_STATS (NUM_MAIN_STATS + NUM_PORT_STATS + NUM_PKT_STATS + \
118126
NUM_FLOW_STATS + NUM_PERF_STATS + NUM_PF_STATS + \
119-
NUM_XDP_STATS)
127+
NUM_XDP_STATS + NUM_PHY_STATS)
120128

121129
#define MLX4_FIND_NETDEV_STAT(n) (offsetof(struct net_device_stats, n) / \
122130
sizeof(((struct net_device_stats *)0)->n))

0 commit comments

Comments
 (0)