Commit 739d911c authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-mlx5-refactor-devcom-and-add-net-namespace-support'

Tariq Toukan says:

====================
net/mlx5: Refactor devcom and add net namespace support

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.
====================

Link: https://patch.msgid.link/1757940070-618661-1-git-send-email-tariqt@nvidia.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 7cfbe1c3 d654d3fc
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -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;
+5 −1
Original line number Diff line number Diff line
@@ -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))
+7 −3
Original line number Diff line number Diff line
@@ -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"
@@ -5387,12 +5388,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 +5450,10 @@ 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));
		attr.flags = MLX5_DEVCOM_MATCH_FLAGS_NS;
		attr.net = mlx5_core_net(esw->dev);
		mlx5_esw_offloads_devcom_init(esw, &attr);
	}

	return 0;
+5 −2
Original line number Diff line number Diff line
@@ -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; }
+3 −2
Original line number Diff line number Diff line
@@ -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))
Loading