scsi_to_pci_dma_dir(Cmnd->sc_data_direction)); 
Cmnd->sc_data_direction); 
void isp2x00_intr_handler(int irq, void *dev_id, struct pt_regs *regs){	Scsi_Cmnd *Cmnd;	struct Status_Entry *sts;	struct Scsi_Host *host = dev_id;	struct isp2x00_hostdata *hostdata;	u_int in_ptr, out_ptr, handle, num_free;	u_short status;	ENTER_INTR("isp2x00_intr_handler");	hostdata = (struct isp2x00_hostdata *) host->hostdata;	DEBUG_INTR(printk("qlogicfc%d : interrupt on line %d\n", hostdata->host_id, irq));	if (!(inw(host->io_port + PCI_INTER_STS) & 0x08)) {		/* spurious interrupts can happen legally */		DEBUG_INTR(printk("qlogicfc%d : got spurious interrupt\n", hostdata->host_id));		return;	}	in_ptr = inw(host->io_port + MBOX5);	out_ptr = hostdata->res_out_ptr;	if ((inw(host->io_port + PCI_SEMAPHORE) & ASYNC_EVENT_INTERRUPT)) {		status = inw(host->io_port + MBOX0);		DEBUG_INTR(printk("qlogicfc%d : mbox completion status: %x\n",				  hostdata->host_id, status));		switch (status) {		case LOOP_UP:		case POINT_TO_POINT_UP:		        printk("qlogicfc%d : Link is Up\n", hostdata->host_id);			hostdata->adapter_state = AS_REDO_FABRIC_PORTDB | AS_REDO_LOOP_PORTDB;			break;		case LOOP_DOWN:		        printk("qlogicfc%d : Link is Down\n", hostdata->host_id);			hostdata->adapter_state = AS_LOOP_DOWN;			break;		case CONNECTION_MODE:		        printk("received CONNECTION_MODE irq %x\n", inw(host->io_port + MBOX1));			break;		case CHANGE_NOTIFICATION:		        printk("qlogicfc%d : RSCN Received\n", hostdata->host_id);			if (hostdata->adapter_state == AS_LOOP_GOOD)				hostdata->adapter_state = AS_REDO_FABRIC_PORTDB;			break;		        		case LIP_OCCURRED:		case LIP_RECEIVED:		        printk("qlogicfc%d : Loop Reinitialized\n", hostdata->host_id);			if (hostdata->adapter_state == AS_LOOP_GOOD)				hostdata->adapter_state = AS_REDO_LOOP_PORTDB;			break;		case SYSTEM_ERROR:			printk("qlogicfc%d : The firmware just choked.\n", hostdata->host_id);			hostdata->adapter_state = AS_FIRMWARE_DEAD;			break;		case SCSI_COMMAND_COMPLETE:			handle = inw(host->io_port + MBOX1) | (inw(host->io_port + MBOX2) << 16);			Cmnd = hostdata->handle_ptrs[handle];			hostdata->handle_ptrs[handle] = NULL;			hostdata->handle_serials[handle] = 0;			hostdata->queued--;			if (Cmnd != NULL) {				if (Cmnd->use_sg)					pci_unmap_sg(hostdata->pci_dev,						     (struct scatterlist *)Cmnd->buffer,						     Cmnd->use_sg,						     scsi_to_pci_dma_dir(Cmnd->sc_data_direction));				else if (Cmnd->request_bufflen &&					 Cmnd->sc_data_direction != PCI_DMA_NONE)					pci_unmap_page(hostdata->pci_dev,						       Cmnd->SCp.dma_handle,						       Cmnd->request_bufflen,						       scsi_to_pci_dma_dir(Cmnd->sc_data_direction));				Cmnd->result = 0x0;				(*Cmnd->scsi_done) (Cmnd);			} else				printk("qlogicfc%d.c : got a null value out of handle_ptrs, this sucks\n", hostdata->host_id);			break;		case MBOX_COMMAND_COMPLETE:		case INVALID_COMMAND:		case HOST_INTERFACE_ERROR:		case TEST_FAILED:		case COMMAND_ERROR:		case COMMAND_PARAM_ERROR:		case PORT_ID_USED:		case LOOP_ID_USED:		case ALL_IDS_USED:			hostdata->mbox_done = 1;			outw(HCCR_CLEAR_RISC_INTR, host->io_port + HOST_HCCR);			return;		default:			printk("qlogicfc%d : got an unknown status? %x\n", hostdata->host_id, status);		}		if ((hostdata->adapter_state & AS_REDO_LOOP_PORTDB || hostdata->adapter_state & AS_REDO_FABRIC_PORTDB) && hostdata->explore_timer.data == 0){                        hostdata->explore_timer.function = redo_port_db;			hostdata->explore_timer.data = (unsigned long)host;			hostdata->explore_timer.expires = jiffies + (HZ/4);			init_timer(&hostdata->explore_timer);			add_timer(&hostdata->explore_timer);		}		outw(0x0, host->io_port + PCI_SEMAPHORE);	} else {		DEBUG_INTR(printk("qlogicfc%d : response queue update\n", hostdata->host_id));		DEBUG_INTR(printk("qlogicfc%d : response queue depth %d\n", hostdata->host_id, RES_QUEUE_DEPTH(in_ptr, out_ptr)));		while (out_ptr != in_ptr) {			unsigned le_hand;			sts = (struct Status_Entry *) &hostdata->res[out_ptr*QUEUE_ENTRY_LEN];			out_ptr = (out_ptr + 1) & RES_QUEUE_LEN;                 			TRACE("done", out_ptr, Cmnd);			DEBUG_INTR(isp2x00_print_status_entry(sts));			le_hand = le32_to_cpu(sts->handle);			if (sts->hdr.entry_type == ENTRY_STATUS && (Cmnd = hostdata->handle_ptrs[le_hand])) {				Cmnd->result = isp2x00_return_status(Cmnd, sts);				hostdata->queued--;				if (Cmnd->use_sg)					pci_unmap_sg(hostdata->pci_dev,						     (struct scatterlist *)Cmnd->buffer, Cmnd->use_sg,						     scsi_to_pci_dma_dir(Cmnd->sc_data_direction));				else if (Cmnd->request_bufflen && Cmnd->sc_data_direction != PCI_DMA_NONE)					pci_unmap_page(hostdata->pci_dev,						       Cmnd->SCp.dma_handle,						       Cmnd->request_bufflen,						       scsi_to_pci_dma_dir(Cmnd->sc_data_direction));				/* 				 * if any of the following are true we do not				 * call scsi_done.  if the status is CS_ABORTED				 * we don't have to call done because the upper				 * level should already know its aborted.				 */				if (hostdata->handle_serials[le_hand] != Cmnd->serial_number 				    || le16_to_cpu(sts->completion_status) == CS_ABORTED){					hostdata->handle_serials[le_hand] = 0;					hostdata->handle_ptrs[le_hand] = NULL;					outw(out_ptr, host->io_port + MBOX5);					continue;				}				/*				 * if we get back an error indicating the port				 * is not there or if the link is down and 				 * this is a device that used to be there 				 * allow the command to timeout.				 * the device may well be back in a couple of				 * seconds.				 */				if ((hostdata->adapter_state == AS_LOOP_DOWN || sts->completion_status == cpu_to_le16(CS_PORT_UNAVAILABLE) || sts->completion_status == cpu_to_le16(CS_PORT_LOGGED_OUT) || sts->completion_status == cpu_to_le16(CS_PORT_CONFIG_CHANGED)) && hostdata->port_db[Cmnd->device->id].wwn){					outw(out_ptr, host->io_port + MBOX5);					continue;				}			} else {				outw(out_ptr, host->io_port + MBOX5);				continue;			}			hostdata->handle_ptrs[le_hand] = NULL;			if (sts->completion_status == cpu_to_le16(CS_RESET_OCCURRED)			    || (sts->status_flags & cpu_to_le16(STF_BUS_RESET)))				hostdata->send_marker = 1;			if (le16_to_cpu(sts->scsi_status) & 0x0200)				memcpy(Cmnd->sense_buffer, sts->req_sense_data,				       sizeof(Cmnd->sense_buffer));			outw(out_ptr, host->io_port + MBOX5);			if (Cmnd->scsi_done != NULL) {				(*Cmnd->scsi_done) (Cmnd);			} else				printk("qlogicfc%d : Ouch, scsi done is NULL\n", hostdata->host_id);		}		hostdata->res_out_ptr = out_ptr;	}	out_ptr = inw(host->io_port + MBOX4);	in_ptr = hostdata->req_in_ptr;	num_free = QLOGICFC_REQ_QUEUE_LEN - REQ_QUEUE_DEPTH(in_ptr, out_ptr);	num_free = (num_free > 2) ? num_free - 2 : 0;       host->can_queue = host->host_busy + num_free;	if (host->can_queue > QLOGICFC_REQ_QUEUE_LEN)		host->can_queue = QLOGICFC_REQ_QUEUE_LEN;	host->sg_tablesize = QLOGICFC_MAX_SG(num_free);	outw(HCCR_CLEAR_RISC_INTR, host->io_port + HOST_HCCR);	LEAVE_INTR("isp2x00_intr_handler");}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/be7db055dd7261522557046370f49160728e3847/qlogicfc.c/clean/drivers/scsi/qlogicfc.c