[v4,09/10] net/mlx5: add parameter for port representors

Message ID 20180705083934.5535-10-adrien.mazarguil@6wind.com (mailing list archive)
State Superseded, archived
Headers
Series net/mlx5: add port representor support |

Checks

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

Commit Message

Adrien Mazarguil July 5, 2018, 8:45 a.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>
Reviewed-by: Xueming Li <xuemingl@mellanox.com>
--
v3 changes:

- Adapted representor detection to the reworked mlx5_dev_spawn().

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                 | 41 ++++++++++++++++++++++++++--
 3 files changed, 52 insertions(+), 3 deletions(-)
  

Comments

Shahaf Shuler July 9, 2018, 11:57 a.m. UTC | #1
Thursday, July 5, 2018 11:46 AM, Adrien Mazarguil:
> Subject: [PATCH v4 09/10] 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>
> Reviewed-by: Xueming Li <xuemingl@mellanox.com>
> --
> v3 changes:
> 
> - Adapted representor detection to the reworked mlx5_dev_spawn().
> 
> 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                 | 41 ++++++++++++++++++++++++++--
>  3 files changed, 52 insertions(+), 3 deletions(-)
> 
> diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index
> 7dd9c1c5e..0d0d21727 100644
> --- a/doc/guides/nics/mlx5.rst
> +++ b/doc/guides/nics/mlx5.rst
> @@ -392,6 +392,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 4b69f6cbe..b2cf48354 100644
> --- a/doc/guides/prog_guide/poll_mode_drv.rst
> +++ b/doc/guides/prog_guide/poll_mode_drv.rst
> @@ -360,6 +360,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
> 6592480bf..12a77afa8 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -92,6 +92,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) @@ -443,6 +446,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) {
> @@ -515,6 +521,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;
> @@ -672,7 +679,9 @@ mlx5_uar_init_secondary(struct rte_eth_dev *dev)
>   *
>   * @return
>   *   A valid Ethernet device object on success, NULL otherwise and rte_errno
> - *   is set.
> + *   is set. The following error is defined:
> + *
> + *   EBUSY: device is not supposed to be spawned.
>   */
>  static struct rte_eth_dev *
>  mlx5_dev_spawn(struct rte_device *dpdk_dev, @@ -723,6 +732,26 @@
> mlx5_dev_spawn(struct rte_device *dpdk_dev,
>  	int own_domain_id = 0;
>  	unsigned int i;
> 
> +	/* Determine if this port representor is supposed to be spawned. */
> +	if (switch_info->representor && dpdk_dev->devargs) {
> +		struct rte_eth_devargs eth_da;
> +
> +		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",
> +				strerror(rte_errno));
> +			return NULL;
> +		}
> +		for (i = 0; i < eth_da.nb_representor_ports; ++i)
> +			if (eth_da.representor_ports[i] ==
> +			    (uint16_t)switch_info->port_name)
> +				break;
> +		if (i == eth_da.nb_representor_ports) {
> +			rte_errno = EBUSY;

Why EBUSY is the correct errno? Will another attempts to probe the device can be successful? 

> +			return NULL;
> +		}
> +	}
>  	/* Prepare shared data between primary and secondary process. */
>  	mlx5_prepare_shared_data();
>  	errno = 0;
> @@ -1343,8 +1372,12 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv
> __rte_unused,
> 
>  		list[i].eth_dev = mlx5_dev_spawn
>  			(&pci_dev->device, list[i].ibv_dev, vf, &list[i].info);
> -		if (!list[i].eth_dev)
> -			break;
> +		if (!list[i].eth_dev) {
> +			if (rte_errno != EBUSY)
> +				break;
> +			/* Device is disabled, ignore it. */
> +			continue;
> +		}
>  		restore = list[i].eth_dev->data->dev_flags;
>  		rte_eth_copy_pci_info(list[i].eth_dev, pci_dev);
>  		/* Restore non-PCI flags cleared by the above call. */ @@ -
> 1370,6 +1403,8 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv
> __rte_unused,
>  		ret = -rte_errno;
>  		/* Roll back. */
>  		while (i--) {
> +			if (!list[i].eth_dev)
> +				continue;
>  			mlx5_dev_close(list[i].eth_dev);
>  			if (rte_eal_process_type() == RTE_PROC_PRIMARY)
>  				rte_free(list[i].eth_dev->data-
> >dev_private);
> --
> 2.11.0
  
Adrien Mazarguil July 10, 2018, 9:37 a.m. UTC | #2
On Mon, Jul 09, 2018 at 11:57:37AM +0000, Shahaf Shuler wrote:
> Thursday, July 5, 2018 11:46 AM, Adrien Mazarguil:
> > Subject: [PATCH v4 09/10] 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>
> > Reviewed-by: Xueming Li <xuemingl@mellanox.com>
> > --
> > v3 changes:
> > 
> > - Adapted representor detection to the reworked mlx5_dev_spawn().
<snip>
> > @@ -672,7 +679,9 @@ mlx5_uar_init_secondary(struct rte_eth_dev *dev)
> >   *
> >   * @return
> >   *   A valid Ethernet device object on success, NULL otherwise and rte_errno
> > - *   is set.
> > + *   is set. The following error is defined:
> > + *
> > + *   EBUSY: device is not supposed to be spawned.
> >   */
> >  static struct rte_eth_dev *
> >  mlx5_dev_spawn(struct rte_device *dpdk_dev, @@ -723,6 +732,26 @@
> > mlx5_dev_spawn(struct rte_device *dpdk_dev,
> >  	int own_domain_id = 0;
> >  	unsigned int i;
> > 
> > +	/* Determine if this port representor is supposed to be spawned. */
> > +	if (switch_info->representor && dpdk_dev->devargs) {
> > +		struct rte_eth_devargs eth_da;
> > +
> > +		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",
> > +				strerror(rte_errno));
> > +			return NULL;
> > +		}
> > +		for (i = 0; i < eth_da.nb_representor_ports; ++i)
> > +			if (eth_da.representor_ports[i] ==
> > +			    (uint16_t)switch_info->port_name)
> > +				break;
> > +		if (i == eth_da.nb_representor_ports) {
> > +			rte_errno = EBUSY;
> 
> Why EBUSY is the correct errno? Will another attempts to probe the device can be successful? 

That's the definition of EAGAIN :)

I thought EBUSY in the sense of "don't disturb" would be appropriate. This
value was also chosen because it is not likely to be returned by any
intermediate function calls. I've defined EBUSY along with the return value
of this function for clarity (see above). Any suggestion?
  
Shahaf Shuler July 10, 2018, 10:16 a.m. UTC | #3
Tuesday, July 10, 2018 12:37 PM, Adrien Mazarguil:
> Subject: Re: [PATCH v4 09/10] net/mlx5: add parameter for port
> representors
> 
> On Mon, Jul 09, 2018 at 11:57:37AM +0000, Shahaf Shuler wrote:
> > Thursday, July 5, 2018 11:46 AM, Adrien Mazarguil:
> > > Subject: [PATCH v4 09/10] 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>
> > > Reviewed-by: Xueming Li <xuemingl@mellanox.com>
> > > --
> > > v3 changes:
> > >
> > > - Adapted representor detection to the reworked mlx5_dev_spawn().
> <snip>
> > > @@ -672,7 +679,9 @@ mlx5_uar_init_secondary(struct rte_eth_dev
> *dev)
> > >   *
> > >   * @return
> > >   *   A valid Ethernet device object on success, NULL otherwise and
> rte_errno
> > > - *   is set.
> > > + *   is set. The following error is defined:
> > > + *
> > > + *   EBUSY: device is not supposed to be spawned.
> > >   */
> > >  static struct rte_eth_dev *
> > >  mlx5_dev_spawn(struct rte_device *dpdk_dev, @@ -723,6 +732,26 @@
> > > mlx5_dev_spawn(struct rte_device *dpdk_dev,
> > >  	int own_domain_id = 0;
> > >  	unsigned int i;
> > >
> > > +	/* Determine if this port representor is supposed to be spawned. */
> > > +	if (switch_info->representor && dpdk_dev->devargs) {
> > > +		struct rte_eth_devargs eth_da;
> > > +
> > > +		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",
> > > +				strerror(rte_errno));
> > > +			return NULL;
> > > +		}
> > > +		for (i = 0; i < eth_da.nb_representor_ports; ++i)
> > > +			if (eth_da.representor_ports[i] ==
> > > +			    (uint16_t)switch_info->port_name)
> > > +				break;
> > > +		if (i == eth_da.nb_representor_ports) {
> > > +			rte_errno = EBUSY;
> >
> > Why EBUSY is the correct errno? Will another attempts to probe the device
> can be successful?
> 
> That's the definition of EAGAIN :)
> 
> I thought EBUSY in the sense of "don't disturb" would be appropriate. This
> value was also chosen because it is not likely to be returned by any
> intermediate function calls. I've defined EBUSY along with the return value of
> this function for clarity (see above). Any suggestion?

How about ENODEV ?

> 
> --
> Adrien Mazarguil
> 6WIND
  
Adrien Mazarguil July 10, 2018, 10:58 a.m. UTC | #4
On Tue, Jul 10, 2018 at 10:16:03AM +0000, Shahaf Shuler wrote:
> Tuesday, July 10, 2018 12:37 PM, Adrien Mazarguil:
> > Subject: Re: [PATCH v4 09/10] net/mlx5: add parameter for port
> > representors
> > 
> > On Mon, Jul 09, 2018 at 11:57:37AM +0000, Shahaf Shuler wrote:
> > > Thursday, July 5, 2018 11:46 AM, Adrien Mazarguil:
> > > > Subject: [PATCH v4 09/10] 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>
> > > > Reviewed-by: Xueming Li <xuemingl@mellanox.com>
> > > > --
> > > > v3 changes:
> > > >
> > > > - Adapted representor detection to the reworked mlx5_dev_spawn().
> > <snip>
> > > > @@ -672,7 +679,9 @@ mlx5_uar_init_secondary(struct rte_eth_dev
> > *dev)
> > > >   *
> > > >   * @return
> > > >   *   A valid Ethernet device object on success, NULL otherwise and
> > rte_errno
> > > > - *   is set.
> > > > + *   is set. The following error is defined:
> > > > + *
> > > > + *   EBUSY: device is not supposed to be spawned.
> > > >   */
> > > >  static struct rte_eth_dev *
> > > >  mlx5_dev_spawn(struct rte_device *dpdk_dev, @@ -723,6 +732,26 @@
> > > > mlx5_dev_spawn(struct rte_device *dpdk_dev,
> > > >  	int own_domain_id = 0;
> > > >  	unsigned int i;
> > > >
> > > > +	/* Determine if this port representor is supposed to be spawned. */
> > > > +	if (switch_info->representor && dpdk_dev->devargs) {
> > > > +		struct rte_eth_devargs eth_da;
> > > > +
> > > > +		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",
> > > > +				strerror(rte_errno));
> > > > +			return NULL;
> > > > +		}
> > > > +		for (i = 0; i < eth_da.nb_representor_ports; ++i)
> > > > +			if (eth_da.representor_ports[i] ==
> > > > +			    (uint16_t)switch_info->port_name)
> > > > +				break;
> > > > +		if (i == eth_da.nb_representor_ports) {
> > > > +			rte_errno = EBUSY;
> > >
> > > Why EBUSY is the correct errno? Will another attempts to probe the device
> > can be successful?
> > 
> > That's the definition of EAGAIN :)
> > 
> > I thought EBUSY in the sense of "don't disturb" would be appropriate. This
> > value was also chosen because it is not likely to be returned by any
> > intermediate function calls. I've defined EBUSY along with the return value of
> > this function for clarity (see above). Any suggestion?
> 
> How about ENODEV ?

Already used by many internal functions, typically returned if the
associated netdevice doesn't exist (e.g. sent to another netns; a fatal
error when probing representors).

We need a unique error code that says "OK, no problem, just not this one".
  
Shahaf Shuler July 10, 2018, 11:15 a.m. UTC | #5
Tuesday, July 10, 2018 1:58 PM, Adrien Mazarguil:
> Subject: Re: [PATCH v4 09/10] net/mlx5: add parameter for port
> representors
> 
> On Tue, Jul 10, 2018 at 10:16:03AM +0000, Shahaf Shuler wrote:
> > Tuesday, July 10, 2018 12:37 PM, Adrien Mazarguil:
> > > Subject: Re: [PATCH v4 09/10] net/mlx5: add parameter for port
> > > representors
> > >
> > > On Mon, Jul 09, 2018 at 11:57:37AM +0000, Shahaf Shuler wrote:
> > > > Thursday, July 5, 2018 11:46 AM, Adrien Mazarguil:
> > > > > Subject: [PATCH v4 09/10] 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>
> > > > > Reviewed-by: Xueming Li <xuemingl@mellanox.com>
> > > > > --
> > > > > v3 changes:
> > > > >
> > > > > - Adapted representor detection to the reworked
> mlx5_dev_spawn().
> > > <snip>
> > > > > @@ -672,7 +679,9 @@ mlx5_uar_init_secondary(struct rte_eth_dev
> > > *dev)
> > > > >   *
> > > > >   * @return
> > > > >   *   A valid Ethernet device object on success, NULL otherwise and
> > > rte_errno
> > > > > - *   is set.
> > > > > + *   is set. The following error is defined:
> > > > > + *
> > > > > + *   EBUSY: device is not supposed to be spawned.
> > > > >   */
> > > > >  static struct rte_eth_dev *
> > > > >  mlx5_dev_spawn(struct rte_device *dpdk_dev, @@ -723,6 +732,26
> > > > > @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
> > > > >  	int own_domain_id = 0;
> > > > >  	unsigned int i;
> > > > >
> > > > > +	/* Determine if this port representor is supposed to be
> spawned. */
> > > > > +	if (switch_info->representor && dpdk_dev->devargs) {
> > > > > +		struct rte_eth_devargs eth_da;
> > > > > +
> > > > > +		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",
> > > > > +				strerror(rte_errno));
> > > > > +			return NULL;
> > > > > +		}
> > > > > +		for (i = 0; i < eth_da.nb_representor_ports; ++i)
> > > > > +			if (eth_da.representor_ports[i] ==
> > > > > +			    (uint16_t)switch_info->port_name)
> > > > > +				break;
> > > > > +		if (i == eth_da.nb_representor_ports) {
> > > > > +			rte_errno = EBUSY;
> > > >
> > > > Why EBUSY is the correct errno? Will another attempts to probe the
> > > > device
> > > can be successful?
> > >
> > > That's the definition of EAGAIN :)
> > >
> > > I thought EBUSY in the sense of "don't disturb" would be
> > > appropriate. This value was also chosen because it is not likely to
> > > be returned by any intermediate function calls. I've defined EBUSY
> > > along with the return value of this function for clarity (see above). Any
> suggestion?
> >
> > How about ENODEV ?
> 
> Already used by many internal functions, typically returned if the associated
> netdevice doesn't exist (e.g. sent to another netns; a fatal error when
> probing representors).
> 
> We need a unique error code that says "OK, no problem, just not this one".

OK, we can keep the EBUSY. 

> 
> --
> Adrien Mazarguil
> 6WIND
  

Patch

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index 7dd9c1c5e..0d0d21727 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -392,6 +392,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 4b69f6cbe..b2cf48354 100644
--- a/doc/guides/prog_guide/poll_mode_drv.rst
+++ b/doc/guides/prog_guide/poll_mode_drv.rst
@@ -360,6 +360,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 6592480bf..12a77afa8 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -92,6 +92,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)
@@ -443,6 +446,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) {
@@ -515,6 +521,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;
@@ -672,7 +679,9 @@  mlx5_uar_init_secondary(struct rte_eth_dev *dev)
  *
  * @return
  *   A valid Ethernet device object on success, NULL otherwise and rte_errno
- *   is set.
+ *   is set. The following error is defined:
+ *
+ *   EBUSY: device is not supposed to be spawned.
  */
 static struct rte_eth_dev *
 mlx5_dev_spawn(struct rte_device *dpdk_dev,
@@ -723,6 +732,26 @@  mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	int own_domain_id = 0;
 	unsigned int i;
 
+	/* Determine if this port representor is supposed to be spawned. */
+	if (switch_info->representor && dpdk_dev->devargs) {
+		struct rte_eth_devargs eth_da;
+
+		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",
+				strerror(rte_errno));
+			return NULL;
+		}
+		for (i = 0; i < eth_da.nb_representor_ports; ++i)
+			if (eth_da.representor_ports[i] ==
+			    (uint16_t)switch_info->port_name)
+				break;
+		if (i == eth_da.nb_representor_ports) {
+			rte_errno = EBUSY;
+			return NULL;
+		}
+	}
 	/* Prepare shared data between primary and secondary process. */
 	mlx5_prepare_shared_data();
 	errno = 0;
@@ -1343,8 +1372,12 @@  mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 
 		list[i].eth_dev = mlx5_dev_spawn
 			(&pci_dev->device, list[i].ibv_dev, vf, &list[i].info);
-		if (!list[i].eth_dev)
-			break;
+		if (!list[i].eth_dev) {
+			if (rte_errno != EBUSY)
+				break;
+			/* Device is disabled, ignore it. */
+			continue;
+		}
 		restore = list[i].eth_dev->data->dev_flags;
 		rte_eth_copy_pci_info(list[i].eth_dev, pci_dev);
 		/* Restore non-PCI flags cleared by the above call. */
@@ -1370,6 +1403,8 @@  mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		ret = -rte_errno;
 		/* Roll back. */
 		while (i--) {
+			if (!list[i].eth_dev)
+				continue;
 			mlx5_dev_close(list[i].eth_dev);
 			if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 				rte_free(list[i].eth_dev->data->dev_private);