Skip to content

Commit 62752c0

Browse files
shayshyiSaeed Mahameed
authored andcommitted
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: 6d5b732 ("net/mlx5: DR, handle more than one peer domain") Signed-off-by: Shay Drory <[email protected]> Reviewed-by: Yevgeny Kliteynik <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 61eab65 commit 62752c0

File tree

12 files changed

+38
-29
lines changed

12 files changed

+38
-29
lines changed

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,28 +2778,28 @@ static int mlx5_esw_offloads_set_ns_peer(struct mlx5_eswitch *esw,
27782778
struct mlx5_eswitch *peer_esw,
27792779
bool pair)
27802780
{
2781-
u8 peer_idx = mlx5_get_dev_index(peer_esw->dev);
2781+
u16 peer_vhca_id = MLX5_CAP_GEN(peer_esw->dev, vhca_id);
2782+
u16 vhca_id = MLX5_CAP_GEN(esw->dev, vhca_id);
27822783
struct mlx5_flow_root_namespace *peer_ns;
2783-
u8 idx = mlx5_get_dev_index(esw->dev);
27842784
struct mlx5_flow_root_namespace *ns;
27852785
int err;
27862786

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

27902790
if (pair) {
2791-
err = mlx5_flow_namespace_set_peer(ns, peer_ns, peer_idx);
2791+
err = mlx5_flow_namespace_set_peer(ns, peer_ns, peer_vhca_id);
27922792
if (err)
27932793
return err;
27942794

2795-
err = mlx5_flow_namespace_set_peer(peer_ns, ns, idx);
2795+
err = mlx5_flow_namespace_set_peer(peer_ns, ns, vhca_id);
27962796
if (err) {
2797-
mlx5_flow_namespace_set_peer(ns, NULL, peer_idx);
2797+
mlx5_flow_namespace_set_peer(ns, NULL, peer_vhca_id);
27982798
return err;
27992799
}
28002800
} else {
2801-
mlx5_flow_namespace_set_peer(ns, NULL, peer_idx);
2802-
mlx5_flow_namespace_set_peer(peer_ns, NULL, idx);
2801+
mlx5_flow_namespace_set_peer(ns, NULL, peer_vhca_id);
2802+
mlx5_flow_namespace_set_peer(peer_ns, NULL, vhca_id);
28032803
}
28042804

28052805
return 0;

drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static void mlx5_cmd_stub_modify_header_dealloc(struct mlx5_flow_root_namespace
140140

141141
static int mlx5_cmd_stub_set_peer(struct mlx5_flow_root_namespace *ns,
142142
struct mlx5_flow_root_namespace *peer_ns,
143-
u8 peer_idx)
143+
u16 peer_vhca_id)
144144
{
145145
return 0;
146146
}

drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct mlx5_flow_cmds {
9494

9595
int (*set_peer)(struct mlx5_flow_root_namespace *ns,
9696
struct mlx5_flow_root_namespace *peer_ns,
97-
u8 peer_idx);
97+
u16 peer_vhca_id);
9898

9999
int (*create_ns)(struct mlx5_flow_root_namespace *ns);
100100
int (*destroy_ns)(struct mlx5_flow_root_namespace *ns);

drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,15 +3621,15 @@ void mlx5_destroy_match_definer(struct mlx5_core_dev *dev,
36213621

36223622
int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
36233623
struct mlx5_flow_root_namespace *peer_ns,
3624-
u8 peer_idx)
3624+
u16 peer_vhca_id)
36253625
{
36263626
if (peer_ns && ns->mode != peer_ns->mode) {
36273627
mlx5_core_err(ns->dev,
36283628
"Can't peer namespace of different steering mode\n");
36293629
return -EINVAL;
36303630
}
36313631

3632-
return ns->cmds->set_peer(ns, peer_ns, peer_idx);
3632+
return ns->cmds->set_peer(ns, peer_ns, peer_vhca_id);
36333633
}
36343634

36353635
/* This function should be called only at init stage of the namespace.

drivers/net/ethernet/mellanox/mlx5/core/fs_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void);
303303

304304
int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
305305
struct mlx5_flow_root_namespace *peer_ns,
306-
u8 peer_idx);
306+
u16 peer_vhca_id);
307307

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

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2079,7 +2079,7 @@ mlx5dr_action_create_dest_vport(struct mlx5dr_domain *dmn,
20792079

20802080
peer_vport = vhca_id_valid && mlx5_core_is_pf(dmn->mdev) &&
20812081
(vhca_id != dmn->info.caps.gvmi);
2082-
vport_dmn = peer_vport ? dmn->peer_dmn[vhca_id] : dmn;
2082+
vport_dmn = peer_vport ? xa_load(&dmn->peer_dmn_xa, vhca_id) : dmn;
20832083
if (!vport_dmn) {
20842084
mlx5dr_dbg(dmn, "No peer vport domain for given vhca_id\n");
20852085
return NULL;

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ mlx5dr_domain_create(struct mlx5_core_dev *mdev, enum mlx5dr_domain_type type)
475475
mutex_init(&dmn->info.rx.mutex);
476476
mutex_init(&dmn->info.tx.mutex);
477477
xa_init(&dmn->definers_xa);
478+
xa_init(&dmn->peer_dmn_xa);
478479

479480
if (dr_domain_caps_init(mdev, dmn)) {
480481
mlx5dr_err(dmn, "Failed init domain, no caps\n");
@@ -507,6 +508,7 @@ mlx5dr_domain_create(struct mlx5_core_dev *mdev, enum mlx5dr_domain_type type)
507508
uninit_caps:
508509
dr_domain_caps_uninit(dmn);
509510
def_xa_destroy:
511+
xa_destroy(&dmn->peer_dmn_xa);
510512
xa_destroy(&dmn->definers_xa);
511513
kfree(dmn);
512514
return NULL;
@@ -547,6 +549,7 @@ int mlx5dr_domain_destroy(struct mlx5dr_domain *dmn)
547549
dr_domain_uninit_csum_recalc_fts(dmn);
548550
dr_domain_uninit_resources(dmn);
549551
dr_domain_caps_uninit(dmn);
552+
xa_destroy(&dmn->peer_dmn_xa);
550553
xa_destroy(&dmn->definers_xa);
551554
mutex_destroy(&dmn->info.tx.mutex);
552555
mutex_destroy(&dmn->info.rx.mutex);
@@ -556,17 +559,21 @@ int mlx5dr_domain_destroy(struct mlx5dr_domain *dmn)
556559

557560
void mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,
558561
struct mlx5dr_domain *peer_dmn,
559-
u8 peer_idx)
562+
u16 peer_vhca_id)
560563
{
564+
struct mlx5dr_domain *peer;
565+
561566
mlx5dr_domain_lock(dmn);
562567

563-
if (dmn->peer_dmn[peer_idx])
564-
refcount_dec(&dmn->peer_dmn[peer_idx]->refcount);
568+
peer = xa_load(&dmn->peer_dmn_xa, peer_vhca_id);
569+
if (peer)
570+
refcount_dec(&peer->refcount);
565571

566-
dmn->peer_dmn[peer_idx] = peer_dmn;
572+
WARN_ON(xa_err(xa_store(&dmn->peer_dmn_xa, peer_vhca_id, peer_dmn, GFP_KERNEL)));
567573

568-
if (dmn->peer_dmn[peer_idx])
569-
refcount_inc(&dmn->peer_dmn[peer_idx]->refcount);
574+
peer = xa_load(&dmn->peer_dmn_xa, peer_vhca_id);
575+
if (peer)
576+
refcount_inc(&peer->refcount);
570577

571578
mlx5dr_domain_unlock(dmn);
572579
}

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,17 +1652,18 @@ dr_ste_v0_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,
16521652
struct mlx5dr_domain *dmn = sb->dmn;
16531653
struct mlx5dr_domain *vport_dmn;
16541654
u8 *bit_mask = sb->bit_mask;
1655+
struct mlx5dr_domain *peer;
16551656
bool source_gvmi_set;
16561657

16571658
DR_STE_SET_TAG(src_gvmi_qp, tag, source_qp, misc, source_sqn);
16581659

16591660
if (sb->vhca_id_valid) {
1661+
peer = xa_load(&dmn->peer_dmn_xa, id);
16601662
/* Find port GVMI based on the eswitch_owner_vhca_id */
16611663
if (id == dmn->info.caps.gvmi)
16621664
vport_dmn = dmn;
1663-
else if (id < MLX5_MAX_PORTS && dmn->peer_dmn[id] &&
1664-
(id == dmn->peer_dmn[id]->info.caps.gvmi))
1665-
vport_dmn = dmn->peer_dmn[id];
1665+
else if (peer && (id == peer->info.caps.gvmi))
1666+
vport_dmn = peer;
16661667
else
16671668
return -EINVAL;
16681669

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,16 +1984,17 @@ static int dr_ste_v1_build_src_gvmi_qpn_tag(struct mlx5dr_match_param *value,
19841984
struct mlx5dr_domain *dmn = sb->dmn;
19851985
struct mlx5dr_domain *vport_dmn;
19861986
u8 *bit_mask = sb->bit_mask;
1987+
struct mlx5dr_domain *peer;
19871988

19881989
DR_STE_SET_TAG(src_gvmi_qp_v1, tag, source_qp, misc, source_sqn);
19891990

19901991
if (sb->vhca_id_valid) {
1992+
peer = xa_load(&dmn->peer_dmn_xa, id);
19911993
/* Find port GVMI based on the eswitch_owner_vhca_id */
19921994
if (id == dmn->info.caps.gvmi)
19931995
vport_dmn = dmn;
1994-
else if (id < MLX5_MAX_PORTS && dmn->peer_dmn[id] &&
1995-
(id == dmn->peer_dmn[id]->info.caps.gvmi))
1996-
vport_dmn = dmn->peer_dmn[id];
1996+
else if (peer && (id == peer->info.caps.gvmi))
1997+
vport_dmn = peer;
19971998
else
19981999
return -EINVAL;
19992000

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,6 @@ struct mlx5dr_domain_info {
935935
};
936936

937937
struct mlx5dr_domain {
938-
struct mlx5dr_domain *peer_dmn[MLX5_MAX_PORTS];
939938
struct mlx5_core_dev *mdev;
940939
u32 pdn;
941940
struct mlx5_uars_page *uar;
@@ -956,6 +955,7 @@ struct mlx5dr_domain {
956955
struct list_head dbg_tbl_list;
957956
struct mlx5dr_dbg_dump_info dump_info;
958957
struct xarray definers_xa;
958+
struct xarray peer_dmn_xa;
959959
/* memory management statistics */
960960
u32 num_buddies[DR_ICM_TYPE_MAX];
961961
};

0 commit comments

Comments
 (0)