From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ophir Munk Subject: [PATCH v4 1/3] net/mlx5: allow multiple probing for representor Date: Tue, 23 Oct 2018 18:26:03 +0000 Message-ID: <1540319157-11191-1-git-send-email-ophirmu@mellanox.com> References: <1539936770-24252-1-git-send-email-ophirmu@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: Thomas Monjalon , Olga Shern , Asaf Penso , Shahaf Shuler To: "dev@dpdk.org" , Yongseok Koh , Ophir Munk Return-path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0059.outbound.protection.outlook.com [104.47.0.59]) by dpdk.org (Postfix) with ESMTP id B24B71B104 for ; Tue, 23 Oct 2018 20:26:04 +0200 (CEST) In-Reply-To: <1539936770-24252-1-git-send-email-ophirmu@mellanox.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Implement probing of a rte device multiple times, see [1]. Set PCI driver RTE_PCI_DRV_PROBE_AGAIN flag to enable multiple probing of the PCI device by the PCI common driver. Consecutive probing requests with a devargs string may contain repetitive master and representors devices for which eth device should be created only once. In case an eth device already exists - silently ignore it. [1] commit e9d159c3d534 ("eal: allow probing a device again") Signed-off-by: Ophir Munk --- v1: Initial release v2: Rebase + code review updates https://patches.dpdk.org/patch/45927/ v3: - Set PCI driver RTE_PCI_DRV_PROBE_AGAIN flag required by PCI common driver - Update commit message v4: Update commit message. Specify reference [1] as commit number drivers/net/mlx5/mlx5.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 297cbff..93b4057 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -694,9 +694,10 @@ * * @return * A valid Ethernet device object on success, NULL otherwise and rte_err= no - * 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, @@ -745,6 +746,7 @@ struct ether_addr mac; char name[RTE_ETH_NAME_MAX_LEN]; int own_domain_id =3D 0; + uint16_t port_id; unsigned int i; =20 /* Determine if this port representor is supposed to be spawned. */ @@ -767,6 +769,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) =3D=3D 0) { + rte_errno =3D EEXIST; + return NULL; + } /* Prepare shared data between primary and secondary process. */ mlx5_prepare_shared_data(); errno =3D 0; @@ -873,11 +886,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() =3D=3D RTE_PROC_SECONDARY) { eth_dev =3D rte_eth_dev_attach_secondary(name); @@ -1421,9 +1429,9 @@ struct mlx5_dev_spawn_data { list[i].eth_dev =3D mlx5_dev_spawn (&pci_dev->device, list[i].ibv_dev, vf, &list[i].info); if (!list[i].eth_dev) { - if (rte_errno !=3D EBUSY) + if (rte_errno !=3D EBUSY && rte_errno !=3D EEXIST) break; - /* Device is disabled, ignore it. */ + /* Device is disabled or already spawned. Ignore it. */ continue; } restore =3D list[i].eth_dev->data->dev_flags; @@ -1518,7 +1526,8 @@ struct mlx5_dev_spawn_data { }, .id_table =3D mlx5_pci_id_map, .probe =3D mlx5_pci_probe, - .drv_flags =3D RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV, + .drv_flags =3D RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV | + RTE_PCI_DRV_PROBE_AGAIN, }; =20 #ifdef RTE_LIBRTE_MLX5_DLOPEN_DEPS --=20 1.8.3.1