FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_build_mptmfi_passthru:	Builds a MPT MFI Passthru command
 * input:						Adapter soft state mfi cmd pointer
 *
 * The MPT command and the io_request are setup as a passthru command. The SGE
 * chain address is set to frame_phys_addr of the MFI command.
 */
Builds a MPT MFI Passthru command
input:                                               Adapter soft state mfi cmd pointer

The MPT command and the io_request are setup as a passthru command. The SGE
chain address is set to frame_phys_addr of the MFI command.
Builds a MPT MFI Passthru command input : Adapter soft state mfi cmd pointer The MPT command and the io_request are setup as a passthru command . The SGE chain address is set to frame_phys_addr of the MFI command .
u_int8_t
mrsas_build_mptmfi_passthru(struct mrsas_softc *sc, struct mrsas_mfi_cmd *mfi_cmd)
{
	MPI25_IEEE_SGE_CHAIN64 *mpi25_ieee_chain;
	PTR_MRSAS_RAID_SCSI_IO_REQUEST io_req;
	struct mrsas_mpt_cmd *mpt_cmd;
	struct mrsas_header *frame_hdr = &mfi_cmd->frame->hdr;
	mpt_cmd = mrsas_get_mpt_cmd(sc);
	if (!mpt_cmd)
		return (1);
	mfi_cmd->cmd_id.context.smid = mpt_cmd->index;
	mpt_cmd->sync_cmd_idx = mfi_cmd->index;
	if (frame_hdr->flags & MFI_FRAME_DONT_POST_IN_REPLY_QUEUE)
		mpt_cmd->flags = MFI_FRAME_DONT_POST_IN_REPLY_QUEUE;
	io_req = mpt_cmd->io_request;
	if ((sc->device_id == MRSAS_INVADER) ||
	    (sc->device_id == MRSAS_FURY) ||
	    (sc->device_id == MRSAS_INTRUDER) ||
	    (sc->device_id == MRSAS_INTRUDER_24) ||
	    (sc->device_id == MRSAS_CUTLASS_52) ||
	    (sc->device_id == MRSAS_CUTLASS_53)) {
		pMpi25IeeeSgeChain64_t sgl_ptr_end = (pMpi25IeeeSgeChain64_t)&io_req->SGL;
		sgl_ptr_end += sc->max_sge_in_main_msg - 1;
		sgl_ptr_end->Flags = 0;
	}
	mpi25_ieee_chain = (MPI25_IEEE_SGE_CHAIN64 *) & io_req->SGL.IeeeChain;
	io_req->Function = MRSAS_MPI2_FUNCTION_PASSTHRU_IO_REQUEST;
	io_req->SGLOffset0 = offsetof(MRSAS_RAID_SCSI_IO_REQUEST, SGL) / 4;
	io_req->ChainOffset = sc->chain_offset_mfi_pthru;
	mpi25_ieee_chain->Address = mfi_cmd->frame_phys_addr;
	mpi25_ieee_chain->Flags = IEEE_SGE_FLAGS_CHAIN_ELEMENT |
	    MPI2_IEEE_SGE_FLAGS_IOCPLBNTA_ADDR;
	mpi25_ieee_chain->Length = sc->max_chain_frame_sz;
	return (0);
}
u_int8_t mrsas_build_mptmfi_passthru ( struct mrsas_softc * sc , struct mrsas_mfi_cmd * mfi_cmd ) { MPI25_IEEE_SGE_CHAIN64 * mpi25_ieee_chain ; PTR_MRSAS_RAID_SCSI_IO_REQUEST io_req ; struct mrsas_mpt_cmd * mpt_cmd ; struct mrsas_header * frame_hdr = & mfi_cmd -> frame -> hdr ; mpt_cmd = mrsas_get_mpt_cmd ( sc ) ; if ( ! mpt_cmd ) return ( 1 ) ; mfi_cmd -> cmd_id . context . smid = mpt_cmd -> index ; mpt_cmd -> sync_cmd_idx = mfi_cmd -> index ; if ( frame_hdr -> flags & MFI_FRAME_DONT_POST_IN_REPLY_QUEUE ) mpt_cmd -> flags = MFI_FRAME_DONT_POST_IN_REPLY_QUEUE ; io_req = mpt_cmd -> io_request ; if ( ( sc -> device_id == MRSAS_INVADER ) || ( sc -> device_id == MRSAS_FURY ) || ( sc -> device_id == MRSAS_INTRUDER ) || ( sc -> device_id == MRSAS_INTRUDER_24 ) || ( sc -> device_id == MRSAS_CUTLASS_52 ) || ( sc -> device_id == MRSAS_CUTLASS_53 ) ) { pMpi25IeeeSgeChain64_t sgl_ptr_end = ( pMpi25IeeeSgeChain64_t ) & io_req -> SGL ; sgl_ptr_end += sc -> max_sge_in_main_msg - 1 ; sgl_ptr_end -> Flags = 0 ; } mpi25_ieee_chain = ( MPI25_IEEE_SGE_CHAIN64 * ) & io_req -> SGL . IeeeChain ; io_req -> Function = MRSAS_MPI2_FUNCTION_PASSTHRU_IO_REQUEST ; io_req -> SGLOffset0 = offsetof ( MRSAS_RAID_SCSI_IO_REQUEST , SGL ) / 4 ; io_req -> ChainOffset = sc -> chain_offset_mfi_pthru ; mpi25_ieee_chain -> Address = mfi_cmd -> frame_phys_addr ; mpi25_ieee_chain -> Flags = IEEE_SGE_FLAGS_CHAIN_ELEMENT | MPI2_IEEE_SGE_FLAGS_IOCPLBNTA_ADDR ; mpi25_ieee_chain -> Length = sc -> max_chain_frame_sz ; return ( 0 ) ; }
mrsas_build_mptmfi_passthru: Builds a MPT MFI Passthru command
 input:                                               Adapter soft state mfi cmd pointer
mrsas_build_mptmfi_passthru : Builds a MPT MFI Passthru command input : Adapter soft state mfi cmd pointer
/* Save the smid. To be used for returning the cmd */ /*
	 * For cmds where the flag is set, store the flag and check on
	 * completion. For cmds with this flag, don't call
	 * mrsas_complete_cmd.
	 */