| @@ -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 | |
| 57 | static struct mlx5_flow_table * | 59 | static struct mlx5_flow_table * |
| 58 | esw_get_prio_table(struct mlx5_eswitch *esw, u32 chain, u16 prio, int level); | 60 | esw_get_prio_table(struct mlx5_eswitch *esw, u32 chain, u16 prio, int level); |
| 59 | static void | 61 | static 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 | |
| | 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 | |
| 1242 | static void esw_offloads_unload_reps_type(struct mlx5_eswitch *esw, int nvports, | 1253 | static 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 | |
| 1257 | static void esw_offloads_unload_reps(struct mlx5_eswitch *esw, int nvports) | 1268 | 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 |
| 1262 | esw_offloads_unload_reps_type(esw, nvports, rep_type); | 1273 | esw_offloads_unload_reps_type(esw, nvports, rep_type); |
| 1263 | } | 1274 | } |
| 1264 | | 1275 | |
| | 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 | |
| 1265 | static int esw_offloads_load_reps_type(struct mlx5_eswitch *esw, int nvports, | 1285 | static 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 | |
| 1284 | err_reps: | 1306 | err_reps: |
| 1285 | esw_offloads_unload_reps_type(esw, vport, rep_type); | 1307 | esw_offloads_unload_reps_type(esw, vport, rep_type); |
| | 1308 | out: |
| 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 | |
| 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) |
| 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 | |
| 1484 | void esw_offloads_cleanup(struct mlx5_eswitch *esw, int nvports) | 1508 | void 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 | |
| 1823 | void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type) | 1849 | void *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 | |