diff mbox series

[v5,9/9] net/mlx5: probe host PF representor with SubFunction

Message ID 1616939297-15627-10-git-send-email-xuemingl@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers show
Series net/mlx5: support SubFunction representor | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot success github build: passed
ci/travis-robot success travis build: passed
ci/checkpatch success coding style OK

Commit Message

Xueming(Steven) Li March 28, 2021, 1:48 p.m. UTC
To simplify BlueField HPF representor(vf[-1]) probe, this patch allows
probe it with "sf" syntax: "sf[-1]".

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_os.c | 14 ++++++++++----
 drivers/net/mlx5/mlx5.h          |  3 ++-
 drivers/net/mlx5/mlx5_ethdev.c   | 25 +++++++++++++++++++++----
 3 files changed, 33 insertions(+), 9 deletions(-)

Comments

Viacheslav Ovsiienko March 30, 2021, 7:37 a.m. UTC | #1
> -----Original Message-----
> From: Xueming Li <xuemingl@nvidia.com>
> Sent: Sunday, March 28, 2021 16:48
> To: Slava Ovsiienko <viacheslavo@nvidia.com>
> Cc: dev@dpdk.org; Xueming(Steven) Li <xuemingl@nvidia.com>; Asaf Penso
> <asafp@nvidia.com>; Matan Azrad <matan@nvidia.com>; Shahaf Shuler
> <shahafs@nvidia.com>
> Subject: [PATCH v5 9/9] net/mlx5: probe host PF representor with
> SubFunction
> 
> To simplify BlueField HPF representor(vf[-1]) probe, this patch allows probe it
> with "sf" syntax: "sf[-1]".
> 
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
diff mbox series

Patch

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 5bdc8caee5..74f72188ff 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -710,11 +710,15 @@  mlx5_representor_match(struct mlx5_dev_spawn_data *spawn,
 	struct mlx5_switch_info *switch_info = &spawn->info;
 	unsigned int p, f;
 	uint16_t id;
-	uint16_t repr_id = mlx5_representor_id_encode(switch_info);
+	uint16_t repr_id = mlx5_representor_id_encode(switch_info,
+						      eth_da->type);
 
 	switch (eth_da->type) {
 	case RTE_ETH_REPRESENTOR_SF:
-		if (switch_info->name_type != MLX5_PHYS_PORT_NAME_TYPE_PFSF) {
+		if (!(spawn->info.port_name == -1 &&
+		      switch_info->name_type ==
+				MLX5_PHYS_PORT_NAME_TYPE_PFHPF) &&
+		    switch_info->name_type != MLX5_PHYS_PORT_NAME_TYPE_PFSF) {
 			rte_errno = EBUSY;
 			return false;
 		}
@@ -742,7 +746,8 @@  mlx5_representor_match(struct mlx5_dev_spawn_data *spawn,
 		if (spawn->pf_bond < 0) {
 			/* For non-LAG mode, allow and ignore pf. */
 			switch_info->pf_num = eth_da->ports[p];
-			repr_id = mlx5_representor_id_encode(switch_info);
+			repr_id = mlx5_representor_id_encode(switch_info,
+							     eth_da->type);
 		}
 		for (f = 0; f < eth_da->nb_representor_ports; ++f) {
 			id = MLX5_REPRESENTOR_ID
@@ -1107,7 +1112,8 @@  mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	priv->vport_id = switch_info->representor ?
 			 switch_info->port_name + 1 : -1;
 #endif
-	priv->representor_id = mlx5_representor_id_encode(switch_info);
+	priv->representor_id = mlx5_representor_id_encode(switch_info,
+							  eth_da->type);
 	/*
 	 * Look for sibling devices in order to reuse their switch domain
 	 * if any, otherwise allocate one.
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index a1d2798373..fa9e68ded9 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1055,7 +1055,8 @@  int mlx5_representor_info_get(struct rte_eth_dev *dev,
 		((repr_id) & 0xfff)
 #define MLX5_REPRESENTOR_TYPE(repr_id) \
 		(((repr_id) >> 12) & 3)
-uint16_t mlx5_representor_id_encode(const struct mlx5_switch_info *info);
+uint16_t mlx5_representor_id_encode(const struct mlx5_switch_info *info,
+				    enum rte_eth_representor_type hpf_type);
 int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver,
 			size_t fw_size);
 int mlx5_dev_infos_get(struct rte_eth_dev *dev,
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 4f97a69a20..564d7132e0 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -363,12 +363,15 @@  mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
  *
  * @param info
  *   Port switch info.
+ * @param hpf_type
+ *   Use this type if port is HPF.
  *
  * @return
  *   Encoded representor ID.
  */
 uint16_t
-mlx5_representor_id_encode(const struct mlx5_switch_info *info)
+mlx5_representor_id_encode(const struct mlx5_switch_info *info,
+			   enum rte_eth_representor_type hpf_type)
 {
 	enum rte_eth_representor_type type = RTE_ETH_REPRESENTOR_VF;
 	uint16_t repr = info->port_name;
@@ -377,8 +380,10 @@  mlx5_representor_id_encode(const struct mlx5_switch_info *info)
 		return UINT16_MAX;
 	if (info->name_type == MLX5_PHYS_PORT_NAME_TYPE_PFSF)
 		type = RTE_ETH_REPRESENTOR_SF;
-	if (info->name_type == MLX5_PHYS_PORT_NAME_TYPE_PFHPF)
+	if (info->name_type == MLX5_PHYS_PORT_NAME_TYPE_PFHPF) {
+		type = hpf_type;
 		repr = UINT16_MAX;
+	}
 	return MLX5_REPRESENTOR_ID(info->pf_num, type, repr);
 }
 
@@ -403,7 +408,7 @@  mlx5_representor_info_get(struct rte_eth_dev *dev,
 			  struct rte_eth_representor_info *info)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
-	int n_type = 3; /* Number of representor types, VF, HPF and SF. */
+	int n_type = 4; /* Representor types, VF, HPF@VF, SF and HPF@SF. */
 	int n_pf = 2; /* Number of PFs. */
 	int i = 0, pf;
 
@@ -424,7 +429,7 @@  mlx5_representor_info_get(struct rte_eth_dev *dev,
 		snprintf(info->ranges[i].name,
 			 sizeof(info->ranges[i].name), "pf%dvf", pf);
 		i++;
-		/* HPF range. */
+		/* HPF range of VF type. */
 		info->ranges[i].type = RTE_ETH_REPRESENTOR_VF;
 		info->ranges[i].controller = 0;
 		info->ranges[i].pf = pf;
@@ -448,6 +453,18 @@  mlx5_representor_info_get(struct rte_eth_dev *dev,
 		snprintf(info->ranges[i].name,
 			 sizeof(info->ranges[i].name), "pf%dsf", pf);
 		i++;
+		/* HPF range of SF type. */
+		info->ranges[i].type = RTE_ETH_REPRESENTOR_SF;
+		info->ranges[i].controller = 0;
+		info->ranges[i].pf = pf;
+		info->ranges[i].vf = UINT16_MAX;
+		info->ranges[i].id_base =
+			MLX5_REPRESENTOR_ID(pf, info->ranges[i].type, -1);
+		info->ranges[i].id_end =
+			MLX5_REPRESENTOR_ID(pf, info->ranges[i].type, -1);
+		snprintf(info->ranges[i].name,
+			 sizeof(info->ranges[i].name), "pf%dsf", pf);
+		i++;
 	}
 out:
 	return n_type * n_pf;