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

Xueming(Steven) Li xuemingl at mellanox.com
Sat Jun 16 10:59:43 CEST 2018


Reviewed-by: Xueming Li <xuemingl at mellanox.com>

> -----Original Message-----
> From: dev <dev-bounces at dpdk.org> On Behalf Of Adrien Mazarguil
> Sent: Thursday, June 14, 2018 4:35 PM
> To: Shahaf Shuler <shahafs at mellanox.com>
> Cc: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH v2 7/7] net/mlx5: add parameter for port representors
> 
> 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>
> --
> v2 changes:
> 
> - Added error message for when rte_eth_devargs_parse() fails.
> ---
>  doc/guides/nics/mlx5.rst                | 12 ++++++++++++
>  doc/guides/prog_guide/poll_mode_drv.rst |  2 ++
>  drivers/net/mlx5/mlx5.c                 | 29 ++++++++++++++++++++++++++++
>  3 files changed, 43 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 716c9d9a5..26e61d99d 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -91,6 +91,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)
> @@ -423,6 +426,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) {
> @@ -495,6 +501,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;
> @@ -1173,13 +1180,34 @@ 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) {
> +			rte_errno = -ret;
> +			DRV_LOG(ERR, "failed to process device arguments: %s",
> +				strerror(rte_errno));
> +			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) {
> @@ -1218,6 +1246,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