From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0075.outbound.protection.outlook.com [104.47.1.75]) by dpdk.org (Postfix) with ESMTP id A8F651B2EF for ; Sun, 11 Feb 2018 08:40:35 +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=FXuV4Pn8YS+phjFu7ZhMmikoleM54A1R5ZLUJkOAI/I=; b=MtrXJFcCf/TPf0AQ3QAoxLX5Yo1iVFYdHP83Auvu+fQkuHmNwLy/10hmas4jQJS45djZSlOT0zex/H/K28ziwjUFhkUFJm09Q1vKiiQNkRs7Op3FgmF7ImrxfF3fjx4rB/8Wp6Lv9kQV+Pp5A9uiMLSn6KMcpm14sr/zf6eISp0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM4PR0501MB2657.eurprd05.prod.outlook.com (2603:10a6:200:59::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.10; Sun, 11 Feb 2018 07:40:34 +0000 From: Matan Azrad To: Yuanhan Liu Cc: stable@dpdk.org Date: Sun, 11 Feb 2018 07:40:22 +0000 Message-Id: <1518334822-18674-1-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0501CA0009.eurprd05.prod.outlook.com (2603:10a6:800:92::19) To AM4PR0501MB2657.eurprd05.prod.outlook.com (2603:10a6:200:59::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f484f579-4c44-4447-bf7c-08d57122bc7c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020); SRVR:AM4PR0501MB2657; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0501MB2657; 3:u8rsZyjdXjhu2IfjoSt49bxv3f3rlB2PG645QTV1PG3RYnOeNW68d9D8YnnPAsUZhgBY0PzkEwvUNI747q2nEze1MTGzdHVkC1XQK894V1+EZtLZhxh+ZvtH3m7RPxg7ZpelWUylavC2x33PtumcGpCQNkd8qRd0jtJiZaV42qZexYlF6XjQ6PcdlDTICJY8lsPmQMDYvUdFkeI2S+OV8wqwPVI5SHMYxD1cR5MD9GadEskAPy/i4V9ykpCUbGOP; 25:fNp0dCVksjpJcyY6nwFTNMKxaxC8GLm0MZn6oLzPpu19f4pBFsSGfaJFprkPBao6dXMuCdkpTI0H7ADYfdOvxpPUGZWMTDKmwhjQzv0iNKfBCrYmx+XbQcP0UHT4/7P3DsSd3At/PTe7nMd2aS3ZNtuVTa3toivRJruMgK2uA1fzYHVvmMh1MSdT0ik0LmRZG7bGbm3vGWOkAhbNcvoMJKLbTy2G1UR8irlYp3jGjMexvTQG/hQeJ0n/dqi4B77Nn9u23vsZI9PiVqWOoYup0cSflelZ07OjK8/pYOZs2mmWs66GVVop73vLtszBX4/GSdaXxwCK1Glu8BHdJvWUTw==; 31:Udn+t07pkMLPkj5g/3FXSx5CZFMf1i8jcpU93LkfivtTxkW62iV5LYuCQ8ax2TSdsdKyg1GL2r5iC6eKfUkPy8ep8IRbf3geRD8x7yOBah53474Av3Rh1rzhAbUbyR9dQWWOKxQjIz6gbsjUs/AhjjKKbHeKuwqQVmfgPW3InM1sTLpBEpzqH7JyWx1pAHmEXtxOjZb4N4sfWlvXZfGFRteey3umE5T2vEvyt+DGIv0= X-MS-TrafficTypeDiagnostic: AM4PR0501MB2657: X-Microsoft-Exchange-Diagnostics: 1; AM4PR0501MB2657; 20:Kw2ao6gQDOCdW5z+Wlmm4y1xNXl3fx74J3UhPdM113h66PaIy5tffRfZYT077sX464LaRT+SV2GqTpkieXFszYzp28UKGT0huSB6PwgYdN/xFlxwjmo+gARZ6PcDTGmHMT67Sud271O0xcMA1S+LEuCFgm0KgSi8JsAdwc21Ctt0/W/VcXboktjCq1gFxi6gdzO1OxJQea/CtrobSMpvXqmIa23JWZyn80Kc8VAVn0kUTxc6ROw1iLDlKN/lkMHsUVys6Bgg6iNNYJCrEXBNuEP7EpcBx3dBeHWRjz4cFMzsdNpxhEUV+ULMo5k9NT2ogjbGS6ZtlN8y1Q/u+SlWoGv7WZcB9YPeudCoDVnF3OR6bjTTlQLKbcAQWAjV2uUSVRa5ja2r9OX/4Werc9KEwhlTqpxnR0R4gKjdhxNWXNlVw0au5/YZbYKOJG47RIcIoWPUmmFHDiMevJcPD9AW0binSHcuXSGaZFBbM+lTR/hzAC7w1N0+khcjrRsDkOpv; 4:8IrMLLssizJ5KqPaE4zDFdWO5BvtnTEIq90lah0jI6FUHPdS42i1fCGfEeyY2hPxGfCl2JCc6pomV7K6RcTQM1cEjOE+uMDa3/sswvmhApIfsnRCJD/t+/HbI/gnZFa/N+r0MsZWxjUe3k1mM3nJaMsqeW3hxu0I/ryXuGA9w83w7KRtNQJS3vltVWPACrv9nHCLttAut+MAfKRAM/f8yKWqPO6ItCzhjH7pHH5dk02e3lCz4RfBAOsqgWs1Q+NhGOobFe6bTRS7wEJ8qceCVlXxe+W9WczxhxyAlsObR79AFW/n3iYV8Cut/qDXgIKuVLtn5YJXpO5Eb3/ugkUZJQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231101)(2400082)(944501161)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041288)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM4PR0501MB2657; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0501MB2657; X-Forefront-PRVS: 058043A388 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(39380400002)(366004)(396003)(346002)(189003)(199004)(305945005)(55016002)(478600001)(47776003)(316002)(106356001)(1857600001)(6116002)(68736007)(51416003)(66066001)(8936002)(7696005)(6916009)(3846002)(575784001)(52116002)(36756003)(86362001)(7736002)(50226002)(4326008)(8676002)(16586007)(81166006)(26005)(81156014)(69596002)(186003)(16526019)(50466002)(5660300001)(53936002)(21086003)(97736004)(6666003)(386003)(25786009)(33026002)(4720700003)(48376002)(2906002)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0501MB2657; 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; AM4PR0501MB2657; 23:HEkHSO/PUuHMM3kvMx2C0hKDgWDVG6eJkIXsSTU?= =?us-ascii?Q?W7myBvblyAz66akqs9DyOyxcd+BSi69M99g9pYWazZgHcrD6WXMdrMm/dedj?= =?us-ascii?Q?3PN5Y2E2tJZDYW1PavJJX7/PWxedGV8ftz0xcuLfBWYEBYoFAjxnLxBzKZtn?= =?us-ascii?Q?XpcQ1yEdKTUz/I0CIXlD0KfigcyUtLyKKL1iV/FFs48TRfWG1atNFtzlkigA?= =?us-ascii?Q?i9XgPtjF/ZwftIfPbBBUm74BfZ8EM2fvOsQHZfrPG/ffTN/OqIBsoRz3imqD?= =?us-ascii?Q?zgZnDnsEc5Tj3OFC+D55YQpd7Red2s3rJ6eRYe2/Ct5WXxScry4k4fSVReyF?= =?us-ascii?Q?fV4vp0bumo8D2KYlE1LwmNV/O+OrW2zxN0H4o2DMCRWuI3Dnld0jwPqCuKpb?= =?us-ascii?Q?SQXHqJLjq3a66J0Ng2pQjqn4Xfb8AL5POPA7sjebVGZEgieR3VdH15llCobI?= =?us-ascii?Q?zgXgqnGGwrc2wxiKtNCew32PWy+sC346krhB/7Q4cNxECFi7kJJejcl8cCHF?= =?us-ascii?Q?jk6HTnBACr9NlKq8e3hB0o3T08qjcYCWx5jGql6W4o1PZ73/OEyVmOpuA/oF?= =?us-ascii?Q?eJCMo6U0Ih1pjlfu+15r2Rlj/mwkDVC7wUMayXbNA/jOxq+x6PMPyYyuXya8?= =?us-ascii?Q?jgXHaARQpISu2a7Cd2GqDhpW9Q2C2pUmjLkOXXgIwUvoxVMZYeBMg+dNSgub?= =?us-ascii?Q?n47b0fR4dhC4SA3CvCwVZSoXZM4OykOaAmC46yvq40/xL5tF9gXPMfbG0oz5?= =?us-ascii?Q?P9Cb4F0TEsI6SY06DlMy0AV45mL2UzWcXU8/xDIozhw0huabcmYUCGZmGZfS?= =?us-ascii?Q?H6flLjpEigfl4aCA+QqQJEiOuJm1vyxUEsguG4iwnZ/qpdNcjMSiwpAyAzx6?= =?us-ascii?Q?lOhL7/bD5IP7ebz5F5mK1ZhwgnksFlhvbW2GCgb7KITkTvbZb/YypkEawgVX?= =?us-ascii?Q?lh3Smh8yXkODL5shcZYvxKIBMQ5ndpH8nXYlENO5Val6n0BGjuBNPQrZzoWD?= =?us-ascii?Q?NUvzpsB+acWPnbSjKv7umZ7vwVSniXzKopyHYWG3SsRrVBaZJUxRQ57jBtXO?= =?us-ascii?Q?2nme7ZhykeTDllY6WI1lVlMjJclKScgVKXwu6KYajWG7o3sFbrL2zTC12kP7?= =?us-ascii?Q?28UIUG13Vqrh4qAlqMDXJNK+48H5Cz2pglTte/E2iVLUENC39yurSCBs14x9?= =?us-ascii?Q?4pewTuWsJCf8N1e4=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM4PR0501MB2657; 6:0mnTxpdiBYaImiVC2ipgoBvBUoqg8yzy7ASeoPkNEbpfdQ2ylH9oCszpSveyvu9aFBMUe/0BVZ3fxccKVgW308HiC3RKAI/I5WZsGiX0FRT0AsmcdhHOpTDcbZRZ5kcau5iPpVgO+9h0BKlTXPRxO6JpkZ8EwF190qJLLr4wb3NYOCN/2O8r3S2cV+Sb6wLs6sU8StiQ52nOQkyyguE6xfE1LftS5F62aA/FziokqHe1VUdx984ydXFwxgbn99HN/A6FbwSrRFI6efHfLP1VVjavncNPWyQBnJ2gPtFIEFyfOXF14ddnuBL1LkulDFBhDxjXCtrdyoNeTm1DjSzMG33KM8OoopMMIbsrDb5cE2o=; 5:p167+Bn+K1tn5PFNy+THUcuc41QMQbng1hkVX9UaNcqUvgYbLgBdIQhjoD8tDgYXyy1drlEhjcZWZToImSOCn0DDSMiGKZZ1IqKn6sGdZHbTvN5M25YmN/B+2jFndSex1INfK3dfs5wai5SdkWHjvvBzzgv0kZ2VcZyCcYFg1/g=; 24:ryMgKdpu0WM1HXtw8UVfrS+macui2NgpF+DzVXA1Qcz8pi/93C24XPLJZROs4hK0FRqIicv7xzCzXawvIvCjg9S44xK7e9nFrCmCG8U0sbU=; 7:dMRkQySO1z59J/H2oyX/pQpYvHmGyItHbDowyCAQSHZWoYX30EgGvbewh9GK2yqRSw6FQMZyZY+PpDcNAstr2JIBZdaROd6DJJQdThLHDXXaAlaePO3lxBlUv2aXIlylwRKHWQry5VTwW7MAPWudnSDndJFFhUtynR3jS8zmLtTRhavT8tQlmEMUrG8ISzYcOOaYaiBbayIwN7dt95lKKtHKSs8w+Bv3dg0RQ7SSl13U4so95JiCws1oLRuwRBVy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2018 07:40:34.2755 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f484f579-4c44-4447-bf7c-08d57122bc7c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2657 Subject: [dpdk-stable] [PATCH] ethdev: fix port id allocation 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, 11 Feb 2018 07:40:35 -0000 [ backported from upstream commit 8ee892a2385c50427c03db5cef1789babceb5999 ] rte_eth_dev_find_free_port() found a free port by state checking. The state field are in local process memory, so other DPDK processes may get the same port ID because their local states may be different. Replace the state checking by the ethdev port name checking, so, if the name is an empty string the port ID will be detected as unused. Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") Suggested-by: Konstantin Ananyev Signed-off-by: Matan Azrad Acked-by: Thomas Monjalon Acked-by: Konstantin Ananyev --- Backported this commit for LTS release 17.11.1. Please let me know for any issue with this commit, will be happy to help. lib/librte_ether/rte_ethdev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 9dcb0d2..4d23bc1 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -192,8 +192,12 @@ struct rte_eth_dev * unsigned i; for (i = 0; i < RTE_MAX_ETHPORTS; i++) { - if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED) + /* Using shared name field to find a free port. */ + if (rte_eth_dev_data[i].name[0] == '\0') { + RTE_ASSERT(rte_eth_devices[i].state == + RTE_ETH_DEV_UNUSED); return i; + } } return RTE_MAX_ETHPORTS; } @@ -218,15 +222,15 @@ struct rte_eth_dev * uint16_t port_id; struct rte_eth_dev *eth_dev; + if (rte_eth_dev_data == NULL) + rte_eth_dev_data_alloc(); + port_id = rte_eth_dev_find_free_port(); if (port_id == RTE_MAX_ETHPORTS) { RTE_PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n"); return NULL; } - if (rte_eth_dev_data == NULL) - rte_eth_dev_data_alloc(); - if (rte_eth_dev_allocated(name) != NULL) { RTE_PMD_DEBUG_TRACE("Ethernet Device with name %s already allocated!\n", name); -- 1.8.3.1