Commit f05a82fb authored by Shay Drory's avatar Shay Drory Committed by Jakub Kicinski
Browse files

net/mlx5: Refactor devcom to use match attributes



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: default avatarShay Drory <shayd@nvidia.com>
Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/1757940070-618661-2-git-send-email-tariqt@nvidia.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7cfbe1c3
Loading
Loading
Loading
Loading
+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))
+4 −3
Original line number Diff line number Diff line
@@ -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;
+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))
+10 −4
Original line number Diff line number Diff line
@@ -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,
	compd = mlx5_devcom_register_component(mdev->priv.devc,
					       MLX5_DEVCOM_SHARED_CLOCK,
								    key, NULL, mdev);
	if (IS_ERR(mdev->clock_state->compdev))
					       &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) {
Loading