net/mlx5e: Query global pause state before setting prio2buffer

[ Upstream commit 73e6551699 ]

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: 0696d60853 ("net/mlx5e: Receive buffer configuration")
Signed-off-by: Huy Nguyen <huyn@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Huy Nguyen 2019-09-06 09:28:46 -05:00 committed by Greg Kroah-Hartman
parent 0703996ff4
commit 9617d69d66

View file

@ -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;