sg_flags = 0x00000000; 
sgl_offset = SGL_OFFSET_0; 
static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,				 void (*done) (struct scsi_cmnd *)){	struct i2o_controller *c;	struct Scsi_Host *host;	struct i2o_device *i2o_dev;	struct device *dev;	int tid;	struct i2o_message __iomem *msg;	u32 m;	/*	 * ENABLE_DISCONNECT	 * SIMPLE_TAG	 * RETURN_SENSE_DATA_IN_REPLY_MESSAGE_FRAME	 */	u32 scsi_flags = 0x20a00000;	u32 sg_flags;	u32 __iomem *mptr;	u32 __iomem *lenptr;	u32 len;	int i;	/*	 *      Do the incoming paperwork	 */	i2o_dev = SCpnt->device->hostdata;	host = SCpnt->device->host;	c = i2o_dev->iop;	dev = &c->pdev->dev;	SCpnt->scsi_done = done;	if (unlikely(!i2o_dev)) {		osm_warn("no I2O device in request\n");		SCpnt->result = DID_NO_CONNECT << 16;		done(SCpnt);		return 0;	}	tid = i2o_dev->lct_data.tid;	osm_debug("qcmd: Tid = %03x\n", tid);	osm_debug("Real scsi messages.\n");	/*	 *      Obtain an I2O message. If there are none free then	 *      throw it back to the scsi layer	 */	m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);	if (m == I2O_QUEUE_EMPTY)		return SCSI_MLQUEUE_HOST_BUSY;	mptr = &msg->body[0];	/*	 *      Put together a scsi execscb message	 */	switch (SCpnt->sc_data_direction) {	case PCI_DMA_NONE:		/* DATA NO XFER */		sg_flags = 0x00000000;		break;	case PCI_DMA_TODEVICE:		/* DATA OUT (iop-->dev) */		scsi_flags |= 0x80000000;		sg_flags = 0x14000000;		break;	case PCI_DMA_FROMDEVICE:		/* DATA IN  (iop<--dev) */		scsi_flags |= 0x40000000;		sg_flags = 0x10000000;		break;	default:		/* Unknown - kill the command */		SCpnt->result = DID_NO_CONNECT << 16;		done(SCpnt);		return 0;	}	writel(I2O_CMD_SCSI_EXEC << 24 | HOST_TID << 12 | tid, &msg->u.head[1]);	writel(i2o_scsi_driver.context, &msg->u.s.icntxt);	/* We want the SCSI control block back */	writel(i2o_cntxt_list_add(c, SCpnt), &msg->u.s.tcntxt);	/* LSI_920_PCI_QUIRK	 *	 *      Intermittant observations of msg frame word data corruption	 *      observed on msg[4] after:	 *        WRITE, READ-MODIFY-WRITE	 *      operations.  19990606 -sralston	 *	 *      (Hence we build this word via tag. Its good practice anyway	 *       we don't want fetches over PCI needlessly)	 */	/* Attach tags to the devices */	/*	   if(SCpnt->device->tagged_supported) {	   if(SCpnt->tag == HEAD_OF_QUEUE_TAG)	   scsi_flags |= 0x01000000;	   else if(SCpnt->tag == ORDERED_QUEUE_TAG)	   scsi_flags |= 0x01800000;	   }	 */	writel(scsi_flags | SCpnt->cmd_len, mptr++);	/* Write SCSI command into the message - always 16 byte block */	memcpy_toio(mptr, SCpnt->cmnd, 16);	mptr += 4;	lenptr = mptr++;	/* Remember me - fill in when we know */	/* Now fill in the SGList and command */	if (SCpnt->use_sg) {		struct scatterlist *sg;		int sg_count;		sg = SCpnt->request_buffer;		len = 0;		sg_count = dma_map_sg(dev, sg, SCpnt->use_sg,				      SCpnt->sc_data_direction);		if (unlikely(sg_count <= 0))			return -ENOMEM;		for (i = SCpnt->use_sg; i > 0; i--) {			if (i == 1)				sg_flags |= 0xC0000000;			writel(sg_flags | sg_dma_len(sg), mptr++);			writel(sg_dma_address(sg), mptr++);			len += sg_dma_len(sg);			sg++;		}		writel(len, lenptr);	} else {		len = SCpnt->request_bufflen;		writel(len, lenptr);		if (len > 0) {			dma_addr_t dma_addr;			dma_addr = dma_map_single(dev, SCpnt->request_buffer,						  SCpnt->request_bufflen,						  SCpnt->sc_data_direction);			if (!dma_addr)				return -ENOMEM;			SCpnt->SCp.ptr = (void *)(unsigned long)dma_addr;			sg_flags |= 0xC0000000;			writel(sg_flags | SCpnt->request_bufflen, mptr++);			writel(dma_addr, mptr++);		}	}	/* Stick the headers on */	writel((mptr - &msg->u.head[0]) << 16 | SGL_OFFSET_10, &msg->u.head[0]);	/* Queue the message */	i2o_msg_post(c, m);	osm_debug("Issued %ld\n", SCpnt->serial_number);	return 0;};
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b2aaee33fbb354a2f08121aa1c1be55841102761/i2o_scsi.c/clean/drivers/message/i2o/i2o_scsi.c