From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20067.outbound.protection.outlook.com [40.107.2.67]) by dpdk.org (Postfix) with ESMTP id 07225107A for ; Wed, 13 Dec 2017 15:29:45 +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=NHR60l/id2sdBDdurl6rg9xEfP4nxZAhz8yUktGw/IM=; b=Q6ZrQIA6VzZgA4furiuu49ldaWkcZYK9VfVLgeqwkAyUv4YsaaTd+ySBg2+uGWmrjvkayF3c6GVuo2xJk70HFaRH9ld5AU4z44Zv2WRT4R4j0XLgumkGl1Y2u1kZ/BYaNWQnL3BNyNNSj9LgjYFDV2bKLIFXoRJ+udLslEIouBI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM0PR0502MB3649.eurprd05.prod.outlook.com (2603:10a6:208:1d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Wed, 13 Dec 2017 14:29:43 +0000 From: Matan Azrad To: Adrien Mazarguil , Thomas Monjalon , Gaetan Rivet Cc: dev@dpdk.org Date: Wed, 13 Dec 2017 14:29:27 +0000 Message-Id: <1513175370-16583-2-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1513175370-16583-1-git-send-email-matan@mellanox.com> References: <1509637324-13525-1-git-send-email-matan@mellanox.com> <1513175370-16583-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: DB6PR0301CA0049.eurprd03.prod.outlook.com (2603:10a6:4:54::17) To AM0PR0502MB3649.eurprd05.prod.outlook.com (2603:10a6:208:1d::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de52cfdf-469a-42b5-3317-08d54235f431 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(48565401081)(2017052603307); SRVR:AM0PR0502MB3649; X-Microsoft-Exchange-Diagnostics: 1; AM0PR0502MB3649; 3:GK7Y25AdkVtQycj0t70b5pXlSrr9W/EMEixC3ocujumpbvxkHn/Lm/Cdu3gkz+xKRn4JG8I3Cm2F0B+BZNMU1hCoEpt7ajfUD/wYvzU9ZNH5EiA9XYkS7kqjGSOqfvPnNwgmYRTUcMRz+0lXMSdBWqVX4Fit0vGSMv1cLa+1DNeB5hgE1eXluJu2A2ARDYSamPH+4zWKfE2x0BQHjYLHk0N8g7DMMaAvLPlXS+kCY2nWosjPMX9OOsQasntQmW+o; 25:06DVTbJFCMV43m24S9IncbMTpPUYaZabzvDcd7eALmXSUNrF1lG3HMMgmkoZpTlJmUI7JASJpv2TnfjJeM6m2uViPXI/k9BaRNEiSXMoRRqvzULfd6zlBKQiNGblw5is3keuqOFypOZmNx50E6G/j+pIeM6ZD4uyLMv6g7cg4t8t/DOM57Zfl6BCp8zPJFoQTGpVqrujwB0uZC9qH47WZf1CWpAtaIb6tPVTYGFHWkDUPPF7KhPnHmQ8wYpnYAWeWw7A1XaLyVPKuQaKCWVChLG+Ob88KJkeEdcSi6N8qsjpAS66i59AWldGc9hG2YZmUP6rzpi7pIDCYNu9vB8Tjw==; 31:NnmgptGqjZ0YpETUTOSzi9aXaseWgylC4+ydI9JBVUvczj8L/IRaAQ9vXIrSmw238XQpnH4Cdh0B8Ruh95mRL0+hwyWHaHJkDTwAIAVCz6thnaNq0fecOwSdxF3ESKd8ximCjvDBkqCOeIk/TX0IPJfBBQohcQzzQLPe7Lckrcy7S+DS9+OFeRie9sH2eXbd5spMdUzLaPAkJzOMZChF71cAikHXiNiwaXv8XoBHIqU= X-MS-TrafficTypeDiagnostic: AM0PR0502MB3649: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM0PR0502MB3649; 20:q+/f/IgysRnWakfgucNJeWRM88HdcTcENsGN/15/nUjs5xiOUkeMYmGL/vPmwaG9RnTBIDCWgYs6i73CY4WdcA0FiyIT4/KgD+Cd2pcWzHHsN/5N0K+qNAxlfGfAUzF3ILejMi0ZUXtIyOUpaK0833SH/aPIdHsURDDWFrjFiuXanBf8aqk+LvX7qpH9QverWHuSEojz5G9SC+3Her/xh8RG6sfdgK5AtCwkZ82vyxAlsLTR10LPmNNIjQ8IfhGbp38YIKlHahtTLgX2f26n+yJruBdsGZh9juw8Y48CNzoY0FuxCFrIjpYmAHB6yE9dR72OC+Z4Sr0ViH60476n8on+eGKtPAsUAbO8NFbuRqDtb3dEUW5JWyueh5nmQojNg7Fg5l0WrnBy/3nuNczQnGaYftCMBsZUQo+99gIPYP/nBVIgquGMKeejJKuJDwzb0pgc7dP5f1V3AVTC+rfAFHL8/beZq5eK4IcLiIWRU02j2oNc9y2cEsqSGasVPTa5; 4:zmqRVlDEFVGtkwxuVMrqQKBGM4vED7YUptdXZ83dLWfyQh2cWt3uILY+wfFmnNfaGZo+9dJYIx4swvk/MQVLd2pWJCuKQQRcDRxakI/4E9RnsTBMZEDO5kDzR/jD/4L22Lm5LJhPf9fzyHk7ky0uuAmHCLfXZM3ym5xH65AZU4A0GOT0tjTbaTR+7ANaDSSoJ/WFlGhalHjOMWI8qbjm+GlgvGczj/Bhzhk91+TjVL7F3xubJF0n3Vw4cSoCrLEsqvA2nI6bhVaerwrafXwPty4y+5XixSN/IXu3v7G8WjbpQD01Nouzq1nM8VN1XKu7 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(3231023)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123560025)(20161123558100)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM0PR0502MB3649; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM0PR0502MB3649; X-Forefront-PRVS: 052017CAF1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(376002)(346002)(199004)(189003)(8936002)(305945005)(16526018)(51416003)(7696005)(106356001)(68736007)(52116002)(4326008)(81156014)(3846002)(16586007)(81166006)(36756003)(6116002)(97736004)(316002)(76176011)(8676002)(86362001)(5660300001)(33026002)(66066001)(575784001)(7736002)(4720700003)(53936002)(47776003)(478600001)(2906002)(69596002)(6666003)(25786009)(110136005)(5890100001)(55016002)(50226002)(48376002)(59450400001)(2950100002)(50466002)(21086003)(386003)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3649; 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; AM0PR0502MB3649; 23:1utJWAOmcVwZE0cRxFv7Ssm7/Q4SMW/Xi9DV+6F?= =?us-ascii?Q?HjYqPpJSRQtaQREzeJWAHLYs510hnTnaUIA/md/Y9SxQX0UUdA4taA0dNxKg?= =?us-ascii?Q?zyXVqeZ+ACVy9JW7ZN4kLv1hkohCfR8PA/TdewylDLpWCQH2Ujf4AuZ2UbH/?= =?us-ascii?Q?dtUtGctZJ9maJ9OiT8FU+f6ARAgvv1NCBzUDLPi0TRqLYkDBDn09XwRAmW4K?= =?us-ascii?Q?oop6tFRWeRfQQONqOcqKWuoLSdeQa3PxF6pMZhe6AmYEJI/QWAUDDDsAUQbk?= =?us-ascii?Q?dsJUfgJC06BhT10uG2dHRHTPePxI3st2Iwb5IOEYK1j3+lUcnRoMcBBBzo7j?= =?us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exchange-Diagnostics: 1; AM0PR0502MB3649; 6:yf5AP/jdA80L+R1vVJVIROMgx/hb8AbNFmwYJ9LwaMZnU+7EdTFovtJ1lWkHbk6XvbyhCAAhZc7nm+Hfx+dS8BnlycXGnnM1wO1XugnkOAuPoyBQ3CvKENFbQD32eTGnpppU+3cu9oj3IX/G7FJHqE9jQofbkugIKtwmhInHBYxE7TGLjt1E8dJjvy8rNkl1zGwI03QpXAZPB5rs37uT3ESl0SKRJeWR5xYvbDyndXBUu7JJ1EmEbu77DWE7IzA1WDGXarBi66H9LL5n7onoW0ySaK0Wk1oatSELKcwX/lX1JaC8Q3O76JDqfng5CVMVY5pMHjhDjxjijidCuNK5Ka+/XRF4q8ONMUqhGzidBpU=; 5:NhLHtwMmEENxWwFEFKcFzx6pq29MICnVD0nQ98X47p36w+6WPRt6yt+1lwLCBDpORcd/SEs2vK6vtUSFAFGlDlO+BhJmEtPcwjuC5x7xCLe4CieI+3Zn1D8kacznm6M32hurviz09Efs6NG3b4UISD+B3kiqOwYtm3waM4NgSx8=; 24:jDizKmHxxNkpSfWaT4LLWOEbgmWXOutpuM9CXoDeJ419uWRHiczRgJrb7YPqxFJRnHEpA4HJAgBNYqcUA+ivqX3NEn9ZHzb4xapNCBXtcEk=; 7:VA9p9yxuj0Mu/UaNCf3VezoEbAUP8eXfRtEEe2G1J7NUCggZp2n+rLYP3O6WCZWCK6ilaQLXMzpkErsn28iYDpU1eoWV/O3O5BNg4rWETWRGf9MAUcrZRY+jI+g7zP32d6YLgwWZ1E0owHXknzLM4quOW3h8281ryueEB/4f5V4rIf01162qb2W7YUsk4pUq/Ch0ePwyhXLBK39cKVI4gJNJk1UDKLpgE1N1X0wFhLgSoKPVK96YT95TQkbElect SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2017 14:29:43.2076 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de52cfdf-469a-42b5-3317-08d54235f431 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3649 Subject: [dpdk-dev] [PATCH v2 1/4] 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, 13 Dec 2017 14:29:46 -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 --- 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