drivers/scsi/qla4xxx/ql4_bsg.c

Source file repositories/reference/linux-study-clean/drivers/scsi/qla4xxx/ql4_bsg.c

File Facts

System
Linux kernel
Corpus path
drivers/scsi/qla4xxx/ql4_bsg.c
Extension
.c
Size
24579 bytes
Lines
873
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

if (ha->idc_extend_tmo) {
			if (!wait_for_completion_timeout(&ha->idc_comp,
						(ha->idc_extend_tmo * HZ))) {
				ha->notify_idc_comp = 0;
				ha->notify_link_up_comp = 0;
				ql4_printk(KERN_WARNING, ha, "%s: Aborting: IDC Complete notification not received",
					   __func__);
				status = QLA_ERROR;
				goto exit_wait;
			} else {
				DEBUG2(ql4_printk(KERN_INFO, ha,
						  "%s: IDC Complete notification received\n",
						  __func__));
			}
		}
	} else {
		DEBUG2(ql4_printk(KERN_INFO, ha,
				  "%s: IDC Complete notification received\n",
				  __func__));
	}
	ha->notify_idc_comp = 0;

	if (wait_for_link) {
		if (!wait_for_completion_timeout(&ha->link_up_comp,
						 (IDC_COMP_TOV * HZ))) {
			ha->notify_link_up_comp = 0;
			ql4_printk(KERN_WARNING, ha, "%s: Aborting: LINK UP notification not received",
				   __func__);
			status = QLA_ERROR;
			goto exit_wait;
		} else {
			DEBUG2(ql4_printk(KERN_INFO, ha,
					  "%s: LINK UP notification received\n",
					  __func__));
		}
		ha->notify_link_up_comp = 0;
	}

exit_wait:
	return status;
}

static int qla4_83xx_pre_loopback_config(struct scsi_qla_host *ha,
					 uint32_t *mbox_cmd)
{
	uint32_t config = 0;
	int status = QLA_SUCCESS;

	DEBUG2(ql4_printk(KERN_INFO, ha, "%s: in\n", __func__));

	status = qla4_83xx_get_port_config(ha, &config);
	if (status != QLA_SUCCESS)
		goto exit_pre_loopback_config;

	DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Default port config=%08X\n",
			  __func__, config));

	if ((config & ENABLE_INTERNAL_LOOPBACK) ||
	    (config & ENABLE_EXTERNAL_LOOPBACK)) {
		ql4_printk(KERN_INFO, ha, "%s: Loopback diagnostics already in progress. Invalid request\n",
			   __func__);
		goto exit_pre_loopback_config;
	}

	if (mbox_cmd[1] == QL_DIAG_CMD_TEST_INT_LOOPBACK)
		config |= ENABLE_INTERNAL_LOOPBACK;

	if (mbox_cmd[1] == QL_DIAG_CMD_TEST_EXT_LOOPBACK)
		config |= ENABLE_EXTERNAL_LOOPBACK;

	config &= ~ENABLE_DCBX;

	DEBUG2(ql4_printk(KERN_INFO, ha, "%s: New port config=%08X\n",
			  __func__, config));

	ha->notify_idc_comp = 1;
	ha->notify_link_up_comp = 1;

	/* get the link state */
	qla4xxx_get_firmware_state(ha);

	status = qla4_83xx_set_port_config(ha, &config);
	if (status != QLA_SUCCESS) {
		ha->notify_idc_comp = 0;
		ha->notify_link_up_comp = 0;
		goto exit_pre_loopback_config;
	}
exit_pre_loopback_config:
	DEBUG2(ql4_printk(KERN_INFO, ha, "%s: status = %s\n", __func__,
			  STATUS(status)));

Annotation

Implementation Notes