setinqstr(cardtype, (void *) (inq_data.inqd_vid), (sizeof(container_types)/sizeof(char *))); 
setinqstr(dev, (void *) (inq_data.inqd_vid), (sizeof(container_types)/sizeof(char *))); 
int aac_scsi_cmd(struct scsi_cmnd * scsicmd){	u32 cid = 0;	struct Scsi_Host *host = scsicmd->device->host;	struct aac_dev *dev = (struct aac_dev *)host->hostdata;	struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;	int cardtype = dev->cardtype;	int ret;		/*	 *	If the bus, id or lun is out of range, return fail	 *	Test does not apply to ID 16, the pseudo id for the controller	 *	itself.	 */	if (scsicmd->device->id != host->this_id) {		if ((scsicmd->device->channel == 0) ){			if( (scsicmd->device->id >= dev->maximum_num_containers) || (scsicmd->device->lun != 0)){ 				scsicmd->result = DID_NO_CONNECT << 16;				scsicmd->scsi_done(scsicmd);				return 0;			}			cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);			/*			 *	If the target container doesn't exist, it may have			 *	been newly created			 */			if ((fsa_dev_ptr[cid].valid & 1) == 0) {				switch (scsicmd->cmnd[0]) {				case INQUIRY:				case READ_CAPACITY:				case TEST_UNIT_READY:					spin_unlock_irq(host->host_lock);					probe_container(dev, cid);					spin_lock_irq(host->host_lock);					if (fsa_dev_ptr[cid].valid == 0) {						scsicmd->result = DID_NO_CONNECT << 16;						scsicmd->scsi_done(scsicmd);						return 0;					}				default:					break;				}			}			/*			 *	If the target container still doesn't exist, 			 *	return failure			 */			if (fsa_dev_ptr[cid].valid == 0) {				scsicmd->result = DID_BAD_TARGET << 16;				scsicmd->scsi_done(scsicmd);				return 0;			}		} else {  /* check for physical non-dasd devices */			if(dev->nondasd_support == 1){				return aac_send_srb_fib(scsicmd);			} else {				scsicmd->result = DID_NO_CONNECT << 16;				scsicmd->scsi_done(scsicmd);				return 0;			}		}	}	/*	 * else Command for the controller itself	 */	else if ((scsicmd->cmnd[0] != INQUIRY) &&	/* only INQUIRY & TUR cmnd supported for controller */		(scsicmd->cmnd[0] != TEST_UNIT_READY)) 	{		dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0]));		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;		set_sense((u8 *) &dev->fsa_dev[cid].sense_data,			    ILLEGAL_REQUEST,			    SENCODE_INVALID_COMMAND,			    ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);		memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,		  (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))		    ? sizeof(scsicmd->sense_buffer)		    : sizeof(dev->fsa_dev[cid].sense_data));		scsicmd->scsi_done(scsicmd);		return 0;	}	/* Handle commands here that don't really require going out to the adapter */	switch (scsicmd->cmnd[0]) {	case INQUIRY:	{		struct inquiry_data inq_data;		dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", scsicmd->device->id));		memset(&inq_data, 0, sizeof (struct inquiry_data));		inq_data.inqd_ver = 2;	/* claim compliance to SCSI-2 */		inq_data.inqd_dtq = 0x80;	/* set RMB bit to one indicating that the medium is removable */		inq_data.inqd_rdf = 2;	/* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */		inq_data.inqd_len = 31;		/*Format for "pad2" is  RelAdr | WBus32 | WBus16 |  Sync  | Linked |Reserved| CmdQue | SftRe */		inq_data.inqd_pad2= 0x32 ;	 /*WBus16|Sync|CmdQue */		/*		 *	Set the Vendor, Product, and Revision Level		 *	see: <vendor>.c i.e. aac.c		 */		if (scsicmd->device->id == host->this_id) {			setinqstr(cardtype, (void *) (inq_data.inqd_vid), (sizeof(container_types)/sizeof(char *)));			inq_data.inqd_pdt = INQD_PDT_PROC;	/* Processor device */			aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;			scsicmd->scsi_done(scsicmd);			return 0;		}		setinqstr(cardtype, (void *) (inq_data.inqd_vid), fsa_dev_ptr[cid].type);		inq_data.inqd_pdt = INQD_PDT_DA;	/* Direct/random access device */		aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));		return aac_get_container_name(scsicmd, cid);	}	case READ_CAPACITY:	{		u32 capacity;		char cp[8];		dprintk((KERN_DEBUG "READ CAPACITY command.\n"));		if (fsa_dev_ptr[cid].size <= 0x100000000LL)			capacity = fsa_dev_ptr[cid].size - 1;		else			capacity = (u32)-1;		cp[0] = (capacity >> 24) & 0xff;		cp[1] = (capacity >> 16) & 0xff;		cp[2] = (capacity >> 8) & 0xff;		cp[3] = (capacity >> 0) & 0xff;		cp[4] = 0;		cp[5] = 0;		cp[6] = 2;		cp[7] = 0;		aac_internal_transfer(scsicmd, cp, 0, sizeof(cp));		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;		scsicmd->scsi_done(scsicmd);		return 0;	}	case MODE_SENSE:	{		char mode_buf[4];		dprintk((KERN_DEBUG "MODE SENSE command.\n"));		mode_buf[0] = 3;	/* Mode data length */		mode_buf[1] = 0;	/* Medium type - default */		mode_buf[2] = 0;	/* Device-specific param, bit 8: 0/1 = write enabled/protected */		mode_buf[3] = 0;	/* Block descriptor length */		aac_internal_transfer(scsicmd, mode_buf, 0, sizeof(mode_buf));		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;		scsicmd->scsi_done(scsicmd);		return 0;	}	case MODE_SENSE_10:	{		char mode_buf[8];		dprintk((KERN_DEBUG "MODE SENSE 10 byte command.\n"));		mode_buf[0] = 0;	/* Mode data length (MSB) */		mode_buf[1] = 6;	/* Mode data length (LSB) */		mode_buf[2] = 0;	/* Medium type - default */		mode_buf[3] = 0;	/* Device-specific param, bit 8: 0/1 = write enabled/protected */		mode_buf[4] = 0;	/* reserved */		mode_buf[5] = 0;	/* reserved */		mode_buf[6] = 0;	/* Block descriptor length (MSB) */		mode_buf[7] = 0;	/* Block descriptor length (LSB) */		aac_internal_transfer(scsicmd, mode_buf, 0, sizeof(mode_buf));		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;		scsicmd->scsi_done(scsicmd);		return 0;	}	case REQUEST_SENSE:		dprintk((KERN_DEBUG "REQUEST SENSE command.\n"));		memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, sizeof (struct sense_data));		memset(&dev->fsa_dev[cid].sense_data, 0, sizeof (struct sense_data));		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;		scsicmd->scsi_done(scsicmd);		return 0;	case ALLOW_MEDIUM_REMOVAL:		dprintk((KERN_DEBUG "LOCK command.\n"));		if (scsicmd->cmnd[4])			fsa_dev_ptr[cid].locked = 1;		else			fsa_dev_ptr[cid].locked = 0;		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;		scsicmd->scsi_done(scsicmd);		return 0;	/*	 *	These commands are all No-Ops	 */	case TEST_UNIT_READY:	case RESERVE:	case RELEASE:	case REZERO_UNIT:	case REASSIGN_BLOCKS:	case SEEK_10:	case START_STOP:		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;		scsicmd->scsi_done(scsicmd);		return 0;	}	switch (scsicmd->cmnd[0]) 	{		case READ_6:		case READ_10:			/*			 *	Hack to keep track of ordinal number of the device that			 *	corresponds to a container. Needed to convert			 *	containers to /dev/sd device names			 */			 			spin_unlock_irq(host->host_lock);			if  (scsicmd->request->rq_disk)				memcpy(fsa_dev_ptr[cid].devname,					scsicmd->request->rq_disk->disk_name,					8);			ret = aac_read(scsicmd, cid);			spin_lock_irq(host->host_lock);			return ret;		case WRITE_6:		case WRITE_10:			spin_unlock_irq(host->host_lock);			ret = aac_write(scsicmd, cid);			spin_lock_irq(host->host_lock);			return ret;		case SYNCHRONIZE_CACHE:			/* Issue FIB to tell Firmware to flush it's cache */			return aac_synchronize(scsicmd, cid);					default:			/*			 *	Unhandled commands			 */			dprintk((KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0]));			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;			set_sense((u8 *) &dev->fsa_dev[cid].sense_data,				ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,				ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);			memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,			  (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))			    ? sizeof(scsicmd->sense_buffer)			    : sizeof(dev->fsa_dev[cid].sense_data));			scsicmd->scsi_done(scsicmd);			return 0;	}}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/794d0601e7a379f0188655115a3642f1e326116f/aachba.c/clean/drivers/scsi/aacraid/aachba.c