PATCH v3 is expected to accommodate more updates in hotplug series by Thomas. Please do not merge this patch.
> -----Original Message----- > From: Yongseok Koh > Sent: Friday, October 05, 2018 9:06 PM > To: Ophir Munk <ophi...@mellanox.com> > Cc: dev@dpdk.org; Asaf Penso <as...@mellanox.com>; Shahaf Shuler > <shah...@mellanox.com>; Thomas Monjalon <tho...@monjalon.net>; > Olga Shern <ol...@mellanox.com> > Subject: Re: [PATCH v2] net/mlx5: allow multiple probing for representor > > > On Oct 5, 2018, at 4:06 AM, Ophir Munk <ophi...@mellanox.com> wrote: > > > > Implement probing of a device multiple times, see [1]. > > Consecutive probing requests with a devargs string may contain > > repetitive master and representors devices for which eth device should > > be created. If an eth device already exists - silently ignore it. > > > > [1] > > https://patches.dpdk.org/patch/45601/ > > ("eal: allow probing a device again") > > > > Signed-off-by: Ophir Munk <ophi...@mellanox.com> > > --- > Acked-by: Yongseok Koh <ys...@mellanox.com> > > Thanks > > > v1: > > Initial release > > > > v2: > > Rebase + code review updates > > https://patches.dpdk.org/patch/45927/ > > > > drivers/net/mlx5/mlx5.c | 27 ++++++++++++++++----------- > > 1 file changed, 16 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index > > 9131290..a5a9eca 100644 > > --- a/drivers/net/mlx5/mlx5.c > > +++ b/drivers/net/mlx5/mlx5.c > > @@ -693,9 +693,10 @@ > > * > > * @return > > * A valid Ethernet device object on success, NULL otherwise and > rte_errno > > - * is set. The following error is defined: > > + * is set. The following errors are defined: > > * > > * EBUSY: device is not supposed to be spawned. > > + * EEXIST: device is already spawned > > */ > > static struct rte_eth_dev * > > mlx5_dev_spawn(struct rte_device *dpdk_dev, @@ -744,6 +745,7 @@ > > struct ether_addr mac; > > char name[RTE_ETH_NAME_MAX_LEN]; > > int own_domain_id = 0; > > + uint16_t port_id; > > unsigned int i; > > > > /* Determine if this port representor is supposed to be spawned. */ > > @@ -766,6 +768,17 @@ > > return NULL; > > } > > } > > + /* Build device name. */ > > + if (!switch_info->representor) > > + rte_strlcpy(name, dpdk_dev->name, sizeof(name)); > > + else > > + snprintf(name, sizeof(name), "%s_representor_%u", > > + dpdk_dev->name, switch_info->port_name); > > + /* check if the device is already spawned */ > > + if (rte_eth_dev_get_port_by_name(name, &port_id) == 0) { > > + rte_errno = EEXIST; > > + return NULL; > > + } > > /* Prepare shared data between primary and secondary process. */ > > mlx5_prepare_shared_data(); > > errno = 0; > > @@ -872,11 +885,6 @@ > > DEBUG("ibv_query_device_ex() failed"); > > goto error; > > } > > - if (!switch_info->representor) > > - rte_strlcpy(name, dpdk_dev->name, sizeof(name)); > > - else > > - snprintf(name, sizeof(name), "%s_representor_%u", > > - dpdk_dev->name, switch_info->port_name); > > DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name); > > if (rte_eal_process_type() == RTE_PROC_SECONDARY) { > > eth_dev = rte_eth_dev_attach_secondary(name); > > @@ -1306,9 +1314,6 @@ struct mlx5_dev_spawn_data { > > assert(pci_drv == &mlx5_driver); > > errno = 0; > > > > - if (rte_dev_is_probed(&pci_dev->device)) > > - return -EEXIST; > > - > > ibv_list = mlx5_glue->get_device_list(&ret); > > if (!ibv_list) { > > rte_errno = errno ? errno : ENOSYS; > > @@ -1418,9 +1423,9 @@ struct mlx5_dev_spawn_data { > > list[i].eth_dev = mlx5_dev_spawn > > (&pci_dev->device, list[i].ibv_dev, vf, &list[i].info); > > if (!list[i].eth_dev) { > > - if (rte_errno != EBUSY) > > + if (rte_errno != EBUSY && rte_errno != EEXIST) > > break; > > - /* Device is disabled, ignore it. */ > > + /* Device is disabled or already spawned. Ignore it. > */ > > continue; > > } > > restore = list[i].eth_dev->data->dev_flags; > > -- > > 1.8.3.1 > >