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

Message ID 20180525161814.13873-8-adrien.mazarguil@6wind.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Adrien Mazarguil May 25, 2018, 4:35 p.m. UTC
  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@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(+)
  

Comments

Xueming Li June 12, 2018, 8:02 a.m. UTC | #1
Hi Adrien,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Adrien Mazarguil
> Sent: Saturday, May 26, 2018 12:35 AM
> To: Shahaf Shuler <shahafs@mellanox.com>
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 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@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;

Not related to this patch, from this data structure, maximum representor count is 32, 
customer might use VF on container environment, 32 is far from requirement. We need
additional work here. A workaround is that users call this api multiple times with different
representor IDs.

>  	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]);

Need a range check for j here.

>  	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
  
Adrien Mazarguil June 12, 2018, 1:20 p.m. UTC | #2
On Tue, Jun 12, 2018 at 08:02:17AM +0000, Xueming(Steven) Li wrote:
> Hi Adrien,
> 
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Adrien Mazarguil
> > Sent: Saturday, May 26, 2018 12:35 AM
> > To: Shahaf Shuler <shahafs@mellanox.com>
> > Cc: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH 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@6wind.com>
<snip>
> > @@ -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;
> 
> Not related to this patch, from this data structure, maximum representor count is 32, 
> customer might use VF on container environment, 32 is far from requirement. We need
> additional work here. A workaround is that users call this api multiple times with different
> representor IDs.

32 ought to be enough for anybody!

Not sure I understand your concern actually. One can't instantiate more
representors than there are DPDK ports because the limit for both is
RTE_MAX_ETHPORTS (i.e. 1 representor = 1 DPDK port). Users who want to spawn
more than 32 DPDK ports overall must increase RTE_MAX_ETHPORTS regardless.

> >  	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]);
> 
> Need a range check for j here.

I think it's properly checked. j == 0 stands for "master device", always
found at index 0 and probed. Representors devices, if any, start at index 1
which triggers the previous block. This block makes sure that a given
representor is indeed enabled before either spawning the related device
(pass through with a valid "j") or skipping it altogether (goto skip).

I intend to leave this patch as is for v2.
  
Xueming Li June 12, 2018, 1:43 p.m. UTC | #3
> -----Original Message-----
> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> Sent: Tuesday, June 12, 2018 9:21 PM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>
> Cc: Shahaf Shuler <shahafs@mellanox.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 7/7] net/mlx5: add parameter for port representors
> 
> On Tue, Jun 12, 2018 at 08:02:17AM +0000, Xueming(Steven) Li wrote:
> > Hi Adrien,
> >
> > > -----Original Message-----
> > > From: dev <dev-bounces@dpdk.org> On Behalf Of Adrien Mazarguil
> > > Sent: Saturday, May 26, 2018 12:35 AM
> > > To: Shahaf Shuler <shahafs@mellanox.com>
> > > Cc: dev@dpdk.org
> > > Subject: [dpdk-dev] [PATCH 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@6wind.com>
> <snip>
> > > @@ -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;
> >
> > Not related to this patch, from this data structure, maximum
> > representor count is 32, customer might use VF on container
> > environment, 32 is far from requirement. We need additional work here.
> > A workaround is that users call this api multiple times with different representor IDs.
> 
> 32 ought to be enough for anybody!
> 
> Not sure I understand your concern actually. One can't instantiate more representors than there are
> DPDK ports because the limit for both is RTE_MAX_ETHPORTS (i.e. 1 representor = 1 DPDK port). Users
> who want to spawn more than 32 DPDK ports overall must increase RTE_MAX_ETHPORTS regardless.

ConnectX-5 support 127 VFs, but as you said, increasing RTE_MAX_ETHPORTS should work.

> 
> > >  	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]);
> >
> > Need a range check for j here.
> 
> I think it's properly checked. j == 0 stands for "master device", always found at index 0 and probed.
> Representors devices, if any, start at index 1 which triggers the previous block. This block makes
> sure that a given representor is indeed enabled before either spawning the related device (pass
> through with a valid "j") or skipping it altogether (goto skip).

Yes, this code looks good. What I wanted to ask what if dev args specify an invalid rep id, e.g. 33.
This code walk through silently w/o warning, it works, but it better to have a warning if input id out of range.

> 
> I intend to leave this patch as is for v2.
> 
> --
> Adrien Mazarguil
> 6WIND
  
Xueming Li June 12, 2018, 2:44 p.m. UTC | #4
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Adrien Mazarguil
> Sent: Saturday, May 26, 2018 12:35 AM
> To: Shahaf Shuler <shahafs@mellanox.com>
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 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@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;

int rte_eth_dev_attach(const char *devargs, uint16_t *port_id);
The rte_eth_dev_attach api attach one device a time as only one *port_id parameter.
Dev argument "82:0.0,representer[a-b] will register multiple devices in one call,
is this correct behavior? I ask this because this caused testpmd CLI "port attach" 
crash due to only the last registered port id returned.

>  	eth_list[n] = NULL;
> --
> 2.11.0
  
Adrien Mazarguil June 13, 2018, 1:11 p.m. UTC | #5
On Tue, Jun 12, 2018 at 02:44:12PM +0000, Xueming(Steven) Li wrote:
<snip>
> > +	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;
> 
> int rte_eth_dev_attach(const char *devargs, uint16_t *port_id);
> The rte_eth_dev_attach api attach one device a time as only one *port_id parameter.
> Dev argument "82:0.0,representer[a-b] will register multiple devices in one call,
> is this correct behavior?

Yes, this is how the representor argument is documented and supposed to be
used. This probing approach is obviously not compatible with representors
hot-plugging, for which something will have to be devised if needed.

> I ask this because this caused testpmd CLI "port attach" 
> crash due to only the last registered port id returned.

I reproduced this crash and determined it is caused by a bug in
testpmd. I'll submit a separate fix for it.
  
Adrien Mazarguil June 14, 2018, 8:01 a.m. UTC | #6
On Tue, Jun 12, 2018 at 01:43:18PM +0000, Xueming(Steven) Li wrote:
<snip>
> > > >  	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]);
> > >
> > > Need a range check for j here.
> > 
> > I think it's properly checked. j == 0 stands for "master device", always found at index 0 and probed.
> > Representors devices, if any, start at index 1 which triggers the previous block. This block makes
> > sure that a given representor is indeed enabled before either spawning the related device (pass
> > through with a valid "j") or skipping it altogether (goto skip).
> 
> Yes, this code looks good. What I wanted to ask what if dev args specify an invalid rep id, e.g. 33.
> This code walk through silently w/o warning, it works, but it better to have a warning if input id out of range.

You're right. On the other hand this provides a means to spawn all
representors without necessarily knowing how many can be instantiated first,
e.g. by always providing a "representor=[0-31]" argument, since no special
keyword is defined to request them all.

Not saying it's a good or bad thing, but somewhat harmless. Just like
specifying "-w {DBDF}" arguments with invalid addresses, nonexistent
representors are silently ignored.

In any case, this can be improved later. We're already seeing a couple of
limitations with the representor argument, namely the lack of hot-plug
support, which will need to be addressed as well.
  

Patch

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;