FreeBSD/sys/dev/mrsas/mrsas_ioctl.c
/*
 * mrsas_create_frame_pool:	Creates DMA pool for cmd frames
 * input:					Adapter soft state
 *
 * Each command packet has an embedded DMA memory buffer that is used for
 * filling MFI frame and the SG list that immediately follows the frame. This
 * function creates those DMA memory buffers for each command packet by using
 * PCI pool facility. pad_0 is initialized to 0 to prevent corrupting value
 * of context and could cause FW crash.
 */
Creates DMA pool for cmd frames
input:                                       Adapter soft state

Each command packet has an embedded DMA memory buffer that is used for
filling MFI frame and the SG list that immediately follows the frame. This
function creates those DMA memory buffers for each command packet by using
PCI pool facility. pad_0 is initialized to 0 to prevent corrupting value
of context and could cause FW crash.
Creates DMA pool for cmd frames input : Adapter soft state Each command packet has an embedded DMA memory buffer that is used for filling MFI frame and the SG list that immediately follows the frame . This function creates those DMA memory buffers for each command packet by using PCI pool facility . pad_0 is initialized to 0 to prevent corrupting value of context and could cause FW crash .
static int
mrsas_create_frame_pool(struct mrsas_softc *sc)
{
	int i;
	struct mrsas_mfi_cmd *cmd;
	if (bus_dma_tag_create(sc->mrsas_parent_tag,
	    1, 0,
	    BUS_SPACE_MAXADDR_32BIT,
	    BUS_SPACE_MAXADDR,
	    NULL, NULL,
	    MRSAS_MFI_FRAME_SIZE,
	    1,
	    MRSAS_MFI_FRAME_SIZE,
	    BUS_DMA_ALLOCNOW,
	    NULL, NULL,
	    &sc->mficmd_frame_tag)) {
		device_printf(sc->mrsas_dev, "Cannot create MFI frame tag\n");
		return (ENOMEM);
	}
	for (i = 0; i < MRSAS_MAX_MFI_CMDS; i++) {
		cmd = sc->mfi_cmd_list[i];
		cmd->frame = mrsas_alloc_frame(sc, cmd);
		if (cmd->frame == NULL) {
			device_printf(sc->mrsas_dev, "Cannot alloc MFI frame memory\n");
			return (ENOMEM);
		}
		memset(cmd->frame, 0, MRSAS_MFI_FRAME_SIZE);
		cmd->frame->io.context = cmd->index;
		cmd->frame->io.pad_0 = 0;
	}
	return (0);
}
static int mrsas_create_frame_pool ( struct mrsas_softc * sc ) { int i ; struct mrsas_mfi_cmd * cmd ; if ( bus_dma_tag_create ( sc -> mrsas_parent_tag , 1 , 0 , BUS_SPACE_MAXADDR_32BIT , BUS_SPACE_MAXADDR , NULL , NULL , MRSAS_MFI_FRAME_SIZE , 1 , MRSAS_MFI_FRAME_SIZE , BUS_DMA_ALLOCNOW , NULL , NULL , & sc -> mficmd_frame_tag ) ) { device_printf ( sc -> mrsas_dev , " \n " ) ; return ( ENOMEM ) ; } for ( i = 0 ; i < MRSAS_MAX_MFI_CMDS ; i ++ ) { cmd = sc -> mfi_cmd_list [ i ] ; cmd -> frame = mrsas_alloc_frame ( sc , cmd ) ; if ( cmd -> frame == NULL ) { device_printf ( sc -> mrsas_dev , " \n " ) ; return ( ENOMEM ) ; } memset ( cmd -> frame , 0 , MRSAS_MFI_FRAME_SIZE ) ; cmd -> frame -> io . context = cmd -> index ; cmd -> frame -> io . pad_0 = 0 ; } return ( 0 ) ; }
mrsas_create_frame_pool:     Creates DMA pool for cmd frames
 input:                                       Adapter soft state
mrsas_create_frame_pool : Creates DMA pool for cmd frames input : Adapter soft state
/*
		 * For MFI controllers.
		 * max_num_sge = 60
		 * max_sge_sz  = 16 byte (sizeof megasas_sge_skinny)
		 * Totl 960 byte (15 MFI frame of 64 byte)
		 *
		 * Fusion adapter require only 3 extra frame.
		 * max_num_sge = 16 (defined as MAX_IOCTL_SGE)
		 * max_sge_sz  = 12 byte (sizeof  megasas_sge64)
		 * Total 192 byte (3 MFI frame of 64 byte)
		 */