1 /* $FreeBSD: src/sys/dev/asr/osd_unix.h,v 1.1.2.2 2001/08/23 05:21:29 scottl Exp $ */
2 /* $DragonFly: src/sys/dev/raid/asr/osd_unix.h,v 1.3 2004/07/02 15:53:01 joerg Exp $ */
4 * Copyright (c) 1996-1999 Distributed Processing Technology Corporation
7 * Redistribution and use in source form, with or without modification, are
8 * permitted provided that redistributions of source code must retain the
9 * above copyright notice, this list of conditions and the following disclaimer.
11 * This software is provided `as is' by Distributed Processing Technology and
12 * any express or implied warranties, including, but not limited to, the
13 * implied warranties of merchantability and fitness for a particular purpose,
14 * are disclaimed. In no event shall Distributed Processing Technology be
15 * liable for any direct, indirect, incidental, special, exemplary or
16 * consequential damages (including, but not limited to, procurement of
17 * substitute goods or services; loss of use, data, or profits; or business
18 * interruptions) however caused and on any theory of liability, whether in
19 * contract, strict liability, or tort (including negligence or otherwise)
20 * arising in any way out of the use of this driver software, even if advised
21 * of the possibility of such damage.
28 /*File - OSD_UNIX.H */
29 /*****************************************************************************/
33 /* This file contains definitions for the UNIX OS dependent layer of the */
36 /*Copyright Distributed Processing Technology, Corp. */
38 /* Maitland, Fl. 32751 USA */
39 /* Phone: (407) 830-5522 Fax: (407) 260-5366 */
40 /* All Rights Reserved */
42 /*Author: Bob Pasteur */
46 /* 3/7/96 salyzyn@dpt.com */
47 /* Added BSDi extensions */
48 /* 30/9/99 salyzyn@dpt.com */
49 /* Added I2ORESCANCMD */
50 /* 7/12/99 salyzyn@dpt.com */
51 /* Added I2ORESETCMD */
56 /*****************************************************************************/
58 /* Definitions - Defines & Constants ---------------------------------------*/
60 #define DPT_TurnAroundKey 0x01 /* TurnAround Message Type for engine */
61 #define DPT_EngineKey 0x02 /* Message Que and Type for engine */
62 #define DPT_LoggerKey 0x03 /* Message Type For Logger */
63 #define DPT_CommEngineKey 0x04 /* Message Que Type Created */
65 #define MSG_RECEIVE 0x40000000 /* Ored Into Logger PID For Return Msg */
67 #define ENGMSG_ECHO 0x00 /* Turnarround Echo Engine Message */
68 #define ENGMSG_OPEN 0x01 /* Turnarround Open Engine Message */
69 #define ENGMSG_CLOSE 0x02 /* Turnarround Close Engine Message */
71 /* Message Que Creation Flags */
79 #define MSG_ALLRD 00444
80 #define MSG_ALLWR 00222
82 /* Message Que Creation Flags */
90 #define SHM_ALLRD 00444
91 #define SHM_ALLWR 00222
93 /* Program Exit Codes */
95 #define ExitGoodStatus 0
96 #define ExitBadParameter 1
97 #define ExitSignalFail 3
98 #define ExitMsqAllocFail 5
99 #define ExitBuffAllocFail 6
100 #define ExitMsgSendFail 8
101 #define ExitMsgReceiveFail 9
103 #define ExitEngOpenFail 10
104 #define ExitDuplicateEngine 11
106 #define ExitCommAllocFail 12
107 #define ExitDuplicateCommEng 13
108 #define ExitCommConnectFail 14
115 #endif /* ifndef MAX_HAS */
119 uCHAR ConfigLength[4]; /* Len in bytes after this field. */
120 uCHAR EATAsignature[4];
125 uCHAR CPlength[4]; /* Command Packet Length */
126 uCHAR SPlength[4]; /* Status Packet Length */
127 uCHAR QueueSize[2]; /* Controller Que depth */
130 uCHAR Reserved0; /* Reserved Field */
133 uCHAR MaxLUN; /* Maximun LUN Supported */
135 uCHAR RaidNum; /* RAID HBA Number For Stripping */
136 uCHAR Reserved3; /* Reserved Field */
139 #if defined ( _DPT_SOLARIS )
141 #include <sys/types.h>
142 #include <sys/ddidmareq.h>
143 #include <sys/mutex.h>
144 #include <sys/scsi/scsi.h>
146 #include <sys/dditypes.h>
147 #include <sys/ddi_impldefs.h>
148 #include <sys/scsi/impl/transport.h>
151 #undef MSG_DISCONNECT
152 #define MSG_DISCONNECT 0x11L
155 #define DPT_SIGNATURE 2
156 #define DPT_NUMCTRLS 3
157 #define DPT_CTRLINFO 4
158 #define DPT_SYSINFO 5
159 #define DPT_BLINKLED 6
161 //#define I2ORESCANCMD 8 /* Use DPT_IO_ACCESS instead */
162 //#define I2ORESETCMD 9 /* Use DPT_IO_ACCESS instead */
164 #define DPT_MAX_DMA_SEGS 32 /* Max used Scatter/Gather seg */
176 #elif defined(_DPT_DGUX)
179 # define _IOWR(x,y,z) (0x0fff3900|y)
182 # define _IOW(x,y,z) (0x0fff3900|y)
185 # define _IOR(x,y,z) (0x0fff3900|y)
188 # define _IO(x,y) (0x0fff3900|y)
190 /* EATA PassThrough Command */
191 #define EATAUSRCMD _IOWR('D',65,EATA_CP)
192 /* Get Signature Structure */
193 #define DPT_SIGNATURE _IOR('D',67,dpt_sig_S)
194 /* Get Number Of DPT Adapters */
195 #define DPT_NUMCTRLS _IOR('D',68,int)
196 /* Get Adapter Info Structure */
197 #define DPT_CTRLINFO _IOR('D',69,CtrlInfo)
198 /* Get System Info Structure */
199 #define DPT_SYSINFO _IOR('D',72,sysInfo_S)
200 /* Get Blink LED Code */
201 #define DPT_BLINKLED _IOR('D',75,int)
202 /* Get Statistical information (if available) */
203 #define DPT_STATS_INFO _IOR('D',80,STATS_DATA)
204 /* Clear the statistical information */
205 #define DPT_STATS_CLEAR _IO('D',81)
206 /* Send an I2O command */
207 #define I2OUSRCMD _IO('D',76)
208 /* Inform driver to re-acquire LCT information */
209 #define I2ORESCANCMD _IO('D',77)
210 /* Inform driver to reset adapter */
211 #define I2ORESETCMD _IO('D',78)
213 #elif defined (SNI_MIPS)
214 /* Unix Ioctl Command definitions */
216 #define EATAUSRCMD (('D'<<8)|65)
217 #define DPT_DEBUG (('D'<<8)|66)
218 #define DPT_SIGNATURE (('D'<<8)|67)
219 #define DPT_NUMCTRLS (('D'<<8)|68)
220 #define DPT_CTRLINFO (('D'<<8)|69)
221 #define DPT_STATINFO (('D'<<8)|70)
222 #define DPT_CLRSTAT (('D'<<8)|71)
223 #define DPT_SYSINFO (('D'<<8)|72)
224 /* Set Timeout Value */
225 #define DPT_TIMEOUT (('D'<<8)|73)
226 /* Get config Data */
227 #define DPT_CONFIG (('D'<<8)|74)
228 /* Get config Data */
229 #define DPT_BLINKLED (('D'<<8)|75)
230 /* Get Statistical information (if available) */
231 #define DPT_STATS_INFO (('D'<<8)|80)
232 /* Clear the statistical information */
233 #define DPT_STATS_CLEAR (('D'<<8)|81)
234 /* Send an I2O command */
235 #define I2OUSRCMD (('D'<<8)|76)
236 /* Inform driver to re-acquire LCT information */
237 #define I2ORESCANCMD (('D'<<8)|77)
238 /* Inform driver to reset adapter */
239 #define I2ORESETCMD (('D'<<8)|78)
243 /* Unix Ioctl Command definitions */
254 # define _IOWR(x,y,z) (((x)<<8)|y)
257 # define _IOW(x,y,z) (((x)<<8)|y)
260 # define _IOR(x,y,z) (((x)<<8)|y)
263 # define _IO(x,y) (((x)<<8)|y)
265 /* EATA PassThrough Command */
266 #define EATAUSRCMD _IOWR('D',65,EATA_CP)
267 /* Set Debug Level If Enabled */
268 #define DPT_DEBUG _IOW('D',66,int)
269 /* Get Signature Structure */
270 #define DPT_SIGNATURE _IOR('D',67,dpt_sig_S)
272 #define DPT_SIGNATURE_PACKED _IOR('D',67,dpt_sig_S_Packed)
274 /* Get Number Of DPT Adapters */
275 #define DPT_NUMCTRLS _IOR('D',68,int)
276 /* Get Adapter Info Structure */
277 #define DPT_CTRLINFO _IOR('D',69,CtrlInfo)
278 /* Get Statistics If Enabled */
279 #define DPT_STATINFO _IO('D',70)
280 /* Clear Stats If Enabled */
281 #define DPT_CLRSTAT _IO('D',71)
282 /* Get System Info Structure */
283 #define DPT_SYSINFO _IOR('D',72,sysInfo_S)
284 /* Set Timeout Value */
285 #define DPT_TIMEOUT _IO('D',73)
286 /* Get config Data */
287 #define DPT_CONFIG _IO('D',74)
288 /* Get Blink LED Code */
289 #define DPT_BLINKLED _IOR('D',75,int)
290 /* Get Statistical information (if available) */
291 #define DPT_STATS_INFO _IOR('D',80,STATS_DATA)
292 /* Clear the statistical information */
293 #define DPT_STATS_CLEAR _IO('D',81)
294 /* Get Performance metrics */
295 #define DPT_PERF_INFO _IOR('D',82,dpt_perf_t)
296 /* Send an I2O command */
297 #define I2OUSRCMD _IO('D',76)
298 /* Inform driver to re-acquire LCT information */
299 #define I2ORESCANCMD _IO('D',77)
300 /* Inform driver to reset adapter */
301 #define I2ORESETCMD _IO('D',78)
302 #if defined _DPT_LINUX
303 /* See if the target is mounted */
304 #define DPT_TARGET_BUSY _IOR('D',79, TARGET_BUSY_T)
308 #endif /* _DPT_SOLARIS else */
310 /* Adapter Flags Field Bit Definitions */
312 #define CTLR_INSTALLED 0x00000001 /* Adapter Was Installed */
313 #define CTLR_DMA 0x00000002 /* DMA Supported */
314 #define CTLR_OVERLAP 0x00000004 /* Overlapped Commands Support */
315 #define CTLR_SECONDARY 0x00000008 /* I/O Address Not 0x1f0 */
316 #define CTLR_BLINKLED 0x00000010 /* Adapter In Blink LED State */
317 #define CTLR_HBACI 0x00000020 /* Cache Inhibit Supported */
318 #define CTLR_CACHE 0x00000040 /* Adapter Has Cache */
319 #define CTLR_SANE 0x00000080 /* Adapter Functioning OK */
320 #define CTLR_BUS_QUIET 0x00000100 /* Bus Quite On This Adapter */
321 #define CTLR_ABOVE_16 0x00000200 /* Support For Mem. Above 16 MB */
322 #define CTLR_SCAT_GATH 0x00000400 /* Scatter Gather Supported */
325 /* Definitions - Structure & Typedef ---------------------------------------*/
333 uLONG FromEngBuffOffset;
339 #define MsgDataSize sizeof(MsgHdr) - 4
343 /*-------------------------------------------------------------------------*/
344 /* EATA Command Packet definition */
345 /*-------------------------------------------------------------------------*/
347 typedef struct EATACommandPacket {
355 #endif /* _DPT_UNIXWARE */
362 #endif /* _DPT_AIX */
364 uCHAR cp_Flags1; /* Command Flags */
365 uCHAR cp_Req_Len; /* AutoRequestSense Data length. */
366 uCHAR cp_Resv1[3]; /* Reserved Fields */
370 uCHAR cp_msg0; /* Identify and Disconnect Message. */
374 uCHAR cp_cdb[12]; /* SCSI cdb for command. */
375 uLONG cp_dataLen; /* Data length in Bytes for command. */
376 uLONG cp_Vue; /* Vendor Unique Area */
377 uCHAR *cp_DataAddr; /* Data Address For The Command. */
378 uCHAR *cp_SpAddr; /* Status Packet Physical Address. */
379 uCHAR *cp_SenseAddr; /* AutoRequestSense Data Phy Address. */
387 struct scsi_arq_status ReqSenseData;
388 struct dpt_sg SG_List[DPT_MAX_DMA_SEGS];
391 struct scsi_cmd *b_ownerp;
396 #else /* _DPT_SOLARIS */
403 #endif /* _DPT_SOLARIS else */
406 #endif /* SNI_MIPS */
409 /* Control Flags 1 Definitions */
411 #define SCSI_RESET 0x01 /* Cause a SCSI Bus reset on the cmd */
412 #define HBA_INIT 0x02 /* Cause Controller to reInitialize */
413 #define AUTO_REQ_SENSE 0x04 /* Do Auto Request Sense on errors */
414 #define SCATTER_GATHER 0x08 /* Data Ptr points to a SG Packet */
415 #define INTERPRET 0x20 /* Interpret the SCSI cdb of own use */
416 #define DATA_OUT 0x04 /* Data Out phase with command */
417 #define DATA_IN 0x08 /* Data In phase with command */
419 /* Control Flags 2 Definitions */
421 #define FIRMWARE_NESTED 0x01
424 /* Control Flags 3 Definitions */
426 #define PHYSICAL_UNIT 0x01 /* Send Command Directly To Target */
427 #define IAT 0x02 /* Inhibit Address Translation */
428 #define HBACI 0x04 /* Inhibit Caching */
431 /* Structure Returned From Get Controller Info */
435 uCHAR state; /* Operational state */
436 uCHAR id; /* Host adapter SCSI id */
437 int vect; /* Interrupt vector number */
438 int base; /* Base I/O address */
439 int njobs; /* # of jobs sent to HA */
440 int qdepth; /* Controller queue depth. */
441 int wakebase; /* mpx wakeup base index. */
442 uLONG SGsize; /* Scatter/Gather list size. */
443 unsigned heads; /* heads for drives on cntlr. */
444 unsigned sectors; /* sectors for drives on cntlr. */
445 uCHAR do_drive32; /* Flag for Above 16 MB Ability */
446 uCHAR BusQuiet; /* SCSI Bus Quiet Flag */
447 char idPAL[4]; /* 4 Bytes Of The ID Pal */
448 uCHAR primary; /* 1 For Primary, 0 For Secondary */
449 uCHAR eataVersion; /* EATA Version */
450 uLONG cpLength; /* EATA Command Packet Length */
451 uLONG spLength; /* EATA Status Packet Length */
452 uCHAR drqNum; /* DRQ Index (0,5,6,7) */
453 uCHAR flag1; /* EATA Flags 1 (Byte 9) */
454 uCHAR flag2; /* EATA Flags 2 (Byte 30) */
463 uINT state; /* Operational state */
464 uCHAR id[4]; /* Host adapter SCSI id */
465 uINT vect; /* Interrupt vector number */
466 uLONG base; /* Base I/O address */
467 int ha_max_jobs; /* Max number of Active Jobs */
468 uLONG ha_cacheParams;
469 int ha_nbus; /* Number Of Busses on HBA */
470 int ha_ntargets; /* Number Of Targets Supported */
471 int ha_nluns; /* Number Of LUNs Supported */
472 int ha_tshift; /* Shift value for target */
473 int ha_bshift; /* Shift value for bus */
474 uINT ha_npend; /* # of jobs sent to HA */
475 int ha_active_jobs; /* Number Of Active Jobs */
479 /* SDI ioctl prefix for hba specific ioctl's */
481 #define SDI_IOC (('S'<<24)|('D'<<16)|('I'<<8))
483 #define SDI_HBANAME ((SDI_IOC)|0x14) /* Get HBA module name */
484 #define SDI_SEND 0x0081 /* Send a SCSI command */
490 uLONG flags; /* Operational State Flags */
491 uCHAR id[4]; /* Host Adapter SCSI ID */
492 int vect; /* Interrupt Vector Number */
493 int base; /* Base I/O Address */
494 int njobs; /* # Of CCBs Outstanding To HBA */
495 int qdepth; /* Controller Queue depth. */
496 uLONG SGsize; /* Scatter/Gather List Size. */
497 char idPAL[4]; /* 4 Bytes Of The ID Pal */
498 uCHAR eataVersion; /* EATA Version */
499 uLONG cpLength; /* EATA Command Packet Length */
500 uLONG spLength; /* EATA Status Packet Length */
501 uCHAR drqNum; /* DRQ Index (0,5,6,7) */
502 uCHAR eataflag1; /* EATA Flags 1 (Byte 9) */
503 uCHAR eataflag2; /* EATA Flags 2 (Byte 30) */
504 uCHAR maxChannel; /* Maximum Channel Number */
505 uCHAR maxID; /* Maximum Target ID */
506 uCHAR maxLUN; /* Maximum LUN */
507 uCHAR HbaBusType; /* HBA Bus Type, EISA, PCI, etc */
508 uCHAR RaidNum; /* Host Adapter RAID Number */
512 #endif /* _DPT_UNIXWARE */
513 #endif /* SNI_MIPS */
519 * DPT Host Adapter config information structure - this structure contains
520 * configuration information about an adapter. It is imbedded into the
524 typedef struct dpt_cfg {
525 uchar flags; /* Operational state flags */
526 uchar id[4]; /* Host adapter SCSI IDs */
527 int vect; /* Interrupt vector number */
528 ulong base_addr; /* Base I/O address */
529 int qdepth; /* Controller queue depth. */
530 ulong SGsize; /* Max scatter/gather list sz */
531 ulong SGmax; /* Max s/g we can use per req */
532 uchar eataVersion; /* EATA version */
533 ushort cpPadLen; /* # of pad bytes sent to HA for
535 ulong cpLength; /* EATA Command Packet length */
536 ulong spLength; /* EATA Status Packet length */
537 uchar eataflag1; /* EATA Flags 1 (Byte 9) */
538 uchar eataflag2; /* EATA Flags 2 (Byte 30) */
539 uchar maxChan; /* Maximum Channel number */
540 uchar maxID; /* Maximum target ID */
541 uchar maxLUN; /* Maximum LUN */
542 uchar HbaBusType; /* HBA bus type, EISA, PCI, etc */
543 uchar RaidNum; /* Host adapter RAID number */
546 #endif /* _DPT_AIX */
549 #define MAX_ELEMENT_COUNT 64
550 #define MAX_BUCKET_COUNT 10
553 * DPT statistics structure definitions
555 typedef struct IO_SIZE_STATS
561 uLONG IoCountWriteSg;
562 uLONG UnalignedIoAddress;
563 uLONG SgElementCount[MAX_ELEMENT_COUNT];
565 } IO_SIZE_STATS_T, *pIO_SIZE_STATS_T;
567 typedef struct STATS_DATA
570 uLONG TotalUnCachedIoCount;
571 uLONG MaxOutstandingIoCount;
572 uLONG CurrentOutstandingIoCount;
573 uLONG OutstandingIoRunningCount;
574 uLONG UnalignedPktCount;
575 uLONG UnalignedSgCount;
576 uLONG NonPageListAddressSgCount;
577 uLONG MaxMessagesPerInterrupt;
578 IO_SIZE_STATS_T IoSize[MAX_BUCKET_COUNT];
580 } STATS_DATA_T, *pSTATS_DATA_T;
582 typedef struct TARGET_BUSY
589 #endif /* __OSD_UNIX_H */