From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10068.outbound.protection.outlook.com [40.107.1.68]) by dpdk.org (Postfix) with ESMTP id D058F1B1D8 for ; Thu, 18 Jan 2018 12:27:39 +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=Z0bTRte7p8jbTVzE6CBwKyZcu1JSUM1zlhJdJp1FVs0=; b=cBsn77hS2ZUkEqvX4oUqNyqqepDK+yTs2ZqyrYGtRBdL+4YOcjv0xevd4QltcAQFbEd/w+3eTpYJSmmDyqfWbsYdy07Gn407zFFimNYaXnggrZSAG06UVUTzLQBsEPyDpEJVTxtUoZy3YLX6NaTWsfLC66WYXz094Ng8JPrCCNQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM6PR0502MB3797.eurprd05.prod.outlook.com (2603:10a6:209:a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Thu, 18 Jan 2018 11:27:37 +0000 From: Matan Azrad To: Ferruh Yigit , Adrien Mazarguil , Gaetan Rivet Cc: Thomas Monjalon , dev@dpdk.org Date: Thu, 18 Jan 2018 11:27:09 +0000 Message-Id: <1516274834-19755-2-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516274834-19755-1-git-send-email-matan@mellanox.com> References: <1516220357-13013-1-git-send-email-matan@mellanox.com> <1516274834-19755-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR0102CA0042.eurprd01.prod.exchangelabs.com (2603:10a6:7:7d::19) To AM6PR0502MB3797.eurprd05.prod.outlook.com (2603:10a6:209:a::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f7f07e4f-94a5-49dc-6e27-08d55e667af9 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(48565401081)(2017052603307)(7153060)(7193020); SRVR:AM6PR0502MB3797; X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3797; 3:dR+gS0IPH7IXursGKmvufkPnppoY5ZFvz/CFunwyRh7MuwCajixWC65/F6iQngLGE/acdkkyTY2Abu7hCzqIdl3UXlOMkozN0RviFae5zyq8FENj+PNvOgwZOhglL8UNA4jSm3IptX8flmf5XaV/0M3CE8KESfFdHnfadmUEN2F9gx+ItHQTCkqIVGLeg/CuFkj6S9i0FneePi1CfPDV+iY3jqwgdc4xCwJ9zOgBjn4rpzKpA6L0zTmVdblxKG8F; 25:LHYMl/EFMcfIG2agTpsw5FtnylHxiFm81LbCuhJZvXXsE95EMtNIhVSGpwOAF/6saf3V7I0QC0RpwDGHFYFAk3UdYVe6FdY6Zz7kVy5aq3nD+tyR48E8xbMpLd6cEwS80/bhvYlrDovk3bilVUmTpuqPzetDFxrZPZe4dkLCC+w2XJ5O4/35W35qOrzAqhVuqFo8hzY3Wx1NjvRDiafL45mPfFkiv9sJ8msDjZ3AvodxZCrYiym2pmN1J23P0vaYfMi/EBnhuKku9SaPPj4nt0eofjv/i/WyrAfLK5i3HeZiRRLcxU20SkA5PysjpZm12kc706Vp3Rx3gbp1HIlbvg==; 31:dm4/dWJkQJerOadqzoF/1BAt3p4t5VNdfnKpBNCQe6LdEP+b9pZQ1fswiSm+ophbKuuK++QOvO+bXOL23Z9Mi8kcTjXGV2Dn+Xq4l8kZtus59J9qqzo7SL9nuizB+O5NTxbhoAXLc45djs7021eWWhEsqz/QGq2wj2C/pIFVBkg0XjE1SbKQeZCPI4HQ3T29ggtUMP4HXQL9ROGz4Zlbgc+iMtte9KrvvFVAZKuBgOU= X-MS-TrafficTypeDiagnostic: AM6PR0502MB3797: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3797; 20:IfZu96VmCzCgbxc7bJjryF2CaRI9XTYf4TQNxjvRBPLsRBIdwLuYIsAtuGojPE4hg3M/4SbdB+WijIXqdxX0zUp/uNgrq4Pu2pvcZv1jEcZ18JsomgTNvwz6Lt33QwTJz65vu9dZ9TLWXPowQmIj+iWNAMtYxsdV/1mXzFo8sXGHdxXkRVqTHpil8TPswLE6NaH9N/ZKfiTb/TH69fcL9Vh61/ao/51Li9Voamo0iKg8IgX0QQHVjRy+iSNvdFN9KlrRs9+1GCpWy28LOBR5rSJg8spqRrwIotHOCtw7FpVt7Mc+N/4U+EOG+cfBill+w7427OhYUtLmIMTR96Qg7F41ixnqucLQ5SRkg5ghbjpGIehC9Xm+XSiii7TU7qDHlAgWQflmQhoCCDDQUBCf7GtTP+m1UZhC3cN3ZT1XSeGaDm+M15TYfgooXC3kEK2nj+4Hykj9Gwd61n7LSB5M+OJJ5ROJ9fxEbG471GoNu+yCJt8rYwmz6VdOA24TIL5c; 4:Jqztou8vfhRaW2LmYaKIixdV4ktGM0CmjrtFUAbar0n8pwBNyQBco8ak4QLm2g8GoPqmqf+5qDhB98D/7/fg3nByNR7VLuhn5Rma01ccigPTv0g+J56DBeZD0V1mOpH3moqFG1lp6O/JG3T6XijFsK/Qp6QayRdvnnoUcye8dGGO22iCo9vDhUhw2rLOIOks542JQ1w/mSzfEyBaLYJIkUQR3STnl2UmG7LAHs8XYISKR4ye4mBo3F/vtrQDlhwFP7qVofN6WZKO/9HswE4htxHnkbuXXokOkHxthhpDriCiUG/HcsZ3k5N7BbnFGVAv 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)(3002001)(3231023)(2400060)(944501161)(10201501046)(6055026)(6041268)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(6072148)(201708071742011); SRVR:AM6PR0502MB3797; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM6PR0502MB3797; X-Forefront-PRVS: 05568D1FF7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(366004)(39860400002)(346002)(39380400002)(396003)(199004)(189003)(53936002)(6116002)(76176011)(386003)(4720700003)(59450400001)(26005)(7736002)(305945005)(50466002)(66066001)(2906002)(47776003)(16586007)(5890100001)(8676002)(110136005)(478600001)(316002)(25786009)(21086003)(2950100002)(48376002)(6666003)(51416003)(52116002)(7696005)(81156014)(8936002)(81166006)(4326008)(86362001)(575784001)(16526018)(97736004)(68736007)(36756003)(50226002)(5660300001)(105586002)(69596002)(3846002)(106356001)(33026002)(55016002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0502MB3797; 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; AM6PR0502MB3797; 23:50NtvD6y+JzVf+Tz9lKRGLAGEwL+/snhzrkDi3v?= =?us-ascii?Q?7AWtLw4TwOWLGK/4FoegYlibXvLzPA+R/3Nh4gQCfRU/PTckqsdLt3wPwDlo?= =?us-ascii?Q?NQVdhm2/esgxbz02Xih2ZJT55Mk/xDKf4VccWr5bbg3cdeIPPNjX6XjzLDJw?= =?us-ascii?Q?YcPUi9VGewOqq0wEJYQEAASpIEjUCjNlonjeUQu/zH/GHG7ltXAwq+F/+ij6?= =?us-ascii?Q?uFihEpyNjOCeHn4aJvYNr+Pavs+dEvz/q1kjW/3VajIZ3/LCU/TTV5wi25Ms?= =?us-ascii?Q?TbJ+CasgO7XPPvtzm58bv2MmMvuI7auEu9De7yriAciwDf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put: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2018 11:27:37.6104 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7f07e4f-94a5-49dc-6e27-08d55e667af9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0502MB3797 Subject: [dpdk-dev] [PATCH v6 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: Thu, 18 Jan 2018 11:27:40 -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 | 20 ++++++++++++++++++++ lib/librte_ether/rte_ethdev_version.map | 1 + 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index b349599..c93cec1 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,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 f0eeefe..18c14e9 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 + * - 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..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