[dpdk-dev] [PATCH 7/7] net/mlx5: add parameter for port representors

Adrien Mazarguil adrien.mazarguil at 6wind.com
Fri May 25 18:35:26 CEST 2018


Prior to this patch, all port representors detected on a given device were
probed and Ethernet devices instantiated for each of them.

This patch adds support for the standard "representor" parameter, which
implies that port representors are not probed by default anymore, except
for the list provided through device arguments.

(Patch based on prior work from Yuanhan Liu)

Signed-off-by: Adrien Mazarguil <adrien.mazarguil at 6wind.com>
---
 doc/guides/nics/mlx5.rst                | 12 ++++++++++++
 doc/guides/prog_guide/poll_mode_drv.rst |  2 ++
 drivers/net/mlx5/mlx5.c                 | 25 +++++++++++++++++++++++++
 3 files changed, 39 insertions(+)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index 79c982e29..5229e546c 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -388,6 +388,18 @@ Run-time configuration
 
   Disabled by default.
 
+- ``representor`` parameter [list]
+
+  This parameter can be used to instantiate DPDK Ethernet devices from
+  existing port (or VF) representors configured on the device.
+
+  It is a standard parameter whose format is described in
+  :ref:`ethernet_device_standard_device_arguments`.
+
+  For instance, to probe port representors 0 through 2::
+
+    representor=[0-2]
+
 Firmware configuration
 ~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/doc/guides/prog_guide/poll_mode_drv.rst b/doc/guides/prog_guide/poll_mode_drv.rst
index af82352a0..58d49ba0f 100644
--- a/doc/guides/prog_guide/poll_mode_drv.rst
+++ b/doc/guides/prog_guide/poll_mode_drv.rst
@@ -365,6 +365,8 @@ Ethernet Device API
 
 The Ethernet device API exported by the Ethernet PMDs is described in the *DPDK API Reference*.
 
+.. _ethernet_device_standard_device_arguments:
+
 Ethernet Device Standard Device Arguments
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 09afca63c..216753ba6 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -90,6 +90,9 @@
 /* Activate Netlink support in VF mode. */
 #define MLX5_VF_NL_EN "vf_nl_en"
 
+/* Select port representors to instantiate. */
+#define MLX5_REPRESENTOR "representor"
+
 #ifndef HAVE_IBV_MLX5_MOD_MPW
 #define MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED (1 << 2)
 #define MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW (1 << 3)
@@ -420,6 +423,9 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
 	struct mlx5_dev_config *config = opaque;
 	unsigned long tmp;
 
+	/* No-op, port representors are processed in mlx5_dev_spawn(). */
+	if (!strcmp(MLX5_REPRESENTOR, key))
+		return 0;
 	errno = 0;
 	tmp = strtoul(val, NULL, 0);
 	if (errno) {
@@ -492,6 +498,7 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
 		MLX5_RX_VEC_EN,
 		MLX5_L3_VXLAN_EN,
 		MLX5_VF_NL_EN,
+		MLX5_REPRESENTOR,
 		NULL,
 	};
 	struct rte_kvargs *kvlist;
@@ -1142,13 +1149,30 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	struct rte_eth_dev **eth_list = NULL;
 	struct ibv_context *ctx;
 	struct ibv_device_attr_ex attr;
+	struct rte_eth_devargs eth_da;
 	void *tmp;
 	unsigned int i;
 	unsigned int j = 0;
 	unsigned int n = 0;
 	int ret;
 
+	if (dpdk_dev->devargs) {
+		ret = rte_eth_devargs_parse(dpdk_dev->devargs->args, &eth_da);
+		if (ret)
+			goto error;
+	} else {
+		memset(&eth_da, 0, sizeof(eth_da));
+	}
 next:
+	if (j) {
+		unsigned int k;
+
+		for (k = 0; k < eth_da.nb_representor_ports; ++k)
+			if (eth_da.representor_ports[k] == j - 1)
+				break;
+		if (k == eth_da.nb_representor_ports)
+			goto skip;
+	}
 	errno = 0;
 	ctx = mlx5_glue->open_device(ibv_dev[j]);
 	if (!ctx) {
@@ -1187,6 +1211,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 			goto error;
 		++n;
 	}
+skip:
 	if (ibv_dev[++j])
 		goto next;
 	eth_list[n] = NULL;
-- 
2.11.0


More information about the dev mailing list