From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40087.outbound.protection.outlook.com [40.107.4.87]) by dpdk.org (Postfix) with ESMTP id 9CE741B617 for ; Thu, 2 Nov 2017 16:42:46 +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=BHtvHIK0UcVdbfhJEc9grd8UYsZXTeys0mwXpXdGyc0=; b=Uhx+pc6vRg7+fNA7r7vcoYhHDnMNwqSlXXprhc2W+JNzAYOEcRAh+FFsaXxpeKN+Etfw91SlBQyJkUlhiDFAD8WBcRRDnk34uuA5/3hTewr0ylnYGGISu82sIccEQ3A6W/AQbvixLPT1vruvcVN0+Q3xFXJjwfEi77xiKELVdMo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by VI1PR0502MB3664.eurprd05.prod.outlook.com (2603:10a6:803:f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Thu, 2 Nov 2017 15:42:44 +0000 From: Matan Azrad To: Adrien Mazarguil , Gaetan Rivet Cc: dev@dpdk.org Date: Thu, 2 Nov 2017 15:42:04 +0000 Message-Id: <1509637324-13525-4-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1509637324-13525-1-git-send-email-matan@mellanox.com> References: <1509637324-13525-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: DB6PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:4:29::31) To VI1PR0502MB3664.eurprd05.prod.outlook.com (2603:10a6:803:f::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7aba00b2-c50b-46c2-382a-08d522085cd9 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:VI1PR0502MB3664; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3664; 3:awqIYMiZeOB8mfCnmShGOK0XSdKmZhhj9/HumPADAc9YP99vWeR9DFZIkwUqUhzL+Dtf6Apwni73Dtj+bTM7K72US68vvLtVThDcswjjVqPqN6peK77F+dNRnjYPNipogj95UErKlrL/r5BVXl8t3nH51wE+9OTe7alaStCqQFS7fr5tsyZ24vWEvzhYfLKEJIevjcCWWWe8ofr9AerE12gxo4x5Bnvu3+NPct4roQYZx/9weiV0cNziAlbVNc/n; 25:G7q5r/A2PI9kOTV2sHcZDH5jMlMZLwkIym8RpSQgTYSRhTdSFcvaXHS0B1YuFfCi/4CijQE6pk01hAocwiYjNsw66M9jlDqDUS0jNaFR45L6f0nQVCnmBe9c8ovBrxGHYOcWwBLYM1pauvlm5H8qs6NYPOAJTWxTyccap8jtemdKxC0GPhmn8gVbtBcIxPTZYYK/6cVe5ftpAFbTxgUOF4JbzBEWLnb1B184LV7uV0EUnUFmWCQAIpiu3mlfVPivZx/Ec3GtwHf0aTKFHBbf+qd4YA31tpnA/AJRZ/gUENLDJJaasEnE3HgOiRHG0EtqtVH+QPkgVRLy4/FM8E6A4g==; 31:kJhCQsgKSBcaEfuzJbyGMDkeb66ijmQgtWKfpG9iAD1ubP84bQRud1OzYJ7qvyBaGzhYbnuykClBFzwtcNJPSaohXxeyuJNQj9z/2KXFqHkAYUJz8d6aPWN9ujlwSilP+EmjXID/s0uc2FKa0m7pXQZQSWC9RpgTMJIwm0feTZvOqQIHCekyq++uZn8Q+7ldIIToPZs+kN/vSt3ceW57P8w/bHpF0gkyxmx9qAMwzgQ= X-MS-TrafficTypeDiagnostic: VI1PR0502MB3664: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3664; 20:hWliolfiAVOoP099uI1LvBZsmgzJGMPI+NVdrwhYoB9qTSZgbKqw+LESnj4eN7+kt49elRAuETstyphFOZi361MyP/KVc2Jgsupu2pnoEPJHCw7288tOg3Ncbeu7IemgMsYdCGl2/vdhBPmGnbQn8cUE5S19f4Dy0jdJCrzXpkdLGRoqJPmxxbAGe7vgSu3ySTRj9TP/yszg6GNc0+oHNS73L6Ba0kRjnwt9RxMoK863NkmozBQ2k2l9VZtpXKNuYQE+fdyLpLMdh94oSEKo4WjEuIX3kgKv6Fnco2Cc9mbcG+j7sMfyrd9lQ3vjUozSGdbnD+PmgqywmSJybKH7wjyY4Ua+zwYS0WRgQvyjA3liCftxPw8PBdjPJcprXF6x47ZKlThGqCfK12oLVLTFEDtyaiIZf1fsyco/tzNfZo7a3OAhJmCUAM7WwpxarfMV57mxwcubWWaSjdbOxQfJ5afO/x2xRG/zklUoONL82zXzw6D+D0j9Hi800ETHBPL7; 4:4PA1iYW7g0Jo0nwQHbkFt8K8+uN9Ugkf+5uXlSB4amehD2/DkRCePodjDc28JDtn1+63XnK3OQweS/uHRBRadBjMSG9/KA8xV/kNPegO9GVrF017JPLbG+HErXBLX9+jSWx9ppzYg6y96f0DjP4yyNuFQvpZxjsMJTnR6fx34xQ+P/LNNSQojFkJxmP6MzImiIqgTrKlI07xGkipmKTHju/uAzQh8DEhqh+x0JXDC+2drV112JWyTLtSBkl00anOYPAoixKW/DuXPwjqusT8mQ== 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)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(100000703101)(100105400095)(3231020)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123562025)(20161123558100)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR0502MB3664; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR0502MB3664; X-Forefront-PRVS: 047999FF16 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(39860400002)(199003)(189002)(8936002)(48376002)(50466002)(2906002)(81166006)(81156014)(8676002)(3846002)(6116002)(106356001)(69596002)(105586002)(33646002)(2950100002)(6666003)(4720700003)(76176999)(50986999)(5660300001)(101416001)(5003940100001)(189998001)(7736002)(36756003)(53936002)(97736004)(25786009)(316002)(33026002)(16586007)(86362001)(47776003)(4326008)(66066001)(575784001)(16526018)(50226002)(478600001)(68736007)(110136005)(55016002)(21086003)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0502MB3664; 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; VI1PR0502MB3664; 23:mCWPfKu9T8BqDFtEINRSGe2SyzkPtfoJWF83fzq?= =?us-ascii?Q?8YeBFRk9Tu+ISyxvVytdDWvA+dTQov0Cg+zKPHbmwe44KTTWua7+b7RD3x3z?= =?us-ascii?Q?+MtFDSblaevAylAMhiGn9ozY2PnCFMGIQUZ+1K31fZGoO0H92Lw0O8ejNZ8m?= =?us-ascii?Q?jIy3OfPnuo73ZI+lOw2OPXafbTzj3fjpUSIo37gQiR0UvBZfg+n/euvd60bN?= =?us-ascii?Q?r0BNvJFwSO+du8e7MNdkat3nVLqbRJ96PV8VVwVkhvjuEhIFd1UhsQHwvz9m?= =?us-ascii?Q?7MsXLbgfPdEnpm/DWOQPKMKTvSqsXvgq6ffAI5ZE9mjEPKxaC/bSAp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; VI1PR0502MB3664; 6:yAZrYnNmcV6+z1xydAVAF4G5YGjp9KiDG+Yb2n7tqEcJfSD3dLUJ24Zj62+2zbbHszsMQleRtWTuEt9eGkihfHJJYYCDD/tbaYa6g/4NDzv43X/k7/QSQ8zaOyCFiqWyp6cXLYC53ELujJIjM+iAZSt0JIAcylkZs2L+aqoSrKf5Iw9l2M2CzgK0ju3Jf2s+Ozn/o7Jo5XZiC7WTzXDNNs8vYjGqgbFtquMMdsiosgcsdpjPNPSMbU0ig3Q1RG2kaXBT5S8Pd39M5ZSXnJ5onpqmHNHFztW98NjBvt6i3DkFqL0uR7y3V++hlQ9Pt2ATnhpsjNTw0woLjkGQzKGfpsGStNX3yu+YQue0w54iI40=; 5:7Bhg+HG1DsAp1u5zxme312hRrpv7Tg2y1+8kjZ//WBFYlLeuoiC50RPNZyIZSVR8HNRqBBWN8MPVwJ+r691ZyE/JxgepOTrVb5odc7M1eJoa5noOOPm5c5Uv+4dn4L9Rwc76is8OvjEpFZGszD0BJG9FSH2LgL3wbLA7Gh5RAm8=; 24:krzLl3hb2h7a3VbYZO5SfGKHe4dbGZBYlErNXqcd0lXfyQLN2ievnivUHdO6OHzLtutaK3GAymheN3ulJ0nnWkLasYnB8r1fk02yGQtcVFU=; 7:KIG1/Ps9nqRRNuh/KP8PnFptBZs9xKAPou9vnL7QMEjl3/oerDiYMKPuLV19WRqQ1E/BOf+jE8oE15EqdEEgVXlNWPvhLgIdRQuVRV67sLhz4AidavVlJhkjhNsgzmevIa0KL0Tps3yBr8jMxksUJyNgSbvZ1HQQJPbYYSNI913u6G+UFHV2JfJu+wg/sThlvMGXuO7fafdHG1ZpY47l2ceQB04MkWJAtJ6deUxV8dhSaM+7WXnsNi4/jT01DGbZ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2017 15:42:44.7802 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7aba00b2-c50b-46c2-382a-08d522085cd9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3664 Subject: [dpdk-dev] [PATCH 3/3] net/mlx5: adjust removal error 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: Thu, 02 Nov 2017 15:42:47 -0000 Fail-safe PMD expects to get -ENODEV error value if sub PMD control command fails because of device removal. Make control callbacks return with -ENODEV when the device has disappeared. Signed-off-by: Matan Azrad --- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_ethdev.c | 39 +++++++++++++++++++++++++++++++++++---- drivers/net/mlx5/mlx5_flow.c | 2 ++ drivers/net/mlx5/mlx5_rss.c | 4 ++++ drivers/net/mlx5/mlx5_rxq.c | 12 ++++++++++-- drivers/net/mlx5/mlx5_stats.c | 6 +++++- drivers/net/mlx5/mlx5_txq.c | 2 ++ 7 files changed, 59 insertions(+), 7 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index e6a69b8..0dd104a 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -208,6 +208,7 @@ int mlx5_ibv_device_to_pci_addr(const struct ibv_device *, int mlx5_set_link_up(struct rte_eth_dev *dev); void priv_dev_select_tx_function(struct priv *priv, struct rte_eth_dev *dev); void priv_dev_select_rx_function(struct priv *priv, struct rte_eth_dev *dev); +int mlx5_removed(const struct priv *priv); /* mlx5_mac.c */ diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index c31ea4b..bf61cd6 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -394,6 +394,8 @@ struct priv * ret = priv_sysfs_write(priv, name, value_str, (sizeof(value_str) - 1)); if (ret == -1) { + if (mlx5_removed(priv)) + errno = ENODEV; DEBUG("cannot write %s `%s' (%lu) to sysfs: %s", name, value_str, value, strerror(errno)); return -1; @@ -925,13 +927,17 @@ struct priv * { struct utsname utsname; int ver[3]; + int ret; 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); + ret = mlx5_link_update_unlocked_gs(dev, wait_to_complete); + if (ret && mlx5_removed(mlx5_get_priv(dev))) + return -ENODEV; + return ret; } /** @@ -978,6 +984,8 @@ struct priv * strerror(ret)); priv_unlock(priv); assert(ret >= 0); + if (mlx5_removed(priv)) + return -ENODEV; return -ret; } @@ -1029,6 +1037,8 @@ struct priv * out: priv_unlock(priv); assert(ret >= 0); + if (mlx5_removed(priv)) + return -ENODEV; return -ret; } @@ -1083,6 +1093,8 @@ struct priv * out: priv_unlock(priv); assert(ret >= 0); + if (mlx5_removed(priv)) + return -ENODEV; return -ret; } @@ -1364,13 +1376,13 @@ struct priv * if (up) { err = priv_set_flags(priv, ~IFF_UP, IFF_UP); if (err) - return err; + return errno == ENODEV ? -ENODEV : err; priv_dev_select_tx_function(priv, dev); priv_dev_select_rx_function(priv, dev); } else { err = priv_set_flags(priv, ~IFF_UP, ~IFF_UP); if (err) - return err; + return errno == ENODEV ? -ENODEV : err; dev->rx_pkt_burst = removed_rx_burst; dev->tx_pkt_burst = removed_tx_burst; } @@ -1474,3 +1486,22 @@ struct priv * dev->rx_pkt_burst = mlx5_rx_burst; } } + +/** + * Check if mlx5 device was removed. + * + * @param priv + * Pointer to private structure. + * + * @return + * -ENODEV when device is removed and rte_errno is set, otherwise 0. + */ +int +mlx5_removed(const struct priv *priv) +{ + struct ibv_device_attr device_attr; + + if (ibv_query_device(priv->ctx, &device_attr) == EIO) + return -(rte_errno = ENODEV); + return 0; +} diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 5f49bf5..448c0a3 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -3068,6 +3068,8 @@ struct rte_flow * priv_lock(priv); ret = priv_fdir_ctrl_func(priv, filter_op, arg); priv_unlock(priv); + if (ret && mlx5_removed(priv)) + ret = ENODEV; break; default: ERROR("%p: filter type (%d) not supported", diff --git a/drivers/net/mlx5/mlx5_rss.c b/drivers/net/mlx5/mlx5_rss.c index f3de46d..1ad9269 100644 --- a/drivers/net/mlx5/mlx5_rss.c +++ b/drivers/net/mlx5/mlx5_rss.c @@ -250,6 +250,8 @@ priv_lock(priv); ret = priv_dev_rss_reta_query(priv, reta_conf, reta_size); priv_unlock(priv); + if (ret && mlx5_removed(priv)) + return -ENODEV; return -ret; } @@ -282,5 +284,7 @@ mlx5_dev_stop(dev); mlx5_dev_start(dev); } + if (ret && mlx5_removed(priv)) + return -ENODEV; return -ret; } diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index a1f382b..c9a549d 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -278,6 +278,8 @@ (*priv->rxqs)[idx] = &rxq_ctrl->rxq; out: priv_unlock(priv); + if (mlx5_removed(priv)) + return -ENODEV; return -ret; } @@ -485,8 +487,11 @@ } exit: priv_unlock(priv); - if (ret) + if (ret) { WARN("unable to arm interrupt on rx queue %d", rx_queue_id); + if (mlx5_removed(priv)) + return -ENODEV; + } return -ret; } @@ -537,9 +542,12 @@ if (rxq_ibv) mlx5_priv_rxq_ibv_release(priv, rxq_ibv); priv_unlock(priv); - if (ret) + if (ret) { WARN("unable to disable interrupt on rx queue %d", rx_queue_id); + if (mlx5_removed(priv)) + return -ENODEV; + } return -ret; } diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c index 5e225d3..33b2a60 100644 --- a/drivers/net/mlx5/mlx5_stats.c +++ b/drivers/net/mlx5/mlx5_stats.c @@ -438,13 +438,17 @@ struct mlx5_counter_ctrl { stats_n = priv_ethtool_get_stats_n(priv); if (stats_n < 0) { priv_unlock(priv); - return -1; + ret = -1; + goto error; } if (xstats_ctrl->stats_n != stats_n) priv_xstats_init(priv); ret = priv_xstats_get(priv, stats); priv_unlock(priv); } +error: + if (ret < 0 && mlx5_removed(priv)) + return -ENODEV; return ret; } diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index fbb2630..a0101cb 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -186,6 +186,8 @@ (*priv->txqs)[idx] = &txq_ctrl->txq; out: priv_unlock(priv); + if (mlx5_removed(priv)) + return -ENODEV; return -ret; } -- 1.8.3.1