Skip to content

Commit f6e168b

Browse files
committed
Merge branch 'mlx4-misc-fixes'
Tariq Toukan says: ==================== mlx4 misc fixes This patchset contains misc bug fixes from the team to the mlx4 Core and Eth drivers. Patch 1 by Eugenia fixes an MTU issue in selftest. Patch 2 by Eran fixes an accounting issue in the resource tracker. Patch 3 by Eran fixes a race condition that causes counter inconsistency. Series generated against net commit: 2008097 fou: fix some member types in guehdr v2: Patch 2: Add reviewer credit, rephrase commit message. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents de9c4e0 + 5a1647c commit f6e168b

File tree

4 files changed

+35
-28
lines changed

4 files changed

+35
-28
lines changed

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

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
188188
struct net_device *dev = mdev->pndev[port];
189189
struct mlx4_en_priv *priv = netdev_priv(dev);
190190
struct net_device_stats *stats = &dev->stats;
191-
struct mlx4_cmd_mailbox *mailbox;
191+
struct mlx4_cmd_mailbox *mailbox, *mailbox_priority;
192192
u64 in_mod = reset << 8 | port;
193193
int err;
194194
int i, counter_index;
@@ -198,6 +198,13 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
198198
mailbox = mlx4_alloc_cmd_mailbox(mdev->dev);
199199
if (IS_ERR(mailbox))
200200
return PTR_ERR(mailbox);
201+
202+
mailbox_priority = mlx4_alloc_cmd_mailbox(mdev->dev);
203+
if (IS_ERR(mailbox_priority)) {
204+
mlx4_free_cmd_mailbox(mdev->dev, mailbox);
205+
return PTR_ERR(mailbox_priority);
206+
}
207+
201208
err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma, in_mod, 0,
202209
MLX4_CMD_DUMP_ETH_STATS, MLX4_CMD_TIME_CLASS_B,
203210
MLX4_CMD_NATIVE);
@@ -206,6 +213,28 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
206213

207214
mlx4_en_stats = mailbox->buf;
208215

216+
memset(&tmp_counter_stats, 0, sizeof(tmp_counter_stats));
217+
counter_index = mlx4_get_default_counter_index(mdev->dev, port);
218+
err = mlx4_get_counter_stats(mdev->dev, counter_index,
219+
&tmp_counter_stats, reset);
220+
221+
/* 0xffs indicates invalid value */
222+
memset(mailbox_priority->buf, 0xff,
223+
sizeof(*flowstats) * MLX4_NUM_PRIORITIES);
224+
225+
if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) {
226+
memset(mailbox_priority->buf, 0,
227+
sizeof(*flowstats) * MLX4_NUM_PRIORITIES);
228+
err = mlx4_cmd_box(mdev->dev, 0, mailbox_priority->dma,
229+
in_mod | MLX4_DUMP_ETH_STATS_FLOW_CONTROL,
230+
0, MLX4_CMD_DUMP_ETH_STATS,
231+
MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
232+
if (err)
233+
goto out;
234+
}
235+
236+
flowstats = mailbox_priority->buf;
237+
209238
spin_lock_bh(&priv->stats_lock);
210239

211240
mlx4_en_fold_software_stats(dev);
@@ -345,31 +374,6 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
345374
priv->pkstats.tx_prio[8][0] = be64_to_cpu(mlx4_en_stats->TTOT_novlan);
346375
priv->pkstats.tx_prio[8][1] = be64_to_cpu(mlx4_en_stats->TOCT_novlan);
347376

348-
spin_unlock_bh(&priv->stats_lock);
349-
350-
memset(&tmp_counter_stats, 0, sizeof(tmp_counter_stats));
351-
counter_index = mlx4_get_default_counter_index(mdev->dev, port);
352-
err = mlx4_get_counter_stats(mdev->dev, counter_index,
353-
&tmp_counter_stats, reset);
354-
355-
/* 0xffs indicates invalid value */
356-
memset(mailbox->buf, 0xff, sizeof(*flowstats) * MLX4_NUM_PRIORITIES);
357-
358-
if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) {
359-
memset(mailbox->buf, 0,
360-
sizeof(*flowstats) * MLX4_NUM_PRIORITIES);
361-
err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma,
362-
in_mod | MLX4_DUMP_ETH_STATS_FLOW_CONTROL,
363-
0, MLX4_CMD_DUMP_ETH_STATS,
364-
MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
365-
if (err)
366-
goto out;
367-
}
368-
369-
flowstats = mailbox->buf;
370-
371-
spin_lock_bh(&priv->stats_lock);
372-
373377
if (tmp_counter_stats.counter_mode == 0) {
374378
priv->pf_stats.rx_bytes = be64_to_cpu(tmp_counter_stats.rx_bytes);
375379
priv->pf_stats.tx_bytes = be64_to_cpu(tmp_counter_stats.tx_bytes);
@@ -410,6 +414,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
410414

411415
out:
412416
mlx4_free_cmd_mailbox(mdev->dev, mailbox);
417+
mlx4_free_cmd_mailbox(mdev->dev, mailbox_priority);
413418
return err;
414419
}
415420

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf)
185185
if (priv->mdev->dev->caps.flags &
186186
MLX4_DEV_CAP_FLAG_UC_LOOPBACK) {
187187
buf[3] = mlx4_en_test_registers(priv);
188-
if (priv->port_up)
188+
if (priv->port_up && dev->mtu >= MLX4_SELFTEST_LB_MIN_MTU)
189189
buf[4] = mlx4_en_test_loopback(priv);
190190
}
191191

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@
153153
#define SMALL_PACKET_SIZE (256 - NET_IP_ALIGN)
154154
#define HEADER_COPY_SIZE (128 - NET_IP_ALIGN)
155155
#define MLX4_LOOPBACK_TEST_PAYLOAD (HEADER_COPY_SIZE - ETH_HLEN)
156+
#define PREAMBLE_LEN 8
157+
#define MLX4_SELFTEST_LB_MIN_MTU (MLX4_LOOPBACK_TEST_PAYLOAD + NET_IP_ALIGN + \
158+
ETH_HLEN + PREAMBLE_LEN)
156159

157160
#define MLX4_EN_MIN_MTU 46
158161
/* VLAN_HLEN is added twice,to support skb vlan tagged with multiple

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,6 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
611611
MLX4_MAX_PORTS;
612612
else
613613
res_alloc->guaranteed[t] = 0;
614-
res_alloc->res_free -= res_alloc->guaranteed[t];
615614
break;
616615
default:
617616
break;

0 commit comments

Comments
 (0)