FreeBSD/sys/dev/mfi/mfi_tbolt.c
/*
 * mfi_get_cmd -	Get a command from the free pool
 * @instance:		Adapter soft state
 *
 * Returns a free command from the pool
 */
Get a command from the free pool
@instance:           Adapter soft state

Returns a free command from the pool
Get a command from the free pool @instance : Adapter soft state Returns a free command from the pool
struct mfi_cmd_tbolt *
mfi_tbolt_get_cmd(struct mfi_softc *sc, struct mfi_command *mfi_cmd)
{
	struct mfi_cmd_tbolt *cmd = NULL;
	mtx_assert(&sc->mfi_io_lock, MA_OWNED);
	if ((cmd = TAILQ_FIRST(&sc->mfi_cmd_tbolt_tqh)) == NULL)
		return (NULL);
	TAILQ_REMOVE(&sc->mfi_cmd_tbolt_tqh, cmd, next);
	memset((uint8_t *)cmd->sg_frame, 0, MEGASAS_MAX_SZ_CHAIN_FRAME);
	memset((uint8_t *)cmd->io_request, 0,
	    MEGASAS_THUNDERBOLT_NEW_MSG_SIZE);
	cmd->sync_cmd_idx = mfi_cmd->cm_index;
	mfi_cmd->cm_extra_frames = cmd->index; 
	mfi_cmd->cm_flags |= MFI_CMD_TBOLT;
	return cmd;
}
struct mfi_cmd_tbolt * mfi_tbolt_get_cmd ( struct mfi_softc * sc , struct mfi_command * mfi_cmd ) { struct mfi_cmd_tbolt * cmd = NULL ; mtx_assert ( & sc -> mfi_io_lock , MA_OWNED ) ; if ( ( cmd = TAILQ_FIRST ( & sc -> mfi_cmd_tbolt_tqh ) ) == NULL ) return ( NULL ) ; TAILQ_REMOVE ( & sc -> mfi_cmd_tbolt_tqh , cmd , next ) ; memset ( ( uint8_t * ) cmd -> sg_frame , 0 , MEGASAS_MAX_SZ_CHAIN_FRAME ) ; memset ( ( uint8_t * ) cmd -> io_request , 0 , MEGASAS_THUNDERBOLT_NEW_MSG_SIZE ) ; cmd -> sync_cmd_idx = mfi_cmd -> cm_index ; mfi_cmd -> cm_extra_frames = cmd -> index ; mfi_cmd -> cm_flags |= MFI_CMD_TBOLT ; return cmd ; }
mfi_get_cmd -        Get a command from the free pool
 @instance:           Adapter soft state
mfi_get_cmd - Get a command from the free pool @instance : Adapter soft state
/* Frame count used as SMID */