1 /*        $NetBSD: i2o.h,v 1.18 2023/09/07 20:03:25 ad Exp $          */
2 
3 /*-
4  * Copyright (c) 2000, 2001 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  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /*
33  * Structures and constants, as presented by the I2O specification revision
34  * 1.5 (obtainable from http://www.intelligent-io.com/).  Currently, only
35  * what's useful to us is defined in this file.  LAN defs used to be here
36  * but were removed as they're useless.
37  */
38 
39 #ifndef   _I2O_I2O_H_
40 #define   _I2O_I2O_H_
41 
42 #include <sys/cdefs.h>
43 #include <sys/types.h>
44 
45 /*
46  * ================= Miscellaneous definitions =================
47  */
48 
49 /* Organisation IDs */
50 #define   I2O_ORG_DPT                             0x001b
51 #define   I2O_ORG_INTEL                           0x0028
52 #define   I2O_ORG_AMI                             0x1000
53 
54 /* Macros to assist in building message headers */
55 #define   I2O_MSGFLAGS(s)               (I2O_VERSION_11 | (sizeof(struct s) << 14))
56 #define   I2O_MSGFUNC(t, f)   ((t) | (I2O_TID_HOST << 12) | ((f) << 24))
57 #define   I2O_MSGPRIV(o, f)   ((f) | ((o) << 16))
58 
59 /* Common message function codes with no payload or an undefined payload */
60 #define   I2O_UTIL_NOP                            0x00
61 #define   I2O_EXEC_IOP_CLEAR            0xbe
62 #define   I2O_EXEC_SYS_QUIESCE                    0xc3
63 #define   I2O_EXEC_SYS_ENABLE           0xd1
64 #define   I2O_PRIVATE_MESSAGE           0xff
65 
66 /* Device class codes */
67 #define   I2O_CLASS_EXECUTIVE                     0x00
68 #define   I2O_CLASS_DDM                                     0x01
69 #define   I2O_CLASS_RANDOM_BLOCK_STORAGE                    0x10
70 #define   I2O_CLASS_SEQUENTIAL_STORAGE            0x11
71 #define   I2O_CLASS_LAN                                     0x20
72 #define   I2O_CLASS_WAN                                     0x30
73 #define   I2O_CLASS_FIBRE_CHANNEL_PORT            0x40
74 #define   I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL      0x41
75 #define   I2O_CLASS_SCSI_PERIPHERAL               0x51
76 #define   I2O_CLASS_ATE_PORT                      0x60
77 #define   I2O_CLASS_ATE_PERIPHERAL                0x61
78 #define   I2O_CLASS_FLOPPY_CONTROLLER             0x70
79 #define   I2O_CLASS_FLOPPY_DEVICE                           0x71
80 #define   I2O_CLASS_BUS_ADAPTER_PORT              0x80
81 
82 #define   I2O_CLASS_ANY                                     0xffffffff
83 
84 /* Reply status codes */
85 #define   I2O_STATUS_SUCCESS                      0x00
86 #define   I2O_STATUS_ABORT_DIRTY                            0x01
87 #define   I2O_STATUS_ABORT_NO_DATA_XFER           0x02
88 #define   I2O_STATUS_ABORT_PARTIAL_XFER           0x03
89 #define   I2O_STATUS_ERROR_DIRTY                            0x04
90 #define   I2O_STATUS_ERROR_NO_DATA_XFER           0x05
91 #define   I2O_STATUS_ERROR_PARTIAL_XFER           0x06
92 #define   I2O_STATUS_PROCESS_ABORT_DIRTY          0x08
93 #define   I2O_STATUS_PROCESS_ABORT_NO_DATA_XFER   0x09
94 #define   I2O_STATUS_PROCESS_ABORT_PARTIAL_XFER   0x0a
95 #define   I2O_STATUS_TRANSACTION_ERROR            0x0b
96 #define   I2O_STATUS_PROGRESS_REPORT              0x80
97 
98 /* Detailed status codes */
99 #define   I2O_DSC_SUCCESS                                   0x00
100 #define   I2O_DSC_BAD_KEY                                   0x02
101 #define   I2O_DSC_TCL_ERROR                       0x03
102 #define   I2O_DSC_REPLY_BUFFER_FULL               0x04
103 #define   I2O_DSC_NO_SUCH_PAGE                              0x05
104 #define   I2O_DSC_INSUFFICIENT_RESOURCE_SOFT      0x06
105 #define   I2O_DSC_INSUFFICIENT_RESOURCE_HARD      0x07
106 #define   I2O_DSC_CHAIN_BUFFER_TOO_LARGE                    0x09
107 #define   I2O_DSC_UNSUPPORTED_FUNCTION            0x0a
108 #define   I2O_DSC_DEVICE_LOCKED                             0x0b
109 #define   I2O_DSC_DEVICE_RESET                              0x0c
110 #define   I2O_DSC_INAPPROPRIATE_FUNCTION                    0x0d
111 #define   I2O_DSC_INVALID_INITIATOR_ADDRESS       0x0e
112 #define   I2O_DSC_INVALID_MESSAGE_FLAGS           0x0f
113 #define   I2O_DSC_INVALID_OFFSET                            0x10
114 #define   I2O_DSC_INVALID_PARAMETER               0x11
115 #define   I2O_DSC_INVALID_REQUEST                           0x12
116 #define   I2O_DSC_INVALID_TARGET_ADDRESS                    0x13
117 #define   I2O_DSC_MESSAGE_TOO_LARGE               0x14
118 #define   I2O_DSC_MESSAGE_TOO_SMALL               0x15
119 #define   I2O_DSC_MISSING_PARAMETER               0x16
120 #define   I2O_DSC_TIMEOUT                                   0x17
121 #define   I2O_DSC_UNKNOWN_ERROR                             0x18
122 #define   I2O_DSC_UNKNOWN_FUNCTION                0x19
123 #define   I2O_DSC_UNSUPPORTED_VERSION             0x1a
124 #define   I2O_DSC_DEVICE_BUSY                     0x1b
125 #define   I2O_DSC_DEVICE_NOT_AVAILABLE            0x1c
126 
127 /* Message versions */
128 #define   I2O_VERSION_10                          0x00
129 #define   I2O_VERSION_11                          0x01
130 #define   I2O_VERSION_20                          0x02
131 
132 /* Commonly used TIDs */
133 #define   I2O_TID_IOP                             0
134 #define   I2O_TID_HOST                            1
135 #define   I2O_TID_NONE                            4095
136 
137 /* SGL flags.  This list covers only a fraction of the possibilities. */
138 #define   I2O_SGL_IGNORE                          0x00000000
139 #define   I2O_SGL_SIMPLE                          0x10000000
140 #define   I2O_SGL_PAGE_LIST             0x20000000
141 
142 #define   I2O_SGL_BC_32BIT              0x01000000
143 #define   I2O_SGL_BC_64BIT              0x02000000
144 #define   I2O_SGL_BC_96BIT              0x03000000
145 #define   I2O_SGL_DATA_OUT              0x04000000
146 #define   I2O_SGL_END_BUFFER            0x40000000
147 #define   I2O_SGL_END                             0x80000000
148 
149 /* Serial number formats */
150 #define   I2O_SNFMT_UNKNOWN             0
151 #define   I2O_SNFMT_BINARY              1
152 #define   I2O_SNFMT_ASCII                         2
153 #define   I2O_SNFMT_UNICODE             3
154 #define   I2O_SNFMT_LAN_MAC             4
155 #define   I2O_SNFMT_WAN_MAC             5
156 
157 /*
158  * ================= Common structures =================
159  */
160 
161 /*
162  * Standard I2O message frame.  All message frames begin with this.
163  *
164  * Bits  Field          Meaning
165  * ----  -------------  ----------------------------------------------------
166  * 0-2   msgflags       Message header version. Must be 001 (little endian).
167  * 3     msgflags   Reserved.
168  * 4-7   msgflags       Offset to SGLs expressed as # of 32-bit words.
169  * 8-15  msgflags       Control flags.
170  * 16-31 msgflags       Message frame size expressed as # of 32-bit words.
171  * 0-11  msgfunc    TID of target.
172  * 12-23 msgfunc        TID of initiator.
173  * 24-31 msgfunc        Function (i.e., type of message).
174  */
175 struct i2o_msg {
176           u_int32_t msgflags;
177           u_int32_t msgfunc;
178           u_int32_t msgictx;  /* Initiator context */
179           u_int32_t msgtctx;  /* Transaction context */
180 
181           /* Message payload */
182 
183 } __packed;
184 
185 #define   I2O_MSGFLAGS_STATICMF                   0x0100
186 #define   I2O_MSGFLAGS_64BIT            0x0200
187 #define   I2O_MSGFLAGS_MULTI            0x1000
188 #define   I2O_MSGFLAGS_FAIL             0x2000
189 #define   I2O_MSGFLAGS_LAST_REPLY                 0x4000
190 #define   I2O_MSGFLAGS_REPLY            0x8000
191 
192 /*
193  * Standard reply frame.  msgflags, msgfunc, msgictx and msgtctx have the
194  * same meaning as in `struct i2o_msg'.
195  */
196 struct i2o_reply {
197           u_int32_t msgflags;
198           u_int32_t msgfunc;
199           u_int32_t msgictx;
200           u_int32_t msgtctx;
201           u_int16_t detail;             /* Detailed status code */
202           u_int8_t  reserved;
203           u_int8_t  reqstatus;          /* Request status code */
204 
205           /* Reply payload */
206 
207 } __packed;
208 
209 /*
210  * Fault notification reply, returned when a message frame can not be
211  * processed (i.e I2O_MSGFLAGS_FAIL is set in the reply).
212  */
213 struct i2o_fault_notify {
214           u_int32_t msgflags;
215           u_int32_t msgfunc;
216           u_int32_t msgictx;
217           u_int32_t msgtctx;  /* Not valid! */
218           u_int8_t  lowestver;
219           u_int8_t  highestver;
220           u_int8_t  severity;
221           u_int8_t  failurecode;
222           u_int16_t failingiop;         /* Bits 0-12 only */
223           u_int16_t failinghostunit;
224           u_int32_t agelimit;
225           u_int32_t lowmfa;
226           u_int32_t highmfa;
227 };
228 
229 /*
230  * Hardware resource table.  Not documented here.
231  */
232 struct i2o_hrt_entry {
233           u_int32_t adapterid;
234           u_int16_t controllingtid;
235           u_int8_t  busnumber;
236           u_int8_t  bustype;
237           u_int8_t  businfo[8];
238 } __packed;
239 
240 struct i2o_hrt {
241           u_int16_t numentries;
242           u_int8_t  entrysize;
243           u_int8_t  hrtversion;
244           u_int32_t changeindicator;
245           struct i2o_hrt_entry          entry[1];
246 } __packed;
247 
248 /*
249  * Logical configuration table entry.  Bitfields are broken down as follows:
250  *
251  * Bits   Field           Meaning
252  * -----  --------------  ---------------------------------------------------
253  *  0-11  classid         Class ID.
254  * 12-15  classid         Class version.
255  *  0-11  usertid         User TID
256  * 12-23  usertid         Parent TID.
257  * 24-31  usertid         BIOS info.
258  */
259 struct i2o_lct_entry {
260           u_int16_t entrysize;
261           u_int16_t localtid;           /* Bits 0-12 only */
262           u_int32_t changeindicator;
263           u_int32_t deviceflags;
264           u_int16_t classid;
265           u_int16_t orgid;
266           u_int32_t subclassinfo;
267           u_int32_t usertid;
268           u_int8_t  identitytag[8];
269           u_int32_t eventcaps;
270 } __packed;
271 
272 /*
273  * Logical configuration table header.
274  */
275 struct i2o_lct {
276           u_int16_t tablesize;
277           u_int16_t flags;
278           u_int32_t iopflags;
279           u_int32_t changeindicator;
280           struct i2o_lct_entry          entry[1];
281 } __packed;
282 
283 /*
284  * IOP system table.  Bitfields are broken down as follows:
285  *
286  * Bits   Field           Meaning
287  * -----  --------------  ---------------------------------------------------
288  *  0-11  iopid           IOP ID.
289  * 12-31  iopid           Reserved.
290  *  0-11  segnumber       Segment number.
291  * 12-15  segnumber       I2O version.
292  * 16-23  segnumber       IOP state.
293  * 24-31  segnumber       Messenger type.
294  */
295 struct i2o_systab_entry {
296           u_int16_t orgid;
297           u_int16_t reserved0;
298           u_int32_t iopid;
299           u_int32_t segnumber;
300           u_int16_t inboundmsgframesize;
301           u_int16_t reserved1;
302           u_int32_t lastchanged;
303           u_int32_t iopcaps;
304           u_int32_t inboundmsgportaddresslow;
305           u_int32_t inboundmsgportaddresshigh;
306 } __packed;
307 
308 struct i2o_systab {
309           u_int8_t  numentries;
310           u_int8_t  version;
311           u_int16_t reserved0;
312           u_int32_t changeindicator;
313           u_int32_t reserved1[2];
314           struct    i2o_systab_entry entry[1];
315 } __packed;
316 
317 /*
318  * IOP status record.  Bitfields are broken down as follows:
319  *
320  * Bits   Field           Meaning
321  * -----  --------------  ---------------------------------------------------
322  *  0-11  iopid           IOP ID.
323  * 12-15  iopid           Reserved.
324  * 16-31  iopid           Host unit ID.
325  *  0-11  segnumber       Segment number.
326  * 12-15  segnumber       I2O version.
327  * 16-23  segnumber       IOP state.
328  * 24-31  segnumber       Messenger type.
329  */
330 struct i2o_status {
331           u_int16_t orgid;
332           u_int16_t reserved0;
333           u_int32_t iopid;
334           u_int32_t segnumber;
335           u_int16_t inboundmframesize;
336           u_int8_t  initcode;
337           u_int8_t  reserved1;
338           u_int32_t maxinboundmframes;
339           u_int32_t currentinboundmframes;
340           u_int32_t maxoutboundmframes;
341           u_int8_t  productid[24];
342           u_int32_t expectedlctsize;
343           u_int32_t iopcaps;
344           u_int32_t desiredprivmemsize;
345           u_int32_t currentprivmemsize;
346           u_int32_t currentprivmembase;
347           u_int32_t desiredpriviosize;
348           u_int32_t currentpriviosize;
349           u_int32_t currentpriviobase;
350           u_int8_t  reserved2[3];
351           u_int8_t  syncbyte;
352 } __packed;
353 
354 #define   I2O_IOP_STATE_INITIALIZING              0x01
355 #define   I2O_IOP_STATE_RESET                     0x02
356 #define   I2O_IOP_STATE_HOLD                      0x04
357 #define   I2O_IOP_STATE_READY                     0x05
358 #define   I2O_IOP_STATE_OPERATIONAL               0x08
359 #define   I2O_IOP_STATE_FAILED                              0x10
360 #define   I2O_IOP_STATE_FAULTED                             0x11
361 
362 /*
363  * ================= Executive class messages =================
364  */
365 
366 #define   I2O_EXEC_STATUS_GET           0xa0
367 struct i2o_exec_status_get {
368           u_int32_t msgflags;
369           u_int32_t msgfunc;
370           u_int32_t reserved[4];
371           u_int32_t addrlow;
372           u_int32_t addrhigh;
373           u_int32_t length;
374 } __packed;
375 
376 #define   I2O_EXEC_OUTBOUND_INIT                  0xa1
377 struct i2o_exec_outbound_init {
378           u_int32_t msgflags;
379           u_int32_t msgfunc;
380           u_int32_t msgictx;
381           u_int32_t msgtctx;
382           u_int32_t pagesize;
383           u_int32_t flags;              /* init code, outbound msg size */
384 } __packed;
385 
386 #define   I2O_EXEC_OUTBOUND_INIT_IN_PROGRESS      1
387 #define   I2O_EXEC_OUTBOUND_INIT_REJECTED                   2
388 #define   I2O_EXEC_OUTBOUND_INIT_FAILED           3
389 #define   I2O_EXEC_OUTBOUND_INIT_COMPLETE                   4
390 
391 #define   I2O_EXEC_LCT_NOTIFY           0xa2
392 struct i2o_exec_lct_notify {
393           u_int32_t msgflags;
394           u_int32_t msgfunc;
395           u_int32_t msgictx;
396           u_int32_t msgtctx;
397           u_int32_t classid;
398           u_int32_t changeindicator;
399 } __packed;
400 
401 #define   I2O_EXEC_SYS_TAB_SET                    0xa3
402 struct i2o_exec_sys_tab_set {
403           u_int32_t msgflags;
404           u_int32_t msgfunc;
405           u_int32_t msgictx;
406           u_int32_t msgtctx;
407           u_int32_t iopid;
408           u_int32_t segnumber;
409 } __packed;
410 
411 #define   I2O_EXEC_HRT_GET              0xa8
412 struct i2o_exec_hrt_get {
413           u_int32_t msgflags;
414           u_int32_t msgfunc;
415           u_int32_t msgictx;
416           u_int32_t msgtctx;
417 } __packed;
418 
419 #define   I2O_EXEC_IOP_RESET            0xbd
420 struct i2o_exec_iop_reset {
421           u_int32_t msgflags;
422           u_int32_t msgfunc;
423           u_int32_t reserved[4];
424           u_int32_t statuslow;
425           u_int32_t statushigh;
426 } __packed;
427 
428 #define   I2O_RESET_IN_PROGRESS                   0x01
429 #define   I2O_RESET_REJECTED            0x02
430 
431 /*
432  * ================= Executive class parameter groups =================
433  */
434 
435 #define   I2O_PARAM_EXEC_LCT_SCALAR     0x0101
436 #define   I2O_PARAM_EXEC_LCT_TABLE      0x0102
437 
438 /*
439  * ================= HBA class messages =================
440  */
441 
442 #define   I2O_HBA_BUS_SCAN              0x89
443 struct i2o_hba_bus_scan {
444           u_int32_t msgflags;
445           u_int32_t msgfunc;
446           u_int32_t msgictx;
447           u_int32_t msgtctx;
448 } __packed;
449 
450 /*
451  * ================= HBA class parameter groups =================
452  */
453 
454 #define   I2O_PARAM_HBA_CTLR_INFO                 0x0000
455 struct i2o_param_hba_ctlr_info {
456           u_int8_t  bustype;
457           u_int8_t  busstate;
458           u_int16_t reserved;
459           u_int8_t  busname[12];
460 } __packed;
461 
462 #define   I2O_HBA_BUS_GENERIC           0x00
463 #define   I2O_HBA_BUS_SCSI              0x01
464 #define   I2O_HBA_BUS_FCA                         0x10
465 
466 #define   I2O_PARAM_HBA_SCSI_PORT_INFO  0x0001
467 struct i2o_param_hba_scsi_port_info {
468           u_int8_t  physicalif;
469           u_int8_t  electricalif;
470           u_int8_t  isosynchonrous;
471           u_int8_t  connectortype;
472           u_int8_t  connectorgender;
473           u_int8_t  reserved1;
474           u_int16_t reserved2;
475           u_int32_t maxnumberofdevices;
476 } __packed;
477 
478 #define   I2O_PARAM_HBA_SCSI_PORT_GENERIC         0x01
479 #define   I2O_PARAM_HBA_SCSI_PORT_UNKNOWN         0x02
480 #define   I2O_PARAM_HBA_SCSI_PORT_PARINTF         0x03
481 #define   I2O_PARAM_HBA_SCSI_PORT_FCL   0x04
482 #define   I2O_PARAM_HBA_SCSI_PORT_1394  0x05
483 #define   I2O_PARAM_HBA_SCSI_PORT_SSA   0x06
484 
485 #define   I2O_PARAM_HBA_SCSI_PORT_SE    0x03
486 #define   I2O_PARAM_HBA_SCSI_PORT_DIFF  0x04
487 #define   I2O_PARAM_HBA_SCSI_PORT_LVD   0x05
488 #define   I2O_PARAM_HBA_SCSI_PORT_OPTCL 0x06
489 
490 #define   I2O_PARAM_HBA_SCSI_PORT_HDBS50          0x04
491 #define   I2O_PARAM_HBA_SCSI_PORT_HDBU50          0x05
492 #define   I2O_PARAM_HBA_SCSI_PORT_DBS50 0x06
493 #define   I2O_PARAM_HBA_SCSI_PORT_DBU50 0x07
494 #define   I2O_PARAM_HBA_SCSI_PORT_HDBS68          0x08
495 #define   I2O_PARAM_HBA_SCSI_PORT_HDBU68          0x09
496 #define   I2O_PARAM_HBA_SCSI_PORT_SCA1  0x0a
497 #define   I2O_PARAM_HBA_SCSI_PORT_SCA2  0x0b
498 #define   I2O_PARAM_HBA_SCSI_PORT_FCDB9 0x0c
499 #define   I2O_PARAM_HBA_SCSI_PORT_FC    0x0d
500 #define   I2O_PARAM_HBA_SCSI_PORT_FCSCA40         0x0e
501 #define   I2O_PARAM_HBA_SCSI_PORT_FCSCA20         0x0f
502 #define   I2O_PARAM_HBA_SCSI_PORT_FCBNC 0x10
503 
504 #define   I2O_PARAM_HBA_SCSI_PORT_FEMALE          0x03
505 #define   I2O_PARAM_HBA_SCSI_PORT_MALE  0x04
506 
507 #define   I2O_PARAM_HBA_SCSI_CTLR_INFO  0x0200
508 struct i2o_param_hba_scsi_ctlr_info {
509           u_int8_t  scsitype;
510           u_int8_t  protection;
511           u_int8_t  settings;
512           u_int8_t  reserved;
513           u_int32_t initiatorid;
514           u_int64_t scanlun0only;
515           u_int16_t disabledevice;
516           u_int8_t  maxoffset;
517           u_int8_t  maxdatawidth;
518           u_int64_t maxsyncrate;
519 } __packed;
520 
521 /*
522  * ================= Utility messages =================
523  */
524 
525 #define   I2O_UTIL_ABORT                          0x01
526 struct i2o_util_abort {
527           u_int32_t msgflags;
528           u_int32_t msgfunc;
529           u_int32_t msgictx;
530           u_int32_t msgtctx;
531           u_int32_t flags;              /* abort type and function type */
532           u_int32_t tctxabort;
533 } __packed;
534 
535 #define   I2O_UTIL_ABORT_EXACT                    0x00000000
536 #define   I2O_UTIL_ABORT_FUNCTION                 0x00010000
537 #define   I2O_UTIL_ABORT_TRANSACTION    0x00020000
538 #define   I2O_UTIL_ABORT_WILD           0x00030000
539 
540 #define   I2O_UTIL_ABORT_CLEAN                    0x00040000
541 
542 struct i2o_util_abort_reply {
543           u_int32_t msgflags;
544           u_int32_t msgfunc;
545           u_int32_t msgictx;
546           u_int32_t msgtctx;
547           u_int32_t count;
548 } __packed;
549 
550 #define   I2O_UTIL_PARAMS_SET           0x05
551 #define   I2O_UTIL_PARAMS_GET           0x06
552 struct i2o_util_params_op {
553           u_int32_t msgflags;
554           u_int32_t msgfunc;
555           u_int32_t msgictx;
556           u_int32_t msgtctx;
557           u_int32_t flags;
558 } __packed;
559 
560 #define   I2O_PARAMS_OP_FIELD_GET                 1
561 #define   I2O_PARAMS_OP_LIST_GET                  2
562 #define   I2O_PARAMS_OP_MORE_GET                  3
563 #define   I2O_PARAMS_OP_SIZE_GET                  4
564 #define   I2O_PARAMS_OP_TABLE_GET                 5
565 #define   I2O_PARAMS_OP_FIELD_SET                 6
566 #define   I2O_PARAMS_OP_LIST_SET                  7
567 #define   I2O_PARAMS_OP_ROW_ADD                   8
568 #define   I2O_PARAMS_OP_ROW_DELETE      9
569 #define   I2O_PARAMS_OP_TABLE_CLEAR     10
570 
571 struct i2o_param_op_list_header {
572           u_int16_t count;
573           u_int16_t reserved;
574 } __packed;
575 
576 struct i2o_param_op_all_template {
577           u_int16_t operation;
578           u_int16_t group;
579           u_int16_t fieldcount;
580           u_int16_t fields[1];
581 } __packed;
582 
583 struct i2o_param_op_results {
584           u_int16_t count;
585           u_int16_t reserved;
586 } __packed;
587 
588 struct i2o_param_read_results {
589           u_int16_t blocksize;
590           u_int8_t  blockstatus;
591           u_int8_t  errorinfosize;
592 } __packed;
593 
594 struct i2o_param_table_results {
595           u_int16_t blocksize;
596           u_int8_t  blockstatus;
597           u_int8_t  errorinfosize;
598           u_int16_t rowcount;
599           u_int16_t moreflag;
600 } __packed;
601 
602 #define   I2O_UTIL_CLAIM                          0x09
603 struct i2o_util_claim {
604           u_int32_t msgflags;
605           u_int32_t msgfunc;
606           u_int32_t msgictx;
607           u_int32_t msgtctx;
608           u_int32_t flags;
609 } __packed;
610 
611 #define   I2O_UTIL_CLAIM_RESET_SENSITIVE                    0x00000002
612 #define   I2O_UTIL_CLAIM_STATE_SENSITIVE                    0x00000004
613 #define   I2O_UTIL_CLAIM_CAPACITY_SENSITIVE       0x00000008
614 #define   I2O_UTIL_CLAIM_NO_PEER_SERVICE                    0x00000010
615 #define   I2O_UTIL_CLAIM_NO_MANAGEMENT_SERVICE    0x00000020
616 
617 #define   I2O_UTIL_CLAIM_PRIMARY_USER             0x01000000
618 #define   I2O_UTIL_CLAIM_AUTHORIZED_USER                    0x02000000
619 #define   I2O_UTIL_CLAIM_SECONDARY_USER           0x03000000
620 #define   I2O_UTIL_CLAIM_MANAGEMENT_USER                    0x04000000
621 
622 #define   I2O_UTIL_CLAIM_RELEASE                  0x0b
623 struct i2o_util_claim_release {
624           u_int32_t msgflags;
625           u_int32_t msgfunc;
626           u_int32_t msgictx;
627           u_int32_t msgtctx;
628           u_int32_t flags;              /* User flags as per I2O_UTIL_CLAIM */
629 } __packed;
630 
631 #define   I2O_UTIL_CLAIM_RELEASE_CONDITIONAL      0x00000001
632 
633 #define   I2O_UTIL_CONFIG_DIALOG                  0x10
634 struct i2o_util_config_dialog {
635           u_int32_t msgflags;
636           u_int32_t msgfunc;
637           u_int32_t msgictx;
638           u_int32_t msgtctx;
639           u_int32_t pageno;
640 } __packed;
641 
642 #define   I2O_UTIL_EVENT_REGISTER                 0x13
643 struct i2o_util_event_register {
644           u_int32_t msgflags;
645           u_int32_t msgfunc;
646           u_int32_t msgictx;
647           u_int32_t msgtctx;
648           u_int32_t eventmask;
649 } __packed;
650 
651 struct i2o_util_event_register_reply {
652           u_int32_t msgflags;
653           u_int32_t msgfunc;
654           u_int32_t msgictx;
655           u_int32_t msgtctx;
656           u_int32_t event;
657           u_int32_t eventdata[1];
658 } __packed;
659 
660 /* Generic events. */
661 #define   I2O_EVENT_GEN_DEVICE_STATE              0x00400000
662 #define   I2O_EVENT_GEN_VENDOR_EVENT              0x00800000
663 #define   I2O_EVENT_GEN_FIELD_MODIFIED            0x01000000
664 #define   I2O_EVENT_GEN_EVENT_MASK_MODIFIED       0x02000000
665 #define   I2O_EVENT_GEN_DEVICE_RESET              0x04000000
666 #define   I2O_EVENT_GEN_CAPABILITY_CHANGE                   0x08000000
667 #define   I2O_EVENT_GEN_LOCK_RELEASE              0x10000000
668 #define   I2O_EVENT_GEN_NEED_CONFIGURATION        0x20000000
669 #define   I2O_EVENT_GEN_GENERAL_WARNING           0x40000000
670 #define   I2O_EVENT_GEN_STATE_CHANGE              0x80000000
671 
672 /* Executive class events. */
673 #define   I2O_EVENT_EXEC_RESOURCE_LIMITS                    0x00000001
674 #define   I2O_EVENT_EXEC_CONNECTION_FAIL                    0x00000002
675 #define   I2O_EVENT_EXEC_ADAPTER_FAULT            0x00000004
676 #define   I2O_EVENT_EXEC_POWER_FAIL               0x00000008
677 #define   I2O_EVENT_EXEC_RESET_PENDING            0x00000010
678 #define   I2O_EVENT_EXEC_RESET_IMMINENT           0x00000020
679 #define   I2O_EVENT_EXEC_HARDWARE_FAIL            0x00000040
680 #define   I2O_EVENT_EXEC_XCT_CHANGE               0x00000080
681 #define   I2O_EVENT_EXEC_NEW_LCT_ENTRY            0x00000100
682 #define   I2O_EVENT_EXEC_MODIFIED_LCT             0x00000200
683 #define   I2O_EVENT_EXEC_DDM_AVAILIBILITY                   0x00000400
684 
685 /*
686  * ================= Utility parameter groups =================
687  */
688 
689 #define   I2O_PARAM_DEVICE_IDENTITY     0xf100
690 struct i2o_param_device_identity {
691           u_int32_t classid;
692           u_int16_t ownertid;
693           u_int16_t parenttid;
694           u_int8_t  vendorinfo[16];
695           u_int8_t  productinfo[16];
696           u_int8_t  description[16];
697           u_int8_t  revlevel[8];
698           u_int8_t  snformat;
699           u_int8_t  serialnumber[1];
700 } __packed;
701 
702 #define   I2O_PARAM_DDM_IDENTITY                  0xf101
703 struct i2o_param_ddm_identity {
704           u_int16_t ddmtid;
705           u_int8_t  name[24];
706           u_int8_t  revlevel[8];
707           u_int8_t  snformat;
708           u_int8_t  serialnumber[12];
709 } __packed;
710 
711 /*
712  * ================= Block storage class messages =================
713  */
714 
715 #define   I2O_RBS_BLOCK_READ            0x30
716 struct i2o_rbs_block_read {
717           u_int32_t msgflags;
718           u_int32_t msgfunc;
719           u_int32_t msgictx;
720           u_int32_t msgtctx;
721           u_int32_t flags;              /* flags, time multiplier, read ahead */
722           u_int32_t datasize;
723           u_int32_t lowoffset;
724           u_int32_t highoffset;
725 } __packed;
726 
727 #define   I2O_RBS_BLOCK_READ_NO_RETRY   0x01
728 #define   I2O_RBS_BLOCK_READ_SOLO                 0x02
729 #define   I2O_RBS_BLOCK_READ_CACHE_READ 0x04
730 #define   I2O_RBS_BLOCK_READ_PREFETCH   0x08
731 #define   I2O_RBS_BLOCK_READ_CACHE_ONLY 0x10
732 
733 #define   I2O_RBS_BLOCK_WRITE             0x31
734 struct i2o_rbs_block_write {
735           u_int32_t msgflags;
736           u_int32_t msgfunc;
737           u_int32_t msgictx;
738           u_int32_t msgtctx;
739           u_int32_t flags;              /* flags, time multiplier */
740           u_int32_t datasize;
741           u_int32_t lowoffset;
742           u_int32_t highoffset;
743 } __packed;
744 
745 #define   I2O_RBS_BLOCK_WRITE_NO_RETRY  0x01
746 #define   I2O_RBS_BLOCK_WRITE_SOLO      0x02
747 #define   I2O_RBS_BLOCK_WRITE_CACHE_NONE          0x04
748 #define   I2O_RBS_BLOCK_WRITE_CACHE_WT  0x08
749 #define   I2O_RBS_BLOCK_WRITE_CACHE_WB  0x10
750 
751 #define   I2O_RBS_CACHE_FLUSH             0x37
752 struct i2o_rbs_cache_flush {
753           u_int32_t msgflags;
754           u_int32_t msgfunc;
755           u_int32_t msgictx;
756           u_int32_t msgtctx;
757           u_int32_t flags;              /* flags, time multiplier */
758 } __packed;
759 
760 #define   I2O_RBS_MEDIA_MOUNT           0x41
761 struct i2o_rbs_media_mount {
762           u_int32_t msgflags;
763           u_int32_t msgfunc;
764           u_int32_t msgictx;
765           u_int32_t msgtctx;
766           u_int32_t mediaid;
767           u_int32_t loadflags;
768 } __packed;
769 
770 #define   I2O_RBS_MEDIA_EJECT             0x43
771 struct i2o_rbs_media_eject {
772           u_int32_t msgflags;
773           u_int32_t msgfunc;
774           u_int32_t msgictx;
775           u_int32_t msgtctx;
776           u_int32_t mediaid;
777 } __packed;
778 
779 #define   I2O_RBS_MEDIA_LOCK            0x49
780 struct i2o_rbs_media_lock {
781           u_int32_t msgflags;
782           u_int32_t msgfunc;
783           u_int32_t msgictx;
784           u_int32_t msgtctx;
785           u_int32_t mediaid;
786 } __packed;
787 
788 #define   I2O_RBS_MEDIA_UNLOCK                    0x4b
789 struct i2o_rbs_media_unlock {
790           u_int32_t msgflags;
791           u_int32_t msgfunc;
792           u_int32_t msgictx;
793           u_int32_t msgtctx;
794           u_int32_t mediaid;
795 } __packed;
796 
797 /* Standard RBS reply frame. */
798 struct i2o_rbs_reply {
799           u_int32_t msgflags;
800           u_int32_t msgfunc;
801           u_int32_t msgictx;
802           u_int32_t msgtctx;
803           u_int16_t detail;
804           u_int8_t  retrycount;
805           u_int8_t  reqstatus;
806           u_int32_t transfercount;
807           u_int64_t offset;             /* Error replies only */
808 } __packed;
809 
810 /*
811  * ================= Block storage class parameter groups =================
812  */
813 
814 #define   I2O_PARAM_RBS_DEVICE_INFO     0x0000
815 struct i2o_param_rbs_device_info {
816           u_int8_t  type;
817           u_int8_t  npaths;
818           u_int16_t powerstate;
819           u_int32_t blocksize;
820           u_int64_t capacity;
821           u_int32_t capabilities;
822           u_int32_t state;
823 } __packed;
824 
825 #define   I2O_RBS_TYPE_DIRECT           0x00
826 #define   I2O_RBS_TYPE_WORM             0x04
827 #define   I2O_RBS_TYPE_CDROM            0x05
828 #define   I2O_RBS_TYPE_OPTICAL                    0x07
829 
830 #define   I2O_RBS_CAP_CACHING           0x00000001
831 #define   I2O_RBS_CAP_MULTI_PATH                  0x00000002
832 #define   I2O_RBS_CAP_DYNAMIC_CAPACITY  0x00000004
833 #define   I2O_RBS_CAP_REMOVABLE_MEDIA   0x00000008
834 #define   I2O_RBS_CAP_REMOVABLE_DEVICE  0x00000010
835 #define   I2O_RBS_CAP_READ_ONLY                   0x00000020
836 #define   I2O_RBS_CAP_LOCKOUT           0x00000040
837 #define   I2O_RBS_CAP_BOOT_BYPASS                 0x00000080
838 #define   I2O_RBS_CAP_COMPRESSION                 0x00000100
839 #define   I2O_RBS_CAP_DATA_SECURITY     0x00000200
840 #define   I2O_RBS_CAP_RAID              0x00000400
841 
842 #define   I2O_RBS_STATE_CACHING                   0x00000001
843 #define   I2O_RBS_STATE_POWERED_ON      0x00000002
844 #define   I2O_RBS_STATE_READY           0x00000004
845 #define   I2O_RBS_STATE_MEDIA_LOADED    0x00000008
846 #define   I2O_RBS_STATE_DEVICE_LOADED   0x00000010
847 #define   I2O_RBS_STATE_READ_ONLY                 0x00000020
848 #define   I2O_RBS_STATE_LOCKOUT                   0x00000040
849 #define   I2O_RBS_STATE_BOOT_BYPASS     0x00000080
850 #define   I2O_RBS_STATE_COMPRESSION     0x00000100
851 #define   I2O_RBS_STATE_DATA_SECURITY   0x00000200
852 #define   I2O_RBS_STATE_RAID            0x00000400
853 
854 #define   I2O_PARAM_RBS_OPERATION                 0x0001
855 struct i2o_param_rbs_operation {
856           u_int8_t  autoreass;
857           u_int8_t  reasstolerance;
858           u_int8_t  numretries;
859           u_int8_t  reserved0;
860           u_int32_t reasssize;
861           u_int32_t expectedtimeout;
862           u_int32_t rwvtimeout;
863           u_int32_t rwvtimeoutbase;
864           u_int32_t timeoutbase;
865           u_int32_t orderedreqdepth;
866           u_int32_t atomicwritesize;
867 } __packed;
868 
869 #define   I2O_PARAM_RBS_OPERATION_autoreass                 0
870 #define   I2O_PARAM_RBS_OPERATION_reasstolerance            1
871 #define   I2O_PARAM_RBS_OPERATION_numretries                2
872 #define   I2O_PARAM_RBS_OPERATION_reserved0                 3
873 #define   I2O_PARAM_RBS_OPERATION_reasssize                 4
874 #define   I2O_PARAM_RBS_OPERATION_expectedtimeout           5
875 #define   I2O_PARAM_RBS_OPERATION_rwvtimeout                6
876 #define   I2O_PARAM_RBS_OPERATION_rwvtimeoutbase            7
877 #define   I2O_PARAM_RBS_OPERATION_timeoutbase               8
878 #define   I2O_PARAM_RBS_OPERATION_orderedreqdepth           9
879 #define   I2O_PARAM_RBS_OPERATION_atomicwritesize           10
880 
881 #define   I2O_PARAM_RBS_CACHE_CONTROL   0x0003
882 struct i2o_param_rbs_cache_control {
883           u_int32_t totalcachesize;
884           u_int32_t readcachesize;
885           u_int32_t writecachesize;
886           u_int8_t  writepolicy;
887           u_int8_t  readpolicy;
888           u_int8_t  errorcorrection;
889           u_int8_t  reserved;
890 } __packed;
891 
892 /*
893  * ================= SCSI peripheral class messages =================
894  */
895 
896 #define   I2O_SCSI_DEVICE_RESET                   0x27
897 struct i2o_scsi_device_reset {
898           u_int32_t msgflags;
899           u_int32_t msgfunc;
900           u_int32_t msgictx;
901           u_int32_t msgtctx;
902 } __packed;
903 
904 #define   I2O_SCSI_SCB_EXEC             0x81
905 struct i2o_scsi_scb_exec {
906           u_int32_t msgflags;
907           u_int32_t msgfunc;
908           u_int32_t msgictx;
909           u_int32_t msgtctx;
910           u_int32_t flags;              /* CDB length and flags */
911           u_int8_t  cdb[16];
912           u_int32_t datalen;
913 } __packed;
914 
915 #define   I2O_SCB_FLAG_SENSE_DATA_IN_MESSAGE  0x00200000
916 #define   I2O_SCB_FLAG_SENSE_DATA_IN_BUFFER   0x00600000
917 #define   I2O_SCB_FLAG_SIMPLE_QUEUE_TAG       0x00800000
918 #define   I2O_SCB_FLAG_HEAD_QUEUE_TAG         0x01000000
919 #define   I2O_SCB_FLAG_ORDERED_QUEUE_TAG      0x01800000
920 #define   I2O_SCB_FLAG_ACA_QUEUE_TAG          0x02000000
921 #define   I2O_SCB_FLAG_ENABLE_DISCONNECT      0x20000000
922 #define   I2O_SCB_FLAG_XFER_FROM_DEVICE       0x40000000
923 #define   I2O_SCB_FLAG_XFER_TO_DEVICE         0x80000000
924 
925 #define   I2O_SCSI_SCB_ABORT            0x83
926 struct i2o_scsi_scb_abort {
927           u_int32_t msgflags;
928           u_int32_t msgfunc;
929           u_int32_t msgictx;
930           u_int32_t msgtctx;
931           u_int32_t tctxabort;
932 } __packed;
933 
934 struct i2o_scsi_reply {
935           u_int32_t msgflags;
936           u_int32_t msgfunc;
937           u_int32_t msgictx;
938           u_int32_t msgtctx;
939           u_int8_t  scsistatus;
940           u_int8_t  hbastatus;
941           u_int8_t  reserved;
942           u_int8_t  reqstatus;
943           u_int32_t datalen;
944           u_int32_t senselen;
945           u_int8_t  sense[40];
946 } __packed;
947 
948 #define   I2O_SCSI_DSC_SUCCESS                0x00
949 #define   I2O_SCSI_DSC_REQUEST_ABORTED        0x02
950 #define   I2O_SCSI_DSC_UNABLE_TO_ABORT        0x03
951 #define   I2O_SCSI_DSC_COMPLETE_WITH_ERROR    0x04
952 #define   I2O_SCSI_DSC_ADAPTER_BUSY           0x05
953 #define   I2O_SCSI_DSC_REQUEST_INVALID        0x06
954 #define   I2O_SCSI_DSC_PATH_INVALID           0x07
955 #define   I2O_SCSI_DSC_DEVICE_NOT_PRESENT     0x08
956 #define   I2O_SCSI_DSC_UNABLE_TO_TERMINATE    0x09
957 #define   I2O_SCSI_DSC_SELECTION_TIMEOUT      0x0a
958 #define   I2O_SCSI_DSC_COMMAND_TIMEOUT        0x0b
959 #define   I2O_SCSI_DSC_MR_MESSAGE_RECEIVED    0x0d
960 #define   I2O_SCSI_DSC_SCSI_BUS_RESET         0x0e
961 #define   I2O_SCSI_DSC_PARITY_ERROR_FAILURE   0x0f
962 #define   I2O_SCSI_DSC_AUTOSENSE_FAILED       0x10
963 #define   I2O_SCSI_DSC_NO_ADAPTER             0x11
964 #define   I2O_SCSI_DSC_DATA_OVERRUN           0x12
965 #define   I2O_SCSI_DSC_UNEXPECTED_BUS_FREE    0x13
966 #define   I2O_SCSI_DSC_SEQUENCE_FAILURE       0x14
967 #define   I2O_SCSI_DSC_REQUEST_LENGTH_ERROR   0x15
968 #define   I2O_SCSI_DSC_PROVIDE_FAILURE        0x16
969 #define   I2O_SCSI_DSC_BDR_MESSAGE_SENT       0x17
970 #define   I2O_SCSI_DSC_REQUEST_TERMINATED     0x18
971 #define   I2O_SCSI_DSC_IDE_MESSAGE_SENT       0x33
972 #define   I2O_SCSI_DSC_RESOURCE_UNAVAILABLE   0x34
973 #define   I2O_SCSI_DSC_UNACKNOWLEDGED_EVENT   0x35
974 #define   I2O_SCSI_DSC_MESSAGE_RECEIVED       0x36
975 #define   I2O_SCSI_DSC_INVALID_CDB            0x37
976 #define   I2O_SCSI_DSC_LUN_INVALID            0x38
977 #define   I2O_SCSI_DSC_SCSI_TID_INVALID       0x39
978 #define   I2O_SCSI_DSC_FUNCTION_UNAVAILABLE   0x3a
979 #define   I2O_SCSI_DSC_NO_NEXUS               0x3b
980 #define   I2O_SCSI_DSC_SCSI_IID_INVALID       0x3c
981 #define   I2O_SCSI_DSC_CDB_RECEIVED           0x3d
982 #define   I2O_SCSI_DSC_LUN_ALREADY_ENABLED    0x3e
983 #define   I2O_SCSI_DSC_BUS_BUSY               0x3f
984 #define   I2O_SCSI_DSC_QUEUE_FROZEN           0x40
985 
986 /*
987  * ================= SCSI peripheral class parameter groups =================
988  */
989 
990 #define   I2O_PARAM_SCSI_DEVICE_INFO    0x0000
991 struct i2o_param_scsi_device_info {
992           u_int8_t  devicetype;
993           u_int8_t  flags;
994           u_int16_t reserved0;
995           u_int32_t identifier;
996           u_int8_t  luninfo[8];
997           u_int32_t queuedepth;
998           u_int8_t  reserved1;
999           u_int8_t  negoffset;
1000           u_int8_t  negdatawidth;
1001           u_int8_t  reserved2;
1002           u_int64_t negsyncrate;
1003 } __packed;
1004 
1005 #endif    /* !defined _I2O_I2O_H_ */
1006