Home | History | Annotate | Line # | Download | only in ic
      1  1.11    andvar /*	$NetBSD: cissreg.h,v 1.11 2022/11/01 19:24:30 andvar Exp $	*/
      2   1.4  christos /*	$OpenBSD: cissreg.h,v 1.11 2010/06/03 01:02:13 dlg Exp $	*/
      3   1.1        he 
      4   1.1        he /*
      5   1.4  christos  * Copyright (c) 2005,2006 Michael Shalayeff
      6   1.1        he  * All rights reserved.
      7   1.1        he  *
      8   1.1        he  * Permission to use, copy, modify, and distribute this software for any
      9   1.1        he  * purpose with or without fee is hereby granted, provided that the above
     10   1.1        he  * copyright notice and this permission notice appear in all copies.
     11   1.1        he  *
     12   1.1        he  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     13   1.1        he  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     14   1.1        he  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     15   1.1        he  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     16   1.1        he  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
     17   1.1        he  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
     18   1.1        he  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     19   1.1        he  */
     20   1.1        he 
     21   1.2    mhitch #define	CISS_BIGBIT	0x80	/* texas radio and the big beat! */
     22   1.2    mhitch 
     23   1.1        he #define	CISS_IDB	0x20
     24   1.1        he #define	CISS_IDB_CFG	0x01
     25   1.1        he #define	CISS_ISR	0x30
     26   1.1        he #define	CISS_IMR	0x34
     27   1.5  christos #define	CISS_INTR_OPQ_SA5	(1<<3)
     28   1.5  christos #define	CISS_INTR_OPQ_SA5B	(1<<2)
     29   1.5  christos #define	CISS_INTR_OPQ	(CISS_INTR_OPQ_SA5|CISS_INTR_OPQ_SA5B)
     30   1.5  christos #define	CISS_INTR_MSI		(1<<0)
     31   1.1        he #define	CISS_INQ	0x40
     32   1.1        he #define	CISS_OUTQ	0x44
     33   1.6  jdolecek #define CISS_OSR	0x9c    /* outbound status register */
     34   1.6  jdolecek #define CISS_ODC	0xa0    /* outbound doorbell clear register */
     35   1.6  jdolecek #define CISS_ODC_CLEAR		(0x1)
     36   1.1        he #define	CISS_CFG_BAR	0xb4
     37   1.1        he #define	CISS_CFG_OFF	0xb8
     38   1.1        he 
     39   1.4  christos /* 64bit FIFO mode input/output post queues */
     40   1.4  christos #define CISS_INQ64_LO	0xc0
     41   1.4  christos #define CISS_INQ64_HI	0xc4
     42   1.4  christos #define CISS_OUTQ64_LO	0xc8
     43   1.4  christos #define CISS_OUTQ64_HI	0xcc
     44   1.4  christos 
     45   1.1        he #define	CISS_DRVMAP_SIZE	(128 / 8)
     46   1.1        he 
     47   1.1        he #define	CISS_CMD_CTRL_GET	0x26
     48   1.1        he #define	CISS_CMD_CTRL_SET	0x27
     49   1.1        he /* sub-commands for GET/SET */
     50   1.1        he #define	CISS_CMS_CTRL_LDID	0x10
     51   1.1        he #define	CISS_CMS_CTRL_CTRL	0x11
     52   1.1        he #define	CISS_CMS_CTRL_LDSTAT	0x12
     53   1.1        he #define	CISS_CMS_CTRL_PDID	0x15
     54   1.1        he #define	CISS_CMS_CTRL_PDBLINK	0x16
     55   1.1        he #define	CISS_CMS_CTRL_PDBLSENS	0x17
     56   1.2    mhitch #define	CISS_CMS_CTRL_LDIDEXT	0x18
     57   1.2    mhitch #define	CISS_CMS_CTRL_REDSTAT	0x82
     58   1.1        he #define	CISS_CMS_CTRL_FLUSH	0xc2
     59   1.1        he #define	CISS_CMS_CTRL_ACCEPT	0xe0
     60   1.1        he 
     61   1.2    mhitch #define	CISS_CMD_READ	0xc0
     62   1.2    mhitch #define	CISS_CMD_READ_EVENT	0xd0
     63   1.2    mhitch #define	CISS_EVENT_RECENT	0x08	/* ignore previous events */
     64   1.2    mhitch #define	CISS_EVENT_RSTOLD	0x04	/* start w/ the oldest one */
     65   1.2    mhitch #define	CISS_EVENT_ORDER	0x02	/* keep the order */
     66   1.2    mhitch #define	CISS_EVENT_SYNC		0x01	/* sync mode: wait till new come */
     67   1.1        he #define	CISS_CMD_LDMAP	0xc2
     68   1.1        he #define	CISS_CMD_PDMAP	0xc3
     69   1.1        he 
     70   1.2    mhitch #define	ciss_bitset(d, v)	((v)[(d) >> 3] & (1 << ((d) & 7)))
     71   1.2    mhitch 
     72   1.1        he struct ciss_softc;
     73   1.1        he 
     74   1.1        he struct ciss_config {
     75   1.1        he 	u_int32_t	signature;
     76   1.1        he #define	CISS_SIGNATURE	(*(const u_int32_t *)"CISS")
     77   1.1        he 	u_int32_t	version;
     78   1.1        he 	u_int32_t	methods;
     79   1.4  christos #define CISS_METH_READY		0x00000001 /* indicate to accept commands */
     80   1.4  christos #define CISS_METH_SIMPL		0x00000002 /* simple mode */
     81   1.4  christos #define CISS_METH_PERF		0x00000004 /* performant mode */
     82   1.4  christos #define CISS_METH_EMQ		0x00000008 /* MEMQ method */
     83   1.4  christos #define CISS_METH_BIT63		0x08000000 /* address bit 63 is valid */
     84   1.4  christos #define CISS_METH_FIFO64_RRO	0x10000000 /* 64bit FIFO reverse read order */
     85   1.4  christos #define CISS_METH_SHORT_TAG	0x20000000 /* short 4 byte tag support */
     86   1.4  christos #define CISS_METH_MSIX		0x40000000 /* directed MSI-X support */
     87   1.4  christos #define CISS_METH_FIFO64	0x80000000 /* 64bit FIFO support */
     88   1.1        he 	u_int32_t	amethod;
     89   1.1        he 	u_int32_t	rmethod;
     90   1.1        he 	u_int32_t	paddr_lim;
     91   1.1        he 	u_int32_t	int_delay;
     92   1.1        he 	u_int32_t	int_count;
     93   1.1        he 	u_int32_t	maxcmd;
     94   1.1        he 	u_int32_t	scsibus;
     95   1.1        he #define	CISS_BUS_U2	0x0001
     96   1.1        he #define	CISS_BUS_U3	0x0002
     97   1.1        he #define	CISS_BUS_FC1	0x0100
     98   1.1        he #define	CISS_BUS_FC2	0x0200
     99   1.1        he 	u_int32_t	troff;
    100   1.1        he 	u_int8_t	hostname[16];
    101   1.1        he 	u_int32_t	heartbeat;
    102   1.1        he 	u_int32_t	driverf;
    103   1.1        he #define	CISS_DRV_UATT	0x0001
    104   1.1        he #define	CISS_DRV_QINI	0x0002
    105   1.1        he #define	CISS_DRV_LCKINT	0x0004
    106   1.1        he #define	CISS_DRV_QTAGS	0x0008
    107   1.1        he #define	CISS_DRV_ALPHA	0x0010
    108   1.1        he #define	CISS_DRV_LUNS	0x0020
    109   1.1        he #define	CISS_DRV_MSGRQ	0x0080
    110   1.1        he #define	CISS_DRV_DBRD	0x0100
    111   1.1        he #define	CISS_DRV_PRF	0x0200
    112   1.1        he 	u_int32_t	maxsg;
    113   1.6  jdolecek /*
    114   1.6  jdolecek  * these fields appear in OpenCISS Spec 1.06
    115   1.6  jdolecek  * http://cciss.sourceforge.net/#docs
    116   1.6  jdolecek  */
    117   1.6  jdolecek 	u_int32_t	max_logical_supported;
    118   1.6  jdolecek 	u_int32_t	max_physical_supported;
    119   1.6  jdolecek 	u_int32_t	max_physical_per_logical;
    120   1.6  jdolecek 	u_int32_t	max_perfomant_mode_cmds;
    121   1.6  jdolecek 	u_int32_t	max_block_fetch_count;
    122   1.1        he } __packed;
    123   1.1        he 
    124   1.6  jdolecek /*
    125   1.6  jdolecek  * Configuration table for the Performant transport.  Only 4 request queues
    126   1.6  jdolecek  * are mentioned in this table, though apparently up to 256 can exist.
    127   1.6  jdolecek  */
    128   1.6  jdolecek struct ciss_perf_config {
    129   1.6  jdolecek 	uint32_t	fetch_count[8];
    130   1.6  jdolecek #define CISS_SG_FETCH_MAX	0
    131   1.6  jdolecek #define CISS_SG_FETCH_1		1
    132   1.6  jdolecek #define CISS_SG_FETCH_2		2
    133   1.6  jdolecek #define CISS_SG_FETCH_4		3
    134   1.6  jdolecek #define CISS_SG_FETCH_8		4
    135   1.6  jdolecek #define CISS_SG_FETCH_16	5
    136   1.6  jdolecek #define CISS_SG_FETCH_32	6
    137   1.6  jdolecek #define CISS_SG_FETCH_NONE	7
    138   1.6  jdolecek 	uint32_t	rq_size;
    139   1.6  jdolecek 	uint32_t	rq_count;
    140   1.6  jdolecek 	uint32_t	rq_bank_lo;
    141   1.6  jdolecek 	uint32_t	rq_bank_hi;
    142   1.6  jdolecek 	struct {
    143   1.6  jdolecek 		uint32_t	rq_addr_lo;
    144   1.6  jdolecek 		uint32_t	rq_addr_hi;
    145   1.6  jdolecek 	} __packed rq[4];
    146   1.6  jdolecek } __packed;
    147   1.6  jdolecek #define	CISS_CYCLE_MASK	0x00000001
    148   1.6  jdolecek 
    149   1.1        he struct ciss_inquiry {
    150   1.1        he 	u_int8_t	numld;
    151   1.1        he 	u_int8_t	sign[4];
    152   1.1        he 	u_int8_t	fw_running[4];
    153   1.1        he 	u_int8_t	fw_stored[4];
    154   1.1        he 	u_int8_t	hw_rev;
    155   1.1        he 	u_int8_t	resv0[12];
    156   1.1        he 	u_int16_t	pci_vendor;
    157   1.1        he 	u_int16_t	pci_product;
    158   1.1        he 	u_int8_t	resv1[10];
    159   1.1        he 	u_int8_t	market_rev;
    160   1.1        he 	u_int8_t	flags;
    161   1.1        he #define	CISS_INQ_WIDE	0x08
    162   1.1        he #define	CISS_INQ_BIGMAP	0x80
    163   1.1        he #define	CISS_INQ_BITS	"\020\04WIDE\010BIGMAP"
    164   1.1        he 	u_int8_t	resv2[2];
    165   1.1        he 	u_int8_t	nscsi_bus;
    166   1.1        he 	u_int8_t	resv3[4];
    167   1.1        he 	u_int8_t	clk[4];		/* unaligned dumbness */
    168   1.1        he 	u_int8_t	buswidth;
    169   1.1        he 	u_int8_t	disks[CISS_DRVMAP_SIZE];
    170   1.1        he 	u_int8_t	extdisks[CISS_DRVMAP_SIZE];
    171   1.1        he 	u_int8_t	nondisks[CISS_DRVMAP_SIZE];
    172   1.1        he } __packed;
    173   1.1        he 
    174   1.1        he struct ciss_ldmap {
    175   1.1        he 	u_int32_t	size;
    176   1.1        he 	u_int32_t	resv;
    177   1.1        he 	struct {
    178   1.1        he 		u_int32_t tgt;
    179   1.1        he 		u_int32_t tgt2;
    180   1.1        he 	} map[1];
    181   1.1        he } __packed;
    182   1.1        he 
    183   1.1        he struct ciss_flush {
    184   1.1        he 	u_int16_t	flush;
    185   1.1        he #define	CISS_FLUSH_ENABLE	0
    186   1.1        he #define	CISS_FLUSH_DISABLE	1
    187   1.1        he 	u_int16_t	resv[255];
    188   1.1        he } __packed;
    189   1.1        he 
    190   1.2    mhitch struct ciss_blink {
    191   1.2    mhitch 	u_int32_t	duration;	/* x100ms */
    192   1.2    mhitch 	u_int32_t	elapsed;	/* only for sense */
    193   1.2    mhitch 	u_int8_t	pdtab[256];
    194   1.2    mhitch #define	CISS_BLINK_ALL	1
    195   1.2    mhitch #define	CISS_BLINK_TIMED 2
    196   1.2    mhitch 	u_int8_t	res[248];
    197   1.2    mhitch } __packed;
    198   1.2    mhitch 
    199   1.2    mhitch struct ciss_ldid {
    200   1.2    mhitch 	u_int16_t	blksize;
    201   1.2    mhitch 	u_int16_t	nblocks[2];	/* UNALIGNED! */
    202   1.2    mhitch 	u_int8_t	params[16];
    203   1.2    mhitch 	u_int8_t	type;
    204   1.2    mhitch #define	CISS_LD_RAID0	0
    205   1.2    mhitch #define	CISS_LD_RAID4	1
    206   1.2    mhitch #define	CISS_LD_RAID1	2
    207   1.2    mhitch #define	CISS_LD_RAID5	3
    208   1.2    mhitch #define	CISS_LD_RAID51	4
    209   1.2    mhitch #define	CISS_LD_RAIDADG	5
    210   1.2    mhitch 	u_int8_t	res0;
    211   1.2    mhitch 	u_int8_t	bios_dis;
    212   1.2    mhitch 	u_int8_t	res1;
    213   1.2    mhitch 	u_int32_t	id;
    214   1.2    mhitch 	u_int8_t	label[64];
    215   1.2    mhitch 	u_int64_t	nbigblocks;
    216   1.2    mhitch 	u_int8_t	res2[410];
    217   1.2    mhitch } __packed;
    218   1.2    mhitch 
    219   1.2    mhitch struct ciss_ldstat {
    220   1.2    mhitch 	u_int8_t	stat;
    221   1.2    mhitch #define	CISS_LD_OK	0
    222   1.2    mhitch #define	CISS_LD_FAILED	1
    223   1.2    mhitch #define	CISS_LD_UNCONF	2
    224   1.2    mhitch #define	CISS_LD_DEGRAD	3
    225   1.2    mhitch #define	CISS_LD_RBLDRD	4	/* ready for rebuild */
    226   1.2    mhitch #define	CISS_LD_REBLD	5
    227   1.2    mhitch #define	CISS_LD_PDINV	6	/* wrong phys drive replaced */
    228   1.2    mhitch #define	CISS_LD_PDUNC	7	/* phys drive is not connected proper */
    229   1.2    mhitch #define	CISS_LD_EXPND	10	/* expanding */
    230   1.2    mhitch #define	CISS_LD_NORDY	11	/* volume is not ready */
    231   1.2    mhitch #define	CISS_LD_QEXPND	12	/* queued for expansion */
    232   1.2    mhitch 	u_int8_t	failed[4];	/* failed map */
    233   1.2    mhitch 	u_int8_t	res0[416];
    234   1.2    mhitch 	u_int8_t	prog[4];	/* blocks left to rebuild/expand */
    235   1.2    mhitch 	u_int8_t	rebuild;	/* drive that is rebuilding */
    236   1.2    mhitch 	u_int16_t	remapcnt[32];	/* count of remapped blocks for pds */
    237   1.2    mhitch 	u_int8_t	replaced[4];	/* replaced drives map */
    238   1.2    mhitch 	u_int8_t	spare[4];	/* used spares map */
    239   1.2    mhitch 	u_int8_t	sparestat;	/* spare status */
    240   1.2    mhitch #define	CISS_LD_CONF	0x01	/* spare configured */
    241   1.2    mhitch #define	CISS_LD_RBLD	0x02	/* spare is used and rebuilding */
    242   1.2    mhitch #define	CISS_LD_DONE	0x04	/* spare rebuild done */
    243   1.2    mhitch #define	CISS_LD_FAIL	0x08	/* at least one spare drive has failed */
    244   1.2    mhitch #define	CISS_LD_USED	0x10	/* at least one spare drive is used */
    245   1.2    mhitch #define	CISS_LD_AVAIL	0x20	/* at least one spare is available */
    246   1.2    mhitch 	u_int8_t	sparemap[32];	/* spare->pd replacement map */
    247   1.2    mhitch 	u_int8_t	replok[4];	/* replaced failed map */
    248   1.2    mhitch 	u_int8_t	readyok;	/* ready to become ok */
    249   1.2    mhitch 	u_int8_t	memfail;	/* cache mem failure */
    250   1.2    mhitch 	u_int8_t	expfail;	/* expansion failure */
    251   1.2    mhitch 	u_int8_t	rebldfail;	/* rebuild failure */
    252  1.11    andvar #define	CISS_LD_RBLD_READ	0x01	/* read failed */
    253   1.2    mhitch #define	CISS_LD_RBLD_WRITE	0x02	/* write fail */
    254   1.2    mhitch 	u_int8_t	bigfailed[16];	/* bigmap vers of same of the above */
    255   1.2    mhitch 	u_int8_t	bigremapcnt[256];
    256   1.2    mhitch 	u_int8_t	bigreplaced[16];
    257   1.2    mhitch 	u_int8_t	bigspare[16];
    258   1.2    mhitch 	u_int8_t	bigsparemap[128];
    259   1.2    mhitch 	u_int8_t	bigreplok[16];
    260   1.2    mhitch 	u_int8_t	bigrebuild;	/* big-number rebuilding driveno */
    261   1.2    mhitch } __packed;
    262   1.2    mhitch 
    263   1.2    mhitch struct ciss_pdid {
    264   1.2    mhitch 	u_int8_t	bus;
    265   1.2    mhitch 	u_int8_t	target;
    266   1.2    mhitch 	u_int16_t	blksz;
    267   1.2    mhitch 	u_int32_t	nblocks;
    268   1.2    mhitch 	u_int32_t	resblks;
    269   1.2    mhitch 	u_int8_t	model[40];
    270   1.2    mhitch 	u_int8_t	serial[40];
    271   1.2    mhitch 	u_int8_t	revision[8];
    272   1.2    mhitch 	u_int8_t	bits;
    273   1.2    mhitch 	u_int8_t	res0[2];
    274   1.2    mhitch 	u_int8_t	present;
    275   1.2    mhitch #define	CISS_PD_PRESENT	0x01
    276   1.2    mhitch #define	CISS_PD_NONDSK	0x02
    277   1.2    mhitch #define	CISS_PD_WIDE	0x04
    278   1.2    mhitch #define	CISS_PD_SYNC	0x08
    279   1.2    mhitch #define	CISS_PD_NARROW	0x10
    280   1.2    mhitch #define	CISS_PD_W2NARR	0x20	/* wide downgrade to narrow */
    281   1.2    mhitch #define	CISS_PD_ULTRA	0x40
    282   1.2    mhitch #define	CISS_PD_ULTRA2	0x80
    283   1.2    mhitch 	u_int8_t	config;
    284   1.2    mhitch #define	CISS_PD_SMART	0x01
    285   1.2    mhitch #define	CISS_PD_SMERRR	0x02
    286   1.2    mhitch #define	CISS_PD_SMERRE	0x04
    287   1.2    mhitch #define	CISS_PD_SMERRD	0x08
    288   1.2    mhitch #define	CISS_PD_EXT	0x10
    289   1.2    mhitch #define	CISS_PD_CONF	0x20
    290   1.2    mhitch #define	CISS_PD_SPARE	0x40
    291   1.2    mhitch #define	CISS_PD_CASAVE	0x80
    292   1.2    mhitch 	u_int8_t	res1;
    293   1.2    mhitch 	u_int8_t	cache;
    294   1.2    mhitch #define	CISS_PD_CACHE	0x01
    295   1.2    mhitch #define	CISS_PD_CASAFE	0x01
    296   1.2    mhitch 	u_int8_t	res2[5];
    297   1.2    mhitch 	u_int8_t	connector[2];
    298   1.2    mhitch 	u_int8_t	res3;
    299   1.2    mhitch 	u_int8_t	bay;
    300   1.2    mhitch 	u_int16_t	rpm;
    301   1.2    mhitch 	u_int8_t	type;
    302   1.2    mhitch 	u_int8_t	res4[393];
    303   1.2    mhitch } __packed;
    304   1.2    mhitch 
    305   1.2    mhitch struct ciss_event {
    306   1.2    mhitch 	u_int32_t	reltime;	/* time since controller boot */
    307   1.2    mhitch 	u_int16_t	event;
    308   1.2    mhitch #define	CISS_EVCLS_PROTO	0
    309   1.2    mhitch #define	CISS_EVCLS_PLUG		1
    310   1.2    mhitch #define	CISS_EVCLS_HW		2
    311   1.2    mhitch #define	CISS_EVCLS_ENV		3
    312   1.2    mhitch #define	CISS_EVCLS_PD		4	/* ciss_evpdchg in details */
    313   1.2    mhitch #define	CISS_EVCLS_LD		5
    314   1.2    mhitch #define	CISS_EVCLS_CTRL		6
    315   1.2    mhitch #define	CISS_EVCLS_CISS		8	/*  funky errors */
    316   1.2    mhitch #define	CISS_EVCLS_RESV		9
    317   1.2    mhitch 	u_int16_t	subevent;
    318   1.2    mhitch #define	CISS_EVPROTO_STAT	0
    319   1.2    mhitch #define	CISS_EVPROTO_ERR	1
    320   1.2    mhitch #define	CISS_EVPLUG_PDCHG	0	/* ciss_evpdchg */
    321   1.2    mhitch #define	CISS_EVPLUG_POWER	1	/* ciss_evpschg */
    322   1.2    mhitch #define	CISS_EVPLUG_FAN		2	/* ciss_evfanchg */
    323   1.2    mhitch #define	CISS_EVPLUG_UPS		3	/* ciss_evupschg */
    324   1.2    mhitch #define	CISS_EVPLUG_CTRL	4	/* ciss_evctrlchg: ctrl removed? (; */
    325   1.2    mhitch #define	CISS_EVHW_CABLES	0
    326   1.2    mhitch #define	CISS_EVHW_MEMORY	1
    327   1.2    mhitch #define	CISS_EVHW_FAN		2	/* detail as in CISS_EVPLUG_FAN */
    328   1.2    mhitch #define	CISS_EVHW_VRM		3
    329   1.2    mhitch #define	CISS_EVENV_TEMP		0	/* ciss_evtempchg */
    330   1.2    mhitch #define	CISS_EVENV_PS		1
    331   1.2    mhitch #define	CISS_EVENV_CHASSIS	2
    332   1.2    mhitch #define	CISS_EVENV_AC		3
    333   1.2    mhitch #define	CISS_EVPD_STAT		0
    334   1.2    mhitch #define	CISS_EVLD_STAT		0
    335   1.2    mhitch #define	CISS_EVLD_ERR		1
    336   1.2    mhitch #define	CISS_EVLD_CHECK		2	/* surface check */
    337   1.2    mhitch #define	CISS_EVCTRL_STAT	0
    338   1.2    mhitch 	u_int16_t	detail;
    339   1.2    mhitch #define	CISS_EVSTAT_NONE	0
    340   1.2    mhitch #define	CISS_EVSTAT_DISABLE	1
    341   1.2    mhitch #define	CISS_EVSTAT_TMO		2	/* async event poll timeout */
    342   1.2    mhitch #define	CISS_EVERR_OVERFLOW	0	/* event queue overflow */
    343   1.2    mhitch #define	CISS_EVPLUG_REMOVE	0
    344   1.2    mhitch #define	CISS_EVPLUG_INSERT	1
    345   1.2    mhitch #define	CISS_EVFAN_FAULT	0
    346   1.2    mhitch #define	CISS_EVFAN_DEGRADED	1
    347   1.2    mhitch #define	CISS_EVFAN_OK		2
    348   1.2    mhitch #define	CISS_EVVRM_REMOVE	0
    349   1.2    mhitch #define	CISS_EVVRM_INSERT	1
    350   1.2    mhitch #define	CISS_EVVRM_FAILED	2
    351   1.2    mhitch #define	CISS_EVVRM_OK		3
    352   1.2    mhitch #define	CISS_EVTEMP_LIMEX	0	/* limit exceeded */
    353   1.2    mhitch #define	CISS_EVTEMP_WARN	1
    354   1.2    mhitch #define	CISS_EVTEMP_OK		2
    355   1.2    mhitch #define	CISS_EVPS_FAIL		0
    356   1.2    mhitch #define	CISS_EVPS_OK		2
    357   1.2    mhitch #define	CISS_EVCHAS_OPEN	0
    358   1.2    mhitch #define	CISS_EVCHAS_CLOSE	2
    359   1.2    mhitch #define	CISS_EVAC_FAIL		0
    360   1.2    mhitch #define	CISS_EVAC_BATTLOW	1
    361   1.2    mhitch #define	CISS_EVPDSTAT_FAIL	0
    362   1.2    mhitch #define	CISS_EVLDSTAT_CHG	0	/* ciss_evldchg */
    363   1.2    mhitch #define	CISS_EVLDSTAT_EXMEDIA	1	/* untolerant cfg got drive replaced */
    364   1.2    mhitch #define	CISS_EVLDSTAT_RERDERR	2	/* ciss_evldrblderr */
    365   1.2    mhitch #define	CISS_EVLDSTAT_REWRERR	3	/* ciss_evldrblderr */
    366   1.2    mhitch #define	CISS_EVLDERR_FATAL	0	/* ciss_evlderr */
    367   1.2    mhitch #define	CISS_EVCHECK_DONE	0	/* details have onle 16bit ld num */
    368   1.2    mhitch #define	CISS_EVCTRLSTAT_CHG	0	/* ciss_evctrlstat */
    369   1.2    mhitch 	u_int8_t	data[64];
    370   1.2    mhitch 	u_int8_t	msg[80];
    371   1.2    mhitch 	u_int32_t	tag;
    372   1.2    mhitch 	u_int16_t	monday;
    373   1.2    mhitch 	u_int16_t	year;
    374   1.2    mhitch 	u_int32_t	time;
    375   1.2    mhitch 	u_int16_t	presec;		/* time for events before boot */
    376   1.2    mhitch 	u_int8_t	device[8];
    377   1.2    mhitch 	u_int8_t	resv[336];
    378   1.2    mhitch } __packed;
    379   1.2    mhitch 
    380   1.2    mhitch struct ciss_evpdchg {	/* details pointer */
    381   1.2    mhitch 	u_int16_t	pd;
    382   1.2    mhitch 	u_int8_t	flag;		/* 1 for configured */
    383   1.2    mhitch 	u_int8_t	spare;
    384   1.2    mhitch 	u_int8_t	bigpd;		/* big number of the pd */
    385   1.2    mhitch 	u_int8_t	baynum;
    386   1.2    mhitch } __packed;
    387   1.2    mhitch 
    388   1.2    mhitch struct ciss_evpschg {	/* details pointer */
    389   1.2    mhitch 	u_int16_t	port;
    390   1.2    mhitch 	u_int16_t	psid;
    391   1.2    mhitch 	u_int16_t	box;
    392   1.2    mhitch } __packed;
    393   1.2    mhitch 
    394   1.2    mhitch struct ciss_evfanchg {	/* details pointer */
    395   1.2    mhitch 	u_int16_t	port;
    396   1.2    mhitch 	u_int16_t	fanid;
    397   1.2    mhitch 	u_int16_t	box;
    398   1.2    mhitch } __packed;
    399   1.2    mhitch 
    400   1.2    mhitch struct ciss_evupschg {	/* details pointer */
    401   1.2    mhitch 	u_int16_t	port;
    402   1.2    mhitch 	u_int16_t	upsid;
    403   1.2    mhitch } __packed;
    404   1.2    mhitch 
    405   1.2    mhitch struct ciss_evctrlchg {	/* details pointer */
    406   1.2    mhitch 	u_int16_t	slot;
    407   1.2    mhitch } __packed;
    408   1.2    mhitch 
    409   1.2    mhitch struct ciss_evtempchg {	/* details pointer */
    410   1.2    mhitch 	u_int16_t	port;
    411   1.2    mhitch 	u_int16_t	sensid;
    412   1.2    mhitch 	u_int16_t	box;
    413   1.2    mhitch } __packed;
    414   1.2    mhitch 
    415   1.2    mhitch struct ciss_evldchg {	/* details pointer */
    416   1.2    mhitch 	u_int16_t	ld;
    417   1.2    mhitch 	u_int8_t	prevstat;	/* same as ldstat->state */
    418   1.2    mhitch 	u_int8_t	newstat;	/* same as ldstat->state */
    419   1.2    mhitch 	u_int8_t	sparestat;
    420   1.2    mhitch } __packed;
    421   1.2    mhitch 
    422   1.2    mhitch struct ciss_evldrblderr { /* details pointer */
    423   1.2    mhitch 	u_int16_t	ld;
    424   1.2    mhitch 	u_int8_t	replace;
    425   1.2    mhitch 	u_int8_t	errpd;
    426   1.2    mhitch 	u_int8_t	bigreplace;
    427   1.2    mhitch 	u_int8_t	bigerrpd;
    428   1.2    mhitch } __packed;
    429   1.2    mhitch 
    430   1.2    mhitch struct ciss_evlderr {	/* details pointer */
    431   1.2    mhitch 	u_int16_t	ld;
    432   1.2    mhitch 	u_int16_t	blkno[2];	/* unaligned; if >2tb see big later */
    433   1.2    mhitch 	u_int16_t	count;
    434   1.2    mhitch 	u_int8_t	ldcmd;
    435   1.2    mhitch 	u_int8_t	bus;
    436   1.2    mhitch 	u_int8_t	target;
    437   1.2    mhitch 	u_int8_t	bigblkno[8];	/* unaligned */
    438   1.2    mhitch } __packed;
    439   1.2    mhitch 
    440   1.2    mhitch struct ciss_evctrlstat { /* details pointer */
    441   1.2    mhitch 	u_int8_t	prefctrl;
    442   1.2    mhitch 	u_int8_t	currmode;
    443   1.2    mhitch 	u_int8_t	redctrl;
    444   1.2    mhitch 	u_int8_t	redfail;
    445   1.2    mhitch 	u_int8_t	prevctrl;
    446   1.2    mhitch 	u_int8_t	prevmode;
    447   1.2    mhitch 	u_int8_t	prevred;
    448   1.2    mhitch 	u_int8_t	prevfail;
    449   1.2    mhitch } __packed;
    450   1.2    mhitch 
    451   1.6  jdolecek struct ciss_sg_entry {
    452   1.6  jdolecek 	u_int32_t	addr_lo;
    453   1.6  jdolecek 	u_int32_t	addr_hi;
    454   1.6  jdolecek 	u_int32_t	len;
    455   1.6  jdolecek 	u_int32_t	flags;
    456   1.6  jdolecek #define	CISS_SG_EXT	0x0001
    457   1.6  jdolecek } __packed;
    458   1.6  jdolecek 
    459   1.1        he struct ciss_cmd {
    460   1.1        he 	u_int8_t	resv0;	/* 00 */
    461   1.1        he 	u_int8_t	sgin;	/* 01: #sg in the cmd */
    462   1.1        he 	u_int16_t	sglen;	/* 02: #sg total */
    463   1.1        he 	u_int32_t	id;	/* 04: cmd id << 2 and status bits */
    464   1.1        he #define	CISS_CMD_ERR	0x02
    465   1.1        he 	u_int32_t	id_hi;	/* 08: not used */
    466   1.1        he 	u_int32_t	tgt;	/* 0c: tgt:bus:mode or lun:mode */
    467   1.1        he #define	CISS_CMD_MODE_PERIPH	0x00000000
    468   1.1        he #define	CISS_CMD_MODE_LD	0x40000000
    469   1.1        he #define	CISS_CMD_TGT_MASK	0x40ffffff
    470   1.1        he #define	CISS_CMD_BUS_MASK	0x3f000000
    471   1.1        he #define	CISS_CMD_BUS_SHIFT	24
    472   1.1        he 	u_int32_t	tgt2;	/* 10: scsi-3 address bytes */
    473   1.1        he 
    474   1.1        he 	u_int8_t	cdblen;	/* 14: valid length of cdb */
    475   1.1        he 	u_int8_t	flags;	/* 15 */
    476   1.1        he #define	CISS_CDB_CMD	0x00
    477   1.1        he #define	CISS_CDB_MSG	0x01
    478   1.1        he #define	CISS_CDB_NOTAG	0x00
    479   1.1        he #define	CISS_CDB_SIMPL	0x20
    480   1.1        he #define	CISS_CDB_QHEAD	0x28
    481   1.1        he #define	CISS_CDB_ORDR	0x30
    482   1.1        he #define	CISS_CDB_AUTO	0x38
    483   1.1        he #define	CISS_CDB_IN	0x80
    484   1.1        he #define	CISS_CDB_OUT	0x40
    485   1.1        he 	u_int16_t	tmo;	/* 16: timeout in seconds */
    486   1.3    bouyer #define	CISS_MAX_CDB	16
    487   1.1        he 	u_int8_t	cdb[16];/* 18 */
    488   1.1        he 
    489   1.1        he 	u_int64_t	err_pa;	/* 28: pa(struct ciss_error *) */
    490   1.1        he 	u_int32_t	err_len;/* 30 */
    491   1.1        he 
    492   1.6  jdolecek 	struct ciss_sg_entry sgl[1];		/* 34 */
    493   1.1        he } __packed;
    494   1.1        he 
    495   1.1        he struct ciss_error {
    496   1.1        he 	u_int8_t	scsi_stat;	/* SCSI_OK etc */
    497   1.1        he 	u_int8_t	senselen;
    498   1.1        he 	u_int16_t	cmd_stat;
    499   1.1        he #define	CISS_ERR_OK	0
    500   1.1        he #define	CISS_ERR_TGTST	1	/* target status */
    501   1.1        he #define	CISS_ERR_UNRUN	2
    502   1.1        he #define	CISS_ERR_OVRUN	3
    503   1.1        he #define	CISS_ERR_INVCMD	4
    504   1.1        he #define	CISS_ERR_PROTE	5
    505   1.1        he #define	CISS_ERR_HWERR	6
    506   1.1        he #define	CISS_ERR_CLOSS	7
    507   1.1        he #define	CISS_ERR_ABRT	8
    508   1.1        he #define	CISS_ERR_FABRT	9
    509   1.1        he #define	CISS_ERR_UABRT	10
    510   1.1        he #define	CISS_ERR_TMO	11
    511   1.1        he #define	CISS_ERR_NABRT	12
    512   1.1        he 	u_int32_t	resid;
    513   1.1        he 	u_int8_t	err_type[4];
    514   1.1        he 	u_int32_t	err_info;
    515   1.1        he 	u_int8_t	sense[32];
    516   1.1        he } __packed;
    517   1.1        he 
    518   1.1        he struct ciss_ccb {
    519   1.9  jdolecek 	TAILQ_ENTRY(ciss_ccb)	ccb_link;
    520   1.1        he 	paddr_t			ccb_cmdpa;
    521   1.1        he 	enum {
    522   1.1        he 		CISS_CCB_FREE	= 0x01,
    523   1.1        he 		CISS_CCB_READY	= 0x02,
    524   1.1        he 		CISS_CCB_ONQ	= 0x04,
    525   1.1        he 		CISS_CCB_PREQ	= 0x08,
    526   1.1        he 		CISS_CCB_POLL	= 0x10,
    527   1.1        he 		CISS_CCB_FAIL	= 0x80
    528   1.1        he #define	CISS_CCB_BITS	"\020\01FREE\02READY\03ONQ\04PREQ\05POLL\010FAIL"
    529   1.1        he 	} ccb_state;
    530   1.1        he 
    531   1.1        he 	struct scsipi_xfer	*ccb_xs;
    532   1.1        he 	size_t			ccb_len;
    533   1.1        he 	void			*ccb_data;
    534   1.1        he 	bus_dmamap_t		ccb_dmamap;
    535   1.6  jdolecek 	uint8_t			ccb_sg_tag;
    536   1.1        he 
    537   1.1        he 	struct ciss_error	ccb_err;
    538  1.10  jdolecek 	struct ciss_cmd		ccb_cmd __aligned(16);	/* followed by sgl */
    539   1.1        he };
    540  1.10  jdolecek CTASSERT((offsetof(struct ciss_ccb, ccb_cmd) & 0xf) == 0);
    541   1.1        he 
    542   1.9  jdolecek typedef TAILQ_HEAD(ciss_queue_head, ciss_ccb)     ciss_queue_head;
    543   1.1        he 
    544