Commit 43a8088c authored by Hao Chen's avatar Hao Chen Committed by Jiantao Xiao
Browse files

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

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I84WFI


CVE: NA

----------------------------------------------------------------------

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

Signed-off-by: default avatarHao Chen <chenhao418@huawei.com>
parent 85c4ae5d
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -374,6 +374,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;
+8 −0
Original line number Diff line number Diff line
@@ -246,6 +246,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,
@@ -392,6 +395,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;
+40 −3
Original line number Diff line number Diff line
@@ -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)
@@ -29,9 +57,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,
	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,
+2 −0
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@

#include "hclge_main.h"

#define	HCLGE_DEVLINK_FW_SCC_LEN	32

struct hclge_devlink_priv {
	struct hclge_dev *hdev;
};
+18 −0
Original line number Diff line number Diff line
@@ -11276,6 +11276,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;
Loading