Skip to content

Commit d666675

Browse files
Saeed Mahameeddavem330
authored andcommitted
net/mlx5: E-Switch, Introduce HCA cap and E-Switch vport context
E-Switch vport context is unlike NIC vport context, managed by the E-Switch manager or vport_group_manager and not by the NIC(VF) driver. The E-Switch manager can access (read/modify) any of its vports E-Switch context. Currently E-Switch vport context includes only clietnt and server vlan insertion and striping data (for later support of VST mode). Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7725657 commit d666675

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,17 @@ int mlx5_query_hca_caps(struct mlx5_core_dev *dev)
173173
return err;
174174
}
175175

176+
if (MLX5_CAP_GEN(dev, vport_group_manager)) {
177+
err = mlx5_core_get_caps(dev, MLX5_CAP_ESWITCH,
178+
HCA_CAP_OPMOD_GET_CUR);
179+
if (err)
180+
return err;
181+
err = mlx5_core_get_caps(dev, MLX5_CAP_ESWITCH,
182+
HCA_CAP_OPMOD_GET_MAX);
183+
if (err)
184+
return err;
185+
}
186+
176187
return 0;
177188
}
178189

include/linux/mlx5/device.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ enum mlx5_cap_type {
11451145
MLX5_CAP_EOIB_OFFLOADS,
11461146
MLX5_CAP_FLOW_TABLE,
11471147
MLX5_CAP_ESWITCH_FLOW_TABLE,
1148+
MLX5_CAP_ESWITCH,
11481149
/* NUM OF CAP Types */
11491150
MLX5_CAP_NUM
11501151
};
@@ -1196,6 +1197,14 @@ enum mlx5_cap_type {
11961197
#define MLX5_CAP_ESW_FLOWTABLE_FDB_MAX(mdev, cap) \
11971198
MLX5_CAP_ESW_FLOWTABLE_MAX(mdev, flow_table_properties_nic_esw_fdb.cap)
11981199

1200+
#define MLX5_CAP_ESW(mdev, cap) \
1201+
MLX5_GET(e_switch_cap, \
1202+
mdev->hca_caps_cur[MLX5_CAP_ESWITCH], cap)
1203+
1204+
#define MLX5_CAP_ESW_MAX(mdev, cap) \
1205+
MLX5_GET(e_switch_cap, \
1206+
mdev->hca_caps_max[MLX5_CAP_ESWITCH], cap)
1207+
11991208
#define MLX5_CAP_ODP(mdev, cap)\
12001209
MLX5_GET(odp_cap, mdev->hca_caps_cur[MLX5_CAP_ODP], cap)
12011210

include/linux/mlx5/mlx5_ifc.h

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,17 @@ struct mlx5_ifc_flow_table_eswitch_cap_bits {
459459
u8 reserved_1[0x7800];
460460
};
461461

462+
struct mlx5_ifc_e_switch_cap_bits {
463+
u8 vport_svlan_strip[0x1];
464+
u8 vport_cvlan_strip[0x1];
465+
u8 vport_svlan_insert[0x1];
466+
u8 vport_cvlan_insert_if_not_exist[0x1];
467+
u8 vport_cvlan_insert_overwrite[0x1];
468+
u8 reserved_0[0x1b];
469+
470+
u8 reserved_1[0x7e0];
471+
};
472+
462473
struct mlx5_ifc_per_protocol_networking_offload_caps_bits {
463474
u8 csum_cap[0x1];
464475
u8 vlan_cap[0x1];
@@ -1860,6 +1871,7 @@ union mlx5_ifc_hca_cap_union_bits {
18601871
struct mlx5_ifc_per_protocol_networking_offload_caps_bits per_protocol_networking_offload_caps;
18611872
struct mlx5_ifc_flow_table_nic_cap_bits flow_table_nic_cap;
18621873
struct mlx5_ifc_flow_table_eswitch_cap_bits flow_table_eswitch_cap;
1874+
struct mlx5_ifc_e_switch_cap_bits e_switch_cap;
18631875
u8 reserved_0[0x8000];
18641876
};
18651877

@@ -2305,6 +2317,26 @@ struct mlx5_ifc_hca_vport_context_bits {
23052317
u8 reserved_6[0xca0];
23062318
};
23072319

2320+
struct mlx5_ifc_esw_vport_context_bits {
2321+
u8 reserved_0[0x3];
2322+
u8 vport_svlan_strip[0x1];
2323+
u8 vport_cvlan_strip[0x1];
2324+
u8 vport_svlan_insert[0x1];
2325+
u8 vport_cvlan_insert[0x2];
2326+
u8 reserved_1[0x18];
2327+
2328+
u8 reserved_2[0x20];
2329+
2330+
u8 svlan_cfi[0x1];
2331+
u8 svlan_pcp[0x3];
2332+
u8 svlan_id[0xc];
2333+
u8 cvlan_cfi[0x1];
2334+
u8 cvlan_pcp[0x3];
2335+
u8 cvlan_id[0xc];
2336+
2337+
u8 reserved_3[0x7a0];
2338+
};
2339+
23082340
enum {
23092341
MLX5_EQC_STATUS_OK = 0x0,
23102342
MLX5_EQC_STATUS_EQ_WRITE_FAILURE = 0xa,
@@ -3743,6 +3775,64 @@ struct mlx5_ifc_query_flow_group_in_bits {
37433775
u8 reserved_5[0x120];
37443776
};
37453777

3778+
struct mlx5_ifc_query_esw_vport_context_out_bits {
3779+
u8 status[0x8];
3780+
u8 reserved_0[0x18];
3781+
3782+
u8 syndrome[0x20];
3783+
3784+
u8 reserved_1[0x40];
3785+
3786+
struct mlx5_ifc_esw_vport_context_bits esw_vport_context;
3787+
};
3788+
3789+
struct mlx5_ifc_query_esw_vport_context_in_bits {
3790+
u8 opcode[0x10];
3791+
u8 reserved_0[0x10];
3792+
3793+
u8 reserved_1[0x10];
3794+
u8 op_mod[0x10];
3795+
3796+
u8 other_vport[0x1];
3797+
u8 reserved_2[0xf];
3798+
u8 vport_number[0x10];
3799+
3800+
u8 reserved_3[0x20];
3801+
};
3802+
3803+
struct mlx5_ifc_modify_esw_vport_context_out_bits {
3804+
u8 status[0x8];
3805+
u8 reserved_0[0x18];
3806+
3807+
u8 syndrome[0x20];
3808+
3809+
u8 reserved_1[0x40];
3810+
};
3811+
3812+
struct mlx5_ifc_esw_vport_context_fields_select_bits {
3813+
u8 reserved[0x1c];
3814+
u8 vport_cvlan_insert[0x1];
3815+
u8 vport_svlan_insert[0x1];
3816+
u8 vport_cvlan_strip[0x1];
3817+
u8 vport_svlan_strip[0x1];
3818+
};
3819+
3820+
struct mlx5_ifc_modify_esw_vport_context_in_bits {
3821+
u8 opcode[0x10];
3822+
u8 reserved_0[0x10];
3823+
3824+
u8 reserved_1[0x10];
3825+
u8 op_mod[0x10];
3826+
3827+
u8 other_vport[0x1];
3828+
u8 reserved_2[0xf];
3829+
u8 vport_number[0x10];
3830+
3831+
struct mlx5_ifc_esw_vport_context_fields_select_bits field_select;
3832+
3833+
struct mlx5_ifc_esw_vport_context_bits esw_vport_context;
3834+
};
3835+
37463836
struct mlx5_ifc_query_eq_out_bits {
37473837
u8 status[0x8];
37483838
u8 reserved_0[0x18];

0 commit comments

Comments
 (0)