From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30082.outbound.protection.outlook.com [40.107.3.82]) by dpdk.org (Postfix) with ESMTP id 36DBB322C; Tue, 16 Jan 2018 00:48:26 +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=Wi/lLTTLO+uqtIg5VRbftcT4HpQ/vtm3zsbNBhdWnek=; b=IkBwxb1Mrq4/cJ3dgESZPa8f6TjWjYSFqL5rQWX9Ct64Ib3k/LuYYxFyd3GYWQyAxea343wVXucW+vlO2SMAw1AleS+dltQ1SQPLJPsOMLr5SpOCNGTFusoemMyqe4RdotWGRQ24ZnmIxnewg8cdSzJJ5NYWDdBzK2fMC3/dqe4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; Received: from mellanox.com (209.116.155.178) by VI1PR0501MB2046.eurprd05.prod.outlook.com (2603:10a6:800:36::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Mon, 15 Jan 2018 23:48:21 +0000 From: Yongseok Koh To: adrien.mazarguil@6wind.com, nelio.laranjeiro@6wind.com Cc: dev@dpdk.org, Yongseok Koh , stable@dpdk.org Date: Mon, 15 Jan 2018 15:48:00 -0800 Message-Id: <20180115234800.3316-1-yskoh@mellanox.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [209.116.155.178] X-ClientProxiedBy: CY1PR07CA0033.namprd07.prod.outlook.com (2a01:111:e400:c60a::43) To VI1PR0501MB2046.eurprd05.prod.outlook.com (2603:10a6:800:36::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 132ec4fa-6e60-45e3-9a0a-08d55c72768a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR0501MB2046; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2046; 3:baSSBhSLc9lq1V2N0iMrdLlAWfN06qzhBEQxprWOA2vMGvR0jMT/gTupluTJsNAR1S3qZyRi9yP1LVg6ikGwrJ1J47ZWIeoUyQjZUc0pYTvAS+nAaJOl7B5nsYhTmPR4UAaZ2kkAdvXutFjhGkxGwtcQHxyXRpPhwODummTG36PU9oG/58RLYdsasGO8Gw5yYcxbcuP6+OAvQlDMPyEP103fU68yp70ucx+hbMtu1MxeSYQzyEFI/P416HSlOg2d; 25:NRWzAD23orLYh1QI5azBFKJQi+7kZfoScL874I0mnN9f9BLR63hb22fjhK6ZrdkpvnVe+0bEvijt50G0QBlAckTAqhJaEX4fAxSI4ThWRxkC42nZYJET/ZnLRD68m5RvkN9/orDkTF7P2J6mA3rmshxXOgTUahd3f5k/TFSDUSd/JsX4538crqWF/+GdpVfdoctGOZGORkdhtCA2haECk6Sr/sakSQvz67iV/jPu7ksTdq89XIEt1ZHhP7yWP327p6WJyC/lp8nCvpG8u/6ejhZPgV9J7KdvfsSD9t1Bqkckn+rLK/CdPn+iqFPSWrnHFFvqqaK+4VKUy8Ya7dDJYw==; 31:XyUC0jiKCPIsQjzZcfdBEH0gqYdltBpF5ww8DjLGtovcJpwWwVJ8HWN8V/qPvbGZjriIIjUxg9yzHO2j/WXME2Oj/+8xiqnK3/Qg15EVIbj9IVKi7IOgq6TXSRfF0g6n21LYd8kcNEC6R8XFBqz96Si7RQ2B/KXL9oRsGXkApC3An+QSRMGwsgNHnu1Ckpri/poF6jItefAZhc7k8ttEfFAvi+ku2rbuCw9MlJYfIdk= X-MS-TrafficTypeDiagnostic: VI1PR0501MB2046: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2046; 20:zLWlg7rvHyPQ86gr5hofP4Ftm/2CoEiEuBT4EHXG3qRV6Lg88qmFPGu77wvp/IMmo9oJIpCSw7rd7PwIQHNW2dTCm9JPGwe7o9quoUDL5rg266K1mywPxJH6r9B/nR1nW/zC9OaQ8rNbXlBTbUqbrnzSq0dUdqWyPWL0fmFysL1saHT5pgFcpdJ0LnvxYwoGGikg3+eSBo6Y+eI7kLo21W971wzu3Wbw71GzxTDQETHa2XDFMBmBE20vv3Ox2yFsIccgf5WLWHV9BELJ65hvg27kJ8iVQBLdXZ/mrRggFjN0w9dP6wt7R5Nx8pNLk1e1MQX4tdarnSFMO7YqtX1JvNsJVieYs6r8WEyu0mNW5D0KFrqp8iN72EtATRQjAxlOvnVpOtfiZsG/2iRsbErlG0CPTi0E3bL9RFbkkQiUzKGytnV/mShS+5TkcveVbb1XG7xaQ3D/Wn4rfH8AforcAoe3blAaOdvXOZer240ydHzaVxND28UuAtdr06fsSj03; 4:aeXfYIwY7Bl6O2vh4qSD0SL9+5suYwXwhhu/sj0JtOwSztaSlc70Ur+QQIcd6V0j+nGtbr3N0BWFLDvnTcbCQDNhGpi41iP0cNfs+LM8MeHDCq6fGI2sfntNs7TdQZa+uwKdi2VNKR7hft/VbU/Q3sEWmKhO3xa47ZvqiW+8HfOf6If7cqv9dRYh+tLMUWmzy64RTvW8ZPOCmqtyrwADMH8EaFByVL0FG/I+kLOM3/Re5bjUgMTaiYRktxzevWz5SGvVdNmlMDY6HsFL4h/iLQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(10201501046)(3231023)(944501161)(3002001)(93006095)(93001095)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:VI1PR0501MB2046; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:VI1PR0501MB2046; X-Forefront-PRVS: 0553CBB77A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(396003)(346002)(39380400002)(376002)(39860400002)(189003)(199004)(6666003)(7736002)(86362001)(316002)(5660300001)(16586007)(106356001)(55016002)(81166006)(8676002)(81156014)(305945005)(105586002)(2906002)(53936002)(1076002)(6116002)(21086003)(3846002)(59450400001)(386003)(50466002)(36756003)(48376002)(97736004)(66066001)(47776003)(16526018)(4326008)(478600001)(7696005)(51416003)(52116002)(68736007)(8936002)(50226002)(69596002)(25786009)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2046; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; VI1PR0501MB2046; 23:wzPh39BnK6+q1gV/flZ1rQ+lr+9jAV0LAOYfykX?= =?us-ascii?Q?5+dcF3W79JN1kxIMOyBCDgwhfXJOl0g8V7zYeytoIU62jpPwgM2V8K9lc3FB?= =?us-ascii?Q?ueLVig38Q6c2x9NcqWh6iiZoxK4FLy3oY59otGGZjmcODNjVB1zq0XVn8Nv4?= =?us-ascii?Q?NRH9HQRHHyd0Ubh32OYUUV7+aHuAJDsAcjuhTmJ2Zw26Eqbdt+lFFn2PMDCH?= =?us-ascii?Q?oPDBwpzK/0Vb+8sHuW36NaDBHm8f+zhoD3+j4Pk3UXP0xSJE5l1EMVFUGcda?= =?us-ascii?Q?hehHbDppbcnXGSiA3d84ZLxoPKGqKdMGWeNAwCxlGHq27B67i3gnCJQue6yv?= =?us-ascii?Q?aQc1DNiCYmjrKOayk0h3rA6RQVKF6CqE+yy7ip63zcpVYxBwXEMXavNfmIvh?= =?us-ascii?Q?KgheNyscAVNgR27V/wLJhyKPbdRb5ckH8Oo6FZEUVSaS4oOqiFrCbAIU0dCK?= =?us-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WF9NMVy5ekbqErh4gi3QdAaZXaBEBSp4to8Gtp8t+8B/kdJL0jR98S6YY4/82ROyGxQryM0grxppKrx3Csi2IulcpH6CKcIYhoWVRMKvkZ+gJdm+eR/De37GzSM5wAiYx3WNGWqE7k=; 5:VM9s86dkWd6d0ZFsj1gey59Qp9j9vXJlYWfz6HZyS8demOUsk0mwcRCWtYA138o+c7ZKtTbHm3lrOs2a8CXHpSNEtIwopjBdezl++XFqyWS/oN78e6PZn8N7kwYLPKToG9OGgsvl5TuFgVqZIthGtGWhe2VxTtpeNoSG0P8quu8=; 24:044eupLWF+p9X6WrfisQSiuVsrUkiQRDJwLxf/kCn8JXLnEKwp8xNx0e/K2u+FUp+fs4CFID0bXegPPiUYU3iwppJdcuxPfY1WQQ9Z6ZwSY=; 7:iqYmCcooCv51UxzIRQKg93IrLGAUqyNM0P1WlA2UuPADign5fyJGs/HVTds/AchrXKhyQxF7Z+L6b6qusOw/lUvNH3UGl4KqsYmMo3YbyA2cryunWMLMLw7a61YI96ir65LiLjcaNdxajGF60kzU+CW91Gpb0kCyF3RmRpKZ5vkicrmjoq62r6keQwMELDpkMwi6ge4FhlZEKT9Kuj0ILr1ZWO0jH6u/OKZFPsvtLqIwfxyXNfSYlOS4SWMxZiQt SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2018 23:48:21.5739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 132ec4fa-6e60-45e3-9a0a-08d55c72768a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2046 Subject: [dpdk-stable] [PATCH] net/mlx5: fix handling link status change event 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: Mon, 15 Jan 2018 23:48:26 -0000 Even though link of a port gets down, device still can receive traffic. That is the reason why mlx5_set_link_up/down() switches rx/tx_pkt_burst(). However, if link gets down by an external command (e.g. ifconfig), it isn't effective. It is better to change burst functions when link status change is detected. Fixes: 62072098b54e ("mlx5: support setting link up or down") Cc: stable@dpdk.org Signed-off-by: Yongseok Koh --- drivers/net/mlx5/mlx5.c | 1 - drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_ethdev.c | 112 +++++++++++++++++++++++++++++++--------- drivers/net/mlx5/mlx5_trigger.c | 23 ++------- 4 files changed, 93 insertions(+), 44 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 1c95f3520..fc2d59fee 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -869,7 +869,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) /* Bring Ethernet device up. */ DEBUG("forcing Ethernet interface up"); priv_set_flags(priv, ~IFF_UP, IFF_UP); - mlx5_link_update(priv->dev, 1); /* Store device configuration on private structure. */ priv->config = config; continue; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index e740a4e77..9a4a59bd4 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -225,6 +225,7 @@ int priv_set_flags(struct priv *, unsigned int, unsigned int); int mlx5_dev_configure(struct rte_eth_dev *); void mlx5_dev_infos_get(struct rte_eth_dev *, struct rte_eth_dev_info *); const uint32_t *mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev); +int priv_link_update(struct priv *, int); int mlx5_link_update(struct rte_eth_dev *, int); int mlx5_dev_set_mtu(struct rte_eth_dev *, uint16_t); int mlx5_dev_get_flow_ctrl(struct rte_eth_dev *, struct rte_eth_fc_conf *); diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 6f78adc4a..16377a8cb 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -885,7 +885,49 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete) } /** - * DPDK callback to retrieve physical link information. + * Enable receiving and transmitting traffic. + * + * @param dev + * Pointer to Ethernet device structure. + */ +static void +priv_link_start(struct priv *priv) +{ + struct rte_eth_dev *dev = priv->dev; + int err; + + dev->tx_pkt_burst = priv_select_tx_function(priv, dev); + dev->rx_pkt_burst = priv_select_rx_function(priv, dev); + err = priv_dev_traffic_enable(priv, dev); + if (err) + ERROR("%p: error occurred while configuring control flows: %s", + (void *)priv, strerror(err)); + err = priv_flow_start(priv, &priv->flows); + if (err) + ERROR("%p: error occurred while configuring flows: %s", + (void *)priv, strerror(err)); +} + +/** + * Disable receiving and transmitting traffic. + * + * @param dev + * Pointer to Ethernet device structure. + */ +static void +priv_link_stop(struct priv *priv) +{ + struct rte_eth_dev *dev = priv->dev; + + priv_flow_stop(priv, &priv->flows); + priv_dev_traffic_disable(priv, dev); + dev->rx_pkt_burst = removed_rx_burst; + dev->tx_pkt_burst = removed_tx_burst; +} + +/** + * Retrieve physical link information and update rx/tx_pkt_burst callbacks + * accordingly. * * @param dev * Pointer to Ethernet device structure. @@ -893,17 +935,54 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete) * Wait for request completion (ignored). */ int -mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete) +priv_link_update(struct priv *priv, int wait_to_complete) { + struct rte_eth_dev *dev = priv->dev; struct utsname utsname; int ver[3]; + int ret; + struct rte_eth_link dev_link = dev->data->dev_link; if (uname(&utsname) == -1 || sscanf(utsname.release, "%d.%d.%d", &ver[0], &ver[1], &ver[2]) != 3 || KERNEL_VERSION(ver[0], ver[1], ver[2]) < KERNEL_VERSION(4, 9, 0)) - return mlx5_link_update_unlocked_gset(dev, wait_to_complete); - return mlx5_link_update_unlocked_gs(dev, wait_to_complete); + ret = mlx5_link_update_unlocked_gset(dev, wait_to_complete); + else + ret = mlx5_link_update_unlocked_gs(dev, wait_to_complete); + /* If lsc interrupt is disabled, should always be ready for traffic. */ + if (!dev->data->dev_conf.intr_conf.lsc) { + priv_link_start(priv); + return ret; + } + /* Re-select burst callbacks only if link status has been changed. */ + if (!ret && dev_link.link_status != dev->data->dev_link.link_status) { + if (dev->data->dev_link.link_status == ETH_LINK_UP) + priv_link_start(priv); + else + priv_link_stop(priv); + } + return ret; +} + +/** + * DPDK callback to retrieve physical link information. + * + * @param dev + * Pointer to Ethernet device structure. + * @param wait_to_complete + * Wait for request completion (ignored). + */ +int +mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete) +{ + struct priv *priv = dev->data->dev_private; + int ret; + + priv_lock(priv); + ret = priv_link_update(priv, wait_to_complete); + priv_unlock(priv); + return ret; } /** @@ -1113,7 +1192,7 @@ priv_link_status_update(struct priv *priv) { struct rte_eth_link *link = &priv->dev->data->dev_link; - mlx5_link_update(priv->dev, 0); + priv_link_update(priv, 0); if (((link->link_speed == 0) && link->link_status) || ((link->link_speed != 0) && !link->link_status)) { /* @@ -1321,24 +1400,9 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev) * 0 on success, errno value on failure. */ static int -priv_dev_set_link(struct priv *priv, struct rte_eth_dev *dev, int up) +priv_dev_set_link(struct priv *priv, int up) { - int err; - - if (up) { - err = priv_set_flags(priv, ~IFF_UP, IFF_UP); - if (err) - return err; - dev->tx_pkt_burst = priv_select_tx_function(priv, dev); - dev->rx_pkt_burst = priv_select_rx_function(priv, dev); - } else { - err = priv_set_flags(priv, ~IFF_UP, ~IFF_UP); - if (err) - return err; - dev->rx_pkt_burst = removed_rx_burst; - dev->tx_pkt_burst = removed_tx_burst; - } - return 0; + return priv_set_flags(priv, ~IFF_UP, up ? IFF_UP : ~IFF_UP); } /** @@ -1357,7 +1421,7 @@ mlx5_set_link_down(struct rte_eth_dev *dev) int err; priv_lock(priv); - err = priv_dev_set_link(priv, dev, 0); + err = priv_dev_set_link(priv, 0); priv_unlock(priv); return err; } @@ -1378,7 +1442,7 @@ mlx5_set_link_up(struct rte_eth_dev *dev) int err; priv_lock(priv); - err = priv_dev_set_link(priv, dev, 1); + err = priv_dev_set_link(priv, 1); priv_unlock(priv); return err; } diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index 1a20967a2..6f5c799b5 100644 --- a/drivers/net/mlx5/mlx5_trigger.c +++ b/drivers/net/mlx5/mlx5_trigger.c @@ -151,38 +151,23 @@ mlx5_dev_start(struct rte_eth_dev *dev) (void *)dev, strerror(err)); goto error; } - /* Update send callback. */ - dev->tx_pkt_burst = priv_select_tx_function(priv, dev); err = priv_rxq_start(priv); if (err) { ERROR("%p: RXQ allocation failed: %s", (void *)dev, strerror(err)); goto error; } - /* Update receive callback. */ - dev->rx_pkt_burst = priv_select_rx_function(priv, dev); - err = priv_dev_traffic_enable(priv, dev); - if (err) { - ERROR("%p: an error occurred while configuring control flows:" - " %s", - (void *)priv, strerror(err)); - goto error; - } - err = priv_flow_start(priv, &priv->flows); - if (err) { - ERROR("%p: an error occurred while configuring flows:" - " %s", - (void *)priv, strerror(err)); - goto error; - } err = priv_rx_intr_vec_enable(priv); if (err) { ERROR("%p: RX interrupt vector creation failed", (void *)priv); goto error; } - priv_dev_interrupt_handler_install(priv, dev); priv_xstats_init(priv); + /* Update link status and Tx/Rx callbacks for the first time. */ + memset(&dev->data->dev_link, 0, sizeof(struct rte_eth_link)); + priv_link_update(priv, 1); + priv_dev_interrupt_handler_install(priv, dev); priv_unlock(priv); return 0; error: -- 2.11.0