From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0046.outbound.protection.outlook.com [104.47.2.46]) by dpdk.org (Postfix) with ESMTP id E3CE411C5 for ; Tue, 29 Aug 2017 10:31:09 +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=srG1v/qRHxpS//p8SLvDB+FZLhT69g56EBRA5cGzVA0=; b=pVhPNGOygTDFe4i3KNiT8g/Sk20YCnLJk450BBdZxhekrElkU5vuyDADUFZ99idVQ0P68/kWFhnZwl4Oh4CE994NmDyhci9n/hKhmKoFJ9Ze2gtpzvVnpm57kNMQWTKoBs9Caw13UlrqrSmcBkfL8mBN+itKX9JzkthjJU4yc94= Received: from mellanox.com (37.142.13.130) by VI1PR0502MB3056.eurprd05.prod.outlook.com (2603:10a6:800:b3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Tue, 29 Aug 2017 08:31:07 +0000 From: Matan Azrad To: Nelio Laranjeiro Cc: dev@dpdk.org, Adrien Mazarguil Date: Tue, 29 Aug 2017 11:30:44 +0300 Message-Id: <1503995444-43359-1-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20170825082918.GU4544@autoinstall.dev.6wind.com> References: <20170825082918.GU4544@autoinstall.dev.6wind.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR06CA0156.eurprd06.prod.outlook.com (2603:10a6:7:16::43) To VI1PR0502MB3056.eurprd05.prod.outlook.com (2603:10a6:800:b3::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7c2f2e9f-4e59-413d-e397-08d4eeb84bc4 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:VI1PR0502MB3056; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3056; 3:qwxUjGktk7NHULckHRNWwS7PfH1NZxzYfk6+vLEKeuPEBmzC1IcHQkSBHuSp8LBjjVlu+pd9wARaKsdzlD4gLr7Trq/M/nZ7jO34F1UDuuQoqne9rA96JX7h+5V4ujA9Slsbo00Q/2MwYiTTaRvBl23qxxvlUeMXf/nTB1W1Qraa5jVUg7h5luLPCXznEs5q4A7PKqt3Dzpb7vuhUFK68i8u3XN4TjgXpv8GqWJNNaPevFmS8bg+Wu7rAxmQM/RF; 25:r/hQGqUN+EN7jh0N1xb9JTpFHDJIowr/JnXeLxEZao3x+TfbPcTOLE3qIqkExbcaj1kfmJrR9JdYBVwmwYLTz5oNGbd1+aYO8uOGkteYWvev0Q0cTQR2yY912/9sHVWbnH1D5CSHcjoykq5R8Fum4BXJUsXxhtaxOfrnq/Ni/8C8csktO8FdhwfixVBUsDKZcDJ7HkvSvJhPPKq03IhhhSOvVQ5N14rWany2RJdFerKpejiruLVvl69jZhS4cTypC5zKxu0vCNxo6sANkN6zwW3WrePhSWusPZOt4NLsj9Z0DXy9zvc7rQO+PABSCk5gCsab6Q9lMSBf4FBwkbkfAg==; 31:32GqDESaW6uHf2foLOCjoh+uAoXJ+VOz3nlAgyDjUVJmmKW05mx+caR39aui9Uph/5m5GZsWcIaduuyrWI8di5qwsjuSAW+7w577oIcegwmxbf//0UL9tiAarj3U+t8CGGzn5ICHCwjuMOeYIbf1aBILMd3ry/vz2lyfVSVpwN+p6h+FcxYUc5r6HTYYTOog93KlAOtgYQJBoAIl0CtuG31eoUKPybPKmBFpkMO46fw= X-MS-TrafficTypeDiagnostic: VI1PR0502MB3056: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3056; 20:6rMnLk+DnAgMy3/rcfiCtGha3yGgfFZmTyaUFUCJKF4GHJN7ZaMdHoCi0QGwK5FA80ephiCq0furY2cmz04fXwILOSZDkS+d95FQx3T1qS9+yZ/MePXH8hZxCUiELI1y4SY7iGiHSZ/bPHj9Eeet7OzEfNUaeQLNtrXVJXEnAxFGVEyWb7Z1514dmz38G2h7ogG0qdFcFvICSt0O7Lu81uAEYJvOJoqaAkzMFraC3ItMq72YM+tk3MK/8OvX0sfnBOIsQxREb/GTnmkFMNcM4o7gKhDZA8Ze2bqvRnFcWA9M+HHV0aQlYDHz/A2UmAf912fYGri8wtGgd6rdwU819JVG3mTm7XIIo1FlCm1FMKOSJh+ffv6eiXuCoY0Jtkpa7LaWbqOsgsozIeC1lg/IKCUZsWsZ9GcFCur1KeiU5G32FFk//6kkYcpqk4pal8AW4jk1gdYtDjL1ZkKSfoQRV/v1QV2dYZ1AcuDOxKlLu0/HePMuvgPsMC9LQ86oFff7; 4:meA+uc39+zl1yveUr0vDrjblwrmy/H/LcEaE1IqSyaZOAqdrHV7mEzxPMRqgLBVq4O8QVdqT8Os9TDR+iJMrVSczr8u/FSH9i5feTrIBH/oWfKP3NaHNsSTX8GmuhB4fmpuh5Kv0kmEJLQsIuaXSL68O9Sez+x9O+dGzvo34oPV6/Fq/rRKyAw6gUrfJD3I+vMpEiRO+WGjAh3QfLcAlb8sI5wF+mBnt0YMxNRoe6fXkEVpYOKMdzPxokgDIRIh3 X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123562025)(20161123560025)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR0502MB3056; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR0502MB3056; X-Forefront-PRVS: 0414DF926F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(199003)(189002)(5003940100001)(7350300001)(48376002)(21086003)(50466002)(6916009)(2950100002)(25786009)(6666003)(189998001)(478600001)(4326008)(33646002)(36756003)(33026002)(55016002)(69596002)(66066001)(110136004)(47776003)(53936002)(2906002)(42186005)(305945005)(7736002)(86362001)(105586002)(76176999)(50986999)(3846002)(6116002)(106356001)(50226002)(68736007)(8676002)(81156014)(81166006)(97736004)(101416001)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0502MB3056; 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) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0502MB3056; 23:Jw/ou1fZcxNOCR0P/cuTo2KHhM2Awbfg99as8rQ?= =?us-ascii?Q?76T14X/BPvpLyWMsMOVnKZC+uWaDofikVkIZi/+KO1g3KA4mOggJmbDrZpiF?= =?us-ascii?Q?G2nUunsMk2wZZE+DdgPheic5sTpXO5kCCofigRG3w13upaLy/2t07x0m4MU1?= =?us-ascii?Q?vYFj3zQo9s3pcnsHLWaeWtk6uextUOwXcSIqPYgQdTROu6oazJrhD/BXCZXb?= =?us-ascii?Q?Nt7TeCF5xYXSwxazgFTzzajpOfY7Dew16lUiPw5e4mzSNEo5ACMl9C+tFvcV?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zKZnkxAL2p2IY?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3056; 6:+zayzs3P66b3RUJ+8M20YeXYA14gL3ljasjCB33Bwz6wteFTdYf20v+LYBIVN3l/LoKV1/UKOR7BQ+ZehwBpQAlVmkg/wiuzsT4NjBvKjwErYWZHDHqNsd0y1wyk5RdZAwmBGLFR3o5dvkDdPW7vKqHDdzFNv7Fl+Qq1o7PILgOfOFvTLiuLxopnaNYvByyz4AnyauiHGkj/HNnnTp7G7k9Ac/Ov3VEs/6gJbFpdbiLzn+GZLY562p7zUzZuhTXmPuMZeFJj82GEVBTsHBvgj/ENs7xKQfZAq7D7DcaV6lgOPAlVGkTFfnfKwC4gMWaSvj6DxjsuqMfZiDC3373TPw==; 5:kWpRiGXdnOrtpvRcchIjUUj3EgZUjiLRwCi28tOsUup/WjV6JRxIsH+7SqWxMIDcK7oNKCtOcGYR76VsJ8CGCEOIGS4cw+arCG4qv0FIvy3Rlab9To7yd/3g9AXFk6qgK3oB/6JQQeViiDXCktuVtg==; 24:EAZDjKTz7LvosKJjab/v2jhyYWf93Dra7k6TStg2PPrBGVuNJUUDk/7g/UXRU04nJDKetkneflgtyRsHj56fDu6PV63IxK1E8lFHKGZqCis=; 7:wGrUwFN607QrcgJOqiAqIUMvbvjYV4lEZsbcO/QEQDXT0RWcITqAcoffMjzmNbcYloN4lVkTO4UDvP0cRQYDWS1XGTWCtb/zMwXO336a75/ozBElOrXNWBBeGX4gewKhprsVcLyS9IuJbY6/9atp4Cz/cdH2tgHdNiOW6j0zBFlypKuG0EpGXgBP9y55VrKj0E/HiPeAjMIRo0XRqKaHJ5MZ5BrKPT6LBrf2NzbtIJM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2017 08:31:07.0076 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3056 Subject: [dpdk-dev] [PATCH v2] 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: Tue, 29 Aug 2017 08:31:10 -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 | 108 ++++++++++++++++++++++++++++------------- 2 files changed, 76 insertions(+), 34 deletions(-) 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..2cf7726 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -1112,47 +1112,83 @@ 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 PMD is working in polling mode it gets 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); + 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,11 +1208,11 @@ 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); + NULL); } /** @@ -1192,14 +1228,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); + NULL); + if (events & (1 << RTE_ETH_EVENT_INTR_RMV)) + _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RMV, NULL, + NULL); } /** @@ -1213,7 +1252,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 +1278,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 +1287,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