FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_sync_map_info:        Get FW's ld_map structure input:
 * Adapter instance soft state
 *
 * Issues an internal command (DCMD) to get the FW's controller PD list
 * structure.
 */
Get FW's ld_map structure input:
Adapter instance soft state

Issues an internal command (DCMD) to get the FW's controller PD list
structure.
Get FW ' s ld_map structure input : Adapter instance soft state Issues an internal command ( DCMD ) to get the FW ' s controller PD list structure .
static int
mrsas_sync_map_info(struct mrsas_softc *sc)
{
	int retcode = 0, i;
	struct mrsas_mfi_cmd *cmd;
	struct mrsas_dcmd_frame *dcmd;
	uint32_t size_sync_info, num_lds;
	MR_LD_TARGET_SYNC *target_map = NULL;
	MR_DRV_RAID_MAP_ALL *map;
	MR_LD_RAID *raid;
	MR_LD_TARGET_SYNC *ld_sync;
	bus_addr_t map_phys_addr = 0;
	cmd = mrsas_get_mfi_cmd(sc);
	if (!cmd) {
		device_printf(sc->mrsas_dev,
		    "Cannot alloc for sync map info cmd\n");
		return 1;
	}
	map = sc->ld_drv_map[sc->map_id & 1];
	num_lds = map->raidMap.ldCount;
	dcmd = &cmd->frame->dcmd;
	size_sync_info = sizeof(MR_LD_TARGET_SYNC) * num_lds;
	memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
	target_map = (MR_LD_TARGET_SYNC *) sc->raidmap_mem[(sc->map_id - 1) & 1];
	memset(target_map, 0, sc->max_map_sz);
	map_phys_addr = sc->raidmap_phys_addr[(sc->map_id - 1) & 1];
	ld_sync = (MR_LD_TARGET_SYNC *) target_map;
	for (i = 0; i < num_lds; i++, ld_sync++) {
		raid = MR_LdRaidGet(i, map);
		ld_sync->targetId = MR_GetLDTgtId(i, map);
		ld_sync->seqNum = raid->seqNum;
	}
	dcmd->cmd = MFI_CMD_DCMD;
	dcmd->cmd_status = 0xFF;
	dcmd->sge_count = 1;
	dcmd->flags = MFI_FRAME_DIR_WRITE;
	dcmd->timeout = 0;
	dcmd->pad_0 = 0;
	dcmd->data_xfer_len = sc->current_map_sz;
	dcmd->mbox.b[0] = num_lds;
	dcmd->mbox.b[1] = MRSAS_DCMD_MBOX_PEND_FLAG;
	dcmd->opcode = MR_DCMD_LD_MAP_GET_INFO;
	dcmd->sgl.sge32[0].phys_addr = map_phys_addr;
	dcmd->sgl.sge32[0].length = sc->current_map_sz;
	sc->map_update_cmd = cmd;
	if (mrsas_issue_dcmd(sc, cmd)) {
		device_printf(sc->mrsas_dev,
		    "Fail to send sync map info command.\n");
		return (1);
	}
	return (retcode);
}
static int mrsas_sync_map_info ( struct mrsas_softc * sc ) { int retcode = 0 , i ; struct mrsas_mfi_cmd * cmd ; struct mrsas_dcmd_frame * dcmd ; uint32_t size_sync_info , num_lds ; MR_LD_TARGET_SYNC * target_map = NULL ; MR_DRV_RAID_MAP_ALL * map ; MR_LD_RAID * raid ; MR_LD_TARGET_SYNC * ld_sync ; bus_addr_t map_phys_addr = 0 ; cmd = mrsas_get_mfi_cmd ( sc ) ; if ( ! cmd ) { device_printf ( sc -> mrsas_dev , " \n " ) ; return 1 ; } map = sc -> ld_drv_map [ sc -> map_id & 1 ] ; num_lds = map -> raidMap . ldCount ; dcmd = & cmd -> frame -> dcmd ; size_sync_info = sizeof ( MR_LD_TARGET_SYNC ) * num_lds ; memset ( dcmd -> mbox . b , 0 , MFI_MBOX_SIZE ) ; target_map = ( MR_LD_TARGET_SYNC * ) sc -> raidmap_mem [ ( sc -> map_id - 1 ) & 1 ] ; memset ( target_map , 0 , sc -> max_map_sz ) ; map_phys_addr = sc -> raidmap_phys_addr [ ( sc -> map_id - 1 ) & 1 ] ; ld_sync = ( MR_LD_TARGET_SYNC * ) target_map ; for ( i = 0 ; i < num_lds ; i ++ , ld_sync ++ ) { raid = MR_LdRaidGet ( i , map ) ; ld_sync -> targetId = MR_GetLDTgtId ( i , map ) ; ld_sync -> seqNum = raid -> seqNum ; } dcmd -> cmd = MFI_CMD_DCMD ; dcmd -> cmd_status = 0xFF ; dcmd -> sge_count = 1 ; dcmd -> flags = MFI_FRAME_DIR_WRITE ; dcmd -> timeout = 0 ; dcmd -> pad_0 = 0 ; dcmd -> data_xfer_len = sc -> current_map_sz ; dcmd -> mbox . b [ 0 ] = num_lds ; dcmd -> mbox . b [ 1 ] = MRSAS_DCMD_MBOX_PEND_FLAG ; dcmd -> opcode = MR_DCMD_LD_MAP_GET_INFO ; dcmd -> sgl . sge32 [ 0 ] . phys_addr = map_phys_addr ; dcmd -> sgl . sge32 [ 0 ] . length = sc -> current_map_sz ; sc -> map_update_cmd = cmd ; if ( mrsas_issue_dcmd ( sc , cmd ) ) { device_printf ( sc -> mrsas_dev , " \n " ) ; return ( 1 ) ; } return ( retcode ) ; }
mrsas_sync_map_info:        Get FW's ld_map structure input:
 Adapter instance soft state
mrsas_sync_map_info : Get FW ' s ld_map structure input : Adapter instance soft state