mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req,				int replyBytes, u16 *u16reply, int maxwait, int sleepFlag){	MPIDefaultReply_t *mptReply;	int failcnt = 0;	int t;	/*	 * Get ready to cache a handshake reply	 */	ioc->hs_reply_idx = 0;	mptReply = (MPIDefaultReply_t *) ioc->hs_reply;	mptReply->MsgLength = 0;	/*	 * Make sure there are no doorbells (WRITE 0 to IntStatus reg),	 * then tell IOC that we want to handshake a request of N words.	 * (WRITE u32val to Doorbell reg).	 */	CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);	CHIPREG_WRITE32(&ioc->chip->Doorbell,			((MPI_FUNCTION_HANDSHAKE<<MPI_DOORBELL_FUNCTION_SHIFT) |			 ((reqBytes/4)<<MPI_DOORBELL_ADD_DWORDS_SHIFT)));	/*	 * Wait for IOC's doorbell handshake int	 */	if ((t = WaitForDoorbellInt(ioc, 5, sleepFlag)) < 0)		failcnt++;	dhsprintk((MYIOC_s_INFO_FMT "HandShake request start reqBytes=%d, WaitCnt=%d%s\n",			ioc->name, reqBytes, t, failcnt ? " - MISSING DOORBELL HANDSHAKE!" : ""));	/* Read doorbell and check for active bit */	if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE))			return -1;	/*	 * Clear doorbell int (WRITE 0 to IntStatus reg),	 * then wait for IOC to ACKnowledge that it's ready for	 * our handshake request.	 */	CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);	if (!failcnt && (t = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0)		failcnt++;	if (!failcnt) {		int	 ii;		u8	*req_as_bytes = (u8 *) req;		/*		 * Stuff request words via doorbell handshake,		 * with ACK from IOC for each.		 */		for (ii = 0; !failcnt && ii < reqBytes/4; ii++) {			u32 word = ((req_as_bytes[(ii*4) + 0] <<  0) |				    (req_as_bytes[(ii*4) + 1] <<  8) |				    (req_as_bytes[(ii*4) + 2] << 16) |				    (req_as_bytes[(ii*4) + 3] << 24));			CHIPREG_WRITE32(&ioc->chip->Doorbell, word);			if ((t = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0)				failcnt++;		}		dhsprintk((KERN_INFO MYNAM ": Handshake request frame (@%p) header\n", req));		DBG_DUMP_REQUEST_FRAME_HDR(req)		dhsprintk((MYIOC_s_INFO_FMT "HandShake request post done, WaitCnt=%d%s\n",				ioc->name, t, failcnt ? " - MISSING DOORBELL ACK!" : ""));		/*		 * Wait for completion of doorbell handshake reply from the IOC		 */		if (!failcnt && (t = WaitForDoorbellReply(ioc, maxwait, sleepFlag)) < 0)			failcnt++;				dhsprintk((MYIOC_s_INFO_FMT "HandShake reply count=%d%s\n",				ioc->name, t, failcnt ? " - MISSING DOORBELL REPLY!" : ""));		/*		 * Copy out the cached reply...		 */		for (ii=0; ii < min(replyBytes/2,mptReply->MsgLength*2); ii++)			u16reply[ii] = ioc->hs_reply[ii];	} else {		return -99;	}	return -failcnt;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/c6678e0cfb41b029c3600c54b5bb65954de1230a/mptbase.c/clean/drivers/message/fusion/mptbase.c