} 
qla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt){	unsigned	b, t, l;	srb_t		*sp;	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;	}	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,	fcport = sp->fcport;	/* 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;			qla2x00_sp_compl(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;		}		cp->result = DID_OK << 16 | lscsi_status;		if (lscsi_status != SS_CHECK_CONDITION)			break;		/*		 * Copy Sense Data into sense buffer		 */		memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer));		if (!(scsi_status & SS_SENSE_LEN_VALID))			break;		if (le16_to_cpu(pkt->req_sense_length) <		    sizeof(cp->sense_buffer))			sense_sz = le16_to_cpu(pkt->req_sense_length);		else			sense_sz = sizeof(cp->sense_buffer);		CMD_ACTUAL_SNSLEN(cp) = sense_sz;		sp->request_sense_length = sense_sz;		sp->request_sense_ptr = cp->sense_buffer;		if (sp->request_sense_length > 32)			sense_sz = 32;		memcpy(cp->sense_buffer, pkt->req_sense_data, sense_sz);		sp->request_sense_ptr += sense_sz;		sp->request_sense_length -= sense_sz;		if (sp->request_sense_length != 0)			ha->status_srb = sp;		DEBUG5(printk("%s(): Check condition Sense data, "		    "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n",		    __func__, ha->host_no, b, t, l, cp,		    cp->serial_number));		if (sense_sz)			DEBUG5(qla2x00_dump_buffer(cp->sense_buffer,			    CMD_ACTUAL_SNSLEN(cp)));		break;	case CS_DATA_UNDERRUN:		DEBUG2(printk(KERN_INFO		    "scsi(%ld:%d:%d) UNDERRUN status detected 0x%x-0x%x.\n",		    ha->host_no, t, l, comp_status, scsi_status));		resid = le32_to_cpu(pkt->residual_length);		if (scsi_status & SS_RESIDUAL_UNDER) {			cp->resid = resid;			CMD_RESID_LEN(cp) = resid;		}		/*		 * Check to see if SCSI Status is non zero. If so report SCSI 		 * Status.		 */		if (lscsi_status != 0) {			cp->result = DID_OK << 16 | lscsi_status;			if (lscsi_status != SS_CHECK_CONDITION)				break;			/* Copy Sense Data into sense buffer */			memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer));			if (!(scsi_status & SS_SENSE_LEN_VALID))				break;			if (le16_to_cpu(pkt->req_sense_length) <			    sizeof(cp->sense_buffer))				sense_sz = le16_to_cpu(pkt->req_sense_length);			else				sense_sz = sizeof(cp->sense_buffer);			CMD_ACTUAL_SNSLEN(cp) = sense_sz;			sp->request_sense_length = sense_sz;			sp->request_sense_ptr = cp->sense_buffer;			if (sp->request_sense_length > 32) 				sense_sz = 32;			memcpy(cp->sense_buffer, pkt->req_sense_data, sense_sz);			sp->request_sense_ptr += sense_sz;			sp->request_sense_length -= sense_sz;			if (sp->request_sense_length != 0)				ha->status_srb = sp;			DEBUG5(printk("%s(): Check condition Sense data, "			    "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n",			    __func__, ha->host_no, b, t, l, cp,			    cp->serial_number));			if (sense_sz)				DEBUG5(qla2x00_dump_buffer(cp->sense_buffer,				    CMD_ACTUAL_SNSLEN(cp)));		} else {			/*			 * If RISC reports underrun and target does not report			 * it then we must have a lost frame, so tell upper			 * layer to retry it by reporting a bus busy.			 */			if (!(scsi_status & SS_RESIDUAL_UNDER)) {				DEBUG2(printk("scsi(%ld:%d:%d:%d) Dropped "				    "frame(s) detected (%x of %x bytes)..."				    "retrying command.\n",				    ha->host_no, b, t, l, resid,				    cp->request_bufflen));				cp->result = DID_BUS_BUSY << 16;				break;			}			/* Handle mid-layer underflow */			if ((unsigned)(cp->request_bufflen - resid) <			    cp->underflow) {				qla_printk(KERN_INFO, ha,				    "scsi(%ld:%d:%d:%d): Mid-layer underflow "				    "detected (%x of %x bytes)...returning "				    "error status.\n",				    ha->host_no, b, t, l, resid,				    cp->request_bufflen);				cp->result = DID_ERROR << 16;				break;			}			/* Everybody online, looking good... */			cp->result = DID_OK << 16;		}		break;	case CS_DATA_OVERRUN:		DEBUG2(printk(KERN_INFO		    "scsi(%ld:%d:%d): OVERRUN status detected 0x%x-0x%x\n",		    ha->host_no, t, l, comp_status, scsi_status));		DEBUG2(printk(KERN_INFO		    "CDB: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",		    cp->cmnd[0], cp->cmnd[1], cp->cmnd[2], cp->cmnd[3],		    cp->cmnd[4], cp->cmnd[5]));		DEBUG2(printk(KERN_INFO		    "PID=0x%lx req=0x%x xtra=0x%x -- returning DID_ERROR "		    "status!\n",		    cp->serial_number, cp->request_bufflen,		    le32_to_cpu(pkt->residual_length)));		cp->result = DID_ERROR << 16;		break;	case CS_PORT_LOGGED_OUT:	case CS_PORT_CONFIG_CHG:	case CS_PORT_BUSY:	case CS_INCOMPLETE:	case CS_PORT_UNAVAILABLE:		/*		 * If the port is in Target Down state, return all IOs for this		 * Target with DID_NO_CONNECT ELSE Queue the IOs in the		 * retry_queue.		 */		DEBUG2(printk("scsi(%ld:%d:%d): status_entry: Port Down "		    "pid=%ld, compl status=0x%x, port state=0x%x\n",		    ha->host_no, t, l, cp->serial_number, comp_status,		    atomic_read(&fcport->state)));		cp->result = DID_BUS_BUSY << 16;		if (atomic_read(&fcport->state) == FCS_ONLINE) {			qla2x00_mark_device_lost(ha, fcport, 1);		}		break;	case CS_RESET:		DEBUG2(printk(KERN_INFO		    "scsi(%ld): RESET status detected 0x%x-0x%x.\n",		    ha->host_no, comp_status, scsi_status));		cp->result = DID_RESET << 16;		break;	case CS_ABORTED:		/* 		 * hv2.19.12 - DID_ABORT does not retry the request if we		 * aborted this request then abort otherwise it must be a		 * reset.		 */		DEBUG2(printk(KERN_INFO		    "scsi(%ld): ABORT status detected 0x%x-0x%x.\n",		    ha->host_no, comp_status, scsi_status));		cp->result = DID_RESET << 16;		break;	case CS_TIMEOUT:		DEBUG2(printk(KERN_INFO		    "scsi(%ld:%d:%d:%d): TIMEOUT status detected 0x%x-0x%x "		    "sflags=%x.\n", ha->host_no, b, t, l, comp_status,		    scsi_status, le16_to_cpu(pkt->status_flags)));		cp->result = DID_BUS_BUSY << 16;		/* Check to see if logout occurred */		if ((le16_to_cpu(pkt->status_flags) & SF_LOGOUT_SENT)) {			qla2x00_mark_device_lost(ha, fcport, 1);		}		break;	case CS_QUEUE_FULL:		DEBUG2(printk(KERN_INFO		    "scsi(%ld): QUEUE FULL status detected 0x%x-0x%x.\n",		    ha->host_no, comp_status, scsi_status));		/* SCSI Mid-Layer handles device queue full */		cp->result = DID_OK << 16 | lscsi_status; 		break;	default:		DEBUG3(printk("scsi(%ld): Error detected (unknown status) "		    "0x%x-0x%x.\n",		    ha->host_no, comp_status, scsi_status));		qla_printk(KERN_INFO, ha,		    "Unknown status detected 0x%x-0x%x.\n",		    comp_status, scsi_status);		cp->result = DID_ERROR << 16;		break;	}	/* Place command on done queue. */	if (ha->status_srb == NULL)		qla2x00_sp_compl(ha, sp);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/9a853f71804d80e862362f6d0743d06955305752/qla_isr.c/buggy/drivers/scsi/qla2xxx/qla_isr.c