1/*- 2 * Copyright (c) 1996-1999 Distributed Processing Technology Corporation 3 * All rights reserved. 4 * 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. 8 * 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. 20 * 21 * $FreeBSD$ 22 */ 23 24#ifndef __OSD_UNIX_H 25#define __OSD_UNIX_H 26 27/*File - OSD_UNIX.H */ 28/*****************************************************************************/ 29/* */ 30/*Description: */ 31/* */ 32/* This file contains definitions for the UNIX OS dependent layer of the */ 33/*DPT engine. */ 34/* */ 35/*Copyright Distributed Processing Technology, Corp. */ 36/* 140 Candace Dr. */ 37/* Maitland, Fl. 32751 USA */ 38/* Phone: (407) 830-5522 Fax: (407) 260-5366 */ 39/* All Rights Reserved */ 40/* */ 41/*Author: Bob Pasteur */ 42/*Date: 5/28/93 */ 43/* */ 44/*Editors: */ 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 */ 51/* */ 52/*Remarks: */ 53/* */ 54/* */ 55/*****************************************************************************/ 56 57/* Definitions - Defines & Constants ---------------------------------------*/ 58 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 */ 63 64#define MSG_RECEIVE 0x40000000 /* Ored Into Logger PID For Return Msg */ 65 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 */ 69 70 /* Message Que Creation Flags */ 71 72#define MSG_URD 00400 73#define MSG_UWR 00200 74#define MSG_GRD 00040 75#define MSG_GWR 00020 76#define MSG_ORD 00004 77#define MSG_OWR 00002 78#define MSG_ALLRD 00444 79#define MSG_ALLWR 00222 80 81 /* Message Que Creation Flags */ 82 83#define SHM_URD 00400 84#define SHM_UWR 00200 85#define SHM_GRD 00040 86#define SHM_GWR 00020 87#define SHM_ORD 00004 88#define SHM_OWR 00002 89#define SHM_ALLRD 00444 90#define SHM_ALLWR 00222 91 92 /* Program Exit Codes */ 93 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 101 102#define ExitEngOpenFail 10 103#define ExitDuplicateEngine 11 104 105#define ExitCommAllocFail 12 106#define ExitDuplicateCommEng 13 107#define ExitCommConnectFail 14 108 109#ifndef MAX_HAS 110 111#define MAX_HAS 18 112#define MAX_NAME 100 113 114#endif /* ifndef MAX_HAS */ 115 116 117typedef struct { 118 uCHAR ConfigLength[4]; /* Len in bytes after this field. */ 119 uCHAR EATAsignature[4]; 120 uCHAR EATAversion; 121 uCHAR Flags1; 122 uCHAR PadLength[2]; 123 uCHAR HBA[4]; 124 uCHAR CPlength[4]; /* Command Packet Length */ 125 uCHAR SPlength[4]; /* Status Packet Length */ 126 uCHAR QueueSize[2]; /* Controller Que depth */ 127 uCHAR SG_Size[4]; 128 uCHAR Flags2; 129 uCHAR Reserved0; /* Reserved Field */ 130 uCHAR Flags3; 131 uCHAR ScsiValues; 132 uCHAR MaxLUN; /* Maximun LUN Supported */ 133 uCHAR Flags4; 134 uCHAR RaidNum; /* RAID HBA Number For Stripping */ 135 uCHAR Reserved3; /* Reserved Field */ 136 } DptReadConfig_t; 137 138#if defined(_DPT_SOLARIS) 139 140#include <sys/types.h> 141#include <sys/ddidmareq.h> 142#include <sys/mutex.h> 143#include <sys/scsi/scsi.h> 144/*#define _KERNEL */ 145#include <sys/dditypes.h> 146#include <sys/ddi_impldefs.h> 147#include <sys/scsi/impl/transport.h> 148/* #undef _KERNEL */ 149 150#undef MSG_DISCONNECT 151#define MSG_DISCONNECT 0x11L 152 153#define EATAUSRCMD 1 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 159#define I2OUSRCMD 7 160/* #define I2ORESCANCMD 8 */ /* Use DPT_IO_ACCESS instead */ 161/* #define I2ORESETCMD 9 */ /* Use DPT_IO_ACCESS instead */ 162 163#define DPT_MAX_DMA_SEGS 32 /* Max used Scatter/Gather seg */ 164 165struct dpt_sg { 166 paddr_t data_addr; 167 uLONG data_len; 168 }; 169 170typedef struct { 171 uSHORT NumHBAs; 172 uLONG IOAddrs[18]; 173 } GetHbaInfo_t; 174 175#elif defined(_DPT_DGUX) 176 177#ifndef _IOWR 178# define _IOWR(x,y,z) (0x0fff3900|y) 179#endif 180#ifndef _IOW 181# define _IOW(x,y,z) (0x0fff3900|y) 182#endif 183#ifndef _IOR 184# define _IOR(x,y,z) (0x0fff3900|y) 185#endif 186#ifndef _IO 187# define _IO(x,y) (0x0fff3900|y) 188#endif 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) 211 212#elif defined(SNI_MIPS) 213 /* Unix Ioctl Command definitions */ 214 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) 239 240#else 241 242 /* Unix Ioctl Command definitions */ 243 244#ifdef _DPT_AIX 245 246#undef _IOWR 247#undef _IOW 248#undef _IOR 249#undef _IO 250#endif 251 252#ifndef _IOWR 253# define _IOWR(x,y,z) (((x)<<8)|y) 254#endif 255#ifndef _IOW 256# define _IOW(x,y,z) (((x)<<8)|y) 257#endif 258#ifndef _IOR 259# define _IOR(x,y,z) (((x)<<8)|y) 260#endif 261#ifndef _IO 262# define _IO(x,y) (((x)<<8)|y) 263#endif 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) 270#if defined __bsdi__ 271#define DPT_SIGNATURE_PACKED _IOR('D',67,dpt_sig_S_Packed) 272#endif 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) 304#endif 305 306 307#endif /* _DPT_SOLARIS else */ 308 309 /* Adapter Flags Field Bit Definitions */ 310 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 */ 322 323 324/* Definitions - Structure & Typedef ---------------------------------------*/ 325 326typedef struct { 327 uLONG MsgID; 328 DPT_TAG_T engineTag; 329 DPT_TAG_T targetTag; 330 DPT_MSG_T engEvent; 331 long BufferID; 332 uLONG FromEngBuffOffset; 333 uLONG callerID; 334 DPT_RTN_T result; 335 uLONG timeOut; 336 } MsgHdr; 337 338#define MsgDataSize sizeof(MsgHdr) - 4 339 340#ifndef SNI_MIPS 341 342/*-------------------------------------------------------------------------*/ 343/* EATA Command Packet definition */ 344/*-------------------------------------------------------------------------*/ 345 346typedef struct EATACommandPacket { 347 348#ifdef _DPT_UNIXWARE 349 350 uCHAR EataID[4]; 351 uINT EataCmd; 352 uCHAR *CmdBuffer; 353 354#endif /* _DPT_UNIXWARE */ 355 356#ifdef _DPT_AIX 357 358 uCHAR HbaTargetID; 359 uCHAR HbaLUN; 360 361#endif /* _DPT_AIX */ 362 363 uCHAR cp_Flags1; /* Command Flags */ 364 uCHAR cp_Req_Len; /* AutoRequestSense Data length. */ 365 uCHAR cp_Resv1[3]; /* Reserved Fields */ 366 uCHAR cp_Flags2; 367 uCHAR cp_Flags3; 368 uCHAR cp_ScsiAddr; 369 uCHAR cp_msg0; /* Identify and Disconnect Message. */ 370 uCHAR cp_msg1; 371 uCHAR cp_msg2; 372 uCHAR cp_msg3; 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. */ 379 380#ifdef _DPT_SOLARIS 381 382 uCHAR HostStatus; 383 uCHAR TargetStatus; 384 uCHAR CdbLength; 385 uCHAR SG_Size; 386 struct scsi_arq_status ReqSenseData; 387 struct dpt_sg SG_List[DPT_MAX_DMA_SEGS]; 388 union { 389 char *b_scratch; 390 struct scsi_cmd *b_ownerp; 391 } cc; 392 paddr_t ccb_paddr; 393 uSHORT IOAddress; 394 395#else /* _DPT_SOLARIS */ 396 397 uLONG TimeOut ; 398 uCHAR HostStatus; 399 uCHAR TargetStatus; 400 uCHAR Retries; 401 402#endif /* _DPT_SOLARIS else */ 403 404 } EATA_CP; 405#endif /* SNI_MIPS */ 406 407 408 /* Control Flags 1 Definitions */ 409 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 */ 417 418 /* Control Flags 2 Definitions */ 419 420#define FIRMWARE_NESTED 0x01 421 422 423 /* Control Flags 3 Definitions */ 424 425#define PHYSICAL_UNIT 0x01 /* Send Command Directly To Target */ 426#define IAT 0x02 /* Inhibit Address Translation */ 427#define HBACI 0x04 /* Inhibit Caching */ 428 429 430 /* Structure Returned From Get Controller Info */ 431 432typedef struct { 433 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) */ 454 455 } CtrlInfo; 456 457#ifndef SNI_MIPS 458#ifdef _DPT_UNIXWARE 459 460typedef struct { 461 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 */ 475 476 } HbaInfo; 477 478 /* SDI ioctl prefix for hba specific ioctl's */ 479 480#define SDI_IOC (('S'<<24)|('D'<<16)|('I'<<8)) 481 482#define SDI_HBANAME ((SDI_IOC)|0x14) /* Get HBA module name */ 483#define SDI_SEND 0x0081 /* Send a SCSI command */ 484 485#else 486 487typedef struct { 488 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 */ 508 509 } HbaInfo; 510 511#endif /* _DPT_UNIXWARE */ 512#endif /* SNI_MIPS */ 513 514 515#ifdef _DPT_AIX 516 517/* 518 * DPT Host Adapter config information structure - this structure contains 519 * configuration information about an adapter. It is imbedded into the 520 * dpt_ctl structure. 521 */ 522 523typedef 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 533 PIO commands */ 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 */ 543} DptCfg_t; 544 545#endif /* _DPT_AIX */ 546 547 548#define MAX_ELEMENT_COUNT 64 549#define MAX_BUCKET_COUNT 10 550 551/* 552 * DPT statistics structure definitions 553 */ 554typedef struct IO_SIZE_STATS 555{ 556 uLONG TotalIoCount; 557 uLONG IoCountRead; 558 uLONG IoCountReadSg; 559 uLONG IoCountWrite; 560 uLONG IoCountWriteSg; 561 uLONG UnalignedIoAddress; 562 uLONG SgElementCount[MAX_ELEMENT_COUNT]; 563 564} IO_SIZE_STATS_T, *pIO_SIZE_STATS_T; 565 566typedef struct STATS_DATA 567{ 568 uLONG TotalIoCount; 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]; 578 579} STATS_DATA_T, *pSTATS_DATA_T; 580 581typedef struct TARGET_BUSY 582{ 583 uLONG channel; 584 uLONG id; 585 uLONG lun; 586 uLONG isBusy; 587} TARGET_BUSY_T; 588#endif /* __OSD_UNIX_H */ 589