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 B1A8F43B86 for ; Tue, 5 Mar 2024 10:56:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ABE744026B; Tue, 5 Mar 2024 10:56:04 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2088.outbound.protection.outlook.com [40.107.93.88]) by mails.dpdk.org (Postfix) with ESMTP id 0A93A4014F for ; Tue, 5 Mar 2024 10:56:03 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FlAlTCsR1+ot6NRgHqiESZfv0SXoj/rh8O3ie4rG6vel7e9eyMnaCk8Ga3mwBZoWUoJW8vwOouqrCzo6CFiT7jt7T32FNM8YTmIBpPlHnDkzUsjXa/vEJup5JA0zuTbwOMD+3ZSWSWNfvO503vr7x1etNVzcpRI/kaDsymKzxu24cQ7g6D+o4owiK3gx1VJtB5Tmut6JsO/S2m/OZKxbpqXnM9mK9N8h7RVRILLBvvv9aB4ZCEDGfnRJJwYYQk0aYE2nIT/9Z+U1vFIswe2PP9QWiw30J274XhOG/AL5wioYoKekcfQUwIv4qEvewZh+j7bIESbgSRJ3QurCDWLd7w== 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=wrhuFb7rsGJnV4jI6MOQJkO2z0wESkCQ7rvKysw2zGQ=; b=h6851TLOCXhNRGMV2lCTIi/b6PoIDIOOZWaJUfQIdXExKi5YqdnvT9b4n8La32yVpODH75f2vC8hCcwTJK7dDIGVG0G3nm6oqGyYXZ8Pyl/90RqhXYs0DgDTbqLU/ZF7VNGuKVhgn+psfbJK6O9xUYFxVPxBy0I+cZwAgGC77kPgPsQSsSsUDFNgXQy+4t2V+0QSIDfMqtkMfatPjhuWhrSU7/XZWUUHiZl3GYecMYHbaK9LYM+j5ZtUXQoCBC0//lgO7ZzbUcnSiDYX9bSrapiEY/l44jeIl9p+IabZjkgISsBiUj5yNwtKSqmD7tv4LYX/r0Wq3Crm+wx1+Iv+Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=huawei.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=wrhuFb7rsGJnV4jI6MOQJkO2z0wESkCQ7rvKysw2zGQ=; b=s/ogEvUP6Rt7jBV9eodm0dS4ZCy6kc8TxoekQNtoTS2r6mH3g67uHvwJ/id1fuXTWZOXnW3PqN/vLWqWGZOyIVjtHQB06jDHXwVN6529LzAL7nVetzgsYTr4eUkx2VjIPJPM1nFu0lt1gOIHi2+D0NXizLKNJL6Gw0salWXMh96mPh+zqWzIXWw8Z48vQAL46+xQFbNYI8Ou3FfVQbQNs3LJZyIs98+weSf1dmHFLmgVvE48LFo/o7Xv7mHABOVE7dniPRG2hlMvduKn1DBeSKMT3Js39fsYLKAzr5prU8Sk//S71RT4kpUZu953Zj5T1xF9WfNZsC3wXAx95dmoQg== Received: from SJ0PR03CA0187.namprd03.prod.outlook.com (2603:10b6:a03:2ef::12) by CH3PR12MB7521.namprd12.prod.outlook.com (2603:10b6:610:143::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Tue, 5 Mar 2024 09:56:00 +0000 Received: from SJ5PEPF000001D6.namprd05.prod.outlook.com (2603:10b6:a03:2ef:cafe::3b) by SJ0PR03CA0187.outlook.office365.com (2603:10b6:a03:2ef::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.34 via Frontend Transport; Tue, 5 Mar 2024 09:55:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ5PEPF000001D6.mail.protection.outlook.com (10.167.242.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Tue, 5 Mar 2024 09:55:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 5 Mar 2024 01:55:48 -0800 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 5 Mar 2024 01:55:46 -0800 From: Xueming Li To: Dengdui Huang CC: Jie Hai , dpdk stable Subject: patch 'net/hns3: refactor handle mailbox function' has been queued to stable release 23.11.1 Date: Tue, 5 Mar 2024 17:47:06 +0800 Message-ID: <20240305094757.439387-86-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240305094757.439387-1-xuemingl@nvidia.com> References: <20240305094757.439387-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D6:EE_|CH3PR12MB7521:EE_ X-MS-Office365-Filtering-Correlation-Id: e1ecb74d-6348-46e1-44c1-08dc3cfa7583 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GMJrgzIX2AG0O3FPYIx79X3UUcbY5Y+FIN3W4oFTgwLq73jrGAYMYLXd+uLlAdVYdWTNp1VsZgRxLanracXUYG2E9MptpduSWm/l5gqR8RmyuJ8Kv9+lju6zQVva0YVm4Q+JSMvPqZ0o3D+7rdDDTUpHeHMaT1MLsclsuReouE1C5GBF2kogbnTf9MTw5ELwzZhiufrBRcBKcBLJhEhzWFK4rWWiNu+AUttRaGEQIi06RJoKKX10f/1cqLY2KUUz6BMaIpsviie6lDDPTsWck/bIgZu7D5SLYEY2wSjW/tHfZEGo3baVlcuiBv8u+5TeMfobTBuKGSWmGgqdh858WZDCXS2grIUofpx4pT92y0py2FPY9Ye9LDjQpwmQ4ZfEkLaFkbGc6SmByx3GC5Dy6wRIc+X3eNWFpl8SOx/Qj/u9QTjV+dEkA7pXY2M99/J1INpzZPKC1eJvXWMcQsWXBKpxKgVTTQKLEczDtnvmIJypybr/zuB2BBnhToVDVhhOOzGWdiiTDOTp48fbk+QHBphn1CSDag1XEy6HFmTsnofEmXwyogP9QugC0Uy/S4L1Mq7pzEKmIbIbnWp8BJ0RkfIKlY+AirAyCSFPPDMEO2kiGvWEugSFYlVij1fVpBU1EoJs47dPkL6g+rm7rtpWmuEG6bmMX833zbebbKHZc2Dl2kd0oaMuK+RjoIZXtGd0TJ874yZUL4Vb11iZXk7DAH2KCWsbHxB+bKRFIAUKTSwPXQP7cBN6TPryhjHpFUqT X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(376005)(36860700004)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 09:55:59.0639 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1ecb74d-6348-46e1-44c1-08dc3cfa7583 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7521 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 Hi, FYI, your patch has been queued to stable release 23.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/31/24. 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://git.dpdk.org/dpdk-stable/log/?h=23.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=8abf8591dcc17e9a0a7cd11da0597d90fe095b46 Thanks. Xueming Li --- >From 8abf8591dcc17e9a0a7cd11da0597d90fe095b46 Mon Sep 17 00:00:00 2001 From: Dengdui Huang Date: Fri, 8 Dec 2023 14:55:08 +0800 Subject: [PATCH] net/hns3: refactor handle mailbox function Cc: Xueming Li [ upstream commit 277d522ae39f6c9daa38c5ad5d3b94f632f9cf49 ] The mailbox messages of the PF and VF are processed in the same function. The PF and VF call the same function to process the messages. This code is excessive coupling and isn't good for maintenance. Therefore, this patch separates the interfaces that handle PF mailbox message and handle VF mailbox message. Fixes: 463e748964f5 ("net/hns3: support mailbox") Fixes: 109e4dd1bd7a ("net/hns3: get link state change through mailbox") Signed-off-by: Dengdui Huang Signed-off-by: Jie Hai --- drivers/net/hns3/hns3_ethdev.c | 2 +- drivers/net/hns3/hns3_ethdev_vf.c | 4 +- drivers/net/hns3/hns3_mbx.c | 69 ++++++++++++++++++++++++------- drivers/net/hns3/hns3_mbx.h | 3 +- 4 files changed, 58 insertions(+), 20 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index ae81368f68..bccd9db0dd 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -380,7 +380,7 @@ hns3_interrupt_handler(void *param) hns3_warn(hw, "received reset interrupt"); hns3_schedule_reset(hns); } else if (event_cause == HNS3_VECTOR0_EVENT_MBX) { - hns3_dev_handle_mbx_msg(hw); + hns3pf_handle_mbx_msg(hw); } else if (event_cause != HNS3_VECTOR0_EVENT_PTP) { hns3_warn(hw, "received unknown event: vector0_int_stat:0x%x " "ras_int_stat:0x%x cmdq_int_stat:0x%x", diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index b0d0c29df1..f5a7a2b1f4 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -618,7 +618,7 @@ hns3vf_interrupt_handler(void *param) hns3_schedule_reset(hns); break; case HNS3VF_VECTOR0_EVENT_MBX: - hns3_dev_handle_mbx_msg(hw); + hns3vf_handle_mbx_msg(hw); break; default: break; @@ -670,7 +670,7 @@ hns3vf_get_push_lsc_cap(struct hns3_hw *hw) * driver has to actively handle the HNS3_MBX_LINK_STAT_CHANGE * mailbox from PF driver to get this capability. */ - hns3_dev_handle_mbx_msg(hw); + hns3vf_handle_mbx_msg(hw); if (__atomic_load_n(&vf->pf_push_lsc_cap, __ATOMIC_ACQUIRE) != HNS3_PF_PUSH_LSC_CAP_UNKNOWN) break; diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index 43195ff184..9cdbc1668a 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -78,7 +78,7 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, return -EIO; } - hns3_dev_handle_mbx_msg(hw); + hns3vf_handle_mbx_msg(hw); rte_delay_us(HNS3_WAIT_RESP_US); if (hw->mbx_resp.received_match_resp) @@ -372,9 +372,57 @@ scan_next: } void -hns3_dev_handle_mbx_msg(struct hns3_hw *hw) +hns3pf_handle_mbx_msg(struct hns3_hw *hw) +{ + struct hns3_cmq_ring *crq = &hw->cmq.crq; + struct hns3_mbx_vf_to_pf_cmd *req; + struct hns3_cmd_desc *desc; + uint16_t flag; + + rte_spinlock_lock(&hw->cmq.crq.lock); + + while (!hns3_cmd_crq_empty(hw)) { + if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) { + rte_spinlock_unlock(&hw->cmq.crq.lock); + return; + } + desc = &crq->desc[crq->next_to_use]; + req = (struct hns3_mbx_vf_to_pf_cmd *)desc->data; + + flag = rte_le_to_cpu_16(crq->desc[crq->next_to_use].flag); + if (unlikely(!hns3_get_bit(flag, HNS3_CMDQ_RX_OUTVLD_B))) { + hns3_warn(hw, + "dropped invalid mailbox message, code = %u", + req->msg.code); + + /* dropping/not processing this invalid message */ + crq->desc[crq->next_to_use].flag = 0; + hns3_mbx_ring_ptr_move_crq(crq); + continue; + } + + switch (req->msg.code) { + case HNS3_MBX_PUSH_LINK_STATUS: + hns3pf_handle_link_change_event(hw, req); + break; + default: + hns3_err(hw, "received unsupported(%u) mbx msg", + req->msg.code); + break; + } + crq->desc[crq->next_to_use].flag = 0; + hns3_mbx_ring_ptr_move_crq(crq); + } + + /* Write back CMDQ_RQ header pointer, IMP need this pointer */ + hns3_write_dev(hw, HNS3_CMDQ_RX_HEAD_REG, crq->next_to_use); + + rte_spinlock_unlock(&hw->cmq.crq.lock); +} + +void +hns3vf_handle_mbx_msg(struct hns3_hw *hw) { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); struct hns3_cmq_ring *crq = &hw->cmq.crq; struct hns3_mbx_pf_to_vf_cmd *req; struct hns3_cmd_desc *desc; @@ -385,7 +433,7 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) rte_spinlock_lock(&hw->cmq.crq.lock); handle_out = (rte_eal_process_type() != RTE_PROC_PRIMARY || - !rte_thread_is_intr()) && hns->is_vf; + !rte_thread_is_intr()); if (handle_out) { /* * Currently, any threads in the primary and secondary processes @@ -430,8 +478,7 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) continue; } - handle_out = hns->is_vf && desc->opcode == 0; - if (handle_out) { + if (desc->opcode == 0) { /* Message already processed by other thread */ crq->desc[crq->next_to_use].flag = 0; hns3_mbx_ring_ptr_move_crq(crq); @@ -448,16 +495,6 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) case HNS3_MBX_ASSERTING_RESET: hns3_handle_asserting_reset(hw, req); break; - case HNS3_MBX_PUSH_LINK_STATUS: - /* - * This message is reported by the firmware and is - * reported in 'struct hns3_mbx_vf_to_pf_cmd' format. - * Therefore, we should cast the req variable to - * 'struct hns3_mbx_vf_to_pf_cmd' and then process it. - */ - hns3pf_handle_link_change_event(hw, - (struct hns3_mbx_vf_to_pf_cmd *)req); - break; case HNS3_MBX_PUSH_VLAN_INFO: /* * When the PVID configuration status of VF device is diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h index 2952b96ab6..2b6cb8f513 100644 --- a/drivers/net/hns3/hns3_mbx.h +++ b/drivers/net/hns3/hns3_mbx.h @@ -207,7 +207,8 @@ struct hns3_pf_rst_done_cmd { ((crq)->next_to_use = ((crq)->next_to_use + 1) % (crq)->desc_num) struct hns3_hw; -void hns3_dev_handle_mbx_msg(struct hns3_hw *hw); +void hns3pf_handle_mbx_msg(struct hns3_hw *hw); +void hns3vf_handle_mbx_msg(struct hns3_hw *hw); void hns3vf_mbx_setup(struct hns3_vf_to_pf_msg *req, uint8_t code, uint8_t subcode); int hns3vf_mbx_send(struct hns3_hw *hw, -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-05 17:39:33.582398286 +0800 +++ 0085-net-hns3-refactor-handle-mailbox-function.patch 2024-03-05 17:39:30.833566495 +0800 @@ -1 +1 @@ -From 277d522ae39f6c9daa38c5ad5d3b94f632f9cf49 Mon Sep 17 00:00:00 2001 +From 8abf8591dcc17e9a0a7cd11da0597d90fe095b46 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 277d522ae39f6c9daa38c5ad5d3b94f632f9cf49 ] @@ -15 +17,0 @@ -Cc: stable@dpdk.org