⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libscsi.h

📁 读取SCSI磁盘阵列信息的源代码,支持设备:mega scsi device
💻 H
📖 第 1 页 / 共 3 页
字号:
					      * 4 started */	unsigned short	ano_paramval;		/* new val modified param */	unsigned char	ano_writeconfcounter;	/* write config */	unsigned char	ano_writeconfrsvd[3];	unsigned char	ano_ldopcounter;	/* ld op started/completed */	unsigned char	ano_ldopid;		/* ld modified */	unsigned char	ano_ldopcmd;		/* ld operation */#define MEGASCSI_LDCMD_CHKCONSISTANCY	0x01#define MEGASCSI_LDCMD_INITIALIZE		0x02#define MEGASCSI_LDCMD_RECONSTRUCTION	0x03	unsigned char	ano_ldopstatus;		/* status of the operation */#define MEGASCSI_LDOP_SUCCESS		0x00#define MEGASCSI_LDOP_FAILED			0x01#define MEGASCSI_LDOP_ABORTED		0x02#define MEGASCSI_LDOP_CORRECTED		0x03#define MEGASCSI_LDOP_STARTED		0x04	unsigned char	ano_ldstatecounter;	/* change of ld state */	unsigned char	ano_ldstateid;		/* ld state changed */	unsigned char	ano_ldstatenew;		/* new state */	unsigned char	ano_ldstateold;		/* old state */#define MEGASCSI_RDRV_OFFLINE		0#define MEGASCSI_RDRV_DEGRADED		1#define MEGASCSI_RDRV_OPTIMAL		2#define MEGASCSI_RDRV_DELETED		3	unsigned char	ano_pdstatecounter;	/* change of pd state */	unsigned char	ano_pdstateid;		/* pd state changed */	unsigned char	ano_pdstatenew;		/* new state */	unsigned char	ano_pdstateold;		/* old state */#define MEGASCSI_PD_UNCNF			0#define MEGASCSI_PD_ONLINE			3#define MEGASCSI_PD_FAILED			4#define MEGASCSI_PD_RBLD			5#define MEGASCSI_PD_HOTSPARE			6	unsigned char	ano_pdfmtcounter;	/* pd format started/over */	unsigned char	ano_pdfmtid;		/* pd id */	unsigned char	ano_pdfmtval;		/* format started/over */#define MEGASCSI_PDFMT_START			0x01#define MEGASCSI_PDFMT_OVER			0x02	unsigned char	ano_pdfmtrsvd;	unsigned char	ano_targxfercounter;	/* SCSI-2 Xfer rate change */	unsigned char	ano_targxferid;		/* pd that changed  */	unsigned char	ano_targxferval;	/* new xfer parameters */	unsigned char	ano_targxferrsvd;	unsigned char	ano_fclidchgcounter;	/* loop id changed */	unsigned char	ano_fclidpdid;		/* pd id */	unsigned char	ano_fclid0;		/* loop id on fc loop 0 */	unsigned char	ano_fclid1;		/* loop id on fc loop 1 */	unsigned char	ano_fclstatecounter;	/* loop state changed */	unsigned char	ano_fclstate0;		/* state of fc loop 0 */	unsigned char	ano_fclstate1;		/* state of fc loop 1 */#define MEGASCSI_FCLOOP_FAILED		0#define MEGASCSI_FCLOOP_ACTIVE		1#define MEGASCSI_FCLOOP_TRANSIENT		2	unsigned char	ano_fclstatersvd;};struct megascsi_fc_einquiry {	unsigned int	ain_size;	/* size of this structure */	/* notify */	struct	megascsi_notify ain_notify;	unsigned char	ain_notifyrsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];	unsigned char	ain_rbldrate;	/* rebuild rate %% */	unsigned char	ain_flushintvl;	unsigned char	ain_sensealert;	unsigned char	ain_drvinscnt;	/* drive insertion count */	unsigned char	ain_battery;	/* battery status */	unsigned char	ain_nlogdrv;	unsigned char	ain_recon[MEGASCSI_BIG_MAX_LDRIVES / 8];	unsigned short	ain_stat[MEGASCSI_BIG_MAX_LDRIVES / 8];	unsigned int	ain_ldsize[MEGASCSI_BIG_MAX_LDRIVES];	unsigned char	ain_ldprop[MEGASCSI_BIG_MAX_LDRIVES];	unsigned char	ain_ldstat[MEGASCSI_BIG_MAX_LDRIVES];	unsigned char	ain_pdstat[MEGASCSI_BIG_MAX_PDRIVES];	unsigned short	ain_pdfmtinp[MEGASCSI_BIG_MAX_PDRIVES];	unsigned char	ain_pdrates [80];	/* pdrv xfer rates */	unsigned char	ain_pad[263];		/* pad to 1k */};struct megascsi_fc_prodinfo {	unsigned int	api_size;	/* size of this structure */	unsigned int	api_config;	unsigned char	api_fwver[16];	unsigned char	api_biosver[16];	unsigned char	api_product[80];	unsigned char	api_maxcmd;	unsigned char	api_channels;	unsigned char	api_fcloops;	unsigned char	api_memtype;	unsigned int	api_signature;	unsigned short	api_ramsize;	unsigned short	api_ssid;	unsigned short	api_ssvid;	unsigned char	api_nnotify;};struct megascsi_diskarray {	unsigned char	ada_nld;	unsigned char	ada_pad[3];	struct {		unsigned char	adl_spandepth;		unsigned char	adl_raidlvl;		unsigned char	adl_rdahead;		unsigned char	adl_stripesz;		unsigned char	adl_status;		unsigned char	adl_wrpolicy;		unsigned char	adl_directio;		unsigned char	adl_nstripes;		struct {			unsigned int	ads_start;			unsigned int	ads_length;	/* blocks */			struct {				unsigned char	add_channel;				unsigned char	add_target;			} ads_devs[MEGASCSI_MAX_DEVDEPTH];		} adl_spans[MEGASCSI_MAX_SPANDEPTH];	} ada_ldrv[MEGASCSI_MAX_LDRIVES];	struct {		unsigned char	adp_type;	/* SCSI device type */		unsigned char	adp_ostatus;	/* status during config */		unsigned char	adp_tagdepth;	/* level of tagging */		unsigned char	adp_sneg;	/* sync negotiation */		unsigned int	adp_size;	} ada_pdrv[MEGASCSI_MAX_PDRIVES];};struct megascsi_big_diskarray {	unsigned char	ada_nld;	unsigned char	ada_pad[3];#define ald ada_ldrv	struct {		unsigned char	adl_spandepth;		unsigned char	adl_raidlvl;		unsigned char	adl_rdahead;		unsigned char	adl_stripesz;		unsigned char	adl_status;		unsigned char	adl_wrpolicy;		unsigned char	adl_directio;		unsigned char	adl_nstripes;#define 	asp adl_spans		struct {			unsigned int	ads_start;			unsigned int	ads_length;	/* blocks */#define 		adv ads_devs			struct {				unsigned char	add_channel;				unsigned char	add_target;			} ads_devs[MEGASCSI_BIG_MAX_DEVDEPTH];		} adl_spans[MEGASCSI_BIG_MAX_SPANDEPTH];	} ada_ldrv[MEGASCSI_BIG_MAX_LDRIVES];#define apd ada_pdrv	struct {		unsigned char	adp_type;	/* SCSI device type */		unsigned char	adp_ostatus;	/* status during config */		unsigned char	adp_tagdepth;	/* level of tagging */		unsigned char	adp_sneg;	/* sync negotiation */		unsigned int	adp_size;	} ada_pdrv[MEGASCSI_BIG_MAX_PDRIVES];};struct megascsi_scsisense {	unsigned char	ase_end;	struct {		unsigned char	asd_channel;		unsigned char	asd_target;		unsigned short	asd_errcode;		unsigned short	asd_sense;		unsigned short	asd_addarea1;		unsigned short	asd_addarea2;		unsigned short	asd_cmdspec0;		unsigned short	asd_cmdspec1;		unsigned short	asd_aadapter_ascq;	} ase_dump[5];};struct megascsi_escsisense {	unsigned char	ase_end;	struct {		unsigned char	asd_channel;		unsigned char	asd_target;		unsigned short	asd_errcode;		unsigned short	asd_sense;		unsigned short	asd_addarea1;		unsigned short	asd_addarea2;		unsigned short	asd_cmdspec0;		unsigned short	asd_cmdspec1;		unsigned short	asd_aadapter_ascq;		unsigned short	asd_extarea;	} ase_dump[5];};struct megascsi_cachestats {	unsigned int	acs_total;	unsigned int	acs_hits;};struct megascsi_drivehistory {	struct {		unsigned char	adh_error;#define	MEGASCSI_ADHERR_TIMEOUT(e)	((e) & 15)#define	MEGASCSI_ADHERR_PARITY(e)	(((e) >> 4) & 15)		unsigned char	adh_throttle;	} adh_err[3][16];	/* channels * drives */	unsigned char	adh_failidx;	struct {		unsigned char	adh_tag;#define	MEGASCSI_ADHTAG_CH(t)	((t) & 7)#define	MEGASCSI_ADHTAG_TARG(t)	(((t) >> 3) & 15)#define	MEGASCSI_ADHTAG_VALID(t)	((t) & 0x80)		unsigned char	reason;#define	MEGASCSI_ADHERR_MEDIA	1#define	MEGASCSI_ADHERR_NMEDIA	2#define	MEGASCSI_ADHERR_CMDTMO	3#define	MEGASCSI_ADHERR_SELTMO	4#define	MEGASCSI_ADHERR_HAFAIL	5#define	MEGASCSI_ADHERR_REASSIGN	6#define	MEGASCSI_ADHERR_CMDFAIL	7#define	MEGASCSI_ADHERR_OTHER	8#define	MEGASCSI_FAILHISTORY		10	} adh_fail[MEGASCSI_FAILHISTORY];};struct megascsi_inq_data {	unsigned char	aid_peri;	unsigned char	aid_scsitype;	unsigned char	aid_ver;	unsigned char	aid_datatrans;	unsigned char	aid_addlen;	unsigned char	aid_resv[2];	unsigned char	aid_scsival;	unsigned char	aid_vendor[8];	unsigned char	aid_prod[16];	unsigned char	aid_prodver[4];	unsigned char	aid_mederr;	unsigned char	aid_otherr;	unsigned char	aid_proctype;	unsigned char	resv2[20];};#pragma pack()/* mega scsi device definition */struct megascsi_adapter;struct device {	int	dv_unit;		/* device unit number */	char	dv_xname[16];		/* external name (name + unit) */	struct	device *dv_parent;	/* pointer to parent device */	int	dv_flags;		/* misc. flags; see below */	int	dv_ref;			/* ref count */};struct megascsi_rawadapter {	struct megascsi_adapter *adapter_softc;	unsigned char	adapter_channel;	int		adapter_proctarget;	/* ses/safte target id */	char		adapter_procdev[16];	/* ses/safte device */};struct megascsi_adapter {	struct device	adapter_dev;	uint	adapter_handle;	uint	adapter_adapt_no;/* don't use 0x0001 */#define MEGASCSI_BROKEN 	0x0002#define	MEGASCSI_CMDWAIT	0x0004#define MEGASCSI_QUARTZ	0x0008	uint	adapter_flags;	volatile struct megascsi_iocmd *adapter_mbox;	unsigned int	adapter_mbox_pa;	int		adapter_timeout;	/*	struct timeout	adapter_requeue_tmo;	struct timeout	adapter_poll_tmo;	*/	int		adapter_dis_poll;	char	adapter_fwver[16];	char	adapter_biosver[16];	int	adapter_maxcmds;	int	adapter_memory;	int	adapter_targets;	int	adapter_channels;	int	adapter_maxunits;	int	adapter_nunits;	struct {		unsigned char	hd_present;		unsigned char	hd_is_logdrv;		unsigned char	hd_heads;		unsigned char	hd_secs;		unsigned char	hd_prop;		unsigned char	hd_stat;		unsigned int	hd_size;		char		dev[16];	} adapter_hdr[MEGASCSI_BIG_MAX_PDRIVES];	struct megascsi_rawadapter adapter_rawadapters[MEGASCSI_MAX_CHANNEL];};/* Mega IOCTL definition*/#define BUFF_SIZE 4096#define POLL_TIME 10	/* in secs */#define DEBUG 1/** * mimd_t	: Old style ioctl packet structure (deprecated) * * @inlen	: * @outlen	: * @fca		: * @opcode	: * @subopcode	: * @adapno	: * @buffer	: * @pad		: * @length	: * @mbox	: * @pthru	: * @data	: * @pad		: * * Note		: This structure is DEPRECATED. New applications must use *		: uioc_t structure instead. All new hba drivers use the new *		: format. If we get this mimd packet, we will convert it into *		: new uioc_t format and send it to the hba drivers. */typedef struct mimd {	unsigned int inlen;	unsigned int outlen;	union {		unsigned char fca[16];		struct {			unsigned char opcode;			unsigned char subopcode;			unsigned short adapno;#if BITS_PER_LONG == 32				unsigned char *buffer;			unsigned char pad[4];#endif #if BITS_PER_LONG == 64			unsigned char *buffer;#endif			unsigned int length;		} __attribute__ ((packed)) fcs;	} __attribute__ ((packed)) ui;	unsigned char mbox[18];		/* 16 bytes + 2 status bytes */	mraid_passthru_t pthru;#if BITS_PER_LONG == 32	char *data;		/* buffer <= 4096 for 0x80 commands */	char pad[4];#endif#if BITS_PER_LONG == 64	char *data;#endif} __attribute__ ((packed))mimd_t;/* * Definitions & Declarations needed to use common management module */#define MEGAIOC_MAGIC		'm'#define MEGAIOCCMD		_IOWR(MEGAIOC_MAGIC, 0, mimd_t)#define MEGAIOC_QNADAP		'm'	/* Query # of adapters		*/#define MEGAIOC_QDRVRVER	'e'	/* Query driver version		*/#define MEGAIOC_QADAPINFO   	'g'	/* Query adapter information	*/// #define USCSICMD		0x80	/* Linux 2.6.x kernel */// #define USCSICMD             0xe0	/* Linux 2.4.x kernel */#define UIOC_RD			0x00001#define UIOC_WR			0x00002#define MBOX_CMD		0x00000#define GET_DRIVER_VER		0x10000#define GET_N_ADAP		0x20000#define GET_ADAP_INFO		0x30000#define GET_CAP			0x40000#define GET_STATS		0x50000#define GET_IOCTL_VERSION	0x01#define EXT_IOCTL_SIGN_SZ	16#define EXT_IOCTL_SIGN		"$$_EXTD_IOCTL_$$"#define	MBOX_LEGACY		0x00		/* ioctl has legacy mbox*/#define MBOX_HPE		0x01		/* ioctl has hpe mbox	*/#define	APPTYPE_MIMD		0x00		/* old existing apps	*/#define APPTYPE_UIOC		0x01		/* new apps using uioc	*/#define IOCTL_ISSUE		0x00000001	/* Issue ioctl		*/#define IOCTL_ABORT		0x00000002	/* Abort previous ioctl	*/#define DRVRTYPE_MBOX		0x00000001	/* regular mbox driver	*/#define DRVRTYPE_HPE		0x00000002	/* new hpe driver	*//** * struct mraid_hba_info - information about the controller * * @param pci_vendor_id		: PCI vendor id * @param pci_device_id		: PCI device id * @param subsystem_vendor_id	: PCI subsystem vendor id * @param subsystem_device_id	: PCI subsystem device id * @param baseport		: base port of hba memory * @param pci_bus		: PCI bus * @param pci_dev_fn		: PCI device/function values * @param irq			: interrupt vector for the device * * Extended information of 256 bytes about the controller. Align on the single * byte boundary so that 32-bit applications can be run on 64-bit platform * drivers withoug re-compilation. * NOTE: reduce the number of reserved bytes whenever new field are added, so * that total size of the structure remains 256 bytes. */typedef struct mraid_hba_info {	unsigned short	pci_vendor_id;	unsigned short	pci_device_id;	unsigned short	subsys_vendor_id;	unsigned short	subsys_device_id;	unsigned long long	baseport;	unsigned char		pci_bus;	unsigned char		pci_dev_fn;	unsigned char		pci_slot;	unsigned char		irq;	unsigned int	unique_id;	unsigned int	host_no;	unsigned char		num_ldrv;} __attribute__ ((aligned(256), packed)) mraid_hba_info_t;/** * mcontroller	: adapter info structure for old mimd_t apps * * @base	: base address * @irq		: irq number * @numldrv	: number of logical drives * @pcibus	: pci bus * @pcidev	: pci device * @pcifun	: pci function * @pciid	: pci id * @pcivendor	: vendor id * @pcislot	: slot number * @uid		: unique id */typedef struct mcontroller {	unsigned long long	base;	unsigned char		irq;	unsigned char		numldrv;	unsigned char		pcibus;	unsigned short	pcidev;	unsigned char		pcifun;	unsigned short	pciid;	unsigned short	pcivendor;	unsigned char		pcislot;	unsigned int	uid;} __attribute__ ((packed)) mcontroller_t;/* Kernel Mode IOCTL Operation Definition*/int	megascsi_query_adapt(struct megascsi_adapter *);void megascsi_copyhds(struct megascsi_adapter *scsi_adapter, const unsigned int *sizes,	const unsigned char *props, const unsigned char *stats);int megascsi_drv_inq(struct megascsi_adapter *, unsigned char, unsigned char, unsigned char, void *);int megascsi_mgmt(struct megascsi_adapter *, unsigned char, unsigned char, unsigned char, unsigned char,    size_t, void *);int megascsi_ioctl_inq(struct megascsi_adapter *, struct mioc_inq *);int megascsi_vol(struct megascsi_adapter *, struct mioc_vol *,    struct megascsi_big_diskarray *);int megascsi_disk(struct megascsi_adapter *, struct mioc_disk *,    struct megascsi_big_diskarray *);int megascsi_ioctl_vol(struct megascsi_adapter *, struct mioc_vol *);int megascsi_ioctl_disk(struct megascsi_adapter *, struct mioc_disk *);#endif /* _LIB_MEGA_SCSI_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -