Skip to contentSkip to conversation

net/mlx5: fix local and host representor name collision

PATCH Superseded Bing Zhao 2 participants 4 messages Nov 2 – Nov 5 1 message not in the archive Network drivers

lore
Share & tools
lore

Bing Zhao

author
#0 lore raw

PATCH 1/1 net/mlx5: fix local and host representor name collision

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")
---
 drivers/net/mlx5/linux/mlx5_os.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/mlx5/linux/mlx5_os.c +12 -1
index 4c35737292..82a8ad549b 100644
@@ -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;
 	}
Signature · 1 line
2.34.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#2 lore raw

RE: |WARNING| net/mlx5: fix local and host representor name collision

The Review-Result: WARNING on patch 172348 is a false positive. I checked all three items against the patch from patchwork and the current tree, and none of them holds up as written. The patch applies cleanly to HEAD and the patched mlx5_os.c compiles with the flags in build-txci .

The review's findings

Warning 1, missing release notes: not valid as written.

* The suggested entry goes under a "Bug Fixes" section, but release_26_11.rst has no such section. Its sections are New Features, Removed Items, API Changes, ABI Changes, Known Issues and Tested Platforms. DPDK doesn't list fixes in the main release notes.
* A new log message never needs a release note.
* The patch is Cc: [email protected] , so a 26.11 release-note hunk would just get in the way of the backport.
* There is a real point underneath it, covered under "Real concern 2" below.

Info 1, bounds check on ctrl_num / pf_num : invalid.

* The patch only changes the condition. The snprintf format line was already there. mlx5_os.c:1138-1145 (file:///root/dpdk.org/drivers/net/mlx5/linux/mlx5_os.c)
* The output is capped at name_sz - written , and truncation is caught (mlx5_os.c:1154-1155 (file:///root/dpdk.org/drivers/net/mlx5/linux/mlx5_os.c)) and logged (mlx5_os.c:1352-1353 (file:///root/dpdk.org/drivers/net/mlx5/linux/mlx5_os.c)).
* The fields are int32_t printed with %d , so nothing can overflow. The item also breaks the AGENTS.md evidence rule ("likely bounded", "could prevent potential").

Info 2, the NOTICE log: should not have been output. The item ends with "This is acceptable", which is exactly the wording AGENTS.md says to delete. The log itself is fine: switch_info is in scope at line 1324 and port_id is uint16_t printed with %u .

Quoted 94 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Monday, November 2, 2026 9:23 PM
To: [email protected]
Cc: Bing Zhao <[email protected]>
Subject: |WARNING| net/mlx5: fix local and host representor name collision

External email: Use caution opening links or attachments

Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/172348

_AI Code Review_

=== Patch Review: series.patch (via Claude) === Review date: 2026-11-02

# DPDK Patch Review

## Patch Summary
This patch fixes a naming collision between local and host representors on BlueField by adding controller and PF indexes to local representor names when a host PF is present.

---

## ERRORS

None identified.

---

## WARNINGS

### 1. Missing release notes update

**File:** drivers/net/mlx5/linux/mlx5_os.c
**Issue:** This patch fixes a bug that changes user-visible port naming and adds a new log message, but does not update the release notes.

**Why it matters:** The naming change affects applications that rely on port name patterns. Users upgrading to this version need to know that local representor names will change from <BDF>_representor_vf0 to <BDF>_representor_c0pf0vf0 on BlueField systems with host PFs.

**Suggested fix:** Add an entry to doc/guides/rel_notes/release_26_11.rst (or current release) under "Bug Fixes" section:

```rst
* **net/mlx5: Fixed local and host representor name collision on
BlueField.**

  On BlueField with a single uplink and host PF, local representors
(controller 0)
  and host representors (controller 1) with the same index previously had
the same
  name, causing probing failures. Local representor names now include
controller
  and PF indexes (e.g., ``<BDF>_representor_c0pf0vf0``) when a host PF is
present.
```

---

## INFO

### 1. Consider bounds check on controller and PF numbers

**File:** drivers/net/mlx5/linux/mlx5_os.c
**Line:** spawn->info.ctrl_num and spawn->info.pf_num in snprintf()

The controller and PF numbers come from the device information structure. While these are likely bounded by hardware constraints, an explicit bounds check before formatting could prevent potential buffer issues if the fields ever contain unexpected values. This is a hardening suggestion for robustness, not a correctness bug in the current code.

### 2. Log message uses DRV_LOG(NOTICE)

**File:** drivers/net/mlx5/linux/mlx5_os.c **Line 1370-1371:** ```c DRV_LOG(NOTICE, "representor \"%s\" is already spawned as port %u",

        name, port_id);

```

This is acceptable. The NOTICE level is appropriate for informing the user that a representor probe was a no-op because the port already exists. The message provides useful diagnostic information without being an error or warning.

---

Review-Result: WARNING

author
#3 lore raw

PATCH v2 1/1 net/mlx5: fix local and host representor name collision

In reply to Bing Zhao

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. The host PF representor can also report controller 0, so it is excluded explicitly. 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")

---
v2:
- Exclude the host PF representor from the new naming condition with is_hpf(). It can also report controller 0, so without this it was renamed too. Its name is now unchanged.
- Update the commit log to mention the host PF exclusion.

---
 drivers/net/mlx5/linux/mlx5_os.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/net/mlx5/linux/mlx5_os.c +13 -1
index 4c35737292..bf6f5c0ae2 100644
@@ -1081,6 +1081,13 @@ 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 && !is_hpf(spawn);
+}
+
 static int
 build_port_name(struct rte_device *dpdk_dev,
 		struct mlx5_dev_spawn_data *spawn,
@@ -1130,12 +1137,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 +1368,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;
 	}
Signature · 1 line
2.34.1