diff mbox series

[RFC,9/9] net/mlx5: support new device global syntax

Message ID 1608304614-13908-10-git-send-email-xuemingl@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series support global syntax | expand

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Xueming(Steven) Li Dec. 18, 2020, 3:16 p.m. UTC
This patch support new device global syntax like:
	bus=pci,addr=BB:DD.F/class=eth/driver=mlx5,devargs,..

Ignore "driver" key as part of new global device syntax in devargs.

The representor devarg is supposed to come from either class section or
driver section.

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_os.c | 18 ++++++++++++++++--
 drivers/net/mlx5/mlx5.c          |  6 +++++-
 2 files changed, 21 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 917d6be7b8..fae339584b 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -694,13 +694,27 @@  mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	if (switch_info->representor && dpdk_dev->devargs) {
 		struct rte_eth_devargs eth_da;
 
-		err = rte_eth_devargs_parse(dpdk_dev->devargs->args, &eth_da);
+		/* Representer should come from class argument or driver */
+		if (dpdk_dev->devargs->cls_str)
+			err = rte_eth_devargs_parse(dpdk_dev->devargs->cls_str,
+						    &eth_da);
 		if (err) {
 			rte_errno = -err;
 			DRV_LOG(ERR, "failed to process device arguments: %s",
-				strerror(rte_errno));
+				dpdk_dev->devargs->cls_str);
 			return NULL;
 		}
+		if (eth_da.type == RTE_ETH_REPRESENTOR_NONE) {
+			/* Support legacy device argument */
+			err = rte_eth_devargs_parse(dpdk_dev->devargs->args,
+						    &eth_da);
+			if (err) {
+				rte_errno = -err;
+				DRV_LOG(ERR, "failed to process device arguments: %s",
+					dpdk_dev->devargs->args);
+				return NULL;
+			}
+		}
 		for (i = 0; i < eth_da.nb_representor_ports; ++i)
 			if (eth_da.representor_ports[i] ==
 			    (uint16_t)switch_info->port_name)
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 52a8a252d4..3dc15e21ca 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -39,6 +39,9 @@ 
 #include "mlx5_flow.h"
 #include "rte_pmd_mlx5.h"
 
+/* Driver type key for new device global syntax. */
+#define MLX5_DRIVER_KEY "driver"
+
 /* Device parameter to enable RX completion queue compression. */
 #define MLX5_RXQ_CQE_COMP_EN "rxq_cqe_comp_en"
 
@@ -1449,7 +1452,7 @@  mlx5_args_check(const char *key, const char *val, void *opaque)
 	signed long tmp;
 
 	/* No-op, port representors are processed in mlx5_dev_spawn(). */
-	if (!strcmp(MLX5_REPRESENTOR, key))
+	if (!strcmp(MLX5_DRIVER_KEY, key) || !strcmp(MLX5_REPRESENTOR, key))
 		return 0;
 	errno = 0;
 	tmp = strtol(val, NULL, 0);
@@ -1603,6 +1606,7 @@  int
 mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
 {
 	const char **params = (const char *[]){
+		MLX5_DRIVER_KEY,
 		MLX5_RXQ_CQE_COMP_EN,
 		MLX5_RXQ_CQE_PAD_EN,
 		MLX5_RXQ_PKT_PAD_EN,