⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qla_isr.c

📁 h内核
💻 C
📖 第 1 页 / 共 3 页
字号:
		set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);		ha->operating_mode = LOOP;		ha->flags.management_server_logged_in = 0;		/* Update AEN queue. */		qla2x00_enqueue_aen(ha, MBA_LIP_RESET, NULL);		ha->total_lip_cnt++;		break;	case MBA_POINT_TO_POINT:	/* Point-to-Point */		if (IS_QLA2100(ha))			break;		DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE received.\n",		    ha->host_no));		/*		 * Until there's a transition from loop down to loop up, treat		 * this as loop down only.		 */		if (atomic_read(&ha->loop_state) != LOOP_DOWN) {			atomic_set(&ha->loop_state, LOOP_DOWN);			if (!atomic_read(&ha->loop_down_timer))				atomic_set(&ha->loop_down_timer,				    LOOP_DOWN_TIME);			qla2x00_mark_all_devices_lost(ha);		}		if (!(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags))) {			set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);		}		set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags);		break;	case MBA_CHG_IN_CONNECTION:	/* Change in connection mode */		if (IS_QLA2100(ha))			break;		mb[1] = RD_MAILBOX_REG(ha, reg, 1);		DEBUG2(printk("scsi(%ld): Asynchronous Change In Connection "		    "received.\n",		    ha->host_no));		qla_printk(KERN_INFO, ha,		    "Configuration change detected: value=%x.\n", mb[1]);		if (atomic_read(&ha->loop_state) != LOOP_DOWN) {			atomic_set(&ha->loop_state, LOOP_DOWN);  			if (!atomic_read(&ha->loop_down_timer))				atomic_set(&ha->loop_down_timer,				    LOOP_DOWN_TIME);			qla2x00_mark_all_devices_lost(ha);		}		set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);		set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);		break;	case MBA_PORT_UPDATE:		/* Port database update */		mb[1] = RD_MAILBOX_REG(ha, reg, 1);		mb[2] = RD_MAILBOX_REG(ha, reg, 2);		/*		 * If a single remote port just logged into (or logged out of)		 * us, create a new entry in our rscn fcports list and handle		 * the event like an RSCN.		 */		if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA6312(ha) &&		    !IS_QLA6322(ha) && ha->flags.init_done && mb[1] != 0xffff &&		    ((ha->operating_mode == P2P && mb[1] != 0) ||		    (ha->operating_mode != P2P && mb[1] !=			SNS_FIRST_LOOP_ID)) && (mb[2] == 6 || mb[2] == 7)) {			int rval;			fc_port_t *rscn_fcport;			/* Create new fcport for login. */			rscn_fcport = qla2x00_alloc_rscn_fcport(ha, GFP_ATOMIC);			if (rscn_fcport) {				DEBUG14(printk("scsi(%ld): Port Update -- "				    "creating RSCN fcport %p for %x/%x.\n",				    ha->host_no, rscn_fcport, mb[1], mb[2]));				rscn_fcport->loop_id = mb[1];				rscn_fcport->d_id.b24 = INVALID_PORT_ID;				atomic_set(&rscn_fcport->state,				    FCS_DEVICE_LOST);				list_add_tail(&rscn_fcport->list,				    &ha->rscn_fcports);				rval = qla2x00_handle_port_rscn(ha, 0,				    rscn_fcport, 1);				if (rval == QLA_SUCCESS)					break;			} else {				DEBUG14(printk("scsi(%ld): Port Update -- "				    "-- unable to allocate RSCN fcport "				    "login.\n", ha->host_no));			}		}		/*		 * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET		 * event etc. earlier indicating loop is down) then process		 * it.  Otherwise ignore it and Wait for RSCN to come in.		 */		atomic_set(&ha->loop_down_timer, 0);		if (atomic_read(&ha->loop_state) != LOOP_DOWN &&		    atomic_read(&ha->loop_state) != LOOP_DEAD) {			DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE "			    "ignored.\n", ha->host_no));			break;		}		DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n",		    ha->host_no));		DEBUG(printk(KERN_INFO		    "scsi(%ld): Port database changed %04x %04x.\n",		    ha->host_no, mb[1], mb[2]));		/*		 * Mark all devices as missing so we will login again.		 */		atomic_set(&ha->loop_state, LOOP_UP);		qla2x00_mark_all_devices_lost(ha);		ha->flags.rscn_queue_overflow = 1;		set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);		set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);		/* Update AEN queue. */		qla2x00_enqueue_aen(ha, MBA_PORT_UPDATE, NULL);		break;	case MBA_RSCN_UPDATE:		/* State Change Registration */		mb[1] = RD_MAILBOX_REG(ha, reg, 1);		mb[2] = RD_MAILBOX_REG(ha, reg, 2);		DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n",		    ha->host_no));		DEBUG(printk(KERN_INFO		    "scsi(%ld): RSCN database changed -- %04x %04x.\n",		    ha->host_no, mb[1], mb[2]));		rscn_entry = (mb[1] << 16) | mb[2];		host_pid = (ha->d_id.b.domain << 16) | (ha->d_id.b.area << 8) |		    ha->d_id.b.al_pa;		if (rscn_entry == host_pid) {			DEBUG(printk(KERN_INFO			    "scsi(%ld): Ignoring RSCN update to local host "			    "port ID (%06x)\n",			    ha->host_no, host_pid));			break;		}		rscn_queue_index = ha->rscn_in_ptr + 1;		if (rscn_queue_index == MAX_RSCN_COUNT)			rscn_queue_index = 0;		if (rscn_queue_index != ha->rscn_out_ptr) {			ha->rscn_queue[ha->rscn_in_ptr] = rscn_entry;			ha->rscn_in_ptr = rscn_queue_index;		} else {			ha->flags.rscn_queue_overflow = 1;		}		atomic_set(&ha->loop_state, LOOP_UPDATE);		atomic_set(&ha->loop_down_timer, 0);		ha->flags.management_server_logged_in = 0;		set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);		set_bit(RSCN_UPDATE, &ha->dpc_flags);		/* Update AEN queue. */		qla2x00_enqueue_aen(ha, MBA_RSCN_UPDATE, &mb[0]);		break;	/* case MBA_RIO_RESPONSE: */	case MBA_ZIO_RESPONSE:		DEBUG2(printk("scsi(%ld): [R|Z]IO update completion.\n",		    ha->host_no));		DEBUG(printk(KERN_INFO		    "scsi(%ld): [R|Z]IO update completion.\n",		    ha->host_no));		qla2x00_process_response_queue(ha);		break;	}}/** * qla2x00_process_completed_request() - Process a Fast Post response. * @ha: SCSI driver HA context * @index: SRB index */static voidqla2x00_process_completed_request(struct scsi_qla_host *ha, uint32_t index){	srb_t *sp;	/* Validate handle. */	if (index >= MAX_OUTSTANDING_COMMANDS) {		DEBUG2(printk("scsi(%ld): Invalid SCSI completion handle %d.\n",		    ha->host_no, index));		qla_printk(KERN_WARNING, ha,		    "Invalid SCSI completion handle %d.\n", index);		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);		return;	}	sp = ha->outstanding_cmds[index];	if (sp) {		/* Free outstanding command slot. */		ha->outstanding_cmds[index] = NULL;		if (ha->actthreads)			ha->actthreads--;		sp->lun_queue->out_cnt--;		CMD_COMPL_STATUS(sp->cmd) = 0L;		CMD_SCSI_STATUS(sp->cmd) = 0L;		/* Save ISP completion status */		sp->cmd->result = DID_OK << 16;		sp->fo_retry_cnt = 0;		add_to_done_queue(ha, sp);	} else {		DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n",		    ha->host_no));		qla_printk(KERN_WARNING, ha,		    "Invalid ISP SCSI completion handle\n");		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);	}}/** * qla2x00_process_response_queue() - Process response queue entries. * @ha: SCSI driver HA context */voidqla2x00_process_response_queue(struct scsi_qla_host *ha){	device_reg_t __iomem *reg = ha->iobase;	sts_entry_t	*pkt;	uint16_t        handle_cnt;	uint16_t        cnt;	if (!ha->flags.online)		return;	while (ha->response_ring_ptr->signature != RESPONSE_PROCESSED) {		pkt = (sts_entry_t *)ha->response_ring_ptr;		ha->rsp_ring_index++;		if (ha->rsp_ring_index == ha->response_q_length) {			ha->rsp_ring_index = 0;			ha->response_ring_ptr = ha->response_ring;		} else {			ha->response_ring_ptr++;		}		if (pkt->entry_status != 0) {			DEBUG3(printk(KERN_INFO			    "scsi(%ld): Process error entry.\n", ha->host_no));			qla2x00_error_entry(ha, pkt);			((response_t *)pkt)->signature = RESPONSE_PROCESSED;			wmb();			continue;		}		switch (pkt->entry_type) {		case STATUS_TYPE:			qla2x00_status_entry(ha, pkt);			break;		case STATUS_TYPE_21:			handle_cnt = ((sts21_entry_t *)pkt)->handle_count;			for (cnt = 0; cnt < handle_cnt; cnt++) {				qla2x00_process_completed_request(ha,				    ((sts21_entry_t *)pkt)->handle[cnt]);			}			break;		case STATUS_TYPE_22:			handle_cnt = ((sts22_entry_t *)pkt)->handle_count;			for (cnt = 0; cnt < handle_cnt; cnt++) {				qla2x00_process_completed_request(ha,				    ((sts22_entry_t *)pkt)->handle[cnt]);			}			break;		case STATUS_CONT_TYPE:			qla2x00_status_cont_entry(ha, (sts_cont_entry_t *)pkt);			break;		case MS_IOCB_TYPE:			qla2x00_ms_entry(ha, (ms_iocb_entry_t *)pkt);			break;		case MBX_IOCB_TYPE:			if (!IS_QLA2100(ha) && !IS_QLA2200(ha) &&			    !IS_QLA6312(ha) && !IS_QLA6322(ha)) {				if (pkt->sys_define == SOURCE_ASYNC_IOCB) {					qla2x00_process_iodesc(ha,					    (struct mbx_entry *)pkt);				} else {					/* MBX IOCB Type Not Supported. */					DEBUG4(printk(KERN_WARNING					    "scsi(%ld): Received unknown MBX "					    "IOCB response pkt type=%x "					    "source=%x entry status=%x.\n",					    ha->host_no, pkt->entry_type,					    pkt->sys_define,					    pkt->entry_status));				}				break;			}			/* Fallthrough. */		default:			/* Type Not Supported. */			DEBUG4(printk(KERN_WARNING			    "scsi(%ld): Received unknown response pkt type %x "			    "entry status=%x.\n",			    ha->host_no, pkt->entry_type, pkt->entry_status));			break;		}		((response_t *)pkt)->signature = RESPONSE_PROCESSED;		wmb();	}	/* Adjust ring index */	WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), ha->rsp_ring_index);}/** * qla2x00_status_entry() - Process a Status IOCB entry. * @ha: SCSI driver HA context * @pkt: Entry pointer */static voidqla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt){	int		ret;	unsigned	b, t, l;	srb_t		*sp;	os_lun_t	*lq;	os_tgt_t	*tq;	fc_port_t	*fcport;	struct scsi_cmnd *cp;	uint16_t	comp_status;	uint16_t	scsi_status;	uint8_t		lscsi_status;	int32_t		resid;	uint8_t		sense_sz = 0;	uint16_t	rsp_info_len;	/* Fast path completion. */	if (le16_to_cpu(pkt->comp_status) == CS_COMPLETE &&	    (le16_to_cpu(pkt->scsi_status) & SS_MASK) == 0) {		qla2x00_process_completed_request(ha, pkt->handle);		return;	}	/* Validate handle. */	if (pkt->handle < MAX_OUTSTANDING_COMMANDS) {		sp = ha->outstanding_cmds[pkt->handle];		ha->outstanding_cmds[pkt->handle] = NULL;	} else		sp = NULL;	if (sp == NULL) {		DEBUG2(printk("scsi(%ld): Status Entry invalid handle.\n",		    ha->host_no));		qla_printk(KERN_WARNING, ha, "Status Entry invalid handle.\n");		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);		if (ha->dpc_wait && !ha->dpc_active) 			up(ha->dpc_wait);		return;	}	cp = sp->cmd;	if (cp == NULL) {		DEBUG2(printk("scsi(%ld): Command already returned back to OS "		    "pkt->handle=%d sp=%p sp->state:%d\n",		    ha->host_no, pkt->handle, sp, sp->state));		qla_printk(KERN_WARNING, ha,		    "Command is NULL: already returned to OS (sp=%p)\n", sp);		return;	}	if (ha->actthreads)		ha->actthreads--;	if (sp->lun_queue == NULL) {		DEBUG2(printk("scsi(%ld): Status Entry invalid lun pointer.\n",		    ha->host_no));		qla_printk(KERN_WARNING, ha,		    "Status Entry invalid lun pointer.\n");		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);		if (ha->dpc_wait && !ha->dpc_active) 			up(ha->dpc_wait);		return;	}	sp->lun_queue->out_cnt--;	comp_status = le16_to_cpu(pkt->comp_status);	/* Mask of reserved bits 12-15, before we examine the scsi status */	scsi_status = le16_to_cpu(pkt->scsi_status) & SS_MASK;	lscsi_status = scsi_status & STATUS_MASK;	CMD_ENTRY_STATUS(cp) = pkt->entry_status;	CMD_COMPL_STATUS(cp) = comp_status;	CMD_SCSI_STATUS(cp) = scsi_status;	/* Generate LU queue on cntrl, target, LUN */	b = cp->device->channel;	t = cp->device->id;	l = cp->device->lun,	tq = sp->tgt_queue;	lq = sp->lun_queue;	/*	 * If loop is in transient state Report DID_BUS_BUSY	 */	if ((comp_status != CS_COMPLETE || scsi_status != 0)) {		if (!(sp->flags & (SRB_IOCTL | SRB_TAPE)) &&		    (atomic_read(&ha->loop_down_timer) ||			atomic_read(&ha->loop_state) != LOOP_READY)) {			DEBUG2(printk("scsi(%ld:%d:%d:%d): Loop Not Ready - "			    "pid=%lx.\n",			    ha->host_no, b, t, l, cp->serial_number));			qla2x00_extend_timeout(cp, EXTEND_CMD_TIMEOUT);			add_to_retry_queue(ha, sp);			return;		}	}	/* Check for any FCP transport errors. */	if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) {		rsp_info_len = le16_to_cpu(pkt->rsp_info_len);		if (rsp_info_len > 3 && pkt->rsp_info[3]) {			DEBUG2(printk("scsi(%ld:%d:%d:%d) FCP I/O protocol "			    "failure (%x/%02x%02x%02x%02x%02x%02x%02x%02x)..."			    "retrying command\n", ha->host_no, b, t, l,			    rsp_info_len, pkt->rsp_info[0], pkt->rsp_info[1],			    pkt->rsp_info[2], pkt->rsp_info[3],			    pkt->rsp_info[4], pkt->rsp_info[5],			    pkt->rsp_info[6], pkt->rsp_info[7]));			cp->result = DID_BUS_BUSY << 16;			add_to_done_queue(ha, sp);			return;		}	}	/*	 * Based on Host and scsi status generate status code for Linux	 */	switch (comp_status) {	case CS_COMPLETE:		if (scsi_status == 0) {			cp->result = DID_OK << 16;			break;		}		if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) {			resid = le32_to_cpu(pkt->residual_length);			cp->resid = resid;			CMD_RESID_LEN(cp) = resid;		}		if (lscsi_status == SS_BUSY_CONDITION) {			cp->result = DID_BUS_BUSY << 16 | lscsi_status;			break;		}		cp->result = DID_OK << 16 | lscsi_status;		if (lscsi_status != SS_CHECK_CONDITION)			break;		/*		 * Copy Sense Data into sense buffer

⌨️ 快捷键说明

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