19da57d7bSbt150084 /* 29da57d7bSbt150084 * CDDL HEADER START 39da57d7bSbt150084 * 49da57d7bSbt150084 * The contents of this file are subject to the terms of the 59da57d7bSbt150084 * Common Development and Distribution License (the "License"). 69da57d7bSbt150084 * You may not use this file except in compliance with the License. 79da57d7bSbt150084 * 80dc2366fSVenugopal Iyer * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90dc2366fSVenugopal Iyer * or http://www.opensolaris.org/os/licensing. 109da57d7bSbt150084 * See the License for the specific language governing permissions 119da57d7bSbt150084 * and limitations under the License. 129da57d7bSbt150084 * 130dc2366fSVenugopal Iyer * When distributing Covered Code, include this CDDL HEADER in each 140dc2366fSVenugopal Iyer * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159da57d7bSbt150084 * If applicable, add the following below this CDDL HEADER, with the 169da57d7bSbt150084 * fields enclosed by brackets "[]" replaced with your own identifying 179da57d7bSbt150084 * information: Portions Copyright [yyyy] [name of copyright owner] 189da57d7bSbt150084 * 199da57d7bSbt150084 * CDDL HEADER END 209da57d7bSbt150084 */ 219da57d7bSbt150084 229da57d7bSbt150084 /* 235b6dd21fSchenlu chen - Sun Microsystems - Beijing China * Copyright(c) 2007-2010 Intel Corporation. All rights reserved. 245b6dd21fSchenlu chen - Sun Microsystems - Beijing China */ 255b6dd21fSchenlu chen - Sun Microsystems - Beijing China 265b6dd21fSchenlu chen - Sun Microsystems - Beijing China /* 275b6dd21fSchenlu chen - Sun Microsystems - Beijing China * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 289da57d7bSbt150084 */ 29*69b5a878SDan McDonald /* 30*69b5a878SDan McDonald * Copyright (c) 2012, Joyent, Inc. All rights reserved. 31*69b5a878SDan McDonald */ 329da57d7bSbt150084 339da57d7bSbt150084 #ifndef _IXGBE_OSDEP_H 349da57d7bSbt150084 #define _IXGBE_OSDEP_H 359da57d7bSbt150084 369da57d7bSbt150084 #ifdef __cplusplus 379da57d7bSbt150084 extern "C" { 389da57d7bSbt150084 #endif 399da57d7bSbt150084 409da57d7bSbt150084 #include <sys/types.h> 4173cd555cSBin Tu - Sun Microsystems - Beijing China #include <sys/byteorder.h> 429da57d7bSbt150084 #include <sys/conf.h> 439da57d7bSbt150084 #include <sys/debug.h> 449da57d7bSbt150084 #include <sys/stropts.h> 459da57d7bSbt150084 #include <sys/stream.h> 469da57d7bSbt150084 #include <sys/strlog.h> 479da57d7bSbt150084 #include <sys/kmem.h> 489da57d7bSbt150084 #include <sys/stat.h> 499da57d7bSbt150084 #include <sys/kstat.h> 509da57d7bSbt150084 #include <sys/modctl.h> 519da57d7bSbt150084 #include <sys/errno.h> 529da57d7bSbt150084 #include <sys/ddi.h> 539da57d7bSbt150084 #include <sys/dditypes.h> 549da57d7bSbt150084 #include <sys/sunddi.h> 559da57d7bSbt150084 #include <sys/pci.h> 569da57d7bSbt150084 #include <sys/atomic.h> 579da57d7bSbt150084 #include <sys/note.h> 589da57d7bSbt150084 #include "ixgbe_debug.h" 599da57d7bSbt150084 60*69b5a878SDan McDonald /* Cheesy hack for EWARN() */ 61*69b5a878SDan McDonald #define EWARN(H, W, S) cmn_err(CE_NOTE, W) 62*69b5a878SDan McDonald 639da57d7bSbt150084 /* function declarations */ 649da57d7bSbt150084 struct ixgbe_hw; 659da57d7bSbt150084 uint16_t ixgbe_read_pci_cfg(struct ixgbe_hw *, uint32_t); 6673cd555cSBin Tu - Sun Microsystems - Beijing China void ixgbe_write_pci_cfg(struct ixgbe_hw *, uint32_t, uint32_t); 679da57d7bSbt150084 689da57d7bSbt150084 #define usec_delay(x) drv_usecwait(x) 699da57d7bSbt150084 #define msec_delay(x) drv_usecwait(x * 1000) 709da57d7bSbt150084 719da57d7bSbt150084 #define OS_DEP(hw) ((struct ixgbe_osdep *)((hw)->back)) 729da57d7bSbt150084 7313740cb2SPaul Guo #define false B_FALSE 7413740cb2SPaul Guo #define true B_TRUE 7563b3bba8SJerry Jelinek #define FALSE B_FALSE 7663b3bba8SJerry Jelinek #define TRUE B_TRUE 779da57d7bSbt150084 789da57d7bSbt150084 #define IXGBE_READ_PCIE_WORD ixgbe_read_pci_cfg 7973cd555cSBin Tu - Sun Microsystems - Beijing China #define IXGBE_WRITE_PCIE_WORD ixgbe_write_pci_cfg 809da57d7bSbt150084 #define CMD_MEM_WRT_INVALIDATE 0x0010 /* BIT_4 */ 819da57d7bSbt150084 #define PCI_COMMAND_REGISTER 0x04 829da57d7bSbt150084 #define PCI_EX_CONF_CAP 0xE0 839da57d7bSbt150084 #define SPEED_10GB 10000 849da57d7bSbt150084 #define SPEED_1GB 1000 859da57d7bSbt150084 #define SPEED_100 100 869da57d7bSbt150084 #define FULL_DUPLEX 2 879da57d7bSbt150084 889da57d7bSbt150084 #define IXGBE_WRITE_FLUSH(a) (void) IXGBE_READ_REG(a, IXGBE_STATUS) 899da57d7bSbt150084 909da57d7bSbt150084 #define IXGBE_WRITE_REG(a, reg, value) \ 9113740cb2SPaul Guo ddi_put32((OS_DEP(a))->reg_handle, \ 9213740cb2SPaul Guo (uint32_t *)((uintptr_t)(a)->hw_addr + reg), (value)) 939da57d7bSbt150084 945b6dd21fSchenlu chen - Sun Microsystems - Beijing China #define IXGBE_WRITE_REG_ARRAY(a, reg, index, value) \ 955b6dd21fSchenlu chen - Sun Microsystems - Beijing China IXGBE_WRITE_REG(a, ((reg) + ((index) << 2)), (value)) 965b6dd21fSchenlu chen - Sun Microsystems - Beijing China 979da57d7bSbt150084 #define IXGBE_READ_REG(a, reg) \ 9813740cb2SPaul Guo ddi_get32((OS_DEP(a))->reg_handle, \ 9913740cb2SPaul Guo (uint32_t *)((uintptr_t)(a)->hw_addr + reg)) 1009da57d7bSbt150084 1015b6dd21fSchenlu chen - Sun Microsystems - Beijing China #define IXGBE_READ_REG_ARRAY(a, reg, index) \ 1025b6dd21fSchenlu chen - Sun Microsystems - Beijing China IXGBE_READ_REG(a, ((reg) + ((index) << 2))) 1035b6dd21fSchenlu chen - Sun Microsystems - Beijing China 1049da57d7bSbt150084 #define msec_delay_irq msec_delay 10573cd555cSBin Tu - Sun Microsystems - Beijing China #define IXGBE_HTONL htonl 10663b3bba8SJerry Jelinek #define IXGBE_NTOHL ntohl 10763b3bba8SJerry Jelinek #define IXGBE_NTOHS ntohs 1089da57d7bSbt150084 109*69b5a878SDan McDonald #ifdef _BIG_ENDIAN 110*69b5a878SDan McDonald #define IXGBE_CPU_TO_LE32 BSWAP_32 111*69b5a878SDan McDonald #define IXGBE_LE32_TO_CPUS BSWAP_32 112*69b5a878SDan McDonald #else 113*69b5a878SDan McDonald #define IXGBE_CPU_TO_LE32(x) (x) 114*69b5a878SDan McDonald #define IXGBE_LE32_TO_CPUS(x) (x) 115*69b5a878SDan McDonald #endif /* _BIG_ENDIAN */ 116*69b5a878SDan McDonald 1179da57d7bSbt150084 #define UNREFERENCED_PARAMETER(x) _NOTE(ARGUNUSED(x)) 118*69b5a878SDan McDonald #define UNREFERENCED_1PARAMETER(_p) UNREFERENCED_PARAMETER(_p) 119*69b5a878SDan McDonald #define UNREFERENCED_2PARAMETER(_p, _q) _NOTE(ARGUNUSED(_p, _q)) 120*69b5a878SDan McDonald #define UNREFERENCED_3PARAMETER(_p, _q, _r) _NOTE(ARGUNUSED(_p, _q, _r)) 121*69b5a878SDan McDonald #define UNREFERENCED_4PARAMETER(_p, _q, _r, _s) _NOTE(ARGUNUSED(_p, _q,_r, _s)) 122*69b5a878SDan McDonald 123*69b5a878SDan McDonald 1249da57d7bSbt150084 1259da57d7bSbt150084 typedef int8_t s8; 1269da57d7bSbt150084 typedef int16_t s16; 1279da57d7bSbt150084 typedef int32_t s32; 1289da57d7bSbt150084 typedef int64_t s64; 1299da57d7bSbt150084 typedef uint8_t u8; 1309da57d7bSbt150084 typedef uint16_t u16; 1319da57d7bSbt150084 typedef uint32_t u32; 1329da57d7bSbt150084 typedef uint64_t u64; 1339da57d7bSbt150084 typedef boolean_t bool; 1349da57d7bSbt150084 1359da57d7bSbt150084 struct ixgbe_osdep { 1369da57d7bSbt150084 ddi_acc_handle_t reg_handle; 1379da57d7bSbt150084 ddi_acc_handle_t cfg_handle; 1389da57d7bSbt150084 struct ixgbe *ixgbe; 1399da57d7bSbt150084 }; 1409da57d7bSbt150084 1419da57d7bSbt150084 #ifdef __cplusplus 1429da57d7bSbt150084 } 1439da57d7bSbt150084 #endif 1449da57d7bSbt150084 1459da57d7bSbt150084 #endif /* _IXGBE_OSDEP_H */ 146