History

net/mlx5: E-Switch, Split VF and special vports for offloads mode

When driver is entering offloads mode, there are two major tasks to do: initialize flow steering and create representors. Flow steering should make sure enough flow table/group spaces are reserved for all reps. Representors will be created in a group, all or none. With the introduction of ECPF, flow steering should still reserve the same spaces. But, the representors are not always loaded/unloaded in a single piece. Once ECPF is in offloads mode, it will get the number of VF changing event from host PF. In such scenario, only the VF reps should be loaded/unloaded, not the reps for special vports (such as the uplink vport). Thus, when entering offloads mode, driver should specify the total number of reps, and the number of VF reps separately. When leaving offloads mode, the cleanup should use the information self-contained in eswitch such as number of VFs. This patch doesn't change any functionality.

Bodong Wang committed 7 years ago

Commit c9b99ab1 parent eca8cc34 files · +48 −22Browse files

Unified · Split

4 files
  1. drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +3 −4
  2. drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +3 −2
  3. drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +41 −16
  4. include/linux/mlx5/vport.h +1 −0
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c+3−4
@@ -1641,7 +1641,8 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode) · 1640 unmodified lines
16411641 } else {
16421642 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
16431643 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
1644− err = esw_offloads_init(esw, nvfs + MLX5_SPECIAL_VPORTS);
1644+ err = esw_offloads_init(esw, nvfs,
1645+ nvfs + MLX5_SPECIAL_VPORTS);
16451646 }
16461647
16471648 if (err)
@@ -1683,7 +1684,6 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw) · 35 unmodified lines
16831684 {
16841685 struct esw_mc_addr *mc_promisc;
16851686 int old_mode;
1686− int nvports;
16871687 int i;
16881688
16891689 if (!ESW_ALLOWED(esw) || esw->mode == SRIOV_NONE)
@@ -1693,7 +1693,6 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw) · 3 unmodified lines
16931693 esw->enabled_vports, esw->mode);
16941694
16951695 mc_promisc = &esw->mc_promisc;
1696− nvports = esw->enabled_vports;
16971696
16981697 if (esw->mode == SRIOV_LEGACY)
16991698 mlx5_eq_notifier_unregister(esw->dev, &esw->nb);
@@ -1709,7 +1708,7 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw) · 9 unmodified lines
17091708 if (esw->mode == SRIOV_LEGACY)
17101709 esw_destroy_legacy_fdb_table(esw);
17111710 else if (esw->mode == SRIOV_OFFLOADS)
1712− esw_offloads_cleanup(esw, nvports);
1711+ esw_offloads_cleanup(esw);
17131712
17141713 old_mode = esw->mode;
17151714 esw->mode = SRIOV_NONE;
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h+3−2
@@ -208,8 +208,9 @@ struct mlx5_eswitch { · 207 unmodified lines
208208 u16 manager_vport;
209209 };
210210
211−void esw_offloads_cleanup(struct mlx5_eswitch *esw, int nvports);
212−int esw_offloads_init(struct mlx5_eswitch *esw, int nvports);
211+void esw_offloads_cleanup(struct mlx5_eswitch *esw);
212+int esw_offloads_init(struct mlx5_eswitch *esw, int vf_nvports,
213+ int total_nvports);
213214 void esw_offloads_cleanup_reps(struct mlx5_eswitch *esw);
214215 int esw_offloads_init_reps(struct mlx5_eswitch *esw);
215216
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c+41−16
@@ -54,6 +54,8 @@ enum { · 53 unmodified lines
5454 #define fdb_prio_table(esw, chain, prio, level) \
5555 (esw)->fdb_table.offloads.fdb_prio[(chain)][(prio)][(level)]
5656
57+#define UPLINK_REP_INDEX 0
58+
5759 static struct mlx5_flow_table *
5860 esw_get_prio_table(struct mlx5_eswitch *esw, u32 chain, u16 prio, int level);
5961 static void
@@ -1239,19 +1241,28 @@ int esw_offloads_init_reps(struct mlx5_eswitch *esw) · 1179 unmodified lines
12391241 return 0;
12401242 }
12411243
1244+static void __esw_offloads_unload_rep(struct mlx5_eswitch *esw,
1245+ struct mlx5_eswitch_rep *rep, u8 rep_type)
1246+{
1247+ if (!rep->rep_if[rep_type].valid)
1248+ return;
1249+
1250+ rep->rep_if[rep_type].unload(rep);
1251+}
1252+
12421253 static void esw_offloads_unload_reps_type(struct mlx5_eswitch *esw, int nvports,
12431254 u8 rep_type)
12441255 {
12451256 struct mlx5_eswitch_rep *rep;
12461257 int vport;
12471258
1248− for (vport = nvports - 1; vport >= 0; vport--) {
1259+ for (vport = nvports; vport >= MLX5_VPORT_FIRST_VF; vport--) {
12491260 rep = &esw->offloads.vport_reps[vport];
1250− if (!rep->rep_if[rep_type].valid)
1251− continue;
1252−
1253− rep->rep_if[rep_type].unload(rep);
1261+ __esw_offloads_unload_rep(esw, rep, rep_type);
12541262 }
1263+
1264+ rep = &esw->offloads.vport_reps[UPLINK_REP_INDEX];
1265+ __esw_offloads_unload_rep(esw, rep, rep_type);
12551266 }
12561267
12571268 static void esw_offloads_unload_reps(struct mlx5_eswitch *esw, int nvports)
@@ -1262,6 +1273,15 @@ static void esw_offloads_unload_reps(struct mlx5_eswitch *esw, int nvports) · 4 unmodified lines
12621273 esw_offloads_unload_reps_type(esw, nvports, rep_type);
12631274 }
12641275
1276+static int __esw_offloads_load_rep(struct mlx5_eswitch *esw,
1277+ struct mlx5_eswitch_rep *rep, u8 rep_type)
1278+{
1279+ if (!rep->rep_if[rep_type].valid)
1280+ return 0;
1281+
1282+ return rep->rep_if[rep_type].load(esw->dev, rep);
1283+}
1284+
12651285 static int esw_offloads_load_reps_type(struct mlx5_eswitch *esw, int nvports,
12661286 u8 rep_type)
12671287 {
@@ -1269,12 +1289,14 @@ static int esw_offloads_load_reps_type(struct mlx5_eswitch *esw, int nvports, · 1 unmodified line
12691289 int vport;
12701290 int err;
12711291
1272− for (vport = 0; vport < nvports; vport++) {
1273− rep = &esw->offloads.vport_reps[vport];
1274− if (!rep->rep_if[rep_type].valid)
1275− continue;
1292+ rep = &esw->offloads.vport_reps[UPLINK_REP_INDEX];
1293+ err = __esw_offloads_load_rep(esw, rep, rep_type);
1294+ if (err)
1295+ goto out;
12761296
1277− err = rep->rep_if[rep_type].load(esw->dev, rep);
1297+ for (vport = MLX5_VPORT_FIRST_VF; vport <= nvports; vport++) {
1298+ rep = &esw->offloads.vport_reps[vport];
1299+ err = __esw_offloads_load_rep(esw, rep, rep_type);
12781300 if (err)
12791301 goto err_reps;
12801302 }
@@ -1283,6 +1305,7 @@ static int esw_offloads_load_reps_type(struct mlx5_eswitch *esw, int nvports, · 2 unmodified lines
12831305
12841306 err_reps:
12851307 esw_offloads_unload_reps_type(esw, vport, rep_type);
1308+out:
12861309 return err;
12871310 }
12881311
@@ -1440,17 +1463,18 @@ static void esw_offloads_steering_cleanup(struct mlx5_eswitch *esw) · 151 unmodified lines
14401463 esw_destroy_offloads_fdb_tables(esw);
14411464 }
14421465
1443−int esw_offloads_init(struct mlx5_eswitch *esw, int nvports)
1466+int esw_offloads_init(struct mlx5_eswitch *esw, int vf_nvports,
1467+ int total_nvports)
14441468 {
14451469 int err;
14461470
14471471 mutex_init(&esw->fdb_table.offloads.fdb_prio_lock);
14481472
1449− err = esw_offloads_steering_init(esw, nvports);
1473+ err = esw_offloads_steering_init(esw, total_nvports);
14501474 if (err)
14511475 return err;
14521476
1453− err = esw_offloads_load_reps(esw, nvports);
1477+ err = esw_offloads_load_reps(esw, vf_nvports);
14541478 if (err)
14551479 goto err_reps;
14561480
@@ -1481,10 +1505,12 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw, · 24 unmodified lines
14811505 return err;
14821506 }
14831507
1484−void esw_offloads_cleanup(struct mlx5_eswitch *esw, int nvports)
1508+void esw_offloads_cleanup(struct mlx5_eswitch *esw)
14851509 {
1510+ u16 num_vfs = esw->dev->priv.sriov.num_vfs;
1511+
14861512 esw_offloads_devcom_cleanup(esw);
1487− esw_offloads_unload_reps(esw, nvports);
1513+ esw_offloads_unload_reps(esw, num_vfs);
14881514 esw_offloads_steering_cleanup(esw);
14891515 }
14901516
@@ -1822,7 +1848,6 @@ EXPORT_SYMBOL(mlx5_eswitch_unregister_vport_rep); · 331 unmodified lines
18221848
18231849 void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type)
18241850 {
1825−#define UPLINK_REP_INDEX 0
18261851 struct mlx5_esw_offload *offloads = &esw->offloads;
18271852 struct mlx5_eswitch_rep *rep;
18281853
include/linux/mlx5/vport.h+1−0
@@ -53,6 +53,7 @@ enum { · 52 unmodified lines
5353
5454 enum {
5555 MLX5_VPORT_PF = 0x0,
56+ MLX5_VPORT_FIRST_VF = 0x1,
5657 MLX5_VPORT_ECPF = 0xfffe,
5758 MLX5_VPORT_UPLINK = 0xffff
5859 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t