* Set up multiple TISs with different affinities according to * number of bonding ports * * @param priv * Pointer of shared context. * * @return * Zero on success, -1 otherwise. */
| 1305 | * Zero on success, -1 otherwise. |
| 1306 | */ |
| 1307 | static int |
| 1308 | mlx5_setup_tis(struct mlx5_dev_ctx_shared *sh) |
| 1309 | { |
| 1310 | struct mlx5_devx_lag_context lag_ctx = { 0 }; |
| 1311 | struct mlx5_devx_tis_attr tis_attr = { 0 }; |
| 1312 | int i; |
| 1313 | |
| 1314 | tis_attr.transport_domain = sh->td->id; |
| 1315 | if (sh->bond.n_port) { |
| 1316 | if (!mlx5_devx_cmd_query_lag(sh->cdev->ctx, &lag_ctx)) { |
| 1317 | sh->lag.tx_remap_affinity[0] = |
| 1318 | lag_ctx.tx_remap_affinity_1; |
| 1319 | sh->lag.tx_remap_affinity[1] = |
| 1320 | lag_ctx.tx_remap_affinity_2; |
| 1321 | sh->lag.affinity_mode = lag_ctx.port_select_mode; |
| 1322 | } else { |
| 1323 | DRV_LOG(ERR, "Failed to query lag affinity."); |
| 1324 | return -1; |
| 1325 | } |
| 1326 | if (sh->lag.affinity_mode == MLX5_LAG_MODE_TIS) |
| 1327 | DRV_LOG(DEBUG, "LAG number of ports : %d, affinity_1 & 2 : pf%d & %d.\n", |
| 1328 | sh->bond.n_port, lag_ctx.tx_remap_affinity_1, |
| 1329 | lag_ctx.tx_remap_affinity_2); |
| 1330 | else if (sh->lag.affinity_mode == MLX5_LAG_MODE_HASH) |
| 1331 | DRV_LOG(INFO, "Device %s enabled HW hash based LAG.", |
| 1332 | sh->ibdev_name); |
| 1333 | } |
| 1334 | for (i = 0; i <= sh->bond.n_port; i++) { |
| 1335 | /* |
| 1336 | * lag_tx_port_affinity: 0 auto-selection, 1 PF1, 2 PF2 vice versa. |
| 1337 | * Each TIS binds to one PF by setting lag_tx_port_affinity (> 0). |
| 1338 | * Once LAG enabled, we create multiple TISs and bind each one to |
| 1339 | * different PFs, then TIS[i+1] gets affinity i+1 and goes to PF i+1. |
| 1340 | * TIS[0] is reserved for HW Hash mode. |
| 1341 | */ |
| 1342 | tis_attr.lag_tx_port_affinity = i; |
| 1343 | sh->tis[i] = mlx5_devx_cmd_create_tis(sh->cdev->ctx, &tis_attr); |
| 1344 | if (!sh->tis[i]) { |
| 1345 | DRV_LOG(ERR, "Failed to create TIS %d/%d for [bonding] device" |
| 1346 | " %s.", i, sh->bond.n_port, |
| 1347 | sh->ibdev_name); |
| 1348 | return -1; |
| 1349 | } |
| 1350 | } |
| 1351 | return 0; |
| 1352 | } |
| 1353 | |
| 1354 | /** |
| 1355 | * Verify and store value for share device argument. |
no test coverage detected