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 6C37043829 for ; Tue, 5 Mar 2024 16:35:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6589E42E1F; Tue, 5 Mar 2024 16:35:55 +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 6C3AC410D3 for ; Tue, 5 Mar 2024 16:35:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709652953; 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=z3lvBnOb1Mexmxl6T+iTF5KKZJ2qd65BaBcuo8JmIRo=; b=fV09rDoEsEY46Z7uYU5gcgplbxsiC2KpoQIQX10o+z21odltXjm47ap64yFkACqHyKd8Ra uxQQAqnD3kycAP3bo5hCj6U2owueTbjU86LF/VUKLp5W0qQDbpb1SlVeeUyCxSUkXKQuUm bf9cksdMM4C5hJPBNeUUcR9ihkFpGlA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-MJKz3DW_NsS7DOrkTlj6eQ-1; Tue, 05 Mar 2024 10:35:51 -0500 X-MC-Unique: MJKz3DW_NsS7DOrkTlj6eQ-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 4D706891E69; Tue, 5 Mar 2024 15:35:51 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.194.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EF6C2022C25; Tue, 5 Mar 2024 15:35:50 +0000 (UTC) From: Kevin Traynor To: Dengdui Huang Cc: Jie Hai , dpdk stable Subject: patch 'net/hns3: refactor VF mailbox message struct' has been queued to stable release 21.11.7 Date: Tue, 5 Mar 2024 15:34:14 +0000 Message-ID: <20240305153449.263666-41-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/8b31b471949f8919493fb991270832a30fe330f0 Thanks. Kevin --- >From 8b31b471949f8919493fb991270832a30fe330f0 Mon Sep 17 00:00:00 2001 From: Dengdui Huang Date: Fri, 8 Dec 2023 14:55:05 +0800 Subject: [PATCH] net/hns3: refactor VF mailbox message struct [ upstream commit 692b35be121b724119da001d7ec4c0fabd51177b ] The data region in VF to PF mbx memssage command is used to communicate with PF driver. And this data region exists as an array. As a result, some complicated feature commands, like setting promisc mode, map/unmap ring vector and setting VLAN id, 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_vf_to_pf_msg structure. In addition, the PF link change event message is reported by the firmware and is reported in hns3_mbx_vf_to_pf_cmd format, it also needs to be modified. Fixes: 463e748964f5 ("net/hns3: support mailbox") Signed-off-by: Dengdui Huang Signed-off-by: Jie Hai --- drivers/net/hns3/hns3_ethdev_vf.c | 54 ++++++++++++++--------------- drivers/net/hns3/hns3_mbx.c | 24 ++++++------- drivers/net/hns3/hns3_mbx.h | 56 ++++++++++++++++++++++--------- 3 files changed, 76 insertions(+), 58 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 0d1d271f37..639a00615e 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -335,9 +335,10 @@ hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc, */ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_MBX_VF_TO_PF, false); - req->msg[0] = HNS3_MBX_SET_PROMISC_MODE; - req->msg[1] = en_bc_pmc ? 1 : 0; - req->msg[2] = en_uc_pmc ? 1 : 0; - req->msg[3] = en_mc_pmc ? 1 : 0; - req->msg[4] = hw->promisc_mode == HNS3_LIMIT_PROMISC_MODE ? 1 : 0; + req->msg.code = HNS3_MBX_SET_PROMISC_MODE; + req->msg.en_bc = en_bc_pmc ? 1 : 0; + req->msg.en_uc = en_uc_pmc ? 1 : 0; + req->msg.en_mc = en_mc_pmc ? 1 : 0; + req->msg.en_limit_promisc = + hw->promisc_mode == HNS3_LIMIT_PROMISC_MODE ? 1 : 0; ret = hns3_cmd_send(hw, &desc, 1); @@ -428,28 +429,26 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, uint16_t queue_id) { - struct hns3_vf_bind_vector_msg bind_msg; +#define HNS3_RING_VERCTOR_DATA_SIZE 14 + struct hns3_vf_to_pf_msg req = {0}; const char *op_str; - uint16_t code; int ret; - memset(&bind_msg, 0, sizeof(bind_msg)); - code = mmap ? HNS3_MBX_MAP_RING_TO_VECTOR : + req.code = mmap ? HNS3_MBX_MAP_RING_TO_VECTOR : HNS3_MBX_UNMAP_RING_TO_VECTOR; - bind_msg.vector_id = (uint8_t)vector_id; + req.vector_id = (uint8_t)vector_id; + req.ring_num = 1; if (queue_type == HNS3_RING_TYPE_RX) - bind_msg.param[0].int_gl_index = HNS3_RING_GL_RX; + req.ring_param[0].int_gl_index = HNS3_RING_GL_RX; else - bind_msg.param[0].int_gl_index = HNS3_RING_GL_TX; - - bind_msg.param[0].ring_type = queue_type; - bind_msg.ring_num = 1; - bind_msg.param[0].tqp_index = queue_id; + req.ring_param[0].int_gl_index = HNS3_RING_GL_TX; + 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, code, 0, (uint8_t *)&bind_msg, - sizeof(bind_msg), false, NULL, 0); + ret = hns3_send_mbx_msg(hw, req.code, 0, (uint8_t *)&req.vector_id, + HNS3_RING_VERCTOR_DATA_SIZE, false, NULL, 0); if (ret) - hns3_err(hw, "%s TQP %u fail, vector_id is %u, ret is %d.", - op_str, queue_id, bind_msg.vector_id, ret); + hns3_err(hw, "%s TQP %u fail, vector_id is %u, ret = %d.", + op_str, queue_id, req.vector_id, ret); return ret; @@ -1081,17 +1080,14 @@ static int hns3vf_vlan_filter_configure(struct hns3_adapter *hns, uint16_t vlan_id, int on) { -#define HNS3VF_VLAN_MBX_MSG_LEN 5 + struct hns3_mbx_vlan_filter vlan_filter = {0}; struct hns3_hw *hw = &hns->hw; - uint8_t msg_data[HNS3VF_VLAN_MBX_MSG_LEN]; - uint16_t proto = htons(RTE_ETHER_TYPE_VLAN); - uint8_t is_kill = on ? 0 : 1; - msg_data[0] = is_kill; - memcpy(&msg_data[1], &vlan_id, sizeof(vlan_id)); - memcpy(&msg_data[3], &proto, sizeof(proto)); + 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, - msg_data, HNS3VF_VLAN_MBX_MSG_LEN, true, NULL, - 0); + (uint8_t *)&vlan_filter, sizeof(vlan_filter), + true, NULL, 0); } diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index f1743c195e..ad5ec555b3 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -12,6 +12,4 @@ #include "hns3_rxtx.h" -#define HNS3_CMD_CODE_OFFSET 2 - static const struct errno_respcode_map err_code_map[] = { {0, 0}, @@ -128,5 +126,4 @@ hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, struct hns3_cmd_desc desc; bool is_ring_vector_msg; - int offset; int ret; @@ -134,21 +131,23 @@ hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, /* first two bytes are reserved for code & subcode */ - if (msg_len > (HNS3_MBX_MAX_MSG_SIZE - HNS3_CMD_CODE_OFFSET)) { + 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_MAX_MSG_SIZE - HNS3_CMD_CODE_OFFSET); + 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[0] = code; + 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[1] = subcode; + req->msg.subcode = subcode; if (msg_data) { - offset = is_ring_vector_msg ? 1 : HNS3_CMD_CODE_OFFSET; - memcpy(&req->msg[offset], msg_data, msg_len); + if (is_ring_vector_msg) + memcpy(&req->msg.vector_id, msg_data, msg_len); + else + memcpy(&req->msg.data, msg_data, msg_len); } @@ -297,9 +296,6 @@ hns3pf_handle_link_change_event(struct hns3_hw *hw, struct hns3_mbx_vf_to_pf_cmd *req) { -#define LINK_STATUS_OFFSET 1 -#define LINK_FAIL_CODE_OFFSET 2 - - if (!req->msg[LINK_STATUS_OFFSET]) - hns3_link_fail_parse(hw, req->msg[LINK_FAIL_CODE_OFFSET]); + if (!req->msg.link_status) + hns3_link_fail_parse(hw, req->msg.link_fail_code); hns3_update_linkstatus_and_event(hw, true); diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h index 1d9a788df5..172b044575 100644 --- a/drivers/net/hns3/hns3_mbx.h +++ b/drivers/net/hns3/hns3_mbx.h @@ -86,5 +86,4 @@ enum hns3_mbx_link_fail_subcode { }; -#define HNS3_MBX_MAX_MSG_SIZE 16 #define HNS3_MBX_MAX_RESP_DATA_SIZE 8 #define HNS3_MBX_DEF_TIME_LIMIT_MS 500 @@ -104,4 +103,44 @@ struct hns3_mbx_resp_status { }; +struct hns3_ring_chain_param { + uint8_t ring_type; + uint8_t tqp_index; + uint8_t int_gl_index; +}; + +struct hns3_mbx_vlan_filter { + uint8_t is_kill; + uint16_t vlan_id; + uint16_t proto; +} __rte_packed; + +#define HNS3_MBX_MSG_MAX_DATA_SIZE 14 +#define HNS3_MBX_MAX_RING_CHAIN_PARAM_NUM 4 +struct hns3_vf_to_pf_msg { + uint8_t code; + union { + struct { + uint8_t subcode; + uint8_t data[HNS3_MBX_MSG_MAX_DATA_SIZE]; + }; + struct { + uint8_t en_bc; + uint8_t en_uc; + uint8_t en_mc; + uint8_t en_limit_promisc; + }; + struct { + uint8_t vector_id; + uint8_t ring_num; + struct hns3_ring_chain_param + ring_param[HNS3_MBX_MAX_RING_CHAIN_PARAM_NUM]; + }; + struct { + uint8_t link_status; + uint8_t link_fail_code; + }; + }; +}; + struct errno_respcode_map { uint16_t resp_code; @@ -119,5 +158,5 @@ struct hns3_mbx_vf_to_pf_cmd { uint8_t rsv2; uint16_t match_id; - uint8_t msg[HNS3_MBX_MAX_MSG_SIZE]; + struct hns3_vf_to_pf_msg msg; }; @@ -131,17 +170,4 @@ struct hns3_mbx_pf_to_vf_cmd { }; -struct hns3_ring_chain_param { - uint8_t ring_type; - uint8_t tqp_index; - uint8_t int_gl_index; -}; - -#define HNS3_MBX_MAX_RING_CHAIN_PARAM_NUM 4 -struct hns3_vf_bind_vector_msg { - uint8_t vector_id; - uint8_t ring_num; - struct hns3_ring_chain_param param[HNS3_MBX_MAX_RING_CHAIN_PARAM_NUM]; -}; - struct hns3_pf_rst_done_cmd { uint8_t pf_rst_done; -- 2.43.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-05 14:08:55.638027428 +0000 +++ 0041-net-hns3-refactor-VF-mailbox-message-struct.patch 2024-03-05 14:08:54.660520792 +0000 @@ -1 +1 @@ -From 692b35be121b724119da001d7ec4c0fabd51177b Mon Sep 17 00:00:00 2001 +From 8b31b471949f8919493fb991270832a30fe330f0 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 692b35be121b724119da001d7ec4c0fabd51177b ] + @@ -20 +21,0 @@ -Cc: stable@dpdk.org @@ -31 +32 @@ -index 916cc0fb1b..19e734ca8d 100644 +index 0d1d271f37..639a00615e 100644 @@ -34 +35 @@ -@@ -255,9 +255,10 @@ hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc, +@@ -335,9 +335,10 @@ hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc, @@ -50 +51 @@ -@@ -348,28 +349,26 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, +@@ -428,28 +429,26 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, @@ -92 +93 @@ -@@ -966,17 +965,14 @@ static int +@@ -1081,17 +1080,14 @@ static int @@ -176 +177 @@ -index 4a328802b9..59fb73abcc 100644 +index 1d9a788df5..172b044575 100644 @@ -179 +180 @@ -@@ -90,5 +90,4 @@ enum hns3_mbx_link_fail_subcode { +@@ -86,5 +86,4 @@ enum hns3_mbx_link_fail_subcode { @@ -185 +186 @@ -@@ -108,4 +107,44 @@ struct hns3_mbx_resp_status { +@@ -104,4 +103,44 @@ struct hns3_mbx_resp_status { @@ -230 +231 @@ -@@ -123,5 +162,5 @@ struct hns3_mbx_vf_to_pf_cmd { +@@ -119,5 +158,5 @@ struct hns3_mbx_vf_to_pf_cmd { @@ -237 +238 @@ -@@ -135,17 +174,4 @@ struct hns3_mbx_pf_to_vf_cmd { +@@ -131,17 +170,4 @@ struct hns3_mbx_pf_to_vf_cmd {