1139749Simp/*-
265312Smsmith * Copyright (c) 1996-1999 Distributed Processing Technology Corporation
365312Smsmith * All rights reserved.
465312Smsmith *
565312Smsmith * Redistribution and use in source form, with or without modification, are
665312Smsmith * permitted provided that redistributions of source code must retain the
765312Smsmith * above copyright notice, this list of conditions and the following disclaimer.
865312Smsmith *
965312Smsmith * This software is provided `as is' by Distributed Processing Technology and
1065312Smsmith * any express or implied warranties, including, but not limited to, the
1165312Smsmith * implied warranties of merchantability and fitness for a particular purpose,
1265312Smsmith * are disclaimed. In no event shall Distributed Processing Technology be
1365312Smsmith * liable for any direct, indirect, incidental, special, exemplary or
1465312Smsmith * consequential damages (including, but not limited to, procurement of
1565312Smsmith * substitute goods or services; loss of use, data, or profits; or business
1665312Smsmith * interruptions) however caused and on any theory of liability, whether in
1765312Smsmith * contract, strict liability, or tort (including negligence or otherwise)
1865312Smsmith * arising in any way out of the use of this driver software, even if advised
1965312Smsmith * of the possibility of such damage.
2065312Smsmith *
2187826Sobrien * $FreeBSD$
2265312Smsmith */
2365312Smsmith
2496554Sobrien#ifndef		__OSD_UNIX_H
2596554Sobrien#define		__OSD_UNIX_H
2665312Smsmith
2765312Smsmith/*File - OSD_UNIX.H */
2865312Smsmith/*****************************************************************************/
2996554Sobrien/*									     */
3096554Sobrien/*Description:								     */
3196554Sobrien/*									     */
3265312Smsmith/*    This file contains definitions for the UNIX OS dependent layer of the  */
3396554Sobrien/*DPT engine.								     */
3496554Sobrien/*									     */
3596554Sobrien/*Copyright Distributed Processing Technology, Corp.			     */
3696554Sobrien/*	  140 Candace Dr.						     */
3796554Sobrien/*	  Maitland, Fl. 32751	USA					     */
3896554Sobrien/*	  Phone: (407) 830-5522	 Fax: (407) 260-5366			     */
3996554Sobrien/*	  All Rights Reserved						     */
4096554Sobrien/*									     */
4196554Sobrien/*Author:	Bob Pasteur						     */
4296554Sobrien/*Date:		5/28/93							     */
4396554Sobrien/*									     */
4496554Sobrien/*Editors:								     */
4565312Smsmith/*		3/7/96	salyzyn@dpt.com					     */
4665312Smsmith/*			Added BSDi extensions				     */
4796554Sobrien/*		30/9/99 salyzyn@dpt.com					     */
4865312Smsmith/*			Added I2ORESCANCMD				     */
4996554Sobrien/*		7/12/99 salyzyn@dpt.com					     */
5065312Smsmith/*			Added I2ORESETCMD				     */
5196554Sobrien/*									     */
5296554Sobrien/*Remarks:								     */
5396554Sobrien/*									     */
5496554Sobrien/*									     */
5565312Smsmith/*****************************************************************************/
5665312Smsmith
5765312Smsmith/* Definitions - Defines & Constants ---------------------------------------*/
5865312Smsmith
5996615Sobrien#define	DPT_TurnAroundKey  0x01	   /* TurnAround Message Type for engine      */
6096615Sobrien#define	DPT_EngineKey	   0x02	   /* Message Que and Type for engine	      */
6196615Sobrien#define	DPT_LoggerKey	   0x03	   /* Message Type For Logger		      */
6296615Sobrien#define	DPT_CommEngineKey  0x04	   /* Message Que Type Created		      */
6365312Smsmith
6496615Sobrien#define	MSG_RECEIVE    0x40000000  /* Ored Into Logger PID For Return Msg     */
6565312Smsmith
6696615Sobrien#define	ENGMSG_ECHO	   0x00	   /* Turnarround Echo Engine Message	      */
6796615Sobrien#define	ENGMSG_OPEN	   0x01	   /* Turnarround Open Engine Message	      */
6896615Sobrien#define	ENGMSG_CLOSE	   0x02	   /* Turnarround Close Engine Message	      */
6996554Sobrien
7065312Smsmith  /* Message Que Creation Flags */
7165312Smsmith
7296615Sobrien#define	MSG_URD		   00400
7396615Sobrien#define	MSG_UWR		   00200
7496615Sobrien#define	MSG_GRD		   00040
7596615Sobrien#define	MSG_GWR		   00020
7696615Sobrien#define	MSG_ORD		   00004
7796615Sobrien#define	MSG_OWR		   00002
7896615Sobrien#define	MSG_ALLRD	   00444
7996615Sobrien#define	MSG_ALLWR	   00222
8065312Smsmith
8165312Smsmith  /* Message Que Creation Flags */
8265312Smsmith
8396615Sobrien#define	SHM_URD		   00400
8496615Sobrien#define	SHM_UWR		   00200
8596615Sobrien#define	SHM_GRD		   00040
8696615Sobrien#define	SHM_GWR		   00020
8796615Sobrien#define	SHM_ORD		   00004
8896615Sobrien#define	SHM_OWR		   00002
8996615Sobrien#define	SHM_ALLRD	   00444
9096615Sobrien#define	SHM_ALLWR	   00222
9165312Smsmith
9265312Smsmith  /* Program Exit Codes */
9365312Smsmith
9496615Sobrien#define	ExitGoodStatus		 0
9596615Sobrien#define	ExitBadParameter	 1
9696615Sobrien#define	ExitSignalFail		 3
9796615Sobrien#define	ExitMsqAllocFail	 5
9896615Sobrien#define	ExitBuffAllocFail	 6
9996615Sobrien#define	ExitMsgSendFail		 8
10096615Sobrien#define	ExitMsgReceiveFail	 9
10165312Smsmith
10296615Sobrien#define	ExitEngOpenFail		 10
10396615Sobrien#define	ExitDuplicateEngine	 11
10465312Smsmith
10596615Sobrien#define	ExitCommAllocFail	 12
10696615Sobrien#define	ExitDuplicateCommEng	 13
10796615Sobrien#define	ExitCommConnectFail	 14
10865312Smsmith
10965312Smsmith#ifndef MAX_HAS
11065312Smsmith
11196615Sobrien#define	MAX_HAS			 18
11296615Sobrien#define	MAX_NAME		 100
11365312Smsmith
11496554Sobrien#endif	/* ifndef MAX_HAS */
11565312Smsmith
11665312Smsmith
11765312Smsmithtypedef struct {
11896554Sobrien	uCHAR ConfigLength[4];	     /* Len in bytes after this field.	    */
11965312Smsmith	uCHAR EATAsignature[4];
12065312Smsmith	uCHAR EATAversion;
12196554Sobrien	uCHAR Flags1;
12265312Smsmith	uCHAR PadLength[2];
12365312Smsmith	uCHAR HBA[4];
12496554Sobrien	uCHAR CPlength[4];	     /* Command Packet Length		    */
12596554Sobrien	uCHAR SPlength[4];	     /* Status Packet Length		    */
12696554Sobrien	uCHAR QueueSize[2];	     /* Controller Que depth		    */
12765312Smsmith	uCHAR SG_Size[4];
12896554Sobrien	uCHAR Flags2;
12996554Sobrien	uCHAR Reserved0;	     /* Reserved Field			     */
13096554Sobrien	uCHAR Flags3;
13196554Sobrien	uCHAR ScsiValues;
13296554Sobrien	uCHAR MaxLUN;		     /* Maximun LUN Supported		     */
13396554Sobrien	uCHAR Flags4;
13496554Sobrien	uCHAR RaidNum;		     /* RAID HBA Number For Stripping	     */
13596554Sobrien	uCHAR Reserved3;	     /* Reserved Field			     */
13665312Smsmith	       } DptReadConfig_t;
13765312Smsmith
13896614Sobrien#if defined(_DPT_SOLARIS)
13965312Smsmith
14065312Smsmith#include <sys/types.h>
14165312Smsmith#include <sys/ddidmareq.h>
14265312Smsmith#include <sys/mutex.h>
14365312Smsmith#include <sys/scsi/scsi.h>
14496551Sobrien/*#define	_KERNEL */
14565312Smsmith#include <sys/dditypes.h>
14665312Smsmith#include <sys/ddi_impldefs.h>
14765312Smsmith#include <sys/scsi/impl/transport.h>
14887826Sobrien/* #undef _KERNEL */
14965312Smsmith
15065312Smsmith#undef MSG_DISCONNECT
15196615Sobrien#define	MSG_DISCONNECT	0x11L
15265312Smsmith
15396615Sobrien#define	EATAUSRCMD     1
15496615Sobrien#define	DPT_SIGNATURE  2
15596615Sobrien#define	DPT_NUMCTRLS   3
15696615Sobrien#define	DPT_CTRLINFO   4
15796615Sobrien#define	DPT_SYSINFO    5
15896615Sobrien#define	DPT_BLINKLED   6
15996615Sobrien#define	I2OUSRCMD      7
16096551Sobrien/* #define	I2ORESCANCMD 8 */	/* Use DPT_IO_ACCESS instead */
16196551Sobrien/* #define	I2ORESETCMD  9 */	/* Use DPT_IO_ACCESS instead */
16265312Smsmith
16396615Sobrien#define	DPT_MAX_DMA_SEGS  32	     /* Max used Scatter/Gather seg	    */
16465312Smsmith
16565312Smsmithstruct dpt_sg {
16665312Smsmith       paddr_t data_addr;
16765312Smsmith       uLONG data_len;
16865312Smsmith	      };
16965312Smsmith
17065312Smsmithtypedef struct {
17165312Smsmith	uSHORT NumHBAs;
17265312Smsmith	uLONG IOAddrs[18];
17365312Smsmith	       } GetHbaInfo_t;
17465312Smsmith
17565312Smsmith#elif defined(_DPT_DGUX)
17665312Smsmith
17765312Smsmith#ifndef _IOWR
17865312Smsmith# define _IOWR(x,y,z)	(0x0fff3900|y)
17965312Smsmith#endif
18065312Smsmith#ifndef _IOW
18165312Smsmith# define _IOW(x,y,z)	(0x0fff3900|y)
18265312Smsmith#endif
18365312Smsmith#ifndef _IOR
18465312Smsmith# define _IOR(x,y,z)	(0x0fff3900|y)
18565312Smsmith#endif
18665312Smsmith#ifndef _IO
18765312Smsmith# define _IO(x,y)	(0x0fff3900|y)
18865312Smsmith#endif
18965312Smsmith/* EATA PassThrough Command	*/
19096615Sobrien#define	EATAUSRCMD	_IOWR('D',65,EATA_CP)
19165312Smsmith/* Get Signature Structure	*/
19296615Sobrien#define	DPT_SIGNATURE	_IOR('D',67,dpt_sig_S)
19365312Smsmith/* Get Number Of DPT Adapters	*/
19496615Sobrien#define	DPT_NUMCTRLS	_IOR('D',68,int)
19565312Smsmith/* Get Adapter Info Structure	*/
19696615Sobrien#define	DPT_CTRLINFO	_IOR('D',69,CtrlInfo)
19765312Smsmith/* Get System Info Structure	*/
19896615Sobrien#define	DPT_SYSINFO	_IOR('D',72,sysInfo_S)
19996554Sobrien/* Get Blink LED Code		*/
20096615Sobrien#define	DPT_BLINKLED	_IOR('D',75,int)
20165312Smsmith/* Get Statistical information (if available) */
20296615Sobrien#define	DPT_STATS_INFO	      _IOR('D',80,STATS_DATA)
20396554Sobrien/* Clear the statistical information	      */
20496615Sobrien#define	DPT_STATS_CLEAR	      _IO('D',81)
20565312Smsmith/* Send an I2O command */
20696615Sobrien#define	I2OUSRCMD	_IO('D',76)
20765312Smsmith/* Inform driver to re-acquire LCT information */
20896615Sobrien#define	I2ORESCANCMD	_IO('D',77)
20965312Smsmith/* Inform driver to reset adapter */
21096615Sobrien#define	I2ORESETCMD	_IO('D',78)
21165312Smsmith
21296614Sobrien#elif defined(SNI_MIPS)
21365312Smsmith  /* Unix Ioctl Command definitions */
21465312Smsmith
21596615Sobrien#define	EATAUSRCMD     (('D'<<8)|65)
21696615Sobrien#define	DPT_DEBUG      (('D'<<8)|66)
21796615Sobrien#define	DPT_SIGNATURE  (('D'<<8)|67)
21896615Sobrien#define	DPT_NUMCTRLS   (('D'<<8)|68)
21996615Sobrien#define	DPT_CTRLINFO   (('D'<<8)|69)
22096615Sobrien#define	DPT_STATINFO   (('D'<<8)|70)
22196615Sobrien#define	DPT_CLRSTAT    (('D'<<8)|71)
22296615Sobrien#define	DPT_SYSINFO    (('D'<<8)|72)
22365312Smsmith/* Set Timeout Value		*/
22496615Sobrien#define	DPT_TIMEOUT    (('D'<<8)|73)
22596554Sobrien/* Get config Data		*/
22696615Sobrien#define	DPT_CONFIG     (('D'<<8)|74)
22796554Sobrien/* Get config Data		*/
22896615Sobrien#define	DPT_BLINKLED   (('D'<<8)|75)
22965312Smsmith/* Get Statistical information (if available) */
23096615Sobrien#define	DPT_STATS_INFO	      (('D'<<8)|80)
23196554Sobrien/* Clear the statistical information	      */
23296615Sobrien#define	DPT_STATS_CLEAR	      (('D'<<8)|81)
23365312Smsmith/* Send an I2O command */
23496615Sobrien#define	I2OUSRCMD	(('D'<<8)|76)
23565312Smsmith/* Inform driver to re-acquire LCT information */
23696615Sobrien#define	I2ORESCANCMD	(('D'<<8)|77)
23765312Smsmith/* Inform driver to reset adapter */
23896615Sobrien#define	I2ORESETCMD	(('D'<<8)|78)
23965312Smsmith
24096554Sobrien#else
24165312Smsmith
24265312Smsmith  /* Unix Ioctl Command definitions */
24365312Smsmith
24465312Smsmith#ifdef _DPT_AIX
24565312Smsmith
24665312Smsmith#undef _IOWR
24765312Smsmith#undef _IOW
24865312Smsmith#undef _IOR
24965312Smsmith#undef _IO
25065312Smsmith#endif
25165312Smsmith
25265312Smsmith#ifndef _IOWR
25365312Smsmith# define _IOWR(x,y,z)	(((x)<<8)|y)
25465312Smsmith#endif
25565312Smsmith#ifndef _IOW
25665312Smsmith# define _IOW(x,y,z)	(((x)<<8)|y)
25765312Smsmith#endif
25865312Smsmith#ifndef _IOR
25965312Smsmith# define _IOR(x,y,z)	(((x)<<8)|y)
26065312Smsmith#endif
26165312Smsmith#ifndef _IO
26265312Smsmith# define _IO(x,y)	(((x)<<8)|y)
26365312Smsmith#endif
26465312Smsmith/* EATA PassThrough Command	*/
26596615Sobrien#define	EATAUSRCMD	_IOWR('D',65,EATA_CP)
26665312Smsmith/* Set Debug Level If Enabled	*/
26796615Sobrien#define	DPT_DEBUG	_IOW('D',66,int)
26865312Smsmith/* Get Signature Structure	*/
26996615Sobrien#define	DPT_SIGNATURE	_IOR('D',67,dpt_sig_S)
27065312Smsmith#if defined __bsdi__
27196615Sobrien#define	DPT_SIGNATURE_PACKED   _IOR('D',67,dpt_sig_S_Packed)
27265312Smsmith#endif
27365312Smsmith/* Get Number Of DPT Adapters	*/
27496615Sobrien#define	DPT_NUMCTRLS	_IOR('D',68,int)
27565312Smsmith/* Get Adapter Info Structure	*/
27696615Sobrien#define	DPT_CTRLINFO	_IOR('D',69,CtrlInfo)
27765312Smsmith/* Get Statistics If Enabled	*/
27896615Sobrien#define	DPT_STATINFO	_IO('D',70)
27965312Smsmith/* Clear Stats If Enabled	*/
28096615Sobrien#define	DPT_CLRSTAT	_IO('D',71)
28165312Smsmith/* Get System Info Structure	*/
28296615Sobrien#define	DPT_SYSINFO	_IOR('D',72,sysInfo_S)
28365312Smsmith/* Set Timeout Value		*/
28496615Sobrien#define	DPT_TIMEOUT	_IO('D',73)
28596554Sobrien/* Get config Data		*/
28696615Sobrien#define	DPT_CONFIG	_IO('D',74)
28796554Sobrien/* Get Blink LED Code		*/
28896615Sobrien#define	DPT_BLINKLED	_IOR('D',75,int)
28965312Smsmith/* Get Statistical information (if available) */
29096615Sobrien#define	DPT_STATS_INFO	      _IOR('D',80,STATS_DATA)
29196554Sobrien/* Clear the statistical information	      */
29296615Sobrien#define	DPT_STATS_CLEAR	      _IO('D',81)
29365312Smsmith/* Get Performance metrics */
29496615Sobrien#define	DPT_PERF_INFO	     _IOR('D',82,dpt_perf_t)
29565312Smsmith/* Send an I2O command */
29696615Sobrien#define	I2OUSRCMD	_IO('D',76)
29765312Smsmith/* Inform driver to re-acquire LCT information */
29896615Sobrien#define	I2ORESCANCMD	_IO('D',77)
29965312Smsmith/* Inform driver to reset adapter */
30096615Sobrien#define	I2ORESETCMD	_IO('D',78)
30165312Smsmith#if defined _DPT_LINUX
30265312Smsmith/* See if the target is mounted */
30396615Sobrien#define	DPT_TARGET_BUSY _IOR('D',79, TARGET_BUSY_T)
30465312Smsmith#endif
30565312Smsmith
30665312Smsmith
30796554Sobrien#endif	/* _DPT_SOLARIS else */
30865312Smsmith
30965312Smsmith		 /* Adapter Flags Field Bit Definitions */
31065312Smsmith
31196615Sobrien#define	CTLR_INSTALLED	0x00000001  /* Adapter Was Installed	    */
31296615Sobrien#define	CTLR_DMA	0x00000002  /* DMA Supported		    */
31396615Sobrien#define	CTLR_OVERLAP	0x00000004  /* Overlapped Commands Support  */
31496615Sobrien#define	CTLR_SECONDARY	0x00000008  /* I/O Address Not 0x1f0	    */
31596615Sobrien#define	CTLR_BLINKLED	0x00000010  /* Adapter In Blink LED State   */
31696615Sobrien#define	CTLR_HBACI	0x00000020  /* Cache Inhibit Supported	    */
31796615Sobrien#define	CTLR_CACHE	0x00000040  /* Adapter Has Cache	    */
31896615Sobrien#define	CTLR_SANE	0x00000080  /* Adapter Functioning OK	    */
31996615Sobrien#define	CTLR_BUS_QUIET	0x00000100  /* Bus Quite On This Adapter    */
32096615Sobrien#define	CTLR_ABOVE_16	0x00000200  /* Support For Mem. Above 16 MB */
32196615Sobrien#define	CTLR_SCAT_GATH	0x00000400  /* Scatter Gather Supported	    */
32265312Smsmith
32365312Smsmith
32465312Smsmith/* Definitions - Structure & Typedef ---------------------------------------*/
32565312Smsmith
32665312Smsmithtypedef struct {
32796554Sobrien		 uLONG	   MsgID;
32865312Smsmith		 DPT_TAG_T engineTag;
32965312Smsmith		 DPT_TAG_T targetTag;
33065312Smsmith		 DPT_MSG_T engEvent;
33196554Sobrien		 long	   BufferID;
33296554Sobrien		 uLONG	   FromEngBuffOffset;
33396554Sobrien		 uLONG	   callerID;
33465312Smsmith		 DPT_RTN_T result;
33596554Sobrien		 uLONG	   timeOut;
33665312Smsmith	       } MsgHdr;
33765312Smsmith
33896615Sobrien#define	MsgDataSize sizeof(MsgHdr) - 4
33965312Smsmith
34065312Smsmith#ifndef SNI_MIPS
34165312Smsmith
34265312Smsmith/*-------------------------------------------------------------------------*/
34396554Sobrien/*		       EATA Command Packet definition			   */
34465312Smsmith/*-------------------------------------------------------------------------*/
34565312Smsmith
34665312Smsmithtypedef struct EATACommandPacket {
34765312Smsmith
34865312Smsmith#ifdef _DPT_UNIXWARE
34965312Smsmith
35096554Sobrien	uCHAR	  EataID[4];
35196554Sobrien	uINT	  EataCmd;
35296554Sobrien	uCHAR	  *CmdBuffer;
35365312Smsmith
35496554Sobrien#endif	 /* _DPT_UNIXWARE */
35565312Smsmith
35665312Smsmith#ifdef _DPT_AIX
35765312Smsmith
35896554Sobrien	uCHAR	  HbaTargetID;
35996554Sobrien	uCHAR	  HbaLUN;
36065312Smsmith
36196554Sobrien#endif	/* _DPT_AIX */
36265312Smsmith
36396554Sobrien	uCHAR	 cp_Flags1;	     /* Command Flags			    */
36496554Sobrien	uCHAR	 cp_Req_Len;	     /* AutoRequestSense Data length.	    */
36596554Sobrien	uCHAR	 cp_Resv1[3];	     /* Reserved Fields			    */
36696554Sobrien	uCHAR	 cp_Flags2;
36796554Sobrien	uCHAR	 cp_Flags3;
36896554Sobrien	uCHAR	 cp_ScsiAddr;
36996554Sobrien	uCHAR	 cp_msg0;	     /* Identify and Disconnect Message.    */
37096554Sobrien	uCHAR	 cp_msg1;
37196554Sobrien	uCHAR	 cp_msg2;
37296554Sobrien	uCHAR	 cp_msg3;
37396554Sobrien	uCHAR	 cp_cdb[12];	     /* SCSI cdb for command.		    */
37496554Sobrien	uLONG	 cp_dataLen;	     /* Data length in Bytes for command.   */
37596554Sobrien	uLONG	 cp_Vue;	     /* Vendor Unique Area		    */
37696554Sobrien	uCHAR	 *cp_DataAddr;	     /* Data Address For The Command.	    */
37796554Sobrien	uCHAR	 *cp_SpAddr;	     /* Status Packet Physical Address.	    */
37896554Sobrien	uCHAR	 *cp_SenseAddr;	     /* AutoRequestSense Data Phy Address.  */
37996554Sobrien
38065312Smsmith#ifdef _DPT_SOLARIS
38165312Smsmith
38296554Sobrien	uCHAR	  HostStatus;
38396554Sobrien	uCHAR	  TargetStatus;
38496554Sobrien	uCHAR	  CdbLength;
38596554Sobrien	uCHAR	  SG_Size;
38665312Smsmith	struct scsi_arq_status ReqSenseData;
38796554Sobrien	struct	dpt_sg SG_List[DPT_MAX_DMA_SEGS];
38865312Smsmith	union {
38965312Smsmith		char *b_scratch;
39096554Sobrien		struct scsi_cmd *b_ownerp;
39165312Smsmith	      } cc;
39265312Smsmith	paddr_t ccb_paddr;
39365312Smsmith	uSHORT IOAddress;
39496554Sobrien
39565312Smsmith#else  /* _DPT_SOLARIS */
39665312Smsmith
39796554Sobrien	uLONG	  TimeOut ;
39896554Sobrien	uCHAR	  HostStatus;
39996554Sobrien	uCHAR	  TargetStatus;
40096554Sobrien	uCHAR	  Retries;
40165312Smsmith
40296554Sobrien#endif	/* _DPT_SOLARIS else */
40365312Smsmith
40465312Smsmith				  } EATA_CP;
40587816Sjhb#endif /* SNI_MIPS */
40665312Smsmith
40765312Smsmith
40896554Sobrien		      /* Control Flags 1 Definitions */
40965312Smsmith
41096615Sobrien#define	SCSI_RESET	  0x01	     /* Cause a SCSI Bus reset on the cmd */
41196615Sobrien#define	HBA_INIT	  0x02	     /* Cause Controller to reInitialize  */
41296615Sobrien#define	AUTO_REQ_SENSE	  0x04	     /* Do Auto Request Sense on errors	  */
41396615Sobrien#define	SCATTER_GATHER	  0x08	     /* Data Ptr points to a SG Packet	  */
41496615Sobrien#define	INTERPRET	  0x20	     /* Interpret the SCSI cdb of own use */
41596615Sobrien#define	DATA_OUT	  0x04	     /* Data Out phase with command	  */
41696615Sobrien#define	DATA_IN		  0x08	     /* Data In phase with command	  */
41765312Smsmith
41896554Sobrien		      /* Control Flags 2 Definitions */
41965312Smsmith
42096615Sobrien#define	FIRMWARE_NESTED	  0x01
42165312Smsmith
42265312Smsmith
42396554Sobrien		      /* Control Flags 3 Definitions */
42465312Smsmith
42596615Sobrien#define	PHYSICAL_UNIT	  0x01	     /* Send Command Directly To Target	  */
42696615Sobrien#define	IAT		  0x02	     /* Inhibit Address Translation	  */
42796615Sobrien#define	HBACI		  0x04	     /* Inhibit Caching			  */
42865312Smsmith
42965312Smsmith
43096554Sobrien  /* Structure Returned From Get Controller Info			     */
43165312Smsmith
43265312Smsmithtypedef struct {
43365312Smsmith
43496554Sobrien	uCHAR	 state;		   /* Operational state		      */
43596554Sobrien	uCHAR	 id;		   /* Host adapter SCSI id	      */
43696554Sobrien	int	 vect;		   /* Interrupt vector number	      */
43796554Sobrien	int	 base;		   /* Base I/O address		      */
43896554Sobrien	int	 njobs;		   /* # of jobs sent to HA	      */
43996554Sobrien	int	 qdepth;	   /* Controller queue depth.	      */
44096554Sobrien	int	 wakebase;	   /* mpx wakeup base index.	      */
44196554Sobrien	uLONG	 SGsize;	   /* Scatter/Gather list size.	      */
44296554Sobrien	unsigned heads;		   /* heads for drives on cntlr.      */
44396554Sobrien	unsigned sectors;	   /* sectors for drives on cntlr.    */
44496554Sobrien	uCHAR	 do_drive32;	   /* Flag for Above 16 MB Ability    */
44596554Sobrien	uCHAR	 BusQuiet;	   /* SCSI Bus Quiet Flag	      */
44696554Sobrien	char	 idPAL[4];	   /* 4 Bytes Of The ID Pal	      */
44796554Sobrien	uCHAR	 primary;	   /* 1 For Primary, 0 For Secondary  */
44896554Sobrien	uCHAR	 eataVersion;	   /* EATA Version		      */
44996554Sobrien	uLONG	 cpLength;	   /* EATA Command Packet Length      */
45096554Sobrien	uLONG	 spLength;	   /* EATA Status Packet Length	      */
45196554Sobrien	uCHAR	 drqNum;	   /* DRQ Index (0,5,6,7)	      */
45296554Sobrien	uCHAR	 flag1;		   /* EATA Flags 1 (Byte 9)	      */
45396554Sobrien	uCHAR	 flag2;		   /* EATA Flags 2 (Byte 30)	      */
45465312Smsmith
45565312Smsmith	       } CtrlInfo;
45665312Smsmith
45765312Smsmith#ifndef SNI_MIPS
45865312Smsmith#ifdef _DPT_UNIXWARE
45965312Smsmith
46065312Smsmithtypedef struct {
46165312Smsmith
46296554Sobrien	uINT	 state;		   /* Operational state		   */
46396554Sobrien	uCHAR	 id[4];		   /* Host adapter SCSI id	   */
46496554Sobrien	uINT	 vect;		   /* Interrupt vector number	   */
46596554Sobrien	uLONG	 base;		   /* Base I/O address		   */
46696554Sobrien	int	 ha_max_jobs;	   /* Max number of Active Jobs	   */
46796554Sobrien	uLONG	 ha_cacheParams;
46896554Sobrien	int	 ha_nbus;	   /* Number Of Busses on HBA	   */
46996554Sobrien	int	 ha_ntargets;	   /* Number Of Targets Supported  */
47096554Sobrien	int	 ha_nluns;	   /* Number Of LUNs Supported	   */
47196554Sobrien	int	 ha_tshift;	   /* Shift value for target	   */
47296554Sobrien	int	 ha_bshift;	   /* Shift value for bus	   */
47396554Sobrien	uINT	 ha_npend;	   /* # of jobs sent to HA	   */
47496554Sobrien	int	 ha_active_jobs;   /* Number Of Active Jobs	   */
47565312Smsmith
47665312Smsmith	       } HbaInfo;
47765312Smsmith
47865312Smsmith	/* SDI ioctl prefix for hba specific ioctl's */
47965312Smsmith
48096615Sobrien#define	SDI_IOC	       (('S'<<24)|('D'<<16)|('I'<<8))
48165312Smsmith
48296615Sobrien#define	SDI_HBANAME    ((SDI_IOC)|0x14) /* Get HBA module name	    */
48396615Sobrien#define	SDI_SEND       0x0081		/* Send a SCSI command	    */
48465312Smsmith
48565312Smsmith#else
48665312Smsmith
48765312Smsmithtypedef struct {
48865312Smsmith
48996554Sobrien	uLONG  flags;		 /* Operational State Flags	    */
49096554Sobrien	uCHAR  id[4];		 /* Host Adapter SCSI ID	    */
49196554Sobrien	int    vect;		 /* Interrupt Vector Number	    */
49296554Sobrien	int    base;		 /* Base I/O Address		    */
49396554Sobrien	int    njobs;		 /* # Of CCBs Outstanding To HBA    */
49496554Sobrien	int    qdepth;		 /* Controller Queue depth.	    */
49596554Sobrien	uLONG  SGsize;		 /* Scatter/Gather List Size.	    */
49696554Sobrien	char   idPAL[4];	 /* 4 Bytes Of The ID Pal	    */
49796554Sobrien	uCHAR  eataVersion;	 /* EATA Version		    */
49896554Sobrien	uLONG  cpLength;	 /* EATA Command Packet Length	    */
49996554Sobrien	uLONG  spLength;	 /* EATA Status Packet Length	    */
50096554Sobrien	uCHAR  drqNum;		 /* DRQ Index (0,5,6,7)		    */
50196554Sobrien	uCHAR  eataflag1;	 /* EATA Flags 1 (Byte 9)	    */
50296554Sobrien	uCHAR  eataflag2;	 /* EATA Flags 2 (Byte 30)	    */
50396554Sobrien	uCHAR  maxChannel;	 /* Maximum Channel Number	    */
50496554Sobrien	uCHAR  maxID;		 /* Maximum Target ID		    */
50596554Sobrien	uCHAR  maxLUN;		 /* Maximum LUN			    */
50696554Sobrien	uCHAR  HbaBusType;	 /* HBA Bus Type, EISA, PCI, etc    */
50796554Sobrien	uCHAR  RaidNum;		 /* Host Adapter RAID Number	    */
50865312Smsmith
50965312Smsmith	       } HbaInfo;
51065312Smsmith
51196554Sobrien#endif	/* _DPT_UNIXWARE */
51287816Sjhb#endif /* SNI_MIPS */
51365312Smsmith
51465312Smsmith
51565312Smsmith#ifdef _DPT_AIX
51665312Smsmith
51765312Smsmith/*
51865312Smsmith * DPT Host Adapter config information structure - this structure contains
51996554Sobrien * configuration information about an adapter.	It is imbedded into the
52065312Smsmith * dpt_ctl structure.
52165312Smsmith */
52265312Smsmith
52365312Smsmithtypedef struct dpt_cfg {
52465312Smsmith    uchar	flags;			/* Operational state flags	*/
52565312Smsmith    uchar	id[4];			/* Host adapter SCSI IDs	*/
52665312Smsmith    int		vect;			/* Interrupt vector number	*/
52796554Sobrien    ulong	base_addr;		/* Base I/O address		*/
52865312Smsmith    int		qdepth;			/* Controller queue depth.	*/
52965312Smsmith    ulong	SGsize;			/* Max scatter/gather list sz	*/
53065312Smsmith    ulong	SGmax;			/* Max s/g we can use per req	*/
53165312Smsmith    uchar	eataVersion;		/* EATA version			*/
53265312Smsmith    ushort	cpPadLen;		/* # of pad bytes sent to HA for
53365312Smsmith					   PIO commands			*/
53465312Smsmith    ulong	cpLength;		/* EATA Command Packet length	*/
53565312Smsmith    ulong	spLength;		/* EATA Status Packet length	*/
53665312Smsmith    uchar	eataflag1;		/* EATA Flags 1 (Byte 9)	*/
53765312Smsmith    uchar	eataflag2;		/* EATA Flags 2 (Byte 30)	*/
53865312Smsmith    uchar	maxChan;		/* Maximum Channel number	*/
53965312Smsmith    uchar	maxID;			/* Maximum target ID		*/
54065312Smsmith    uchar	maxLUN;			/* Maximum LUN			*/
54196554Sobrien    uchar	HbaBusType;		/* HBA bus type, EISA, PCI, etc */
54265312Smsmith    uchar	RaidNum;		/* Host adapter RAID number	*/
54365312Smsmith} DptCfg_t;
54465312Smsmith
54565312Smsmith#endif /* _DPT_AIX */
54665312Smsmith
54765312Smsmith
54896615Sobrien#define	MAX_ELEMENT_COUNT	 64
54996615Sobrien#define	MAX_BUCKET_COUNT	 10
55065312Smsmith
55165312Smsmith/*
55265312Smsmith * DPT statistics structure definitions
55365312Smsmith */
55496554Sobrientypedef struct IO_SIZE_STATS
55565312Smsmith{
55665312Smsmith  uLONG TotalIoCount;
55765312Smsmith  uLONG IoCountRead;
55865312Smsmith  uLONG IoCountReadSg;
55965312Smsmith  uLONG IoCountWrite;
56065312Smsmith  uLONG IoCountWriteSg;
56165312Smsmith  uLONG UnalignedIoAddress;
56265312Smsmith  uLONG SgElementCount[MAX_ELEMENT_COUNT];
56365312Smsmith
56465312Smsmith} IO_SIZE_STATS_T, *pIO_SIZE_STATS_T;
56565312Smsmith
56696554Sobrientypedef struct STATS_DATA
56765312Smsmith{
56865312Smsmith  uLONG TotalIoCount;
56965312Smsmith  uLONG TotalUnCachedIoCount;
57065312Smsmith  uLONG MaxOutstandingIoCount;
57165312Smsmith  uLONG CurrentOutstandingIoCount;
57265312Smsmith  uLONG OutstandingIoRunningCount;
57365312Smsmith  uLONG UnalignedPktCount;
57465312Smsmith  uLONG UnalignedSgCount;
57565312Smsmith  uLONG NonPageListAddressSgCount;
57665312Smsmith  uLONG MaxMessagesPerInterrupt;
57765312Smsmith  IO_SIZE_STATS_T IoSize[MAX_BUCKET_COUNT];
57865312Smsmith
57965312Smsmith} STATS_DATA_T, *pSTATS_DATA_T;
58065312Smsmith
58165312Smsmithtypedef struct TARGET_BUSY
58265312Smsmith{
58365312Smsmith  uLONG channel;
58465312Smsmith  uLONG id;
58565312Smsmith  uLONG lun;
58665312Smsmith  uLONG isBusy;
58765312Smsmith} TARGET_BUSY_T;
58865312Smsmith#endif /* __OSD_UNIX_H */
589