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
1641 } else {1641 } else {
1642 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);1642 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
1643 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);1643 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);
1645 }1646 }
1646 1647
1647 if (err)1648 if (err)
@@ -1683,7 +1684,6 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw) · 35 unmodified lines
1683{1684{
1684 struct esw_mc_addr *mc_promisc;1685 struct esw_mc_addr *mc_promisc;
1685 int old_mode;1686 int old_mode;
1686 int nvports;
1687 int i;1687 int i;
1688 1688
1689 if (!ESW_ALLOWED(esw) || esw->mode == SRIOV_NONE)1689 if (!ESW_ALLOWED(esw) || esw->mode == SRIOV_NONE)
@@ -1693,7 +1693,6 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw) · 3 unmodified lines
1693 esw->enabled_vports, esw->mode);1693 esw->enabled_vports, esw->mode);
1694 1694
1695 mc_promisc = &esw->mc_promisc;1695 mc_promisc = &esw->mc_promisc;
1696 nvports = esw->enabled_vports;
1697 1696
1698 if (esw->mode == SRIOV_LEGACY)1697 if (esw->mode == SRIOV_LEGACY)
1699 mlx5_eq_notifier_unregister(esw->dev, &esw->nb);1698 mlx5_eq_notifier_unregister(esw->dev, &esw->nb);
@@ -1709,7 +1708,7 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw) · 9 unmodified lines
1709 if (esw->mode == SRIOV_LEGACY)1708 if (esw->mode == SRIOV_LEGACY)
1710 esw_destroy_legacy_fdb_table(esw);1709 esw_destroy_legacy_fdb_table(esw);
1711 else if (esw->mode == SRIOV_OFFLOADS)1710 else if (esw->mode == SRIOV_OFFLOADS)
1712 esw_offloads_cleanup(esw, nvports);1711 esw_offloads_cleanup(esw);
1713 1712
1714 old_mode = esw->mode;1713 old_mode = esw->mode;
1715 esw->mode = SRIOV_NONE;1714 esw->mode = SRIOV_NONE;
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h+3−2
@@ -208,8 +208,9 @@ struct mlx5_eswitch { · 207 unmodified lines
208 u16 manager_vport;208 u16 manager_vport;
209};209};
210 210
211void esw_offloads_cleanup(struct mlx5_eswitch *esw, int nvports);211void esw_offloads_cleanup(struct mlx5_eswitch *esw);
212int esw_offloads_init(struct mlx5_eswitch *esw, int nvports);212int esw_offloads_init(struct mlx5_eswitch *esw, int vf_nvports,
213 int total_nvports);
213void esw_offloads_cleanup_reps(struct mlx5_eswitch *esw);214void esw_offloads_cleanup_reps(struct mlx5_eswitch *esw);
214int esw_offloads_init_reps(struct mlx5_eswitch *esw);215int esw_offloads_init_reps(struct mlx5_eswitch *esw);
215 216
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c+41−16
@@ -54,6 +54,8 @@ enum { · 53 unmodified lines
54#define fdb_prio_table(esw, chain, prio, level) \54#define fdb_prio_table(esw, chain, prio, level) \
55 (esw)->fdb_table.offloads.fdb_prio[(chain)][(prio)][(level)]55 (esw)->fdb_table.offloads.fdb_prio[(chain)][(prio)][(level)]
56 56
57#define UPLINK_REP_INDEX 0
58
57static struct mlx5_flow_table *59static struct mlx5_flow_table *
58esw_get_prio_table(struct mlx5_eswitch *esw, u32 chain, u16 prio, int level);60esw_get_prio_table(struct mlx5_eswitch *esw, u32 chain, u16 prio, int level);
59static void61static void
@@ -1239,19 +1241,28 @@ int esw_offloads_init_reps(struct mlx5_eswitch *esw) · 1179 unmodified lines
1239 return 0;1241 return 0;
1240}1242}
1241 1243
1244static 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
1242static void esw_offloads_unload_reps_type(struct mlx5_eswitch *esw, int nvports,1253static void esw_offloads_unload_reps_type(struct mlx5_eswitch *esw, int nvports,
1243 u8 rep_type)1254 u8 rep_type)
1244{1255{
1245 struct mlx5_eswitch_rep *rep;1256 struct mlx5_eswitch_rep *rep;
1246 int vport;1257 int vport;
1247 1258
1248 for (vport = nvports - 1; vport >= 0; vport--) {1259 for (vport = nvports; vport >= MLX5_VPORT_FIRST_VF; vport--) {
1249 rep = &esw->offloads.vport_reps[vport];1260 rep = &esw->offloads.vport_reps[vport];
1250 if (!rep->rep_if[rep_type].valid)1261 __esw_offloads_unload_rep(esw, rep, rep_type);
1251 continue;
1252
1253 rep->rep_if[rep_type].unload(rep);
1254 }1262 }
1263
1264 rep = &esw->offloads.vport_reps[UPLINK_REP_INDEX];
1265 __esw_offloads_unload_rep(esw, rep, rep_type);
1255}1266}
1256 1267
1257static void esw_offloads_unload_reps(struct mlx5_eswitch *esw, int nvports)1268static 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
1262 esw_offloads_unload_reps_type(esw, nvports, rep_type);1273 esw_offloads_unload_reps_type(esw, nvports, rep_type);
1263}1274}
1264 1275
1276static 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
1265static int esw_offloads_load_reps_type(struct mlx5_eswitch *esw, int nvports,1285static int esw_offloads_load_reps_type(struct mlx5_eswitch *esw, int nvports,
1266 u8 rep_type)1286 u8 rep_type)
1267{1287{
@@ -1269,12 +1289,14 @@ static int esw_offloads_load_reps_type(struct mlx5_eswitch *esw, int nvports, · 1 unmodified line
1269 int vport;1289 int vport;
1270 int err;1290 int err;
1271 1291
1272 for (vport = 0; vport < nvports; vport++) {1292 rep = &esw->offloads.vport_reps[UPLINK_REP_INDEX];
1273 rep = &esw->offloads.vport_reps[vport];1293 err = __esw_offloads_load_rep(esw, rep, rep_type);
1274 if (!rep->rep_if[rep_type].valid)1294 if (err)
1275 continue;1295 goto out;
1276 1296
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);
1278 if (err)1300 if (err)
1279 goto err_reps;1301 goto err_reps;
1280 }1302 }
@@ -1283,6 +1305,7 @@ static int esw_offloads_load_reps_type(struct mlx5_eswitch *esw, int nvports, · 2 unmodified lines
1283 1305
1284err_reps:1306err_reps:
1285 esw_offloads_unload_reps_type(esw, vport, rep_type);1307 esw_offloads_unload_reps_type(esw, vport, rep_type);
1308out:
1286 return err;1309 return err;
1287}1310}
1288 1311
@@ -1440,17 +1463,18 @@ static void esw_offloads_steering_cleanup(struct mlx5_eswitch *esw) · 151 unmodified lines
1440 esw_destroy_offloads_fdb_tables(esw);1463 esw_destroy_offloads_fdb_tables(esw);
1441}1464}
1442 1465
1443int esw_offloads_init(struct mlx5_eswitch *esw, int nvports)1466int esw_offloads_init(struct mlx5_eswitch *esw, int vf_nvports,
1467 int total_nvports)
1444{1468{
1445 int err;1469 int err;
1446 1470
1447 mutex_init(&esw->fdb_table.offloads.fdb_prio_lock);1471 mutex_init(&esw->fdb_table.offloads.fdb_prio_lock);
1448 1472
1449 err = esw_offloads_steering_init(esw, nvports);1473 err = esw_offloads_steering_init(esw, total_nvports);
1450 if (err)1474 if (err)
1451 return err;1475 return err;
1452 1476
1453 err = esw_offloads_load_reps(esw, nvports);1477 err = esw_offloads_load_reps(esw, vf_nvports);
1454 if (err)1478 if (err)
1455 goto err_reps;1479 goto err_reps;
1456 1480
@@ -1481,10 +1505,12 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw, · 24 unmodified lines
1481 return err;1505 return err;
1482}1506}
1483 1507
1484void esw_offloads_cleanup(struct mlx5_eswitch *esw, int nvports)1508void esw_offloads_cleanup(struct mlx5_eswitch *esw)
1485{1509{
1510 u16 num_vfs = esw->dev->priv.sriov.num_vfs;
1511
1486 esw_offloads_devcom_cleanup(esw);1512 esw_offloads_devcom_cleanup(esw);
1487 esw_offloads_unload_reps(esw, nvports);1513 esw_offloads_unload_reps(esw, num_vfs);
1488 esw_offloads_steering_cleanup(esw);1514 esw_offloads_steering_cleanup(esw);
1489}1515}
1490 1516
@@ -1822,7 +1848,6 @@ EXPORT_SYMBOL(mlx5_eswitch_unregister_vport_rep); · 331 unmodified lines
1822 1848
1823void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type)1849void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type)
1824{1850{
1825#define UPLINK_REP_INDEX 0
1826 struct mlx5_esw_offload *offloads = &esw->offloads;1851 struct mlx5_esw_offload *offloads = &esw->offloads;
1827 struct mlx5_eswitch_rep *rep;1852 struct mlx5_eswitch_rep *rep;
1828 1853
include/linux/mlx5/vport.h+1−0
@@ -53,6 +53,7 @@ enum { · 52 unmodified lines
53 53
54enum {54enum {
55 MLX5_VPORT_PF = 0x0,55 MLX5_VPORT_PF = 0x0,
56 MLX5_VPORT_FIRST_VF = 0x1,
56 MLX5_VPORT_ECPF = 0xfffe,57 MLX5_VPORT_ECPF = 0xfffe,
57 MLX5_VPORT_UPLINK = 0xffff58 MLX5_VPORT_UPLINK = 0xffff
58};59};

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