diff mbox series

[v1,2/2] net/mlx5: support new device global syntax

Message ID 20210108151500.30308-3-xuemingl@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers show
Series [v1,1/2] common/mlx5: support device global syntax | expand

Checks

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

Commit Message

Xueming Li Jan. 8, 2021, 3:15 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 6812a1f215..f1ed3505b1 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -699,13 +699,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 023ef50a77..f2b6cf9fd6 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -41,6 +41,9 @@ 
 #include "mlx5_flow_os.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"
 
@@ -1600,7 +1603,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);
@@ -1754,6 +1757,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,