drivers/scsi/lpfc/lpfc_attr.c

Source file repositories/reference/linux-study-clean/drivers/scsi/lpfc/lpfc_attr.c

File Facts

System
Linux kernel
Corpus path
drivers/scsi/lpfc/lpfc_attr.c
Extension
.c
Size
229521 bytes
Lines
7589
Domain
Driver Families
Bucket
drivers/scsi
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

switch (phba->cmf_active_mode) {
		case LPFC_CFG_OFF:
			scnprintf(tmp, sizeof(tmp), "Active: Mode:Off\n");
			break;
		case LPFC_CFG_MANAGED:
			scnprintf(tmp, sizeof(tmp), "Active: Mode:Managed\n");
			break;
		case LPFC_CFG_MONITOR:
			scnprintf(tmp, sizeof(tmp), "Active: Mode:Monitor\n");
			break;
		default:
			scnprintf(tmp, sizeof(tmp), "Active: Mode:Unknown\n");
		}
		if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
			goto buffer_done;
	}

	switch (phba->cgn_p.cgn_param_mode) {
	case LPFC_CFG_OFF:
		scnprintf(tmp, sizeof(tmp), "Config: Mode:Off  ");
		break;
	case LPFC_CFG_MANAGED:
		scnprintf(tmp, sizeof(tmp), "Config: Mode:Managed ");
		break;
	case LPFC_CFG_MONITOR:
		scnprintf(tmp, sizeof(tmp), "Config: Mode:Monitor ");
		break;
	default:
		scnprintf(tmp, sizeof(tmp), "Config: Mode:Unknown ");
	}
	if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
		goto buffer_done;

	total = 0;
	rcv = 0;
	for_each_present_cpu(cpu) {
		cgs = per_cpu_ptr(phba->cmf_stat, cpu);
		total += atomic64_read(&cgs->total_bytes);
		rcv += atomic64_read(&cgs->rcv_bytes);
	}

	scnprintf(tmp, sizeof(tmp),
		  "IObusy:%d Info:%d Bytes: Rcv:x%llx Total:x%llx\n",
		  atomic_read(&phba->cmf_busy),
		  phba->cmf_active_info, rcv, total);
	if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE)
		goto buffer_done;

	scnprintf(tmp, sizeof(tmp),
		  "Port_speed:%d  Link_byte_cnt:%ld  "
		  "Max_byte_per_interval:%ld\n",
		  lpfc_sli_port_speed_get(phba),
		  (unsigned long)phba->cmf_link_byte_count,
		  (unsigned long)phba->cmf_max_bytes_per_interval);
	strlcat(buf, tmp, PAGE_SIZE);

buffer_done:
	len = strnlen(buf, PAGE_SIZE);

	if (unlikely(len >= (PAGE_SIZE - 1))) {
		lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
				"6312 Catching potential buffer "
				"overflow > PAGE_SIZE = %lu bytes\n",
				PAGE_SIZE);
		strscpy(buf + PAGE_SIZE - 1 - sizeof(LPFC_INFO_MORE_STR),
			LPFC_INFO_MORE_STR, sizeof(LPFC_INFO_MORE_STR) + 1);
	}
	return len;
}

static ssize_t
lpfc_vmid_info_show(struct device *dev, struct device_attribute *attr,
		    char *buf)
{
	struct Scsi_Host  *shost = class_to_shost(dev);
	struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
	struct lpfc_hba   *phba = vport->phba;
	struct lpfc_vmid  *vmp;
	int  len = 0, i, j, k, cpu;
	char hxstr[LPFC_MAX_VMID_SIZE * 3] = {0};
	struct timespec64 curr_tm;
	struct lpfc_vmid_priority_range *vr;
	u64 *lta, rct_acc = 0, max_lta = 0;
	struct tm tm_val;

	ktime_get_ts64(&curr_tm);

	len += scnprintf(buf + len, PAGE_SIZE - len, "Key 'vmid':\n");

	/* if enabled continue, else return */

Annotation

Implementation Notes