Commit 73e65516 authored by Huy Nguyen's avatar Huy Nguyen Committed by Saeed Mahameed

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: 0696d608 ("net/mlx5e: Receive buffer configuration")
Signed-off-by: default avatarHuy Nguyen <huyn@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent c55d8b10
......@@ -155,8 +155,11 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
}
if (port_buffer->buffer[i].size <
(xoff + max_mtu + (1 << MLX5E_BUFFER_CELL_SHIFT)))
(xoff + max_mtu + (1 << MLX5E_BUFFER_CELL_SHIFT))) {
pr_err("buffer_size[%d]=%d is not enough for lossless buffer\n",
i, port_buffer->buffer[i].size);
return -ENOMEM;
}
port_buffer->buffer[i].xoff = port_buffer->buffer[i].size - xoff;
port_buffer->buffer[i].xon =
......@@ -232,6 +235,26 @@ static int update_buffer_lossy(unsigned int max_mtu,
return 0;
}
static int fill_pfc_en(struct mlx5_core_dev *mdev, u8 *pfc_en)
{
u32 g_rx_pause, g_tx_pause;
int err;
err = mlx5_query_port_pause(mdev, &g_rx_pause, &g_tx_pause);
if (err)
return err;
/* If global pause enabled, set all active buffers to lossless.
* Otherwise, check PFC setting.
*/
if (g_rx_pause || g_tx_pause)
*pfc_en = 0xff;
else
err = mlx5_query_port_pfc(mdev, pfc_en, NULL);
return err;
}
#define MINIMUM_MAX_MTU 9216
int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
u32 change, unsigned int mtu,
......@@ -277,7 +300,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
if (change & MLX5E_PORT_BUFFER_PRIO2BUFFER) {
update_prio2buffer = true;
err = mlx5_query_port_pfc(priv->mdev, &curr_pfc_en, NULL);
err = fill_pfc_en(priv->mdev, &curr_pfc_en);
if (err)
return err;
......
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