143 lines
5.5 KiB
Diff
143 lines
5.5 KiB
Diff
From 9f88327ce89be95757619078e64831f60cb79111 Mon Sep 17 00:00:00 2001
|
|
From: Kamal Heib <kheib@redhat.com>
|
|
Date: Fri, 17 Apr 2026 11:27:01 -0400
|
|
Subject: [PATCH] net/mlx5e: Query FW for buffer ownership
|
|
|
|
JIRA: https://redhat.atlassian.net/browse/RHEL-169055
|
|
|
|
commit 451d2849ea66659040b59ae3cb7e50cc97404733
|
|
Author: Alexei Lazar <alazar@nvidia.com>
|
|
Date: Wed Aug 20 16:32:08 2025 +0300
|
|
|
|
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: ecdf2dadee8e ("net/mlx5e: Receive buffer support for DCBX")
|
|
Signed-off-by: Alexei Lazar <alazar@nvidia.com>
|
|
Reviewed-by: Shahar Shitrit <shshitrit@nvidia.com>
|
|
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
|
|
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
|
|
Link: https://patch.msgid.link/20250820133209.389065-8-mbloch@nvidia.com
|
|
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
|
|
Signed-off-by: Kamal Heib <kheib@redhat.com>
|
|
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/dcbnl.h b/drivers/net/ethernet/mellanox/mlx5/core/en/dcbnl.h
|
|
index b59aee75de94..2c98a5299df3 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/dcbnl.h
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/dcbnl.h
|
|
@@ -26,7 +26,6 @@ struct mlx5e_dcbx {
|
|
u8 cap;
|
|
|
|
/* Buffer configuration */
|
|
- bool manual_buffer;
|
|
u32 cable_len;
|
|
u32 xoff;
|
|
u16 port_buff_cell_sz;
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
|
|
index 8705cffc747f..b08328fe1aa3 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
|
|
@@ -362,6 +362,7 @@ static int mlx5e_dcbnl_ieee_getpfc(struct net_device *dev,
|
|
static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
|
|
struct ieee_pfc *pfc)
|
|
{
|
|
+ u8 buffer_ownership = MLX5_BUF_OWNERSHIP_UNKNOWN;
|
|
struct mlx5e_priv *priv = netdev_priv(dev);
|
|
struct mlx5_core_dev *mdev = priv->mdev;
|
|
u32 old_cable_len = priv->dcbx.cable_len;
|
|
@@ -389,7 +390,14 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
|
|
|
|
if (MLX5_BUFFER_SUPPORTED(mdev)) {
|
|
pfc_new.pfc_en = (changed & MLX5E_PORT_BUFFER_PFC) ? pfc->pfc_en : curr_pfc_en;
|
|
- if (priv->dcbx.manual_buffer)
|
|
+ ret = mlx5_query_port_buffer_ownership(mdev,
|
|
+ &buffer_ownership);
|
|
+ if (ret)
|
|
+ netdev_err(dev,
|
|
+ "%s, Failed to get buffer ownership: %d\n",
|
|
+ __func__, ret);
|
|
+
|
|
+ if (buffer_ownership == MLX5_BUF_OWNERSHIP_SW_OWNED)
|
|
ret = mlx5e_port_manual_buffer_config(priv, changed,
|
|
dev->mtu, &pfc_new,
|
|
NULL, NULL);
|
|
@@ -982,7 +990,6 @@ static int mlx5e_dcbnl_setbuffer(struct net_device *dev,
|
|
if (!changed)
|
|
return 0;
|
|
|
|
- priv->dcbx.manual_buffer = true;
|
|
err = mlx5e_port_manual_buffer_config(priv, changed, dev->mtu, NULL,
|
|
buffer_size, prio2buffer);
|
|
return err;
|
|
@@ -1250,7 +1257,6 @@ void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv)
|
|
priv->dcbx.cap |= DCB_CAP_DCBX_HOST;
|
|
|
|
priv->dcbx.port_buff_cell_sz = mlx5e_query_port_buffers_cell_size(priv);
|
|
- priv->dcbx.manual_buffer = false;
|
|
priv->dcbx.cable_len = MLX5E_DEFAULT_CABLE_LEN;
|
|
|
|
mlx5e_ets_init(priv);
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
|
|
index b6d53db27cd5..9d3504f5abfa 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
|
|
@@ -367,6 +367,8 @@ int mlx5_query_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *out);
|
|
int mlx5_set_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *in);
|
|
int mlx5_set_trust_state(struct mlx5_core_dev *mdev, u8 trust_state);
|
|
int mlx5_query_trust_state(struct mlx5_core_dev *mdev, u8 *trust_state);
|
|
+int mlx5_query_port_buffer_ownership(struct mlx5_core_dev *mdev,
|
|
+ u8 *buffer_ownership);
|
|
int mlx5_set_dscp2prio(struct mlx5_core_dev *mdev, u8 dscp, u8 prio);
|
|
int mlx5_query_dscp2prio(struct mlx5_core_dev *mdev, u8 *dscp2prio);
|
|
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c b/drivers/net/ethernet/mellanox/mlx5/core/port.c
|
|
index 7b99e08a7964..aa9f2b0a77d3 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/port.c
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c
|
|
@@ -968,6 +968,26 @@ int mlx5_query_trust_state(struct mlx5_core_dev *mdev, u8 *trust_state)
|
|
return err;
|
|
}
|
|
|
|
+int mlx5_query_port_buffer_ownership(struct mlx5_core_dev *mdev,
|
|
+ u8 *buffer_ownership)
|
|
+{
|
|
+ u32 out[MLX5_ST_SZ_DW(pfcc_reg)] = {};
|
|
+ int err;
|
|
+
|
|
+ if (!MLX5_CAP_PCAM_FEATURE(mdev, buffer_ownership)) {
|
|
+ *buffer_ownership = MLX5_BUF_OWNERSHIP_UNKNOWN;
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ err = mlx5_query_pfcc_reg(mdev, out, sizeof(out));
|
|
+ if (err)
|
|
+ return err;
|
|
+
|
|
+ *buffer_ownership = MLX5_GET(pfcc_reg, out, buf_ownership);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
int mlx5_set_dscp2prio(struct mlx5_core_dev *mdev, u8 dscp, u8 prio)
|
|
{
|
|
int sz = MLX5_ST_SZ_BYTES(qpdpm_reg);
|
|
--
|
|
2.50.1 (Apple Git-155)
|
|
|