drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
Extension
.c
Size
89528 bytes
Lines
3474
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (actual_len > HCLGE_MOD_REG_INFO_LEN_MAX) {
			dev_info(dev, "length of reg(%s) is invalid, len=%d\n",
				 reg_info[i].reg_name, actual_len);
			continue;
		}

		pos = scnprintf(buf, HCLGE_MOD_REG_INFO_LEN_MAX, "%s",
				reg_info[i].reg_name);
		if (reg_info[i].has_suffix)
			pos += scnprintf(buf + pos,
					 HCLGE_MOD_REG_INFO_LEN_MAX - pos, "%u",
					 le32_to_cpu(desc->data[0]));
		pos += scnprintf(buf + pos,
				 HCLGE_MOD_REG_INFO_LEN_MAX - pos,
				 ":");
		for (j = 0; j < reg_info[i].group_size; j++) {
			offset = reg_info[i].reg_offset_group[j];
			index = offset % HCLGE_DESC_DATA_LEN;
			bd_idx = offset / HCLGE_DESC_DATA_LEN;
			pos += scnprintf(buf + pos,
					 HCLGE_MOD_REG_INFO_LEN_MAX - pos,
					 " %08x",
					 le32_to_cpu(desc[bd_idx].data[index]));
		}
		dev_info(dev, "%s\n", buf);
	}

	kfree(buf);
	return 0;
}

static bool hclge_err_mod_check_support_cmd(enum hclge_opcode_type opcode,
					    struct hclge_dev *hdev)
{
	if (opcode == HCLGE_OPC_DFX_GEN_REG &&
	    !hnae3_ae_dev_gen_reg_dfx_supported(hdev))
		return false;
	return true;
}

/* For each common msg, send cmdq to IMP and print result reg info.
 * If there is a parameter, loop it and request.
 */
static void
hclge_query_reg_info(struct hclge_dev *hdev,
		     struct hclge_mod_reg_common_msg *msg, u32 loop_time,
		     u32 *loop_para)
{
	int desc_len, i, ret;

	desc_len = msg->bd_num * sizeof(struct hclge_desc);
	msg->desc = kzalloc(desc_len, GFP_KERNEL);
	if (!msg->desc) {
		dev_err(&hdev->pdev->dev, "failed to query reg info, ret=%d",
			-ENOMEM);
		return;
	}

	for (i = 0; i < loop_time; i++) {
		ret = hclge_dbg_cmd_send(hdev, msg->desc, *loop_para,
					 msg->bd_num, msg->cmd);
		loop_para++;
		if (ret)
			continue;
		ret = hclge_print_mod_reg_info(&hdev->pdev->dev, msg->desc,
					       msg->result_regs,
					       msg->result_regs_size);
		if (ret)
			dev_err(&hdev->pdev->dev, "failed to print mod reg info, ret=%d\n",
				ret);
	}

	kfree(msg->desc);
}

static void hclge_query_reg_info_of_ssu(struct hclge_dev *hdev)
{
	u32 loop_para[HCLGE_MOD_MSG_PARA_ARRAY_MAX_SIZE] = {0};
	struct hclge_mod_reg_common_msg msg;
	u8 i, j, num, loop_time;

	num = ARRAY_SIZE(hclge_ssu_reg_common_msg);
	for (i = 0; i < num; i++) {
		msg = hclge_ssu_reg_common_msg[i];
		if (!hclge_err_mod_check_support_cmd(msg.cmd, hdev))
			continue;
		loop_time = 1;
		loop_para[0] = 0;
		if (msg.need_para) {
			loop_time = min(hdev->ae_dev->dev_specs.tnl_num,

Annotation

Implementation Notes