From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10077.outbound.protection.outlook.com [40.107.1.77]) by dpdk.org (Postfix) with ESMTP id 02CA61B2CC for ; Wed, 17 Jan 2018 21:19:53 +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=DA+4mzbWSepPAv3B4vLdCIN0GNV2C9F3G4taXqm3FkY=; b=cqBI/I8T/7I/HeFctIOgTNIoNG9Ql4H2WD3QRTgF2BX7BVtVgcZVLGzojZ0I7UME8XLOnL9E5QHNY5jhKgmZMQJvoupaE6g3rUwzayUinRQxoa06Mo/UJTrzdlYBWn3/tfHeBwif6JTNb5WNHV+VWaOzqEqhXGO4BUP/4F/OuOs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM6PR0502MB3799.eurprd05.prod.outlook.com (2603:10a6:209:a::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Wed, 17 Jan 2018 20:19:52 +0000 From: Matan Azrad To: Ferruh Yigit , Adrien Mazarguil , Gaetan Rivet Cc: Thomas Monjalon , dev@dpdk.org Date: Wed, 17 Jan 2018 20:19:12 +0000 Message-Id: <1516220357-13013-2-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516220357-13013-1-git-send-email-matan@mellanox.com> References: <1515587465-9304-1-git-send-email-matan@mellanox.com> <1516220357-13013-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR06CA0129.eurprd06.prod.outlook.com (2603:10a6:7:16::16) To AM6PR0502MB3799.eurprd05.prod.outlook.com (2603:10a6:209:a::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 180ad737-c424-4dd8-4e5f-08d55de7aaf6 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:AM6PR0502MB3799; X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3799; 3:8DiPkSlhdJW7Pk9nMxo9xwJluMTfq5Wv8uXAy5kfNeNBlAilAb13Y7gMGl778EfNsUJ/agQE4iczr9Lj18mx2cTFb5TJRjTU/ACktpaXgCmuL2BrPHB7hUAKk8Ssar9bOxVpqWBaoqb5qAHjDETmB3RV8V6TmZhkqgVfvjRVMmHrdcVtpTPHqyvOshL1TEnjCnJcBsNV8Y7pGnoo0BAWEwmlb9BEZQDAO9mw7ZjoMhb3X3kwVlha6Q2N36kZ4mEB; 25:J24YkxgxL3pcbj1TmsLPgOMlGml4DJa4iIyEsUUkaeUzp/acESs5tN6Jp1YyWPLVybvT/5PoImWz/WeTSHf2kVX81/xyN+w7Z/EW0C2/PgBITprykEKq5ib8zrWLcbSNe9Roqd2ddGKjp0RCjbSdnIMvYJSp80scr0UEtqrOtq5/RqeksYA4RexBO5Gg/ZY5QDMm5Zj+w9VgAVBRfuZcLNYXLQbZK7pi3EQAtBht79vAFnp5Ex4pGuF+D2ob5uIf7ynrpOsBLTDr0ZJ9bHP63z/Wy4ew48GmVGisBxcYmO9rF5DO4+VNimnSB1g6+n7aIRoszwOqqfibupaOPMSWZA==; 31:4jst8VIX7n3wQ5WNnM3cZBVb7aZmM3GODSsswzC/g5rKFy52esvntThfgrA4XDUGl7fuvLU9PVutCJNJ+zRqKes9RrDVxA2gHabZR8s340EMMvdSPL0urKrEB2KqRQqE+tw0LzJ2F8wRxkHNhlgx33UtDcrFa+V4+Jd2OFieYc6MuitvIyIAprKmpRaG9nEDcr/qsrRM27Wpt2Gu2AKxiZRsJ/su0E8oXuIvVHvSWIs= X-MS-TrafficTypeDiagnostic: AM6PR0502MB3799: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3799; 20:I1DbFuDkeMnp1L2TtLVFVJS9C15OTiI0iHWTQlogVKxba2JZrdmumcbALb/hUX0wAbOqoPpw65ZpGiTYmcpjT6b3t1n4V8qNIhJG3MBlceq6WMadkeRBzS0v99ZBjovQOuxB1ze+hIwqN4pdku9Cvr3b62mv0YqopTsx9hTgX6qgbaokEq66bNT0KIcIZqcm5ubiOrlab0TgN3/wuN/yoX8DssXmciNQh39I0qjLn3SICRDQBRtJ95aDJ+grk8j7ilR/ECkjrj6sufQC/VoQkS4kWOB8dQVZTHWOE95vWMXqeguI9bTneIXm9+3O4ImVl6hZEtwWYlM17ieN3XHHiFfm2p2883q6o9UhzQKqO/MfKJoPSM5kdHreq+3fzhhBUdAB9VPMEnZedAGwV2nFw5zgMn/f+nI/Lh5qe80SRvSoGcsQQf3zkElT+xA2+9NOzEQFyZ4dfMbSs/0RK1fAxvfmA5vYrJhLdoNbKZwavyjOdnrUe2i48m5KRNeOqncE; 4:vgvyg+fxKd0p3VSYVevru79q+suEjTjGeILkZIHNxpka5Fi2uZTIk106p2tFYDzufSA/QEAkQGiUdVigt7gdvF+6xy1+kAaCgWb2K74iX6jvPQvv7YrMwgN7J0UHnavjaiadLowezBA33El8qG1YC4EwuCTpwN8HA6JPBdM9agffuPBvgR2GULBIZ3oBFnpuu4IoAE0gbezVKse2lHBkhEAZ1k2GbCrkNd+anaDb3gNEY6WiVL600NR8rExmxSQsGtLhyTXIlWUk2Nh0FRNoay0kH7wspcIq2L6anCoLGGmgP/JADqKs9wY5JL2r5K8P 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)(3002001)(10201501046)(93006095)(93001095)(3231023)(944501161)(6055026)(6041268)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM6PR0502MB3799; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM6PR0502MB3799; X-Forefront-PRVS: 0555EC8317 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(346002)(376002)(39380400002)(39860400002)(396003)(199004)(189003)(51416003)(6666003)(50226002)(53936002)(68736007)(106356001)(55016002)(21086003)(47776003)(16526018)(2906002)(66066001)(105586002)(97736004)(4720700003)(2950100002)(59450400001)(478600001)(52116002)(305945005)(5890100001)(48376002)(50466002)(33026002)(5660300001)(76176011)(575784001)(69596002)(86362001)(3846002)(7696005)(7736002)(8936002)(81156014)(8676002)(110136005)(16586007)(25786009)(386003)(36756003)(6116002)(81166006)(316002)(26005)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0502MB3799; 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; AM6PR0502MB3799; 23:+HV3/iSrMqTn1BNXVw6yV0h2aqUkKoM1M2/ctJV?= =?us-ascii?Q?bnYgTjT7lPOAjNd9RhBjNuU5gNNdEdEgBzrrrNg4dcBnnWHrlOIgfOtaGjQg?= =?us-ascii?Q?UirJY2ThpQNicq7YhtM95PAGzBwGwAB8zJ8RhTw+HLFneszWmXBGq9Y/rSVp?= =?us-ascii?Q?VGPAP+F+Xu8dFHoIqMm20EkpH+GyJzTtycTigKyNTYn2L1hBbmwt1bcrbQGC?= =?us-ascii?Q?f6LFHSupN0uy3UgDHcjNKrCZZ3irJago4B2/hYBe9m7q8MXpaYSq2GntKu5N?= =?us-ascii?Q?8oiCq3ydvJdkx8yVJa1cCXbrPLzV0tF+6qm2kIT8B+nRwA4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adata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2018 20:19:52.0671 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 180ad737-c424-4dd8-4e5f-08d55de7aaf6 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0502MB3799 Subject: [dpdk-dev] [PATCH v5 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, 17 Jan 2018 20:19:54 -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 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..da0c5cf 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,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