From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3D6E3A034F for ; Wed, 10 Nov 2021 07:57:37 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 367B840142; Wed, 10 Nov 2021 07:57:37 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062.outbound.protection.outlook.com [40.107.244.62]) by mails.dpdk.org (Postfix) with ESMTP id 4C19240142 for ; Wed, 10 Nov 2021 07:57:36 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LFRDIophycmodkajkhPERzzQkl4R2LNW2frigw1EJCmk6G9gipWI9fJKa7bSepgJLpiqpotWAVMUR3DCXE0nOw5tydoiCTrSH7xZAlWEcvwrXZtlK3eMLkrM4T3rUJ8BxewG6MF/dZpG5y9xHjeg+GNZ0Mkd/vSp6VWbF0Xlu5fP756kmnGwQltRMZN3QFt7xUdVjw3AM5tHS6mxzI7+DIXtJ/rNLY3pPWnOkvyhRM4KZv5V4rTzOHlYNAICXGxJPnDQBeQkVu5QpmO+TRYG2pLUra4UYEVT5GghPkUh2Nto7z09dQc8tGjnJ6a/R/cIRQsu7gnPCwTSaN8QlT6mPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a5UGPZR1gk2J18KT9BWHpkMwdWKVRjblYPxURs5zZ28=; b=Dst9CDGUo3iKLTYd3HnjtGPx26nyZg9ERiF2tPRUrUkT++qfoxmWpUVXvKLdZ+RoLCUhxVaGn+gT+JRP/VnauQhJzMULh+JH/kVAqo3/Yn3q5YaSxJWG3ii2du2FZPg+eCZCPrFA8vc3voW9mMaGLTTKEQrjjrNHf9TE2FMJ21SEdvfpGMX9pzW12+Eyjqh6cCrtUTZhOfhiU9DrLIkv+Ve0c7n6B9oCG4QcIHNhBRRE/LOG2Xr7pUdw7Pit25XakuA2RtldNg0C3lCGm7Kc2Xypnlgxkyd56LRmGkkuxw+qH+gH++YavA33i49anZ+l7c7S0BN/ROHmcdehpA9fLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=huawei.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a5UGPZR1gk2J18KT9BWHpkMwdWKVRjblYPxURs5zZ28=; b=QWAFIzg5RwzpQk3a/L9tbSeDdRZ0w54lkxc5ufVsbXgqchN+/JNmH7q7A1Ddj7Ah0szAHKXeGY+hqPuVqrybHN9+s0ivw81sz/FFCLURXgpFVxnHMx36bIxdJA3tAlN12eJ6oE1lypsZ69nOJ4rx97vi10dqhOWTYlsD/5GO+6jkCwh8Q+M7DF3kgT7xB1TLpkfY74z+hXIJJBytSx5KnVlOXUwNskiVbbl82fO/qC05Czq7Hk08fl3rlGA/Ba0Qf4P0SqSNsGnsVy0D3npygPsJ44rpXdraRXFrIDU+4uBSgxa+uijuJcLOdl0iUu05ifC8Pp0DraDoCuvr3S2sfg== Received: from DM5PR07CA0118.namprd07.prod.outlook.com (2603:10b6:4:ae::47) by MWHPR12MB1678.namprd12.prod.outlook.com (2603:10b6:301:b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Wed, 10 Nov 2021 06:57:33 +0000 Received: from DM6NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ae:cafe::d0) by DM5PR07CA0118.outlook.office365.com (2603:10b6:4:ae::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Wed, 10 Nov 2021 06:57:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT051.mail.protection.outlook.com (10.13.172.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Wed, 10 Nov 2021 06:57:33 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 10 Nov 2021 06:57:28 +0000 From: Xueming Li To: Huisong Li CC: Luca Boccassi , Min Hu , dpdk stable Date: Wed, 10 Nov 2021 14:31:49 +0800 Message-ID: <20211110063216.2744012-226-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211110063216.2744012-1-xuemingl@nvidia.com> References: <20211110063216.2744012-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e6816516-e2fa-44aa-5ce0-08d9a4175ee5 X-MS-TrafficTypeDiagnostic: MWHPR12MB1678: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZEKnRW0b7Ye9bBVtA0WESaqCOEdgyXmWx73jWRKFQnefeR7dfMiHNBRhprrmgDuCCmxikC7XpfKv+h/3YcGhCr2TJ0pAAb0Y/vZ9K3QSgglqg4v11gk6IpeUS845IGlVn10VlTWzO8kQ4v0REYW78Y6ERC5agrq1ERrC/V/5I67HZbuiNJBhDG9sNj96wTweuyYLgeZA1fqX7zDwsHleb88flrl61KjZha3yWpbrBjpUsqL+t/Tm+dljSIQj237+psWjUJ9hr9oslxsvydlWywIbSZIqAWAJvoDCt2JSEPYI/qzYyOiH1eG8TZd4LV9wbxp6nz60cI3+r6/DBRrcnpqrnDsAvUCRdS2rDxxnsQn9bkg67C0/W0OHr712Kq3DLatV/3UXPbAbQBPPmyAxWXw48ghQkdvDVKkdMN/D7NaO86h8YdVU99THMMJxX6N8bfZaV6F1560osqMFhYFk2y/QVD/xJWM1icgoVpbKtNurURfd6VqP/7/k+sQN8Tz/Xk3thH6QQ8mIVGpbbkOlBYXOlzQmQjzAov2o/2lu4g4+UojnzjIx7LppNpMKyPbcsB1Q95a/N3p1QDIMgS8Tud189U5If/Lg6EAZ5kpICfOhXDsP5P17XoypAC+f6G8VmRW2Z6/NGTQdtqFSdzXUsMCrHON/lFHWZyV7Z2oRNkNFa1V1xrgtDQkOIBR/UwH6P9liuJ+YVmJLMbXStWgHlVG4GHM3tWO4DX5zWQcYkhpzt00J33FyGpPR8CfS2kZz+I0Pt19LgGik2dDtFdm9/ptmH9stT/yoKM96PWr78xyMvrCO72A1ZiY6lHlZnbaL9I1XIMO8xyGif/9Nnkhmow== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(53546011)(6286002)(2906002)(7636003)(5660300002)(336012)(7696005)(8936002)(36860700001)(2616005)(316002)(4001150100001)(8676002)(508600001)(16526019)(4326008)(54906003)(966005)(47076005)(6916009)(1076003)(70206006)(70586007)(36756003)(426003)(356005)(26005)(83380400001)(186003)(55016002)(82310400003)(6666004)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 06:57:33.1129 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6816516-e2fa-44aa-5ce0-08d9a4175ee5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1678 Subject: [dpdk-stable] patch 'net/hns3: fix multi-process action register and unregister' has been queued to stable release 20.11.4 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/12/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/0209698523dc297d278394e2945f797ad1195f8b Thanks. Xueming Li --- >From 0209698523dc297d278394e2945f797ad1195f8b Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Tue, 2 Nov 2021 09:38:27 +0800 Subject: [PATCH] net/hns3: fix multi-process action register and unregister Cc: Xueming Li [ upstream commit 841f8693536f9410fd51d385e1090d35cfe59914 ] The multi-process has the following problems: 1) After a port in primary process is closed, the mp action of the process is unregistered. Which will cause that other device in the primary process cannot respond to requests from secondary processes. 2) Because variable "hns3_inited" is set to true without returning an initial value, the mp action cannot be registered again after it is unregistered. 3) The mp action of primary and secondary process need to be registered only once regardless of port numbers in the process. That's what variable "hns3_inited" does. But the variable is difficult to understand. This patch adds a hns3_process_local_data structure to resolve above problems. Fixes: 9570b1fdbdad ("net/hns3: check multi-process action register result") Fixes: 23d4b61fee5d ("net/hns3: support multiple process") Signed-off-by: Huisong Li Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.c | 2 ++ drivers/net/hns3/hns3_ethdev_vf.c | 2 ++ drivers/net/hns3/hns3_mp.c | 37 ++++++++++++++++++------------- drivers/net/hns3/hns3_mp.h | 7 ++++++ 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 8049573444..46dfbe5d69 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -6290,6 +6290,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) goto err_mp_init_secondary; } __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); + process_data.eth_dev_cnt++; return 0; } @@ -6302,6 +6303,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) ret); goto err_mp_init_primary; } + process_data.eth_dev_cnt++; hw->adapter_state = HNS3_NIC_UNINITIALIZED; hns->is_vf = false; diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 0f8ffe0c32..87859c45a4 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -2767,6 +2767,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) goto err_mp_init_secondary; } __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); + process_data.eth_dev_cnt++; return 0; } @@ -2779,6 +2780,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) ret); goto err_mp_init_primary; } + process_data.eth_dev_cnt++; hw->adapter_state = HNS3_NIC_UNINITIALIZED; hns->is_vf = true; diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c index 32046b7612..6461ded2d2 100644 --- a/drivers/net/hns3/hns3_mp.c +++ b/drivers/net/hns3/hns3_mp.c @@ -12,7 +12,8 @@ #include "hns3_rxtx.h" #include "hns3_mp.h" -static bool hns3_inited; +/* local data for primary or secondary process. */ +struct hns3_process_local_data process_data; /* * Initialize IPC message. @@ -198,14 +199,15 @@ int hns3_mp_init_primary(void) { int ret; - if (!hns3_inited) { - /* primary is allowed to not support IPC */ - ret = rte_mp_action_register(HNS3_MP_NAME, mp_primary_handle); - if (ret && rte_errno != ENOTSUP) - return ret; + if (process_data.init_done) + return 0; - hns3_inited = true; - } + /* primary is allowed to not support IPC */ + ret = rte_mp_action_register(HNS3_MP_NAME, mp_primary_handle); + if (ret && rte_errno != ENOTSUP) + return ret; + + process_data.init_done = true; return 0; } @@ -215,8 +217,12 @@ int hns3_mp_init_primary(void) */ void hns3_mp_uninit_primary(void) { - if (hns3_inited) + process_data.eth_dev_cnt--; + + if (process_data.eth_dev_cnt == 0) { rte_mp_action_unregister(HNS3_MP_NAME); + process_data.init_done = false; + } } /* @@ -226,13 +232,14 @@ int hns3_mp_init_secondary(void) { int ret; - if (!hns3_inited) { - ret = rte_mp_action_register(HNS3_MP_NAME, mp_secondary_handle); - if (ret) - return ret; + if (process_data.init_done) + return 0; - hns3_inited = true; - } + ret = rte_mp_action_register(HNS3_MP_NAME, mp_secondary_handle); + if (ret) + return ret; + + process_data.init_done = true; return 0; } diff --git a/drivers/net/hns3/hns3_mp.h b/drivers/net/hns3/hns3_mp.h index 1a73598dc4..758ffa70ac 100644 --- a/drivers/net/hns3/hns3_mp.h +++ b/drivers/net/hns3/hns3_mp.h @@ -5,6 +5,13 @@ #ifndef _HNS3_MP_H_ #define _HNS3_MP_H_ +/* Local data for primary or secondary process. */ +struct hns3_process_local_data { + bool init_done; /* Process action register completed flag. */ + int eth_dev_cnt; /* Ethdev count under the current process. */ +}; +extern struct hns3_process_local_data process_data; + void hns3_mp_req_start_rxtx(struct rte_eth_dev *dev); void hns3_mp_req_stop_rxtx(struct rte_eth_dev *dev); int hns3_mp_init_primary(void); -- 2.33.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-11-10 14:17:11.828273101 +0800 +++ 0225-net-hns3-fix-multi-process-action-register-and-unreg.patch 2021-11-10 14:17:02.047411312 +0800 @@ -1 +1 @@ -From 841f8693536f9410fd51d385e1090d35cfe59914 Mon Sep 17 00:00:00 2001 +From 0209698523dc297d278394e2945f797ad1195f8b Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 841f8693536f9410fd51d385e1090d35cfe59914 ] @@ -34 +37 @@ -index dafaf31f65..874854da61 100644 +index 8049573444..46dfbe5d69 100644 @@ -37 +40 @@ -@@ -7380,6 +7380,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) +@@ -6290,6 +6290,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) @@ -42 +44,0 @@ - hns3_tx_push_init(eth_dev); @@ -45 +47,2 @@ -@@ -7391,6 +7392,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) + +@@ -6302,6 +6303,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) @@ -54 +57 @@ -index 41d61a8160..91acd1f5dd 100644 +index 0f8ffe0c32..87859c45a4 100644 @@ -57 +60 @@ -@@ -2688,6 +2688,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) +@@ -2767,6 +2767,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) @@ -62 +64,0 @@ - hns3_tx_push_init(eth_dev); @@ -65 +67,2 @@ -@@ -2699,6 +2700,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) + +@@ -2779,6 +2780,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) @@ -74 +77 @@ -index c28598a53a..1a79d249b8 100644 +index 32046b7612..6461ded2d2 100644 @@ -87 +90 @@ -@@ -230,14 +231,15 @@ int hns3_mp_init_primary(void) +@@ -198,14 +199,15 @@ int hns3_mp_init_primary(void) @@ -110 +113 @@ -@@ -247,8 +249,12 @@ int hns3_mp_init_primary(void) +@@ -215,8 +217,12 @@ int hns3_mp_init_primary(void) @@ -124 +127 @@ -@@ -258,13 +264,14 @@ int hns3_mp_init_secondary(void) +@@ -226,13 +232,14 @@ int hns3_mp_init_secondary(void) @@ -146 +149 @@ -index e0e4aeaf6c..b49532f985 100644 +index 1a73598dc4..758ffa70ac 100644 @@ -162 +165 @@ - void hns3_mp_req_start_tx(struct rte_eth_dev *dev); + int hns3_mp_init_primary(void);