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 70EF51B613 for ; Thu, 2 Nov 2017 16:42:45 +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=tjjLcrKsa4XBT0ltuQyK2vifbjWjCfLBv/uePsOAqi0=; b=bknzf/d3pxmtKdpI1CBXUMfgcWQaMYL4QNcRzo0qxylWWJF78O1dYViAGGWewlRdUU98S1UCislUmXiedSBELHvOvq16GIpOO9DXuvoStzvQiVm7nj+WfeZbAH/uh2yDN1y60RVlDEuDesRzD7bSS3Xmc5hPo2Ry7O1wN+Sos6o= 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:43 +0000 From: Matan Azrad To: Adrien Mazarguil , Gaetan Rivet Cc: dev@dpdk.org Date: Thu, 2 Nov 2017 15:42:03 +0000 Message-Id: <1509637324-13525-3-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: ecfbe414-f433-47a8-a250-08d522085c21 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:pr7+MmXdRDj/MzIwivJDmcMOURIhxbqxfydPI+5A32ZjhpbpXMxZCleh6nUihN5bAr8YApHK0bmImEDNFZaMfUzSbvHbGigxgvaBCgricmNp3wctAvhc8Mh2CfTisrNDAMsoQR6eEGO4bJwa7JBzyl2smr/rQevwcErrrAiS2MQ4hPpP7roC+Otn+jll3FlHNd36rKCIAAMBf2kbtRLNa1hVfLUNbFcsGnX8rp7Rs8T7aqbUCobjuC4W91BVUKve; 25:SbOr002DcOP25iFq7fimWIjlQR/9sUX29PtKPKVQ3P9GZ2F1xfLH0rCiwlG1T42Ot+N2OoxKCR/o3oUdRStLwkQD8lIUM6e8EWrmw92L4n0Bj5LxBPgDpbhin/1i4qVu0fJ27OkGuLiyF1sCnxqcpeV6MEP8BqCnl/yxWeCEu/OahhHDHbJqGRE9UMRjsTBj/QEWhI17XLVsaSGT6WQPQw5dnDXDSdgZ7G9ovR8Xj0uarBkqNRDNoopgtsERoF8r3L4ko1MPx86rf+8RDstAlifsTho4cW4Nye6Z5Vh1wGUPevm7PK8LyPl4D8yC6pJmcMtUoDQxBUgP8DgvlIJrfA==; 31:XRHDB4J2Aii+oknk2pV7qzhk2O6CXn6hT4zVQVrwPj8hWWC2mYA3toL2S2UnTJSH8WKA3MVvhWUwClPiZb3a7EWfLSuw1d0lmncDFNUkUftsNljyjZyVc9v7gaum3U9tD44W4iuKAUylsW6TUet0R6kSH6t8uTF7SCsSGsYlj3BTR0SPvUx7zDK3e/sgY4A0zZiu90p+eaP+2QmGLdbl6QeATKvkYJrnHWZ252/WgX0= X-MS-TrafficTypeDiagnostic: VI1PR0502MB3664: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3664; 20:a/4xhQdzIUmyi5CwxZlhNyDZ86ZtUqeYU0Pn8FFWrBTCO02UrQhtryfDtc0EvHMKRXZ9IcqNLMHIng7SEM9V600Um4ftehPECLcK5xxGUQJ6/shnT5t25Swccyr2dkWg1THPoabfSS9ZlLhOpk4F0ADevAuvCUu1pk9AJ4mkBOmybVlyj9jwzYxT4JxxBXlAbcVKdkw7m2WHiEfqmL6NpaSpb986iwAk4Xd/zw6h4bOsvuW//lg7Xbv98SPYOjKNlQZP1eYtWCe1PQpbJsXa+z19E0YlKWFBl3Jg0u/JvP6L9KI1RW+MmQsu1SO2L35WK5vlSI1QKhTW77UIwDm5AHQhcgG++tPCR4wPBX3rKj977TSeUYqwq7j0RFudtQ17SuOCH17tH0ji8kGESOhuJLJZIotyXWR63GDnFNwebPMSI/lO83Yrh1pH7dAETbhC7bwhUbYF8+MLAoZ+O3/HAczt521C8jn1iKyiJBmJTftgYeHW/P+swAa3iXGunm+9; 4:pxg8hID6UmDgBFDF0CkDgig90v2SOoiNrzCM1CE+bx230y+wC6ruSfykVZJPfVK5lG4P5nvcDFJfpjkzuw3t9hJ3YHXCc3fKli1nIIr31bE+8heRTgSPF3nV8ycg3+Ds+ojVnwCLxfzIJp90zv4V3aQodI80re86nJjnQl1ckbTkAWBD9Z8WcqkvlL0HXvMNjzjgGiVKrXQ6K6ypZXU1lXgyK1kb/YLDyPZbjy7O3Qc5rKMm8kEDHmZynLFc6OXnODgDLYmdc2NOTvzp5U4p4w== 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:X26u5JWrF0ROmm+d/S6dD+MsKUIt4gO92dDWv3V?= =?us-ascii?Q?f6Czx7yI2u7w4IQLS0JhO9NLm9DFsgiG2hk3jDNKpgP4MzrAvWlDk9kJLeMJ?= =?us-ascii?Q?OPaHlDhDNzFyc/bRFZA18RneaVESK/2E1+3yc/c0QWhcBaQ2tOMjjgxI4pDO?= =?us-ascii?Q?e5N5045lgCJ+Ok51LcG2Fa7Nn7wXyNcAT1jc2Gza2+CdXnjcM3mZV8ioUY9o?= =?us-ascii?Q?4RpZUHwmQ5m7VAwy3FXzdP8yZgvRuCOsEWisBsOskYgoh3uTsnOR74gE7CGv?= =?us-ascii?Q?WVx78NoDQpeicVSbbi5jxv6wkr4OEwzUG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= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3664; 6:4f0HL71RJbWY0dI8flTuDKeb6NtgNGCnf3Q+nqF341GRQeowomUbUGF0UsAsFIkgFKoP9sasWkOg/NFLtBSeRfD9aXX+016utuYbZeqwfY//ppq/XEhPOHBGcFqg+sYZuYbiKTYYytqiYNyyW42IkTxs3VAf21Ju5UmCqfr/z5rewGdDUGwZnYO4L6P27r/xmUQ7/mOT3SsHYIFKXwct6EOyWUwbMM5NvaTDNHwOQF6AJy7yrPDDd+lCsq/ghjr/bF07nopdeIGOKSYDZ3Vna1IQE1cQIJOwZrECShgkXWtUD6EQYNNRBP+JPUg1V47JvRNexouTKOB2Cfn1sdXgAWXUC0Yfzpuaj+kA9+GUrrg=; 5:PGx/TUfn2w4vBkLpia07SOSHoOLfda6jC5JVK4/2qjQKJYMirKgS6B9UVVwbsusw2cHJj4XceZOhDaqysjV/VU/Uf1rz7cJqKpRdQQPrSINaqmJB5sNcjzyEsKAVaMLBCNr1eI/+XRj82Va1oVUr4mlMVxeECIoHvw98hZ29Fg0=; 24:D0FlV5D3ogmiy7JEaVseHbvNLA+Gag8u8DlG4rgO7UOmbgJBuc9w5ltxAcDri6RL4Pl+kHJ9ckHEOXbN8irPKQ+DtEQyf2uTvQcDRXJO/e8=; 7:wY8zCQo7nx0XDBkSFi+t2mYpKLMaKE3E4i3exoByV9qRRu+dJHkdGAEqhVEBknAnCM9thksmeTW0X+XQj9WT+vu1tqiOCHI/eDgALqcHDxVRUetqefhsY0hcKf9Bn9NmNJ+2PooG3DDnXXOLkqabgVj+XXhi7sqAriOXKFrrqDg12SbPdLECPgYQmgUEmF+3vqZJJ4e7sIb6TuTb3Osg+QWK+aH1Hms3Kw1mDBXK/1sJ2LVZbeMQswOj+G+I/Ovx SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2017 15:42:43.5615 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecfbe414-f433-47a8-a250-08d522085c21 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 2/3] net/mlx4: 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:46 -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/mlx4/mlx4.h | 1 + drivers/net/mlx4/mlx4_ethdev.c | 38 ++++++++++++++++++++++++++++++++++---- drivers/net/mlx4/mlx4_flow.c | 2 ++ drivers/net/mlx4/mlx4_intr.c | 5 ++++- drivers/net/mlx4/mlx4_rxq.c | 1 + drivers/net/mlx4/mlx4_txq.c | 1 + 6 files changed, 43 insertions(+), 5 deletions(-) diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index e0a9853..cac9654 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -149,6 +149,7 @@ int mlx4_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf); int mlx4_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf); +int mlx4_removed(const struct priv *priv); /* mlx4_intr.c */ diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index b0acd12..76914b0 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -312,6 +312,8 @@ ret = mlx4_sysfs_write(priv, name, value_str, (sizeof(value_str) - 1)); if (ret < 0) { + if (mlx4_removed(priv)) + ret = -ENODEV; DEBUG("cannot write %s `%s' (%lu) to sysfs: %s", name, value_str, value, strerror(rte_errno)); return ret; @@ -340,15 +342,19 @@ if (sock == -1) { rte_errno = errno; - return -rte_errno; + goto error; } ret = mlx4_get_ifname(priv, &ifr->ifr_name); if (!ret && ioctl(sock, req, ifr) == -1) { rte_errno = errno; - ret = -rte_errno; + close(sock); + goto error; } close(sock); return ret; +error: + mlx4_removed(priv); + return -rte_errno; } /** @@ -473,13 +479,17 @@ if (up) { err = mlx4_set_flags(priv, ~IFF_UP, IFF_UP); if (err) - return err; + goto error; } else { err = mlx4_set_flags(priv, ~IFF_UP, ~IFF_UP); if (err) - return err; + goto error; } return 0; +error: + if (mlx4_removed(priv)) + return -ENODEV; + return err; } /** @@ -947,6 +957,7 @@ enum rxmode_toggle { ifr.ifr_data = (void *)ðpause; if (mlx4_ifreq(priv, SIOCETHTOOL, &ifr)) { + mlx4_removed(priv); ret = rte_errno; WARN("ioctl(SIOCETHTOOL, ETHTOOL_GPAUSEPARAM)" " failed: %s", @@ -1002,6 +1013,7 @@ enum rxmode_toggle { else ethpause.tx_pause = 0; if (mlx4_ifreq(priv, SIOCETHTOOL, &ifr)) { + mlx4_removed(priv); ret = rte_errno; WARN("ioctl(SIOCETHTOOL, ETHTOOL_SPAUSEPARAM)" " failed: %s", @@ -1013,3 +1025,21 @@ enum rxmode_toggle { assert(ret >= 0); return -ret; } +/** + * Check if mlx4 device was removed. + * + * @param priv + * Pointer to private structure. + * + * @return + * -ENODEV when device is removed and rte_errno is set, otherwise 0. + */ +int +mlx4_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/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 8b87b29..606c888 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -1069,6 +1069,8 @@ struct mlx4_drop { err = errno; msg = "flow rule rejected by device"; error: + if (mlx4_removed(priv)) + err = ENODEV; return rte_flow_error_set (error, err, RTE_FLOW_ERROR_TYPE_HANDLE, flow, msg); } diff --git a/drivers/net/mlx4/mlx4_intr.c b/drivers/net/mlx4/mlx4_intr.c index b17d109..0ebdb28 100644 --- a/drivers/net/mlx4/mlx4_intr.c +++ b/drivers/net/mlx4/mlx4_intr.c @@ -359,7 +359,10 @@ ret = EINVAL; } if (ret) { - rte_errno = ret; + if (mlx4_removed(dev->data->dev_private)) + ret = ENODEV; + else + rte_errno = ret; WARN("unable to disable interrupt on rx queue %d", idx); } else { diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index 7fe21b6..43dad26 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -832,6 +832,7 @@ void mlx4_rss_detach(struct mlx4_rss *rss) ret = rte_errno; mlx4_rx_queue_release(rxq); rte_errno = ret; + mlx4_removed(priv); assert(rte_errno > 0); return -rte_errno; } diff --git a/drivers/net/mlx4/mlx4_txq.c b/drivers/net/mlx4/mlx4_txq.c index a9c5bd2..09bdfd8 100644 --- a/drivers/net/mlx4/mlx4_txq.c +++ b/drivers/net/mlx4/mlx4_txq.c @@ -372,6 +372,7 @@ struct txq_mp2mr_mbuf_check_data { ret = rte_errno; mlx4_tx_queue_release(txq); rte_errno = ret; + mlx4_removed(priv); assert(rte_errno > 0); return -rte_errno; } -- 1.8.3.1