On BlueField with a single uplink and host PF, representor port names
omit the controller index. A local representor (pf0vf0, controller 0)
and a host representor (c1pf0vf0, controller 1) with the same index
were both named <BDF>_representor_vf0. Whichever was probed first took
the name. Probing the other one returned EEXIST, which is treated as
already spawned, so the attach succeeded silently without a new port.
Add controller and PF indexes to the names of local representors on
BlueField, detected by the presence of a host PF, for example
<BDF>_representor_c0pf0vf0 and <BDF>_representor_c0pf0sf0.
Host representor names are unchanged.
Also log a notice when a requested representor is already spawned,
so that probing it again is no longer silent.
Fixes: cb95feefdd03 ("net/mlx5: support sub-function representor")
Cc: [email protected]
Signed-off-by: Bing Zhao <[email protected]>
Acked-by: Dariusz Sosnowski <[email protected]>
---
drivers/net/mlx5/linux/mlx5_os.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 4c35737292..82a8ad549b 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -1081,6 +1081,12 @@ is_hpf(const struct mlx5_dev_spawn_data *spawn)
spawn->info.name_type == MLX5_PHYS_PORT_NAME_TYPE_PFHPF;
}
+static bool
+is_bluefield_local_representor(const struct mlx5_dev_spawn_data *spawn)
+{
+ return spawn->info.representor && spawn->info.ctrl_num == 0 &&
spawn->nb_hpfs > 0;
+}
+
static int
build_port_name(struct rte_device *dpdk_dev,
struct mlx5_dev_spawn_data *spawn,
@@ -1130,12 +1136,14 @@ build_port_name(struct rte_device *dpdk_dev,
* 1. Device is a bond (VF-LAG).
* 2. There are multiple uplinks (MPESW).
* 3. There are multiple host PFs (BlueField socket direct).
+ * 4. Port is a local (controller 0) representor on BlueField.
Local and
+ * host representors with the same index would otherwise
share a name.
*
* If none of these conditions apply, then it is assumed that
* this device manages a single non-shared E-Switch with single
controller,
* where there is only one uplink/PF and one host PF (on
BlueField).
*/
- if (!is_standard_eswitch(spawn))
+ if (!is_standard_eswitch(spawn) ||
is_bluefield_local_representor(spawn))
ret = snprintf(name + written, name_sz - written,
"_representor_c%dpf%d%s%u",
spawn->info.ctrl_num,
@@ -1359,6 +1367,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
*/
if (mkvlist)
mlx5_port_args_set_used(name, port_id, mkvlist);
+ if (switch_info->representor)
+ DRV_LOG(NOTICE, "representor \"%s\" is already spawned
as port %u",
+ name, port_id);
rte_errno = EEXIST;
return NULL;
}
--
2.34.1