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 7746D43B86 for ; Tue, 5 Mar 2024 10:55:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6DDD84026B; Tue, 5 Mar 2024 10:55:55 +0100 (CET) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2040.outbound.protection.outlook.com [40.107.101.40]) by mails.dpdk.org (Postfix) with ESMTP id 9C0AA40ED3 for ; Tue, 5 Mar 2024 10:55:53 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yf7RVqdU91vDJtRp7LOjdeJr86gCc2dFEZ9esXuFca5iAzJEyXtQC+XjGDdgsn+genjfoukMAIxDBFk3goywknlv18PsItidcoDwiYA0TzYqlqMvJzMuVzBlGBoMfUQ+BE/k3Un/gQKtjoDSP9kkvzcOoF/u0/1zh6ehdbsYwLh+h8XuXeWbg9wAP/QtJumedI/9X0r1z8u/JLHqy3ihZ2qOuCWSMPk/NMucW7AzGpSICPI3t4BMCjlUaXPVcxlDXT5bhyoXZesYuyeUybOCMIpurFGKDcd6cSpa8d9NsRdTFyYPLLwI/qQJ2j1CKi9WWD8bKXS3QejJ3n1yW9mcRw== 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=45XcT0uo2+ClRqnKt47TjJny1mJZmb30YtltgcqRKvo=; b=coOpHjBXYfq7T4Bs4PpytARH3ZQSOEnSwGFJbEBKvdbrq0iFKulV3oClaTiXwXw/DZx27ql8+kRsP0nXUUj8LqphfWx2gHBSL0hP5baWjhTLap5R7LWZxX5RPbXB/AO8ZmAN1amdHWQOQ9041O2133fbaTPJ8uCcJ/bz1UME60lsadUgOj6F/SUiAbRdyoaZuYFep45dYO5qO+SC7COoinQl6+UovJEYTnBNbs9jAYYDSOrG70MMIlT8cmEwodZH4+4hGouoZTVb7XR5dHKbZvGmp6l4mMs35M9ZDUQ+yJK1sNRt2dVBA48OWTAjE6wM9nD7N642q8llhrIFCWMdPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=45XcT0uo2+ClRqnKt47TjJny1mJZmb30YtltgcqRKvo=; b=GI1d/YN8tHM5sT1ucxeOabXpl1+UfcgVys98ulHNMrUpC1BdO5lWnHmTtIembZukNfLr7cgJLDgKqKzBgBbf2AJMvQPEYdGX5p/jMFwKFy097ksTMWHlqPNNxc83Tcr/5yQEoUH611D8vQYBWQBdxARI+3gY/il+Cr1GSjz/G0+DlTgOzajHoCuczhOc4IMbazylmVOaDehwyE/SLcQkIkyBHXToRIAsblqyHMuYXg8t2UIfFp9xo0oUy0HTRtc6YBUqsxP8ij1guY+hArBoHCYym/IGE74PN9XUDOT0SOUK0O+2ltDvuZvRUg6ga5jDk0xkI+4dKaS9xcxdSaZTag== Received: from MW4PR04CA0075.namprd04.prod.outlook.com (2603:10b6:303:6b::20) by IA0PR12MB7532.namprd12.prod.outlook.com (2603:10b6:208:43e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Tue, 5 Mar 2024 09:55:50 +0000 Received: from CO1PEPF000042AC.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::6c) by MW4PR04CA0075.outlook.office365.com (2603:10b6:303:6b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38 via Frontend Transport; Tue, 5 Mar 2024 09:55:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1PEPF000042AC.mail.protection.outlook.com (10.167.243.41) 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:48 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) 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:28 -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:27 -0800 From: Xueming Li To: Dengdui Huang CC: Jie Hai , dpdk stable Subject: patch 'net/hns3: refactor send mailbox function' has been queued to stable release 23.11.1 Date: Tue, 5 Mar 2024 17:47:05 +0800 Message-ID: <20240305094757.439387-85-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: CO1PEPF000042AC:EE_|IA0PR12MB7532:EE_ X-MS-Office365-Filtering-Correlation-Id: 5494e766-bcb0-46b0-c8a6-08dc3cfa6f5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V4NoKAzCkNTdiJRpg4c/F9Fgz6mKHaCJXkchWfPGfQ74RPKhw1cI6i7kez7LpTYzRzHnhRXtfZi+XmAbLPIvgws+XGFO0bEznO4hyeGvfAiBzs98nj1vggiWNi0t2255XInCJJST/fIm2VRwoCzEUsAAqAsqWB0YsHwRsMGTeROF1j+puDAwUGNeAWp1atmAU3+nXZqvLrc78gOlrxNdMv+IMMk4ZJms8Lo3wl21/JCAfEoM0YuQDZUQCnGHO7MPcunTUaEoOVLbqHd219NiDrBABo/u+THba8KLavfcFFAMHdgx+TLSaezQNmkmR/ghE7KagfHCE4BPaxkTYLbZ/6siwvMDyuS1v2WRWXO7zz97Kzuz92ceEpJlXusmcmDryOXgKfZrxHbaTnMYBnkv8jeJOB7VMVj3XCxHQ6HRn1TFnsMEIlIgvpF7dWehfIvUYAGQ4KDqnGIbflXXhqe4jjRq6Gc5eK814dX3I90ez3GwcPb+lpjTdvug91C5qmLR+qRf37k9eiAtMKGggoyb5vdMLqShlqBnEVzEuM+OLMckDQPuHVJC9VzRKbTEgMSIJBCioX2Z2tRZP3eofegbWnu1mTtVp+Nu5dsSnYDYhyja/EzgvLa2QRh8Z2BEowzYLtc2mT4BSltoWHZ5DofGfbZFO9eDDmdYOIk8aEf0mhrvAhDXN4CF84jsvaZ41mhfTiRhci+YT1zoqA4xhv1SsiA2zXanPwCo7voq8kJ4UbW4QsqsAKrkaVVgws1G9SSY X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(36860700004)(376005)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 09:55:48.5981 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5494e766-bcb0-46b0-c8a6-08dc3cfa6f5b 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7532 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=1be4ad59be7f6d3cea9c6e4536339178714c2cfc Thanks. Xueming Li --- >From 1be4ad59be7f6d3cea9c6e4536339178714c2cfc Mon Sep 17 00:00:00 2001 From: Dengdui Huang Date: Fri, 8 Dec 2023 14:55:07 +0800 Subject: [PATCH] net/hns3: refactor send mailbox function Cc: Xueming Li [ upstream commit c9bd98d84587dbc0dddb8964ad3d7d54818aca01 ] The 'hns3_send_mbx_msg' function has following problem: 1. the name is vague, missing caller indication 2. too many input parameters because the filling messages are placed in commands the send command. Therefore, a common interface is encapsulated to fill in the mailbox message before sending it. Fixes: 463e748964f5 ("net/hns3: support mailbox") Signed-off-by: Dengdui Huang Signed-off-by: Jie Hai --- drivers/net/hns3/hns3_ethdev_vf.c | 141 ++++++++++++++++++------------ drivers/net/hns3/hns3_mbx.c | 50 ++++------- drivers/net/hns3/hns3_mbx.h | 8 +- drivers/net/hns3/hns3_rxtx.c | 18 ++-- 4 files changed, 116 insertions(+), 101 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 19e734ca8d..b0d0c29df1 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -91,11 +91,13 @@ hns3vf_add_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) { /* mac address was checked by upper level interface */ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; + struct hns3_vf_to_pf_msg req; int ret; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST, - HNS3_MBX_MAC_VLAN_UC_ADD, mac_addr->addr_bytes, - RTE_ETHER_ADDR_LEN, false, NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_SET_UNICAST, + HNS3_MBX_MAC_VLAN_UC_ADD); + memcpy(req.data, mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN); + ret = hns3vf_mbx_send(hw, &req, false, NULL, 0); if (ret) { hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, mac_addr); @@ -110,12 +112,13 @@ hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) { /* mac address was checked by upper level interface */ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; + struct hns3_vf_to_pf_msg req; int ret; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST, - HNS3_MBX_MAC_VLAN_UC_REMOVE, - mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN, - false, NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_SET_UNICAST, + HNS3_MBX_MAC_VLAN_UC_REMOVE); + memcpy(req.data, mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN); + ret = hns3vf_mbx_send(hw, &req, false, NULL, 0); if (ret) { hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, mac_addr); @@ -134,6 +137,7 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *old_addr; uint8_t addr_bytes[HNS3_TWO_ETHER_ADDR_LEN]; /* for 2 MAC addresses */ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; + struct hns3_vf_to_pf_msg req; int ret; /* @@ -146,9 +150,10 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev, memcpy(&addr_bytes[RTE_ETHER_ADDR_LEN], old_addr->addr_bytes, RTE_ETHER_ADDR_LEN); - ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST, - HNS3_MBX_MAC_VLAN_UC_MODIFY, addr_bytes, - HNS3_TWO_ETHER_ADDR_LEN, true, NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_SET_UNICAST, + HNS3_MBX_MAC_VLAN_UC_MODIFY); + memcpy(req.data, addr_bytes, HNS3_TWO_ETHER_ADDR_LEN); + ret = hns3vf_mbx_send(hw, &req, true, NULL, 0); if (ret) { /* * The hns3 VF PMD depends on the hns3 PF kernel ethdev @@ -185,12 +190,13 @@ hns3vf_add_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) { char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; + struct hns3_vf_to_pf_msg req; int ret; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_MULTICAST, - HNS3_MBX_MAC_VLAN_MC_ADD, - mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN, false, - NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_SET_MULTICAST, + HNS3_MBX_MAC_VLAN_MC_ADD); + memcpy(req.data, mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN); + ret = hns3vf_mbx_send(hw, &req, false, NULL, 0); if (ret) { hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, mac_addr); @@ -206,12 +212,13 @@ hns3vf_remove_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) { char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; + struct hns3_vf_to_pf_msg req; int ret; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_MULTICAST, - HNS3_MBX_MAC_VLAN_MC_REMOVE, - mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN, false, - NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_SET_MULTICAST, + HNS3_MBX_MAC_VLAN_MC_REMOVE); + memcpy(req.data, mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN); + ret = hns3vf_mbx_send(hw, &req, false, NULL, 0); if (ret) { hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, mac_addr); @@ -348,7 +355,6 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, bool mmap, enum hns3_ring_type queue_type, uint16_t queue_id) { -#define HNS3_RING_VERCTOR_DATA_SIZE 14 struct hns3_vf_to_pf_msg req = {0}; const char *op_str; int ret; @@ -365,8 +371,7 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, req.ring_param[0].ring_type = queue_type; req.ring_param[0].tqp_index = queue_id; op_str = mmap ? "Map" : "Unmap"; - ret = hns3_send_mbx_msg(hw, req.code, 0, (uint8_t *)&req.vector_id, - HNS3_RING_VERCTOR_DATA_SIZE, false, NULL, 0); + ret = hns3vf_mbx_send(hw, &req, false, NULL, 0); if (ret) hns3_err(hw, "%s TQP %u fail, vector_id is %u, ret = %d.", op_str, queue_id, req.vector_id, ret); @@ -452,10 +457,12 @@ cfg_err: static int hns3vf_config_mtu(struct hns3_hw *hw, uint16_t mtu) { + struct hns3_vf_to_pf_msg req; int ret; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_MTU, 0, (const uint8_t *)&mtu, - sizeof(mtu), true, NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_SET_MTU, 0); + memcpy(req.data, &mtu, sizeof(mtu)); + ret = hns3vf_mbx_send(hw, &req, true, NULL, 0); if (ret) hns3_err(hw, "Failed to set mtu (%u) for vf: %d", mtu, ret); @@ -646,12 +653,13 @@ hns3vf_get_push_lsc_cap(struct hns3_hw *hw) uint16_t val = HNS3_PF_PUSH_LSC_CAP_NOT_SUPPORTED; uint16_t exp = HNS3_PF_PUSH_LSC_CAP_UNKNOWN; struct hns3_vf *vf = HNS3_DEV_HW_TO_VF(hw); + struct hns3_vf_to_pf_msg req; __atomic_store_n(&vf->pf_push_lsc_cap, HNS3_PF_PUSH_LSC_CAP_UNKNOWN, __ATOMIC_RELEASE); - (void)hns3_send_mbx_msg(hw, HNS3_MBX_GET_LINK_STATUS, 0, NULL, 0, false, - NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_GET_LINK_STATUS, 0); + (void)hns3vf_mbx_send(hw, &req, false, NULL, 0); while (remain_ms > 0) { rte_delay_ms(HNS3_POLL_RESPONE_MS); @@ -746,12 +754,13 @@ hns3vf_check_tqp_info(struct hns3_hw *hw) static int hns3vf_get_port_base_vlan_filter_state(struct hns3_hw *hw) { + struct hns3_vf_to_pf_msg req; uint8_t resp_msg; int ret; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN, - HNS3_MBX_GET_PORT_BASE_VLAN_STATE, NULL, 0, - true, &resp_msg, sizeof(resp_msg)); + hns3vf_mbx_setup(&req, HNS3_MBX_SET_VLAN, + HNS3_MBX_GET_PORT_BASE_VLAN_STATE); + ret = hns3vf_mbx_send(hw, &req, true, &resp_msg, sizeof(resp_msg)); if (ret) { if (ret == -ETIME) { /* @@ -792,10 +801,12 @@ hns3vf_get_queue_info(struct hns3_hw *hw) { #define HNS3VF_TQPS_RSS_INFO_LEN 6 uint8_t resp_msg[HNS3VF_TQPS_RSS_INFO_LEN]; + struct hns3_vf_to_pf_msg req; int ret; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_QINFO, 0, NULL, 0, true, - resp_msg, HNS3VF_TQPS_RSS_INFO_LEN); + hns3vf_mbx_setup(&req, HNS3_MBX_GET_QINFO, 0); + ret = hns3vf_mbx_send(hw, &req, true, + resp_msg, HNS3VF_TQPS_RSS_INFO_LEN); if (ret) { PMD_INIT_LOG(ERR, "Failed to get tqp info from PF: %d", ret); return ret; @@ -833,10 +844,11 @@ hns3vf_get_basic_info(struct hns3_hw *hw) { uint8_t resp_msg[HNS3_MBX_MAX_RESP_DATA_SIZE]; struct hns3_basic_info *basic_info; + struct hns3_vf_to_pf_msg req; int ret; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_BASIC_INFO, 0, NULL, 0, - true, resp_msg, sizeof(resp_msg)); + hns3vf_mbx_setup(&req, HNS3_MBX_GET_BASIC_INFO, 0); + ret = hns3vf_mbx_send(hw, &req, true, resp_msg, sizeof(resp_msg)); if (ret) { hns3_err(hw, "failed to get basic info from PF, ret = %d.", ret); @@ -856,10 +868,11 @@ static int hns3vf_get_host_mac_addr(struct hns3_hw *hw) { uint8_t host_mac[RTE_ETHER_ADDR_LEN]; + struct hns3_vf_to_pf_msg req; int ret; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_MAC_ADDR, 0, NULL, 0, - true, host_mac, RTE_ETHER_ADDR_LEN); + hns3vf_mbx_setup(&req, HNS3_MBX_GET_MAC_ADDR, 0); + ret = hns3vf_mbx_send(hw, &req, true, host_mac, RTE_ETHER_ADDR_LEN); if (ret) { hns3_err(hw, "Failed to get mac addr from PF: %d", ret); return ret; @@ -908,6 +921,7 @@ static void hns3vf_request_link_info(struct hns3_hw *hw) { struct hns3_vf *vf = HNS3_DEV_HW_TO_VF(hw); + struct hns3_vf_to_pf_msg req; bool send_req; int ret; @@ -919,8 +933,8 @@ hns3vf_request_link_info(struct hns3_hw *hw) if (!send_req) return; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_LINK_STATUS, 0, NULL, 0, false, - NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_GET_LINK_STATUS, 0); + ret = hns3vf_mbx_send(hw, &req, false, NULL, 0); if (ret) { hns3_err(hw, "failed to fetch link status, ret = %d", ret); return; @@ -964,16 +978,18 @@ hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, static int hns3vf_vlan_filter_configure(struct hns3_adapter *hns, uint16_t vlan_id, int on) { - struct hns3_mbx_vlan_filter vlan_filter = {0}; + struct hns3_mbx_vlan_filter *vlan_filter; + struct hns3_vf_to_pf_msg req = {0}; struct hns3_hw *hw = &hns->hw; - vlan_filter.is_kill = on ? 0 : 1; - vlan_filter.proto = rte_cpu_to_le_16(RTE_ETHER_TYPE_VLAN); - vlan_filter.vlan_id = rte_cpu_to_le_16(vlan_id); + req.code = HNS3_MBX_SET_VLAN; + req.subcode = HNS3_MBX_VLAN_FILTER; + vlan_filter = (struct hns3_mbx_vlan_filter *)req.data; + vlan_filter->is_kill = on ? 0 : 1; + vlan_filter->proto = rte_cpu_to_le_16(RTE_ETHER_TYPE_VLAN); + vlan_filter->vlan_id = rte_cpu_to_le_16(vlan_id); - return hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN, HNS3_MBX_VLAN_FILTER, - (uint8_t *)&vlan_filter, sizeof(vlan_filter), - true, NULL, 0); + return hns3vf_mbx_send(hw, &req, true, NULL, 0); } static int @@ -1002,6 +1018,7 @@ hns3vf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) static int hns3vf_en_vlan_filter(struct hns3_hw *hw, bool enable) { + struct hns3_vf_to_pf_msg req; uint8_t msg_data; int ret; @@ -1009,9 +1026,10 @@ hns3vf_en_vlan_filter(struct hns3_hw *hw, bool enable) return 0; msg_data = enable ? 1 : 0; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN, - HNS3_MBX_ENABLE_VLAN_FILTER, &msg_data, - sizeof(msg_data), true, NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_SET_VLAN, + HNS3_MBX_ENABLE_VLAN_FILTER); + memcpy(req.data, &msg_data, sizeof(msg_data)); + ret = hns3vf_mbx_send(hw, &req, true, NULL, 0); if (ret) hns3_err(hw, "%s vlan filter failed, ret = %d.", enable ? "enable" : "disable", ret); @@ -1022,12 +1040,15 @@ hns3vf_en_vlan_filter(struct hns3_hw *hw, bool enable) static int hns3vf_en_hw_strip_rxvtag(struct hns3_hw *hw, bool enable) { + struct hns3_vf_to_pf_msg req; uint8_t msg_data; int ret; msg_data = enable ? 1 : 0; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN, HNS3_MBX_VLAN_RX_OFF_CFG, - &msg_data, sizeof(msg_data), false, NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_SET_VLAN, + HNS3_MBX_VLAN_RX_OFF_CFG); + memcpy(req.data, &msg_data, sizeof(msg_data)); + ret = hns3vf_mbx_send(hw, &req, false, NULL, 0); if (ret) hns3_err(hw, "vf %s strip failed, ret = %d.", enable ? "enable" : "disable", ret); @@ -1171,11 +1192,13 @@ hns3vf_dev_configure_vlan(struct rte_eth_dev *dev) static int hns3vf_set_alive(struct hns3_hw *hw, bool alive) { + struct hns3_vf_to_pf_msg req; uint8_t msg_data; msg_data = alive ? 1 : 0; - return hns3_send_mbx_msg(hw, HNS3_MBX_SET_ALIVE, 0, &msg_data, - sizeof(msg_data), false, NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_SET_ALIVE, 0); + memcpy(req.data, &msg_data, sizeof(msg_data)); + return hns3vf_mbx_send(hw, &req, false, NULL, 0); } static void @@ -1183,11 +1206,12 @@ hns3vf_keep_alive_handler(void *param) { struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param; struct hns3_adapter *hns = eth_dev->data->dev_private; + struct hns3_vf_to_pf_msg req; struct hns3_hw *hw = &hns->hw; int ret; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_KEEP_ALIVE, 0, NULL, 0, - false, NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_KEEP_ALIVE, 0); + ret = hns3vf_mbx_send(hw, &req, false, NULL, 0); if (ret) hns3_err(hw, "VF sends keeping alive cmd failed(=%d)", ret); @@ -1326,9 +1350,11 @@ err_init_hardware: static int hns3vf_clear_vport_list(struct hns3_hw *hw) { - return hns3_send_mbx_msg(hw, HNS3_MBX_HANDLE_VF_TBL, - HNS3_MBX_VPORT_LIST_CLEAR, NULL, 0, false, - NULL, 0); + struct hns3_vf_to_pf_msg req; + + hns3vf_mbx_setup(&req, HNS3_MBX_HANDLE_VF_TBL, + HNS3_MBX_VPORT_LIST_CLEAR); + return hns3vf_mbx_send(hw, &req, false, NULL, 0); } static int @@ -1797,12 +1823,13 @@ hns3vf_wait_hardware_ready(struct hns3_adapter *hns) static int hns3vf_prepare_reset(struct hns3_adapter *hns) { + struct hns3_vf_to_pf_msg req; struct hns3_hw *hw = &hns->hw; int ret; if (hw->reset.level == HNS3_VF_FUNC_RESET) { - ret = hns3_send_mbx_msg(hw, HNS3_MBX_RESET, 0, NULL, - 0, true, NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_RESET, 0); + ret = hns3vf_mbx_send(hw, &req, true, NULL, 0); if (ret) return ret; } diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index c90f5d59ba..43195ff184 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -24,6 +24,14 @@ static const struct errno_respcode_map err_code_map[] = { {95, -EOPNOTSUPP}, }; +void +hns3vf_mbx_setup(struct hns3_vf_to_pf_msg *req, uint8_t code, uint8_t subcode) +{ + memset(req, 0, sizeof(struct hns3_vf_to_pf_msg)); + req->code = code; + req->subcode = subcode; +} + static int hns3_resp_to_errno(uint16_t resp_code) { @@ -118,45 +126,24 @@ hns3_mbx_prepare_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode) } int -hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - const uint8_t *msg_data, uint8_t msg_len, bool need_resp, - uint8_t *resp_data, uint16_t resp_len) +hns3vf_mbx_send(struct hns3_hw *hw, + struct hns3_vf_to_pf_msg *req, bool need_resp, + uint8_t *resp_data, uint16_t resp_len) { - struct hns3_mbx_vf_to_pf_cmd *req; + struct hns3_mbx_vf_to_pf_cmd *cmd; struct hns3_cmd_desc desc; - bool is_ring_vector_msg; int ret; - req = (struct hns3_mbx_vf_to_pf_cmd *)desc.data; - - /* first two bytes are reserved for code & subcode */ - if (msg_len > HNS3_MBX_MSG_MAX_DATA_SIZE) { - hns3_err(hw, - "VF send mbx msg fail, msg len %u exceeds max payload len %d", - msg_len, HNS3_MBX_MSG_MAX_DATA_SIZE); - return -EINVAL; - } - hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_MBX_VF_TO_PF, false); - req->msg.code = code; - is_ring_vector_msg = (code == HNS3_MBX_MAP_RING_TO_VECTOR) || - (code == HNS3_MBX_UNMAP_RING_TO_VECTOR) || - (code == HNS3_MBX_GET_RING_VECTOR_MAP); - if (!is_ring_vector_msg) - req->msg.subcode = subcode; - if (msg_data) { - if (is_ring_vector_msg) - memcpy(&req->msg.vector_id, msg_data, msg_len); - else - memcpy(&req->msg.data, msg_data, msg_len); - } + cmd = (struct hns3_mbx_vf_to_pf_cmd *)desc.data; + cmd->msg = *req; /* synchronous send */ if (need_resp) { - req->mbx_need_resp |= HNS3_MBX_NEED_RESP_BIT; + cmd->mbx_need_resp |= HNS3_MBX_NEED_RESP_BIT; rte_spinlock_lock(&hw->mbx_resp.lock); - hns3_mbx_prepare_resp(hw, code, subcode); - req->match_id = hw->mbx_resp.match_id; + hns3_mbx_prepare_resp(hw, req->code, req->subcode); + cmd->match_id = hw->mbx_resp.match_id; ret = hns3_cmd_send(hw, &desc, 1); if (ret) { rte_spinlock_unlock(&hw->mbx_resp.lock); @@ -165,7 +152,8 @@ hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, return ret; } - ret = hns3_get_mbx_resp(hw, code, subcode, resp_data, resp_len); + ret = hns3_get_mbx_resp(hw, req->code, req->subcode, + resp_data, resp_len); rte_spinlock_unlock(&hw->mbx_resp.lock); } else { /* asynchronous send */ diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h index 09780fcebd..2952b96ab6 100644 --- a/drivers/net/hns3/hns3_mbx.h +++ b/drivers/net/hns3/hns3_mbx.h @@ -208,7 +208,9 @@ struct hns3_pf_rst_done_cmd { struct hns3_hw; void hns3_dev_handle_mbx_msg(struct hns3_hw *hw); -int hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - const uint8_t *msg_data, uint8_t msg_len, bool need_resp, - uint8_t *resp_data, uint16_t resp_len); +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, + struct hns3_vf_to_pf_msg *req_msg, bool need_resp, + uint8_t *resp_data, uint16_t resp_len); #endif /* HNS3_MBX_H */ diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 09b7e90c70..9087bcffed 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -686,13 +686,12 @@ tqp_reset_fail: static int hns3vf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id) { - uint8_t msg_data[2]; + struct hns3_vf_to_pf_msg req; int ret; - memcpy(msg_data, &queue_id, sizeof(uint16_t)); - - ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data, - sizeof(msg_data), true, NULL, 0); + hns3vf_mbx_setup(&req, HNS3_MBX_QUEUE_RESET, 0); + memcpy(req.data, &queue_id, sizeof(uint16_t)); + ret = hns3vf_mbx_send(hw, &req, true, NULL, 0); if (ret) hns3_err(hw, "fail to reset tqp, queue_id = %u, ret = %d.", queue_id, ret); @@ -769,15 +768,14 @@ static int hns3vf_reset_all_tqps(struct hns3_hw *hw) { #define HNS3VF_RESET_ALL_TQP_DONE 1U + struct hns3_vf_to_pf_msg req; uint8_t reset_status; - uint8_t msg_data[2]; int ret; uint16_t i; - memset(msg_data, 0, sizeof(msg_data)); - ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data, - sizeof(msg_data), true, &reset_status, - sizeof(reset_status)); + hns3vf_mbx_setup(&req, HNS3_MBX_QUEUE_RESET, 0); + ret = hns3vf_mbx_send(hw, &req, true, + &reset_status, sizeof(reset_status)); if (ret) { hns3_err(hw, "fail to send rcb reset mbx, ret = %d.", ret); return ret; -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-05 17:39:33.547637285 +0800 +++ 0084-net-hns3-refactor-send-mailbox-function.patch 2024-03-05 17:39:30.833566495 +0800 @@ -1 +1 @@ -From c9bd98d84587dbc0dddb8964ad3d7d54818aca01 Mon Sep 17 00:00:00 2001 +From 1be4ad59be7f6d3cea9c6e4536339178714c2cfc Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit c9bd98d84587dbc0dddb8964ad3d7d54818aca01 ] @@ -15 +17,0 @@ -Cc: stable@dpdk.org