144961713Sgirish /* 244961713Sgirish * CDDL HEADER START 344961713Sgirish * 444961713Sgirish * The contents of this file are subject to the terms of the 544961713Sgirish * Common Development and Distribution License (the "License"). 644961713Sgirish * You may not use this file except in compliance with the License. 744961713Sgirish * 844961713Sgirish * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 944961713Sgirish * or http://www.opensolaris.org/os/licensing. 1044961713Sgirish * See the License for the specific language governing permissions 1144961713Sgirish * and limitations under the License. 1244961713Sgirish * 1344961713Sgirish * When distributing Covered Code, include this CDDL HEADER in each 1444961713Sgirish * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1544961713Sgirish * If applicable, add the following below this CDDL HEADER, with the 1644961713Sgirish * fields enclosed by brackets "[]" replaced with your own identifying 1744961713Sgirish * information: Portions Copyright [yyyy] [name of copyright owner] 1844961713Sgirish * 1944961713Sgirish * CDDL HEADER END 2044961713Sgirish */ 2144961713Sgirish /* 22*4df55fdeSJanie Lu * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 2344961713Sgirish * Use is subject to license terms. 2444961713Sgirish */ 2544961713Sgirish 268fca0570Sjf #ifndef _SYS_NIUMX_VAR_H 278fca0570Sjf #define _SYS_NIUMX_VAR_H 2844961713Sgirish 2944961713Sgirish #ifdef __cplusplus 3044961713Sgirish extern "C" { 3144961713Sgirish #endif 3244961713Sgirish 3344961713Sgirish typedef enum { /* same sequence as niumx_debug_sym[] */ 3444961713Sgirish /* 0 */ DBG_ATTACH, 3544961713Sgirish /* 1 */ DBG_MAP, 3644961713Sgirish /* 2 */ DBG_CTLOPS, 3744961713Sgirish /* 3 */ DBG_INTROPS, 3844961713Sgirish /* 4 */ DBG_A_INTX, 3944961713Sgirish /* 5 */ DBG_R_INTX, 4044961713Sgirish /* 6 */ DBG_INTR, 4144961713Sgirish /* 7 */ DBG_DMA_ALLOCH, 4244961713Sgirish /* 8 */ DBG_DMA_BINDH, 4344961713Sgirish /* 9 */ DBG_DMA_UNBINDH, 4444961713Sgirish /* 10 */ DBG_CHK_MOD 4544961713Sgirish } niumx_debug_bit_t; 4644961713Sgirish 4744961713Sgirish #if defined(DEBUG) 4844961713Sgirish #define DBG niumx_dbg 4944961713Sgirish extern void niumx_dbg(niumx_debug_bit_t bit, dev_info_t *dip, char *fmt, ...); 5044961713Sgirish #else 5144961713Sgirish #define DBG 0 && 5244961713Sgirish #endif /* DEBUG */ 5344961713Sgirish 5444961713Sgirish typedef uint64_t devhandle_t; 5544961713Sgirish #define NIUMX_DEVHDLE_MASK 0xFFFFFFF 5644961713Sgirish typedef uint32_t cpuid_t; 5744961713Sgirish typedef uint32_t devino_t; 5844961713Sgirish typedef uint64_t sysino_t; 5944961713Sgirish 6044961713Sgirish /* 6144961713Sgirish * The following structure represents an interrupt handler control block for 6244961713Sgirish * each interrupt added via ddi_intr_add_handler(). 6344961713Sgirish */ 6444961713Sgirish typedef struct niumx_ih { 6544961713Sgirish dev_info_t *ih_dip; /* devinfo structure */ 6644961713Sgirish uint32_t ih_inum; /* interrupt index, from leaf */ 6744961713Sgirish sysino_t ih_sysino; /* System virtual inumber, from HV */ 6844961713Sgirish cpuid_t ih_cpuid; /* cpu that ino is targeting */ 6944961713Sgirish uint_t (*ih_hdlr)(); /* interrupt handler */ 7044961713Sgirish caddr_t ih_arg1; /* interrupt handler argument #1 */ 7144961713Sgirish caddr_t ih_arg2; /* interrupt handler argument #2 */ 7244961713Sgirish struct niumx_ih *ih_next; /* next in the chain */ 7344961713Sgirish } niumx_ih_t; 7444961713Sgirish 75*4df55fdeSJanie Lu #define NIUMX_MAX_INTRS 64 76*4df55fdeSJanie Lu 7744961713Sgirish typedef struct niumx_devstate { 7844961713Sgirish dev_info_t *dip; 7944961713Sgirish devhandle_t niumx_dev_hdl; /* device handle */ 8044961713Sgirish kmutex_t niumx_mutex; 8114ea4bb7Ssd int niumx_fm_cap; 8214ea4bb7Ssd ddi_iblock_cookie_t niumx_fm_ibc; 83*4df55fdeSJanie Lu niumx_ih_t niumx_ihtable[NIUMX_MAX_INTRS]; 8444961713Sgirish } niumx_devstate_t; 8544961713Sgirish 8644961713Sgirish /* 8744961713Sgirish * flags for overloading dmai_inuse field of the dma request structure: 8844961713Sgirish */ 8944961713Sgirish #define dmai_pfnlst dmai_iopte 9044961713Sgirish #define dmai_pfn0 dmai_sbi 9144961713Sgirish #define dmai_roffset dmai_pool 9244961713Sgirish 9344961713Sgirish #define NIUMX_PAGE_SHIFT 13 9444961713Sgirish #define NIUMX_PAGE_SIZE (1 << NIUMX_PAGE_SHIFT) 9544961713Sgirish #define NIUMX_PAGE_MASK ~(NIUMX_PAGE_SIZE - 1) 9644961713Sgirish #define NIUMX_PAGE_OFFSET (NIUMX_PAGE_SIZE - 1) 9744961713Sgirish #define NIUMX_PTOB(x) (((uint64_t)(x)) << NIUMX_PAGE_SHIFT) 9844961713Sgirish 9944961713Sgirish /* for "ranges" property */ 10044961713Sgirish typedef struct niumx_ranges { 10144961713Sgirish uint32_t child_hi; 10244961713Sgirish uint32_t child_lo; 10344961713Sgirish uint32_t parent_hi; 10444961713Sgirish uint32_t parent_lo; 10544961713Sgirish uint32_t size_hi; 10644961713Sgirish uint32_t size_lo; 10744961713Sgirish } niumx_ranges_t; 10844961713Sgirish 10944961713Sgirish /* IPL of 6 for networking devices */ 11044961713Sgirish #define NIUMX_DEFAULT_PIL 6 11144961713Sgirish 11244961713Sgirish typedef struct { 11344961713Sgirish uint32_t addr_high; 11444961713Sgirish uint32_t addr_low; 11544961713Sgirish uint32_t size_high; 11644961713Sgirish uint32_t size_low; 11744961713Sgirish } niu_regspec_t; 11844961713Sgirish 11944961713Sgirish /* 1203266dff7Sjf * HV INTR API versioning. 12144961713Sgirish * 1223266dff7Sjf * Currently NIU nexus driver supports version 1.0 12344961713Sgirish */ 12444961713Sgirish #define NIUMX_INTR_MAJOR_VER_1 0x1ull 12544961713Sgirish #define NIUMX_INTR_MAJOR_VER NIUMX_INTR_MAJOR_VER_1 12644961713Sgirish 12744961713Sgirish #define NIUMX_INTR_MINOR_VER_0 0x0ull 12844961713Sgirish #define NIUMX_INTR_MINOR_VER NIUMX_INTR_MINOR_VER_0 12944961713Sgirish 13044961713Sgirish #define NAMEINST(dip) ddi_driver_name(dip), ddi_get_instance(dip) 13144961713Sgirish #define DIP_TO_HANDLE(dip) \ 13244961713Sgirish ((niumx_devstate_t *)DIP_TO_STATE(dip))->niumx_dev_hdl 13344961713Sgirish #define DIP_TO_INST(dip) ddi_get_instance(dip) 13444961713Sgirish #define INST_TO_STATE(inst) ddi_get_soft_state(niumx_state, inst) 13544961713Sgirish #define DIP_TO_STATE(dip) INST_TO_STATE(DIP_TO_INST(dip)) 13644961713Sgirish 13744961713Sgirish #ifdef __cplusplus 13844961713Sgirish } 13944961713Sgirish #endif 14044961713Sgirish 1418fca0570Sjf #endif /* _SYS_NIUMX_VAR_H */ 142