From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10066.outbound.protection.outlook.com [40.107.1.66]) by dpdk.org (Postfix) with ESMTP id 49F4B37A0 for ; Mon, 4 Sep 2017 15:56:15 +0200 (CEST) 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=jHGOX6rXYJwtHIcBCYslLzB5lxWd9FPCS8dZyoxE8nw=; b=VPHT0w44WD/vng4ZHscixv09ApZgHpyZ2jraC6Ior+ccUdVFLXI9Kv6K7MXF7ya50MlcK8yhdrWrAqXKdoY428Ynye8kXhv+YPuVkRHExqjqjxhz8erLnX3cDF5RPkkBRMx06jp1idwEWQrnPJR7o/YmWvjJmug1k8aJoFApEY4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by HE1PR0502MB3050.eurprd05.prod.outlook.com (2603:10a6:3:d9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Mon, 4 Sep 2017 13:56:12 +0000 From: Matan Azrad To: Nelio Laranjeiro Cc: dev@dpdk.org Date: Mon, 4 Sep 2017 16:55:53 +0300 Message-Id: <1504533353-38337-1-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20170904124943.2pep4kbglu4q5qg4@localhost> References: <20170904124943.2pep4kbglu4q5qg4@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR0402CA0038.eurprd04.prod.outlook.com (2603:10a6:7:7c::27) To HE1PR0502MB3050.eurprd05.prod.outlook.com (2603:10a6:3:d9::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d316141a-7f59-4476-a5e9-08d4f39cb46a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:HE1PR0502MB3050; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3050; 3:8JQsHkRhAkL7zx2ukwnvEvt6Pjhuf4bO2IoEGrJssViNKUGSt0CiENdAyjDFkhBhUZ3/maGICBJ+QVo4m0UKI7je0QS+ipqfv62qQh2oSSVLYj86RmRnqslEVWRi5mpG94IBZIPyIql3ibaMjG8yX5BGppmRcVybQRHnNzyV7HWJIyTCZ0LkA9QlJ6ngcPVwQUaySgLEKF2uXbzCVUBS6eqzNPvLlyXZswq/P8wUjgwBdrKXOpp1nIgaSEA/Ljsp; 25:VIXwYZbYOs7TJFIXD1RZ2xdbGyi5qQLiCLK1rHdKBUDAIB2y/JocfcGqmds5MQEUeIoAEHUg61H7e2JTHmASBYzQNfoy0DeEoM7s11souVyjZul9MBySF+J+cxn3ZUFW18YfUhLr5Dk1KfQfF2lL9w3hEVlfWTankxfxZET0FChYAUKA9RuJ/CJ32TAglXGtWpDJkMndzAiyYcIsXoEpm4tVyjNZtcrknjuRxmoNu3s7j4KI86So8HsN9E8CdLN5hkdI/SPhWBTK0UlObY36xWtZpAQcKcprqc4UUhc2Pqj0MNNIxgFIwwZYyra1YhX2J3Ajt6Rtquim5sOnJkGpbg==; 31:7nC9Or6WAskWZMRbGT+jy+9k+NyIFAjFPUshJY8Gtvn+vl4E4sQ3Oo4JRW0TtXu7BvGrFEo1HifcAFxVWSlmKw1uYgz2EkWIOE2TNP+HLcjpPOMOFv6k8O/bGzuaMdfHYWdFsWQYx+af7AOfPH0HbvTBIObHHAne2HprvutUAScu5Yz6DkVkvQ87mVg69Td/63cULzVlgFMtaYPElGaFow4F6SiVpGGWYhWRbz+BrWM= X-MS-TrafficTypeDiagnostic: HE1PR0502MB3050: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3050; 20:Wxrv9PV9u9OF1yiu+uVx5bG0FSkn7RboTcY4TvBMLKlUoBskKV6lKHjUWS+MJldUY1ZcImFmD0NKbTAWpWWF4JXp6nvTAO49VoFAN/J5h37r2vBZL5mG6hrzZnKskCYhOkvkv4mX8vH5rjK4uYv0op6PSKJSNRxub+uHSu0kcwNs/PNsM+VYAEDX1rrdD184azhW0LOlO9Frmu3zf9xGRlgyCViO1PMGYpRixYUT2WNg9qsyHXL6aQBFdk4A2LKF8YoKCxu45E0e5JI4uktf/piWFZZtwnzF1ectR0No9oOWQnDoDdEUFnUnD3XgwwGkE5pxe7Qguo9k1YvNdR2wuaFoR4Fg1rh9tZlorwF2x0w6emy9pvYQPQfh9UcyzfSB6ebTbKmR27RSce0+2qI/bldr03p42B3FwcUMxBWwqGdE8CC08+HJuZhMuSx5j/gEzPI0o0yGD8OvTsB8Pw/FN3ArNXdqZKATvO0SG1M84AMjNhclminKX4ASMltNOT1r; 4:y0uHLP83toN3dbjq7gOpxlAp2tLC1fIeHOvPduOcD5iEQg5+ox+QD0hjp4XdXFwz9IhfZQ7V4M5dDcXkwOBokg+7Z3p5pgfjwI0JtjT7/vEseq3VFnllPrf+2nPafqi3EXWEDyhEzsnJprRWiykhvN6PVEJfXJgXDR6H816wovZOTTNd+0i/3KsGWIqNlKUhrEx0IfY06qc45PiPlv161pQxmosc1Br3nfzEDtoikwo5kXIa2QJHf8+UX5Hjo35QbmoBs0CZJQS58khad5LHGo+6Kfze1OzI2stP27JDUuM= X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:HE1PR0502MB3050; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:HE1PR0502MB3050; X-Forefront-PRVS: 0420213CCD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(199003)(189002)(25786009)(5660300001)(110136004)(33026002)(53936002)(478600001)(2950100002)(6916009)(50466002)(48376002)(6666003)(189998001)(55016002)(4326008)(21086003)(68736007)(47776003)(86362001)(69596002)(36756003)(7350300001)(7736002)(305945005)(42186005)(5003940100001)(33646002)(2906002)(6116002)(3846002)(105586002)(97736004)(50986999)(76176999)(81156014)(8676002)(101416001)(81166006)(106356001)(50226002)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0502MB3050; 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; HE1PR0502MB3050; 23:ePdr2aXKT2pDiZsSaeTd2Mu0eMrPtqefsN0LXZR?= =?us-ascii?Q?uqFl7uo7HkS35IjlKjFaek5FS38A2aXvHP0ulehrtIS6x0DoQCfZbjWNbzAo?= =?us-ascii?Q?Nw9Xi4ajaHJg9JDZQHROMcNATt2Ii9+0fVqzUvjiYgvi1uj5WoujpaxTqExy?= =?us-ascii?Q?cLYURfi+OLp6gTxg6+ts+qEZSH3FxtRYw+WxyhmGAp5geGafxomomweEGj72?= =?us-ascii?Q?A7yMdbsmSdeWDfoCoyT8XsDCjK/hu9qkCfUO9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-ascii?Q?ILPZZzTR5mwy4HBQGJAXDr8kx5vb5Nrvs?= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3050; 6:shryq/KyqBaP7npMWumuNlyuf2sXMMK2fVpZYZYMRICz1Umi/Dae4r6rYMZ32/yd/6/8gXY4lvx3cpag8E6oUTq0UeRjuiiVCggbLvOFEzatHplJSSibtOMvdtH7YmLfRCpnJpMxkIcZSk02xaufEE/lJMYouTaGeJ/Qhczzaj+ex6U5Ff0zdzwwiNdS0u3zzjXvgDvZvuz/pvbt42kB3rjZ3vE3tQT17K5JHf7gKYpO3UfMcFR3wHFhZjtfio2bC862IR9FEMPGOJQDanWXI7dGr0uxGKjljn8Z2oHaQSfJq2DPxE73JOYYfMKnSk2JhCZq2PP+nlc4RyPXap8jEA==; 5:LKef7k8iZAKBPv+vyJM/4EnvIbEh/fM9KTmAZPJomnu0Mswoss5PLHiIbftaROONGQA6BjlfyeRx25ZI/QHEfwGJ+eaagfn620oAsKMl2/s8qFSBfzg9d0HJj8FA0jwkY86mro5LN62P2QezKCqaBA==; 24:8zacQCyZU4IBDYV8FcAqOobgGbdDvUC77MCgypi5YXaFYv2Uw2lo56+tzDstR48Keh5Knevx9kDqikbMCGbjwITrGhq8Y7V/mmcxLBt70fg=; 7:pfHri6W0PlwkBD9KAqV388K2Tq+2asOPLPdK44AnYkV29rIQ9hrSIBz8dmNsewCwoEHAVScm+X8JrGb/RG9QXZFacitcSqO5C9Paf+yHWFmoN/IhN2IbFSiO3DpaReEUJGv8Hng1wRIzBna7BPOUki/p4Us3C0FGhVjW0aO/yFy4pW2d+FsZ4BKNsOuINWLT91akkW1OXQMK86MuBwcCpEI+jfYmk4aGLXGaeedbLEA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2017 13:56:12.8262 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0502MB3050 Subject: [dpdk-dev] [PATCH v3] net/mlx5: support device removal event 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: Mon, 04 Sep 2017 13:56:15 -0000 Extend the LSC event handling to support the device removal as well. The Verbs library may send several related events, which are different from LSC event. The mlx5 event handling has been made capable of receiving and signaling several event types at once. This support includes next: 1. Removal event detection according to the user configuration. 2. Calling to all registered mlx5 removal callbacks. 3. Capabilities extension to include removal interrupt handling. Signed-off-by: Matan Azrad --- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5_ethdev.c | 103 +++++++++++++++++++++++++++++------------ 2 files changed, 74 insertions(+), 31 deletions(-) Changes: V2: Replace link status update function name. add inconsistent link workaround comment. V3: Fix indentations. Accurate inconsistent link comment. diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index bd66a7c..1a3d7f1 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -865,7 +865,7 @@ static struct rte_pci_driver mlx5_driver = { }, .id_table = mlx5_pci_id_map, .probe = mlx5_pci_probe, - .drv_flags = RTE_PCI_DRV_INTR_LSC, + .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV, }; /** diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 57f6237..cdbd723 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -1112,47 +1112,84 @@ mlx5_ibv_device_to_pci_addr(const struct ibv_device *device, } /** - * Link status handler. + * Update the link status. * * @param priv * Pointer to private structure. - * @param dev - * Pointer to the rte_eth_dev structure. * * @return - * Nonzero if the callback process can be called immediately. + * Zero if the callback process can be called immediately. */ static int -priv_dev_link_status_handler(struct priv *priv, struct rte_eth_dev *dev) +priv_link_status_update(struct priv *priv) +{ + struct rte_eth_link *link = &priv->dev->data->dev_link; + + mlx5_link_update(priv->dev, 0); + if (((link->link_speed == 0) && link->link_status) || + ((link->link_speed != 0) && !link->link_status)) { + /* + * Inconsistent status. + * The link status is read from Ethtool through an IOCTL, + * but as the application may work in polling mode it + * may get the port event before the Kernel driver had + * time to process it. PMD then request the link from + * the kernel but the event is still not processed (due + * to more urgent interrupts) and finally the PMD may + * get an inconsistent link. + * Setting alarm for later checking. + */ + if (!priv->pending_alarm) { + priv->pending_alarm = 1; + rte_eal_alarm_set(MLX5_ALARM_TIMEOUT_US, + mlx5_dev_link_status_handler, + priv->dev); + } + return 1; + } else if (unlikely(priv->pending_alarm)) { + /* In case of link interrupt while link alarm was setting. */ + priv->pending_alarm = 0; + rte_eal_alarm_cancel(mlx5_dev_link_status_handler, priv->dev); + } + return 0; +} + +/** + * Device status handler. + * + * @param priv + * Pointer to private structure. + * @param events + * Pointer to event flags holder. + * + * @return + * Events bitmap of callback process which can be called immediately. + */ +static uint32_t +priv_dev_status_handler(struct priv *priv) { struct ibv_async_event event; - struct rte_eth_link *link = &dev->data->dev_link; - int ret = 0; + uint32_t ret = 0; /* Read all message and acknowledge them. */ for (;;) { if (ibv_get_async_event(priv->ctx, &event)) break; - - if (event.event_type != IBV_EVENT_PORT_ACTIVE && - event.event_type != IBV_EVENT_PORT_ERR) + if ((event.event_type == IBV_EVENT_PORT_ACTIVE || + event.event_type == IBV_EVENT_PORT_ERR) && + (priv->dev->data->dev_conf.intr_conf.lsc == 1)) + ret |= (1 << RTE_ETH_EVENT_INTR_LSC); + else if (event.event_type == IBV_EVENT_DEVICE_FATAL && + priv->dev->data->dev_conf.intr_conf.rmv == 1) + ret |= (1 << RTE_ETH_EVENT_INTR_RMV); + else DEBUG("event type %d on port %d not handled", event.event_type, event.element.port_num); ibv_ack_async_event(&event); } - mlx5_link_update(dev, 0); - if (((link->link_speed == 0) && link->link_status) || - ((link->link_speed != 0) && !link->link_status)) { - if (!priv->pending_alarm) { - /* Inconsistent status, check again later. */ - priv->pending_alarm = 1; - rte_eal_alarm_set(MLX5_ALARM_TIMEOUT_US, - mlx5_dev_link_status_handler, - dev); - } - } else { - ret = 1; - } + if (ret & (1 << RTE_ETH_EVENT_INTR_LSC)) + if (priv_link_status_update(priv)) + ret &= ~(1 << RTE_ETH_EVENT_INTR_LSC); return ret; } @@ -1172,9 +1209,9 @@ mlx5_dev_link_status_handler(void *arg) priv_lock(priv); assert(priv->pending_alarm == 1); priv->pending_alarm = 0; - ret = priv_dev_link_status_handler(priv, dev); + ret = priv_link_status_update(priv); priv_unlock(priv); - if (ret) + if (!ret) _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, NULL); } @@ -1192,14 +1229,17 @@ mlx5_dev_interrupt_handler(void *cb_arg) { struct rte_eth_dev *dev = cb_arg; struct priv *priv = dev->data->dev_private; - int ret; + uint32_t events; priv_lock(priv); - ret = priv_dev_link_status_handler(priv, dev); + events = priv_dev_status_handler(priv); priv_unlock(priv); - if (ret) + if (events & (1 << RTE_ETH_EVENT_INTR_LSC)) _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, NULL); + if (events & (1 << RTE_ETH_EVENT_INTR_RMV)) + _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RMV, NULL, + NULL); } /** @@ -1213,7 +1253,8 @@ mlx5_dev_interrupt_handler(void *cb_arg) void priv_dev_interrupt_handler_uninstall(struct priv *priv, struct rte_eth_dev *dev) { - if (!dev->data->dev_conf.intr_conf.lsc) + if (!dev->data->dev_conf.intr_conf.lsc && + !dev->data->dev_conf.intr_conf.rmv) return; rte_intr_callback_unregister(&priv->intr_handle, mlx5_dev_interrupt_handler, @@ -1238,7 +1279,8 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev) { int rc, flags; - if (!dev->data->dev_conf.intr_conf.lsc) + if (!dev->data->dev_conf.intr_conf.lsc && + !dev->data->dev_conf.intr_conf.rmv) return; assert(priv->ctx->async_fd > 0); flags = fcntl(priv->ctx->async_fd, F_GETFL); @@ -1246,6 +1288,7 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev) if (rc < 0) { INFO("failed to change file descriptor async event queue"); dev->data->dev_conf.intr_conf.lsc = 0; + dev->data->dev_conf.intr_conf.rmv = 0; } else { priv->intr_handle.fd = priv->ctx->async_fd; priv->intr_handle.type = RTE_INTR_HANDLE_EXT; -- 2.7.4