* [PATCH net-next 0/4] net/mlx5: Refactor devcom and add net namespace support
@ 2025-09-11 6:31 Tariq Toukan
2025-09-11 6:31 ` [PATCH net-next 1/4] net/mlx5: Refactor devcom to use match attributes Tariq Toukan
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Tariq Toukan @ 2025-09-11 6:31 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch, netdev,
linux-rdma, linux-kernel, Gal Pressman, Parav Pandit, Shay Drory
Hi,
This series by Shay improves the mlx5 devcom infrastructure by
introducing a structured matching attribute interface, relocating
certain devcom registration flows to more appropriate locations, and
adding net namespace awareness to the devcom framework and its users.
Patch 1: Refactors the devcom interface to accept a match attribute
structure instead of raw keys, enabling future extensibility such as
namespace-based matching.
Patch 2: Moves the devcom registration for HCA components from the core
code to the LAG layer to better reflect their logical ownership and
lifecycle.
Patch 3: Adds net namespace support to the devcom framework, enabling
components to operate in isolated namespaces.
Patch 4: Updates the LAG layer to make use of the new namespace-aware
devcom interface and improves reload behavior in LAG mode.
Regards,
Tariq
Shay Drory (4):
net/mlx5: Refactor devcom to use match attributes
net/mlx5: Lag, move devcom registration to LAG layer
net/mlx5: Add net namespace support to devcom
net/mlx5: Lag, add net namespace support
.../net/ethernet/mellanox/mlx5/core/devlink.c | 5 ---
.../net/ethernet/mellanox/mlx5/core/en_main.c | 6 ++-
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 10 +++--
.../net/ethernet/mellanox/mlx5/core/eswitch.h | 7 ++-
.../mellanox/mlx5/core/eswitch_offloads.c | 5 ++-
.../net/ethernet/mellanox/mlx5/core/lag/lag.c | 45 +++++++++++++++++--
.../net/ethernet/mellanox/mlx5/core/lag/lag.h | 1 +
.../ethernet/mellanox/mlx5/core/lib/clock.c | 14 ++++--
.../ethernet/mellanox/mlx5/core/lib/devcom.c | 44 +++++++++++++-----
.../ethernet/mellanox/mlx5/core/lib/devcom.h | 16 ++++++-
.../net/ethernet/mellanox/mlx5/core/lib/sd.c | 6 ++-
.../net/ethernet/mellanox/mlx5/core/main.c | 24 ----------
12 files changed, 126 insertions(+), 57 deletions(-)
base-commit: 1f24a240974589ce42f70502ccb3ff3f5189d69a
--
2.31.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next 1/4] net/mlx5: Refactor devcom to use match attributes
2025-09-11 6:31 [PATCH net-next 0/4] net/mlx5: Refactor devcom and add net namespace support Tariq Toukan
@ 2025-09-11 6:31 ` Tariq Toukan
2025-09-12 14:11 ` Simon Horman
2025-09-15 9:08 ` Leon Romanovsky
2025-09-11 6:31 ` [PATCH net-next 2/4] net/mlx5: Lag, move devcom registration to LAG layer Tariq Toukan
` (2 subsequent siblings)
3 siblings, 2 replies; 12+ messages in thread
From: Tariq Toukan @ 2025-09-11 6:31 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch, netdev,
linux-rdma, linux-kernel, Gal Pressman, Parav Pandit, Shay Drory
From: Shay Drory <shayd@nvidia.com>
Refactor the devcom interface to use a match attribute structure instead
of passing raw keys. This change lays the groundwork for extending devcom
matching logic with additional fields like net namespace, improving its
flexibility and robustness.
No functional changes.
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/en_main.c | 6 +++-
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 7 +++--
.../net/ethernet/mellanox/mlx5/core/eswitch.h | 7 +++--
.../mellanox/mlx5/core/eswitch_offloads.c | 5 +--
.../ethernet/mellanox/mlx5/core/lib/clock.c | 14 ++++++---
.../ethernet/mellanox/mlx5/core/lib/devcom.c | 31 +++++++++++++------
.../ethernet/mellanox/mlx5/core/lib/devcom.h | 10 +++++-
.../net/ethernet/mellanox/mlx5/core/lib/sd.c | 4 ++-
.../net/ethernet/mellanox/mlx5/core/main.c | 7 +++--
9 files changed, 65 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 714cce595692..fe5f5ae433b7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -235,9 +235,13 @@ static int mlx5e_devcom_event_mpv(int event, void *my_data, void *event_data)
static int mlx5e_devcom_init_mpv(struct mlx5e_priv *priv, u64 *data)
{
+ struct mlx5_devcom_match_attr attr = {
+ .key.val = *data,
+ };
+
priv->devcom = mlx5_devcom_register_component(priv->mdev->priv.devc,
MLX5_DEVCOM_MPV,
- *data,
+ &attr,
mlx5e_devcom_event_mpv,
priv);
if (IS_ERR(priv->devcom))
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 32c07a8b03d1..9874a15c6fba 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -5387,12 +5387,13 @@ void mlx5e_tc_ht_cleanup(struct rhashtable *tc_ht)
int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv)
{
const size_t sz_enc_opts = sizeof(struct tunnel_match_enc_opts);
+ struct mlx5_devcom_match_attr attr = {};
struct netdev_phys_item_id ppid;
struct mlx5e_rep_priv *rpriv;
struct mapping_ctx *mapping;
struct mlx5_eswitch *esw;
struct mlx5e_priv *priv;
- u64 mapping_id, key;
+ u64 mapping_id;
int err = 0;
rpriv = container_of(uplink_priv, struct mlx5e_rep_priv, uplink_priv);
@@ -5448,8 +5449,8 @@ int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv)
err = netif_get_port_parent_id(priv->netdev, &ppid, false);
if (!err) {
- memcpy(&key, &ppid.id, sizeof(key));
- mlx5_esw_offloads_devcom_init(esw, key);
+ memcpy(&attr.key.val, &ppid.id, sizeof(attr.key.val));
+ mlx5_esw_offloads_devcom_init(esw, &attr);
}
return 0;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index 4fe285ce32aa..df3756d7e52e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -433,7 +433,8 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs);
void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw, bool clear_vf);
void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw);
void mlx5_eswitch_disable(struct mlx5_eswitch *esw);
-void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw, u64 key);
+void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw,
+ const struct mlx5_devcom_match_attr *attr);
void mlx5_esw_offloads_devcom_cleanup(struct mlx5_eswitch *esw);
bool mlx5_esw_offloads_devcom_is_ready(struct mlx5_eswitch *esw);
int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
@@ -928,7 +929,9 @@ static inline void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw) {}
static inline int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) { return 0; }
static inline void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw, bool clear_vf) {}
static inline void mlx5_eswitch_disable(struct mlx5_eswitch *esw) {}
-static inline void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw, u64 key) {}
+static inline void
+mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw,
+ const struct mlx5_devcom_match_attr *attr) {}
static inline void mlx5_esw_offloads_devcom_cleanup(struct mlx5_eswitch *esw) {}
static inline bool mlx5_esw_offloads_devcom_is_ready(struct mlx5_eswitch *esw) { return false; }
static inline bool mlx5_eswitch_is_funcs_handler(struct mlx5_core_dev *dev) { return false; }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index d57f86d297ab..bc9838dc5bf8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -3104,7 +3104,8 @@ static int mlx5_esw_offloads_devcom_event(int event,
return err;
}
-void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw, u64 key)
+void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw,
+ const struct mlx5_devcom_match_attr *attr)
{
int i;
@@ -3123,7 +3124,7 @@ void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw, u64 key)
esw->num_peers = 0;
esw->devcom = mlx5_devcom_register_component(esw->dev->priv.devc,
MLX5_DEVCOM_ESW_OFFLOADS,
- key,
+ attr,
mlx5_esw_offloads_devcom_event,
esw);
if (IS_ERR(esw->devcom))
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index 7ad3baca99de..8f2ad45bec9f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -1435,14 +1435,20 @@ static int mlx5_clock_alloc(struct mlx5_core_dev *mdev, bool shared)
static void mlx5_shared_clock_register(struct mlx5_core_dev *mdev, u64 key)
{
struct mlx5_core_dev *peer_dev, *next = NULL;
+ struct mlx5_devcom_match_attr attr = {
+ .key.val = key,
+ };
+ struct mlx5_devcom_comp_dev *compd;
struct mlx5_devcom_comp_dev *pos;
- mdev->clock_state->compdev = mlx5_devcom_register_component(mdev->priv.devc,
- MLX5_DEVCOM_SHARED_CLOCK,
- key, NULL, mdev);
- if (IS_ERR(mdev->clock_state->compdev))
+ compd = mlx5_devcom_register_component(mdev->priv.devc,
+ MLX5_DEVCOM_SHARED_CLOCK,
+ &attr, NULL, mdev);
+ if (IS_ERR(compd))
return;
+ mdev->clock_state->compdev = compd;
+
mlx5_devcom_comp_lock(mdev->clock_state->compdev);
mlx5_devcom_for_each_peer_entry(mdev->clock_state->compdev, peer_dev, pos) {
if (peer_dev->clock) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
index 7b0766c89f4c..1ab9de316deb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
@@ -22,11 +22,15 @@ struct mlx5_devcom_dev {
struct kref ref;
};
+struct mlx5_devcom_key {
+ union mlx5_devcom_match_key key;
+};
+
struct mlx5_devcom_comp {
struct list_head comp_list;
enum mlx5_devcom_component id;
- u64 key;
struct list_head comp_dev_list_head;
+ struct mlx5_devcom_key key;
mlx5_devcom_event_handler_t handler;
struct kref ref;
bool ready;
@@ -108,7 +112,8 @@ void mlx5_devcom_unregister_device(struct mlx5_devcom_dev *devc)
}
static struct mlx5_devcom_comp *
-mlx5_devcom_comp_alloc(u64 id, u64 key, mlx5_devcom_event_handler_t handler)
+mlx5_devcom_comp_alloc(u64 id, const struct mlx5_devcom_match_attr *attr,
+ mlx5_devcom_event_handler_t handler)
{
struct mlx5_devcom_comp *comp;
@@ -117,7 +122,7 @@ mlx5_devcom_comp_alloc(u64 id, u64 key, mlx5_devcom_event_handler_t handler)
return ERR_PTR(-ENOMEM);
comp->id = id;
- comp->key = key;
+ comp->key.key = attr->key;
comp->handler = handler;
init_rwsem(&comp->sem);
lockdep_register_key(&comp->lock_key);
@@ -180,21 +185,27 @@ devcom_free_comp_dev(struct mlx5_devcom_comp_dev *devcom)
static bool
devcom_component_equal(struct mlx5_devcom_comp *devcom,
enum mlx5_devcom_component id,
- u64 key)
+ const struct mlx5_devcom_match_attr *attr)
{
- return devcom->id == id && devcom->key == key;
+ if (devcom->id != id)
+ return false;
+
+ if (memcmp(&devcom->key.key, &attr->key, sizeof(devcom->key.key)))
+ return false;
+
+ return true;
}
static struct mlx5_devcom_comp *
devcom_component_get(struct mlx5_devcom_dev *devc,
enum mlx5_devcom_component id,
- u64 key,
+ const struct mlx5_devcom_match_attr *attr,
mlx5_devcom_event_handler_t handler)
{
struct mlx5_devcom_comp *comp;
devcom_for_each_component(comp) {
- if (devcom_component_equal(comp, id, key)) {
+ if (devcom_component_equal(comp, id, attr)) {
if (handler == comp->handler) {
kref_get(&comp->ref);
return comp;
@@ -212,7 +223,7 @@ devcom_component_get(struct mlx5_devcom_dev *devc,
struct mlx5_devcom_comp_dev *
mlx5_devcom_register_component(struct mlx5_devcom_dev *devc,
enum mlx5_devcom_component id,
- u64 key,
+ const struct mlx5_devcom_match_attr *attr,
mlx5_devcom_event_handler_t handler,
void *data)
{
@@ -223,14 +234,14 @@ mlx5_devcom_register_component(struct mlx5_devcom_dev *devc,
return ERR_PTR(-EINVAL);
mutex_lock(&comp_list_lock);
- comp = devcom_component_get(devc, id, key, handler);
+ comp = devcom_component_get(devc, id, attr, handler);
if (IS_ERR(comp)) {
devcom = ERR_PTR(-EINVAL);
goto out_unlock;
}
if (!comp) {
- comp = mlx5_devcom_comp_alloc(id, key, handler);
+ comp = mlx5_devcom_comp_alloc(id, attr, handler);
if (IS_ERR(comp)) {
devcom = ERR_CAST(comp);
goto out_unlock;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
index c79699b94a02..f350d2395707 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
@@ -6,6 +6,14 @@
#include <linux/mlx5/driver.h>
+union mlx5_devcom_match_key {
+ u64 val;
+};
+
+struct mlx5_devcom_match_attr {
+ union mlx5_devcom_match_key key;
+};
+
enum mlx5_devcom_component {
MLX5_DEVCOM_ESW_OFFLOADS,
MLX5_DEVCOM_MPV,
@@ -25,7 +33,7 @@ void mlx5_devcom_unregister_device(struct mlx5_devcom_dev *devc);
struct mlx5_devcom_comp_dev *
mlx5_devcom_register_component(struct mlx5_devcom_dev *devc,
enum mlx5_devcom_component id,
- u64 key,
+ const struct mlx5_devcom_match_attr *attr,
mlx5_devcom_event_handler_t handler,
void *data);
void mlx5_devcom_unregister_component(struct mlx5_devcom_comp_dev *devcom);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
index eeb0b7ea05f1..d4015328ba65 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
@@ -210,13 +210,15 @@ static void sd_cleanup(struct mlx5_core_dev *dev)
static int sd_register(struct mlx5_core_dev *dev)
{
struct mlx5_devcom_comp_dev *devcom, *pos;
+ struct mlx5_devcom_match_attr attr = {};
struct mlx5_core_dev *peer, *primary;
struct mlx5_sd *sd, *primary_sd;
int err, i;
sd = mlx5_get_sd(dev);
+ attr.key.val = sd->group_id;
devcom = mlx5_devcom_register_component(dev->priv.devc, MLX5_DEVCOM_SD_GROUP,
- sd->group_id, NULL, dev);
+ &attr, NULL, dev);
if (IS_ERR(devcom))
return PTR_ERR(devcom);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 0951c7cc1b5f..1f7942202e14 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -975,6 +975,10 @@ static void mlx5_pci_close(struct mlx5_core_dev *dev)
static void mlx5_register_hca_devcom_comp(struct mlx5_core_dev *dev)
{
+ struct mlx5_devcom_match_attr attr = {
+ .key.val = mlx5_query_nic_system_image_guid(dev),
+ };
+
/* This component is use to sync adding core_dev to lag_dev and to sync
* changes of mlx5_adev_devices between LAG layer and other layers.
*/
@@ -983,8 +987,7 @@ static void mlx5_register_hca_devcom_comp(struct mlx5_core_dev *dev)
dev->priv.hca_devcom_comp =
mlx5_devcom_register_component(dev->priv.devc, MLX5_DEVCOM_HCA_PORTS,
- mlx5_query_nic_system_image_guid(dev),
- NULL, dev);
+ &attr, NULL, dev);
if (IS_ERR(dev->priv.hca_devcom_comp))
mlx5_core_err(dev, "Failed to register devcom HCA component\n");
}
--
2.31.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next 2/4] net/mlx5: Lag, move devcom registration to LAG layer
2025-09-11 6:31 [PATCH net-next 0/4] net/mlx5: Refactor devcom and add net namespace support Tariq Toukan
2025-09-11 6:31 ` [PATCH net-next 1/4] net/mlx5: Refactor devcom to use match attributes Tariq Toukan
@ 2025-09-11 6:31 ` Tariq Toukan
2025-09-12 14:11 ` Simon Horman
2025-09-11 6:31 ` [PATCH net-next 3/4] net/mlx5: Add net namespace support to devcom Tariq Toukan
2025-09-11 6:31 ` [PATCH net-next 4/4] net/mlx5: Lag, add net namespace support Tariq Toukan
3 siblings, 1 reply; 12+ messages in thread
From: Tariq Toukan @ 2025-09-11 6:31 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch, netdev,
linux-rdma, linux-kernel, Gal Pressman, Parav Pandit, Shay Drory
From: Shay Drory <shayd@nvidia.com>
Move the devcom registration for the HCA_PORTS component from the core
initialization path into the LAG logic. This better reflects the
logical ownership of this component and ensures proper alignment with
the LAG lifecycle.
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/lag/lag.c | 31 ++++++++++++++++++-
.../net/ethernet/mellanox/mlx5/core/main.c | 27 ----------------
2 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
index d058cbb4a00c..ccb22ed13f84 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
@@ -1404,6 +1404,34 @@ static int __mlx5_lag_dev_add_mdev(struct mlx5_core_dev *dev)
return 0;
}
+static void mlx5_lag_unregister_hca_devcom_comp(struct mlx5_core_dev *dev)
+{
+ mlx5_devcom_unregister_component(dev->priv.hca_devcom_comp);
+}
+
+static int mlx5_lag_register_hca_devcom_comp(struct mlx5_core_dev *dev)
+{
+ struct mlx5_devcom_match_attr attr = {
+ .key.val = mlx5_query_nic_system_image_guid(dev),
+ };
+
+ /* This component is use to sync adding core_dev to lag_dev and to sync
+ * changes of mlx5_adev_devices between LAG layer and other layers.
+ */
+ dev->priv.hca_devcom_comp =
+ mlx5_devcom_register_component(dev->priv.devc,
+ MLX5_DEVCOM_HCA_PORTS,
+ &attr, NULL, dev);
+ if (IS_ERR(dev->priv.hca_devcom_comp)) {
+ mlx5_core_err(dev,
+ "Failed to register devcom HCA component, err: %ld\n",
+ PTR_ERR(dev->priv.hca_devcom_comp));
+ return PTR_ERR(dev->priv.hca_devcom_comp);
+ }
+
+ return 0;
+}
+
void mlx5_lag_remove_mdev(struct mlx5_core_dev *dev)
{
struct mlx5_lag *ldev;
@@ -1425,6 +1453,7 @@ void mlx5_lag_remove_mdev(struct mlx5_core_dev *dev)
}
mlx5_ldev_remove_mdev(ldev, dev);
mutex_unlock(&ldev->lock);
+ mlx5_lag_unregister_hca_devcom_comp(dev);
mlx5_ldev_put(ldev);
}
@@ -1435,7 +1464,7 @@ void mlx5_lag_add_mdev(struct mlx5_core_dev *dev)
if (!mlx5_lag_is_supported(dev))
return;
- if (IS_ERR_OR_NULL(dev->priv.hca_devcom_comp))
+ if (mlx5_lag_register_hca_devcom_comp(dev))
return;
recheck:
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 1f7942202e14..eb3ac98a2621 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -973,30 +973,6 @@ static void mlx5_pci_close(struct mlx5_core_dev *dev)
mlx5_pci_disable_device(dev);
}
-static void mlx5_register_hca_devcom_comp(struct mlx5_core_dev *dev)
-{
- struct mlx5_devcom_match_attr attr = {
- .key.val = mlx5_query_nic_system_image_guid(dev),
- };
-
- /* This component is use to sync adding core_dev to lag_dev and to sync
- * changes of mlx5_adev_devices between LAG layer and other layers.
- */
- if (!mlx5_lag_is_supported(dev))
- return;
-
- dev->priv.hca_devcom_comp =
- mlx5_devcom_register_component(dev->priv.devc, MLX5_DEVCOM_HCA_PORTS,
- &attr, NULL, dev);
- if (IS_ERR(dev->priv.hca_devcom_comp))
- mlx5_core_err(dev, "Failed to register devcom HCA component\n");
-}
-
-static void mlx5_unregister_hca_devcom_comp(struct mlx5_core_dev *dev)
-{
- mlx5_devcom_unregister_component(dev->priv.hca_devcom_comp);
-}
-
static int mlx5_init_once(struct mlx5_core_dev *dev)
{
int err;
@@ -1005,7 +981,6 @@ static int mlx5_init_once(struct mlx5_core_dev *dev)
if (IS_ERR(dev->priv.devc))
mlx5_core_warn(dev, "failed to register devcom device %ld\n",
PTR_ERR(dev->priv.devc));
- mlx5_register_hca_devcom_comp(dev);
err = mlx5_query_board_id(dev);
if (err) {
@@ -1143,7 +1118,6 @@ static int mlx5_init_once(struct mlx5_core_dev *dev)
err_irq_cleanup:
mlx5_irq_table_cleanup(dev);
err_devcom:
- mlx5_unregister_hca_devcom_comp(dev);
mlx5_devcom_unregister_device(dev->priv.devc);
return err;
@@ -1174,7 +1148,6 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
mlx5_events_cleanup(dev);
mlx5_eq_table_cleanup(dev);
mlx5_irq_table_cleanup(dev);
- mlx5_unregister_hca_devcom_comp(dev);
mlx5_devcom_unregister_device(dev->priv.devc);
}
--
2.31.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next 3/4] net/mlx5: Add net namespace support to devcom
2025-09-11 6:31 [PATCH net-next 0/4] net/mlx5: Refactor devcom and add net namespace support Tariq Toukan
2025-09-11 6:31 ` [PATCH net-next 1/4] net/mlx5: Refactor devcom to use match attributes Tariq Toukan
2025-09-11 6:31 ` [PATCH net-next 2/4] net/mlx5: Lag, move devcom registration to LAG layer Tariq Toukan
@ 2025-09-11 6:31 ` Tariq Toukan
2025-09-12 14:11 ` Simon Horman
2025-09-11 6:31 ` [PATCH net-next 4/4] net/mlx5: Lag, add net namespace support Tariq Toukan
3 siblings, 1 reply; 12+ messages in thread
From: Tariq Toukan @ 2025-09-11 6:31 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch, netdev,
linux-rdma, linux-kernel, Gal Pressman, Parav Pandit, Shay Drory
From: Shay Drory <shayd@nvidia.com>
Extend the devcom framework to support namespace-aware components.
The existing devcom matching logic was based solely on numeric keys,
limiting its use to the global (init_net) scope or requiring clients
to ignore namespaces altogether, both of which are incorrect in
multi-namespace environments.
This patch introduces namespace support by allowing devcom clients to
provide a namespace match attribute. The devcom pairing mechanism is
updated to compare the namespace, enabling proper isolation and
interaction of components across different net namespaces.
With this change, components that require namespace aware pairing,
such as SD groups or LAG, can now work correctly in multi-namespace
scenarios. In particular, this opens the way to support hardware LAG
within a net namespace.
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 +++
.../net/ethernet/mellanox/mlx5/core/lib/devcom.c | 13 +++++++++++++
.../net/ethernet/mellanox/mlx5/core/lib/devcom.h | 6 ++++++
drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c | 2 ++
4 files changed, 24 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 9874a15c6fba..09c3eecb836d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -66,6 +66,7 @@
#include "lib/devcom.h"
#include "lib/geneve.h"
#include "lib/fs_chains.h"
+#include "lib/mlx5.h"
#include "diag/en_tc_tracepoint.h"
#include <asm/div64.h>
#include "lag/lag.h"
@@ -5450,6 +5451,8 @@ int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv)
err = netif_get_port_parent_id(priv->netdev, &ppid, false);
if (!err) {
memcpy(&attr.key.val, &ppid.id, sizeof(attr.key.val));
+ attr.flags = MLX5_DEVCOM_MATCH_FLAGS_NS;
+ attr.net = mlx5_core_net(esw->dev);
mlx5_esw_offloads_devcom_init(esw, &attr);
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
index 1ab9de316deb..faa2833602c8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
@@ -4,6 +4,7 @@
#include <linux/mlx5/vport.h>
#include <linux/list.h>
#include "lib/devcom.h"
+#include "lib/mlx5.h"
#include "mlx5_core.h"
static LIST_HEAD(devcom_dev_list);
@@ -23,7 +24,9 @@ struct mlx5_devcom_dev {
};
struct mlx5_devcom_key {
+ u32 flags;
union mlx5_devcom_match_key key;
+ possible_net_t net;
};
struct mlx5_devcom_comp {
@@ -123,6 +126,9 @@ mlx5_devcom_comp_alloc(u64 id, const struct mlx5_devcom_match_attr *attr,
comp->id = id;
comp->key.key = attr->key;
+ comp->key.flags = attr->flags;
+ if (attr->flags & MLX5_DEVCOM_MATCH_FLAGS_NS)
+ write_pnet(&comp->key.net, attr->net);
comp->handler = handler;
init_rwsem(&comp->sem);
lockdep_register_key(&comp->lock_key);
@@ -190,9 +196,16 @@ devcom_component_equal(struct mlx5_devcom_comp *devcom,
if (devcom->id != id)
return false;
+ if (devcom->key.flags != attr->flags)
+ return false;
+
if (memcmp(&devcom->key.key, &attr->key, sizeof(devcom->key.key)))
return false;
+ if (devcom->key.flags & MLX5_DEVCOM_MATCH_FLAGS_NS &&
+ !net_eq(read_pnet(&devcom->key.net), attr->net))
+ return false;
+
return true;
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
index f350d2395707..609c85f47917 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
@@ -6,12 +6,18 @@
#include <linux/mlx5/driver.h>
+enum mlx5_devom_match_flags {
+ MLX5_DEVCOM_MATCH_FLAGS_NS = BIT(0),
+};
+
union mlx5_devcom_match_key {
u64 val;
};
struct mlx5_devcom_match_attr {
+ u32 flags;
union mlx5_devcom_match_key key;
+ struct net *net;
};
enum mlx5_devcom_component {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
index d4015328ba65..f5c2701f6e87 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
@@ -217,6 +217,8 @@ static int sd_register(struct mlx5_core_dev *dev)
sd = mlx5_get_sd(dev);
attr.key.val = sd->group_id;
+ attr.flags = MLX5_DEVCOM_MATCH_FLAGS_NS;
+ attr.net = mlx5_core_net(dev);
devcom = mlx5_devcom_register_component(dev->priv.devc, MLX5_DEVCOM_SD_GROUP,
&attr, NULL, dev);
if (IS_ERR(devcom))
--
2.31.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next 4/4] net/mlx5: Lag, add net namespace support
2025-09-11 6:31 [PATCH net-next 0/4] net/mlx5: Refactor devcom and add net namespace support Tariq Toukan
` (2 preceding siblings ...)
2025-09-11 6:31 ` [PATCH net-next 3/4] net/mlx5: Add net namespace support to devcom Tariq Toukan
@ 2025-09-11 6:31 ` Tariq Toukan
2025-09-12 14:09 ` Simon Horman
3 siblings, 1 reply; 12+ messages in thread
From: Tariq Toukan @ 2025-09-11 6:31 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch, netdev,
linux-rdma, linux-kernel, Gal Pressman, Parav Pandit, Shay Drory
From: Shay Drory <shayd@nvidia.com>
Update the LAG implementation to support net namespace isolation.
With recent changes to the devcom framework allowing namespace-aware
matching, the LAG layer is updated to register devcom clients with the
associated net namespace. This ensures that LAG formation only occurs
between mlx5 interfaces that reside in the same namespace.
This change ensures that devices in different namespaces do not interfere
with each other's LAG setup and behavior. For example, if two PCI PFs are
in the same namespace, they are eligible to form a hardware LAG.
In addition, reload behavior for LAG is adjusted to handle namespace
contexts appropriately.
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 5 -----
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 14 +++++++++++---
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h | 1 +
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
index a0b68321355a..bfa44414be82 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
@@ -204,11 +204,6 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
return 0;
}
- if (mlx5_lag_is_active(dev)) {
- NL_SET_ERR_MSG_MOD(extack, "reload is unsupported in Lag mode");
- return -EOPNOTSUPP;
- }
-
if (mlx5_core_is_mp_slave(dev)) {
NL_SET_ERR_MSG_MOD(extack, "reload is unsupported for multi port slave");
return -EOPNOTSUPP;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
index ccb22ed13f84..59c00c911275 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
@@ -35,6 +35,7 @@
#include <linux/mlx5/driver.h>
#include <linux/mlx5/eswitch.h>
#include <linux/mlx5/vport.h>
+#include "lib/mlx5.h"
#include "lib/devcom.h"
#include "mlx5_core.h"
#include "eswitch.h"
@@ -231,9 +232,13 @@ static void mlx5_do_bond_work(struct work_struct *work);
static void mlx5_ldev_free(struct kref *ref)
{
struct mlx5_lag *ldev = container_of(ref, struct mlx5_lag, ref);
+ struct net *net;
+
+ if (ldev->nb.notifier_call) {
+ net = read_pnet(&ldev->net);
+ unregister_netdevice_notifier_net(net, &ldev->nb);
+ }
- if (ldev->nb.notifier_call)
- unregister_netdevice_notifier_net(&init_net, &ldev->nb);
mlx5_lag_mp_cleanup(ldev);
cancel_delayed_work_sync(&ldev->bond_work);
destroy_workqueue(ldev->wq);
@@ -271,7 +276,8 @@ static struct mlx5_lag *mlx5_lag_dev_alloc(struct mlx5_core_dev *dev)
INIT_DELAYED_WORK(&ldev->bond_work, mlx5_do_bond_work);
ldev->nb.notifier_call = mlx5_lag_netdev_event;
- if (register_netdevice_notifier_net(&init_net, &ldev->nb)) {
+ write_pnet(&ldev->net, mlx5_core_net(dev));
+ if (register_netdevice_notifier_net(read_pnet(&ldev->net), &ldev->nb)) {
ldev->nb.notifier_call = NULL;
mlx5_core_err(dev, "Failed to register LAG netdev notifier\n");
}
@@ -1413,6 +1419,8 @@ static int mlx5_lag_register_hca_devcom_comp(struct mlx5_core_dev *dev)
{
struct mlx5_devcom_match_attr attr = {
.key.val = mlx5_query_nic_system_image_guid(dev),
+ .flags = MLX5_DEVCOM_MATCH_FLAGS_NS,
+ .net = mlx5_core_net(dev),
};
/* This component is use to sync adding core_dev to lag_dev and to sync
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
index c2f256bb2bc2..4918eee2b3da 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
@@ -67,6 +67,7 @@ struct mlx5_lag {
struct workqueue_struct *wq;
struct delayed_work bond_work;
struct notifier_block nb;
+ possible_net_t net;
struct lag_mp lag_mp;
struct mlx5_lag_port_sel port_sel;
/* Protect lag fields/state changes */
--
2.31.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 4/4] net/mlx5: Lag, add net namespace support
2025-09-11 6:31 ` [PATCH net-next 4/4] net/mlx5: Lag, add net namespace support Tariq Toukan
@ 2025-09-12 14:09 ` Simon Horman
2025-09-13 1:52 ` Mark Bloch
0 siblings, 1 reply; 12+ messages in thread
From: Simon Horman @ 2025-09-12 14:09 UTC (permalink / raw)
To: Tariq Toukan
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller, Saeed Mahameed, Leon Romanovsky, Mark Bloch,
netdev, linux-rdma, linux-kernel, Gal Pressman, Parav Pandit,
Shay Drory
On Thu, Sep 11, 2025 at 09:31:07AM +0300, Tariq Toukan wrote:
> From: Shay Drory <shayd@nvidia.com>
>
> Update the LAG implementation to support net namespace isolation.
>
> With recent changes to the devcom framework allowing namespace-aware
> matching, the LAG layer is updated to register devcom clients with the
> associated net namespace. This ensures that LAG formation only occurs
> between mlx5 interfaces that reside in the same namespace.
>
> This change ensures that devices in different namespaces do not interfere
> with each other's LAG setup and behavior. For example, if two PCI PFs are
> in the same namespace, they are eligible to form a hardware LAG.
>
> In addition, reload behavior for LAG is adjusted to handle namespace
> contexts appropriately.
>
> Signed-off-by: Shay Drory <shayd@nvidia.com>
> Reviewed-by: Mark Bloch <mbloch@nvidia.com>
> Reviewed-by: Parav Pandit <parav@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 5 -----
> drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 14 +++++++++++---
> drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h | 1 +
> 3 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
> index a0b68321355a..bfa44414be82 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
> @@ -204,11 +204,6 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
> return 0;
> }
>
> - if (mlx5_lag_is_active(dev)) {
> - NL_SET_ERR_MSG_MOD(extack, "reload is unsupported in Lag mode");
> - return -EOPNOTSUPP;
> - }
> -
Maybe I'm missing something obvious. But I think this could do with
some further commentary in the commit message. Or perhaps being a separate
patch.
> if (mlx5_core_is_mp_slave(dev)) {
> NL_SET_ERR_MSG_MOD(extack, "reload is unsupported for multi port slave");
> return -EOPNOTSUPP;
...
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
> index c2f256bb2bc2..4918eee2b3da 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
> @@ -67,6 +67,7 @@ struct mlx5_lag {
> struct workqueue_struct *wq;
> struct delayed_work bond_work;
> struct notifier_block nb;
> + possible_net_t net;
nit: inconsistent indentation.
> struct lag_mp lag_mp;
> struct mlx5_lag_port_sel port_sel;
> /* Protect lag fields/state changes */
> --
> 2.31.1
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 3/4] net/mlx5: Add net namespace support to devcom
2025-09-11 6:31 ` [PATCH net-next 3/4] net/mlx5: Add net namespace support to devcom Tariq Toukan
@ 2025-09-12 14:11 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2025-09-12 14:11 UTC (permalink / raw)
To: Tariq Toukan
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller, Saeed Mahameed, Leon Romanovsky, Mark Bloch,
netdev, linux-rdma, linux-kernel, Gal Pressman, Parav Pandit,
Shay Drory
On Thu, Sep 11, 2025 at 09:31:06AM +0300, Tariq Toukan wrote:
> From: Shay Drory <shayd@nvidia.com>
>
> Extend the devcom framework to support namespace-aware components.
>
> The existing devcom matching logic was based solely on numeric keys,
> limiting its use to the global (init_net) scope or requiring clients
> to ignore namespaces altogether, both of which are incorrect in
> multi-namespace environments.
>
> This patch introduces namespace support by allowing devcom clients to
> provide a namespace match attribute. The devcom pairing mechanism is
> updated to compare the namespace, enabling proper isolation and
> interaction of components across different net namespaces.
>
> With this change, components that require namespace aware pairing,
> such as SD groups or LAG, can now work correctly in multi-namespace
> scenarios. In particular, this opens the way to support hardware LAG
> within a net namespace.
>
> Signed-off-by: Shay Drory <shayd@nvidia.com>
> Reviewed-by: Mark Bloch <mbloch@nvidia.com>
> Reviewed-by: Parav Pandit <parav@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
I've reviewed this with the assumptions that; mlx5_core_net() returns the
devlink net namespace, and; that the devlink net namespace is fixed.
With those assumptions, this looks good to me.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 2/4] net/mlx5: Lag, move devcom registration to LAG layer
2025-09-11 6:31 ` [PATCH net-next 2/4] net/mlx5: Lag, move devcom registration to LAG layer Tariq Toukan
@ 2025-09-12 14:11 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2025-09-12 14:11 UTC (permalink / raw)
To: Tariq Toukan
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller, Saeed Mahameed, Leon Romanovsky, Mark Bloch,
netdev, linux-rdma, linux-kernel, Gal Pressman, Parav Pandit,
Shay Drory
On Thu, Sep 11, 2025 at 09:31:05AM +0300, Tariq Toukan wrote:
> From: Shay Drory <shayd@nvidia.com>
>
> Move the devcom registration for the HCA_PORTS component from the core
> initialization path into the LAG logic. This better reflects the
> logical ownership of this component and ensures proper alignment with
> the LAG lifecycle.
>
> Signed-off-by: Shay Drory <shayd@nvidia.com>
> Reviewed-by: Mark Bloch <mbloch@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 1/4] net/mlx5: Refactor devcom to use match attributes
2025-09-11 6:31 ` [PATCH net-next 1/4] net/mlx5: Refactor devcom to use match attributes Tariq Toukan
@ 2025-09-12 14:11 ` Simon Horman
2025-09-15 9:08 ` Leon Romanovsky
1 sibling, 0 replies; 12+ messages in thread
From: Simon Horman @ 2025-09-12 14:11 UTC (permalink / raw)
To: Tariq Toukan
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller, Saeed Mahameed, Leon Romanovsky, Mark Bloch,
netdev, linux-rdma, linux-kernel, Gal Pressman, Parav Pandit,
Shay Drory
On Thu, Sep 11, 2025 at 09:31:04AM +0300, Tariq Toukan wrote:
> From: Shay Drory <shayd@nvidia.com>
>
> Refactor the devcom interface to use a match attribute structure instead
> of passing raw keys. This change lays the groundwork for extending devcom
> matching logic with additional fields like net namespace, improving its
> flexibility and robustness.
>
> No functional changes.
>
> Signed-off-by: Shay Drory <shayd@nvidia.com>
> Reviewed-by: Mark Bloch <mbloch@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 4/4] net/mlx5: Lag, add net namespace support
2025-09-12 14:09 ` Simon Horman
@ 2025-09-13 1:52 ` Mark Bloch
2025-09-15 8:51 ` Simon Horman
0 siblings, 1 reply; 12+ messages in thread
From: Mark Bloch @ 2025-09-13 1:52 UTC (permalink / raw)
To: Simon Horman, Tariq Toukan
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller, Saeed Mahameed, Leon Romanovsky, netdev,
linux-rdma, linux-kernel, Gal Pressman, Parav Pandit, Shay Drory
On 12/09/2025 17:09, Simon Horman wrote:
> On Thu, Sep 11, 2025 at 09:31:07AM +0300, Tariq Toukan wrote:
>> From: Shay Drory <shayd@nvidia.com>
>>
>> Update the LAG implementation to support net namespace isolation.
>>
>> With recent changes to the devcom framework allowing namespace-aware
>> matching, the LAG layer is updated to register devcom clients with the
>> associated net namespace. This ensures that LAG formation only occurs
>> between mlx5 interfaces that reside in the same namespace.
>>
>> This change ensures that devices in different namespaces do not interfere
>> with each other's LAG setup and behavior. For example, if two PCI PFs are
>> in the same namespace, they are eligible to form a hardware LAG.
>>
>> In addition, reload behavior for LAG is adjusted to handle namespace
>> contexts appropriately.
>>
>> Signed-off-by: Shay Drory <shayd@nvidia.com>
>> Reviewed-by: Mark Bloch <mbloch@nvidia.com>
>> Reviewed-by: Parav Pandit <parav@nvidia.com>
>> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
>> ---
>> drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 5 -----
>> drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 14 +++++++++++---
>> drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h | 1 +
>> 3 files changed, 12 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
>> index a0b68321355a..bfa44414be82 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
>> @@ -204,11 +204,6 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
>> return 0;
>> }
>>
>> - if (mlx5_lag_is_active(dev)) {
>> - NL_SET_ERR_MSG_MOD(extack, "reload is unsupported in Lag mode");
>> - return -EOPNOTSUPP;
>> - }
>> -
>
> Maybe I'm missing something obvious. But I think this could do with
> some further commentary in the commit message. Or perhaps being a separate
> patch.
While one could split this into two patches, first enabling LAG creation
within a namespace, then separately removing the devlink reload restriction
that separation feels artificial.
Both changes are required to deliver complete support for LAG in namespaces
Since removing the reload restriction is a trivial change, it is better
to deliver the entire feature in this single patch.
Will clarify and add this justification to the commit message.
>
>> if (mlx5_core_is_mp_slave(dev)) {
>> NL_SET_ERR_MSG_MOD(extack, "reload is unsupported for multi port slave");
>> return -EOPNOTSUPP;
>
> ...
>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
>> index c2f256bb2bc2..4918eee2b3da 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h
>> @@ -67,6 +67,7 @@ struct mlx5_lag {
>> struct workqueue_struct *wq;
>> struct delayed_work bond_work;
>> struct notifier_block nb;
>> + possible_net_t net;
>
> nit: inconsistent indentation.
I prefer to avoid vertical alignment. I find that style
is often brittle and makes the code harder to maintain
over time.
Thanks for the review!
Mark
>
>> struct lag_mp lag_mp;
>> struct mlx5_lag_port_sel port_sel;
>> /* Protect lag fields/state changes */
>> --
>> 2.31.1
>>
>>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 4/4] net/mlx5: Lag, add net namespace support
2025-09-13 1:52 ` Mark Bloch
@ 2025-09-15 8:51 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2025-09-15 8:51 UTC (permalink / raw)
To: Mark Bloch
Cc: Tariq Toukan, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andrew Lunn, David S. Miller, Saeed Mahameed, Leon Romanovsky,
netdev, linux-rdma, linux-kernel, Gal Pressman, Parav Pandit,
Shay Drory
On Sat, Sep 13, 2025 at 04:52:17AM +0300, Mark Bloch wrote:
>
>
> On 12/09/2025 17:09, Simon Horman wrote:
> > On Thu, Sep 11, 2025 at 09:31:07AM +0300, Tariq Toukan wrote:
> >> From: Shay Drory <shayd@nvidia.com>
> >>
> >> Update the LAG implementation to support net namespace isolation.
> >>
> >> With recent changes to the devcom framework allowing namespace-aware
> >> matching, the LAG layer is updated to register devcom clients with the
> >> associated net namespace. This ensures that LAG formation only occurs
> >> between mlx5 interfaces that reside in the same namespace.
> >>
> >> This change ensures that devices in different namespaces do not interfere
> >> with each other's LAG setup and behavior. For example, if two PCI PFs are
> >> in the same namespace, they are eligible to form a hardware LAG.
> >>
> >> In addition, reload behavior for LAG is adjusted to handle namespace
> >> contexts appropriately.
> >>
> >> Signed-off-by: Shay Drory <shayd@nvidia.com>
> >> Reviewed-by: Mark Bloch <mbloch@nvidia.com>
> >> Reviewed-by: Parav Pandit <parav@nvidia.com>
> >> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> >> ---
> >> drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 5 -----
> >> drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 14 +++++++++++---
> >> drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h | 1 +
> >> 3 files changed, 12 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
> >> index a0b68321355a..bfa44414be82 100644
> >> --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
> >> +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
> >> @@ -204,11 +204,6 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
> >> return 0;
> >> }
> >>
> >> - if (mlx5_lag_is_active(dev)) {
> >> - NL_SET_ERR_MSG_MOD(extack, "reload is unsupported in Lag mode");
> >> - return -EOPNOTSUPP;
> >> - }
> >> -
> >
> > Maybe I'm missing something obvious. But I think this could do with
> > some further commentary in the commit message. Or perhaps being a separate
> > patch.
>
> While one could split this into two patches, first enabling LAG creation
> within a namespace, then separately removing the devlink reload restriction
> that separation feels artificial.
>
> Both changes are required to deliver complete support for LAG in namespaces
> Since removing the reload restriction is a trivial change, it is better
> to deliver the entire feature in this single patch.
>
> Will clarify and add this justification to the commit message.
Thanks, much appreciated.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 1/4] net/mlx5: Refactor devcom to use match attributes
2025-09-11 6:31 ` [PATCH net-next 1/4] net/mlx5: Refactor devcom to use match attributes Tariq Toukan
2025-09-12 14:11 ` Simon Horman
@ 2025-09-15 9:08 ` Leon Romanovsky
1 sibling, 0 replies; 12+ messages in thread
From: Leon Romanovsky @ 2025-09-15 9:08 UTC (permalink / raw)
To: Tariq Toukan
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller, Saeed Mahameed, Mark Bloch, netdev, linux-rdma,
linux-kernel, Gal Pressman, Parav Pandit, Shay Drory
On Thu, Sep 11, 2025 at 09:31:04AM +0300, Tariq Toukan wrote:
> From: Shay Drory <shayd@nvidia.com>
>
> Refactor the devcom interface to use a match attribute structure instead
> of passing raw keys. This change lays the groundwork for extending devcom
> matching logic with additional fields like net namespace, improving its
> flexibility and robustness.
>
> No functional changes.
>
> Signed-off-by: Shay Drory <shayd@nvidia.com>
> Reviewed-by: Mark Bloch <mbloch@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
> .../net/ethernet/mellanox/mlx5/core/en_main.c | 6 +++-
> .../net/ethernet/mellanox/mlx5/core/en_tc.c | 7 +++--
> .../net/ethernet/mellanox/mlx5/core/eswitch.h | 7 +++--
> .../mellanox/mlx5/core/eswitch_offloads.c | 5 +--
> .../ethernet/mellanox/mlx5/core/lib/clock.c | 14 ++++++---
> .../ethernet/mellanox/mlx5/core/lib/devcom.c | 31 +++++++++++++------
> .../ethernet/mellanox/mlx5/core/lib/devcom.h | 10 +++++-
> .../net/ethernet/mellanox/mlx5/core/lib/sd.c | 4 ++-
> .../net/ethernet/mellanox/mlx5/core/main.c | 7 +++--
> 9 files changed, 65 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index 714cce595692..fe5f5ae433b7 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -235,9 +235,13 @@ static int mlx5e_devcom_event_mpv(int event, void *my_data, void *event_data)
>
> static int mlx5e_devcom_init_mpv(struct mlx5e_priv *priv, u64 *data)
> {
> + struct mlx5_devcom_match_attr attr = {
> + .key.val = *data,
> + };
> +
> priv->devcom = mlx5_devcom_register_component(priv->mdev->priv.devc,
> MLX5_DEVCOM_MPV,
> - *data,
> + &attr,
> mlx5e_devcom_event_mpv,
> priv);
> if (IS_ERR(priv->devcom))
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 32c07a8b03d1..9874a15c6fba 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -5387,12 +5387,13 @@ void mlx5e_tc_ht_cleanup(struct rhashtable *tc_ht)
> int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv)
> {
> const size_t sz_enc_opts = sizeof(struct tunnel_match_enc_opts);
> + struct mlx5_devcom_match_attr attr = {};
> struct netdev_phys_item_id ppid;
> struct mlx5e_rep_priv *rpriv;
> struct mapping_ctx *mapping;
> struct mlx5_eswitch *esw;
> struct mlx5e_priv *priv;
> - u64 mapping_id, key;
> + u64 mapping_id;
> int err = 0;
>
> rpriv = container_of(uplink_priv, struct mlx5e_rep_priv, uplink_priv);
> @@ -5448,8 +5449,8 @@ int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv)
>
> err = netif_get_port_parent_id(priv->netdev, &ppid, false);
> if (!err) {
> - memcpy(&key, &ppid.id, sizeof(key));
> - mlx5_esw_offloads_devcom_init(esw, key);
> + memcpy(&attr.key.val, &ppid.id, sizeof(attr.key.val));
> + mlx5_esw_offloads_devcom_init(esw, &attr);
> }
>
> return 0;
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
> index 4fe285ce32aa..df3756d7e52e 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
> @@ -433,7 +433,8 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs);
> void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw, bool clear_vf);
> void mlx5_eswitch_disable_locked(struct mlx5_eswitch *esw);
> void mlx5_eswitch_disable(struct mlx5_eswitch *esw);
> -void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw, u64 key);
> +void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw,
> + const struct mlx5_devcom_match_attr *attr);
> void mlx5_esw_offloads_devcom_cleanup(struct mlx5_eswitch *esw);
> bool mlx5_esw_offloads_devcom_is_ready(struct mlx5_eswitch *esw);
> int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
> @@ -928,7 +929,9 @@ static inline void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw) {}
> static inline int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) { return 0; }
> static inline void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw, bool clear_vf) {}
> static inline void mlx5_eswitch_disable(struct mlx5_eswitch *esw) {}
> -static inline void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw, u64 key) {}
> +static inline void
> +mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw,
> + const struct mlx5_devcom_match_attr *attr) {}
> static inline void mlx5_esw_offloads_devcom_cleanup(struct mlx5_eswitch *esw) {}
> static inline bool mlx5_esw_offloads_devcom_is_ready(struct mlx5_eswitch *esw) { return false; }
> static inline bool mlx5_eswitch_is_funcs_handler(struct mlx5_core_dev *dev) { return false; }
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> index d57f86d297ab..bc9838dc5bf8 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> @@ -3104,7 +3104,8 @@ static int mlx5_esw_offloads_devcom_event(int event,
> return err;
> }
>
> -void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw, u64 key)
> +void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw,
> + const struct mlx5_devcom_match_attr *attr)
> {
> int i;
>
> @@ -3123,7 +3124,7 @@ void mlx5_esw_offloads_devcom_init(struct mlx5_eswitch *esw, u64 key)
> esw->num_peers = 0;
> esw->devcom = mlx5_devcom_register_component(esw->dev->priv.devc,
> MLX5_DEVCOM_ESW_OFFLOADS,
> - key,
> + attr,
> mlx5_esw_offloads_devcom_event,
> esw);
> if (IS_ERR(esw->devcom))
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
> index 7ad3baca99de..8f2ad45bec9f 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
> @@ -1435,14 +1435,20 @@ static int mlx5_clock_alloc(struct mlx5_core_dev *mdev, bool shared)
> static void mlx5_shared_clock_register(struct mlx5_core_dev *mdev, u64 key)
> {
> struct mlx5_core_dev *peer_dev, *next = NULL;
> + struct mlx5_devcom_match_attr attr = {
> + .key.val = key,
> + };
> + struct mlx5_devcom_comp_dev *compd;
> struct mlx5_devcom_comp_dev *pos;
>
> - mdev->clock_state->compdev = mlx5_devcom_register_component(mdev->priv.devc,
> - MLX5_DEVCOM_SHARED_CLOCK,
> - key, NULL, mdev);
> - if (IS_ERR(mdev->clock_state->compdev))
> + compd = mlx5_devcom_register_component(mdev->priv.devc,
> + MLX5_DEVCOM_SHARED_CLOCK,
> + &attr, NULL, mdev);
> + if (IS_ERR(compd))
> return;
>
> + mdev->clock_state->compdev = compd;
> +
> mlx5_devcom_comp_lock(mdev->clock_state->compdev);
> mlx5_devcom_for_each_peer_entry(mdev->clock_state->compdev, peer_dev, pos) {
> if (peer_dev->clock) {
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
> index 7b0766c89f4c..1ab9de316deb 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
> @@ -22,11 +22,15 @@ struct mlx5_devcom_dev {
> struct kref ref;
> };
>
> +struct mlx5_devcom_key {
> + union mlx5_devcom_match_key key;
> +};
> +
> struct mlx5_devcom_comp {
> struct list_head comp_list;
> enum mlx5_devcom_component id;
> - u64 key;
> struct list_head comp_dev_list_head;
> + struct mlx5_devcom_key key;
> mlx5_devcom_event_handler_t handler;
> struct kref ref;
> bool ready;
> @@ -108,7 +112,8 @@ void mlx5_devcom_unregister_device(struct mlx5_devcom_dev *devc)
> }
>
> static struct mlx5_devcom_comp *
> -mlx5_devcom_comp_alloc(u64 id, u64 key, mlx5_devcom_event_handler_t handler)
> +mlx5_devcom_comp_alloc(u64 id, const struct mlx5_devcom_match_attr *attr,
> + mlx5_devcom_event_handler_t handler)
> {
> struct mlx5_devcom_comp *comp;
>
> @@ -117,7 +122,7 @@ mlx5_devcom_comp_alloc(u64 id, u64 key, mlx5_devcom_event_handler_t handler)
> return ERR_PTR(-ENOMEM);
>
> comp->id = id;
> - comp->key = key;
> + comp->key.key = attr->key;
> comp->handler = handler;
> init_rwsem(&comp->sem);
> lockdep_register_key(&comp->lock_key);
> @@ -180,21 +185,27 @@ devcom_free_comp_dev(struct mlx5_devcom_comp_dev *devcom)
> static bool
> devcom_component_equal(struct mlx5_devcom_comp *devcom,
> enum mlx5_devcom_component id,
> - u64 key)
> + const struct mlx5_devcom_match_attr *attr)
> {
> - return devcom->id == id && devcom->key == key;
> + if (devcom->id != id)
> + return false;
> +
> + if (memcmp(&devcom->key.key, &attr->key, sizeof(devcom->key.key)))
> + return false;
> +
> + return true;
> }
>
> static struct mlx5_devcom_comp *
> devcom_component_get(struct mlx5_devcom_dev *devc,
> enum mlx5_devcom_component id,
> - u64 key,
> + const struct mlx5_devcom_match_attr *attr,
> mlx5_devcom_event_handler_t handler)
> {
> struct mlx5_devcom_comp *comp;
>
> devcom_for_each_component(comp) {
> - if (devcom_component_equal(comp, id, key)) {
> + if (devcom_component_equal(comp, id, attr)) {
> if (handler == comp->handler) {
> kref_get(&comp->ref);
> return comp;
> @@ -212,7 +223,7 @@ devcom_component_get(struct mlx5_devcom_dev *devc,
> struct mlx5_devcom_comp_dev *
> mlx5_devcom_register_component(struct mlx5_devcom_dev *devc,
> enum mlx5_devcom_component id,
> - u64 key,
> + const struct mlx5_devcom_match_attr *attr,
> mlx5_devcom_event_handler_t handler,
> void *data)
> {
> @@ -223,14 +234,14 @@ mlx5_devcom_register_component(struct mlx5_devcom_dev *devc,
> return ERR_PTR(-EINVAL);
>
> mutex_lock(&comp_list_lock);
> - comp = devcom_component_get(devc, id, key, handler);
> + comp = devcom_component_get(devc, id, attr, handler);
> if (IS_ERR(comp)) {
> devcom = ERR_PTR(-EINVAL);
> goto out_unlock;
> }
>
> if (!comp) {
> - comp = mlx5_devcom_comp_alloc(id, key, handler);
> + comp = mlx5_devcom_comp_alloc(id, attr, handler);
> if (IS_ERR(comp)) {
> devcom = ERR_CAST(comp);
> goto out_unlock;
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
> index c79699b94a02..f350d2395707 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
> @@ -6,6 +6,14 @@
>
> #include <linux/mlx5/driver.h>
>
> +union mlx5_devcom_match_key {
> + u64 val;
> +};
> +
> +struct mlx5_devcom_match_attr {
> + union mlx5_devcom_match_key key;
> +};
> +
> enum mlx5_devcom_component {
> MLX5_DEVCOM_ESW_OFFLOADS,
> MLX5_DEVCOM_MPV,
> @@ -25,7 +33,7 @@ void mlx5_devcom_unregister_device(struct mlx5_devcom_dev *devc);
> struct mlx5_devcom_comp_dev *
> mlx5_devcom_register_component(struct mlx5_devcom_dev *devc,
> enum mlx5_devcom_component id,
> - u64 key,
> + const struct mlx5_devcom_match_attr *attr,
> mlx5_devcom_event_handler_t handler,
> void *data);
> void mlx5_devcom_unregister_component(struct mlx5_devcom_comp_dev *devcom);
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
> index eeb0b7ea05f1..d4015328ba65 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
> @@ -210,13 +210,15 @@ static void sd_cleanup(struct mlx5_core_dev *dev)
> static int sd_register(struct mlx5_core_dev *dev)
> {
> struct mlx5_devcom_comp_dev *devcom, *pos;
> + struct mlx5_devcom_match_attr attr = {};
> struct mlx5_core_dev *peer, *primary;
> struct mlx5_sd *sd, *primary_sd;
> int err, i;
>
> sd = mlx5_get_sd(dev);
> + attr.key.val = sd->group_id;
> devcom = mlx5_devcom_register_component(dev->priv.devc, MLX5_DEVCOM_SD_GROUP,
> - sd->group_id, NULL, dev);
> + &attr, NULL, dev);
> if (IS_ERR(devcom))
> return PTR_ERR(devcom);
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
> index 0951c7cc1b5f..1f7942202e14 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
> @@ -975,6 +975,10 @@ static void mlx5_pci_close(struct mlx5_core_dev *dev)
>
> static void mlx5_register_hca_devcom_comp(struct mlx5_core_dev *dev)
> {
> + struct mlx5_devcom_match_attr attr = {
> + .key.val = mlx5_query_nic_system_image_guid(dev),
> + };
> +
> /* This component is use to sync adding core_dev to lag_dev and to sync
> * changes of mlx5_adev_devices between LAG layer and other layers.
> */
> @@ -983,8 +987,7 @@ static void mlx5_register_hca_devcom_comp(struct mlx5_core_dev *dev)
>
> dev->priv.hca_devcom_comp =
> mlx5_devcom_register_component(dev->priv.devc, MLX5_DEVCOM_HCA_PORTS,
> - mlx5_query_nic_system_image_guid(dev),
> - NULL, dev);
> + &attr, NULL, dev);
> if (IS_ERR(dev->priv.hca_devcom_comp))
Because you are changing mlx5_devcom_register_component() signature
anyway, please do one step more and make sure that mlx5_devcom_register_component()
returns or NULL or successful devcom pointer. The thing is that devcom
pointer has error code which is stored for whole lifetime of the driver
is causing issues in mlx5_ib IPsec cleanup for multi-port devices.
Thanks
> mlx5_core_err(dev, "Failed to register devcom HCA component\n");
> }
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-09-15 9:08 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11 6:31 [PATCH net-next 0/4] net/mlx5: Refactor devcom and add net namespace support Tariq Toukan
2025-09-11 6:31 ` [PATCH net-next 1/4] net/mlx5: Refactor devcom to use match attributes Tariq Toukan
2025-09-12 14:11 ` Simon Horman
2025-09-15 9:08 ` Leon Romanovsky
2025-09-11 6:31 ` [PATCH net-next 2/4] net/mlx5: Lag, move devcom registration to LAG layer Tariq Toukan
2025-09-12 14:11 ` Simon Horman
2025-09-11 6:31 ` [PATCH net-next 3/4] net/mlx5: Add net namespace support to devcom Tariq Toukan
2025-09-12 14:11 ` Simon Horman
2025-09-11 6:31 ` [PATCH net-next 4/4] net/mlx5: Lag, add net namespace support Tariq Toukan
2025-09-12 14:09 ` Simon Horman
2025-09-13 1:52 ` Mark Bloch
2025-09-15 8:51 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).