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