From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0072.outbound.protection.outlook.com [104.47.1.72]) by dpdk.org (Postfix) with ESMTP id B1EBF1B1D6 for ; Wed, 10 Jan 2018 13:31:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=mHPJ9QO53IlHAlfAuq55PF24GBhwuakuvpy5jxSWe6E=; b=wJriFh9XB1nSqkhdp6o7hiF0U/5s2THp8sGyRAriN2kssbQ674GwtIpTyMfzFvQpTq2rTT6Z4lXoeDePia3W9af8ljlxWPFNIxNRv6Eqn3O7+Swwfu29Scy+0LgBaTw08LNKL4ruNWD2Vmvl8ERaLdMhOk9/usYzyZ+2KpV0qsY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM0PR0502MB3796.eurprd05.prod.outlook.com (2603:10a6:208:1e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Wed, 10 Jan 2018 12:31:26 +0000 From: Matan Azrad To: Thomas Monjalon , Gaetan Rivet Cc: dev@dpdk.org Date: Wed, 10 Jan 2018 12:31:00 +0000 Message-Id: <1515587465-9304-2-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515587465-9304-1-git-send-email-matan@mellanox.com> References: <1513703415-29145-1-git-send-email-matan@mellanox.com> <1515587465-9304-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: AM0PR0102CA0064.eurprd01.prod.exchangelabs.com (2603:10a6:208::41) To AM0PR0502MB3796.eurprd05.prod.outlook.com (2603:10a6:208:1e::30) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c6c3ec1c-67c7-45a0-0916-08d558261157 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:AM0PR0502MB3796; X-Microsoft-Exchange-Diagnostics: 1; AM0PR0502MB3796; 3:wdv7krzIEs4IzrrZnSN7NdUqXZyLhwkoYm9barsOGG3vtpzM6IZV7oR/hPBIx9jDBAi3tOdpket3P0W1Cj6P9c/Q3VjZJ9aSAjCWGj12gpwfvzWjzIKeIQXYYl0KDjtkOD3dKNrnbZ1vPhIkl6du9AjWmS6z6RE9Z7Gdbu31+EYdiNJdIc+QLaIgq+tUAtALPedEl9cb1Aj7y5P9EE61pqptewhZFg1WhWNnNyodZBqbK6+F1B1b5dnY7AkSF4Nw; 25:SmaN/IECvqdR9DJRw6zYiOmmeK49bXLK/kJKANxl4cBVe2sNN24j3BCJ72nI/wE3d+mFC5oopD8dFH0FoOzHFA2t1BcPtVojNPuBGV6SihMeHS3hPsApUIpG9g3bTZ4gtZfUTQLx+b4OlLjzuaZ3lV4lqp5mm6XpmStRizEx8yMY56+AxzNsCjDLs92D2dgy0+1z2wkZO0+GsFQYNJiFa8HyfZrxLfRT53x52bo4igfIlZRW9Pa6R3OIH2+ogh8FTVt0S6SLZAsLypHAe/nir2qJk8tKD0z+261TfMVpH4tjP3w/GgsMWOWslTOyyfoFH8WMqH3RPV/ISPwOhK/9nw==; 31:VWxVma/JBEy3yM5kEKvcVsJ2hG6aTd9ZMP5p/ftpeqS3vV64yzJHdx5BlA1E7QYEQYwimT+YrOTj8o9/RoVpxL1Xrqu6tuHbft1FtZvdycIUuKw/xCJz0Dd5l2AmP1ml/tWrSNbpCn6tHSXyECHt2bErfvmcsTcp1WybU4e+IUW3tcvFn4/Nd+VkJAPNm41V7+chMVMRiqgRIUDTqvQGc7atmf/GVDdl8XSZbNIncbk= X-MS-TrafficTypeDiagnostic: AM0PR0502MB3796: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM0PR0502MB3796; 20:GgpuXkd+tKi5LzPqqofv5wzFLEotAZEQ7tsy9EOsdmmiHg5GuiDuPGfuLNOTGjhMZpcgj5oiu9qpuopDzGaj4RnoBrhKSzBB/uyx2DBY8loVCnkoenonaBf2FnR62CcYIVTxx1gPnhK/Ph3a0/SaWJtYFPRBmU+W3oWAdXq4rmm0Y7vl9LmY6D5WRgW3LNLqCl+y5VYMcA8kdBB0wM1KKXVIebAH9hTSY+ZVd3WS6ymqasF5uQnqfBkoPI0L6W4TmBwD03aKgfxNyq/UEgkRLuh3su365QidQfBoI+mozv7O/H9nq1pToHHV8ZxOc28KFBynjwgjAziDw5yC0WwZkLzbL39/cAy1dgTFjqn/Bchp/gn03eFA9qvDSOS3gKwZlA+oFIdYWLki6EkhPiSwoLFBOGFWRXwQFY0IWS4p2EEEV4vovcCAWRpg+AVxjSVRVxF+nTTb42FJECAmLTReKRdblCKxhT54wNIrSpfnqo1PIV5ZVX/Nzyk/moKfl5Tc; 4:H/90057NWCEGt3XnUM+76GFv8WNA9cF8kC7depYAtdPt2lUz7xLNvQqYOv37Ny4pY4KQVv+8N+Mh3ZaoNF9xbDJm8UCYOdvWcEsqlOaKgK+pRsYL/w3Vb96Ds5wGuMq7hG19Z6w/l/XakQI6k3kpINE0N9gmhAOJRaWbDmtxVTge6lUXMAd3dludRCiJ927uatDOjhpQKiFI4+yy75t32uToc6RHh8CXKqw9aQKF2S72NuKYUrDIokpqdpMrQOLXjn1FQVAiTpoYO5VawcsRa7l6KastzKRgLh/2uekvLot8O1d0/T5B3w5KqrgYjpjX X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231023)(944501075)(10201501046)(3002001)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:AM0PR0502MB3796; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM0PR0502MB3796; X-Forefront-PRVS: 0548586081 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(396003)(376002)(39860400002)(366004)(39380400002)(199004)(189003)(55016002)(68736007)(21086003)(25786009)(6666003)(2950100002)(4720700003)(6116002)(3846002)(4326008)(81166006)(8936002)(86362001)(50226002)(97736004)(69596002)(575784001)(53936002)(16586007)(105586002)(16526018)(305945005)(7736002)(48376002)(316002)(8676002)(81156014)(36756003)(110136005)(5660300001)(50466002)(5890100001)(106356001)(66066001)(51416003)(33026002)(52116002)(478600001)(7696005)(386003)(76176011)(59450400001)(47776003)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3796; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR0502MB3796; 23:0WZfSc9j4lezFmJ+3WbhEdyMEiyVq9ZBMwyLNBg?= =?us-ascii?Q?qdq7ZTl0MFmOhppoPxhv/Kj1+tVmcIQm4zI+k3hjz1jdOLFwKSUKn0AZklHL?= =?us-ascii?Q?zmAlTNrB1bJCZxW1igtsQwvi3VXBPzokQtX7hn9WgxgvYQujzEpJSIKOkRZm?= =?us-ascii?Q?ess/CophXJGM/m4CP26UZRQdt2jMqNWcssodT3ir2wVvbHDlxohZFqjNi5wJ?= =?us-ascii?Q?DzUs/IRAn78a1f/s/vG9i3QEC+7y5/B1rgyUvCs/4eMlgk/paB3UB5UCCLsU?= =?us-ascii?Q?G5/j/kA9kvbqAwQy4HCZhiL/w+7C7kBF2A1KBrmp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: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2018 12:31:26.1805 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6c3ec1c-67c7-45a0-0916-08d558261157 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3796 Subject: [dpdk-dev] [PATCH v4 1/6] ethdev: add devop to check removal status X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jan 2018 12:31:27 -0000 There is time between the physical removal of the device until PMDs get a RMV interrupt. At this time DPDK PMDs and applications still don't know about the removal. Current removal detection is achieved only by registration to device RMV event and the notification comes asynchronously. So, there is no option to detect a device removal synchronously. Applications and other DPDK entities may want to check a device removal synchronously and to take an immediate decision accordingly. Add new dev op called is_removed to allow DPDK entities to check an Ethernet device removal status immediately. Signed-off-by: Matan Azrad Acked-by: Thomas Monjalon --- lib/librte_ether/rte_ethdev.c | 28 +++++++++++++++++++++++++--- lib/librte_ether/rte_ethdev.h | 17 +++++++++++++++++ lib/librte_ether/rte_ethdev_version.map | 7 +++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 318af28..c759d0e 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -142,7 +142,8 @@ enum { rte_eth_find_next(uint16_t port_id) { while (port_id < RTE_MAX_ETHPORTS && - rte_eth_devices[port_id].state != RTE_ETH_DEV_ATTACHED) + rte_eth_devices[port_id].state != RTE_ETH_DEV_ATTACHED && + rte_eth_devices[port_id].state != RTE_ETH_DEV_REMOVED) port_id++; if (port_id >= RTE_MAX_ETHPORTS) @@ -286,8 +287,7 @@ struct rte_eth_dev * rte_eth_dev_is_valid_port(uint16_t port_id) { if (port_id >= RTE_MAX_ETHPORTS || - (rte_eth_devices[port_id].state != RTE_ETH_DEV_ATTACHED && - rte_eth_devices[port_id].state != RTE_ETH_DEV_DEFERRED)) + (rte_eth_devices[port_id].state == RTE_ETH_DEV_UNUSED)) return 0; else return 1; @@ -1118,6 +1118,28 @@ struct rte_eth_dev * } int +rte_eth_dev_is_removed(uint16_t port_id) +{ + struct rte_eth_dev *dev; + int ret; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0); + + dev = &rte_eth_devices[port_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->is_removed, 0); + + if (dev->state == RTE_ETH_DEV_REMOVED) + return 1; + + ret = dev->dev_ops->is_removed(dev); + if (ret != 0) + dev->state = RTE_ETH_DEV_REMOVED; + + return ret; +} + +int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 341c2d6..3aa9d3f 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1196,6 +1196,9 @@ struct rte_eth_dcb_info { typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev); /** <@internal Function used to reset a configured Ethernet device. */ +typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev); +/**< @internal Function used to detect an Ethernet device removal. */ + typedef void (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev); /**< @internal Function used to enable the RX promiscuous mode of an Ethernet device. */ @@ -1525,6 +1528,8 @@ struct eth_dev_ops { eth_dev_close_t dev_close; /**< Close device. */ eth_dev_reset_t dev_reset; /**< Reset device. */ eth_link_update_t link_update; /**< Get device link state. */ + eth_is_removed_t is_removed; + /**< Check if the device was physically removed. */ eth_promiscuous_enable_t promiscuous_enable; /**< Promiscuous ON. */ eth_promiscuous_disable_t promiscuous_disable;/**< Promiscuous OFF. */ @@ -1711,6 +1716,7 @@ enum rte_eth_dev_state { RTE_ETH_DEV_UNUSED = 0, RTE_ETH_DEV_ATTACHED, RTE_ETH_DEV_DEFERRED, + RTE_ETH_DEV_REMOVED, }; /** @@ -1997,6 +2003,17 @@ int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue, void _rte_eth_dev_reset(struct rte_eth_dev *dev); /** + * Check if an Ethernet device was physically removed. + * + * @param port_id + * The port identifier of the Ethernet device. + * @return + * - 0 when the Ethernet device is removed, otherwise 1. + */ +int +rte_eth_dev_is_removed(uint16_t port_id); + +/** * Allocate and set up a receive queue for an Ethernet device. * * The function allocates a contiguous block of memory for *nb_rx_desc* diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index e9681ac..78547ff 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -198,6 +198,13 @@ DPDK_17.11 { } DPDK_17.08; +DPDK_18.02 { + global: + + rte_eth_dev_is_removed; + +} DPDK_17.11; + EXPERIMENTAL { global: -- 1.8.3.1