ql4_isr.c

来自「linux 内核源代码」· C语言 代码 · 共 822 行 · 第 1/2 页

C
822
字号
	writel(ha->response_out, &ha->reg->rsp_q_out);	readl(&ha->reg->rsp_q_out);	set_bit(DPC_RESET_HA, &ha->dpc_flags);}/** * qla4xxx_isr_decode_mailbox - decodes mailbox status * @ha: Pointer to host adapter structure. * @mailbox_status: Mailbox status. * * This routine decodes the mailbox status during the ISR. * Hardware_lock locked upon entry. runs in interrupt context. **/static void qla4xxx_isr_decode_mailbox(struct scsi_qla_host * ha,				       uint32_t mbox_status){	int i;	uint32_t mbox_stat2, mbox_stat3;	if ((mbox_status == MBOX_STS_BUSY) ||	    (mbox_status == MBOX_STS_INTERMEDIATE_COMPLETION) ||	    (mbox_status >> 12 == MBOX_COMPLETION_STATUS)) {		ha->mbox_status[0] = mbox_status;		if (test_bit(AF_MBOX_COMMAND, &ha->flags)) {			/*			 * Copy all mailbox registers to a temporary			 * location and set mailbox command done flag			 */			for (i = 1; i < ha->mbox_status_count; i++)				ha->mbox_status[i] =					readl(&ha->reg->mailbox[i]);			set_bit(AF_MBOX_COMMAND_DONE, &ha->flags);		}	} else if (mbox_status >> 12 == MBOX_ASYNC_EVENT_STATUS) {		/* Immediately process the AENs that don't require much work.		 * Only queue the database_changed AENs */		if (ha->aen_log.count < MAX_AEN_ENTRIES) {			for (i = 0; i < MBOX_AEN_REG_COUNT; i++)				ha->aen_log.entry[ha->aen_log.count].mbox_sts[i] =					readl(&ha->reg->mailbox[i]);			ha->aen_log.count++;		}		switch (mbox_status) {		case MBOX_ASTS_SYSTEM_ERROR:			/* Log Mailbox registers */			if (ql4xdontresethba) {				DEBUG2(printk("%s:Dont Reset HBA\n",					      __func__));			} else {				set_bit(AF_GET_CRASH_RECORD, &ha->flags);				set_bit(DPC_RESET_HA, &ha->dpc_flags);			}			break;		case MBOX_ASTS_REQUEST_TRANSFER_ERROR:		case MBOX_ASTS_RESPONSE_TRANSFER_ERROR:		case MBOX_ASTS_NVRAM_INVALID:		case MBOX_ASTS_IP_ADDRESS_CHANGED:		case MBOX_ASTS_DHCP_LEASE_EXPIRED:			DEBUG2(printk("scsi%ld: AEN %04x, ERROR Status, "				      "Reset HA\n", ha->host_no, mbox_status));			set_bit(DPC_RESET_HA, &ha->dpc_flags);			break;		case MBOX_ASTS_LINK_UP:			DEBUG2(printk("scsi%ld: AEN %04x Adapter LINK UP\n",				      ha->host_no, mbox_status));			set_bit(AF_LINK_UP, &ha->flags);			break;		case MBOX_ASTS_LINK_DOWN:			DEBUG2(printk("scsi%ld: AEN %04x Adapter LINK DOWN\n",				      ha->host_no, mbox_status));			clear_bit(AF_LINK_UP, &ha->flags);			break;		case MBOX_ASTS_HEARTBEAT:			ha->seconds_since_last_heartbeat = 0;			break;		case MBOX_ASTS_DHCP_LEASE_ACQUIRED:			DEBUG2(printk("scsi%ld: AEN %04x DHCP LEASE "				      "ACQUIRED\n", ha->host_no, mbox_status));			set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);			break;		case MBOX_ASTS_PROTOCOL_STATISTIC_ALARM:		case MBOX_ASTS_SCSI_COMMAND_PDU_REJECTED: /* Target							   * mode							   * only */		case MBOX_ASTS_UNSOLICITED_PDU_RECEIVED:  /* Connection mode */		case MBOX_ASTS_IPSEC_SYSTEM_FATAL_ERROR:		case MBOX_ASTS_SUBNET_STATE_CHANGE:			/* No action */			DEBUG2(printk("scsi%ld: AEN %04x\n", ha->host_no,				      mbox_status));			break;		case MBOX_ASTS_IP_ADDR_STATE_CHANGED:			mbox_stat2 = readl(&ha->reg->mailbox[2]);			mbox_stat3 = readl(&ha->reg->mailbox[3]);			if ((mbox_stat3 == 5) && (mbox_stat2 == 3))				set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);			else if ((mbox_stat3 == 2) && (mbox_stat2 == 5))				set_bit(DPC_RESET_HA, &ha->dpc_flags);			break;		case MBOX_ASTS_MAC_ADDRESS_CHANGED:		case MBOX_ASTS_DNS:			/* No action */			DEBUG2(printk(KERN_INFO "scsi%ld: AEN %04x, "				      "mbox_sts[1]=%04x, mbox_sts[2]=%04x\n",				      ha->host_no, mbox_status,				      readl(&ha->reg->mailbox[1]),				      readl(&ha->reg->mailbox[2])));			break;		case MBOX_ASTS_SELF_TEST_FAILED:		case MBOX_ASTS_LOGIN_FAILED:			/* No action */			DEBUG2(printk("scsi%ld: AEN %04x, mbox_sts[1]=%04x, "				      "mbox_sts[2]=%04x, mbox_sts[3]=%04x\n",				      ha->host_no, mbox_status,				      readl(&ha->reg->mailbox[1]),				      readl(&ha->reg->mailbox[2]),				      readl(&ha->reg->mailbox[3])));			break;		case MBOX_ASTS_DATABASE_CHANGED:			/* Queue AEN information and process it in the DPC			 * routine */			if (ha->aen_q_count > 0) {				/* decrement available counter */				ha->aen_q_count--;				for (i = 1; i < MBOX_AEN_REG_COUNT; i++)					ha->aen_q[ha->aen_in].mbox_sts[i] =						readl(&ha->reg->mailbox[i]);				ha->aen_q[ha->aen_in].mbox_sts[0] = mbox_status;				/* print debug message */				DEBUG2(printk("scsi%ld: AEN[%d] %04x queued"					      " mb1:0x%x mb2:0x%x mb3:0x%x mb4:0x%x\n",					      ha->host_no, ha->aen_in,					      mbox_status,					      ha->aen_q[ha->aen_in].mbox_sts[1],					      ha->aen_q[ha->aen_in].mbox_sts[2],					      ha->aen_q[ha->aen_in].mbox_sts[3],					      ha->aen_q[ha->aen_in].  mbox_sts[4]));				/* advance pointer */				ha->aen_in++;				if (ha->aen_in == MAX_AEN_ENTRIES)					ha->aen_in = 0;				/* The DPC routine will process the aen */				set_bit(DPC_AEN, &ha->dpc_flags);			} else {				DEBUG2(printk("scsi%ld: %s: aen %04x, queue "					      "overflowed!  AEN LOST!!\n",					      ha->host_no, __func__,					      mbox_status));				DEBUG2(printk("scsi%ld: DUMP AEN QUEUE\n",					      ha->host_no));				for (i = 0; i < MAX_AEN_ENTRIES; i++) {					DEBUG2(printk("AEN[%d] %04x %04x %04x "						      "%04x\n", i,						      ha->aen_q[i].mbox_sts[0],						      ha->aen_q[i].mbox_sts[1],						      ha->aen_q[i].mbox_sts[2],						      ha->aen_q[i].mbox_sts[3]));				}			}			break;		default:			DEBUG2(printk(KERN_WARNING				      "scsi%ld: AEN %04x UNKNOWN\n",				      ha->host_no, mbox_status));			break;		}	} else {		DEBUG2(printk("scsi%ld: Unknown mailbox status %08X\n",			      ha->host_no, mbox_status));		ha->mbox_status[0] = mbox_status;	}}/** * qla4xxx_interrupt_service_routine - isr * @ha: pointer to host adapter structure. * * This is the main interrupt service routine. * hardware_lock locked upon entry. runs in interrupt context. **/void qla4xxx_interrupt_service_routine(struct scsi_qla_host * ha,				       uint32_t intr_status){	/* Process response queue interrupt. */	if (intr_status & CSR_SCSI_COMPLETION_INTR)		qla4xxx_process_response_queue(ha);	/* Process mailbox/asynch event	 interrupt.*/	if (intr_status & CSR_SCSI_PROCESSOR_INTR) {		qla4xxx_isr_decode_mailbox(ha,					   readl(&ha->reg->mailbox[0]));		/* Clear Mailbox Interrupt */		writel(set_rmask(CSR_SCSI_PROCESSOR_INTR),		       &ha->reg->ctrl_status);		readl(&ha->reg->ctrl_status);	}}/** * qla4xxx_intr_handler - hardware interrupt handler. * @irq: Unused * @dev_id: Pointer to host adapter structure **/irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id){	struct scsi_qla_host *ha;	uint32_t intr_status;	unsigned long flags = 0;	uint8_t reqs_count = 0;	ha = (struct scsi_qla_host *) dev_id;	if (!ha) {		DEBUG2(printk(KERN_INFO			      "qla4xxx: Interrupt with NULL host ptr\n"));		return IRQ_NONE;	}	spin_lock_irqsave(&ha->hardware_lock, flags);	ha->isr_count++;	/*	 * Repeatedly service interrupts up to a maximum of	 * MAX_REQS_SERVICED_PER_INTR	 */	while (1) {		/*		 * Read interrupt status		 */		if (le32_to_cpu(ha->shadow_regs->rsp_q_in) !=		    ha->response_out)			intr_status = CSR_SCSI_COMPLETION_INTR;		else			intr_status = readl(&ha->reg->ctrl_status);		if ((intr_status &		     (CSR_SCSI_RESET_INTR|CSR_FATAL_ERROR|INTR_PENDING)) ==		    0) {			if (reqs_count == 0)				ha->spurious_int_count++;			break;		}		if (intr_status & CSR_FATAL_ERROR) {			DEBUG2(printk(KERN_INFO "scsi%ld: Fatal Error, "				      "Status 0x%04x\n", ha->host_no,				      readl(isp_port_error_status (ha))));			/* Issue Soft Reset to clear this error condition.			 * This will prevent the RISC from repeatedly			 * interrupting the driver; thus, allowing the DPC to			 * get scheduled to continue error recovery.			 * NOTE: Disabling RISC interrupts does not work in			 * this case, as CSR_FATAL_ERROR overrides			 * CSR_SCSI_INTR_ENABLE */			if ((readl(&ha->reg->ctrl_status) &			     CSR_SCSI_RESET_INTR) == 0) {				writel(set_rmask(CSR_SOFT_RESET),				       &ha->reg->ctrl_status);				readl(&ha->reg->ctrl_status);			}			writel(set_rmask(CSR_FATAL_ERROR),			       &ha->reg->ctrl_status);			readl(&ha->reg->ctrl_status);			__qla4xxx_disable_intrs(ha);			set_bit(DPC_RESET_HA, &ha->dpc_flags);			break;		} else if (intr_status & CSR_SCSI_RESET_INTR) {			clear_bit(AF_ONLINE, &ha->flags);			__qla4xxx_disable_intrs(ha);			writel(set_rmask(CSR_SCSI_RESET_INTR),			       &ha->reg->ctrl_status);			readl(&ha->reg->ctrl_status);			if (!ql4_mod_unload)				set_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);			break;		} else if (intr_status & INTR_PENDING) {			qla4xxx_interrupt_service_routine(ha, intr_status);			ha->total_io_count++;			if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)				break;			intr_status = 0;		}	}	spin_unlock_irqrestore(&ha->hardware_lock, flags);	return IRQ_HANDLED;}/** * qla4xxx_process_aen - processes AENs generated by firmware * @ha: pointer to host adapter structure. * @process_aen: type of AENs to process * * Processes specific types of Asynchronous Events generated by firmware. * The type of AENs to process is specified by process_aen and can be *	PROCESS_ALL_AENS	 0 *	FLUSH_DDB_CHANGED_AENS	 1 *	RELOGIN_DDB_CHANGED_AENS 2 **/void qla4xxx_process_aen(struct scsi_qla_host * ha, uint8_t process_aen){	uint32_t mbox_sts[MBOX_AEN_REG_COUNT];	struct aen *aen;	int i;	unsigned long flags;	spin_lock_irqsave(&ha->hardware_lock, flags);	while (ha->aen_out != ha->aen_in) {		aen = &ha->aen_q[ha->aen_out];		/* copy aen information to local structure */		for (i = 0; i < MBOX_AEN_REG_COUNT; i++)			mbox_sts[i] = aen->mbox_sts[i];		ha->aen_q_count++;		ha->aen_out++;		if (ha->aen_out == MAX_AEN_ENTRIES)			ha->aen_out = 0;		spin_unlock_irqrestore(&ha->hardware_lock, flags);		DEBUG2(printk("qla4xxx(%ld): AEN[%d]=0x%08x, mbx1=0x%08x mbx2=0x%08x"			" mbx3=0x%08x mbx4=0x%08x\n", ha->host_no,			(ha->aen_out ? (ha->aen_out-1): (MAX_AEN_ENTRIES-1)),			mbox_sts[0], mbox_sts[1], mbox_sts[2],			mbox_sts[3], mbox_sts[4]));		switch (mbox_sts[0]) {		case MBOX_ASTS_DATABASE_CHANGED:			if (process_aen == FLUSH_DDB_CHANGED_AENS) {				DEBUG2(printk("scsi%ld: AEN[%d] %04x, index "					      "[%d] state=%04x FLUSHED!\n",					      ha->host_no, ha->aen_out,					      mbox_sts[0], mbox_sts[2],					      mbox_sts[3]));				break;			} else if (process_aen == RELOGIN_DDB_CHANGED_AENS) {				/* for use during init time, we only want to				 * relogin non-active ddbs */				struct ddb_entry *ddb_entry;				ddb_entry =					/* FIXME: name length? */					qla4xxx_lookup_ddb_by_fw_index(ha,								       mbox_sts[2]);				if (!ddb_entry)					break;				ddb_entry->dev_scan_wait_to_complete_relogin =					0;				ddb_entry->dev_scan_wait_to_start_relogin =					jiffies +					((ddb_entry->default_time2wait +					  4) * HZ);				DEBUG2(printk("scsi%ld: ddb index [%d] initate"					      " RELOGIN after %d seconds\n",					      ha->host_no,					      ddb_entry->fw_ddb_index,					      ddb_entry->default_time2wait +					      4));				break;			}			if (mbox_sts[1] == 0) {	/* Global DB change. */				qla4xxx_reinitialize_ddb_list(ha);			} else if (mbox_sts[1] == 1) {	/* Specific device. */				qla4xxx_process_ddb_changed(ha, mbox_sts[2],							    mbox_sts[3]);			}			break;		}		spin_lock_irqsave(&ha->hardware_lock, flags);	}	spin_unlock_irqrestore(&ha->hardware_lock, flags);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?