Skip to content

Commit 451d284

Browse files
Alexei Lazarkuba-moo
authored andcommitted
net/mlx5e: Query FW for buffer ownership
The SW currently saves local buffer ownership when setting the buffer. This means that the SW assumes it has ownership of the buffer after the command is set. If setting the buffer fails and we remain in FW ownership, the local buffer ownership state incorrectly remains as SW-owned. This leads to incorrect behavior in subsequent PFC commands, causing failures. Instead of saving local buffer ownership in SW, query the FW for buffer ownership when setting the buffer. This ensures that the buffer ownership state is accurately reflected, avoiding the issues caused by incorrect ownership states. Fixes: ecdf2da ("net/mlx5e: Receive buffer support for DCBX") Signed-off-by: Alexei Lazar <[email protected]> Reviewed-by: Shahar Shitrit <[email protected]> Reviewed-by: Dragos Tatulea <[email protected]> Signed-off-by: Mark Bloch <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 51b17c9 commit 451d284

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/dcbnl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ struct mlx5e_dcbx {
2626
u8 cap;
2727

2828
/* Buffer configuration */
29-
bool manual_buffer;
3029
u32 cable_len;
3130
u32 xoff;
3231
u16 port_buff_cell_sz;

drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ static int mlx5e_dcbnl_ieee_getpfc(struct net_device *dev,
362362
static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
363363
struct ieee_pfc *pfc)
364364
{
365+
u8 buffer_ownership = MLX5_BUF_OWNERSHIP_UNKNOWN;
365366
struct mlx5e_priv *priv = netdev_priv(dev);
366367
struct mlx5_core_dev *mdev = priv->mdev;
367368
u32 old_cable_len = priv->dcbx.cable_len;
@@ -389,7 +390,14 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
389390

390391
if (MLX5_BUFFER_SUPPORTED(mdev)) {
391392
pfc_new.pfc_en = (changed & MLX5E_PORT_BUFFER_PFC) ? pfc->pfc_en : curr_pfc_en;
392-
if (priv->dcbx.manual_buffer)
393+
ret = mlx5_query_port_buffer_ownership(mdev,
394+
&buffer_ownership);
395+
if (ret)
396+
netdev_err(dev,
397+
"%s, Failed to get buffer ownership: %d\n",
398+
__func__, ret);
399+
400+
if (buffer_ownership == MLX5_BUF_OWNERSHIP_SW_OWNED)
393401
ret = mlx5e_port_manual_buffer_config(priv, changed,
394402
dev->mtu, &pfc_new,
395403
NULL, NULL);
@@ -982,7 +990,6 @@ static int mlx5e_dcbnl_setbuffer(struct net_device *dev,
982990
if (!changed)
983991
return 0;
984992

985-
priv->dcbx.manual_buffer = true;
986993
err = mlx5e_port_manual_buffer_config(priv, changed, dev->mtu, NULL,
987994
buffer_size, prio2buffer);
988995
return err;
@@ -1252,7 +1259,6 @@ void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv)
12521259
priv->dcbx.cap |= DCB_CAP_DCBX_HOST;
12531260

12541261
priv->dcbx.port_buff_cell_sz = mlx5e_query_port_buffers_cell_size(priv);
1255-
priv->dcbx.manual_buffer = false;
12561262
priv->dcbx.cable_len = MLX5E_DEFAULT_CABLE_LEN;
12571263

12581264
mlx5e_ets_init(priv);

drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ int mlx5_query_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *out);
367367
int mlx5_set_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *in);
368368
int mlx5_set_trust_state(struct mlx5_core_dev *mdev, u8 trust_state);
369369
int mlx5_query_trust_state(struct mlx5_core_dev *mdev, u8 *trust_state);
370+
int mlx5_query_port_buffer_ownership(struct mlx5_core_dev *mdev,
371+
u8 *buffer_ownership);
370372
int mlx5_set_dscp2prio(struct mlx5_core_dev *mdev, u8 dscp, u8 prio);
371373
int mlx5_query_dscp2prio(struct mlx5_core_dev *mdev, u8 *dscp2prio);
372374

drivers/net/ethernet/mellanox/mlx5/core/port.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,26 @@ int mlx5_query_trust_state(struct mlx5_core_dev *mdev, u8 *trust_state)
968968
return err;
969969
}
970970

971+
int mlx5_query_port_buffer_ownership(struct mlx5_core_dev *mdev,
972+
u8 *buffer_ownership)
973+
{
974+
u32 out[MLX5_ST_SZ_DW(pfcc_reg)] = {};
975+
int err;
976+
977+
if (!MLX5_CAP_PCAM_FEATURE(mdev, buffer_ownership)) {
978+
*buffer_ownership = MLX5_BUF_OWNERSHIP_UNKNOWN;
979+
return 0;
980+
}
981+
982+
err = mlx5_query_pfcc_reg(mdev, out, sizeof(out));
983+
if (err)
984+
return err;
985+
986+
*buffer_ownership = MLX5_GET(pfcc_reg, out, buf_ownership);
987+
988+
return 0;
989+
}
990+
971991
int mlx5_set_dscp2prio(struct mlx5_core_dev *mdev, u8 dscp, u8 prio)
972992
{
973993
int sz = MLX5_ST_SZ_BYTES(qpdpm_reg);

0 commit comments

Comments
 (0)