FreeBSD/sys/dev/mrsas/mrsas.c
/*
 *  mrsas_get_seq_num:	Get latest event sequence number
 *  @sc:				Adapter soft state
 *  @eli:				Firmware event log sequence number information.
 *
 * Firmware maintains a log of all events in a non-volatile area.
 * Driver get the sequence number using DCMD
 * "MR_DCMD_CTRL_EVENT_GET_INFO" at driver load time.
 */
Get latest event sequence number
@sc:                                Adapter soft state
@eli:                               Firmware event log sequence number information.

Firmware maintains a log of all events in a non-volatile area.
Driver get the sequence number using DCMD
"MR_DCMD_CTRL_EVENT_GET_INFO" at driver load time.
Get latest event sequence number @sc : Adapter soft state @eli : Firmware event log sequence number information . Firmware maintains a log of all events in a non - volatile area . Driver get the sequence number using DCMD " MR_DCMD_CTRL_EVENT_GET_INFO " at driver load time .
static int
mrsas_get_seq_num(struct mrsas_softc *sc,
    struct mrsas_evt_log_info *eli)
{
	struct mrsas_mfi_cmd *cmd;
	struct mrsas_dcmd_frame *dcmd;
	u_int8_t do_ocr = 1, retcode = 0;
	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_evt_log_info_cmd(sc) != SUCCESS) {
		device_printf(sc->mrsas_dev, "Cannot allocate evt log 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 = 0x0;
	dcmd->sge_count = 1;
	dcmd->flags = MFI_FRAME_DIR_READ;
	dcmd->timeout = 0;
	dcmd->pad_0 = 0;
	dcmd->data_xfer_len = sizeof(struct mrsas_evt_log_info);
	dcmd->opcode = MR_DCMD_CTRL_EVENT_GET_INFO;
	dcmd->sgl.sge32[0].phys_addr = sc->el_info_phys_addr;
	dcmd->sgl.sge32[0].length = sizeof(struct mrsas_evt_log_info);
	retcode = mrsas_issue_blocked_cmd(sc, cmd);
	if (retcode == ETIMEDOUT)
		goto dcmd_timeout;
	do_ocr = 0;
	memcpy(eli, sc->el_info_mem, sizeof(struct mrsas_evt_log_info));
	mrsas_free_evt_log_info_cmd(sc);
dcmd_timeout:
	if (do_ocr)
		sc->do_timedout_reset = MFI_DCMD_TIMEOUT_OCR;
	else
		mrsas_release_mfi_cmd(cmd);
	return retcode;
}
static int mrsas_get_seq_num ( struct mrsas_softc * sc , struct mrsas_evt_log_info * eli ) { struct mrsas_mfi_cmd * cmd ; struct mrsas_dcmd_frame * dcmd ; u_int8_t do_ocr = 1 , retcode = 0 ; cmd = mrsas_get_mfi_cmd ( sc ) ; if ( ! cmd ) { device_printf ( sc -> mrsas_dev , " \n " ) ; return - ENOMEM ; } dcmd = & cmd -> frame -> dcmd ; if ( mrsas_alloc_evt_log_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 = 0x0 ; dcmd -> sge_count = 1 ; dcmd -> flags = MFI_FRAME_DIR_READ ; dcmd -> timeout = 0 ; dcmd -> pad_0 = 0 ; dcmd -> data_xfer_len = sizeof ( struct mrsas_evt_log_info ) ; dcmd -> opcode = MR_DCMD_CTRL_EVENT_GET_INFO ; dcmd -> sgl . sge32 [ 0 ] . phys_addr = sc -> el_info_phys_addr ; dcmd -> sgl . sge32 [ 0 ] . length = sizeof ( struct mrsas_evt_log_info ) ; retcode = mrsas_issue_blocked_cmd ( sc , cmd ) ; if ( retcode == ETIMEDOUT ) goto dcmd_timeout ; do_ocr = 0 ; memcpy ( eli , sc -> el_info_mem , sizeof ( struct mrsas_evt_log_info ) ) ; mrsas_free_evt_log_info_cmd ( sc ) ; dcmd_timeout : if ( do_ocr ) sc -> do_timedout_reset = MFI_DCMD_TIMEOUT_OCR ; else mrsas_release_mfi_cmd ( cmd ) ; return retcode ; }
mrsas_get_seq_num:  Get latest event sequence number
  @sc:                                Adapter soft state
  @eli:                               Firmware event log sequence number information.
mrsas_get_seq_num : Get latest event sequence number @sc : Adapter soft state @eli : Firmware event log sequence number information .
/*
	 * Copy the data back into callers buffer
	 */