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 #include <sys/ioccom.h>
30 /*File - OSD_UNIX.H */
31 /*****************************************************************************/
35 /* This file contains definitions for the UNIX OS dependent layer of the */
38 /*Copyright Distributed Processing Technology, Corp. */
40 /* Maitland, Fl. 32751 USA */
41 /* Phone: (407) 830-5522 Fax: (407) 260-5366 */
42 /* All Rights Reserved */
44 /*Author: Bob Pasteur */
48 /* 3/7/96 salyzyn@dpt.com */
49 /* Added BSDi extensions */
50 /* 30/9/99 salyzyn@dpt.com */
51 /* Added I2ORESCANCMD */
52 /* 7/12/99 salyzyn@dpt.com */
53 /* Added I2ORESETCMD */
58 /*****************************************************************************/
60 /* Definitions - Defines & Constants ---------------------------------------*/
62 #define DPT_TurnAroundKey 0x01 /* TurnAround Message Type for engine */
63 #define DPT_EngineKey 0x02 /* Message Que and Type for engine */
64 #define DPT_LoggerKey 0x03 /* Message Type For Logger */
65 #define DPT_CommEngineKey 0x04 /* Message Que Type Created */
67 #define MSG_RECEIVE 0x40000000 /* Ored Into Logger PID For Return Msg */
69 #define ENGMSG_ECHO 0x00 /* Turnarround Echo Engine Message */
70 #define ENGMSG_OPEN 0x01 /* Turnarround Open Engine Message */
71 #define ENGMSG_CLOSE 0x02 /* Turnarround Close Engine Message */
73 /* Message Que Creation Flags */
81 #define MSG_ALLRD 00444
82 #define MSG_ALLWR 00222
84 /* Message Que Creation Flags */
92 #define SHM_ALLRD 00444
93 #define SHM_ALLWR 00222
95 /* Program Exit Codes */
97 #define ExitGoodStatus 0
98 #define ExitBadParameter 1
99 #define ExitSignalFail 3
100 #define ExitMsqAllocFail 5
101 #define ExitBuffAllocFail 6
102 #define ExitMsgSendFail 8
103 #define ExitMsgReceiveFail 9
105 #define ExitEngOpenFail 10
106 #define ExitDuplicateEngine 11
108 #define ExitCommAllocFail 12
109 #define ExitDuplicateCommEng 13
110 #define ExitCommConnectFail 14
117 #endif /* ifndef MAX_HAS */
121 uCHAR ConfigLength
[4]; /* Len in bytes after this field. */
122 uCHAR EATAsignature
[4];
127 uCHAR CPlength
[4]; /* Command Packet Length */
128 uCHAR SPlength
[4]; /* Status Packet Length */
129 uCHAR QueueSize
[2]; /* Controller Que depth */
132 uCHAR Reserved0
; /* Reserved Field */
135 uCHAR MaxLUN
; /* Maximun LUN Supported */
137 uCHAR RaidNum
; /* RAID HBA Number For Stripping */
138 uCHAR Reserved3
; /* Reserved Field */
141 #if defined ( _DPT_SOLARIS )
143 #include <sys/types.h>
144 #include <sys/ddidmareq.h>
145 #include <sys/mutex.h>
146 #include <sys/scsi/scsi.h>
148 #include <sys/dditypes.h>
149 #include <sys/ddi_impldefs.h>
150 #include <sys/scsi/impl/transport.h>
153 #undef MSG_DISCONNECT
154 #define MSG_DISCONNECT 0x11L
157 #define DPT_SIGNATURE 2
158 #define DPT_NUMCTRLS 3
159 #define DPT_CTRLINFO 4
160 #define DPT_SYSINFO 5
161 #define DPT_BLINKLED 6
163 //#define I2ORESCANCMD 8 /* Use DPT_IO_ACCESS instead */
164 //#define I2ORESETCMD 9 /* Use DPT_IO_ACCESS instead */
166 #define DPT_MAX_DMA_SEGS 32 /* Max used Scatter/Gather seg */
178 #elif defined(_DPT_DGUX)
181 # define _IOWR(x,y,z) (0x0fff3900|y)
184 # define _IOW(x,y,z) (0x0fff3900|y)
187 # define _IOR(x,y,z) (0x0fff3900|y)
190 # define _IO(x,y) (0x0fff3900|y)
192 /* EATA PassThrough Command */
193 #define EATAUSRCMD _IOWR('D',65,EATA_CP)
194 /* Get Signature Structure */
195 #define DPT_SIGNATURE _IOR('D',67,dpt_sig_S)
196 /* Get Number Of DPT Adapters */
197 #define DPT_NUMCTRLS _IOR('D',68,int)
198 /* Get Adapter Info Structure */
199 #define DPT_CTRLINFO _IOR('D',69,CtrlInfo)
200 /* Get System Info Structure */
201 #define DPT_SYSINFO _IOR('D',72,sysInfo_S)
202 /* Get Blink LED Code */
203 #define DPT_BLINKLED _IOR('D',75,int)
204 /* Get Statistical information (if available) */
205 #define DPT_STATS_INFO _IOR('D',80,STATS_DATA)
206 /* Clear the statistical information */
207 #define DPT_STATS_CLEAR _IO('D',81)
208 /* Send an I2O command */
209 #define I2OUSRCMD _IO('D',76)
210 /* Inform driver to re-acquire LCT information */
211 #define I2ORESCANCMD _IO('D',77)
212 /* Inform driver to reset adapter */
213 #define I2ORESETCMD _IO('D',78)
215 #elif defined (SNI_MIPS)
216 /* Unix Ioctl Command definitions */
218 #define EATAUSRCMD (('D'<<8)|65)
219 #define DPT_DEBUG (('D'<<8)|66)
220 #define DPT_SIGNATURE (('D'<<8)|67)
221 #define DPT_NUMCTRLS (('D'<<8)|68)
222 #define DPT_CTRLINFO (('D'<<8)|69)
223 #define DPT_STATINFO (('D'<<8)|70)
224 #define DPT_CLRSTAT (('D'<<8)|71)
225 #define DPT_SYSINFO (('D'<<8)|72)
226 /* Set Timeout Value */
227 #define DPT_TIMEOUT (('D'<<8)|73)
228 /* Get config Data */
229 #define DPT_CONFIG (('D'<<8)|74)
230 /* Get config Data */
231 #define DPT_BLINKLED (('D'<<8)|75)
232 /* Get Statistical information (if available) */
233 #define DPT_STATS_INFO (('D'<<8)|80)
234 /* Clear the statistical information */
235 #define DPT_STATS_CLEAR (('D'<<8)|81)
236 /* Send an I2O command */
237 #define I2OUSRCMD (('D'<<8)|76)
238 /* Inform driver to re-acquire LCT information */
239 #define I2ORESCANCMD (('D'<<8)|77)
240 /* Inform driver to reset adapter */
241 #define I2ORESETCMD (('D'<<8)|78)
245 /* Unix Ioctl Command definitions */
256 # define _IOWR(x,y,z) (((x)<<8)|y)
259 # define _IOW(x,y,z) (((x)<<8)|y)
262 # define _IOR(x,y,z) (((x)<<8)|y)
265 # define _IO(x,y) (((x)<<8)|y)
267 /* EATA PassThrough Command */
268 #define EATAUSRCMD _IOWR('D',65,EATA_CP)
269 /* Set Debug Level If Enabled */
270 #define DPT_DEBUG _IOW('D',66,int)
271 /* Get Signature Structure */
272 #define DPT_SIGNATURE _IOR('D',67,dpt_sig_S)
274 #define DPT_SIGNATURE_PACKED _IOR('D',67,dpt_sig_S_Packed)
276 /* Get Number Of DPT Adapters */
277 #define DPT_NUMCTRLS _IOR('D',68,int)
278 /* Get Adapter Info Structure */
279 #define DPT_CTRLINFO _IOR('D',69,CtrlInfo)
280 /* Get Statistics If Enabled */
281 #define DPT_STATINFO _IO('D',70)
282 /* Clear Stats If Enabled */
283 #define DPT_CLRSTAT _IO('D',71)
284 /* Get System Info Structure */
285 #define DPT_SYSINFO _IOR('D',72,sysInfo_S)
286 /* Set Timeout Value */
287 #define DPT_TIMEOUT _IO('D',73)
288 /* Get config Data */
289 #define DPT_CONFIG _IO('D',74)
290 /* Get Blink LED Code */
291 #define DPT_BLINKLED _IOR('D',75,int)
292 /* Get Statistical information (if available) */
293 #define DPT_STATS_INFO _IOR('D',80,STATS_DATA)
294 /* Clear the statistical information */
295 #define DPT_STATS_CLEAR _IO('D',81)
296 /* Get Performance metrics */
297 #define DPT_PERF_INFO _IOR('D',82,dpt_perf_t)
298 /* Send an I2O command */
299 #define I2OUSRCMD _IO('D',76)
300 /* Inform driver to re-acquire LCT information */
301 #define I2ORESCANCMD _IO('D',77)
302 /* Inform driver to reset adapter */
303 #define I2ORESETCMD _IO('D',78)
304 #if defined _DPT_LINUX
305 /* See if the target is mounted */
306 #define DPT_TARGET_BUSY _IOR('D',79, TARGET_BUSY_T)
310 #endif /* _DPT_SOLARIS else */
312 /* Adapter Flags Field Bit Definitions */
314 #define CTLR_INSTALLED 0x00000001 /* Adapter Was Installed */
315 #define CTLR_DMA 0x00000002 /* DMA Supported */
316 #define CTLR_OVERLAP 0x00000004 /* Overlapped Commands Support */
317 #define CTLR_SECONDARY 0x00000008 /* I/O Address Not 0x1f0 */
318 #define CTLR_BLINKLED 0x00000010 /* Adapter In Blink LED State */
319 #define CTLR_HBACI 0x00000020 /* Cache Inhibit Supported */
320 #define CTLR_CACHE 0x00000040 /* Adapter Has Cache */
321 #define CTLR_SANE 0x00000080 /* Adapter Functioning OK */
322 #define CTLR_BUS_QUIET 0x00000100 /* Bus Quite On This Adapter */
323 #define CTLR_ABOVE_16 0x00000200 /* Support For Mem. Above 16 MB */
324 #define CTLR_SCAT_GATH 0x00000400 /* Scatter Gather Supported */
327 /* Definitions - Structure & Typedef ---------------------------------------*/
335 uLONG FromEngBuffOffset
;
341 #define MsgDataSize sizeof(MsgHdr) - 4
345 /*-------------------------------------------------------------------------*/
346 /* EATA Command Packet definition */
347 /*-------------------------------------------------------------------------*/
349 typedef struct EATACommandPacket
{
357 #endif /* _DPT_UNIXWARE */
364 #endif /* _DPT_AIX */
366 uCHAR cp_Flags1
; /* Command Flags */
367 uCHAR cp_Req_Len
; /* AutoRequestSense Data length. */
368 uCHAR cp_Resv1
[3]; /* Reserved Fields */
372 uCHAR cp_msg0
; /* Identify and Disconnect Message. */
376 uCHAR cp_cdb
[12]; /* SCSI cdb for command. */
377 uLONG cp_dataLen
; /* Data length in Bytes for command. */
378 uLONG cp_Vue
; /* Vendor Unique Area */
379 uCHAR
*cp_DataAddr
; /* Data Address For The Command. */
380 uCHAR
*cp_SpAddr
; /* Status Packet Physical Address. */
381 uCHAR
*cp_SenseAddr
; /* AutoRequestSense Data Phy Address. */
389 struct scsi_arq_status ReqSenseData
;
390 struct dpt_sg SG_List
[DPT_MAX_DMA_SEGS
];
393 struct scsi_cmd
*b_ownerp
;
398 #else /* _DPT_SOLARIS */
405 #endif /* _DPT_SOLARIS else */
408 #endif /* SNI_MIPS */
411 /* Control Flags 1 Definitions */
413 #define SCSI_RESET 0x01 /* Cause a SCSI Bus reset on the cmd */
414 #define HBA_INIT 0x02 /* Cause Controller to reInitialize */
415 #define AUTO_REQ_SENSE 0x04 /* Do Auto Request Sense on errors */
416 #define SCATTER_GATHER 0x08 /* Data Ptr points to a SG Packet */
417 #define INTERPRET 0x20 /* Interpret the SCSI cdb of own use */
418 #define DATA_OUT 0x04 /* Data Out phase with command */
419 #define DATA_IN 0x08 /* Data In phase with command */
421 /* Control Flags 2 Definitions */
423 #define FIRMWARE_NESTED 0x01
426 /* Control Flags 3 Definitions */
428 #define PHYSICAL_UNIT 0x01 /* Send Command Directly To Target */
429 #define IAT 0x02 /* Inhibit Address Translation */
430 #define HBACI 0x04 /* Inhibit Caching */
433 /* Structure Returned From Get Controller Info */
437 uCHAR state
; /* Operational state */
438 uCHAR id
; /* Host adapter SCSI id */
439 int vect
; /* Interrupt vector number */
440 int base
; /* Base I/O address */
441 int njobs
; /* # of jobs sent to HA */
442 int qdepth
; /* Controller queue depth. */
443 int wakebase
; /* mpx wakeup base index. */
444 uLONG SGsize
; /* Scatter/Gather list size. */
445 unsigned heads
; /* heads for drives on cntlr. */
446 unsigned sectors
; /* sectors for drives on cntlr. */
447 uCHAR do_drive32
; /* Flag for Above 16 MB Ability */
448 uCHAR BusQuiet
; /* SCSI Bus Quiet Flag */
449 char idPAL
[4]; /* 4 Bytes Of The ID Pal */
450 uCHAR primary
; /* 1 For Primary, 0 For Secondary */
451 uCHAR eataVersion
; /* EATA Version */
452 uLONG cpLength
; /* EATA Command Packet Length */
453 uLONG spLength
; /* EATA Status Packet Length */
454 uCHAR drqNum
; /* DRQ Index (0,5,6,7) */
455 uCHAR flag1
; /* EATA Flags 1 (Byte 9) */
456 uCHAR flag2
; /* EATA Flags 2 (Byte 30) */
465 uINT state
; /* Operational state */
466 uCHAR id
[4]; /* Host adapter SCSI id */
467 uINT vect
; /* Interrupt vector number */
468 uLONG base
; /* Base I/O address */
469 int ha_max_jobs
; /* Max number of Active Jobs */
470 uLONG ha_cacheParams
;
471 int ha_nbus
; /* Number Of Busses on HBA */
472 int ha_ntargets
; /* Number Of Targets Supported */
473 int ha_nluns
; /* Number Of LUNs Supported */
474 int ha_tshift
; /* Shift value for target */
475 int ha_bshift
; /* Shift value for bus */
476 uINT ha_npend
; /* # of jobs sent to HA */
477 int ha_active_jobs
; /* Number Of Active Jobs */
481 /* SDI ioctl prefix for hba specific ioctl's */
483 #define SDI_IOC (('S'<<24)|('D'<<16)|('I'<<8))
485 #define SDI_HBANAME ((SDI_IOC)|0x14) /* Get HBA module name */
486 #define SDI_SEND 0x0081 /* Send a SCSI command */
492 uLONG flags
; /* Operational State Flags */
493 uCHAR id
[4]; /* Host Adapter SCSI ID */
494 int vect
; /* Interrupt Vector Number */
495 int base
; /* Base I/O Address */
496 int njobs
; /* # Of CCBs Outstanding To HBA */
497 int qdepth
; /* Controller Queue depth. */
498 uLONG SGsize
; /* Scatter/Gather List Size. */
499 char idPAL
[4]; /* 4 Bytes Of The ID Pal */
500 uCHAR eataVersion
; /* EATA Version */
501 uLONG cpLength
; /* EATA Command Packet Length */
502 uLONG spLength
; /* EATA Status Packet Length */
503 uCHAR drqNum
; /* DRQ Index (0,5,6,7) */
504 uCHAR eataflag1
; /* EATA Flags 1 (Byte 9) */
505 uCHAR eataflag2
; /* EATA Flags 2 (Byte 30) */
506 uCHAR maxChannel
; /* Maximum Channel Number */
507 uCHAR maxID
; /* Maximum Target ID */
508 uCHAR maxLUN
; /* Maximum LUN */
509 uCHAR HbaBusType
; /* HBA Bus Type, EISA, PCI, etc */
510 uCHAR RaidNum
; /* Host Adapter RAID Number */
514 #endif /* _DPT_UNIXWARE */
515 #endif /* SNI_MIPS */
521 * DPT Host Adapter config information structure - this structure contains
522 * configuration information about an adapter. It is imbedded into the
526 typedef struct dpt_cfg
{
527 uchar flags
; /* Operational state flags */
528 uchar id
[4]; /* Host adapter SCSI IDs */
529 int vect
; /* Interrupt vector number */
530 ulong base_addr
; /* Base I/O address */
531 int qdepth
; /* Controller queue depth. */
532 ulong SGsize
; /* Max scatter/gather list sz */
533 ulong SGmax
; /* Max s/g we can use per req */
534 uchar eataVersion
; /* EATA version */
535 ushort cpPadLen
; /* # of pad bytes sent to HA for
537 ulong cpLength
; /* EATA Command Packet length */
538 ulong spLength
; /* EATA Status Packet length */
539 uchar eataflag1
; /* EATA Flags 1 (Byte 9) */
540 uchar eataflag2
; /* EATA Flags 2 (Byte 30) */
541 uchar maxChan
; /* Maximum Channel number */
542 uchar maxID
; /* Maximum target ID */
543 uchar maxLUN
; /* Maximum LUN */
544 uchar HbaBusType
; /* HBA bus type, EISA, PCI, etc */
545 uchar RaidNum
; /* Host adapter RAID number */
548 #endif /* _DPT_AIX */
551 #define MAX_ELEMENT_COUNT 64
552 #define MAX_BUCKET_COUNT 10
555 * DPT statistics structure definitions
557 typedef struct IO_SIZE_STATS
563 uLONG IoCountWriteSg
;
564 uLONG UnalignedIoAddress
;
565 uLONG SgElementCount
[MAX_ELEMENT_COUNT
];
567 } IO_SIZE_STATS_T
, *pIO_SIZE_STATS_T
;
569 typedef struct STATS_DATA
572 uLONG TotalUnCachedIoCount
;
573 uLONG MaxOutstandingIoCount
;
574 uLONG CurrentOutstandingIoCount
;
575 uLONG OutstandingIoRunningCount
;
576 uLONG UnalignedPktCount
;
577 uLONG UnalignedSgCount
;
578 uLONG NonPageListAddressSgCount
;
579 uLONG MaxMessagesPerInterrupt
;
580 IO_SIZE_STATS_T IoSize
[MAX_BUCKET_COUNT
];
582 } STATS_DATA_T
, *pSTATS_DATA_T
;
584 typedef struct TARGET_BUSY
591 #endif /* __OSD_UNIX_H */