16621Sbt150084 /* 26621Sbt150084 * CDDL HEADER START 36621Sbt150084 * 46621Sbt150084 * The contents of this file are subject to the terms of the 56621Sbt150084 * Common Development and Distribution License (the "License"). 66621Sbt150084 * You may not use this file except in compliance with the License. 76621Sbt150084 * 811878SVenu.Iyer@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 911878SVenu.Iyer@Sun.COM * or http://www.opensolaris.org/os/licensing. 106621Sbt150084 * See the License for the specific language governing permissions 116621Sbt150084 * and limitations under the License. 126621Sbt150084 * 1311878SVenu.Iyer@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 1411878SVenu.Iyer@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 156621Sbt150084 * If applicable, add the following below this CDDL HEADER, with the 166621Sbt150084 * fields enclosed by brackets "[]" replaced with your own identifying 176621Sbt150084 * information: Portions Copyright [yyyy] [name of copyright owner] 186621Sbt150084 * 196621Sbt150084 * CDDL HEADER END 206621Sbt150084 */ 216621Sbt150084 226621Sbt150084 /* 23*13006SChenlu.Chen@Sun.COM * Copyright(c) 2007-2010 Intel Corporation. All rights reserved. 24*13006SChenlu.Chen@Sun.COM */ 25*13006SChenlu.Chen@Sun.COM 26*13006SChenlu.Chen@Sun.COM /* 27*13006SChenlu.Chen@Sun.COM * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 286621Sbt150084 */ 296621Sbt150084 306621Sbt150084 #ifndef _IXGBE_OSDEP_H 316621Sbt150084 #define _IXGBE_OSDEP_H 326621Sbt150084 336621Sbt150084 #ifdef __cplusplus 346621Sbt150084 extern "C" { 356621Sbt150084 #endif 366621Sbt150084 376621Sbt150084 #include <sys/types.h> 389353SSamuel.Tu@Sun.COM #include <sys/byteorder.h> 396621Sbt150084 #include <sys/conf.h> 406621Sbt150084 #include <sys/debug.h> 416621Sbt150084 #include <sys/stropts.h> 426621Sbt150084 #include <sys/stream.h> 436621Sbt150084 #include <sys/strlog.h> 446621Sbt150084 #include <sys/kmem.h> 456621Sbt150084 #include <sys/stat.h> 466621Sbt150084 #include <sys/kstat.h> 476621Sbt150084 #include <sys/modctl.h> 486621Sbt150084 #include <sys/errno.h> 496621Sbt150084 #include <sys/ddi.h> 506621Sbt150084 #include <sys/dditypes.h> 516621Sbt150084 #include <sys/sunddi.h> 526621Sbt150084 #include <sys/pci.h> 536621Sbt150084 #include <sys/atomic.h> 546621Sbt150084 #include <sys/note.h> 556621Sbt150084 #include "ixgbe_debug.h" 566621Sbt150084 576621Sbt150084 /* function declarations */ 586621Sbt150084 struct ixgbe_hw; 596621Sbt150084 uint16_t ixgbe_read_pci_cfg(struct ixgbe_hw *, uint32_t); 609353SSamuel.Tu@Sun.COM void ixgbe_write_pci_cfg(struct ixgbe_hw *, uint32_t, uint32_t); 616621Sbt150084 626621Sbt150084 #define usec_delay(x) drv_usecwait(x) 636621Sbt150084 #define msec_delay(x) drv_usecwait(x * 1000) 646621Sbt150084 656621Sbt150084 #define OS_DEP(hw) ((struct ixgbe_osdep *)((hw)->back)) 666621Sbt150084 678490SPaul.Guo@Sun.COM #define false B_FALSE 688490SPaul.Guo@Sun.COM #define true B_TRUE 696621Sbt150084 706621Sbt150084 #define IXGBE_READ_PCIE_WORD ixgbe_read_pci_cfg 719353SSamuel.Tu@Sun.COM #define IXGBE_WRITE_PCIE_WORD ixgbe_write_pci_cfg 726621Sbt150084 #define CMD_MEM_WRT_INVALIDATE 0x0010 /* BIT_4 */ 736621Sbt150084 #define PCI_COMMAND_REGISTER 0x04 746621Sbt150084 #define PCI_EX_CONF_CAP 0xE0 756621Sbt150084 #define SPEED_10GB 10000 766621Sbt150084 #define SPEED_1GB 1000 776621Sbt150084 #define SPEED_100 100 786621Sbt150084 #define FULL_DUPLEX 2 796621Sbt150084 806621Sbt150084 #define IXGBE_WRITE_FLUSH(a) (void) IXGBE_READ_REG(a, IXGBE_STATUS) 816621Sbt150084 826621Sbt150084 #define IXGBE_WRITE_REG(a, reg, value) \ 838490SPaul.Guo@Sun.COM ddi_put32((OS_DEP(a))->reg_handle, \ 848490SPaul.Guo@Sun.COM (uint32_t *)((uintptr_t)(a)->hw_addr + reg), (value)) 856621Sbt150084 86*13006SChenlu.Chen@Sun.COM #define IXGBE_WRITE_REG_ARRAY(a, reg, index, value) \ 87*13006SChenlu.Chen@Sun.COM IXGBE_WRITE_REG(a, ((reg) + ((index) << 2)), (value)) 88*13006SChenlu.Chen@Sun.COM 896621Sbt150084 #define IXGBE_READ_REG(a, reg) \ 908490SPaul.Guo@Sun.COM ddi_get32((OS_DEP(a))->reg_handle, \ 918490SPaul.Guo@Sun.COM (uint32_t *)((uintptr_t)(a)->hw_addr + reg)) 926621Sbt150084 93*13006SChenlu.Chen@Sun.COM #define IXGBE_READ_REG_ARRAY(a, reg, index) \ 94*13006SChenlu.Chen@Sun.COM IXGBE_READ_REG(a, ((reg) + ((index) << 2))) 95*13006SChenlu.Chen@Sun.COM 969353SSamuel.Tu@Sun.COM #define IXGBE_WRITE_REG64(hw, reg, value) \ 979353SSamuel.Tu@Sun.COM do { \ 989353SSamuel.Tu@Sun.COM IXGBE_WRITE_REG(hw, reg, (u32) value); \ 999353SSamuel.Tu@Sun.COM IXGBE_WRITE_REG(hw, reg + 4, (u32) (value >> 32)); \ 1009353SSamuel.Tu@Sun.COM _NOTE(CONSTCOND) \ 1019353SSamuel.Tu@Sun.COM } while (0) 1029353SSamuel.Tu@Sun.COM 1036621Sbt150084 #define msec_delay_irq msec_delay 1049353SSamuel.Tu@Sun.COM #define IXGBE_HTONL htonl 1056621Sbt150084 1066621Sbt150084 #define UNREFERENCED_PARAMETER(x) _NOTE(ARGUNUSED(x)) 1076621Sbt150084 1086621Sbt150084 typedef int8_t s8; 1096621Sbt150084 typedef int16_t s16; 1106621Sbt150084 typedef int32_t s32; 1116621Sbt150084 typedef int64_t s64; 1126621Sbt150084 typedef uint8_t u8; 1136621Sbt150084 typedef uint16_t u16; 1146621Sbt150084 typedef uint32_t u32; 1156621Sbt150084 typedef uint64_t u64; 1166621Sbt150084 typedef boolean_t bool; 1176621Sbt150084 1186621Sbt150084 struct ixgbe_osdep { 1196621Sbt150084 ddi_acc_handle_t reg_handle; 1206621Sbt150084 ddi_acc_handle_t cfg_handle; 1216621Sbt150084 struct ixgbe *ixgbe; 1226621Sbt150084 }; 1236621Sbt150084 1246621Sbt150084 #ifdef __cplusplus 1256621Sbt150084 } 1266621Sbt150084 #endif 1276621Sbt150084 1286621Sbt150084 #endif /* _IXGBE_OSDEP_H */ 129