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