Commit 62752c0b authored by Shay Drory's avatar Shay Drory Committed by Saeed Mahameed
Browse files

net/mlx5: DR, Fix peer domain namespace setting



The offending patch is based on the assumption that for PFs,
mlx5_get_dev_index() is the same as vhca_id. However, this assumption
is wrong in case of DPU (ECPF).
Fix it by using vhca_id directly, and switch the array of peers to
xarray.

Fixes: 6d5b7321 ("net/mlx5: DR, handle more than one peer domain")
Signed-off-by: default avatarShay Drory <shayd@nvidia.com>
Reviewed-by: default avatarYevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 61eab651
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -2778,9 +2778,9 @@ static int mlx5_esw_offloads_set_ns_peer(struct mlx5_eswitch *esw,
					 struct mlx5_eswitch *peer_esw,
					 bool pair)
{
	u8 peer_idx = mlx5_get_dev_index(peer_esw->dev);
	u16 peer_vhca_id = MLX5_CAP_GEN(peer_esw->dev, vhca_id);
	u16 vhca_id = MLX5_CAP_GEN(esw->dev, vhca_id);
	struct mlx5_flow_root_namespace *peer_ns;
	u8 idx = mlx5_get_dev_index(esw->dev);
	struct mlx5_flow_root_namespace *ns;
	int err;

@@ -2788,18 +2788,18 @@ static int mlx5_esw_offloads_set_ns_peer(struct mlx5_eswitch *esw,
	ns = esw->dev->priv.steering->fdb_root_ns;

	if (pair) {
		err = mlx5_flow_namespace_set_peer(ns, peer_ns, peer_idx);
		err = mlx5_flow_namespace_set_peer(ns, peer_ns, peer_vhca_id);
		if (err)
			return err;

		err = mlx5_flow_namespace_set_peer(peer_ns, ns, idx);
		err = mlx5_flow_namespace_set_peer(peer_ns, ns, vhca_id);
		if (err) {
			mlx5_flow_namespace_set_peer(ns, NULL, peer_idx);
			mlx5_flow_namespace_set_peer(ns, NULL, peer_vhca_id);
			return err;
		}
	} else {
		mlx5_flow_namespace_set_peer(ns, NULL, peer_idx);
		mlx5_flow_namespace_set_peer(peer_ns, NULL, idx);
		mlx5_flow_namespace_set_peer(ns, NULL, peer_vhca_id);
		mlx5_flow_namespace_set_peer(peer_ns, NULL, vhca_id);
	}

	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ static void mlx5_cmd_stub_modify_header_dealloc(struct mlx5_flow_root_namespace

static int mlx5_cmd_stub_set_peer(struct mlx5_flow_root_namespace *ns,
				  struct mlx5_flow_root_namespace *peer_ns,
				  u8 peer_idx)
				  u16 peer_vhca_id)
{
	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ struct mlx5_flow_cmds {

	int (*set_peer)(struct mlx5_flow_root_namespace *ns,
			struct mlx5_flow_root_namespace *peer_ns,
			u8 peer_idx);
			u16 peer_vhca_id);

	int (*create_ns)(struct mlx5_flow_root_namespace *ns);
	int (*destroy_ns)(struct mlx5_flow_root_namespace *ns);
+2 −2
Original line number Diff line number Diff line
@@ -3621,7 +3621,7 @@ void mlx5_destroy_match_definer(struct mlx5_core_dev *dev,

int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
				 struct mlx5_flow_root_namespace *peer_ns,
				 u8 peer_idx)
				 u16 peer_vhca_id)
{
	if (peer_ns && ns->mode != peer_ns->mode) {
		mlx5_core_err(ns->dev,
@@ -3629,7 +3629,7 @@ int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
		return -EINVAL;
	}

	return ns->cmds->set_peer(ns, peer_ns, peer_idx);
	return ns->cmds->set_peer(ns, peer_ns, peer_vhca_id);
}

/* This function should be called only at init stage of the namespace.
+1 −1
Original line number Diff line number Diff line
@@ -303,7 +303,7 @@ const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void);

int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
				 struct mlx5_flow_root_namespace *peer_ns,
				 u8 peer_idx);
				 u16 peer_vhca_id);

int mlx5_flow_namespace_set_mode(struct mlx5_flow_namespace *ns,
				 enum mlx5_flow_steering_mode mode);
Loading