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 8C25543829 for ; Tue, 5 Mar 2024 16:35:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 862E6415D7; Tue, 5 Mar 2024 16:35:57 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id B9838410D3 for ; Tue, 5 Mar 2024 16:35:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709652956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lqJSkpo+rw0exMEx5RUfXSyZnDS6jFVDsBb42qBBCvY=; b=SjcKDgbWC1m/C/aZ+JrLvo2Co1XMtZGLaHAxCgOA1ecAVfRkoLonotcX6cMbiW6nLqDqXV VGFtbDtN9l6m0qfYm6CLL7s9Rp2bmepQgQGKKTp1d8rXS9sCWdeNaG1v9kcHqTeG8iM1Vv l+Xn/43NEoLUPt2x9pLjD5AA07JRgDg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-393-Eg5KKHx3N-ax2gVv0td9mg-1; Tue, 05 Mar 2024 10:35:53 -0500 X-MC-Unique: Eg5KKHx3N-ax2gVv0td9mg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B6EA1C01E87; Tue, 5 Mar 2024 15:35:52 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE143200AFA2; Tue, 5 Mar 2024 15:35:51 +0000 (UTC) From: Kevin Traynor To: Dengdui Huang Cc: Jie Hai , dpdk stable Subject: patch 'net/hns3: refactor PF mailbox message struct' has been queued to stable release 21.11.7 Date: Tue, 5 Mar 2024 15:34:15 +0000 Message-ID: <20240305153449.263666-42-ktraynor@redhat.com> In-Reply-To: <20240305153449.263666-1-ktraynor@redhat.com> References: <20240305153449.263666-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 21.11.7 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/11/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://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/9b6c3117a18fad65f55a4d29648e4a05d24c1486 Thanks. Kevin --- >From 9b6c3117a18fad65f55a4d29648e4a05d24c1486 Mon Sep 17 00:00:00 2001 From: Dengdui Huang Date: Fri, 8 Dec 2023 14:55:06 +0800 Subject: [PATCH] net/hns3: refactor PF mailbox message struct [ upstream commit 4d534598d922130d12c244d3237652fbfdad0f4b ] The data region in PF to VF mbx memssage command is used to communicate with VF driver. And this data region exists as an array. As a result, some complicated feature commands, like mailbox response, link change event, close promisc mode, reset request and update pvid state, have to use magic number to set them. This isn't good for maintenance of driver. So this patch refactors these messages by extracting an hns3_pf_to_vf_msg structure. Fixes: 463e748964f5 ("net/hns3: support mailbox") Signed-off-by: Dengdui Huang Signed-off-by: Jie Hai --- drivers/net/hns3/hns3_mbx.c | 38 ++++++++++++++++++------------------- drivers/net/hns3/hns3_mbx.h | 25 +++++++++++++++++++++++- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index ad5ec555b3..c90f5d59ba 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -193,15 +193,15 @@ hns3vf_handle_link_change_event(struct hns3_hw *hw, struct hns3_mbx_pf_to_vf_cmd *req) { + struct hns3_mbx_link_status *link_info = + (struct hns3_mbx_link_status *)req->msg.msg_data; uint8_t link_status, link_duplex; - uint16_t *msg_q = req->msg; uint8_t support_push_lsc; uint32_t link_speed; - memcpy(&link_speed, &msg_q[2], sizeof(link_speed)); - link_status = rte_le_to_cpu_16(msg_q[1]); - link_duplex = (uint8_t)rte_le_to_cpu_16(msg_q[4]); - hns3vf_update_link_status(hw, link_status, link_speed, - link_duplex); - support_push_lsc = (*(uint8_t *)&msg_q[5]) & 1u; + link_status = (uint8_t)rte_le_to_cpu_16(link_info->link_status); + link_speed = rte_le_to_cpu_32(link_info->speed); + link_duplex = (uint8_t)rte_le_to_cpu_16(link_info->duplex); + hns3vf_update_link_status(hw, link_status, link_speed, link_duplex); + support_push_lsc = (link_info->flag) & 1u; hns3vf_update_push_lsc_cap(hw, support_push_lsc); } @@ -212,5 +212,4 @@ hns3_handle_asserting_reset(struct hns3_hw *hw, { enum hns3_reset_level reset_level; - uint16_t *msg_q = req->msg; /* @@ -220,5 +219,5 @@ hns3_handle_asserting_reset(struct hns3_hw *hw, * eventually be re-initialized. */ - reset_level = rte_le_to_cpu_16(msg_q[1]); + reset_level = rte_le_to_cpu_16(req->msg.reset_level); hns3_atomic_set_bit(reset_level, &hw->reset.pending); @@ -242,6 +241,7 @@ hns3_handle_mbx_response(struct hns3_hw *hw, struct hns3_mbx_pf_to_vf_cmd *req) */ if (req->match_id == resp->match_id) { - resp->resp_status = hns3_resp_to_errno(req->msg[3]); - memcpy(resp->additional_info, &req->msg[4], + resp->resp_status = + hns3_resp_to_errno(req->msg.resp_status); + memcpy(resp->additional_info, &req->msg.resp_data, HNS3_MBX_MAX_RESP_DATA_SIZE); rte_io_wmb(); @@ -256,5 +256,6 @@ hns3_handle_mbx_response(struct hns3_hw *hw, struct hns3_mbx_pf_to_vf_cmd *req) * original scheme to process. */ - msg_data = (uint32_t)req->msg[1] << HNS3_MBX_RESP_CODE_OFFSET | req->msg[2]; + msg_data = (uint32_t)req->msg.vf_mbx_msg_code << + HNS3_MBX_RESP_CODE_OFFSET | req->msg.vf_mbx_msg_subcode; if (resp->req_msg_data != msg_data) { hns3_warn(hw, @@ -264,6 +265,6 @@ hns3_handle_mbx_response(struct hns3_hw *hw, struct hns3_mbx_pf_to_vf_cmd *req) } - resp->resp_status = hns3_resp_to_errno(req->msg[3]); - memcpy(resp->additional_info, &req->msg[4], + resp->resp_status = hns3_resp_to_errno(req->msg.resp_status); + memcpy(resp->additional_info, &req->msg.resp_data, HNS3_MBX_MAX_RESP_DATA_SIZE); rte_io_wmb(); @@ -306,6 +307,5 @@ hns3_update_port_base_vlan_info(struct hns3_hw *hw, struct hns3_mbx_pf_to_vf_cmd *req) { -#define PVID_STATE_OFFSET 1 - uint16_t new_pvid_state = req->msg[PVID_STATE_OFFSET] ? + uint16_t new_pvid_state = req->msg.pvid_state ? HNS3_PORT_BASE_VLAN_ENABLE : HNS3_PORT_BASE_VLAN_DISABLE; /* @@ -356,5 +356,5 @@ hns3_handle_mbx_msg_out_intr(struct hns3_hw *hw) desc = &crq->desc[next_to_use]; req = (struct hns3_mbx_pf_to_vf_cmd *)desc->data; - opcode = req->msg[0] & 0xff; + opcode = req->msg.code & 0xff; flag = rte_le_to_cpu_16(crq->desc[next_to_use].flag); @@ -429,5 +429,5 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) desc = &crq->desc[crq->next_to_use]; req = (struct hns3_mbx_pf_to_vf_cmd *)desc->data; - opcode = req->msg[0] & 0xff; + opcode = req->msg.code & 0xff; flag = rte_le_to_cpu_16(crq->desc[crq->next_to_use].flag); @@ -485,5 +485,5 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) * mailbox message from PF driver. */ - hns3_handle_promisc_info(hw, req->msg[1]); + hns3_handle_promisc_info(hw, req->msg.promisc_en); break; default: diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h index 172b044575..8dee17bd03 100644 --- a/drivers/net/hns3/hns3_mbx.h +++ b/drivers/net/hns3/hns3_mbx.h @@ -115,4 +115,11 @@ struct hns3_mbx_vlan_filter { } __rte_packed; +struct hns3_mbx_link_status { + uint16_t link_status; + uint32_t speed; + uint16_t duplex; + uint8_t flag; +} __rte_packed; + #define HNS3_MBX_MSG_MAX_DATA_SIZE 14 #define HNS3_MBX_MAX_RING_CHAIN_PARAM_NUM 4 @@ -143,4 +150,20 @@ struct hns3_vf_to_pf_msg { }; +struct hns3_pf_to_vf_msg { + uint16_t code; + union { + struct { + uint16_t vf_mbx_msg_code; + uint16_t vf_mbx_msg_subcode; + uint16_t resp_status; + uint8_t resp_data[HNS3_MBX_MAX_RESP_DATA_SIZE]; + }; + uint16_t promisc_en; + uint16_t reset_level; + uint16_t pvid_state; + uint8_t msg_data[HNS3_MBX_MSG_MAX_DATA_SIZE]; + }; +}; + struct errno_respcode_map { uint16_t resp_code; @@ -167,5 +190,5 @@ struct hns3_mbx_pf_to_vf_cmd { uint8_t rsv1; uint16_t match_id; - uint16_t msg[8]; + struct hns3_pf_to_vf_msg msg; }; -- 2.43.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-05 14:08:55.660970365 +0000 +++ 0042-net-hns3-refactor-PF-mailbox-message-struct.patch 2024-03-05 14:08:54.660520792 +0000 @@ -1 +1 @@ -From 4d534598d922130d12c244d3237652fbfdad0f4b Mon Sep 17 00:00:00 2001 +From 9b6c3117a18fad65f55a4d29648e4a05d24c1486 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 4d534598d922130d12c244d3237652fbfdad0f4b ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -122 +123 @@ -index 59fb73abcc..09780fcebd 100644 +index 172b044575..8dee17bd03 100644 @@ -125 +126 @@ -@@ -119,4 +119,11 @@ struct hns3_mbx_vlan_filter { +@@ -115,4 +115,11 @@ struct hns3_mbx_vlan_filter { @@ -137 +138 @@ -@@ -147,4 +154,20 @@ struct hns3_vf_to_pf_msg { +@@ -143,4 +150,20 @@ struct hns3_vf_to_pf_msg { @@ -158 +159 @@ -@@ -171,5 +194,5 @@ struct hns3_mbx_pf_to_vf_cmd { +@@ -167,5 +190,5 @@ struct hns3_mbx_pf_to_vf_cmd {