From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80050.outbound.protection.outlook.com [40.107.8.50]) by dpdk.org (Postfix) with ESMTP id 17CC82C38 for ; Thu, 23 Aug 2018 08:39:36 +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:X-MS-Exchange-SenderADCheck; bh=UQWa0A4cV4Nv2rRWtqXXv1XyvfIzQK1WF6Uq/na2z8E=; b=hy+P9gxK+vBnB2UMHTKERwH/O6Kjalkbd+LlsX3MJVZD/7sWypjbchWjlh4Hqvkh14DevE/YRD8FSN4M//PCJQ75Zkq/J7KYuwReO8ol1gMoKFM/3KSoS18BB60qgx89yMwEk397BM6VoDyXWjBxM1WDCQzCu5jqr1hfSx5MiJ4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jackmin@mellanox.com; Received: from dev-r630-08.mtbc.labs.mlnx (118.201.220.138) by HE1PR0501MB2026.eurprd05.prod.outlook.com (2603:10a6:3:35::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.14; Thu, 23 Aug 2018 06:39:31 +0000 From: Xiaoyu Min To: Shahaf Shuler , Yongseok Koh Cc: dev@dpdk.org, xuemingl@mellanox.com Date: Thu, 23 Aug 2018 14:38:51 +0800 Message-Id: <20180823063851.32559-1-jackmin@mellanox.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [118.201.220.138] X-ClientProxiedBy: HK2PR02CA0182.apcprd02.prod.outlook.com (2603:1096:201:21::18) To HE1PR0501MB2026.eurprd05.prod.outlook.com (2603:10a6:3:35::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac397cbd-177a-45d6-e00a-08d608c33020 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:HE1PR0501MB2026; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2026; 3:u68+MdLM3RXg+HIxm/CCi/YS9MVzizoobv9isFKATmRf/V1T+ZcfjPELyFX4ad+PAfiYUuO/Q8uM4V4nYyGVTKtVnauNWIj7XvATJNHPNoaV7TUAooy2pUVgfYeUnxb0i/VFcrbcCkwgT13TZ/NCIMEYBd173bqXb6UrwiZvLgihbZylALSNfV7D7L1EU4+homMf7Clg/IleSpNDvU2LET0aqAFdMkZIBWbjk57bq+bEpGapwp+2Z+2Xz2cBNY4W; 25:84H2pj4WQkut+PIOaLByNUvy7w9+kMn8dD2wDnXLDWrmB/bKLK8SBh67SPyHaMfO2D1JfUTEmDZLrLrI4wlouqFaFC12DCN2f6s/0+3rjZCfb0kbww9itU+IGrP6brRpnJHeFi40fC2h/bt0y70GBbWPTiMy5EEKCAL+zRKhnFoC146cXuL8LXd1m5yAGy71AKkelNaKNfr+/HV8BqgocnFQOFDMTNrDtjP0M1r2V//QX+2jbpVyDJGl0jXAPTSdYwsbiU882B2wiOEJhFmos7uqRLTu6M1zBW7JfnqxLdFpT9vygr+E1Jk5yc33rXYEHfNsMueYbzW+9GVISoAlAA==; 31:/ODIWZTr/qc2PgQL9SY9CFZFc6/BvnbWzzxfPIOie7CFt2lZikocL2CYf4BQiZTB5w7zT7XrI9xms3I6IA6wf8WMVjrzU2CrnXH4jx+ZF7q6VHHzeGjA7pS2r0AvnXVhyhurmukOXaEs0Vbhk4OdQOibxXXTQZxOD3Vz/MxlKG1PaCVYTF3Zh0u0INrWzX04s7KQ9MwxAGI1WS8NdrbRtQZim9I3Me35MajqgIGPFjU= X-MS-TrafficTypeDiagnostic: HE1PR0501MB2026: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2026; 20:N25BYv+RKnUM78dJ5sAM6gsX9CG+TcAKPLkAuGOK8C6UVjRr92xKQynicuJTQXl3Z4JhDqf2/8uK0zp7ENUExAyFDRxeb+HQnq5BZ6TXe99pdwSF0/fZPfnpuERAKjYZ1JQGire1rHyUiomwgHK+lPd381xrkvPF8BpoELHU8Q9c/rICyspVcb/1iQCGz/CdwIEy5gNrGvK/ItfwqRRJpkm2QZ56uW3qRhq58T279+gjdWgvoju36056ian3u4l3NOi3n52DYDMiS+dxgo87h70aiecUUdPYOjEZYJ0kP8gCgWrWsuYMItf74eW1n3eT5Bt8jWTqa09drvP+ZefmCYc/oc2TjdQ/iyiAzZXBTp0axmRYDqmARqTmatSwqWmG8ZgYe9uVgUpn809iiyHT+gtgur2qQ0FsuYAmisWkqCWTWVW/1GPTADFU5J4i3oBdF1xPPSr1IwKJESFlyiNMxgNIxf0qiWTE88LhH3yJ9Qc0LqONW9lBUmanPVKIoVXo; 4:p/zAR2nU0BlK5F+IDhp72ai5sfZ/1pnnR3J/M/p/9wCUXAD0cWK9WHfBhpzBjLmAxe1qlZVZuPppMH+JFSNaiUQ8OGPE5d3euayCOfRqgShRLRMEnmvSMv8ftD7lP2B7Jpjh+YvZeC1QBp8n6KnDBCug3jy/dHQXMeG1u/aMgMSPFZ1ht8flSVPkOgeebvKP4q8W9KPTn0GPrOivEdN4CDgQ4aO8tneRPn8cRxHphc5bDPW/JCNFCfbwB8ACrG4/jxlnK5bQw/X6i6bx73t+fQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699016); SRVR:HE1PR0501MB2026; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2026; X-Forefront-PRVS: 0773BB46AC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(346002)(366004)(136003)(39860400002)(376002)(199004)(189003)(8676002)(51416003)(478600001)(68736007)(47776003)(52116002)(2906002)(105586002)(66066001)(81156014)(106356001)(107886003)(81166006)(36756003)(85306007)(7736002)(305945005)(97736004)(956004)(486006)(476003)(2616005)(16586007)(316002)(48376002)(3846002)(50226002)(25786009)(8936002)(6116002)(6512007)(5660300001)(50466002)(6486002)(26005)(6666003)(386003)(110136005)(16526019)(1076002)(86362001)(6636002)(53936002)(4326008)(6506007)(1857600001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2026; H:dev-r630-08.mtbc.labs.mlnx; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0501MB2026; 23:Kp9FYSkWTFW5APpOfO0z7JuZhbXisQdXMf2/Z44?= =?us-ascii?Q?n0MiAUP5h0kYBmOIkXNAJ0mOuOcaXQIQ75RiQqBKAnvtJGsHYWpKB3WgfoRV?= =?us-ascii?Q?HkGVoeo9DkxKaSpNFMr6zR12X+GJ1v81O3OMBCY1Wk6aIbuvropQlLWe/5OQ?= =?us-ascii?Q?NZuoh2yc019iZSL2O4I5gCOpSaRvQxAj8+P6q3/IbI0FH/k7vULkx/HFz9Gh?= =?us-ascii?Q?vRe7Cofnlgn44/2+MV81i5xL18BKpRsSc3kqTBMhJVBPZdnFzgOMl+YI/xLK?= =?us-ascii?Q?QQgLBSagtfv0A3r1kEFCDgDSm6RVCA6cDyp9KmByiROkORh1xF4NDtAQVF9u?= =?us-ascii?Q?ihHgpSEhPwKJ44l+fqSkJH4DwyZtsozy2SltmOTtQrLQQltJSg8A2QznUBO1?= =?us-ascii?Q?mx4fE8h6mKj48jqnqFoGBfZtgtSIcVhtY1BPf4dsUhPLuj7lywx84edmTGwd?= =?us-ascii?Q?OA+b7/VWG7N2KtIqgB7a96gXNS8Psjrk92nOlLIdc4azElIv8FFDgm/W34Gn?= =?us-ascii?Q?bHqtF62uddu1UcPN2eJOyr3WhjRKEVY+/02WgizefzoDrsq0ymuYjzgyii5q?= =?us-ascii?Q?OdP+FF+YVXZnL60f2AQ2FfFxgb1YdgqP6+E03SUb9Q0ONJPncbuYncBpXMXI?= =?us-ascii?Q?KcXp76YeobOnUvtskgriOgvYStU3UMoQjDk5O+BNaodcZsro/Waa71VfqWz5?= =?us-ascii?Q?BSA3ejDOpFpZ1iSVV5qcfMUaXRdE1bA56S6ZPPYyHF5yCLT6AadhO8JRc9gG?= =?us-ascii?Q?K+CerKfNkYXOQOFDwNfQLtGbIiRE9Kq9/D16oH07iL0llrcBnD8/E7rAxD6X?= =?us-ascii?Q?jezAxFScGDWHAsc2ODaqerj0pV0wAck4MJOB7Nmy4YSeTVvaPkjVGxk19/Ck?= =?us-ascii?Q?cEy3qpwRwgz7gQAyw7nx8jnL9glGk/EiMjs0HsL33AMeduMFaYAqf7uoRE13?= =?us-ascii?Q?Xf9LvKkUC+GlYxiqHJTsN5KW0Ke4KmUjxu2kl25xF0OvhgZjJbgwmqDeVjK8?= =?us-ascii?Q?CqNB9CYmhyhfugWiUkEQC76howFEWLVTRYhwv7W1w8j3QBl2raag5ZFon7Gp?= =?us-ascii?Q?fz8HxcedOGnaakR04wh0XE7GH/L/XqseGOf0Noei1xQV8tNmqkFHmgtaOICu?= =?us-ascii?Q?TFYSdgyONjaqi28FSGATeiKKDaCtSEESp5AYc2aING03sxjvhY84bYaeUf2h?= =?us-ascii?Q?XEIxYM5zv1gljTlwvdhOEldOCGbnmXV7Pbgln?= X-Microsoft-Antispam-Message-Info: GhVT5+10vhnGyvic54gvOZe8sJ0IdQwQUkHfAV1T/FLdqRMYyzz/jyPB2hPfwO1j+sJ5zgffLcplYLv6snJbkOFWykPFmpwVysrJUyGAcny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7f1tbA7KFExn7UV7tqdRthKNzx8XDEm1qrVji7QghmrDlQzlvOyLo4HWY6/JHSSNl1WwTJl8DK6NNDvvCrA1tgGb8Gijhwrd4eHcgc1OnX/BriPJXOQfidzxBH1i3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2018 06:39:31.5839 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac397cbd-177a-45d6-e00a-08d608c33020 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2026 Subject: [dpdk-dev] [PATCH] net/mlx5: handle expected errno properly 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, 23 Aug 2018 06:39:36 -0000 rte_errno is a per thread variable and is widely used as an error indicator, which means a function could affect other functions' results by setting rte_errno carelessly During rxq setup, an EINVAL rte_errno is expected since the queues are not created yet So rte_errno is cleared when it is EINVAL as expected Signed-off-by: Xiaoyu Min --- drivers/net/mlx5/mlx5_rxq.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 1f7bfd4..e7056e8 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -443,6 +443,7 @@ struct mlx5_rxq_data *rxq = (*priv->rxqs)[idx]; struct mlx5_rxq_ctrl *rxq_ctrl = container_of(rxq, struct mlx5_rxq_ctrl, rxq); + int ret = 0; if (!rte_is_power_of_2(desc)) { desc = 1 << log2above(desc); @@ -459,13 +460,21 @@ rte_errno = EOVERFLOW; return -rte_errno; } - if (!mlx5_rxq_releasable(dev, idx)) { + ret = mlx5_rxq_releasable(dev, idx); + if (!ret) { DRV_LOG(ERR, "port %u unable to release queue index %u", dev->data->port_id, idx); rte_errno = EBUSY; return -rte_errno; + } else if (ret == -EINVAL) { + /** + * on the first time, rx queue doesn't exist, + * so just ignore this error and reset rte_errno. + */ + rte_errno = 0; + } else { + mlx5_rxq_release(dev, idx); } - mlx5_rxq_release(dev, idx); rxq_ctrl = mlx5_rxq_new(dev, idx, desc, socket, conf, mp); if (!rxq_ctrl) { DRV_LOG(ERR, "port %u unable to allocate queue index %u", @@ -1543,11 +1552,12 @@ struct mlx5_rxq_ctrl * * @param dev * Pointer to Ethernet device. * @param idx - * TX queue index. + * RX queue index. * * @return - * 1 if the queue can be released, negative errno otherwise and rte_errno is - * set. + * 1 if the queue can be released + * 0 if the queue can not be released + * -EINVAL if the queue doesn't exist */ int mlx5_rxq_releasable(struct rte_eth_dev *dev, uint16_t idx) -- 1.8.3.1