From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40074.outbound.protection.outlook.com [40.107.4.74]) by dpdk.org (Postfix) with ESMTP id 754A21B168 for ; Sat, 20 Jan 2018 22:12: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=xnU/0KBUiMxODLPg5hvt605qOJZnzX2g9El+cwhEWOI=; b=u+1Oh83Tdf14uWyCG8gFaqw1nGfH6xMlvsElOhBaCO23BXaphrvq4ITecGM/56f0s+oM+u7d54wXoIT7wwxmjrDMkPynmeio/xkH+XNOgKhQwMupcoVDS8YwxEqPnV6kD62FvGqA5x+0twAVfBE2OgY8ON51njW/JQ6ol/eQlGM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by HE1PR0502MB3804.eurprd05.prod.outlook.com (2603:10a6:7:86::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Sat, 20 Jan 2018 21:12:42 +0000 From: Matan Azrad To: Ferruh Yigit , Adrien Mazarguil , Gaetan Rivet Cc: Thomas Monjalon , dev@dpdk.org Date: Sat, 20 Jan 2018 21:12:19 +0000 Message-Id: <1516482744-8415-2-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516482744-8415-1-git-send-email-matan@mellanox.com> References: <1516274834-19755-1-git-send-email-matan@mellanox.com> <1516482744-8415-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0502CA0035.eurprd05.prod.outlook.com (2603:10a6:803:1::48) To HE1PR0502MB3804.eurprd05.prod.outlook.com (2603:10a6:7:86::30) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4ae8f4b-3df4-4611-1859-08d5604a8c3f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(48565401081)(2017052603307)(7153060)(7193020); SRVR:HE1PR0502MB3804; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3804; 3:WnckYIwn9u/nlyLuYUPnHJKDR0uvqu3RVt//4q9QWSCg4i6+da4qpnjZ8o731es4yj0zz0Ol+3U57Rp/76U486XhyUpPzfzMh549NqdGG/yFfrVH9P30zwCz7Q8z5hYrVn3Iyo5a4w2e9Dp3+Np/Msq2M35QjnH4OJH8XYJCu/YnB3jT/nNLsiHe/1wHIqQF6CPukCbJAL1YQ1hnyr6cLyTTVFbmGU7B+uwoO9K34ng8iGv/4M7Wyp5Y0EaWhrBt; 25:pcPAhF+KN+361BqhTQIlESLQdXu+NkI8y+SuMcgoYSHl0pTce4nNTIXQ58CmpgbBDatu8YU8Opib7kPLBz1L8+B5JzX7L2aZeAPwikxgmlBjTMt6kfxlrLvu4AWxTW56suCDl/9gs6dJUYJVIPvJyuyygnt0g1ivq4fFHoHrMXKSSkiNPB8XdiVyPn+XnRIo5hmhfQ1ceZOidZ6GgmLPkgIlgAuwhilRvGplpiYDBILzWa/860v1H7Qo84em/U3i2YcdwNF1urEINbNwZ3u3ekMili6IQguwhdqCfk4o2TqiO0o6JjpO8h3iLY0HSuT/kjCLJ+ABWr/9a0zuLuFX5A==; 31:L5oyjw8Kih9O77Gxd+l4cL80Xn+JQRgtJKKcg46C2TaRLUF3efH3+IbGwWm/bgMZmCQe9wqxvIDy4mr9NZcV9WBBv+xhmHdN0ccR05MtwN0Fi232d42MAqEMh3PLG+8Yer83ii3lsb01r9XFK+YOYq0mNFu49FiyGki06xqLSUrtFZnp56UGYSX33U1B4nJgT2YOIz6WSvZ/qrtip4/Rk4BJ94Qry0ftjXAVciHdS7s= X-MS-TrafficTypeDiagnostic: HE1PR0502MB3804: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3804; 20:zlChQpXXSxp5kWevq8y3fh8Y+IjIgTgNXSj4Rq7PKtdbjxSN1P7Luzu3iT5MBAFGPQ7oqirWICUpx10/QJLGbawbJGTLuStgAEfWZneIy1TvS2GjEKUUy5P+FV7Tjmg1nQxsnyg1aVHjY2NhPxNFgFZU+1cItAGbGSO4giN4ULQqrOhpM9dElKe4TevlQuQ6AIT9JVa6iADZYopdjuWRMwZxFXb8fy3OwP8jsB6RX+2bjINZ9f4CmX6XZTAxFHUj9KvCZzWtGWm11VEf/ta0RCfbkGvIGP2hhq8Q6XJtLxuwnF3JVOekiDFoeeK1AAJKXhBmjP0SIvwsanvrxxAKftvv+gO8tkYfEj6aoewB++vsskj5Xe9E+tCfT4rt0d4pJj3/lDVmtwOeSWM/gh/GZhYzCU6jd5EXbRAWFNinNW+TScCnbZDghj/DUHWWcrZ7AkBdVf6+TuoX4jHJnvuGLSSuRYhGkjnnh0rSQK+XY1cu2L3axFjgPJyx5ZQfb9sk; 4:OaMmcSEkoJxIjwBGpNDnNHetUn6Iu5E4DVllH2MsnNNPMQfrX/uH36DjhFAJJnrmii+I9dihBpGDLzpiiWj4K8btEd2B3VqtbudbQQlXGrPCPMRVqxLowx78Qcw1syP8eVUIkfitXR83C6hTcuulRKHIRH1POFimeyNQwm8Ac4JJJoBOurDCGEei2m5440Sd4tdxQo9Zxoul0rL+yMVhGcXMa657iSV2N48/pFslk6jnKJcytCqB8y0nR24WWgTnGUgsewJRRVEsgF7A1q4/BEOx9n7prOphjBwDrQ/PDdwJwWbb/NDHq5bhjM7YuiLQ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(3231023)(2400081)(944501161)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041288)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:HE1PR0502MB3804; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:HE1PR0502MB3804; X-Forefront-PRVS: 0558D3C5AC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(366004)(346002)(396003)(39380400002)(39860400002)(199004)(189003)(36756003)(47776003)(2906002)(4326008)(5660300001)(6116002)(478600001)(25786009)(50226002)(81156014)(59450400001)(16526018)(316002)(16586007)(51416003)(7696005)(76176011)(3846002)(52116002)(110136005)(33026002)(81166006)(386003)(7736002)(106356001)(105586002)(8936002)(8676002)(305945005)(66066001)(97736004)(53936002)(26005)(575784001)(86362001)(55016002)(4720700003)(21086003)(48376002)(68736007)(5890100001)(50466002)(6666003)(69596002)(2950100002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0502MB3804; 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; HE1PR0502MB3804; 23:stdD9vyc8xvYhs5CtIURE3eYm82eIimb0/P8Lme?= =?us-ascii?Q?6EtbaSo0oEJtPsn3613xBC8GoJvfiaOQISQhMaTkyPzPU9kA0ozPzmKawlvf?= =?us-ascii?Q?APr49z2HWZQlJd5T06qXnc6y3c3OzKNBJOEgSv2rDoCTV0fuU7OVVlFxhq/p?= =?us-ascii?Q?KjlSj9duKbjPEktHXUvevtzMy1Zbssl3SEYbEndd2u0Qob/YZnQc8dZxv+QB?= =?us-ascii?Q?iHNiSJz2q/68Xa4XM5Q1l1yaorr2YgtZ6tR/PzJWiNnY6FUdGm3Co5/IF+Sm?= =?us-ascii?Q?25SuBq06x98fXaPWV5Ai4wAqzyL+8VfirQ2BK8t12uYU74V5XB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8ckU2gKs/S0cSQd+V/YKcbaaY0wc26ojp?= =?us-ascii?Q?yIxakrTwhcMU/QTUMisE=3D?= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3804; 6:IidqknPzjqcLZ4Nccqhecs3pjYS/girwy884JOId/GPIXg0F4cXrk3gghD0x723qj8eEfEZOupleKv3FBiHSAhUunHRHJ+wUJS5pWkoV+cMruPkmNZzplkAQE5dKLITSsMqVVJgUrE9nDFsFvZm2C8zIalXdAO1tp5tNPCdKWtFDR/dus7Nk0znyW2Ij0uDZPQrNenuHOcjKYhaEgAA1ecAwCuGE5fdt/E3x2CETXT8PJZU22/US8Po+st2W6YdBxXHRDdvFEgP+rLWszvqH81w8S55kw4hXHl0/kyadWJQqKGDaoMkH4ncRVHIrLgmOkzquQcM5eGaAHkBl4IuCkI5f9CgY7HZU5AItCJkEg5w=; 5:hRie1lUsspI/c+AIkrP5QU63udD7I5cPQUP6RGhnIpT0vugg3L9GoxqmjNhdc8ctIIw8Uvax9nP2e02XvsaTBd6PAWjWQjr80WWAbHumFRZfkbczOPvF3h6Fh8Y9V9ZErycALwi0zWf329ee0oyZtxYxiCak6/qNfQeB2V2NBH8=; 24:/p+UiLwKRCYTPba8DA7TqkDvMlmh1rBHjVjNKjXccfi+Xi224+fOo+G5d5OyEP7JXFCpB3r7w8IcCLa/N0Y6IjQxStuDquWgrq6cMHoUUBw=; 7:TSOIEex2fb8GVXO3hCLQWxa+OY8BexnR2O2PhRU4qC8mIXTZ7l6NM35A/2ozx0ASLakgUE9ySXX2ALHsmEfynTvVjb0LqsduP1B7T4Ad1BcNluH4mOIK15D1f0w48WETw+GlpGFVdmLv/xLUZPPTiVBocgvGXkE65Nc+4AW45g1FEr2eU35y/jT+HyhjnwRkoXdoFq3+x3Y+588zt+LK0QX9AgkaXjnHSo+aRrYzvWoRdaVBvcgZ3OVNAvnK6GNk SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2018 21:12:42.9272 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f4ae8f4b-3df4-4611-1859-08d5604a8c3f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0502MB3804 Subject: [dpdk-dev] [PATCH v7 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: Sat, 20 Jan 2018 21:12: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 Acked-by: Thomas Monjalon --- lib/librte_ether/rte_ethdev.c | 29 ++++++++++++++++++++++++++--- lib/librte_ether/rte_ethdev.h | 20 ++++++++++++++++++++ lib/librte_ether/rte_ethdev_version.map | 1 + 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index b349599..fd70d10 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -114,7 +114,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) @@ -262,8 +263,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; @@ -1094,6 +1094,29 @@ 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]; + + if (dev->state == RTE_ETH_DEV_REMOVED) + return 1; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->is_removed, 0); + + ret = dev->dev_ops->is_removed(dev); + if (ret != 0) + /* Device is physically removed. */ + 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 f0eeefe..ed31a10 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1169,6 +1169,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. */ @@ -1498,6 +1501,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. */ @@ -1684,6 +1689,7 @@ enum rte_eth_dev_state { RTE_ETH_DEV_UNUSED = 0, RTE_ETH_DEV_ATTACHED, RTE_ETH_DEV_DEFERRED, + RTE_ETH_DEV_REMOVED, }; /** @@ -1970,6 +1976,20 @@ int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue, void _rte_eth_dev_reset(struct rte_eth_dev *dev); /** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Check if an Ethernet device was physically removed. + * + * @param port_id + * The port identifier of the Ethernet device. + * @return + * 1 when the Ethernet device is removed, otherwise 0. + */ +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..88b7908 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -201,6 +201,7 @@ DPDK_17.11 { EXPERIMENTAL { global: + rte_eth_dev_is_removed; rte_mtr_capabilities_get; rte_mtr_create; rte_mtr_destroy; -- 1.8.3.1