FreeBSD/sys/dev/mps/mps.c
/*
 * Add a chain element as the next SGE for the specified command.
 * Reset cm_sge and cm_sgesize to indicate all the available space.
 */
Add a chain element as the next SGE for the specified command.
Reset cm_sge and cm_sgesize to indicate all the available space.
Add a chain element as the next SGE for the specified command . Reset cm_sge and cm_sgesize to indicate all the available space .
static int
mps_add_chain(struct mps_command *cm)
{
	MPI2_SGE_CHAIN32 *sgc;
	struct mps_chain *chain;
	int space;
	if (cm->cm_sglsize < MPS_SGC_SIZE)
		panic("MPS: Need SGE Error Code\n");
	chain = mps_alloc_chain(cm->cm_sc);
	if (chain == NULL)
		return (ENOBUFS);
	space = (int)cm->cm_sc->facts->IOCRequestFrameSize * 4;
	TAILQ_INSERT_TAIL(&cm->cm_chain_list, chain, chain_link);
	sgc = (MPI2_SGE_CHAIN32 *)&cm->cm_sge->MpiChain;
	sgc->Length = htole16(space);
	sgc->NextChainOffset = 0;
	sgc->Flags = MPI2_SGE_FLAGS_CHAIN_ELEMENT;
	sgc->Address = htole32(chain->chain_busaddr);
	cm->cm_sge = (MPI2_SGE_IO_UNION *)&chain->chain->MpiSimple;
	cm->cm_sglsize = space;
	return (0);
}
static int mps_add_chain ( struct mps_command * cm ) { MPI2_SGE_CHAIN32 * sgc ; struct mps_chain * chain ; int space ; if ( cm -> cm_sglsize < MPS_SGC_SIZE ) panic ( " \n " ) ; chain = mps_alloc_chain ( cm -> cm_sc ) ; if ( chain == NULL ) return ( ENOBUFS ) ; space = ( int ) cm -> cm_sc -> facts -> IOCRequestFrameSize * 4 ; TAILQ_INSERT_TAIL ( & cm -> cm_chain_list , chain , chain_link ) ; sgc = ( MPI2_SGE_CHAIN32 * ) & cm -> cm_sge -> MpiChain ; sgc -> Length = htole16 ( space ) ; sgc -> NextChainOffset = 0 ; sgc -> Flags = MPI2_SGE_FLAGS_CHAIN_ELEMENT ; sgc -> Address = htole32 ( chain -> chain_busaddr ) ; cm -> cm_sge = ( MPI2_SGE_IO_UNION * ) & chain -> chain -> MpiSimple ; cm -> cm_sglsize = space ; return ( 0 ) ; }
Add a chain element as the next SGE for the specified command.
Add a chain element as the next SGE for the specified command .
/*
	 * Note: a double-linked list is used to make it easier to
	 * walk for debugging.
	 */ /* TODO Looks like bug in Setting sgc->Flags. 
	 *	sgc->Flags = ( MPI2_SGE_FLAGS_CHAIN_ELEMENT | MPI2_SGE_FLAGS_64_BIT_ADDRESSING |
	 *	            MPI2_SGE_FLAGS_SYSTEM_ADDRESS) << MPI2_SGE_FLAGS_SHIFT
	 *	This is fine.. because we are not using simple element. In case of 
	 *	MPI2_SGE_CHAIN32, we have separate Length and Flags feild.
 	 */