Commit 4c3ae347 authored by Zihao Sheng's avatar Zihao Sheng Committed by mufengyan
Browse files

HNS3: Support debugfs dump fastpath info

driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I99GLS


CVE: NA

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

The current software lacks fastpath debug information,
so this patch adds the debugfs query fastpath information
function. By sending the cmdq command to query fastpath
configuration information and print it.

Signed-off-by: default avatarZihao Sheng <shengzihao1@huawei.com>
parent dbd08c19
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -387,6 +387,7 @@ enum hnae3_dbg_cmd {
	HNAE3_DBG_CMD_GUID_SPEC,
	HNAE3_DBG_CMD_IP_LIST,
	HNAE3_DBG_CMD_GUID_LIST,
	HNAE3_DBG_CMD_FASTPATH_INFO,
	HNAE3_DBG_CMD_UNKNOWN,
};

+10 −0
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@ static struct hns3_dbg_dentry_info ub_dbg_dentry[] = {
	{
		.name = "guid_tbl"
	},
	{
		.name = "fastpath_info"
	},
};

static int hns3_unic_dbg_file_init(struct hnae3_handle *handle, u32 cmd);
@@ -63,6 +66,13 @@ static const struct hns3_dbg_cmd_info ub_dbg_cmd[] = {
		.buf_len = HNS3_DBG_READ_LEN,
		.init = hns3_unic_dbg_file_init,
	},
	{
		.name = "fastpath_info",
		.cmd = HNAE3_DBG_CMD_FASTPATH_INFO,
		.dentry = UB_DBG_DENTRY_FASTPATH,
		.buf_len = HNS3_DBG_READ_LEN,
		.init = hns3_unic_dbg_file_init,
	},
};

static int hns3_unic_dbg_get_cmd_index(struct hns3_dbg_data *dbg_data,
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
enum hns3_dbg_ub_dentry_type {
	UB_DBG_DENTRY_IP,
	UB_DBG_DENTRY_GUID,
	UB_DBG_DENTRY_FASTPATH,
	UB_DBG_DENTRY_END,
};

+35 −0
Original line number Diff line number Diff line
@@ -2725,6 +2725,37 @@ static int hclge_dbg_dump_guid_list(struct hclge_dev *hdev, char *buf, int len)
	return 0;
}

static int hclge_dbg_dump_fastpath_info(struct hclge_dev *hdev, char *buf,
					int len)
{
	struct hclge_config_fastpath_cmd *fp_info;
	struct hclge_desc desc;
	int pos = 0;
	int ret;

	hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_COMM_CFG_FASTPATH, true);

	ret = hclge_cmd_send(&hdev->hw, &desc, 1);
	if (ret) {
		dev_err(&hdev->pdev->dev,
			"failed to dump fastpath_info, ret = %d\n", ret);
		return ret;
	}

	fp_info = (struct hclge_config_fastpath_cmd *)desc.data;

	pos += scnprintf(buf + pos, len - pos, "fastpath_en: %u\n",
			 fp_info->fastpath_en);
	pos += scnprintf(buf + pos, len - pos, "ssu_cfg_status: 0x%x\n",
			 le32_to_cpu(fp_info->ssu_cfg_status));
	pos += scnprintf(buf + pos, len - pos, "igu_cfg_status: 0x%x\n",
			 le32_to_cpu(fp_info->igu_cfg_status));
	pos += scnprintf(buf + pos, len - pos, "ppp_cfg_status: 0x%x\n",
			 le32_to_cpu(fp_info->ppp_cfg_status));

	return 0;
}

static const struct hclge_dbg_func hclge_dbg_cmd_func[] = {
	{
		.cmd = HNAE3_DBG_CMD_TM_NODES,
@@ -2894,6 +2925,10 @@ static const struct hclge_dbg_func hclge_dbg_cmd_func[] = {
		.cmd = HNAE3_DBG_CMD_GUID_LIST,
		.dbg_dump = hclge_dbg_dump_guid_list,
	},
	{
		.cmd = HNAE3_DBG_CMD_FASTPATH_INFO,
		.dbg_dump = hclge_dbg_dump_fastpath_info,
	},
};

int hclge_dbg_read_cmd(struct hnae3_handle *handle, enum hnae3_dbg_cmd cmd,