status = facts->IOCStatus & MPI_IOCSTATUS_MASK; 
status = le16_to_cpu(facts->IOCStatus) & MPI_IOCSTATUS_MASK; 
GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason){	IOCFacts_t		 get_facts;	IOCFactsReply_t		*facts;	int			 r;	int			 req_sz;	int			 reply_sz;	int			 sz;	u32			 status, vv;	u8			 shiftFactor=1;	/* IOC *must* NOT be in RESET state! */	if (ioc->last_state == MPI_IOC_STATE_RESET) {		printk(KERN_ERR MYNAM ": ERROR - Can't get IOCFacts, %s NOT READY! (%08x)\n",				ioc->name,				ioc->last_state );		return -44;	}	facts = &ioc->facts;	/* Destination (reply area)... */	reply_sz = sizeof(*facts);	memset(facts, 0, reply_sz);	/* Request area (get_facts on the stack right now!) */	req_sz = sizeof(get_facts);	memset(&get_facts, 0, req_sz);	get_facts.Function = MPI_FUNCTION_IOC_FACTS;	/* Assert: All other get_facts fields are zero! */	dinitprintk((MYIOC_s_INFO_FMT 	    "Sending get IocFacts request req_sz=%d reply_sz=%d\n", 	    ioc->name, req_sz, reply_sz));	/* No non-zero fields in the get_facts request are greater than	 * 1 byte in size, so we can just fire it off as is.	 */	r = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&get_facts,			reply_sz, (u16*)facts, 5 /*seconds*/, sleepFlag);	if (r != 0)		return r;	/*	 * Now byte swap (GRRR) the necessary fields before any further	 * inspection of reply contents.	 *	 * But need to do some sanity checks on MsgLength (byte) field	 * to make sure we don't zero IOC's req_sz!	 */	/* Did we get a valid reply? */	if (facts->MsgLength > offsetof(IOCFactsReply_t, RequestFrameSize)/sizeof(u32)) {		if (reason == MPT_HOSTEVENT_IOC_BRINGUP) {			/*			 * If not been here, done that, save off first WhoInit value			 */			if (ioc->FirstWhoInit == WHOINIT_UNKNOWN)				ioc->FirstWhoInit = facts->WhoInit;		}		facts->MsgVersion = le16_to_cpu(facts->MsgVersion);		facts->MsgContext = le32_to_cpu(facts->MsgContext);		facts->IOCExceptions = le16_to_cpu(facts->IOCExceptions);		facts->IOCStatus = le16_to_cpu(facts->IOCStatus);		facts->IOCLogInfo = le32_to_cpu(facts->IOCLogInfo);		status = facts->IOCStatus & MPI_IOCSTATUS_MASK;		/* CHECKME! IOCStatus, IOCLogInfo */		facts->ReplyQueueDepth = le16_to_cpu(facts->ReplyQueueDepth);		facts->RequestFrameSize = le16_to_cpu(facts->RequestFrameSize);		/*		 * FC f/w version changed between 1.1 and 1.2		 *	Old: u16{Major(4),Minor(4),SubMinor(8)}		 *	New: u32{Major(8),Minor(8),Unit(8),Dev(8)}		 */		if (facts->MsgVersion < 0x0102) {			/*			 *	Handle old FC f/w style, convert to new...			 */			u16	 oldv = le16_to_cpu(facts->Reserved_0101_FWVersion);			facts->FWVersion.Word =					((oldv<<12) & 0xFF000000) |					((oldv<<8)  & 0x000FFF00);		} else			facts->FWVersion.Word = le32_to_cpu(facts->FWVersion.Word);		facts->ProductID = le16_to_cpu(facts->ProductID);		facts->CurrentHostMfaHighAddr =				le32_to_cpu(facts->CurrentHostMfaHighAddr);		facts->GlobalCredits = le16_to_cpu(facts->GlobalCredits);		facts->CurrentSenseBufferHighAddr =				le32_to_cpu(facts->CurrentSenseBufferHighAddr);		facts->CurReplyFrameSize =				le16_to_cpu(facts->CurReplyFrameSize);		/*		 * Handle NEW (!) IOCFactsReply fields in MPI-1.01.xx		 * Older MPI-1.00.xx struct had 13 dwords, and enlarged		 * to 14 in MPI-1.01.0x.		 */		if (facts->MsgLength >= (offsetof(IOCFactsReply_t,FWImageSize) + 7)/4 &&		    facts->MsgVersion > 0x0100) {			facts->FWImageSize = le32_to_cpu(facts->FWImageSize);		}		sz = facts->FWImageSize;		if ( sz & 0x01 )			sz += 1;		if ( sz & 0x02 )			sz += 2;		facts->FWImageSize = sz;				if (!facts->RequestFrameSize) {			/*  Something is wrong!  */			printk(MYIOC_s_ERR_FMT "IOC reported invalid 0 request size!\n",					ioc->name);			return -55;		}		r = sz = facts->BlockSize;		vv = ((63 / (sz * 4)) + 1) & 0x03;		ioc->NB_for_64_byte_frame = vv;		while ( sz )		{			shiftFactor++;			sz = sz >> 1;		}		ioc->NBShiftFactor  = shiftFactor;		dinitprintk((MYIOC_s_INFO_FMT "NB_for_64_byte_frame=%x NBShiftFactor=%x BlockSize=%x\n",					ioc->name, vv, shiftFactor, r));    		if (reason == MPT_HOSTEVENT_IOC_BRINGUP) {			/*			 * Set values for this IOC's request & reply frame sizes,			 * and request & reply queue depths...			 */			ioc->req_sz = min(MPT_DEFAULT_FRAME_SIZE, facts->RequestFrameSize * 4);			ioc->req_depth = min_t(int, MPT_MAX_REQ_DEPTH, facts->GlobalCredits);			ioc->reply_sz = MPT_REPLY_FRAME_SIZE;			ioc->reply_depth = min_t(int, MPT_DEFAULT_REPLY_DEPTH, facts->ReplyQueueDepth);			dinitprintk((MYIOC_s_INFO_FMT "reply_sz=%3d, reply_depth=%4d\n",				ioc->name, ioc->reply_sz, ioc->reply_depth));			dinitprintk((MYIOC_s_INFO_FMT "req_sz  =%3d, req_depth  =%4d\n",				ioc->name, ioc->req_sz, ioc->req_depth));			/* Get port facts! */			if ( (r = GetPortFacts(ioc, 0, sleepFlag)) != 0 )				return r;		}	} else {		printk(MYIOC_s_ERR_FMT 		     "Invalid IOC facts reply, msgLength=%d offsetof=%zd!\n",		     ioc->name, facts->MsgLength, (offsetof(IOCFactsReply_t,		     RequestFrameSize)/sizeof(u32)));		return -66;	}	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/637fa99b86a00a0b5767a982b83a512ff48ad6d2/mptbase.c/clean/drivers/message/fusion/mptbase.c