From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50084.outbound.protection.outlook.com [40.107.5.84]) by dpdk.org (Postfix) with ESMTP id 9EE792C6D for ; Sun, 6 May 2018 08:06:52 +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=XNhq7Cog7e8gCFWmZrx4YxNISaXwrUrpvpNm4lEkiug=; b=lV+eDS9qTopIbC1Qnva6hr3l1cP5SxCtL8Z3ZchE55w8wx2Nvp+6YQDusH5MSdupsoYwmyZt8VicqorJdCT3KG1XTa4isKY+gUH6kAvcXG56Aaq3rkiJusjVVGDvCwJ1HVV0TAeha1hTSos8iLFhB0Z4u4AseXvM2egwS5AxQTI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; Received: from mellanox.com (141.226.120.58) by AM6PR05MB4422.eurprd05.prod.outlook.com (2603:10a6:209:43::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.735.16; Sun, 6 May 2018 06:06:50 +0000 From: Shahaf Shuler To: bluca@debian.org Cc: stable@dpdk.org, nelio.laranjeiro@6wind.com, yskoh@mellanox.com, adrien.mazarguil@6wind.com Date: Sun, 6 May 2018 09:05:49 +0300 Message-Id: <79d00e5d84a2ff4afecb3fe39a00e9e65ac8ad9e.1525586526.git.shahafs@mellanox.com> X-Mailer: git-send-email 2.12.0 MIME-Version: 1.0 In-Reply-To: References: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Originating-IP: [141.226.120.58] X-ClientProxiedBy: LO2P265CA0008.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::20) To AM6PR05MB4422.eurprd05.prod.outlook.com (2603:10a6:209:43::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM6PR05MB4422; X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4422; 3:MmtAf0KH8I/iWtmNWFgyyaK7blVDarT9VghdGNUs2nx8d135QNQR9j3JyMd75rIMBPQeDSXOuzPOsqkDs7VtdsmgtTt4/0YMdjZrLYEK+7oYvS5j3zapm6SkiNEktv4eCBYcheUgpmX7pkHQCdiOwTDjcAfyvIFpthNrL/vfUbpe+hJhwQwvOQErZo8oK6srp52T/Iso/4upUkbtYwy+Ociy9ek8Jwjfy8zDMRmD7GRlFwokU8+a+X/6TY2qsFYw; 25:Vua3+GejYUH9Yi3bZ+zDuwreV7xN/qd1ouKieu9UGYtck7hzfmhDalo1fgmwygRb2qYnz94VB2TLlomiRnYlphop94wok/wM8ZOfHmwNPeRyMLXYtLcrmGBcPSpTbj2S60Y76fSNNfaz8I89cNymfaNaUUCR8nqWcX/bihFETdPM7O2LzKkZHRz27iNU7+FGj5s1MZosnHLWN3iwj81K1s/Z2mFk6WMnB9JXUsAx7SmQGFj6V1J1sSuPHUSlQfJ38g4i3IGI7XMEnzk6/pL4ejg1BtpgG/fqOhu0n0mgXkpA5h6cG6wGz3f/gfJKCPBBk704+8P9eSHysXtIZkg5Hg==; 31:MWxzKeh4TnUTVmQVzgJiFgMgq5WOO0yXqVcAzAeKd26THDKYzxkqsvEZi7hi64uDaA6el589wDGU9NCZD4nR1KvMwQX0odjlMFSKBlJIskaowdSYJTf2My9k8V+W+g8+9E5rRKGCuHseogbmEt9hO+yXtcJQfd1GYbJyqxyNW+tuPr0HN53gNjHXv5tg7wpS6K2e7MjoENYWZItG0/atsNwk7ULlgSIOKoRlpDBOANg= X-MS-TrafficTypeDiagnostic: AM6PR05MB4422: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4422; 20:x1RELFdARuUE2NU4QnTekXtai5uojqQsRgnSd45hbqa72wn3IS8ShToe6pKnntpgcKX9kQxW64MP9+3IpJ0xHQ9LHOuGlpH+T3gYRwoYk42+b3vM9h/ZxpCye3mpslGEZDstdneMtLPwdbUNkgIbW9E8OgS+Z4uGKxQB4py9F1mW80U3/pJ4Alc5wiHoHi1OsRiVj7X4rIJkwS2AH9hGmQU1fGjI1YqM4Og1siN5lPY3AZF9tCnMincV7+/6FXMAxq3anEqRlqBEgSK4yKCHEc8occwCB8of8qFjyNIZuQy68j9QcMKVOucvBJe1Fm2qdNiaEywCjWiIT2OJP0JkoQeQJJ9iXhq3WZ10qI+B7JQoWwAuVGV09BWuXXo5aaGR4OjQ3KFv7pTubgpDrmuIo6s6u9J3WVlIPAAOGipI+z82ehaiNzvcKEI8UT/U4EfpkJ4rg9wijJqY/5FlUbLEbMa6k+9Z//GRHupHzkd/h7HM6+by7R2vT2f4HSnV2t9D; 4:JgT9KruYMnIfe+uu/pRju8HoQNSLG+FNyD/0pRJBgYtQHz2Txepotb/O+avZbXJW1d+aHVtp2CaHpQR9ICw98kq+5aT/ySpKtvaZjXFlVAXFmM174E6+dvPmoOGuO7Y4aS3Z7TxKCkxo5M7nh8YSajM5pDHgdsukN9Q/0AdEKco6j8Jsng7wy78W1n+4xUAJ3idPxD1oCso5bp/DfQrerNXytw9gQE+NmXpK8ZRWPx9BZv1rRHOBgWWw5JJXpChxBechkrvPUi4l05gmVLjk4w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(6055026)(6041310)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011); SRVR:AM6PR05MB4422; BCL:0; PCL:0; RULEID:; SRVR:AM6PR05MB4422; X-Forefront-PRVS: 06640999CA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(39380400002)(396003)(346002)(39860400002)(189003)(199004)(105586002)(8676002)(8936002)(316002)(2351001)(53936002)(86362001)(2361001)(6116002)(3846002)(106356001)(118296001)(66066001)(36756003)(47776003)(81156014)(55016002)(2906002)(2870700001)(50226002)(4326008)(68736007)(305945005)(7736002)(81166006)(50466002)(25786009)(486006)(5660300001)(476003)(2616005)(69596002)(16526019)(26005)(59450400001)(386003)(97736004)(956004)(186003)(478600001)(7696005)(52116002)(23676004)(6916009)(21086003)(446003)(11346002)(76176011)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB4422; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTZQUjA1TUI0NDIyOzIzOk1taWFMYVE0VFdISlRrbmNTTDltWHBlaDRu?= =?utf-8?B?SjNHL3pSdnZDUStWVGtXRVlONUJqb09iQk5oMTdKV3A1QXduMzlwc3J6N3VR?= =?utf-8?B?QzRCRnI2SWJhNzhObFhJNWpHVkswRTA0REZFN0lKaDRmb1lFMEpES3Nqd0lR?= =?utf-8?B?N0JPcTFkOUlCMTZNQStSdXhYRHdKbE5FL3VJRm1WcDJkWUdSYmpxWmxEanFh?= =?utf-8?B?a0xSVkVCTHdod250bmc1US8wQysyaTN0elZkRjhUazdIRGN3UGxRRjBTWWNi?= =?utf-8?B?UThhdjlUYldUY1c2SGhjeVQ5ZzUrNVgrM1d5a2tUVTl2Wm5sT0FvMkMwVXFx?= =?utf-8?B?TUg5Q3c5WnRFZlVHNzBtZUEwdHYrblUvalEwMUtHUFcxVUUwTGJaY3hFS04r?= =?utf-8?B?UlNXQmhjTEFnRUdEbUc5cj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nPoJSXHwVGKwZxqPD+7F2FeapDMhVrIaw/9LBaAzXtWuimBURXTyT366C4yrIZcbCylhCUwC1vjx/u4wThywan8ws0DEvaJmo7RPjkAHf+Q==; 5:1lqJKbZG3a8NVREh28Oy7tFKnc2+kFsBCRgZSS+kcGIf5qqat1zAY6uWpA+HqT+qjCGL6KytweXnUgtExxa48bkz50e+2bHR13oiARUzLr7HqICZu0IDrMOsleQvTEQsfF+R6eVZC4O9CK/43qMuhP/Bm+trlo06i4DZpq542XA=; 24:l8yZEQMfU6r4TkO1bosQADBqCktQ86cz9KpDHYwRbg4IY/8oGMglp3yiDA157YhpgxGGJFbcQanaBSHEhn4HvdwSjhHxmkKdyg2dVId0F6I= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4422; 7:uuGm2qoIIKbJqMru8SZIFa+2obrCEF6JhAG/e0hm7PI4JIa58f6aKjZNo5Jxr8M2dEwiPBqECfZ/EVlnGPf3GDH9OFelD0hbgTzTO5F4upeF5AEwlqZIXymQp1RNXGiRt3Da5wpboU/qhalMI96L6G2C5uEdH/Kd6dUnQKP4Jnl0j2Rk9CAt6I94eDBFShWvBeMnPgZkqbFajT5b80RUXsd6YVZkq1ItBUKQupIyY/ocaXiiRS21JeiouWHgOu0C X-MS-Office365-Filtering-Correlation-Id: 0ea14fcd-0004-4a31-36cc-08d5b3178f6b X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2018 06:06:50.9268 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0ea14fcd-0004-4a31-36cc-08d5b3178f6b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4422 Subject: [dpdk-stable] [PATCH 20/33] net/mlx5: fix link status to use wait to complete X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 May 2018 06:06:52 -0000 From: NĂ©lio Laranjeiro [ upstream commit cfee94752b8f8f09b984335ae77b29af15b967fd ] Wait to complete is present to let the application get a correct status when it requires it, it should not be ignored. Fixes: e313ef4c2fe8 ("net/mlx5: fix link state on device start") Fixes: cb8faed7dde8 ("mlx5: support link status update") Cc: stable@dpdk.org Signed-off-by: Nelio Laranjeiro Acked-by: Adrien Mazarguil --- drivers/net/mlx5/mlx5.h | 1 - drivers/net/mlx5/mlx5_defs.h | 4 +- drivers/net/mlx5/mlx5_ethdev.c | 147 ++++++++++++++---------------------- 3 files changed, 58 insertions(+), 94 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 86310404a0..faacfd9d61 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -124,7 +124,6 @@ struct priv { /* Device properties. */ uint16_t mtu; /* Configured MTU. */ uint8_t port; /* Physical port number. */ - unsigned int pending_alarm:1; /* An alarm is pending. */ unsigned int isolated:1; /* Whether isolated mode is enabled. */ /* RX/TX queues. */ unsigned int rxqs_n; /* RX queues array size. */ diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h index c3334ca300..6401588eee 100644 --- a/drivers/net/mlx5/mlx5_defs.h +++ b/drivers/net/mlx5/mlx5_defs.h @@ -82,8 +82,8 @@ /* Supported RSS */ #define MLX5_RSS_HF_MASK (~(ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP)) -/* Maximum number of attempts to query link status before giving up. */ -#define MLX5_MAX_LINK_QUERY_ATTEMPTS 5 +/* Timeout in seconds to get a valid link status. */ +#define MLX5_LINK_STATUS_TIMEOUT 10 /* Reserved address space for UAR mapping. */ #define MLX5_UAR_SIZE (1ULL << 32) diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index f5af5189f2..81820214bc 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #include #include "mlx5.h" @@ -469,12 +469,15 @@ mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev) * * @param dev * Pointer to Ethernet device structure. + * @param[out] link + * Storage for current link status. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev) +mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev, + struct rte_eth_link *link) { struct priv *priv = dev->data->dev_private; struct ethtool_cmd edata = { @@ -522,14 +525,13 @@ mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev) ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX); dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED); - if (memcmp(&dev_link, &dev->data->dev_link, sizeof(dev_link))) { - /* Link status changed. */ - dev->data->dev_link = dev_link; - return 0; + if ((dev_link.link_speed && !dev_link.link_status) || + (!dev_link.link_speed && dev_link.link_status)) { + rte_errno = EAGAIN; + return -rte_errno; } - /* Link status is still the same. */ - rte_errno = EAGAIN; - return -rte_errno; + *link = dev_link; + return 0; } /** @@ -537,12 +539,16 @@ mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev) * * @param dev * Pointer to Ethernet device structure. + * @param[out] link + * Storage for current link status. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev) +mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, + struct rte_eth_link *link) + { struct priv *priv = dev->data->dev_private; struct ethtool_link_settings gcmd = { .cmd = ETHTOOL_GLINKSETTINGS }; @@ -623,14 +629,13 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev) ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX); dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED); - if (memcmp(&dev_link, &dev->data->dev_link, sizeof(dev_link))) { - /* Link status changed. */ - dev->data->dev_link = dev_link; - return 0; + if ((dev_link.link_speed && !dev_link.link_status) || + (!dev_link.link_speed && dev_link.link_status)) { + rte_errno = EAGAIN; + return -rte_errno; } - /* Link status is still the same. */ - rte_errno = EAGAIN; - return -rte_errno; + *link = dev_link; + return 0; } /** @@ -639,20 +644,43 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev) * @param dev * Pointer to Ethernet device structure. * @param wait_to_complete - * Wait for request completion (ignored). + * Wait for request completion. * * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. + * 0 if link status was not updated, positive if it was, a negative errno + * value otherwise and rte_errno is set. */ int -mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused) +mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete) { int ret; + struct rte_eth_link dev_link; + time_t start_time = time(NULL); - ret = mlx5_link_update_unlocked_gset(dev); - if (ret) - ret = mlx5_link_update_unlocked_gs(dev); - return 0; + do { + ret = mlx5_link_update_unlocked_gset(dev, &dev_link); + if (ret) + ret = mlx5_link_update_unlocked_gs(dev, &dev_link); + if (ret == 0) + break; + /* Handle wait to complete situation. */ + if (wait_to_complete && ret == -EAGAIN) { + if (abs((int)difftime(time(NULL), start_time)) < + MLX5_LINK_STATUS_TIMEOUT) { + usleep(0); + continue; + } else { + rte_errno = EBUSY; + return -rte_errno; + } + } else if (ret < 0) { + return ret; + } + } while (wait_to_complete); + ret = !!memcmp(&dev->data->dev_link, &dev_link, + sizeof(struct rte_eth_link)); + dev->data->dev_link = dev_link; + return ret; } /** @@ -827,47 +855,6 @@ mlx5_ibv_device_to_pci_addr(const struct ibv_device *device, } /** - * Update the link status. - * - * @param dev - * Pointer to Ethernet device. - * - * @return - * Zero if the callback process can be called immediately, negative errno - * value otherwise and rte_errno is set. - */ -static int -mlx5_link_status_update(struct rte_eth_dev *dev) -{ - struct priv *priv = dev->data->dev_private; - struct rte_eth_link *link = &dev->data->dev_link; - int ret; - - ret = mlx5_link_update(dev, 0); - if (ret) - return ret; - if (((link->link_speed == 0) && link->link_status) || - ((link->link_speed != 0) && !link->link_status)) { - /* - * Inconsistent status. Event likely occurred before the - * kernel netdevice exposes the new status. - */ - 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)) { - /* Link interrupt occurred while alarm is already scheduled. */ - priv->pending_alarm = 0; - rte_eal_alarm_cancel(mlx5_dev_link_status_handler, priv->dev); - } - return 0; -} - -/** * Device status handler. * * @param dev @@ -885,6 +872,10 @@ mlx5_dev_status_handler(struct rte_eth_dev *dev) struct ibv_async_event event; uint32_t ret = 0; + if (mlx5_link_update(dev, 0) == -EAGAIN) { + usleep(0); + return 0; + } /* Read all message and acknowledge them. */ for (;;) { if (mlx5_glue->get_async_event(priv->ctx, &event)) @@ -901,32 +892,10 @@ mlx5_dev_status_handler(struct rte_eth_dev *dev) event.event_type, event.element.port_num); mlx5_glue->ack_async_event(&event); } - if (ret & (1 << RTE_ETH_EVENT_INTR_LSC)) - if (mlx5_link_status_update(dev)) - ret &= ~(1 << RTE_ETH_EVENT_INTR_LSC); return ret; } /** - * Handle delayed link status event. - * - * @param arg - * Registered argument. - */ -void -mlx5_dev_link_status_handler(void *arg) -{ - struct rte_eth_dev *dev = arg; - struct priv *priv = dev->data->dev_private; - int ret; - - priv->pending_alarm = 0; - ret = mlx5_link_status_update(dev); - if (!ret) - _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL); -} - -/** * Handle interrupts from the NIC. * * @param[in] intr_handle @@ -979,10 +948,6 @@ mlx5_dev_interrupt_handler_uninstall(struct rte_eth_dev *dev) if (priv->primary_socket) rte_intr_callback_unregister(&priv->intr_handle_socket, mlx5_dev_handler_socket, dev); - if (priv->pending_alarm) { - priv->pending_alarm = 0; - rte_eal_alarm_cancel(mlx5_dev_link_status_handler, dev); - } priv->intr_handle.fd = 0; priv->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN; priv->intr_handle_socket.fd = 0; -- 2.12.0