From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raslan Darawsheh Subject: [PATCH v2 4/4] net/failsafe: support secondary process Date: Tue, 5 Mar 2019 09:52:06 +0000 Message-ID: <1551779507-10857-4-git-send-email-rasland@mellanox.com> References: <1551779507-10857-1-git-send-email-rasland@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" , Thomas Monjalon , Raslan Darawsheh , "stephen@networkplumber.org" To: "gaetan.rivet@6wind.com" Return-path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10084.outbound.protection.outlook.com [40.107.1.84]) by dpdk.org (Postfix) with ESMTP id E8CA52BA7 for ; Tue, 5 Mar 2019 10:52:07 +0100 (CET) In-Reply-To: <1551779507-10857-1-git-send-email-rasland@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" Add implementation for probe in secondary. Failsafe will attempt to attach all the sub-devices in secondary process. Signed-off-by: Raslan Darawsheh Signed-off-by: Thomas Monjalon --- v2: changed devargs_alread_listed return value to be bool. --- drivers/net/failsafe/failsafe.c | 45 +++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsaf= e.c index 68926ca..c3f568b 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -3,6 +3,8 @@ * Copyright 2017 Mellanox Technologies, Ltd */ =20 +#include + #include #include #include @@ -312,11 +314,28 @@ fs_rte_eth_free(const char *name) return ret; } =20 +static bool +devargs_already_listed(struct rte_devargs *devargs) +{ + struct rte_devargs *list_da; + + RTE_EAL_DEVARGS_FOREACH(devargs->bus->name, list_da) { + if (strcmp(list_da->name, devargs->name) =3D=3D 0) + /* devargs already in the list */ + return true; + } + return false; +} + static int rte_pmd_failsafe_probe(struct rte_vdev_device *vdev) { const char *name; struct rte_eth_dev *eth_dev; + struct sub_device *sdev; + struct rte_devargs devargs; + uint8_t i; + int ret; =20 name =3D rte_vdev_device_name(vdev); INFO("Initializing " FAILSAFE_DRIVER_NAME " for %s", @@ -329,9 +348,33 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev) ERROR("Failed to probe %s", name); return -1; } - /* TODO: request info from primary to set up Rx and Tx */ eth_dev->dev_ops =3D &failsafe_ops; eth_dev->device =3D &vdev->device; + eth_dev->rx_pkt_burst =3D (eth_rx_burst_t)&failsafe_rx_burst; + eth_dev->tx_pkt_burst =3D (eth_tx_burst_t)&failsafe_tx_burst; + /* + * Failsafe will attempt to probe all of its sub-devices. + * Any failure in sub-devices is not a fatal error. + * A sub-device can be plugged later. + */ + FOREACH_SUBDEV(sdev, i, eth_dev) { + /* rebuild devargs to be able to get the bus name. */ + ret =3D rte_devargs_parse(&devargs, + sdev->devargs.name); + if (ret !=3D 0) { + ERROR("Failed to parse devargs %s", + devargs.name); + continue; + } + if (!devargs_already_listed(&devargs)) { + ret =3D rte_dev_probe(devargs.name); + if (ret !=3D 0) { + ERROR("Failed to probe devargs %s", + devargs.name); + continue; + } + } + } rte_eth_dev_probing_finish(eth_dev); return 0; } --=20 2.7.4