diff mbox series

[V7,net-next,4/4] net: hns3: add support to query scc version by devlink info

Message ID 20240410125354.2177067-5-shaojijie@huawei.com (mailing list archive)
State Accepted
Commit a1e5de0d07a3b2db047fe8ba0063d129672f979a
Delegated to: Netdev Maintainers
Headers show
Series Support some features for the HNS3 ethernet driver | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 942 this patch: 942
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 3 maintainers not CCed: linux-doc@vger.kernel.org lanhao@huawei.com corbet@lwn.net
netdev/build_clang success Errors and warnings before: 953 this patch: 953
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 954 this patch: 954
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 140 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-12--06-00 (tests: 962)

Commit Message

Jijie Shao April 10, 2024, 12:53 p.m. UTC
From: Hao Chen <chenhao418@huawei.com>

Add support to query scc version by devlink info for device V3.

Signed-off-by: Hao Chen <chenhao418@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
 Documentation/networking/devlink/hns3.rst     |  3 ++
 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  9 ++++
 .../hns3/hns3_common/hclge_comm_cmd.h         |  8 ++++
 .../hisilicon/hns3/hns3pf/hclge_devlink.c     | 44 +++++++++++++++++--
 .../hisilicon/hns3/hns3pf/hclge_devlink.h     |  2 +
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 18 ++++++++
 .../hisilicon/hns3/hns3pf/hclge_main.h        |  1 +
 7 files changed, 82 insertions(+), 3 deletions(-)

Comments

Jiri Pirko April 10, 2024, 2:59 p.m. UTC | #1
Wed, Apr 10, 2024 at 02:53:54PM CEST, shaojijie@huawei.com wrote:
>From: Hao Chen <chenhao418@huawei.com>
>
>Add support to query scc version by devlink info for device V3.
>
>Signed-off-by: Hao Chen <chenhao418@huawei.com>
>Signed-off-by: Jijie Shao <shaojijie@huawei.com>
>---
> Documentation/networking/devlink/hns3.rst     |  3 ++
> drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  9 ++++
> .../hns3/hns3_common/hclge_comm_cmd.h         |  8 ++++
> .../hisilicon/hns3/hns3pf/hclge_devlink.c     | 44 +++++++++++++++++--
> .../hisilicon/hns3/hns3pf/hclge_devlink.h     |  2 +
> .../hisilicon/hns3/hns3pf/hclge_main.c        | 18 ++++++++
> .../hisilicon/hns3/hns3pf/hclge_main.h        |  1 +
> 7 files changed, 82 insertions(+), 3 deletions(-)
>
>diff --git a/Documentation/networking/devlink/hns3.rst b/Documentation/networking/devlink/hns3.rst
>index 4562a6e4782f..e19dea8ef924 100644
>--- a/Documentation/networking/devlink/hns3.rst
>+++ b/Documentation/networking/devlink/hns3.rst
>@@ -23,3 +23,6 @@ The ``hns3`` driver reports the following versions
>    * - ``fw``
>      - running
>      - Used to represent the firmware version.
>+   * - ``fw.scc``

What's scc? I don't see it described anywhere.
Jijie Shao April 11, 2024, 1:05 a.m. UTC | #2
on 2024/4/10 22:59, Jiri Pirko wrote:
> Wed, Apr 10, 2024 at 02:53:54PM CEST, shaojijie@huawei.com wrote:
>> From: Hao Chen <chenhao418@huawei.com>
>>
>> Add support to query scc version by devlink info for device V3.
>>
>> Signed-off-by: Hao Chen <chenhao418@huawei.com>
>> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
>> ---
>> Documentation/networking/devlink/hns3.rst     |  3 ++
>> drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  9 ++++
>> .../hns3/hns3_common/hclge_comm_cmd.h         |  8 ++++
>> .../hisilicon/hns3/hns3pf/hclge_devlink.c     | 44 +++++++++++++++++--
>> .../hisilicon/hns3/hns3pf/hclge_devlink.h     |  2 +
>> .../hisilicon/hns3/hns3pf/hclge_main.c        | 18 ++++++++
>> .../hisilicon/hns3/hns3pf/hclge_main.h        |  1 +
>> 7 files changed, 82 insertions(+), 3 deletions(-)
>>
>> diff --git a/Documentation/networking/devlink/hns3.rst b/Documentation/networking/devlink/hns3.rst
>> index 4562a6e4782f..e19dea8ef924 100644
>> --- a/Documentation/networking/devlink/hns3.rst
>> +++ b/Documentation/networking/devlink/hns3.rst
>> @@ -23,3 +23,6 @@ The ``hns3`` driver reports the following versions
>>     * - ``fw``
>>       - running
>>       - Used to represent the firmware version.
>> +   * - ``fw.scc``
> What's scc? I don't see it described anywhere.

diff --git a/Documentation/networking/devlink/hns3.rst b/Documentation/networking/devlink/hns3.rst
index 4562a6e4782f..e19dea8ef924 100644
--- a/Documentation/networking/devlink/hns3.rst
+++ b/Documentation/networking/devlink/hns3.rst
@@ -23,3 +23,6 @@ The ``hns3`` driver reports the following versions
     * - ``fw``
       - running
       - Used to represent the firmware version.
+   * - ``fw.scc``
+     - running
+     - Used to represent the soft congestion control firmware version.

scc means "soft congestion control"
Jiri Pirko April 11, 2024, 6:23 a.m. UTC | #3
Thu, Apr 11, 2024 at 03:05:53AM CEST, shaojijie@huawei.com wrote:
>
>on 2024/4/10 22:59, Jiri Pirko wrote:
>> Wed, Apr 10, 2024 at 02:53:54PM CEST, shaojijie@huawei.com wrote:
>> > From: Hao Chen <chenhao418@huawei.com>
>> > 
>> > Add support to query scc version by devlink info for device V3.
>> > 
>> > Signed-off-by: Hao Chen <chenhao418@huawei.com>
>> > Signed-off-by: Jijie Shao <shaojijie@huawei.com>
>> > ---
>> > Documentation/networking/devlink/hns3.rst     |  3 ++
>> > drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  9 ++++
>> > .../hns3/hns3_common/hclge_comm_cmd.h         |  8 ++++
>> > .../hisilicon/hns3/hns3pf/hclge_devlink.c     | 44 +++++++++++++++++--
>> > .../hisilicon/hns3/hns3pf/hclge_devlink.h     |  2 +
>> > .../hisilicon/hns3/hns3pf/hclge_main.c        | 18 ++++++++
>> > .../hisilicon/hns3/hns3pf/hclge_main.h        |  1 +
>> > 7 files changed, 82 insertions(+), 3 deletions(-)
>> > 
>> > diff --git a/Documentation/networking/devlink/hns3.rst b/Documentation/networking/devlink/hns3.rst
>> > index 4562a6e4782f..e19dea8ef924 100644
>> > --- a/Documentation/networking/devlink/hns3.rst
>> > +++ b/Documentation/networking/devlink/hns3.rst
>> > @@ -23,3 +23,6 @@ The ``hns3`` driver reports the following versions
>> >     * - ``fw``
>> >       - running
>> >       - Used to represent the firmware version.
>> > +   * - ``fw.scc``
>> What's scc? I don't see it described anywhere.
>
>diff --git a/Documentation/networking/devlink/hns3.rst b/Documentation/networking/devlink/hns3.rst
>index 4562a6e4782f..e19dea8ef924 100644
>--- a/Documentation/networking/devlink/hns3.rst
>+++ b/Documentation/networking/devlink/hns3.rst
>@@ -23,3 +23,6 @@ The ``hns3`` driver reports the following versions
>    * - ``fw``
>      - running
>      - Used to represent the firmware version.
>+   * - ``fw.scc``
>+     - running
>+     - Used to represent the soft congestion control firmware version.
>
>scc means "soft congestion control"

I guess this is something specific to your device, isn't it? Can't you
please extend the description a bit more?

Thanks!

>
Jijie Shao April 12, 2024, 7:12 a.m. UTC | #4
on 2024/4/11 14:23, Jiri Pirko wrote:
> Thu, Apr 11, 2024 at 03:05:53AM CEST, shaojijie@huawei.com wrote:
>> on 2024/4/10 22:59, Jiri Pirko wrote:
>>> Wed, Apr 10, 2024 at 02:53:54PM CEST, shaojijie@huawei.com wrote:
>>>> From: Hao Chen <chenhao418@huawei.com>
>>>>
>>>> Add support to query scc version by devlink info for device V3.
>>>>
>>>> Signed-off-by: Hao Chen <chenhao418@huawei.com>
>>>> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
>>>> ---
>>>> Documentation/networking/devlink/hns3.rst     |  3 ++
>>>> drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  9 ++++
>>>> .../hns3/hns3_common/hclge_comm_cmd.h         |  8 ++++
>>>> .../hisilicon/hns3/hns3pf/hclge_devlink.c     | 44 +++++++++++++++++--
>>>> .../hisilicon/hns3/hns3pf/hclge_devlink.h     |  2 +
>>>> .../hisilicon/hns3/hns3pf/hclge_main.c        | 18 ++++++++
>>>> .../hisilicon/hns3/hns3pf/hclge_main.h        |  1 +
>>>> 7 files changed, 82 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/Documentation/networking/devlink/hns3.rst b/Documentation/networking/devlink/hns3.rst
>>>> index 4562a6e4782f..e19dea8ef924 100644
>>>> --- a/Documentation/networking/devlink/hns3.rst
>>>> +++ b/Documentation/networking/devlink/hns3.rst
>>>> @@ -23,3 +23,6 @@ The ``hns3`` driver reports the following versions
>>>>      * - ``fw``
>>>>        - running
>>>>        - Used to represent the firmware version.
>>>> +   * - ``fw.scc``
>>> What's scc? I don't see it described anywhere.
>> diff --git a/Documentation/networking/devlink/hns3.rst b/Documentation/networking/devlink/hns3.rst
>> index 4562a6e4782f..e19dea8ef924 100644
>> --- a/Documentation/networking/devlink/hns3.rst
>> +++ b/Documentation/networking/devlink/hns3.rst
>> @@ -23,3 +23,6 @@ The ``hns3`` driver reports the following versions
>>     * - ``fw``
>>       - running
>>       - Used to represent the firmware version.
>> +   * - ``fw.scc``
>> +     - running
>> +     - Used to represent the soft congestion control firmware version.
>>
>> scc means "soft congestion control"
> I guess this is something specific to your device, isn't it? Can't you
> please extend the description a bit more?
>
> Thanks!
>
SCC is a firmware which provides multiple congestion control algorithms, including dcqcn.
Congestion control is a mechanism that controls the entry of rdma packets into the network,
enabling a better use of a shared network infrastructure and avoiding congestive collapse.


Jijie Shao
Jakub Kicinski April 13, 2024, 2 a.m. UTC | #5
On Fri, 12 Apr 2024 15:12:17 +0800 Jijie Shao wrote:
> >> +   * - ``fw.scc``
> >> +     - running
> >> +     - Used to represent the soft congestion control firmware version.
> >>
> >> scc means "soft congestion control"  
> > I guess this is something specific to your device, isn't it? Can't you
> > please extend the description a bit more?
> >
> SCC is a firmware which provides multiple congestion control algorithms, including dcqcn.
> Congestion control is a mechanism that controls the entry of rdma packets into the network,
> enabling a better use of a shared network infrastructure and avoiding congestive collapse.

Thanks, I'll amend the patch with a condensed version of this info.
Otherwise I feel like we'll need another 3 revisions to polish it..
diff mbox series

Patch

diff --git a/Documentation/networking/devlink/hns3.rst b/Documentation/networking/devlink/hns3.rst
index 4562a6e4782f..e19dea8ef924 100644
--- a/Documentation/networking/devlink/hns3.rst
+++ b/Documentation/networking/devlink/hns3.rst
@@ -23,3 +23,6 @@  The ``hns3`` driver reports the following versions
    * - ``fw``
      - running
      - Used to represent the firmware version.
+   * - ``fw.scc``
+     - running
+     - Used to represent the soft congestion control firmware version.
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index e9266c65b331..7c2c8bea4c06 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -366,6 +366,15 @@  struct hnae3_vector_info {
 #define HNAE3_FW_VERSION_BYTE0_SHIFT	0
 #define HNAE3_FW_VERSION_BYTE0_MASK	GENMASK(7, 0)
 
+#define HNAE3_SCC_VERSION_BYTE3_SHIFT	24
+#define HNAE3_SCC_VERSION_BYTE3_MASK	GENMASK(31, 24)
+#define HNAE3_SCC_VERSION_BYTE2_SHIFT	16
+#define HNAE3_SCC_VERSION_BYTE2_MASK	GENMASK(23, 16)
+#define HNAE3_SCC_VERSION_BYTE1_SHIFT	8
+#define HNAE3_SCC_VERSION_BYTE1_MASK	GENMASK(15, 8)
+#define HNAE3_SCC_VERSION_BYTE0_SHIFT	0
+#define HNAE3_SCC_VERSION_BYTE0_MASK	GENMASK(7, 0)
+
 struct hnae3_ring_chain_node {
 	struct hnae3_ring_chain_node *next;
 	u32 tqp_index;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.h
index a2bc5a9adaa3..2c2a2f1e0d7a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.h
@@ -247,6 +247,9 @@  enum hclge_opcode_type {
 	HCLGE_OPC_QCN_AJUST_INIT	= 0x1A07,
 	HCLGE_OPC_QCN_DFX_CNT_STATUS    = 0x1A08,
 
+	/* SCC commands */
+	HCLGE_OPC_QUERY_SCC_VER		= 0x1A84,
+
 	/* Mailbox command */
 	HCLGEVF_OPC_MBX_PF_TO_VF	= 0x2000,
 	HCLGEVF_OPC_MBX_VF_TO_PF	= 0x2001,
@@ -394,6 +397,11 @@  struct hclge_comm_query_version_cmd {
 	__le32 caps[HCLGE_COMM_QUERY_CAP_LENGTH]; /* capabilities of device */
 };
 
+struct hclge_comm_query_scc_cmd {
+	__le32 scc_version;
+	u8 rsv[20];
+};
+
 #define HCLGE_DESC_DATA_LEN		6
 struct hclge_desc {
 	__le16 opcode;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c
index 9a939c0b217f..a1571c108678 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c
@@ -5,6 +5,34 @@ 
 
 #include "hclge_devlink.h"
 
+static int hclge_devlink_scc_info_get(struct devlink *devlink,
+				      struct devlink_info_req *req)
+{
+	struct hclge_devlink_priv *priv = devlink_priv(devlink);
+	char scc_version[HCLGE_DEVLINK_FW_SCC_LEN];
+	struct hclge_dev *hdev = priv->hdev;
+	u32 scc_version_tmp;
+	int ret;
+
+	ret = hclge_query_scc_version(hdev, &scc_version_tmp);
+	if (ret) {
+		dev_err(&hdev->pdev->dev,
+			"failed to get scc version, ret = %d\n", ret);
+		return ret;
+	}
+
+	snprintf(scc_version, sizeof(scc_version), "%lu.%lu.%lu.%lu",
+		 hnae3_get_field(scc_version_tmp, HNAE3_SCC_VERSION_BYTE3_MASK,
+				 HNAE3_FW_VERSION_BYTE3_SHIFT),
+		 hnae3_get_field(scc_version_tmp, HNAE3_SCC_VERSION_BYTE2_MASK,
+				 HNAE3_FW_VERSION_BYTE2_SHIFT),
+		 hnae3_get_field(scc_version_tmp, HNAE3_SCC_VERSION_BYTE1_MASK,
+				 HNAE3_FW_VERSION_BYTE1_SHIFT),
+		 hnae3_get_field(scc_version_tmp, HNAE3_SCC_VERSION_BYTE0_MASK,
+				 HNAE3_FW_VERSION_BYTE0_SHIFT));
+	return devlink_info_version_running_put(req, "fw.scc", scc_version);
+}
+
 static int hclge_devlink_info_get(struct devlink *devlink,
 				  struct devlink_info_req *req,
 				  struct netlink_ext_ack *extack)
@@ -13,6 +41,7 @@  static int hclge_devlink_info_get(struct devlink *devlink,
 	struct hclge_devlink_priv *priv = devlink_priv(devlink);
 	char version_str[HCLGE_DEVLINK_FW_STRING_LEN];
 	struct hclge_dev *hdev = priv->hdev;
+	int ret;
 
 	snprintf(version_str, sizeof(version_str), "%lu.%lu.%lu.%lu",
 		 hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE3_MASK,
@@ -24,9 +53,18 @@  static int hclge_devlink_info_get(struct devlink *devlink,
 		 hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE0_MASK,
 				 HNAE3_FW_VERSION_BYTE0_SHIFT));
 
-	return devlink_info_version_running_put(req,
-						DEVLINK_INFO_VERSION_GENERIC_FW,
-						version_str);
+	ret = devlink_info_version_running_put(req,
+					       DEVLINK_INFO_VERSION_GENERIC_FW,
+					       version_str);
+	if (ret) {
+		dev_err(&hdev->pdev->dev, "failed to set running version of fw\n");
+		return ret;
+	}
+
+	if (hdev->pdev->revision > HNAE3_DEVICE_VERSION_V2)
+		ret = hclge_devlink_scc_info_get(devlink, req);
+
+	return ret;
 }
 
 static int hclge_devlink_reload_down(struct devlink *devlink, bool netns_change,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.h
index 918be04507a5..148effa5ea89 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.h
@@ -6,6 +6,8 @@ 
 
 #include "hclge_main.h"
 
+#define	HCLGE_DEVLINK_FW_SCC_LEN	32
+
 struct hclge_devlink_priv {
 	struct hclge_dev *hdev;
 };
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index eb31a7e9c8fc..28336cf17170 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -10883,6 +10883,24 @@  static u32 hclge_get_fw_version(struct hnae3_handle *handle)
 	return hdev->fw_version;
 }
 
+int hclge_query_scc_version(struct hclge_dev *hdev, u32 *scc_version)
+{
+	struct hclge_comm_query_scc_cmd *resp;
+	struct hclge_desc desc;
+	int ret;
+
+	hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_QUERY_SCC_VER, 1);
+	resp = (struct hclge_comm_query_scc_cmd *)desc.data;
+
+	ret = hclge_cmd_send(&hdev->hw, &desc, 1);
+	if (ret)
+		return ret;
+
+	*scc_version = le32_to_cpu(resp->scc_version);
+
+	return 0;
+}
+
 static void hclge_set_flowctrl_adv(struct hclge_dev *hdev, u32 rx_en, u32 tx_en)
 {
 	struct phy_device *phydev = hdev->hw.mac.phydev;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index e821dd2f1528..df3c10098349 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -1169,4 +1169,5 @@  int hclge_enable_vport_vlan_filter(struct hclge_vport *vport, bool request_en);
 int hclge_mac_update_stats(struct hclge_dev *hdev);
 struct hclge_vport *hclge_get_vf_vport(struct hclge_dev *hdev, int vf);
 int hclge_inform_vf_reset(struct hclge_vport *vport, u16 reset_type);
+int hclge_query_scc_version(struct hclge_dev *hdev, u32 *scc_version);
 #endif