Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: hns3: add support to query scc version by devlink info

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>
Link: https://lore.kernel.org/r/20240410125354.2177067-5-shaojijie@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Hao Chen and committed by
Jakub Kicinski
a1e5de0d 8a4bda8c

+84 -3
+5
Documentation/networking/devlink/hns3.rst
··· 23 23 * - ``fw`` 24 24 - running 25 25 - Used to represent the firmware version. 26 + * - ``fw.scc`` 27 + - running 28 + - Used to represent the Soft Congestion Control (SSC) firmware version. 29 + SCC is a firmware component which provides multiple RDMA congestion 30 + control algorithms, including DCQCN.
+9
drivers/net/ethernet/hisilicon/hns3/hnae3.h
··· 366 366 #define HNAE3_FW_VERSION_BYTE0_SHIFT 0 367 367 #define HNAE3_FW_VERSION_BYTE0_MASK GENMASK(7, 0) 368 368 369 + #define HNAE3_SCC_VERSION_BYTE3_SHIFT 24 370 + #define HNAE3_SCC_VERSION_BYTE3_MASK GENMASK(31, 24) 371 + #define HNAE3_SCC_VERSION_BYTE2_SHIFT 16 372 + #define HNAE3_SCC_VERSION_BYTE2_MASK GENMASK(23, 16) 373 + #define HNAE3_SCC_VERSION_BYTE1_SHIFT 8 374 + #define HNAE3_SCC_VERSION_BYTE1_MASK GENMASK(15, 8) 375 + #define HNAE3_SCC_VERSION_BYTE0_SHIFT 0 376 + #define HNAE3_SCC_VERSION_BYTE0_MASK GENMASK(7, 0) 377 + 369 378 struct hnae3_ring_chain_node { 370 379 struct hnae3_ring_chain_node *next; 371 380 u32 tqp_index;
+8
drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.h
··· 247 247 HCLGE_OPC_QCN_AJUST_INIT = 0x1A07, 248 248 HCLGE_OPC_QCN_DFX_CNT_STATUS = 0x1A08, 249 249 250 + /* SCC commands */ 251 + HCLGE_OPC_QUERY_SCC_VER = 0x1A84, 252 + 250 253 /* Mailbox command */ 251 254 HCLGEVF_OPC_MBX_PF_TO_VF = 0x2000, 252 255 HCLGEVF_OPC_MBX_VF_TO_PF = 0x2001, ··· 395 392 __le32 hardware; 396 393 __le32 api_caps; 397 394 __le32 caps[HCLGE_COMM_QUERY_CAP_LENGTH]; /* capabilities of device */ 395 + }; 396 + 397 + struct hclge_comm_query_scc_cmd { 398 + __le32 scc_version; 399 + u8 rsv[20]; 398 400 }; 399 401 400 402 #define HCLGE_DESC_DATA_LEN 6
+41 -3
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c
··· 5 5 6 6 #include "hclge_devlink.h" 7 7 8 + static int hclge_devlink_scc_info_get(struct devlink *devlink, 9 + struct devlink_info_req *req) 10 + { 11 + struct hclge_devlink_priv *priv = devlink_priv(devlink); 12 + char scc_version[HCLGE_DEVLINK_FW_SCC_LEN]; 13 + struct hclge_dev *hdev = priv->hdev; 14 + u32 scc_version_tmp; 15 + int ret; 16 + 17 + ret = hclge_query_scc_version(hdev, &scc_version_tmp); 18 + if (ret) { 19 + dev_err(&hdev->pdev->dev, 20 + "failed to get scc version, ret = %d\n", ret); 21 + return ret; 22 + } 23 + 24 + snprintf(scc_version, sizeof(scc_version), "%lu.%lu.%lu.%lu", 25 + hnae3_get_field(scc_version_tmp, HNAE3_SCC_VERSION_BYTE3_MASK, 26 + HNAE3_FW_VERSION_BYTE3_SHIFT), 27 + hnae3_get_field(scc_version_tmp, HNAE3_SCC_VERSION_BYTE2_MASK, 28 + HNAE3_FW_VERSION_BYTE2_SHIFT), 29 + hnae3_get_field(scc_version_tmp, HNAE3_SCC_VERSION_BYTE1_MASK, 30 + HNAE3_FW_VERSION_BYTE1_SHIFT), 31 + hnae3_get_field(scc_version_tmp, HNAE3_SCC_VERSION_BYTE0_MASK, 32 + HNAE3_FW_VERSION_BYTE0_SHIFT)); 33 + return devlink_info_version_running_put(req, "fw.scc", scc_version); 34 + } 35 + 8 36 static int hclge_devlink_info_get(struct devlink *devlink, 9 37 struct devlink_info_req *req, 10 38 struct netlink_ext_ack *extack) ··· 41 13 struct hclge_devlink_priv *priv = devlink_priv(devlink); 42 14 char version_str[HCLGE_DEVLINK_FW_STRING_LEN]; 43 15 struct hclge_dev *hdev = priv->hdev; 16 + int ret; 44 17 45 18 snprintf(version_str, sizeof(version_str), "%lu.%lu.%lu.%lu", 46 19 hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE3_MASK, ··· 53 24 hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE0_MASK, 54 25 HNAE3_FW_VERSION_BYTE0_SHIFT)); 55 26 56 - return devlink_info_version_running_put(req, 57 - DEVLINK_INFO_VERSION_GENERIC_FW, 58 - version_str); 27 + ret = devlink_info_version_running_put(req, 28 + DEVLINK_INFO_VERSION_GENERIC_FW, 29 + version_str); 30 + if (ret) { 31 + dev_err(&hdev->pdev->dev, "failed to set running version of fw\n"); 32 + return ret; 33 + } 34 + 35 + if (hdev->pdev->revision > HNAE3_DEVICE_VERSION_V2) 36 + ret = hclge_devlink_scc_info_get(devlink, req); 37 + 38 + return ret; 59 39 } 60 40 61 41 static int hclge_devlink_reload_down(struct devlink *devlink, bool netns_change,
+2
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.h
··· 6 6 7 7 #include "hclge_main.h" 8 8 9 + #define HCLGE_DEVLINK_FW_SCC_LEN 32 10 + 9 11 struct hclge_devlink_priv { 10 12 struct hclge_dev *hdev; 11 13 };
+18
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 10883 10883 return hdev->fw_version; 10884 10884 } 10885 10885 10886 + int hclge_query_scc_version(struct hclge_dev *hdev, u32 *scc_version) 10887 + { 10888 + struct hclge_comm_query_scc_cmd *resp; 10889 + struct hclge_desc desc; 10890 + int ret; 10891 + 10892 + hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_QUERY_SCC_VER, 1); 10893 + resp = (struct hclge_comm_query_scc_cmd *)desc.data; 10894 + 10895 + ret = hclge_cmd_send(&hdev->hw, &desc, 1); 10896 + if (ret) 10897 + return ret; 10898 + 10899 + *scc_version = le32_to_cpu(resp->scc_version); 10900 + 10901 + return 0; 10902 + } 10903 + 10886 10904 static void hclge_set_flowctrl_adv(struct hclge_dev *hdev, u32 rx_en, u32 tx_en) 10887 10905 { 10888 10906 struct phy_device *phydev = hdev->hw.mac.phydev;
+1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
··· 1169 1169 int hclge_mac_update_stats(struct hclge_dev *hdev); 1170 1170 struct hclge_vport *hclge_get_vf_vport(struct hclge_dev *hdev, int vf); 1171 1171 int hclge_inform_vf_reset(struct hclge_vport *vport, u16 reset_type); 1172 + int hclge_query_scc_version(struct hclge_dev *hdev, u32 *scc_version); 1172 1173 #endif