FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_get_ld_list:           Returns FW's LD list structure input:
 * Adapter soft state
 *
 * Issues an internal command (DCMD) to get the FW's controller PD list
 * structure.  This information is mainly used to find out about supported by
 * the FW.
 */
Returns FW's LD list structure input:
Adapter soft state

Issues an internal command (DCMD) to get the FW's controller PD list
structure.  This information is mainly used to find out about supported by
the FW.
Returns FW ' s LD list structure input : Adapter soft state Issues an internal command ( DCMD ) to get the FW ' s controller PD list structure . This information is mainly used to find out about supported by the FW .
static int
mrsas_get_ld_list(struct mrsas_softc *sc)
{
	int ld_list_size, retcode = 0, ld_index = 0, ids = 0;
	u_int8_t do_ocr = 1;
	struct mrsas_mfi_cmd *cmd;
	struct mrsas_dcmd_frame *dcmd;
	struct MR_LD_LIST *ld_list_mem;
	bus_addr_t ld_list_phys_addr = 0;
	struct mrsas_tmp_dcmd *tcmd;
	cmd = mrsas_get_mfi_cmd(sc);
	if (!cmd) {
		device_printf(sc->mrsas_dev,
		    "Cannot alloc for get LD list cmd\n");
		return 1;
	}
	dcmd = &cmd->frame->dcmd;
	tcmd = malloc(sizeof(struct mrsas_tmp_dcmd), M_MRSAS, M_NOWAIT);
	ld_list_size = sizeof(struct MR_LD_LIST);
	if (mrsas_alloc_tmp_dcmd(sc, tcmd, ld_list_size) != SUCCESS) {
		device_printf(sc->mrsas_dev,
		    "Cannot alloc dmamap for get LD list cmd\n");
		mrsas_release_mfi_cmd(cmd);
		mrsas_free_tmp_dcmd(tcmd);
		free(tcmd, M_MRSAS);
		return (ENOMEM);
	} else {
		ld_list_mem = tcmd->tmp_dcmd_mem;
		ld_list_phys_addr = tcmd->tmp_dcmd_phys_addr;
	}
	memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
	if (sc->max256vdSupport)
		dcmd->mbox.b[0] = 1;
	dcmd->cmd = MFI_CMD_DCMD;
	dcmd->cmd_status = 0xFF;
	dcmd->sge_count = 1;
	dcmd->flags = MFI_FRAME_DIR_READ;
	dcmd->timeout = 0;
	dcmd->data_xfer_len = sizeof(struct MR_LD_LIST);
	dcmd->opcode = MR_DCMD_LD_GET_LIST;
	dcmd->sgl.sge32[0].phys_addr = ld_list_phys_addr;
	dcmd->sgl.sge32[0].length = sizeof(struct MR_LD_LIST);
	dcmd->pad_0 = 0;
	retcode = mrsas_issue_polled(sc, cmd);
	if (retcode == ETIMEDOUT)
		goto dcmd_timeout;
#if VD_EXT_DEBUG
	printf("Number of LDs %d\n", ld_list_mem->ldCount);
#endif
	if (ld_list_mem->ldCount <= sc->fw_supported_vd_count) {
		sc->CurLdCount = ld_list_mem->ldCount;
		memset(sc->ld_ids, 0xff, MAX_LOGICAL_DRIVES_EXT);
		for (ld_index = 0; ld_index < ld_list_mem->ldCount; ld_index++) {
			if (ld_list_mem->ldList[ld_index].state != 0) {
				ids = ld_list_mem->ldList[ld_index].ref.ld_context.targetId;
				sc->ld_ids[ids] = ld_list_mem->ldList[ld_index].ref.ld_context.targetId;
			}
		}
		do_ocr = 0;
	}
dcmd_timeout:
	mrsas_free_tmp_dcmd(tcmd);
	free(tcmd, M_MRSAS);
	if (do_ocr)
		sc->do_timedout_reset = MFI_DCMD_TIMEOUT_OCR;
	else
		mrsas_release_mfi_cmd(cmd);
	return (retcode);
}
static int mrsas_get_ld_list ( struct mrsas_softc * sc ) { int ld_list_size , retcode = 0 , ld_index = 0 , ids = 0 ; u_int8_t do_ocr = 1 ; struct mrsas_mfi_cmd * cmd ; struct mrsas_dcmd_frame * dcmd ; struct MR_LD_LIST * ld_list_mem ; bus_addr_t ld_list_phys_addr = 0 ; struct mrsas_tmp_dcmd * tcmd ; cmd = mrsas_get_mfi_cmd ( sc ) ; if ( ! cmd ) { device_printf ( sc -> mrsas_dev , " \n " ) ; return 1 ; } dcmd = & cmd -> frame -> dcmd ; tcmd = malloc ( sizeof ( struct mrsas_tmp_dcmd ) , M_MRSAS , M_NOWAIT ) ; ld_list_size = sizeof ( struct MR_LD_LIST ) ; if ( mrsas_alloc_tmp_dcmd ( sc , tcmd , ld_list_size ) != SUCCESS ) { device_printf ( sc -> mrsas_dev , " \n " ) ; mrsas_release_mfi_cmd ( cmd ) ; mrsas_free_tmp_dcmd ( tcmd ) ; free ( tcmd , M_MRSAS ) ; return ( ENOMEM ) ; } else { ld_list_mem = tcmd -> tmp_dcmd_mem ; ld_list_phys_addr = tcmd -> tmp_dcmd_phys_addr ; } memset ( dcmd -> mbox . b , 0 , MFI_MBOX_SIZE ) ; if ( sc -> max256vdSupport ) dcmd -> mbox . b [ 0 ] = 1 ; dcmd -> cmd = MFI_CMD_DCMD ; dcmd -> cmd_status = 0xFF ; dcmd -> sge_count = 1 ; dcmd -> flags = MFI_FRAME_DIR_READ ; dcmd -> timeout = 0 ; dcmd -> data_xfer_len = sizeof ( struct MR_LD_LIST ) ; dcmd -> opcode = MR_DCMD_LD_GET_LIST ; dcmd -> sgl . sge32 [ 0 ] . phys_addr = ld_list_phys_addr ; dcmd -> sgl . sge32 [ 0 ] . length = sizeof ( struct MR_LD_LIST ) ; dcmd -> pad_0 = 0 ; retcode = mrsas_issue_polled ( sc , cmd ) ; if ( retcode == ETIMEDOUT ) goto dcmd_timeout ; #if VD_EXT_DEBUG printf ( " \n " , ld_list_mem -> ldCount ) ; #endif if ( ld_list_mem -> ldCount <= sc -> fw_supported_vd_count ) { sc -> CurLdCount = ld_list_mem -> ldCount ; memset ( sc -> ld_ids , 0xff , MAX_LOGICAL_DRIVES_EXT ) ; for ( ld_index = 0 ; ld_index < ld_list_mem -> ldCount ; ld_index ++ ) { if ( ld_list_mem -> ldList [ ld_index ] . state != 0 ) { ids = ld_list_mem -> ldList [ ld_index ] . ref . ld_context . targetId ; sc -> ld_ids [ ids ] = ld_list_mem -> ldList [ ld_index ] . ref . ld_context . targetId ; } } do_ocr = 0 ; } dcmd_timeout : mrsas_free_tmp_dcmd ( tcmd ) ; free ( tcmd , M_MRSAS ) ; if ( do_ocr ) sc -> do_timedout_reset = MFI_DCMD_TIMEOUT_OCR ; else mrsas_release_mfi_cmd ( cmd ) ; return ( retcode ) ; }
mrsas_get_ld_list:           Returns FW's LD list structure input:
 Adapter soft state
mrsas_get_ld_list : Returns FW ' s LD list structure input : Adapter soft state
/* Get the instance LD list */