FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_get_controller_info:	Returns FW's controller structure
 * input:						Adapter soft state
 * 								Controller information structure
 *
 * Issues an internal command (DCMD) to get the FW's controller structure. This
 * information is mainly used to find out the maximum IO transfer per command
 * supported by the FW.
 */
Returns FW's controller structure
input:                                               Adapter soft state
Controller information structure

Issues an internal command (DCMD) to get the FW's controller structure. This
information is mainly used to find out the maximum IO transfer per command
supported by the FW.
Returns FW ' s controller structure input : Adapter soft state Controller information structure Issues an internal command ( DCMD ) to get the FW ' s controller structure . This information is mainly used to find out the maximum IO transfer per command supported by the FW .
static int
mrsas_get_ctrl_info(struct mrsas_softc *sc)
{
	int retcode = 0;
	u_int8_t do_ocr = 1;
	struct mrsas_mfi_cmd *cmd;
	struct mrsas_dcmd_frame *dcmd;
	cmd = mrsas_get_mfi_cmd(sc);
	if (!cmd) {
		device_printf(sc->mrsas_dev, "Failed to get a free cmd\n");
		return -ENOMEM;
	}
	dcmd = &cmd->frame->dcmd;
	if (mrsas_alloc_ctlr_info_cmd(sc) != SUCCESS) {
		device_printf(sc->mrsas_dev, "Cannot allocate get ctlr info cmd\n");
		mrsas_release_mfi_cmd(cmd);
		return -ENOMEM;
	}
	memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
	dcmd->cmd = MFI_CMD_DCMD;
	dcmd->cmd_status = 0xFF;
	dcmd->sge_count = 1;
	dcmd->flags = MFI_FRAME_DIR_READ;
	dcmd->timeout = 0;
	dcmd->pad_0 = 0;
	dcmd->data_xfer_len = sizeof(struct mrsas_ctrl_info);
	dcmd->opcode = MR_DCMD_CTRL_GET_INFO;
	dcmd->sgl.sge32[0].phys_addr = sc->ctlr_info_phys_addr;
	dcmd->sgl.sge32[0].length = sizeof(struct mrsas_ctrl_info);
	retcode = mrsas_issue_polled(sc, cmd);
	if (retcode == ETIMEDOUT)
		goto dcmd_timeout;
	else
		memcpy(sc->ctrl_info, sc->ctlr_info_mem, sizeof(struct mrsas_ctrl_info));
	do_ocr = 0;
	mrsas_update_ext_vd_details(sc);
	sc->use_seqnum_jbod_fp =
	    sc->ctrl_info->adapterOperations3.useSeqNumJbodFP;
dcmd_timeout:
	mrsas_free_ctlr_info_cmd(sc);
	if (do_ocr)
		sc->do_timedout_reset = MFI_DCMD_TIMEOUT_OCR;
	else
		mrsas_release_mfi_cmd(cmd);
	return (retcode);
}
static int mrsas_get_ctrl_info ( struct mrsas_softc * sc ) { int retcode = 0 ; u_int8_t do_ocr = 1 ; struct mrsas_mfi_cmd * cmd ; struct mrsas_dcmd_frame * dcmd ; cmd = mrsas_get_mfi_cmd ( sc ) ; if ( ! cmd ) { device_printf ( sc -> mrsas_dev , " \n " ) ; return - ENOMEM ; } dcmd = & cmd -> frame -> dcmd ; if ( mrsas_alloc_ctlr_info_cmd ( sc ) != SUCCESS ) { device_printf ( sc -> mrsas_dev , " \n " ) ; mrsas_release_mfi_cmd ( cmd ) ; return - ENOMEM ; } memset ( dcmd -> mbox . b , 0 , MFI_MBOX_SIZE ) ; dcmd -> cmd = MFI_CMD_DCMD ; dcmd -> cmd_status = 0xFF ; dcmd -> sge_count = 1 ; dcmd -> flags = MFI_FRAME_DIR_READ ; dcmd -> timeout = 0 ; dcmd -> pad_0 = 0 ; dcmd -> data_xfer_len = sizeof ( struct mrsas_ctrl_info ) ; dcmd -> opcode = MR_DCMD_CTRL_GET_INFO ; dcmd -> sgl . sge32 [ 0 ] . phys_addr = sc -> ctlr_info_phys_addr ; dcmd -> sgl . sge32 [ 0 ] . length = sizeof ( struct mrsas_ctrl_info ) ; retcode = mrsas_issue_polled ( sc , cmd ) ; if ( retcode == ETIMEDOUT ) goto dcmd_timeout ; else memcpy ( sc -> ctrl_info , sc -> ctlr_info_mem , sizeof ( struct mrsas_ctrl_info ) ) ; do_ocr = 0 ; mrsas_update_ext_vd_details ( sc ) ; sc -> use_seqnum_jbod_fp = sc -> ctrl_info -> adapterOperations3 . useSeqNumJbodFP ; dcmd_timeout : mrsas_free_ctlr_info_cmd ( sc ) ; if ( do_ocr ) sc -> do_timedout_reset = MFI_DCMD_TIMEOUT_OCR ; else mrsas_release_mfi_cmd ( cmd ) ; return ( retcode ) ; }
mrsas_get_controller_info:   Returns FW's controller structure
 input:                                               Adapter soft state
                                                              Controller information structure
mrsas_get_controller_info : Returns FW ' s controller structure input : Adapter soft state Controller information structure