DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dengdui Huang <huangdengdui@huawei.com>
To: <dev@dpdk.org>
Cc: <stephen@networkplumber.org>, <lihuisong@huawei.com>,
	<fengchengwen@huawei.com>, <liuyonglong@huawei.com>
Subject: [PATCH 5/6] net/hns3: VF support discover multi-TCs capability
Date: Wed, 11 Jun 2025 16:18:59 +0800	[thread overview]
Message-ID: <20250611081900.3658421-6-huangdengdui@huawei.com> (raw)
In-Reply-To: <20250611081900.3658421-1-huangdengdui@huawei.com>

From: Chengwen Feng <fengchengwen@huawei.com>

The VF multi-TCs feature depends on firmware and PF driver, the
capability was set when:
1) Firmware report VF multi-TCs flag.
2) PF driver report VF multi-TCs flag.
3) PF driver support query multi-TCs info mailbox message.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
---
 drivers/net/hns3/hns3_cmd.c       |  5 ++++-
 drivers/net/hns3/hns3_cmd.h       |  2 ++
 drivers/net/hns3/hns3_dump.c      |  3 ++-
 drivers/net/hns3/hns3_ethdev.h    |  1 +
 drivers/net/hns3/hns3_ethdev_vf.c | 33 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_mbx.h       |  7 +++++++
 6 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c
index 398b75384e..ad4ef9e189 100644
--- a/drivers/net/hns3/hns3_cmd.c
+++ b/drivers/net/hns3/hns3_cmd.c
@@ -482,7 +482,8 @@ static void
 hns3_parse_capability(struct hns3_hw *hw,
 		      struct hns3_query_version_cmd *cmd)
 {
-	uint32_t caps = rte_le_to_cpu_32(cmd->caps[0]);
+	uint64_t caps = ((uint64_t)rte_le_to_cpu_32(cmd->caps[1]) << 32) |
+			rte_le_to_cpu_32(cmd->caps[0]);
 
 	if (hns3_get_bit(caps, HNS3_CAPS_FD_QUEUE_REGION_B))
 		hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B,
@@ -524,6 +525,8 @@ hns3_parse_capability(struct hns3_hw *hw,
 		hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_FC_AUTO_B, 1);
 	if (hns3_get_bit(caps, HNS3_CAPS_GRO_B))
 		hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_GRO_B, 1);
+	if (hns3_get_bit(caps, HNS3_CAPS_VF_MULTI_TCS_B))
+		hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_VF_MULTI_TCS_B, 1);
 }
 
 static uint32_t
diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h
index e21a2b652f..2a2ec155ea 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -326,6 +326,7 @@ enum HNS3_CAPS_BITS {
 	HNS3_CAPS_TM_B = 19,
 	HNS3_CAPS_GRO_B = 20,
 	HNS3_CAPS_FC_AUTO_B = 30,
+	HNS3_CAPS_VF_MULTI_TCS_B = 34,
 };
 
 /* Capabilities of VF dependent on the PF */
@@ -335,6 +336,7 @@ enum HNS3VF_CAPS_BITS {
 	 * in kernel side PF.
 	 */
 	HNS3VF_CAPS_VLAN_FLT_MOD_B = 0,
+	HNS3VF_CAPS_MULTI_TCS_B = 1,
 };
 
 enum HNS3_API_CAP_BITS {
diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c
index 63c6b4ef2c..678279e2ac 100644
--- a/drivers/net/hns3/hns3_dump.c
+++ b/drivers/net/hns3/hns3_dump.c
@@ -105,7 +105,8 @@ hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
 		{HNS3_DEV_SUPPORT_TM_B, "TM"},
 		{HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, "VF VLAN FILTER MOD"},
 		{HNS3_DEV_SUPPORT_FC_AUTO_B, "FC AUTO"},
-		{HNS3_DEV_SUPPORT_GRO_B, "GRO"}
+		{HNS3_DEV_SUPPORT_GRO_B, "GRO"},
+		{HNS3_DEV_SUPPORT_VF_MULTI_TCS_B, "VF MULTI TCS"},
 	};
 	uint32_t i;
 
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index d7a55c134f..d602bfa02f 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -916,6 +916,7 @@ enum hns3_dev_cap {
 	HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B,
 	HNS3_DEV_SUPPORT_FC_AUTO_B,
 	HNS3_DEV_SUPPORT_GRO_B,
+	HNS3_DEV_SUPPORT_VF_MULTI_TCS_B,
 };
 
 #define hns3_dev_get_support(hw, _name) \
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 632409c5d0..41d8252540 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -815,12 +815,45 @@ hns3vf_get_queue_info(struct hns3_hw *hw)
 	return hns3vf_check_tqp_info(hw);
 }
 
+static void
+hns3vf_update_multi_tcs_cap(struct hns3_hw *hw, uint32_t pf_multi_tcs_bit)
+{
+	uint8_t resp_msg[HNS3_MBX_MAX_RESP_DATA_SIZE];
+	struct hns3_vf_to_pf_msg req;
+	int ret;
+
+	if (!hns3_dev_get_support(hw, VF_MULTI_TCS))
+		return;
+
+	if (pf_multi_tcs_bit == 0) {
+		/*
+		 * Early PF driver versions may don't report
+		 * HNS3VF_CAPS_MULTI_TCS_B when VF query basic info, so clear
+		 * the corresponding capability bit.
+		 */
+		hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_VF_MULTI_TCS_B, 0);
+		return;
+	}
+
+	/*
+	 * Early PF driver versions may also report HNS3VF_CAPS_MULTI_TCS_B
+	 * when VF query basic info, but they don't support query TC info
+	 * mailbox message, so clear the corresponding capability bit.
+	 */
+	hns3vf_mbx_setup(&req, HNS3_MBX_GET_TC, HNS3_MBX_GET_PRIO_MAP);
+	ret = hns3vf_mbx_send(hw, &req, true, resp_msg, sizeof(resp_msg));
+	if (ret)
+		hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_VF_MULTI_TCS_B, 0);
+}
+
 static void
 hns3vf_update_caps(struct hns3_hw *hw, uint32_t caps)
 {
 	if (hns3_get_bit(caps, HNS3VF_CAPS_VLAN_FLT_MOD_B))
 		hns3_set_bit(hw->capability,
 				HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, 1);
+
+	hns3vf_update_multi_tcs_cap(hw, hns3_get_bit(caps, HNS3VF_CAPS_MULTI_TCS_B));
 }
 
 static int
diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h
index 651c6b9023..eec3dd2c7e 100644
--- a/drivers/net/hns3/hns3_mbx.h
+++ b/drivers/net/hns3/hns3_mbx.h
@@ -48,6 +48,9 @@ enum HNS3_MBX_OPCODE {
 
 	HNS3_MBX_HANDLE_VF_TBL = 38,    /* (VF -> PF) store/clear hw cfg tbl */
 	HNS3_MBX_GET_RING_VECTOR_MAP,   /* (VF -> PF) get ring-to-vector map */
+
+	HNS3_MBX_GET_TC = 47,           /* (VF -> PF) get tc info of PF configured */
+
 	HNS3_MBX_PUSH_LINK_STATUS = 201, /* (IMP -> PF) get port link status */
 };
 
@@ -59,6 +62,10 @@ struct hns3_basic_info {
 	uint32_t caps;
 };
 
+enum hns3_mbx_get_tc_subcode {
+	HNS3_MBX_GET_PRIO_MAP = 0, /* query priority to tc map */
+};
+
 /* below are per-VF mac-vlan subcodes */
 enum hns3_mbx_mac_vlan_subcode {
 	HNS3_MBX_MAC_VLAN_UC_MODIFY = 0,        /* modify UC mac addr */
-- 
2.33.0


  parent reply	other threads:[~2025-06-11  8:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11  8:18 [PATCH 0/6] net/hns3: VF support multi-TCs Dengdui Huang
2025-06-11  8:18 ` [PATCH 1/6] net/hns3: fix VF fail to config queue TC Dengdui Huang
2025-06-11  8:18 ` [PATCH 2/6] net/hns3: remove duplicate struct field Dengdui Huang
2025-06-11  8:18 ` [PATCH 3/6] net/hns3: refactor DCB module code Dengdui Huang
2025-06-11  8:18 ` [PATCH 4/6] net/hns3: VF support parse max TC number Dengdui Huang
2025-06-11  8:18 ` Dengdui Huang [this message]
2025-06-11  8:19 ` [PATCH 6/6] net/hns3: VF support multi-TCs configure Dengdui Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250611081900.3658421-6-huangdengdui@huawei.com \
    --to=huangdengdui@huawei.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=lihuisong@huawei.com \
    --cc=liuyonglong@huawei.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).