Skip to content

Commit 73e6551

Browse files
Huy NguyenSaeed Mahameed
authored andcommitted
net/mlx5e: Query global pause state before setting prio2buffer
When the user changes prio2buffer mapping while global pause is enabled, mlx5 driver incorrectly sets all active buffers (buffer that has at least one priority mapped) to lossy. Solution: If global pause is enabled, set all the active buffers to lossless in prio2buffer command. Also, add error message when buffer size is not enough to meet xoff threshold. Fixes: 0696d60 ("net/mlx5e: Receive buffer configuration") Signed-off-by: Huy Nguyen <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent c55d8b1 commit 73e6551

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
155155
}
156156

157157
if (port_buffer->buffer[i].size <
158-
(xoff + max_mtu + (1 << MLX5E_BUFFER_CELL_SHIFT)))
158+
(xoff + max_mtu + (1 << MLX5E_BUFFER_CELL_SHIFT))) {
159+
pr_err("buffer_size[%d]=%d is not enough for lossless buffer\n",
160+
i, port_buffer->buffer[i].size);
159161
return -ENOMEM;
162+
}
160163

161164
port_buffer->buffer[i].xoff = port_buffer->buffer[i].size - xoff;
162165
port_buffer->buffer[i].xon =
@@ -232,6 +235,26 @@ static int update_buffer_lossy(unsigned int max_mtu,
232235
return 0;
233236
}
234237

238+
static int fill_pfc_en(struct mlx5_core_dev *mdev, u8 *pfc_en)
239+
{
240+
u32 g_rx_pause, g_tx_pause;
241+
int err;
242+
243+
err = mlx5_query_port_pause(mdev, &g_rx_pause, &g_tx_pause);
244+
if (err)
245+
return err;
246+
247+
/* If global pause enabled, set all active buffers to lossless.
248+
* Otherwise, check PFC setting.
249+
*/
250+
if (g_rx_pause || g_tx_pause)
251+
*pfc_en = 0xff;
252+
else
253+
err = mlx5_query_port_pfc(mdev, pfc_en, NULL);
254+
255+
return err;
256+
}
257+
235258
#define MINIMUM_MAX_MTU 9216
236259
int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
237260
u32 change, unsigned int mtu,
@@ -277,7 +300,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
277300

278301
if (change & MLX5E_PORT_BUFFER_PRIO2BUFFER) {
279302
update_prio2buffer = true;
280-
err = mlx5_query_port_pfc(priv->mdev, &curr_pfc_en, NULL);
303+
err = fill_pfc_en(priv->mdev, &curr_pfc_en);
281304
if (err)
282305
return err;
283306

0 commit comments

Comments
 (0)