drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

Source file repositories/reference/linux-study-clean/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

File Facts

System
Linux kernel
Corpus path
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
Extension
.c
Size
155263 bytes
Lines
5340
Domain
Driver Families
Bucket
drivers/scsi
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

static const struct file_operations debugfs_trigger_dump_v3_hw_fops = {
	.write = &debugfs_trigger_dump_v3_hw_write,
	.owner = THIS_MODULE,
};

enum {
	HISI_SAS_BIST_LOOPBACK_MODE_DIGITAL = 0,
	HISI_SAS_BIST_LOOPBACK_MODE_SERDES,
	HISI_SAS_BIST_LOOPBACK_MODE_REMOTE,
};

static const struct {
	int		value;
	char		*name;
} debugfs_loop_linkrate_v3_hw[] = {
	{ SAS_LINK_RATE_1_5_GBPS, "1.5 Gbit" },
	{ SAS_LINK_RATE_3_0_GBPS, "3.0 Gbit" },
	{ SAS_LINK_RATE_6_0_GBPS, "6.0 Gbit" },
	{ SAS_LINK_RATE_12_0_GBPS, "12.0 Gbit" },
};

static int debugfs_bist_linkrate_v3_hw_show(struct seq_file *s, void *p)
{
	struct hisi_hba *hisi_hba = s->private;
	int i;

	for (i = 0; i < ARRAY_SIZE(debugfs_loop_linkrate_v3_hw); i++) {
		int match = (hisi_hba->debugfs_bist_linkrate ==
			     debugfs_loop_linkrate_v3_hw[i].value);

		seq_printf(s, "%s%s%s ", match ? "[" : "",
			   debugfs_loop_linkrate_v3_hw[i].name,
			   match ? "]" : "");
	}
	seq_puts(s, "\n");

	return 0;
}

static ssize_t debugfs_bist_linkrate_v3_hw_write(struct file *filp,
						 const char __user *buf,
						 size_t count, loff_t *ppos)
{
	struct seq_file *m = filp->private_data;
	struct hisi_hba *hisi_hba = m->private;
	char kbuf[BIST_BUF_SIZE] = {}, *pkbuf;
	bool found = false;
	int i;

	if (hisi_hba->debugfs_bist_enable)
		return -EPERM;

	if (count >= sizeof(kbuf))
		return -EOVERFLOW;

	if (copy_from_user(kbuf, buf, count))
		return -EINVAL;

	pkbuf = strstrip(kbuf);

	for (i = 0; i < ARRAY_SIZE(debugfs_loop_linkrate_v3_hw); i++) {
		if (!strncmp(debugfs_loop_linkrate_v3_hw[i].name,
			     pkbuf, BIST_BUF_SIZE)) {
			hisi_hba->debugfs_bist_linkrate =
				debugfs_loop_linkrate_v3_hw[i].value;
			found = true;
			break;
		}
	}

	if (!found)
		return -EINVAL;

	return count;
}
DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_linkrate_v3_hw);

static const struct {
	int		value;
	char		*name;
} debugfs_loop_code_mode_v3_hw[] = {
	{ HISI_SAS_BIST_CODE_MODE_PRBS7, "PRBS7" },
	{ HISI_SAS_BIST_CODE_MODE_PRBS23, "PRBS23" },
	{ HISI_SAS_BIST_CODE_MODE_PRBS31, "PRBS31" },
	{ HISI_SAS_BIST_CODE_MODE_JTPAT, "JTPAT" },
	{ HISI_SAS_BIST_CODE_MODE_CJTPAT, "CJTPAT" },
	{ HISI_SAS_BIST_CODE_MODE_SCRAMBED_0, "SCRAMBED_0" },
	{ HISI_SAS_BIST_CODE_MODE_TRAIN, "TRAIN" },
	{ HISI_SAS_BIST_CODE_MODE_TRAIN_DONE, "TRAIN_DONE" },
	{ HISI_SAS_BIST_CODE_MODE_HFTP, "HFTP" },

Annotation

Implementation Notes