Skip to contentSkip to conversation

net/mlx5: use port index as representor index

PATCH Superseded Dariusz Sosnowski 2 participants 3 messages May 22 – Jun 4 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: use port index as representor index

Since the offending commit, mlx5 driver supports probing representors on BlueField DPUs with Socket Direct (SD). Such card can be connected to 2 different CPUs on the host system. On DPU, user would see the following network devices:

- p0 and p1 - physical ports
- pf0hpf and pf2hpf - PF0 on CPU 0 and CPU 1 respectively
- pf1hpf and pf3hpf - PF1 on CPU 0 and CPU 1 respectively

mlx5 driver finds the relevant netdev by matching information provided in representor devarg to phys_port_name reported by Linux kernel.
For the above interfaces phys_port_name's would be reported and probed as:

- p0 -> p0, no need for representor devarg
- p1 -> p1, with representor=pf1
- pf0hpf -> c1pf0, with representor=c1pf0vf65535
- pf1hpf -> c1pf1, with representor=c1pf1vf65535
- pf2hpf -> c2pf0, with representor=c2pf0vf65535
- pf3hpf -> c2pf1, with representor=c2pf1vf65535

Although hot-plugging all these representors is successful, RTE_ETH_FOREACH_MATCHING_DEV() macro would find DPDK ports. This is caused missing information reported by mlx5 driver, through rte_eth_representor_info_get() API. Specifically, mlx5 driver did not report controller index for all representor ranges.

Until now mlx5 driver used static encoding for 16-bit representor_id:

- 2 bits for representor type
- 2 bits for PF index
- 2 bits for representor index (either VF or SF number)

Controller index was not encoded. This caused the mentioned issue and on top of that:

- limits the number of PFs
- limits the number of SFs

This patch changes the mlx5 driver logic for
rte_eth_representor_info_get().
Instead of static encoding:

- representor_id's will be dynamically assigned
to each probed representor.
- rte_eth_representor_info_get() will report N ranges:
- N == number of probed ports on single embedded switch
- Each range will define single representor_id for given controller/PF/VF/SF.

Fixes 2f7cdd821b1b ("net/mlx5: fix probing to allow BlueField Socket Direct")
---
 drivers/net/mlx5/linux/mlx5_os.c |   6 +-
 drivers/net/mlx5/mlx5.h          |  19 +++
 drivers/net/mlx5/mlx5_ethdev.c   | 284 +++++++++++++++++++------------
 3 files changed, 199 insertions(+), 110 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +5 -1
index 0fc721592b..5305523c1b 100644
@@ -1677,9 +1677,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 		err = ENOMEM;
 		goto error;
 	}
+	priv->port_info.type = spawn->info.name_type;
+	priv->port_info.ctrl_num = spawn->info.ctrl_num;
+	priv->port_info.pf_num = spawn->info.pf_num;
+	priv->port_info.port_num = spawn->info.port_name;
 	if (priv->representor) {
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
-		eth_dev->data->representor_id = priv->representor_id;
+		eth_dev->data->representor_id = eth_dev->data->port_id;
 		MLX5_ETH_FOREACH_DEV(port_id, dpdk_dev) {
 			struct mlx5_priv *opriv =
 				rte_eth_devices[port_id].data->dev_private;
drivers/net/mlx5/mlx5.h +19 -0
index 49a0c03544..23803b450b 100644
@@ -1984,6 +1984,24 @@ struct mlx5_quota_ctx {
 	struct mlx5_indexed_pool *quota_ipool; /* Manage quota objects */
 };
 
+/* Stores info parsed from phys_port_name related to given DPDK port. */
+struct mlx5_representor_info {
+	enum mlx5_nl_phys_port_name_type type;
+	/* PCI controller index. 0 if no controller was reported in phys_port_name. */
+	int32_t ctrl_num;
+	/* PF index. */
+	int32_t pf_num;
+	/*
+	 * Representor number:
+	 *
+	 * - For VF/SF - VF/SF index.
+	 * - For PFHPF - -1.
+	 * - For uplink - physical port index.
+	 * - For others - VF representor is assumed, so VF index.
+	 */
+	int32_t port_num;
+};
+
 struct mlx5_nta_sample_ctx;
 struct mlx5_priv {
 	struct rte_eth_dev_data *dev_data;  /* Pointer to device data. */
@@ -2019,6 +2037,7 @@ struct mlx5_priv {
 	uint32_t vport_meta_tag; /* Used for vport index match ove VF LAG. */
 	uint32_t vport_meta_mask; /* Used for vport index field match mask. */
 	uint16_t representor_id; /* UINT16_MAX if not a representor. */
+	struct mlx5_representor_info port_info;
 	int32_t pf_bond; /* >=0, representor owner PF index in bonding. */
 	int32_t mpesw_owner; /* >=0, representor owner PF index in MPESW. */
 	int32_t mpesw_port; /* Related port index of MPESW device. < 0 - no MPESW. */
drivers/net/mlx5/mlx5_ethdev.c +175 -109

312 lines not on this page · raw message

Signature · 1 line
2.47.3
#1 lore raw

PATCH v2 1/1 net/mlx5: use port index as representor index

Since the offending commit, mlx5 driver supports probing representors on BlueField DPUs with Socket Direct (SD). Such card can be connected to 2 different CPUs on the host system. On DPU, user would see the following network devices:

- p0 and p1 - physical ports
- pf0hpf and pf2hpf - PF0 on CPU 0 and CPU 1 respectively
- pf1hpf and pf3hpf - PF1 on CPU 0 and CPU 1 respectively

mlx5 driver finds the relevant netdev by matching information provided in representor devarg to phys_port_name reported by Linux kernel.
For the above interfaces phys_port_name's would be reported and probed as:

- p0 -> p0, no need for representor devarg
- p1 -> p1, with representor=pf1
- pf0hpf -> c1pf0, with representor=c1pf0vf65535
- pf1hpf -> c1pf1, with representor=c1pf1vf65535
- pf2hpf -> c2pf0, with representor=c2pf0vf65535
- pf3hpf -> c2pf1, with representor=c2pf1vf65535

Although hot-plugging all these representors is successful, RTE_ETH_FOREACH_MATCHING_DEV() macro would not find DPDK ports. This is caused missing information reported by mlx5 driver, through rte_eth_representor_info_get() API. Specifically, mlx5 driver did not report controller index for all representor ranges.

Until now mlx5 driver used static encoding for 16-bit representor_id:

- 2 bits for representor type
- 2 bits for PF index
- 12 bits for representor index (either VF or SF number)

Controller index was not encoded. This caused the mentioned issue and on top of that:

- limits the number of PFs
- limits the number of SFs

This patch changes the mlx5 driver logic for
rte_eth_representor_info_get().
Instead of static encoding:

- representor_id's will be dynamically assigned
to each probed representor.
- rte_eth_representor_info_get() will report N ranges:
- N == number of probed ports on single embedded switch
- Each range will define single representor_id for given controller/PF/VF/SF.

Fixes 2f7cdd821b1b ("net/mlx5: fix probing to allow BlueField Socket Direct")

---
v2:
- Added missing "not" in "RTE_ETH_FOREACH_MATCHING_DEV() macro would not find DPDK ports" in the commit message.
- Fixed typo in number of bits for representor index.
Should be 12, not 2.

 drivers/net/mlx5/linux/mlx5_os.c |   6 +-
 drivers/net/mlx5/mlx5.h          |  19 +++
 drivers/net/mlx5/mlx5_ethdev.c   | 284 +++++++++++++++++++------------
 3 files changed, 199 insertions(+), 110 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +5 -1
index 0fc721592b..5305523c1b 100644
@@ -1677,9 +1677,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 		err = ENOMEM;
 		goto error;
 	}
+	priv->port_info.type = spawn->info.name_type;
+	priv->port_info.ctrl_num = spawn->info.ctrl_num;
+	priv->port_info.pf_num = spawn->info.pf_num;
+	priv->port_info.port_num = spawn->info.port_name;
 	if (priv->representor) {
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
-		eth_dev->data->representor_id = priv->representor_id;
+		eth_dev->data->representor_id = eth_dev->data->port_id;
 		MLX5_ETH_FOREACH_DEV(port_id, dpdk_dev) {
 			struct mlx5_priv *opriv =
 				rte_eth_devices[port_id].data->dev_private;
drivers/net/mlx5/mlx5.h +19 -0
index 49a0c03544..23803b450b 100644
@@ -1984,6 +1984,24 @@ struct mlx5_quota_ctx {
 	struct mlx5_indexed_pool *quota_ipool; /* Manage quota objects */
 };
 
+/* Stores info parsed from phys_port_name related to given DPDK port. */
+struct mlx5_representor_info {
+	enum mlx5_nl_phys_port_name_type type;
+	/* PCI controller index. 0 if no controller was reported in phys_port_name. */
+	int32_t ctrl_num;
+	/* PF index. */
+	int32_t pf_num;
+	/*
+	 * Representor number:
+	 *
+	 * - For VF/SF - VF/SF index.
+	 * - For PFHPF - -1.
+	 * - For uplink - physical port index.
+	 * - For others - VF representor is assumed, so VF index.
+	 */
+	int32_t port_num;
+};
+
 struct mlx5_nta_sample_ctx;
 struct mlx5_priv {
 	struct rte_eth_dev_data *dev_data;  /* Pointer to device data. */
@@ -2019,6 +2037,7 @@ struct mlx5_priv {
 	uint32_t vport_meta_tag; /* Used for vport index match ove VF LAG. */
 	uint32_t vport_meta_mask; /* Used for vport index field match mask. */
 	uint16_t representor_id; /* UINT16_MAX if not a representor. */
+	struct mlx5_representor_info port_info;
 	int32_t pf_bond; /* >=0, representor owner PF index in bonding. */
 	int32_t mpesw_owner; /* >=0, representor owner PF index in MPESW. */
 	int32_t mpesw_port; /* Related port index of MPESW device. < 0 - no MPESW. */
drivers/net/mlx5/mlx5_ethdev.c +175 -109

312 lines not on this page · raw message

--
2.47.3

#2 lore raw

Hi,

Quoted 64 lines · Dariusz Sosnowski

Since the offending commit, mlx5 driver supports probing representors on BlueField DPUs with Socket Direct (SD). Such card can be connected to 2 different CPUs on the host system. On DPU, user would see the following network devices:

- p0 and p1 - physical ports
- pf0hpf and pf2hpf - PF0 on CPU 0 and CPU 1 respectively
- pf1hpf and pf3hpf - PF1 on CPU 0 and CPU 1 respectively

mlx5 driver finds the relevant netdev by matching information provided in representor devarg to phys_port_name reported by Linux kernel.
For the above interfaces phys_port_name's would be reported and probed as:

- p0 -> p0, no need for representor devarg
- p1 -> p1, with representor=pf1
- pf0hpf -> c1pf0, with representor=c1pf0vf65535
- pf1hpf -> c1pf1, with representor=c1pf1vf65535
- pf2hpf -> c2pf0, with representor=c2pf0vf65535
- pf3hpf -> c2pf1, with representor=c2pf1vf65535

Although hot-plugging all these representors is successful, RTE_ETH_FOREACH_MATCHING_DEV() macro would not find DPDK ports. This is caused missing information reported by mlx5 driver, through rte_eth_representor_info_get() API. Specifically, mlx5 driver did not report controller index for all representor ranges.

Until now mlx5 driver used static encoding for 16-bit representor_id:

- 2 bits for representor type
- 2 bits for PF index
- 12 bits for representor index (either VF or SF number)

Controller index was not encoded. This caused the mentioned issue and on top of that:

- limits the number of PFs
- limits the number of SFs

This patch changes the mlx5 driver logic for
rte_eth_representor_info_get().
Instead of static encoding:

- representor_id's will be dynamically assigned
to each probed representor.
- rte_eth_representor_info_get() will report N ranges:
- N == number of probed ports on single embedded switch
- Each range will define single representor_id for given controller/PF/VF/SF.

Fixes 2f7cdd821b1b ("net/mlx5: fix probing to allow BlueField Socket Direct")

---
v2:
- Added missing "not" in "RTE_ETH_FOREACH_MATCHING_DEV() macro would not find DPDK ports" in the commit message.
- Fixed typo in number of bits for representor index.
Should be 12, not 2.

Quoted 5 lines
  drivers/net/mlx5/linux/mlx5_os.c |   6 +-
  drivers/net/mlx5/mlx5.h          |  19 +++
  drivers/net/mlx5/mlx5_ethdev.c   | 284 +++++++++++++++++++------------
  3 files changed, 199 insertions(+), 110 deletions(-)

--

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh