Skip to content

Commit

Permalink
net/mlx5: DR, handle more than one peer domain
Browse files Browse the repository at this point in the history
Currently, DR domain is using the assumption that each domain can only
have a single peer.
In order to support VF LAG of more then two ports, expand peer domain
to use an array of peers, and align the code accordingly.

Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Shay Drory authored and Saeed Mahameed committed Jun 2, 2023
1 parent 014e4d4 commit 6d5b732
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 30 deletions.
12 changes: 7 additions & 5 deletions drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
Original file line number Diff line number Diff line change
Expand Up @@ -2778,26 +2778,28 @@ 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);
struct mlx5_flow_root_namespace *peer_ns;
u8 idx = mlx5_get_dev_index(esw->dev);
struct mlx5_flow_root_namespace *ns;
int err;

peer_ns = peer_esw->dev->priv.steering->fdb_root_ns;
ns = esw->dev->priv.steering->fdb_root_ns;

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

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

return 0;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ 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)
struct mlx5_flow_root_namespace *peer_ns,
u8 peer_idx)
{
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ struct mlx5_flow_cmds {
struct mlx5_modify_hdr *modify_hdr);

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

int (*create_ns)(struct mlx5_flow_root_namespace *ns);
int (*destroy_ns)(struct mlx5_flow_root_namespace *ns);
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3620,15 +3620,16 @@ 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)
struct mlx5_flow_root_namespace *peer_ns,
u8 peer_idx)
{
if (peer_ns && ns->mode != peer_ns->mode) {
mlx5_core_err(ns->dev,
"Can't peer namespace of different steering mode\n");
return -EINVAL;
}

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

/* This function should be called only at init stage of the namespace.
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ void mlx5_fc_update_sampling_interval(struct mlx5_core_dev *dev,
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);
struct mlx5_flow_root_namespace *peer_ns,
u8 peer_idx);

int mlx5_flow_namespace_set_mode(struct mlx5_flow_namespace *ns,
enum mlx5_flow_steering_mode mode);
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
Original file line number Diff line number Diff line change
Expand Up @@ -2071,8 +2071,9 @@ mlx5dr_action_create_dest_vport(struct mlx5dr_domain *dmn,
struct mlx5dr_action *action;
u8 peer_vport;

peer_vport = vhca_id_valid && (vhca_id != dmn->info.caps.gvmi);
vport_dmn = peer_vport ? dmn->peer_dmn : dmn;
peer_vport = vhca_id_valid && mlx5_core_is_pf(dmn->mdev) &&
(vhca_id != dmn->info.caps.gvmi);
vport_dmn = peer_vport ? dmn->peer_dmn[vhca_id] : dmn;
if (!vport_dmn) {
mlx5dr_dbg(dmn, "No peer vport domain for given vhca_id\n");
return NULL;
Expand Down
13 changes: 7 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,17 +555,18 @@ int mlx5dr_domain_destroy(struct mlx5dr_domain *dmn)
}

void mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,
struct mlx5dr_domain *peer_dmn)
struct mlx5dr_domain *peer_dmn,
u8 peer_idx)
{
mlx5dr_domain_lock(dmn);

if (dmn->peer_dmn)
refcount_dec(&dmn->peer_dmn->refcount);
if (dmn->peer_dmn[peer_idx])
refcount_dec(&dmn->peer_dmn[peer_idx]->refcount);

dmn->peer_dmn = peer_dmn;
dmn->peer_dmn[peer_idx] = peer_dmn;

if (dmn->peer_dmn)
refcount_inc(&dmn->peer_dmn->refcount);
if (dmn->peer_dmn[peer_idx])
refcount_inc(&dmn->peer_dmn[peer_idx]->refcount);

mlx5dr_domain_unlock(dmn);
}
9 changes: 5 additions & 4 deletions drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,7 @@ dr_ste_v0_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,
u8 *tag)
{
struct mlx5dr_match_misc *misc = &value->misc;
int id = misc->source_eswitch_owner_vhca_id;
struct mlx5dr_cmd_vport_cap *vport_cap;
struct mlx5dr_domain *dmn = sb->dmn;
struct mlx5dr_domain *vport_dmn;
Expand All @@ -1657,11 +1658,11 @@ dr_ste_v0_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,

if (sb->vhca_id_valid) {
/* Find port GVMI based on the eswitch_owner_vhca_id */
if (misc->source_eswitch_owner_vhca_id == dmn->info.caps.gvmi)
if (id == dmn->info.caps.gvmi)
vport_dmn = dmn;
else if (dmn->peer_dmn && (misc->source_eswitch_owner_vhca_id ==
dmn->peer_dmn->info.caps.gvmi))
vport_dmn = dmn->peer_dmn;
else if (id < MLX5_MAX_PORTS && dmn->peer_dmn[id] &&
(id == dmn->peer_dmn[id]->info.caps.gvmi))
vport_dmn = dmn->peer_dmn[id];
else
return -EINVAL;

Expand Down
9 changes: 5 additions & 4 deletions drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,7 @@ static int dr_ste_v1_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,
u8 *tag)
{
struct mlx5dr_match_misc *misc = &value->misc;
int id = misc->source_eswitch_owner_vhca_id;
struct mlx5dr_cmd_vport_cap *vport_cap;
struct mlx5dr_domain *dmn = sb->dmn;
struct mlx5dr_domain *vport_dmn;
Expand All @@ -1988,11 +1989,11 @@ static int dr_ste_v1_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,

if (sb->vhca_id_valid) {
/* Find port GVMI based on the eswitch_owner_vhca_id */
if (misc->source_eswitch_owner_vhca_id == dmn->info.caps.gvmi)
if (id == dmn->info.caps.gvmi)
vport_dmn = dmn;
else if (dmn->peer_dmn && (misc->source_eswitch_owner_vhca_id ==
dmn->peer_dmn->info.caps.gvmi))
vport_dmn = dmn->peer_dmn;
else if (id < MLX5_MAX_PORTS && dmn->peer_dmn[id] &&
(id == dmn->peer_dmn[id]->info.caps.gvmi))
vport_dmn = dmn->peer_dmn[id];
else
return -EINVAL;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ struct mlx5dr_domain_info {
};

struct mlx5dr_domain {
struct mlx5dr_domain *peer_dmn;
struct mlx5dr_domain *peer_dmn[MLX5_MAX_PORTS];
struct mlx5_core_dev *mdev;
u32 pdn;
struct mlx5_uars_page *uar;
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,14 +770,15 @@ static int mlx5_cmd_dr_update_fte(struct mlx5_flow_root_namespace *ns,
}

static int mlx5_cmd_dr_set_peer(struct mlx5_flow_root_namespace *ns,
struct mlx5_flow_root_namespace *peer_ns)
struct mlx5_flow_root_namespace *peer_ns,
u8 peer_idx)
{
struct mlx5dr_domain *peer_domain = NULL;

if (peer_ns)
peer_domain = peer_ns->fs_dr_domain.dr_domain;
mlx5dr_domain_set_peer(ns->fs_dr_domain.dr_domain,
peer_domain);
peer_domain, peer_idx);
return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ int mlx5dr_domain_destroy(struct mlx5dr_domain *domain);
int mlx5dr_domain_sync(struct mlx5dr_domain *domain, u32 flags);

void mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,
struct mlx5dr_domain *peer_dmn);
struct mlx5dr_domain *peer_dmn,
u8 peer_idx);

struct mlx5dr_table *
mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level, u32 flags,
Expand Down

0 comments on commit 6d5b732

Please sign in to comment.