xref: /netbsd/sys/dev/ic/icpreg.h (revision bf9ec67e)
1 /*	$NetBSD: icpreg.h,v 1.1 2002/04/22 21:05:21 ad Exp $	*/
2 
3 /*-
4  * Copyright (c) 2002 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Andrew Doran.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 /*
40  * Copyright (c) 1999, 2000 Niklas Hallqvist.  All rights reserved.
41  *
42  * Redistribution and use in source and binary forms, with or without
43  * modification, are permitted provided that the following conditions
44  * are met:
45  * 1. Redistributions of source code must retain the above copyright
46  *    notice, this list of conditions and the following disclaimer.
47  * 2. Redistributions in binary form must reproduce the above copyright
48  *    notice, this list of conditions and the following disclaimer in the
49  *    documentation and/or other materials provided with the distribution.
50  * 3. All advertising materials mentioning features or use of this software
51  *    must display the following acknowledgement:
52  *	This product includes software developed by Niklas Hallqvist.
53  * 4. The name of the author may not be used to endorse or promote products
54  *    derived from this software without specific prior written permission.
55  *
56  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
57  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
58  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
59  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
60  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
62  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
63  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
64  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
65  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66  *
67  * from OpenBSD: gdtreg.h,v 1.1 2000/02/07 00:33:03 niklas Exp
68  */
69 
70 #ifndef _IC_ICPREG_H_
71 #define _IC_ICPREG_H_
72 
73 #define ICP_MAXBUS		6	/* XXX Why not 5? */
74 #define ICP_MAX_HDRIVES		35	/* 5 busses * 7 targets XXX correct? */
75 #define ICP_MAXID_FC		127	/* Fibre-channel maximum ID */
76 #define ICP_MAXOFFSETS		128
77 #define ICP_MAXSG		17	/* Max. s/g elements; actually 128 */
78 #define ICP_PROTOCOL_VERSION	1
79 #define ICP_LINUX_OS		8	/* Used for cache optimization */
80 #define ICP_SCATTER_GATHER	1	/* s/g feature */
81 #define ICP_SECS32		0x1f	/* round capacity */
82 #define ICP_LOCALBOARD		0	/* Board node always 0 */
83 #define ICP_MAX_CMDS		124
84 #define ICP_SECTOR_SIZE		0x200	/* Always 512 bytes for cache devs */
85 
86 /* DPMEM constants */
87 #define ICP_MPR_MAGIC		0xc0ffee11
88 #define ICP_IC_HEADER_BYTES	48
89 #define ICP_IC_QUEUE_BYTES	4
90 
91 /* Cache/raw service commands */
92 #define ICP_INIT	0		/* service initialization */
93 #define ICP_READ	1		/* read command */
94 #define ICP_WRITE	2		/* write command */
95 #define ICP_INFO	3		/* information about devices */
96 #define ICP_FLUSH	4		/* flush dirty cache buffers */
97 #define ICP_IOCTL	5		/* ioctl command */
98 #define ICP_DEVTYPE	9		/* additional information */
99 #define ICP_MOUNT	10		/* mount cache device */
100 #define ICP_UNMOUNT	11		/* unmount cache device */
101 #define ICP_SET_FEAT	12		/* set features (scatter/gather) */
102 #define ICP_GET_FEAT	13		/* get features */
103 #define ICP_WRITE_THR	16		/* write through */
104 #define ICP_READ_THR	17		/* read through */
105 #define ICP_EXT_INFO	18		/* extended info */
106 #define ICP_RESET	19		/* controller reset */
107 #define ICP_FREEZE_IO	25		/* freeze all IOs */
108 #define ICP_UNFREEZE_IO	26		/* unfreeze all IOs */
109 
110 /* Additional raw service commands */
111 #define ICP_RESERVE	14		/* reserve device to raw service */
112 #define ICP_RELEASE	15		/* release device */
113 #define ICP_RESERVE_ALL 16		/* reserve all devices */
114 #define ICP_RELEASE_ALL 17		/* release all devices */
115 #define ICP_RESET_BUS	18		/* reset bus */
116 #define ICP_SCAN_START	19		/* start device scan */
117 #define ICP_SCAN_END	20		/* stop device scan */
118 
119 /* IOCTL command defines */
120 #define ICP_SCSI_DR_INFO	0x00	/* SCSI drive info */
121 #define ICP_SCSI_CHAN_CNT	0x05	/* SCSI channel count */
122 #define ICP_SCSI_DR_LIST	0x06	/* SCSI drive list */
123 #define ICP_SCSI_DEF_CNT	0x15	/* grown/primary defects */
124 #define ICP_DSK_STATISTICS	0x4b	/* SCSI disk statistics */
125 #define ICP_IOCHAN_DESC		0x5d	/* description of IO channel */
126 #define ICP_IOCHAN_RAW_DESC	0x5e	/* description of raw IO channel */
127 
128 #define ICP_L_CTRL_PATTERN	0x20000000	/* SCSI IOCTL mask */
129 #define ICP_ARRAY_INFO		0x12		/* array drive info */
130 #define ICP_ARRAY_DRV_LIST	0x0f		/* array drive list */
131 #define ICP_LA_CTRL_PATTERN	0x10000000	/* array IOCTL mask */
132 #define ICP_CACHE_DRV_CNT	0x01		/* cache drive count */
133 #define ICP_CACHE_DRV_LIST	0x02		/* cache drive list */
134 #define ICP_CACHE_INFO		0x04		/* cache info */
135 #define ICP_CACHE_CONFIG	0x05		/* cache configuration */
136 #define ICP_CACHE_DRV_INFO	0x07		/* cache drive info */
137 #define ICP_BOARD_FEATURES	0x15		/* controller features */
138 #define ICP_BOARD_INFO		0x28		/* controller info */
139 #define ICP_HOST_GET		0x10001		/* get host drive list */
140 #define ICP_IO_CHANNEL		0x20000		/* default IO channel */
141 #define ICP_INVALID_CHANNEL	0xffff		/* invalid channel */
142 
143 /* IOCTLs */
144 #define ICPIOCTL_MASK	    ('J' << 8)
145 #define ICPIOCTL_GENERAL    (ICPIOCTL_MASK | 0)	/* general IOCTL */
146 #define ICPIOCTL_DRVERS	    (ICPIOCTL_MASK | 1)	/* get driver version */
147 #define ICPIOCTL_CTRTYPE    (ICPIOCTL_MASK | 2)	/* get controller type */
148 #define ICPIOCTL_CTRCNT	    (ICPIOCTL_MASK | 5)	/* get controller count */
149 #define ICPIOCTL_LOCKDRV    (ICPIOCTL_MASK | 6)	/* lock host drive */
150 #define ICPIOCTL_LOCKCHN    (ICPIOCTL_MASK | 7)	/* lock channel */
151 #define ICPIOCTL_EVENT	    (ICPIOCTL_MASK | 8)	/* read controller events */
152 
153 /* Service errors */
154 #define ICP_S_OK		1	/* no error */
155 #define ICP_S_BSY		7	/* controller busy */
156 #define ICP_S_RAW_SCSI		12	/* raw service: target error */
157 #define ICP_S_RAW_ILL		0xff	/* raw service: illegal */
158 #define ICP_S_NO_STATUS		0x1000	/* got no status (driver-generated) */
159 
160 /* Controller services */
161 #define ICP_SCSIRAWSERVICE	3
162 #define ICP_CACHESERVICE	9
163 #define ICP_SCREENSERVICE	11
164 
165 /* Data direction raw service. */
166 #define	ICP_DATA_IN		0x01000000
167 #define	ICP_DATA_OUT		0x00000000
168 
169 /* Command queue entries */
170 #define ICP_OFFSET	0x00	/* u_int16_t, command offset in the DP RAM */
171 #define ICP_SERV_ID	0x02	/* u_int16_t, service */
172 #define ICP_COMM_Q_SZ	0x04
173 
174 /* Interface area */
175 #define ICP_S_CMD_INDX	0x00	/* u_int8_t, special command */
176 #define	ICP_S_STATUS	0x01	/* volatile u_int8_t, status special command */
177 #define ICP_S_INFO	0x04	/* u_int32_t [4], add. info special command */
178 #define ICP_SEMA0	0x14	/* volatile u_int8_t, command semaphore */
179 #define ICP_CMD_INDEX	0x18	/* u_int8_t, command number */
180 #define ICP_STATUS	0x1c	/* volatile u_int16_t, command status */
181 #define ICP_SERVICE	0x1e	/* u_int16_t, service (for asynch. events) */
182 #define ICP_DPR_INFO	0x20	/* u_int32_t [2], additional info */
183 #define ICP_COMM_QUEUE	0x28	/* command queue */
184 #define ICP_DPR_CMD	(0x30 + ICP_MAXOFFSETS * ICP_COMM_Q_SZ)
185 				/* u_int8_t [], commands */
186 #define ICP_DPR_IF_SZ	ICP_DPR_CMD
187 
188 /* Get cache info */
189 #define ICP_CINFO_CPAR		0x00
190 #define ICP_CINFO_CSTAT		0x0c
191 
192 /* Other defines */
193 #define ICP_ASYNCINDEX	0	/* command index asynchronous event */
194 #define ICP_SPEZINDEX	1	/* command index unknown service */
195 
196 /* I/O channel header */
197 struct icp_ioc_version {
198 	u_int32_t	iv_version;	/* version (~0: newest) */
199 	u_int8_t	iv_listents;	/* list entry count */
200 	u_int8_t	iv_firstchan;	/* first channel number */
201 	u_int8_t	iv_lastchan;	/* last channel number */
202 	u_int8_t	iv_chancount;	/* channel count */
203 	u_int32_t	iv_listoffset;	/* offset of list[0] */
204 } __attribute__ ((__packed__));
205 
206 #define	ICP_IOC_NEWEST	0xffffffff
207 
208 /* Get I/O channel description */
209 struct icp_ioc {
210 	u_int32_t	io_addr;	/* channel address */
211 	u_int8_t	io_type;	/* type (SCSI/FCAL) */
212 	u_int8_t	io_localno;	/* local number */
213 	u_int16_t	io_features;	/* channel features */
214 } __attribute__ ((__packed__));
215 
216 /* Get raw I/O channel description */
217 struct icp_rawioc {
218 	u_int8_t	ri_procid;	/* processor ID */
219 	u_int8_t	ri_defect;	/* defect? */
220 	u_int16_t	ri_padding;
221 } __attribute__ ((__packed__));
222 
223 /* Get SCSI channel count */
224 struct icp_getch {
225 	u_int32_t	gc_channo;	/* channel number */
226 	u_int32_t	gc_drivecnt;	/* drive count */
227 	u_int8_t	gc_scsiid;	/* SCSI initiator ID */
228 	u_int8_t	gc_scsistate;	/* SCSI processor state */
229 } __attribute__ ((__packed__));
230 
231 /* Cache info/config IOCTL structures */
232 struct icp_cpar {
233 	u_int32_t	cp_version;	/* firmware version */
234 	u_int16_t	cp_state;	/* cache state (on/off) */
235 	u_int16_t	cp_strategy;	/* cache strategy */
236 	u_int16_t	cp_write_back;	/* write back (on/off) */
237 	u_int16_t	cp_block_size;	/* cache block size */
238 } __attribute__ ((__packed__));
239 
240 struct icp_cstat {
241 	u_int32_t	cs_size;	/* cache size */
242 	u_int32_t	cs_readcnt;	/* read counter */
243 	u_int32_t	cs_writecnt;	/* write counter */
244 	u_int32_t	cs_trhits;	/* track hits */
245 	u_int32_t	cs_sechits;	/* sector hits */
246 	u_int32_t	cs_secmiss;	/* sector misses */
247 } __attribute__ ((__packed__));
248 
249 /* Board information. */
250 struct icp_binfo {
251 	u_int32_t	bi_ser_no;		/* serial number */
252 	u_int8_t	bi_oem_id[2];		/* OEM ID */
253 	u_int16_t	bi_ep_flags;		/* eprom flags */
254 	u_int32_t	bi_proc_id;		/* processor ID */
255 	u_int32_t	bi_memsize;		/* memory size (bytes) */
256 	u_int8_t	bi_mem_banks;		/* memory banks */
257 	u_int8_t	bi_chan_type;		/* channel type */
258 	u_int8_t	bi_chan_count;		/* channel count */
259 	u_int8_t	bi_rdongle_pres;	/* dongle present */
260 	u_int32_t	bi_epr_fw_ver;		/* (eprom) firmware ver */
261 	u_int32_t	bi_upd_fw_ver;		/* (update) firmware ver */
262 	u_int32_t	bi_upd_revision;	/* update revision */
263 	char		bi_type_string[16];	/* char controller name */
264 	char		bi_raid_string[16];	/* char RAID firmware name */
265 	u_int8_t	bi_update_pres;		/* update present? */
266 	u_int8_t	bi_xor_pres;		/* XOR engine present */
267 	u_int8_t	bi_prom_type;		/* ROM type (eprom/flash) */
268 	u_int8_t	bi_prom_count;		/* number of ROM devices */
269 	u_int32_t	bi_dup_pres;		/* duplexing module pres? */
270 	u_int32_t	bi_chan_pres;		/* # of exp. channels */
271 	u_int32_t	bi_mem_pres;		/* memory expansion inst? */
272 	u_int8_t	bi_ft_bus_system;	/* fault bus supported? */
273 	u_int8_t	bi_subtype_valid;	/* board_subtype valid */
274 	u_int8_t	bi_board_subtype;	/* subtype/hardware level */
275 	u_int8_t	bi_rampar_pres;		/* RAM parity check hw? */
276 } __attribute__ ((__packed__));
277 
278 /* Board features. */
279 struct icp_bfeat {
280 	u_int8_t	bf_chaining;	/* chaining supported */
281 	u_int8_t	bf_striping;	/* striping (RAID-0) supported */
282 	u_int8_t	bf_mirroring;	/* mirroring (RAID-1) supported */
283 	u_int8_t	bf_raid;	/* RAID-4/5/10 supported */
284 } __attribute__ ((__packed__));
285 
286 /* Cache drive information. */
287 struct icp_cdevinfo {
288 	char		cd_name[8];
289 	u_int32_t	cd_devtype;
290 	u_int32_t	cd_ldcnt;
291 	u_int32_t	cd_last_error;
292 	u_int8_t	cd_initialized;
293 	u_int8_t	cd_removable;
294 	u_int8_t	cd_write_protected;
295 	u_int8_t	cd_flags;
296 	u_int32_t	ld_blkcnt;
297 	u_int32_t	ld_blksize;
298 	u_int32_t	ld_dcnt;
299 	u_int32_t	ld_slave;
300 	u_int32_t	ld_dtype;
301 	u_int32_t	ld_last_error;
302 	char		ld_name[8];
303 	u_int8_t	ld_error;
304 } __attribute__ ((__packed__));
305 
306 struct icp_sg {
307 	u_int32_t	sg_addr;
308 	u_int32_t	sg_len;
309 } __attribute__ ((__packed__));
310 
311 struct icp_cachecmd {
312 	u_int16_t	cc_deviceno;
313 	u_int32_t	cc_blockno;
314 	u_int32_t	cc_blockcnt;
315 	u_int32_t	cc_addr;		/* ~0 == s/g */
316 	u_int32_t	cc_nsgent;
317 	struct icp_sg	cc_sg[ICP_MAXSG];
318 } __attribute__ ((__packed__));
319 
320 struct icp_ioctlcmd {
321 	u_int16_t	ic_bufsize;
322 	u_int32_t	ic_subfunc;
323 	u_int32_t	ic_channel;
324 	u_int32_t	ic_addr;
325 } __attribute__ ((__packed__));
326 
327 struct icp_screencmd {
328 	u_int32_t	sc_msghandle;
329 	u_int32_t	sc_msgaddr;
330 } __attribute__ ((__packed__));
331 
332 struct icp_rawcmd {
333 	u_int16_t	rc_padding0;		/* unused */
334 	u_int32_t	rc_direction;		/* data direction */
335 	u_int32_t	rc_mdisc_time;		/* disc. time (0: none) */
336 	u_int32_t	rc_mcon_time;		/* conn. time (0: none) */
337 	u_int32_t	rc_sdata;		/* dest address */
338 	u_int32_t	rc_sdlen;		/* data length */
339 	u_int32_t	rc_clen;		/* CDB length */
340 	u_int8_t	rc_cdb[12];		/* SCSI CDB */
341 	u_int8_t	rc_target;		/* target ID */
342 	u_int8_t	rc_lun;			/* LUN */
343 	u_int8_t	rc_bus;			/* channel */
344 	u_int8_t	rc_priority;		/* priority; 0 only */
345 	u_int32_t	rc_sense_len;		/* sense length */
346 	u_int32_t	rc_sense_addr;		/* sense address */
347 	u_int32_t	rc_padding1;		/* unused */
348 	u_int32_t	rc_nsgent;		/* s/g element count */
349 	struct icp_sg	rc_sg[ICP_MAXSG];	/* s/g list */
350 } __attribute__ ((__packed__));
351 
352 struct icp_cmdhdr {
353 	u_int32_t	cmd_boardnode;		/* always 0 */
354 	u_int32_t	cmd_cmdindex;		/* command identifier */
355 	u_int16_t	cmd_opcode;
356 } __attribute__ ((__packed__));
357 
358 struct icp_cmd {
359 	u_int32_t	cmd_boardnode;		/* always 0 */
360 	u_int32_t	cmd_cmdindex;		/* command identifier */
361 	u_int16_t	cmd_opcode;
362 
363 	union {
364 		struct icp_rawcmd	rc;
365 		struct icp_screencmd	sc;
366 		struct icp_ioctlcmd	ic;
367 		struct icp_cachecmd	cc;
368 	} cmd_packet;
369 } __attribute__ ((__packed__));
370 
371 #endif	/* !_IC_ICPREG_H_ */
372