?? libscsi.h
字號:
/* *Mega SCSI IOCTL Parameter and Structure Definition */#ifndef _LIB_MEGA_SCSI_H_#define _LIB_MEGA_SCSI_H_#include <errno.h>#include <fcntl.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <sys/ioctl.h>#include <sys/uio.h>#include <sys/utsname.h>#include "m_defs.h"#include "scsiio.h"#include "scsi_all.h"#include "scsi_disk.h"#include "raid.h"/* * Mega SCSI Low Level Parameter and Structure Definition *//* * Commands and states for mailbox based controllers */#define FC_NEW_CONFIG 0xA1#define NC_SUBOP_PRODUCT_INFO 0x0E#define NC_SUBOP_ENQUIRY3 0x0F#define ENQ3_GET_SOLICITED_FULL 0x02#define OP_DCMD_READ_CONFIG 0x04#define NEW_READ_CONFIG_8LD 0x67#define READ_CONFIG_8LD 0x07/* * Command for random deletion of logical drives */#define FC_DEL_LOGDRV 0xA4/* * BIOS commands */#define IS_BIOS_ENABLED 0x62#define GET_BIOS 0x01#define CHNL_CLASS 0xA9#define GET_CHNL_CLASS 0x00#define SET_CHNL_CLASS 0x01#define CH_RAID 0x01#define CH_SCSI 0x00#define BIOS_PVT_DATA 0x40#define GET_BIOS_PVT_DATA 0x00/* * Module battery status */#define BATTERY_MODULE_MISSING 0x01#define BATTERY_LOW_VOLTAGE 0x02#define BATTERY_TEMP_HIGH 0x04#define BATTERY_PACK_MISSING 0x08#define BATTERY_CHARGE_MASK 0x30#define BATTERY_CHARGE_DONE 0x00#define BATTERY_CHARGE_INPROG 0x10#define BATTERY_CHARGE_FAIL 0x20#define BATTERY_CYCLES_EXCEEDED 0x40/* * Physical drive states. */#define PDRV_UNCNF 0#define PDRV_ONLINE 3#define PDRV_FAILED 4#define PDRV_RBLD 5#define PDRV_HOTSPARE 6/* * Raid logical drive states. */#define RDRV_OFFLINE 0#define RDRV_DEGRADED 1#define RDRV_OPTIMAL 2#define RDRV_DELETED 3/* * Read, write and cache policies */#define NO_READ_AHEAD 0#define READ_AHEAD 1#define ADAP_READ_AHEAD 2#define WRMODE_WRITE_THRU 0#define WRMODE_WRITE_BACK 1#define CACHED_IO 0#define DIRECT_IO 1#define MAX_LOGICAL_DRIVES_8LD 8#define MAX_LOGICAL_DRIVES_40LD 40#define FC_MAX_PHYSICAL_DEVICES 256#define MAX_MBOX_CHANNELS 5#define MAX_MBOX_TARGET 15#define MBOX_MAX_PHYSICAL_DRIVES MAX_MBOX_CHANNELS*MAX_MBOX_TARGET#define MAX_ROW_SIZE_40LD 32#define MAX_ROW_SIZE_8LD 8#define SPAN_DEPTH_8_SPANS 8#define SPAN_DEPTH_4_SPANS 4#define MAX_REQ_SENSE_LEN 0x20#define BIG_MAX_PDRIVES (256)#define BIG_MAX_LDRIVES 40#define BIG_MAX_SPANDEPTH 8#define BIG_MAX_DEVDEPTH 32/** * struct mbox_t - Driver and f/w handshake structure. * @cmd : firmware command * @cmdid : command id * @numsectors : number of sectors to be transferred * @lba : Logical Block Address on LD * @xferaddr : DMA address for data transfer * @logdrv : logical drive number * @numsge : number of scatter gather elements in sg list * @resvd : reserved * @busy : f/w busy, must wait to issue more commands. * @numstatus : number of commands completed. * @status : status of the commands completed * @completed : array of completed command ids. * @poll : poll and ack sequence * @ack : poll and ack sequence * * The central handshake structure between the driver and the firmware. This * structure must be allocated by the driver and aligned at 8-byte boundary. */#define MBOX_MAX_FIRMWARE_STATUS 46typedef struct { unsigned char cmd; unsigned char cmdid; unsigned short numsectors; unsigned int lba; unsigned int xferaddr; unsigned char logdrv; unsigned char numsge; unsigned char resvd; unsigned char busy; unsigned char numstatus; unsigned char status; unsigned char completed[MBOX_MAX_FIRMWARE_STATUS]; unsigned char poll; unsigned char ack;} __attribute__ ((packed)) mbox_t;/** * mbox64_t - 64-bit extension for the mailbox * @segment_lo : the low 32-bits of the address of the scatter-gather list * @segment_hi : the upper 32-bits of the address of the scatter-gather list * @mbox : 32-bit mailbox, whose xferadder field must be set to * 0xFFFFFFFF * * This is the extension of the 32-bit mailbox to be able to perform DMA * beyond 4GB address range. */typedef struct { unsigned int xferaddr_lo; unsigned int xferaddr_hi; mbox_t mbox32;} __attribute__ ((packed)) mbox64_t;/* * mailbox structure used for internal commands */typedef struct { unsigned char cmd; unsigned char cmdid; unsigned char opcode; unsigned char subopcode; unsigned int lba; unsigned int xferaddr; unsigned char logdrv; unsigned char rsvd[3]; unsigned char numstatus; unsigned char status;} __attribute__ ((packed)) int_mbox_t;/** * mraid_passthru_t - passthru structure to issue commands to physical devices * @timeout : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr * @ars : set if ARS required after check condition * @islogical : set if command meant for logical devices * @logdrv : logical drive number if command for LD * @channel : Channel on which physical device is located * @target : SCSI target of the device * @queuetag : unused * @queueaction : unused * @cdb : SCSI CDB * @cdblen : length of the CDB * @reqsenselen : amount of request sense data to be returned * @reqsensearea : Sense information buffer * @numsge : number of scatter-gather elements in the sg list * @scsistatus : SCSI status of the command completed. * @dataxferaddr : DMA data transfer address * @dataxferlen : amount of the data to be transferred. */typedef struct { unsigned char timeout :3; unsigned char ars :1; unsigned char reserved :3; unsigned char islogical :1; unsigned char logdrv; unsigned char channel; unsigned char target; unsigned char queuetag; unsigned char queueaction; unsigned char cdb[10]; unsigned char cdblen; unsigned char reqsenselen; unsigned char reqsensearea[MAX_REQ_SENSE_LEN]; unsigned char numsge; unsigned char scsistatus; unsigned int dataxferaddr; unsigned int dataxferlen;} __attribute__ ((packed)) mraid_passthru_t;typedef struct { unsigned int dataxferaddr_lo; unsigned int dataxferaddr_hi; mraid_passthru_t pthruint32_t;} __attribute__ ((packed)) megascsi_passthru64_t;/** * mraid_epassthru_t - passthru structure to issue commands to physical devices * @timeout : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr * @ars : set if ARS required after check condition * @rsvd1 : reserved field * @cd_rom : (?) * @rsvd2 : reserved field * @islogical : set if command meant for logical devices * @logdrv : logical drive number if command for LD * @channel : Channel on which physical device is located * @target : SCSI target of the device * @queuetag : unused * @queueaction : unused * @cdblen : length of the CDB * @rsvd3 : reserved field * @cdb : SCSI CDB * @numsge : number of scatter-gather elements in the sg list * @status : SCSI status of the command completed. * @reqsenselen : amount of request sense data to be returned * @reqsensearea : Sense information buffer * @rsvd4 : reserved field * @dataxferaddr : DMA data transfer address * @dataxferlen : amount of the data to be transferred. */typedef struct { unsigned char timeout :3; unsigned char ars :1; unsigned char rsvd1 :1; unsigned char cd_rom :1; unsigned char rsvd2 :1; unsigned char islogical :1; unsigned char logdrv; unsigned char channel; unsigned char target; unsigned char queuetag; unsigned char queueaction; unsigned char cdblen; unsigned char rsvd3; unsigned char cdb[16]; unsigned char numsge; unsigned char status; unsigned char reqsenselen; unsigned char reqsensearea[MAX_REQ_SENSE_LEN]; unsigned char rsvd4; unsigned int dataxferaddr; unsigned int dataxferlen;} __attribute__ ((packed)) mraid_epassthru_t;/** * mraid_pinfo_t - product info, static information about the controller * @data_size : current size in bytes (not including resvd) * @config_signature : Current value is 0x00282008 * @fw_version : Firmware version * @bios_version : version of the BIOS * @product_name : Name given to the controller * @max_commands : Maximum concurrent commands supported * @nchannels : Number of SCSI Channels detected * @fc_loop_present : Number of Fibre Loops detected * @mem_type : EDO, FPM, SDRAM etc * @signature : * @dram_size : In terms of MB * @subsysid : device PCI subsystem ID * @subsysvid : device PCI subsystem vendor ID * @notify_counters : * @pad1k : 135 + 889 resvd = 1024 total size * * This structures holds the information about the controller which is not * expected to change dynamically. * * The current value of config signature is 0x00282008: * 0x28 = MAX_LOGICAL_DRIVES, * 0x20 = Number of stripes and * 0x08 = Number of spans */typedef struct { unsigned int data_size; unsigned int config_signature; unsigned char fw_version[16]; unsigned char bios_version[16]; unsigned char product_name[80]; unsigned char max_commands; unsigned char nchannels; unsigned char fc_loop_present; unsigned char mem_type; unsigned int signature; unsigned short dram_size; unsigned short subsysid; unsigned short subsysvid; unsigned char notify_counters; unsigned char pad1k[889];} __attribute__ ((packed)) mraid_pinfo_t;/** * mraid_notify_t - the notification structure * @global_counter : Any change increments this counter * @param_counter : Indicates any params changed * @param_id : Param modified - defined below * @param_val : New val of last param modified * @write_config_counter : write config occurred * @write_config_rsvd : * @ldrv_op_counter : Indicates ldrv op started/completed * @ldrv_opid : ldrv num * @ldrv_opcmd : ldrv operation - defined below * @ldrv_opstatus : status of the operation * @ldrv_state_counter : Indicates change of ldrv state * @ldrv_state_id : ldrv num * @ldrv_state_new : New state * @ldrv_state_old : old state * @pdrv_state_counter : Indicates change of ldrv state * @pdrv_state_id : pdrv id * @pdrv_state_new : New state * @pdrv_state_old : old state * @pdrv_fmt_counter : Indicates pdrv format started/over * @pdrv_fmt_id : pdrv id * @pdrv_fmt_val : format started/over * @pdrv_fmt_rsvd : * @targ_xfer_counter : Indicates SCSI-2 Xfer rate change * @targ_xfer_id : pdrv Id * @targ_xfer_val : new Xfer params of last pdrv * @targ_xfer_rsvd : * @fcloop_id_chg_counter : Indicates loopid changed * @fcloopid_pdrvid : pdrv id * @fcloop_id0 : loopid on fc loop 0 * @fcloop_id1 : loopid on fc loop 1 * @fcloop_state_counter : Indicates loop state changed * @fcloop_state0 : state of fc loop 0 * @fcloop_state1 : state of fc loop 1 * @fcloop_state_rsvd : */typedef struct { unsigned int global_counter; unsigned char param_counter; unsigned char param_id; unsigned short param_val; unsigned char write_config_counter; unsigned char write_config_rsvd[3]; unsigned char ldrv_op_counter; unsigned char ldrv_opid; unsigned char ldrv_opcmd; unsigned char ldrv_opstatus; unsigned char ldrv_state_counter; unsigned char ldrv_state_id; unsigned char ldrv_state_new; unsigned char ldrv_state_old; unsigned char pdrv_state_counter; unsigned char pdrv_state_id; unsigned char pdrv_state_new; unsigned char pdrv_state_old; unsigned char pdrv_fmt_counter; unsigned char pdrv_fmt_id; unsigned char pdrv_fmt_val; unsigned char pdrv_fmt_rsvd; unsigned char targ_xfer_counter; unsigned char targ_xfer_id; unsigned char targ_xfer_val; unsigned char targ_xfer_rsvd; unsigned char fcloop_id_chg_counter; unsigned char fcloopid_pdrvid; unsigned char fcloop_id0; unsigned char fcloop_id1; unsigned char fcloop_state_counter; unsigned char fcloop_state0; unsigned char fcloop_state1; unsigned char fcloop_state_rsvd;} __attribute__ ((packed)) mraid_notify_t;/** * mraid_inquiry3_t - enquiry for device information * * @data_size : current size in bytes (not including resvd) * @notify : * @notify_rsvd : * @rebuild_rate : rebuild rate (0% - 100%) * @cache_flush_int : cache flush interval in seconds * @sense_alert : * @drive_insert_count : drive insertion count * @battery_status : * @num_ldrv : no. of Log Drives configured * @recon_state : state of reconstruct * @ldrv_op_status : logdrv Status * @ldrv_size : size of each log drv * @ldrv_prop : * @ldrv_state : state of log drives * @pdrv_state : state of phys drvs. * @pdrv_format : * @targ_xfer : phys device transfer rate * @pad1k : 761 + 263reserved = 1024 bytes total size */#define MAX_NOTIFY_SIZE 0x80#define CUR_NOTIFY_SIZE sizeof(mraid_notify_t)typedef struct { unsigned int data_size; mraid_notify_t notify; unsigned char notify_rsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE]; unsigned char rebuild_rate; unsigned char cache_flush_int; unsigned char sense_alert; unsigned char drive_insert_count; unsigned char battery_status; unsigned char num_ldrv; unsigned char recon_state[MAX_LOGICAL_DRIVES_40LD / 8]; unsigned short ldrv_op_status[MAX_LOGICAL_DRIVES_40LD / 8]; unsigned int ldrv_size[MAX_LOGICAL_DRIVES_40LD]; unsigned char ldrv_prop[MAX_LOGICAL_DRIVES_40LD]; unsigned char ldrv_state[MAX_LOGICAL_DRIVES_40LD]; unsigned char pdrv_state[FC_MAX_PHYSICAL_DEVICES]; unsigned short pdrv_format[FC_MAX_PHYSICAL_DEVICES / 16]; unsigned char targ_xfer[80]; unsigned char pad1k[263];} __attribute__ ((packed)) mraid_inquiry3_t;/** * mraid_adapinfo_t - information about the adapter * @max_commands : max concurrent commands supported * @rebuild_rate : rebuild rate - 0% thru 100% * @max_targ_per_chan : max targ per channel * @nchannels : number of channels on HBA * @fw_version : firmware version * @age_of_flash : number of times FW has been flashed * @chip_set_value : contents of 0xC0000832 * @dram_size : in MB * @cache_flush_interval : in seconds * @bios_version : * @board_type : * @sense_alert : * @write_config_count : increase with every configuration change * @drive_inserted_count : increase with every drive inserted * @inserted_drive : channel:Id of inserted drive * @battery_status : bit 0: battery module missing * bit 1: VBAD * bit 2: temprature high * bit 3: battery pack missing * bit 4,5: * 00 - charge complete * 01 - fast charge in progress * 10 - fast charge fail * 11 - undefined * bit 6: counter > 1000 * bit 7: Undefined * @dec_fault_bus_info : */typedef struct { unsigned char max_commands; unsigned char rebuild_rate; unsigned char max_targ_per_chan; unsigned char nchannels; unsigned char fw_version[4]; unsigned short age_of_flash; unsigned char chip_set_value; unsigned char dram_size; unsigned char cache_flush_interval; unsigned char bios_version[4]; unsigned char board_type; unsigned char sense_alert; unsigned char write_config_count; unsigned char battery_status; unsigned char dec_fault_bus_info;} __attribute__ ((packed)) mraid_adapinfo_t;/** * mraid_ldrv_info_t - information about the logical drives
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -