📄 eng_scsi.h
字号:
#if !defined( ENGINE_SCSI3_H )
#define ENGINE_SCSI3_H
#include "gen_typs.h"
/* scsi3 opcode and CDB bits */
#define svucSCSI_COMMAND 0x60
#define scsiINQUIRY 0x12
#define scsiMODE_SELECT_6 0x15
#define scsiMODE_SELECT_10 0x55
#define scsiMODE_SENSE_6 0x1A
#define scsiMODE_SENSE_10 0x5A
#define scsiREAD_6 0x08
#define scsiREAD_10 0x28
#define scsiREAD_CAPACITY 0x25
#define scsiREQUEST_SENSE 0x03
#define scsiREZERO_UNIT 0x01
#define scsiSEEK_6 0x0B
#define scsiSEEK_10 0x2B
#define scsiSTART_STOP_UNIT 0x1B
#define scsiTEST_UNIT_READY 0x00
#define scsiVERIFY 0x2F
#define scsiWRITE_6 0x0A
#define scsiWRITE_10 0x2A
#define scsiWRITE_VERIFY 0x2E
#define scsiSYNCHRONIZE_CACHE 0x35
#define scsiREAD_16 0x88 /* to be supported */
#define scsiWRITE_16 0x8A /* to be supported */
#define scsiVERIFY_16 0x8F /* to be supported */
#define scsiREAD_CAPACITY_16 0x9E /* to be supported */
#define scsiRESERVE 0x16
#define scsiRELEASE 0x17
#define scsiIsRead( cmd ) (((cmd)==scsiREAD_10) || ((cmd)==scsiREAD_16))
#define scsiIsWrite( cmd ) (((cmd)==scsiWRITE_10) || ((cmd)==scsiWRITE_16))
#define scsiIsVerify( cmd ) (((cmd)==scsiVERIFY) || ((cmd)==scsiVERIFY_16))
#define scsiIsReadWrite( cmd ) (scsiIsRead(cmd) || scsiIsWrite(cmd))
#define scsiIs16BAccessCmd( cmd ) (((cmd)==scsiREAD_16) || ((cmd)==scsiWRITE_16) || ((cmd)==scsiVERIFY_16))
#if defined(ENGINE_SUPPORT_LARGE_LU)
#define scsiREAD_DEFAULT scsiREAD_16
#define scsiWRITE_DEFAULT scsiWRITE_16
#else /*ENGINE_SUPPORT_LARGE_LU*/
#define scsiREAD_DEFAULT scsiREAD_10
#define scsiWRITE_DEFAULT scsiWRITE_10
#endif /*ENGINE_SUPPORT_LARGE_LU*/
/* Promise unique opcodes */
#define svucARRAY_COMMAND 0xE0
#if !defined(BIOS)
/* array command sub opcodes */
#define acmdARRAY_CONTROL 0x00
#define acmdGET_ARRAY_CONFIG 0x01
#define acmdSET_ARRAY_CONFIG 0x02
#define acmdBGA_START 0x03
#define acmdBGA_CONTROL 0x04
//#define acmdSAVE_MDD 0x05 /* will be translated into
/* ccmdSAVE_DISK_MDD internally */
#define acmdGET_ARRAY_STATUS 0x06
#define acmdDELETE_ARRAY 0x07
#define acmdBGA_FIRST 0x08
#define acmdREBUILD 0x08
#define acmdINITIALIZATION 0x09
#define acmdSYNCHRONIZATION 0x0a
#define acmdMIGRATION 0x0b
#define acmdBGA_LAST 0x0c
#define IsBGARequest( SubOpCode ) \
( ((SubOpCode) >= acmdBGA_FIRST) && ((SubOpCode) < acmdBGA_LAST) )
#define svucARRAY_COMMAND_MAX 0x0c
#else /* !defined(BIOS) */
//#define acmdSAVE_MDD 0x00
#define acmdDELETE_ARRAY 0x00
#define svucARRAY_COMMAND_MAX 0x01
#endif /* !defined(BIOS) */
/* helper definitions for SCSI INQUIRY */
#define blINQUIRY_EVPD bit( 0 )
#define bDISK_UNIT_INFO_PAGE 0xC0
#define DISK_UNIT_INFO_PAGE_SIZE 0xF0
#define STANDARD_INQUIRY_PAGE_SIZE 0x30
#define INQUIRY_PRODUCT_NAME_OFFSET 0x10
/* page codes for MODE_SENSE/SELECT */
#define bCURRENT_PARAMETER 0x00
#define bCHANGEABLE_PARAMETER 0x01
#define bDEFAULT_PARAMETER 0x02
#define bSAVED_PARAMETER 0x03
#define bARRAY_MAPPING_MODE_PAGE 0x20
#define bCONTROLLER_SPECIFIC_PAGE 0x21
#define bMAINTENANCE_CONTROL_PAGE 0x22
#define bALL_PAGES 0x3F
/* Promise controller command opcodes */
#define svucCONTROLLER_COMMAND 0xE1
/* controller command sub opcodes */
#if !defined(BIOS)
#define ccmdSTOP_ALL_BGA 0x00 /* refer to ccmdStopAllBGA */
#define ccmdCREATE_ARRAY 0x01
#define ccmdGET_GLOBAL_CONFIG 0x02
#define ccmdSET_GLOBAL_CONFIG 0x03
#define ccmdPATROL_CONTROL 0x04
#define ccmdSAVE_DISK_MDD 0x05
#define ccmdMEDIA_PATROL 0x06
#define ccmdBLOCK_CONTROL 0x07
#define ccmdENGINE_BIST 0x08
#define ccmdINIT_CONFIG 0x09 /* ccmdINIT_CONFIG is reserved for engine
* internal usage ONLY! */
#define ccmdTRANS_FIX 0x0a
#define ccmdATA_PASSTHRU 0x0b
#define ccmdGET_INFO 0x0c /* misc infor needed by application */
#define ccmdEVENT 0x0d
#define ccmdPOWER_STATE_CHANGING 0x0e /* CDB[2] = CCMD_POWER_WORKING/CCMD_POWER_SAVING */
#define ccmdSMART_CHECK 0x0f
#define ccmdGET_MAX_ARRAY_SIZE 0x10
#define ccmdRESUME_ALL_BGA 0x11
#define ccmdDISABLE_ALL_DISK_CACHE 0x12
#define ccmdRESTORE_ALL_DISK_CACHE 0x13
#define ccmdDISABLE_ALL_ARRAY_CACHE 0x14
#define ccmdRESTORE_ALL_ARRAY_CACHE 0x15
#define ccmdERROR_FIXING 0x16
#define ccmdGET_SET_HDD_CAPACITY 0x17
#define ccmdGET_SET_CAM_SETTINGS 0x18
#define svucCONTROLLER_COMMAND_MAX 0x18
#define ccmdATA_PASSTHRU_EX 0x19
#else /* !defined(BIOS) */
#define ccmdCREATE_ARRAY 0x00
#define ccmdSAVE_DISK_MDD 0x01
#define ccmdBLOCK_CONTROL 0x02
#define ccmdINIT_CONFIG 0x03
#define svucCONTROLLER_COMMAND_MAX 0x04
#endif /* !defined(BIOS) */
/* CDB[2] of ccmdPOWER_STATE_CHANGING */
#define CCMD_POWER_WORKING 0x00 /* system is going to S0 */
#define CCMD_POWER_SAVING 0x01 /* system is going to power saving mode (S1~S5) */
/* Promise auxiliary command opcodes */
#define svucDEBUGGING_COMMAND 0xE2
#define svucPASSTHROUGH_API_COMMAND 0xE3
/* scsi status or bTargetStatus in REQ Structure */
#define ssGOOD 0x00 /* no error */
#define ssCHECK_CONDITION 0x02 /* check sense data for status */
#define ssCONDITION_MET 0x04 /* should not happen */
#define ssBUSY 0x08 /* RAID Engine is busy, retry after some
* time */
#define ssINTERMEDIATE_GOOD 0x10 /* should not happen */
#define ssINTERMEDIATE_MET 0x14 /* should not happen */
#define ssRESERVATION_CONFLICT 0x18 /* should not happen */
#define ssCOMMAND_TERMINATED 0x22 /* should not happen */
#define ssQUEUE_FULL 0x28 /* RAID Engine is busy, retry after some
* time */
#define ssLOCK 0x80
#define ssBYPASS_REJECTED 0xFE
/* scsi sense key, ASC, and ASCQ */
#define skNO_SENSE 0x00 /* no additional status */
#define skRECOVERED_ERROR 0x01 /* cmd completed using recovery */
#define skNOT_READY 0x02 /* array is busy, retry after some time */
#define skMEDIUM_ERROR 0x03 /* auto-reassign/recovery failed */
#define skHARDWARE_ERROR 0x04 /* disk hardware error */
#define skILLEGAL_REQUEST 0x05 /* invalid bits in CDB */
#define skUNIT_ATTENTION 0x06 /* special event just happened */
#define skDATA_PROTECT 0x07 /* should not happen */
#define skBLANK_CHECK 0x08 /* should not happen */
#define skCOPY_ABORTED 0x0A /* should not happen */
#define skABORTED_COMMAND 0x0B /* should not happen */
#define skEQUAL 0x0C /* should not happen */
#define skVOLUME_OVERFLOW 0x0D /* should not happen */
#define skMISCOMPARE 0x0E /* should not happen */
#define saNO_ASC 0x00
#define saLUN_NOT_READY 0x04
#define saECC_ERROR 0x10
#define saID_ADDR_MARK_NOT_FOUND 0x12
#define saINVALID_OPCODE 0x20
#define saLBA_OUT_OF_RANGE 0x21
#define saINVALID_FEILD_IN_CDB 0x24
#define saLOGICAL_UNIT_NOT_SUPPORTED 0x25
#define saINVALID_FIELD_IN_PARAMETER 0x26
#define saINTERNAL_TARGET_FAILURE 0x44
#define sqNO_ASCQ 0x00
#define sqINTERVENTION_REQUIRED 0x03
#define sqMAINTENANCE_IN_PROGRESS 0x80
/*
-----------------------------------------------------------------------------------------
data payload for array commands
-----------------------------------------------------------------------------------------
*/
#define ARRAY_NAME_LENGTH 64
typedef struct _LOGICAL_DEVICE_SETTING_PAGE0
{
U8 CacheMode; /* used by PBM, engine will ignore it */
U8 DiskWriteCache; /* see above LOGICAL_DEVICE */
U8 DiskReadLookahead; /* see above LOGICAL_DEVICE */
U8 Lookahead;
U8 Consolidation;
U8 RealCacheMode;
U8 BypassDisabled;
U8 bReserved;
U8 Name[ARRAY_NAME_LENGTH];
/*
* currently background maintenance rate are defined as global setting. This may
* be changed in the future. If so, I will add some fields here to override global
* settings.
*/
}
LOGICAL_DEVICE_SETTING_PAGE0, buf_space * bpLOGICAL_DEVICE_SETTING_PAGE0;
/* BGA (Maintenance) Actions */
#define MT_ACT_START 0x00
#define MT_ACT_RESTART 0x01
#define MT_ACT_PAUSE 0x02
#define MT_ACT_RESUME 0x03
#define MT_ACT_ABORT 0x04
#define MT_ACT_COMPLETE 0x05 /* engine internal usage */
#define MT_ACT_AUTOPAUSE 0x06 /* engine internal usage */
#define MT_ACT_ERROR_ABORT 0x07 /* engine internal usage */
#define MT_ACT_STOPPING( Action ) \
( \
((Action) == MT_ACT_PAUSE) \
|| ((Action) == MT_ACT_ABORT) \
|| ((Action) == MT_ACT_AUTOPAUSE) \
|| ((Action) == MT_ACT_ERROR_ABORT) \
|| ((Action) == MT_ACT_COMPLETE) \
)
#define MT_ACT_RUNNING( Action ) \
( \
((Action) == MT_ACT_START) \
|| ((Action) == MT_ACT_RESTART) \
|| ((Action) == MT_ACT_RESUME) \
)
typedef struct _CDB_STOP_ALL_BGA
{
U8 OpCode; /* FIXED svucCONTROLLER_COMMAND */
U8 SubOpCode; /* FIXED ccmdSTOP_ALL_BGA */
U8 Action; /* MT_ACT_xxx */
}
PACKED CDB_STOP_ALL_BGA, buf_space * bpCDB_STOP_ALL_BGA;
/* Initialization Control Flags */
#define INIT_CF_QUICK 0x00
#define INIT_CF_FOREGRND 0x01
#define INIT_CF_BACKGRND 0x02
/* data payload for array commands ends */
#if defined(_X8616B)
#define LD_MAX_EXTENTS MAX_DISK_SUPPORTED
#else
#define LD_MAX_EXTENTS 32
#endif
#define LD_PARAM_FORMAT_EXTENTS 0x00
#if !defined(_X8616B)
#define LD_PARAM_FORMAT_DISKIDS 0x01
#define LD_PARAM_FORMAT_DISK_STRUCTURES 0x02
#endif
#define LD_PARAM_FORMAT_LOGICAL_DEVICE 0x03
typedef struct _LD_FMT_EXTENTS
{
U8 NumberOfExtents;
U8 bReserved[7];
U32 wReserved[2];
U8 ExtentID[LD_MAX_EXTENTS];
} LD_FMT_EXTENTS, buf_space * bpLD_FMT_EXTENTS;
typedef struct _LD_FMT_DISKIDS
{
U8 NumberDisks;
U8 bReserved[7]; /* 8 byte alignment */
LBA ExtentSize; /* extent size in sectors */
U32 wReserved[2];
U8 DiskID[LD_MAX_EXTENTS];
} LD_FMT_DISKIDS, buf_space * bpLD_FMT_DISKIDS;
typedef struct _LD_FMT_DISK_STRUCTURE
{
U8 NumberOfExtents;
U8 bReserved[7];
struct
{
U8 DiskID;
U8 bReserved[7];
LBA StartLBA; /* extent start LBA in the disk */
LBA ExtentSize; /* extent size, usually size of all extents must be same */
} Extents[LD_MAX_EXTENTS];
} LD_FMT_DISK_STRUCTURE, buf_space * bpLD_FMT_DISK_STRUCTURE;
/*
* currently _LD_FMT_LD_PARAM definition is the same as _LD_FMT_DISKIDS. If you changed
* the definition of the any one, you may need to change some code in eng_crld.cpp
* correspondingly. */
typedef struct _LD_FMT_LD_PARAM
{
U8 NumberDisks;
U8 bReserved[7]; /* 8 byte alignment */
LBA LDSize; /* logical device size in sectors */
U32 wReserved[2];
U8 DiskID[LD_MAX_EXTENTS];
} LD_FMT_LD_PARAM, buf_space * bpLD_FMT_LD_PARAM;
typedef struct _CREATE_LD_PARAM
{
U8 Format; /* LD_PARAM_FORMAT_xxx */
/* common parameters */
U8 Flags; /* see below CREATE_LD_F_xxx */
U8 RaidLevel;
U8 RoundingScheme; /* see below RAID_ROUNDING_xxx */
U8 MDDFormat;
U8 DriverCacheMode; /* W/B, W/T or bypass */
U8 DriverLookahead;
U8 EnableDiskWriteCache; /* 1 for enable, 0 for disable */
U32 StripeBlockSize; /* in sectors */
/* MOONFANG Extension, valid when RaidLevel==blRAID_MF */
U8 MfParityCount;
U8 MfSymmetric;
I16 MfShift;
U8 Raid50SubArrayCount;
U8 bReserved[3];
U32 wReserved[2];
U8 Name[ARRAY_NAME_LENGTH];
U32 SectorSize; /* 512/1024/2048/etc. */
/* format specific parameters */
union
{
LD_FMT_EXTENTS FormatExtents;
#if !defined(_X8616B)
LD_FMT_DISKIDS FormatDiskIDs;
LD_FMT_DISK_STRUCTURE FormatDiskStructures;
#endif
LD_FMT_LD_PARAM FormatLD;
} param;
} CREATE_LD_PARAM, buf_space * bpCREATE_LD_PARAM;
/* Create Array Flags */
#define CREATE_LD_F_QUICK_INIT 0x01 /* init flags are exclusive */
#define CREATE_LD_F_FOREGRND_INIT 0x02
#define CREATE_LD_F_BACKGRND_INIT 0x04
#define CREATE_LD_F_SECTOR_SIZE_VALID 0x08
/* Rounding Scheme */
#define RAID_ROUNDING_NONE 0x00
#define RAID_ROUNDING_GB 0x01
#define RAID_ROUNDING_10GB 0x02 /* not supported yet */
#define RAID_ROUNDING_CUSTOM 0x03 /* not supported yet */
/* TODO: default rounding scheme needs change in the future */
#define RAID_ROUNDING_DEFAULT ( RAID_ROUNDING_NONE )
typedef struct _LD_MIGRATION_PARAM
{
U8 Format; /* LD_PARAM_FORMAT_xxx */
/* common fields */
U8 RaidLevel; /* target array RAID level */
U8 SubArrayCount; /* ignored if RaidLevel != blRAID50 */
U8 bReserved;
U32 StripeBlockSize; /* target array stripe block size */
/* RAID_MF specific parameters, ignored if RaidLevel != blRAID_MF */
U8 MfParityCount;
U8 MfSymmetric;
I16 MfShift;
U32 wReserved[3];
union
{
LD_FMT_EXTENTS FormatExtents;
LD_FMT_DISKIDS FormatDiskIDs;
LD_FMT_DISK_STRUCTURE FormatDiskStructures;
} param;
}
LD_MIGRATION_PARAM, buf_space * bpLD_MIGRATION_PARAM;
typedef struct _GLOBAL_SETTINGS_PAGE0 /* Page Code 0x01 */
{
/* To avoid BIOS memory usage, put settings BIOS irrelated in the end */
U32 JbodDiskIDBitmap;
#if !defined(_X8616B) && !defined(SIMULATE_BIOS_ENV)
U32 RebuildPolicy;
U32 SyncPolicy;
U32 InitPolicy;
U32 MigrationPolicy;
U32 MediaPatrolPolicy;
/*
* usually all maintenance activities share the same policy, the setting is
* designed independently for later change
*/
U8 RebuildRate; /* rebuild rate */
U8 SyncRate; /* synchronization rate */
U8 InitRate; /* initialization rate */
U8 MediaPatrolRate; /* media patrol rate */
U8 MigrationRate; /* migration rate */
U8 SmartCheckRate;
U8 EnclosurePollInterval;
U8 SmartCheckEnable;
U8 AutoRebuildEnable;
U8 JbodPolicy; /* 1: skip MBR checking */
U8 DefaultTaskTimeoutValue; /* in seconds */
U8 SmartCheckRateHigh; /* extends smart check rate to 16 bits */
U32 OemCode;
U32 wReserved[2];
/* ... subject to change ... */
#endif
}
GLOBAL_SETTINGS_PAGE0, buf_space *bpGLOBAL_SETTINGS_PAGE0;
/*
* If hotspare is enabled and when array rebuild is required, engine will first
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -