1fcf3ce44SJohn Forte /* 2fcf3ce44SJohn Forte * CDDL HEADER START 3fcf3ce44SJohn Forte * 4fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the 5fcf3ce44SJohn Forte * Common Development and Distribution License (the "License"). 6fcf3ce44SJohn Forte * You may not use this file except in compliance with the License. 7fcf3ce44SJohn Forte * 8fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing. 10fcf3ce44SJohn Forte * See the License for the specific language governing permissions 11fcf3ce44SJohn Forte * and limitations under the License. 12fcf3ce44SJohn Forte * 13fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each 14fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the 16fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying 17fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner] 18fcf3ce44SJohn Forte * 19fcf3ce44SJohn Forte * CDDL HEADER END 20fcf3ce44SJohn Forte */ 21fcf3ce44SJohn Forte 22fcf3ce44SJohn Forte /* 23291a2b48SSukumar Swaminathan * Copyright 2009 Emulex. All rights reserved. 24*82527734SSukumar Swaminathan * Use is subject to license terms. 25fcf3ce44SJohn Forte */ 26fcf3ce44SJohn Forte 27fcf3ce44SJohn Forte #ifndef _EMLXS_OS_H 28fcf3ce44SJohn Forte #define _EMLXS_OS_H 29fcf3ce44SJohn Forte 30fcf3ce44SJohn Forte #ifdef __cplusplus 31fcf3ce44SJohn Forte extern "C" { 32fcf3ce44SJohn Forte #endif 33fcf3ce44SJohn Forte 34291a2b48SSukumar Swaminathan #define EMLXS_MODREV2 2 /* Old Solaris 8 & 9 interface */ 35291a2b48SSukumar Swaminathan #define EMLXS_MODREV3 3 /* New Solaris 10 & 11 interface */ 36291a2b48SSukumar Swaminathan #define EMLXS_MODREV4 4 /* Sun FC packet change */ 37291a2b48SSukumar Swaminathan /* Symbolic Node Name interface */ 38291a2b48SSukumar Swaminathan #define EMLXS_MODREV5 5 /* New Sun NPIV Interface */ 39fcf3ce44SJohn Forte 40291a2b48SSukumar Swaminathan #define EMLXS_MODREV2X 2 /* Old Solaris 8 & 9 x86 interface */ 41291a2b48SSukumar Swaminathan #define EMLXS_MODREV3X 3 /* New Solaris 10 & 11 x86 interface */ 42fcf3ce44SJohn Forte 43fcf3ce44SJohn Forte 44fcf3ce44SJohn Forte /* 45291a2b48SSukumar Swaminathan * DRIVER LEVEL FEATURES 46fcf3ce44SJohn Forte */ 47fcf3ce44SJohn Forte #define DHCHAP_SUPPORT /* 2.21 driver */ 48fcf3ce44SJohn Forte 49fcf3ce44SJohn Forte #define SATURN_MSI_SUPPORT /* 2.30 driver */ 50fcf3ce44SJohn Forte #define MENLO_SUPPORT /* 2.30 driver */ 51fcf3ce44SJohn Forte #define MBOX_EXT_SUPPORT /* 2.30 driver */ 52fcf3ce44SJohn Forte 53291a2b48SSukumar Swaminathan #define DUMP_SUPPORT /* 2.40 driver */ 54291a2b48SSukumar Swaminathan #define SAN_DIAG_SUPPORT /* 2.40 driver */ 554baa2c25SSukumar Swaminathan #define FMA_SUPPORT /* 2.40 driver */ 56fcf3ce44SJohn Forte 57*82527734SSukumar Swaminathan #define SLI4_FASTPATH_DEBUG 58*82527734SSukumar Swaminathan 59291a2b48SSukumar Swaminathan /* #define IDLE_TIMER Not yet - untested */ 60fcf3ce44SJohn Forte 61fcf3ce44SJohn Forte /* 62291a2b48SSukumar Swaminathan * OS LEVEL FEATURES 63fcf3ce44SJohn Forte */ 64fcf3ce44SJohn Forte #ifdef S10 65291a2b48SSukumar Swaminathan #define EMLXS_MODREV EMLXS_MODREV3 66291a2b48SSukumar Swaminathan #define MSI_SUPPORT 67fcf3ce44SJohn Forte 68fcf3ce44SJohn Forte 69fcf3ce44SJohn Forte #ifdef EMLXS_I386 70291a2b48SSukumar Swaminathan #define EMLXS_MODREVX EMLXS_MODREV2X 71*82527734SSukumar Swaminathan #endif /* i386 */ 72fcf3ce44SJohn Forte #endif /* S10 */ 73fcf3ce44SJohn Forte 74fcf3ce44SJohn Forte 75fcf3ce44SJohn Forte #ifdef S11 76fcf3ce44SJohn Forte #define MSI_SUPPORT 77291a2b48SSukumar Swaminathan #define SFCT_SUPPORT /* COMSTAR Support */ 78291a2b48SSukumar Swaminathan #define MODFW_SUPPORT /* Dynamic firmware module support */ 79*82527734SSukumar Swaminathan #define EMLXS_MODREV EMLXS_MODREV5 /* Sun NPIV Enhancement */ 80fcf3ce44SJohn Forte 81fcf3ce44SJohn Forte #ifdef EMLXS_I386 82*82527734SSukumar Swaminathan #define EMLXS_MODREVX EMLXS_MODREV2X 83*82527734SSukumar Swaminathan #endif /* i386 */ 84fcf3ce44SJohn Forte #endif /* S11 */ 85fcf3ce44SJohn Forte 86fcf3ce44SJohn Forte /* 87291a2b48SSukumar Swaminathan * SUBFEATURES 88fcf3ce44SJohn Forte */ 89fcf3ce44SJohn Forte #ifdef SFCT_SUPPORT 90291a2b48SSukumar Swaminathan #define MODSYM_SUPPORT /* Dynamic Module Loading Support */ 91291a2b48SSukumar Swaminathan #define FCIO_SUPPORT /* FCIO IOCTL support */ 92291a2b48SSukumar Swaminathan #endif /* SFCT_SUPPORT */ 93fcf3ce44SJohn Forte 94fcf3ce44SJohn Forte 95fcf3ce44SJohn Forte #ifndef EMLXS_MODREV 96fcf3ce44SJohn Forte #define EMLXS_MODREV 0 97291a2b48SSukumar Swaminathan #endif /* EMLXS_MODREV */ 98fcf3ce44SJohn Forte 99fcf3ce44SJohn Forte #ifndef EMLXS_MODREVX 100fcf3ce44SJohn Forte #define EMLXS_MODREVX 0 101291a2b48SSukumar Swaminathan #endif /* EMLXS_MODREVX */ 102fcf3ce44SJohn Forte 103fcf3ce44SJohn Forte /* Create combined definition */ 104fcf3ce44SJohn Forte #if defined(S10) || defined(S11) 105fcf3ce44SJohn Forte #define S10S11 106291a2b48SSukumar Swaminathan #endif /* S10 or S11 */ 107fcf3ce44SJohn Forte 108291a2b48SSukumar Swaminathan #define DRIVER_NAME "emlxs" 109fcf3ce44SJohn Forte 110fcf3ce44SJohn Forte #include <sys/types.h> 111fcf3ce44SJohn Forte #include <sys/varargs.h> 112fcf3ce44SJohn Forte #include <sys/devops.h> 113fcf3ce44SJohn Forte #include <sys/param.h> 114fcf3ce44SJohn Forte #include <sys/user.h> 115fcf3ce44SJohn Forte #include <sys/buf.h> 116fcf3ce44SJohn Forte #include <sys/ioctl.h> 117fcf3ce44SJohn Forte #include <sys/uio.h> 118fcf3ce44SJohn Forte #include <sys/fcntl.h> 119fcf3ce44SJohn Forte 120fcf3ce44SJohn Forte #include <sys/cmn_err.h> 121fcf3ce44SJohn Forte #include <sys/stropts.h> 122fcf3ce44SJohn Forte #include <sys/kmem.h> 123fcf3ce44SJohn Forte 124fcf3ce44SJohn Forte #include <sys/errno.h> 125fcf3ce44SJohn Forte #include <sys/open.h> 126fcf3ce44SJohn Forte #include <sys/kmem.h> 127fcf3ce44SJohn Forte #include <sys/poll.h> 128fcf3ce44SJohn Forte #include <sys/thread.h> 129fcf3ce44SJohn Forte #include <sys/taskq.h> 130fcf3ce44SJohn Forte #include <sys/debug.h> 131fcf3ce44SJohn Forte #include <sys/cpu.h> 132fcf3ce44SJohn Forte #include <sys/autoconf.h> 133fcf3ce44SJohn Forte #include <sys/conf.h> 134fcf3ce44SJohn Forte #include <sys/stat.h> 135fcf3ce44SJohn Forte #include <sys/var.h> 136fcf3ce44SJohn Forte 137fcf3ce44SJohn Forte #include <sys/map.h> 138fcf3ce44SJohn Forte #include <sys/file.h> 139fcf3ce44SJohn Forte #include <sys/syslog.h> 140fcf3ce44SJohn Forte #include <sys/disp.h> 141fcf3ce44SJohn Forte #include <sys/taskq.h> 142fcf3ce44SJohn Forte 143fcf3ce44SJohn Forte #include <sys/ddi.h> 144fcf3ce44SJohn Forte #include <sys/sunddi.h> 145fcf3ce44SJohn Forte #include <sys/promif.h> 146fcf3ce44SJohn Forte #include <sys/ethernet.h> 147fcf3ce44SJohn Forte #include <vm/seg_kmem.h> 148fcf3ce44SJohn Forte #include <sys/utsname.h> 149fcf3ce44SJohn Forte #include <sys/modctl.h> 150fcf3ce44SJohn Forte #include <sys/scsi/scsi.h> 151fcf3ce44SJohn Forte #include <sys/varargs.h> 152fcf3ce44SJohn Forte #include <sys/atomic.h> 153fcf3ce44SJohn Forte 154fcf3ce44SJohn Forte #include <emlxs_hbaapi.h> 155fcf3ce44SJohn Forte 156291a2b48SSukumar Swaminathan #ifdef FMA_SUPPORT 157291a2b48SSukumar Swaminathan #include <sys/ddifm.h> 158291a2b48SSukumar Swaminathan #include <sys/fm/protocol.h> 159291a2b48SSukumar Swaminathan #include <sys/fm/util.h> 160291a2b48SSukumar Swaminathan #endif /* FMA_SUPPORT */ 161291a2b48SSukumar Swaminathan #include <sys/fm/io/ddi.h> 162fcf3ce44SJohn Forte 163fcf3ce44SJohn Forte #ifdef S11 164fcf3ce44SJohn Forte 165fcf3ce44SJohn Forte /* ULP header files */ 166fcf3ce44SJohn Forte #include <sys/fibre-channel/fc.h> 167fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_fcaif.h> 168fcf3ce44SJohn Forte 169fcf3ce44SJohn Forte #else /* !S11 */ 170fcf3ce44SJohn Forte 171fcf3ce44SJohn Forte /* ULP header files */ 172fcf3ce44SJohn Forte #include <sys/fibre-channel/fcio.h> 173fcf3ce44SJohn Forte #include <sys/fibre-channel/fc.h> 174fcf3ce44SJohn Forte #include <sys/fibre-channel/fc_appif.h> 175fcf3ce44SJohn Forte #include <sys/fibre-channel/fc_types.h> 176fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_error.h> 177fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_fla.h> 178fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_linkapp.h> 179fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fcal.h> 180fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fcgs2.h> 181fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fcph.h> 182fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_ulpif.h> 183fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fc_fcaif.h> 184fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fctl.h> 185fcf3ce44SJohn Forte #include <sys/fibre-channel/impl/fctl_private.h> 186fcf3ce44SJohn Forte #include <sys/fibre-channel/ulp/fcp.h> 187fcf3ce44SJohn Forte #include <sys/fibre-channel/ulp/fcp_util.h> 188fcf3ce44SJohn Forte 189fcf3ce44SJohn Forte #endif /* S11 */ 190fcf3ce44SJohn Forte 191fcf3ce44SJohn Forte #ifndef FC_HBA_PORTSPEED_8GBIT 192fcf3ce44SJohn Forte #define FC_HBA_PORTSPEED_8GBIT 16 193fcf3ce44SJohn Forte #endif /* FC_HBA_PORTSPEED_8GBIT */ 194fcf3ce44SJohn Forte 195fcf3ce44SJohn Forte #ifndef FP_DEFAULT_SID 196fcf3ce44SJohn Forte #define FP_DEFAULT_SID (0x000AE) 197fcf3ce44SJohn Forte #endif /* FP_DEFAULT_SID */ 198fcf3ce44SJohn Forte 199fcf3ce44SJohn Forte #ifndef FP_DEFAULT_DID 200fcf3ce44SJohn Forte #define FP_DEFAULT_DID (0x000EA) 201fcf3ce44SJohn Forte #endif /* FP_DEFAULT_DID */ 202fcf3ce44SJohn Forte 203fcf3ce44SJohn Forte #ifdef MSI_SUPPORT 204fcf3ce44SJohn Forte #pragma weak ddi_intr_get_supported_types 205fcf3ce44SJohn Forte #pragma weak ddi_intr_get_nintrs 206fcf3ce44SJohn Forte #pragma weak ddi_intr_add_handler 207fcf3ce44SJohn Forte #pragma weak ddi_intr_remove_handler 208fcf3ce44SJohn Forte #pragma weak ddi_intr_get_hilevel_pri 209fcf3ce44SJohn Forte #pragma weak ddi_intr_enable 210fcf3ce44SJohn Forte #pragma weak ddi_intr_disable 211fcf3ce44SJohn Forte #pragma weak ddi_intr_get_cap 212fcf3ce44SJohn Forte #pragma weak ddi_intr_get_pri 213fcf3ce44SJohn Forte #pragma weak ddi_intr_alloc 214fcf3ce44SJohn Forte #pragma weak ddi_intr_free 215fcf3ce44SJohn Forte #pragma weak ddi_intr_block_enable 216fcf3ce44SJohn Forte #pragma weak ddi_intr_block_disable 217fcf3ce44SJohn Forte extern int ddi_intr_get_supported_types(); 218fcf3ce44SJohn Forte #endif /* MSI_SUPPORT */ 219fcf3ce44SJohn Forte 220fcf3ce44SJohn Forte #ifndef MODSYM_SUPPORT 221fcf3ce44SJohn Forte #pragma weak fc_fca_init 222fcf3ce44SJohn Forte #pragma weak fc_fca_attach 223fcf3ce44SJohn Forte #pragma weak fc_fca_detach 224291a2b48SSukumar Swaminathan #endif /* MODSYM_SUPPORT */ 225fcf3ce44SJohn Forte 226fcf3ce44SJohn Forte /* S11 flag for dma_attr_flags for ddi_dma_attr_t */ 227fcf3ce44SJohn Forte #ifndef DDI_DMA_RELAXED_ORDERING 228fcf3ce44SJohn Forte #define DDI_DMA_RELAXED_ORDERING 0x400 229fcf3ce44SJohn Forte #endif /* DDI_DMA_RELAXED_ORDERING */ 230fcf3ce44SJohn Forte 231291a2b48SSukumar Swaminathan #ifdef FMA_SUPPORT 232291a2b48SSukumar Swaminathan /* FMA Support */ 233291a2b48SSukumar Swaminathan #pragma weak ddi_fm_acc_err_clear 234bb63f56eSSukumar Swaminathan extern void ddi_fm_acc_err_clear(); 235291a2b48SSukumar Swaminathan #endif /* FMA_SUPPORT */ 236fcf3ce44SJohn Forte 237fcf3ce44SJohn Forte #ifdef EMLXS_SPARC 238fcf3ce44SJohn Forte #define EMLXS_BIG_ENDIAN 239fcf3ce44SJohn Forte #endif /* EMLXS_SPARC */ 240fcf3ce44SJohn Forte 241fcf3ce44SJohn Forte #ifdef EMLXS_I386 242fcf3ce44SJohn Forte #define EMLXS_LITTLE_ENDIAN 243fcf3ce44SJohn Forte #endif /* EMLXS_I386 */ 244fcf3ce44SJohn Forte 245fcf3ce44SJohn Forte 246fcf3ce44SJohn Forte /* Solaris 8 does not define this */ 247fcf3ce44SJohn Forte #ifndef TASKQ_DYNAMIC 248291a2b48SSukumar Swaminathan #define TASKQ_DYNAMIC 0x0004 249fcf3ce44SJohn Forte #endif /* TASKQ_DYNAMIC */ 250fcf3ce44SJohn Forte 251fcf3ce44SJohn Forte #ifdef _LP64 252291a2b48SSukumar Swaminathan #define DEAD_PTR 0xdeadbeefdeadbeef 253fcf3ce44SJohn Forte #else 254291a2b48SSukumar Swaminathan #define DEAD_PTR 0xdeadbeef 255fcf3ce44SJohn Forte #endif /* _LP64 */ 256fcf3ce44SJohn Forte 257fcf3ce44SJohn Forte #ifndef FC_STATE_8GBIT_SPEED 258fcf3ce44SJohn Forte /* This was obtained from OpenSolaris */ 259fcf3ce44SJohn Forte #define FC_STATE_8GBIT_SPEED 0x0700 /* 8 Gbit/sec */ 260fcf3ce44SJohn Forte #endif /* FC_STATE_8GBIT_SPEED */ 261fcf3ce44SJohn Forte 262fcf3ce44SJohn Forte #define FC_STATE_QUAD_SPEED 0x0500 263fcf3ce44SJohn Forte 264fcf3ce44SJohn Forte #ifndef BURSTSIZE 265fcf3ce44SJohn Forte #define BURSTSIZE 266291a2b48SSukumar Swaminathan #define BURST1 0x01 267291a2b48SSukumar Swaminathan #define BURST2 0x02 268291a2b48SSukumar Swaminathan #define BURST4 0x04 269291a2b48SSukumar Swaminathan #define BURST8 0x08 270291a2b48SSukumar Swaminathan #define BURST16 0x10 271291a2b48SSukumar Swaminathan #define BURST32 0x20 272291a2b48SSukumar Swaminathan #define BURST64 0x40 273fcf3ce44SJohn Forte #ifdef _LP64 274291a2b48SSukumar Swaminathan #define BURSTSIZE_MASK 0x7f 275fcf3ce44SJohn Forte #else 276291a2b48SSukumar Swaminathan #define BURSTSIZE_MASK 0x3f 277fcf3ce44SJohn Forte #endif /* _LP64 */ 278fcf3ce44SJohn Forte #define DEFAULT_BURSTSIZE (BURSTSIZE_MASK) /* all burst sizes */ 279fcf3ce44SJohn Forte #endif /* BURSTSIZE */ 280fcf3ce44SJohn Forte 281*82527734SSukumar Swaminathan #define PADDR_LO(addr) ((uint32_t)(((uint64_t)(addr)) & 0xffffffff)) 282*82527734SSukumar Swaminathan #define PADDR_HI(addr) ((uint32_t)(((uint64_t)(addr)) >> 32)) 283*82527734SSukumar Swaminathan #define PADDR(high, low) ((uint64_t)((((uint64_t)(high)) << 32) \ 284291a2b48SSukumar Swaminathan | (((uint64_t)(low)) & 0xffffffff))) 285fcf3ce44SJohn Forte 286fcf3ce44SJohn Forte #ifndef TRUE 287fcf3ce44SJohn Forte #define TRUE 1 288fcf3ce44SJohn Forte #endif /* TRUE */ 289fcf3ce44SJohn Forte 290fcf3ce44SJohn Forte #ifndef FALSE 291fcf3ce44SJohn Forte #define FALSE 0 292fcf3ce44SJohn Forte #endif /* FALSE */ 293fcf3ce44SJohn Forte 294291a2b48SSukumar Swaminathan #define DMA_READ_WRITE 0 295291a2b48SSukumar Swaminathan #define DMA_READ_ONLY 1 296291a2b48SSukumar Swaminathan #define DMA_WRITE_ONLY 2 297fcf3ce44SJohn Forte 298291a2b48SSukumar Swaminathan #define DMA_SUCC 1 299fcf3ce44SJohn Forte 300291a2b48SSukumar Swaminathan #define MAX_FC_BRDS 256 /* Maximum # boards per system */ 301fcf3ce44SJohn Forte 302fcf3ce44SJohn Forte #define DELAYMS(ms) drv_usecwait((ms*1000)) 303fcf3ce44SJohn Forte #define DELAYUS(us) drv_usecwait(us) 304fcf3ce44SJohn Forte 305291a2b48SSukumar Swaminathan #ifdef FMA_SUPPORT 306*82527734SSukumar Swaminathan #define EMLXS_MPDATA_SYNC(h, a, b, c) \ 307291a2b48SSukumar Swaminathan if (h) { \ 308291a2b48SSukumar Swaminathan (void) ddi_dma_sync((ddi_dma_handle_t)(h), \ 309291a2b48SSukumar Swaminathan (off_t)(a), (size_t)(b), (uint_t)c); \ 310bb63f56eSSukumar Swaminathan if (emlxs_fm_check_dma_handle(hba, h) != DDI_FM_OK) { \ 311bb63f56eSSukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT, \ 312bb63f56eSSukumar Swaminathan &emlxs_invalid_dma_handle_msg, \ 313bb63f56eSSukumar Swaminathan "ddi_dma_sync hdl=%p off=%x " \ 314bb63f56eSSukumar Swaminathan "size=%d dir=%x ", \ 315bb63f56eSSukumar Swaminathan h, a, b, c); \ 316291a2b48SSukumar Swaminathan } \ 317291a2b48SSukumar Swaminathan } 318291a2b48SSukumar Swaminathan #else /* !FMA_SUPPORT */ 319*82527734SSukumar Swaminathan #define EMLXS_MPDATA_SYNC(h, a, b, c) \ 320291a2b48SSukumar Swaminathan if (h) { \ 321291a2b48SSukumar Swaminathan (void) ddi_dma_sync((ddi_dma_handle_t)(h), \ 322291a2b48SSukumar Swaminathan (off_t)(a), (size_t)(b), (uint_t)c); \ 323fcf3ce44SJohn Forte } 324291a2b48SSukumar Swaminathan #endif /* FMA_SUPPORT */ 325fcf3ce44SJohn Forte 326fcf3ce44SJohn Forte 327fcf3ce44SJohn Forte #define PKT2PRIV(pkt) ((emlxs_buf_t *)(pkt)->pkt_fca_private) 328fcf3ce44SJohn Forte #define PRIV2PKT(sbp) sbp->pkt 329fcf3ce44SJohn Forte 330fcf3ce44SJohn Forte #define EMLXS_INUMBER 0 331fcf3ce44SJohn Forte #define EMLXS_MSI_INUMBER 0 332fcf3ce44SJohn Forte 333fcf3ce44SJohn Forte #define EMLXS_DMA_ALIGN BURST16 334fcf3ce44SJohn Forte 335fcf3ce44SJohn Forte /* 336291a2b48SSukumar Swaminathan * Register indices in PCI configuration space. 337fcf3ce44SJohn Forte */ 338291a2b48SSukumar Swaminathan #define SBUS_FLASH_RD 0 /* FCODE-Flash Read only */ 339291a2b48SSukumar Swaminathan /* index */ 340291a2b48SSukumar Swaminathan #define SBUS_FLASH_RDWR 1 /* FCODE-Flash Read/Write */ 341291a2b48SSukumar Swaminathan /* index */ 342291a2b48SSukumar Swaminathan #define SBUS_DFLY_SLIM_RINDEX 2 /* DragonFly SLIM regs index */ 343291a2b48SSukumar Swaminathan #define SBUS_DFLY_CSR_RINDEX 3 /* DragonFly I/O regs index */ 344291a2b48SSukumar Swaminathan #define SBUS_TITAN_CORE_RINDEX 4 /* TITAN Core register index */ 345291a2b48SSukumar Swaminathan #define SBUS_DFLY_PCI_CFG_RINDEX 5 /* DragonFly PCI ConfigSpace */ 346291a2b48SSukumar Swaminathan /* regs index */ 347291a2b48SSukumar Swaminathan #define SBUS_TITAN_PCI_CFG_RINDEX 6 /* TITAN PCI ConfigSpace regs */ 348291a2b48SSukumar Swaminathan /* index */ 349291a2b48SSukumar Swaminathan #define SBUS_TITAN_CSR_RINDEX 7 /* TITAN Control/Status regs */ 350291a2b48SSukumar Swaminathan /* index */ 351291a2b48SSukumar Swaminathan 352291a2b48SSukumar Swaminathan #define PCI_CFG_RINDEX 0 353291a2b48SSukumar Swaminathan #define PCI_SLIM_RINDEX 1 354291a2b48SSukumar Swaminathan #define PCI_CSR_RINDEX 2 355fcf3ce44SJohn Forte 356*82527734SSukumar Swaminathan #define PCI_BAR1_RINDEX 2 357*82527734SSukumar Swaminathan #define PCI_BAR2_RINDEX 3 358*82527734SSukumar Swaminathan 359*82527734SSukumar Swaminathan 360fcf3ce44SJohn Forte #define EMLXS_MAX_UBUFS 65535 361fcf3ce44SJohn Forte 362fcf3ce44SJohn Forte /* Tokens < EMLXS_UB_TOKEN_OFFSET are reserved for ELS response oxids */ 363291a2b48SSukumar Swaminathan #define EMLXS_UB_TOKEN_OFFSET 0x100 364fcf3ce44SJohn Forte 365291a2b48SSukumar Swaminathan typedef struct emlxs_ub_priv 366291a2b48SSukumar Swaminathan { 367291a2b48SSukumar Swaminathan fc_unsol_buf_t *ubp; 368291a2b48SSukumar Swaminathan void *port; 369fcf3ce44SJohn Forte 370291a2b48SSukumar Swaminathan uint32_t bpl_size; 371291a2b48SSukumar Swaminathan uint8_t *bpl_virt; /* virtual address ptr */ 372291a2b48SSukumar Swaminathan uint64_t bpl_phys; /* mapped address */ 373291a2b48SSukumar Swaminathan void *bpl_data_handle; 374291a2b48SSukumar Swaminathan void *bpl_dma_handle; 375fcf3ce44SJohn Forte 376291a2b48SSukumar Swaminathan uint32_t ip_ub_size; 377291a2b48SSukumar Swaminathan uint8_t *ip_ub_virt; /* virtual address ptr */ 378fcf3ce44SJohn Forte ddi_dma_cookie_t ip_ub_dma_cookies[64]; 379fcf3ce44SJohn Forte ddi_acc_handle_t ip_ub_data_handle; 380fcf3ce44SJohn Forte ddi_dma_handle_t ip_ub_dma_handle; 381291a2b48SSukumar Swaminathan uint32_t ip_ub_cookie_cnt; 382291a2b48SSukumar Swaminathan uint32_t FC4type; 383fcf3ce44SJohn Forte 384291a2b48SSukumar Swaminathan uint16_t flags; 385fcf3ce44SJohn Forte #define EMLXS_UB_FREE 0x0000 386fcf3ce44SJohn Forte #define EMLXS_UB_IN_USE 0x0001 387fcf3ce44SJohn Forte #define EMLXS_UB_REPLY 0x0002 388fcf3ce44SJohn Forte #define EMLXS_UB_RESV 0x0004 389fcf3ce44SJohn Forte #define EMLXS_UB_TIMEOUT 0x0008 390fcf3ce44SJohn Forte #define EMLXS_UB_INTERCEPT 0x0010 391fcf3ce44SJohn Forte 392291a2b48SSukumar Swaminathan uint16_t available; 393fcf3ce44SJohn Forte 394291a2b48SSukumar Swaminathan uint32_t timeout; /* Timeout period in seconds */ 395291a2b48SSukumar Swaminathan uint32_t time; /* EMLXS_UB_IN_USE timestamp */ 396291a2b48SSukumar Swaminathan uint32_t cmd; 397291a2b48SSukumar Swaminathan uint32_t token; 398fcf3ce44SJohn Forte 399fcf3ce44SJohn Forte struct emlxs_unsol_buf *pool; 400fcf3ce44SJohn Forte struct emlxs_ub_priv *next; 401fcf3ce44SJohn Forte } emlxs_ub_priv_t; 402fcf3ce44SJohn Forte 403fcf3ce44SJohn Forte 404291a2b48SSukumar Swaminathan typedef struct emlxs_unsol_buf 405291a2b48SSukumar Swaminathan { 406291a2b48SSukumar Swaminathan struct emlxs_unsol_buf *pool_prev; /* ptr to prev type */ 407291a2b48SSukumar Swaminathan /* of unsol_buf hdr */ 408291a2b48SSukumar Swaminathan struct emlxs_unsol_buf *pool_next; /* ptr to next type */ 409291a2b48SSukumar Swaminathan /* of unsol_buf hdr */ 410fcf3ce44SJohn Forte 411291a2b48SSukumar Swaminathan uint32_t pool_type; /* FC-4 type */ 412291a2b48SSukumar Swaminathan uint32_t pool_buf_size; /* buffer size for */ 413291a2b48SSukumar Swaminathan /* this pool */ 414fcf3ce44SJohn Forte 415291a2b48SSukumar Swaminathan uint32_t pool_nentries; /* no. of bufs in */ 416291a2b48SSukumar Swaminathan /* pool */ 417291a2b48SSukumar Swaminathan uint32_t pool_available; /* no. of bufs avail */ 418291a2b48SSukumar Swaminathan /* in pool */ 419fcf3ce44SJohn Forte 420291a2b48SSukumar Swaminathan uint32_t pool_flags; 421291a2b48SSukumar Swaminathan #define POOL_DESTROY 0x00000001 /* Pool is marked for */ 422291a2b48SSukumar Swaminathan /* destruction */ 423fcf3ce44SJohn Forte 424291a2b48SSukumar Swaminathan uint32_t pool_free; /* Number of free */ 425291a2b48SSukumar Swaminathan /* buffers */ 426291a2b48SSukumar Swaminathan uint32_t pool_free_resv; /* Number of free */ 427291a2b48SSukumar Swaminathan /* reserved buffers */ 428fcf3ce44SJohn Forte 429291a2b48SSukumar Swaminathan uint32_t pool_first_token; /* First token */ 430291a2b48SSukumar Swaminathan /* in pool */ 431291a2b48SSukumar Swaminathan uint32_t pool_last_token; /* Last token */ 432291a2b48SSukumar Swaminathan /* in pool */ 433fcf3ce44SJohn Forte 434291a2b48SSukumar Swaminathan fc_unsol_buf_t *fc_ubufs; /* array of unsol buf */ 435291a2b48SSukumar Swaminathan /* structs */ 436fcf3ce44SJohn Forte } emlxs_unsol_buf_t; 437fcf3ce44SJohn Forte 438fcf3ce44SJohn Forte 439fcf3ce44SJohn Forte #ifndef FC_REASON_NONE 440fcf3ce44SJohn Forte #define FC_REASON_NONE 0 441291a2b48SSukumar Swaminathan #endif /* FC_REASON_NONE */ 442fcf3ce44SJohn Forte 443fcf3ce44SJohn Forte #ifndef FC_ACTION_NONE 444fcf3ce44SJohn Forte #define FC_ACTION_NONE 0 445291a2b48SSukumar Swaminathan #endif /* FC_ACTION_NONE */ 446fcf3ce44SJohn Forte 447fcf3ce44SJohn Forte /* 448fcf3ce44SJohn Forte * emlx status translation table 449fcf3ce44SJohn Forte */ 450291a2b48SSukumar Swaminathan typedef struct emlxs_xlat_err 451291a2b48SSukumar Swaminathan { 452291a2b48SSukumar Swaminathan uint32_t emlxs_status; 453291a2b48SSukumar Swaminathan uint32_t pkt_state; 454291a2b48SSukumar Swaminathan uint32_t pkt_reason; 455291a2b48SSukumar Swaminathan uint32_t pkt_expln; 456291a2b48SSukumar Swaminathan uint32_t pkt_action; 457fcf3ce44SJohn Forte } emlxs_xlat_err_t; 458fcf3ce44SJohn Forte 459fcf3ce44SJohn Forte 460291a2b48SSukumar Swaminathan typedef struct emlxs_table 461291a2b48SSukumar Swaminathan { 462291a2b48SSukumar Swaminathan uint32_t code; 463291a2b48SSukumar Swaminathan char string[32]; 464fcf3ce44SJohn Forte } emlxs_table_t; 465fcf3ce44SJohn Forte 466*82527734SSukumar Swaminathan 467*82527734SSukumar Swaminathan /* PATCH MASK DEFINES */ 468*82527734SSukumar Swaminathan #define EMLXS_PATCH1 0x00000001 469*82527734SSukumar Swaminathan #define EMLXS_PATCH2 0x00000002 470*82527734SSukumar Swaminathan #define EMLXS_PATCH3 0x00000004 471*82527734SSukumar Swaminathan #define EMLXS_PATCH4 0x00000008 472*82527734SSukumar Swaminathan #define EMLXS_PATCH5 0x00000010 473*82527734SSukumar Swaminathan #define EMLXS_PATCH6 0x00000020 474*82527734SSukumar Swaminathan #define EMLXS_PATCH7 0x00000040 475*82527734SSukumar Swaminathan #define EMLXS_PATCH8 0x00000080 476*82527734SSukumar Swaminathan #define EMLXS_PATCH9 0x00000100 477*82527734SSukumar Swaminathan #define EMLXS_PATCH10 0x00000200 478*82527734SSukumar Swaminathan #define EMLXS_PATCH11 0x00000400 479*82527734SSukumar Swaminathan #define EMLXS_PATCH12 0x00000800 480*82527734SSukumar Swaminathan #define EMLXS_PATCH13 0x00001000 481*82527734SSukumar Swaminathan #define EMLXS_PATCH14 0x00002000 482*82527734SSukumar Swaminathan #define EMLXS_PATCH15 0x00004000 483*82527734SSukumar Swaminathan #define EMLXS_PATCH16 0x00008000 484*82527734SSukumar Swaminathan #define EMLXS_PATCH17 0x00010000 485*82527734SSukumar Swaminathan #define EMLXS_PATCH18 0x00020000 486*82527734SSukumar Swaminathan #define EMLXS_PATCH19 0x00040000 487*82527734SSukumar Swaminathan #define EMLXS_PATCH20 0x00080000 488*82527734SSukumar Swaminathan #define EMLXS_PATCH21 0x00100000 489*82527734SSukumar Swaminathan #define EMLXS_PATCH22 0x00200000 490*82527734SSukumar Swaminathan #define EMLXS_PATCH23 0x00400000 491*82527734SSukumar Swaminathan #define EMLXS_PATCH24 0x00800000 492*82527734SSukumar Swaminathan #define EMLXS_PATCH25 0x01000000 493*82527734SSukumar Swaminathan #define EMLXS_PATCH26 0x02000000 494*82527734SSukumar Swaminathan #define EMLXS_PATCH27 0x04000000 495*82527734SSukumar Swaminathan #define EMLXS_PATCH28 0x08000000 496*82527734SSukumar Swaminathan #define EMLXS_PATCH29 0x10000000 497*82527734SSukumar Swaminathan #define EMLXS_PATCH30 0x20000000 498*82527734SSukumar Swaminathan #define EMLXS_PATCH31 0x40000000 499*82527734SSukumar Swaminathan #define EMLXS_PATCH32 0x80000000 500*82527734SSukumar Swaminathan 501*82527734SSukumar Swaminathan 502*82527734SSukumar Swaminathan /* ULP Patches: */ 503*82527734SSukumar Swaminathan 504*82527734SSukumar Swaminathan /* This patch enables the driver to auto respond to unsolicited LOGO's */ 505*82527734SSukumar Swaminathan /* This is needed because ULP is sometimes doesn't reply itself */ 506*82527734SSukumar Swaminathan #define ULP_PATCH2 EMLXS_PATCH2 507*82527734SSukumar Swaminathan 508*82527734SSukumar Swaminathan /* This patch enables the driver to auto respond to unsolicited PRLI's */ 509*82527734SSukumar Swaminathan /* This is needed because ULP is known to panic sometimes */ 510*82527734SSukumar Swaminathan #define ULP_PATCH3 EMLXS_PATCH3 511*82527734SSukumar Swaminathan 512*82527734SSukumar Swaminathan /* This patch enables the driver to auto respond to unsolicited PRLO's */ 513*82527734SSukumar Swaminathan /* This is needed because ULP is known to panic sometimes */ 514*82527734SSukumar Swaminathan #define ULP_PATCH4 EMLXS_PATCH4 515*82527734SSukumar Swaminathan 516*82527734SSukumar Swaminathan /* This patch enables the driver to fail pkt abort requests */ 517*82527734SSukumar Swaminathan #define ULP_PATCH5 EMLXS_PATCH5 518*82527734SSukumar Swaminathan 519*82527734SSukumar Swaminathan /* This patch enables the driver to generate an RSCN for unsolicited PRLO's */ 520*82527734SSukumar Swaminathan /* and LOGO's */ 521*82527734SSukumar Swaminathan #define ULP_PATCH6 EMLXS_PATCH6 522*82527734SSukumar Swaminathan 523*82527734SSukumar Swaminathan /* Sun Disk Array Patches: */ 524*82527734SSukumar Swaminathan 525*82527734SSukumar Swaminathan /* This patch enables the driver to fix a residual underrun issue with */ 526*82527734SSukumar Swaminathan /* check conditions */ 527*82527734SSukumar Swaminathan #define FCP_UNDERRUN_PATCH1 EMLXS_PATCH9 528*82527734SSukumar Swaminathan 529*82527734SSukumar Swaminathan /* This patch enables the driver to fix a residual underrun issue with */ 530*82527734SSukumar Swaminathan /* SCSI inquiry commands */ 531*82527734SSukumar Swaminathan #define FCP_UNDERRUN_PATCH2 EMLXS_PATCH10 532*82527734SSukumar Swaminathan 533*82527734SSukumar Swaminathan 534*82527734SSukumar Swaminathan #define DEFAULT_PATCHES (ULP_PATCH2 | ULP_PATCH3 | \ 535*82527734SSukumar Swaminathan ULP_PATCH5 | ULP_PATCH6 | \ 536*82527734SSukumar Swaminathan FCP_UNDERRUN_PATCH1 | FCP_UNDERRUN_PATCH2) 537*82527734SSukumar Swaminathan 538fcf3ce44SJohn Forte #ifdef __cplusplus 539fcf3ce44SJohn Forte } 540fcf3ce44SJohn Forte #endif 541fcf3ce44SJohn Forte 542fcf3ce44SJohn Forte #endif /* _EMLXS_OS_H */ 543