1 /* 2 * CDDL HEADER START 3 * 4 * Copyright(c) 2007-2008 Intel Corporation. All rights reserved. 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at: 10 * http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When using or redistributing this file, you may do so under the 15 * License only. No other modification of this header is permitted. 16 * 17 * If applicable, add the following below this CDDL HEADER, with the 18 * fields enclosed by brackets "[]" replaced with your own identifying 19 * information: Portions Copyright [yyyy] [name of copyright owner] 20 * 21 * CDDL HEADER END 22 */ 23 24 /* 25 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms of the CDDL. 27 */ 28 29 #ifndef _IXGBE_OSDEP_H 30 #define _IXGBE_OSDEP_H 31 32 #pragma ident "%Z%%M% %I% %E% SMI" 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 #include <sys/types.h> 39 #include <sys/conf.h> 40 #include <sys/debug.h> 41 #include <sys/stropts.h> 42 #include <sys/stream.h> 43 #include <sys/strlog.h> 44 #include <sys/kmem.h> 45 #include <sys/stat.h> 46 #include <sys/kstat.h> 47 #include <sys/modctl.h> 48 #include <sys/errno.h> 49 #include <sys/ddi.h> 50 #include <sys/dditypes.h> 51 #include <sys/sunddi.h> 52 #include <sys/pci.h> 53 #include <sys/atomic.h> 54 #include <sys/note.h> 55 #include "ixgbe_debug.h" 56 57 /* function declarations */ 58 struct ixgbe_hw; 59 uint16_t ixgbe_read_pci_cfg(struct ixgbe_hw *, uint32_t); 60 61 62 #define usec_delay(x) drv_usecwait(x) 63 #define msec_delay(x) drv_usecwait(x * 1000) 64 65 #ifdef IXGBE_DEBUG 66 #define DEBUGOUT(S) IXGBE_DEBUGLOG_0(NULL, S) 67 #define DEBUGOUT1(S, A) IXGBE_DEBUGLOG_1(NULL, S, A) 68 #define DEBUGOUT2(S, A, B) IXGBE_DEBUGLOG_2(NULL, S, A, B) 69 #define DEBUGOUT3(S, A, B, C) IXGBE_DEBUGLOG_3(NULL, S, A, B, C) 70 #define DEBUGOUT6(S, A, B, C, D, E, F) \ 71 IXGBE_DEBUGLOG_6(NULL, S, A, B, C, D, E, F) 72 #define DEBUGFUNC(F) IXGBE_DEBUGLOG_1(NULL, "Entering %s", F) 73 #else 74 #define DEBUGOUT(S) 75 #define DEBUGOUT1(S, A) 76 #define DEBUGOUT2(S, A, B) 77 #define DEBUGOUT3(S, A, B, C) 78 #define DEBUGOUT6(S, A, B, C, D, E, F) 79 #define DEBUGFUNC(F) 80 #endif 81 82 #define OS_DEP(hw) ((struct ixgbe_osdep *)((hw)->back)) 83 84 #define FALSE 0 85 #define TRUE 1 86 87 #define IXGBE_READ_PCIE_WORD ixgbe_read_pci_cfg 88 #define CMD_MEM_WRT_INVALIDATE 0x0010 /* BIT_4 */ 89 #define PCI_COMMAND_REGISTER 0x04 90 #define PCI_EX_CONF_CAP 0xE0 91 #define MAX_NUM_UNICAST_ADDRESSES 0x10 92 #define MAX_NUM_MULTICAST_ADDRESSES 0x1000 93 #define SPEED_10GB 10000 94 #define SPEED_1GB 1000 95 #define SPEED_100 100 96 #define FULL_DUPLEX 2 97 98 #define IXGBE_WRITE_FLUSH(a) (void) IXGBE_READ_REG(a, IXGBE_STATUS) 99 100 #define IXGBE_WRITE_REG(a, reg, value) \ 101 ddi_put32((OS_DEP(hw))->reg_handle, \ 102 (uint32_t *)((uintptr_t)(hw)->hw_addr + reg), (value)) 103 104 #define IXGBE_READ_REG(a, reg) \ 105 ddi_get32((OS_DEP(hw))->reg_handle, \ 106 (uint32_t *)((uintptr_t)(hw)->hw_addr + reg)) 107 108 #define msec_delay_irq msec_delay 109 110 #define UNREFERENCED_PARAMETER(x) _NOTE(ARGUNUSED(x)) 111 112 typedef int8_t s8; 113 typedef int16_t s16; 114 typedef int32_t s32; 115 typedef int64_t s64; 116 typedef uint8_t u8; 117 typedef uint16_t u16; 118 typedef uint32_t u32; 119 typedef uint64_t u64; 120 typedef boolean_t bool; 121 122 struct ixgbe_osdep { 123 ddi_acc_handle_t reg_handle; 124 ddi_acc_handle_t cfg_handle; 125 struct ixgbe *ixgbe; 126 }; 127 128 #ifdef __cplusplus 129 } 130 #endif 131 132 #endif /* _IXGBE_OSDEP_H */ 133