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 */ 2969b5a878SDan McDonald /* 30*0b656ad1SRobert Mustacchi * Copyright (c) 2017, Joyent, Inc. 317e579c30SDale Ghent * Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved. 3269b5a878SDan McDonald */ 339da57d7bSbt150084 349da57d7bSbt150084 #ifndef _IXGBE_OSDEP_H 359da57d7bSbt150084 #define _IXGBE_OSDEP_H 369da57d7bSbt150084 379da57d7bSbt150084 #ifdef __cplusplus 389da57d7bSbt150084 extern "C" { 399da57d7bSbt150084 #endif 409da57d7bSbt150084 419da57d7bSbt150084 #include <sys/types.h> 4273cd555cSBin Tu - Sun Microsystems - Beijing China #include <sys/byteorder.h> 439da57d7bSbt150084 #include <sys/conf.h> 449da57d7bSbt150084 #include <sys/debug.h> 459da57d7bSbt150084 #include <sys/stropts.h> 469da57d7bSbt150084 #include <sys/stream.h> 479da57d7bSbt150084 #include <sys/strlog.h> 489da57d7bSbt150084 #include <sys/kmem.h> 499da57d7bSbt150084 #include <sys/stat.h> 509da57d7bSbt150084 #include <sys/kstat.h> 519da57d7bSbt150084 #include <sys/modctl.h> 529da57d7bSbt150084 #include <sys/errno.h> 539da57d7bSbt150084 #include <sys/ddi.h> 549da57d7bSbt150084 #include <sys/dditypes.h> 559da57d7bSbt150084 #include <sys/sunddi.h> 569da57d7bSbt150084 #include <sys/pci.h> 579da57d7bSbt150084 #include <sys/atomic.h> 589da57d7bSbt150084 #include <sys/note.h> 599da57d7bSbt150084 #include "ixgbe_debug.h" 609da57d7bSbt150084 6169b5a878SDan McDonald /* Cheesy hack for EWARN() */ 6269b5a878SDan McDonald #define EWARN(H, W, S) cmn_err(CE_NOTE, W) 6369b5a878SDan McDonald 649da57d7bSbt150084 /* function declarations */ 659da57d7bSbt150084 struct ixgbe_hw; 669da57d7bSbt150084 uint16_t ixgbe_read_pci_cfg(struct ixgbe_hw *, uint32_t); 6773cd555cSBin Tu - Sun Microsystems - Beijing China void ixgbe_write_pci_cfg(struct ixgbe_hw *, uint32_t, uint32_t); 68*0b656ad1SRobert Mustacchi boolean_t ixgbe_removed(struct ixgbe_hw *); 699da57d7bSbt150084 709da57d7bSbt150084 #define usec_delay(x) drv_usecwait(x) 719da57d7bSbt150084 #define msec_delay(x) drv_usecwait(x * 1000) 729da57d7bSbt150084 739da57d7bSbt150084 #define OS_DEP(hw) ((struct ixgbe_osdep *)((hw)->back)) 749da57d7bSbt150084 7513740cb2SPaul Guo #define false B_FALSE 7613740cb2SPaul Guo #define true B_TRUE 7763b3bba8SJerry Jelinek #define FALSE B_FALSE 7863b3bba8SJerry Jelinek #define TRUE B_TRUE 799da57d7bSbt150084 809da57d7bSbt150084 #define IXGBE_READ_PCIE_WORD ixgbe_read_pci_cfg 8173cd555cSBin Tu - Sun Microsystems - Beijing China #define IXGBE_WRITE_PCIE_WORD ixgbe_write_pci_cfg 829da57d7bSbt150084 #define CMD_MEM_WRT_INVALIDATE 0x0010 /* BIT_4 */ 839da57d7bSbt150084 #define PCI_COMMAND_REGISTER 0x04 849da57d7bSbt150084 #define PCI_EX_CONF_CAP 0xE0 859da57d7bSbt150084 #define SPEED_10GB 10000 867e579c30SDale Ghent #define SPEED_5GB 5000 877e579c30SDale Ghent #define SPEED_2_5GB 2500 889da57d7bSbt150084 #define SPEED_1GB 1000 899da57d7bSbt150084 #define SPEED_100 100 909da57d7bSbt150084 #define FULL_DUPLEX 2 919da57d7bSbt150084 929da57d7bSbt150084 #define IXGBE_WRITE_FLUSH(a) (void) IXGBE_READ_REG(a, IXGBE_STATUS) 939da57d7bSbt150084 949da57d7bSbt150084 #define IXGBE_WRITE_REG(a, reg, value) \ 9513740cb2SPaul Guo ddi_put32((OS_DEP(a))->reg_handle, \ 9613740cb2SPaul Guo (uint32_t *)((uintptr_t)(a)->hw_addr + reg), (value)) 979da57d7bSbt150084 985b6dd21fSchenlu chen - Sun Microsystems - Beijing China #define IXGBE_WRITE_REG_ARRAY(a, reg, index, value) \ 995b6dd21fSchenlu chen - Sun Microsystems - Beijing China IXGBE_WRITE_REG(a, ((reg) + ((index) << 2)), (value)) 1005b6dd21fSchenlu chen - Sun Microsystems - Beijing China 1019da57d7bSbt150084 #define IXGBE_READ_REG(a, reg) \ 10213740cb2SPaul Guo ddi_get32((OS_DEP(a))->reg_handle, \ 10313740cb2SPaul Guo (uint32_t *)((uintptr_t)(a)->hw_addr + reg)) 1049da57d7bSbt150084 1055b6dd21fSchenlu chen - Sun Microsystems - Beijing China #define IXGBE_READ_REG_ARRAY(a, reg, index) \ 1065b6dd21fSchenlu chen - Sun Microsystems - Beijing China IXGBE_READ_REG(a, ((reg) + ((index) << 2))) 1075b6dd21fSchenlu chen - Sun Microsystems - Beijing China 1089da57d7bSbt150084 #define msec_delay_irq msec_delay 10973cd555cSBin Tu - Sun Microsystems - Beijing China #define IXGBE_HTONL htonl 11063b3bba8SJerry Jelinek #define IXGBE_NTOHL ntohl 11163b3bba8SJerry Jelinek #define IXGBE_NTOHS ntohs 1129da57d7bSbt150084 11369b5a878SDan McDonald #ifdef _BIG_ENDIAN 11469b5a878SDan McDonald #define IXGBE_CPU_TO_LE32 BSWAP_32 11569b5a878SDan McDonald #define IXGBE_LE32_TO_CPUS BSWAP_32 116d73cb28fSIgor Kozhukhov #define IXGBE_CPU_TO_BE16(x) (x) 117d73cb28fSIgor Kozhukhov #define IXGBE_CPU_TO_BE32(x) (x) 11869b5a878SDan McDonald #else 11969b5a878SDan McDonald #define IXGBE_CPU_TO_LE32(x) (x) 12069b5a878SDan McDonald #define IXGBE_LE32_TO_CPUS(x) (x) 1217e579c30SDale Ghent #define IXGBE_CPU_TO_BE16 BSWAP_16 1227e579c30SDale Ghent #define IXGBE_CPU_TO_BE32 BSWAP_32 12369b5a878SDan McDonald #endif /* _BIG_ENDIAN */ 12469b5a878SDan McDonald 1259da57d7bSbt150084 #define UNREFERENCED_PARAMETER(x) _NOTE(ARGUNUSED(x)) 12669b5a878SDan McDonald #define UNREFERENCED_1PARAMETER(_p) UNREFERENCED_PARAMETER(_p) 12769b5a878SDan McDonald #define UNREFERENCED_2PARAMETER(_p, _q) _NOTE(ARGUNUSED(_p, _q)) 12869b5a878SDan McDonald #define UNREFERENCED_3PARAMETER(_p, _q, _r) _NOTE(ARGUNUSED(_p, _q, _r)) 12969b5a878SDan McDonald #define UNREFERENCED_4PARAMETER(_p, _q, _r, _s) _NOTE(ARGUNUSED(_p, _q,_r, _s)) 13069b5a878SDan McDonald 13169b5a878SDan McDonald 132*0b656ad1SRobert Mustacchi #define IXGBE_REMOVED(hw) ixgbe_removed(hw) 1339da57d7bSbt150084 1349da57d7bSbt150084 typedef int8_t s8; 1359da57d7bSbt150084 typedef int16_t s16; 1369da57d7bSbt150084 typedef int32_t s32; 1379da57d7bSbt150084 typedef int64_t s64; 1389da57d7bSbt150084 typedef uint8_t u8; 1399da57d7bSbt150084 typedef uint16_t u16; 1409da57d7bSbt150084 typedef uint32_t u32; 1419da57d7bSbt150084 typedef uint64_t u64; 1429da57d7bSbt150084 typedef boolean_t bool; 1439da57d7bSbt150084 1447e579c30SDale Ghent /* shared code requires this */ 1457e579c30SDale Ghent #define __le16 u16 1467e579c30SDale Ghent #define __le32 u32 1477e579c30SDale Ghent #define __le64 u64 1487e579c30SDale Ghent #define __be16 u16 1497e579c30SDale Ghent #define __be32 u32 1507e579c30SDale Ghent #define __be64 u64 1517e579c30SDale Ghent 1529da57d7bSbt150084 struct ixgbe_osdep { 1539da57d7bSbt150084 ddi_acc_handle_t reg_handle; 1549da57d7bSbt150084 ddi_acc_handle_t cfg_handle; 1559da57d7bSbt150084 struct ixgbe *ixgbe; 1569da57d7bSbt150084 }; 1579da57d7bSbt150084 1589da57d7bSbt150084 #ifdef __cplusplus 1599da57d7bSbt150084 } 1609da57d7bSbt150084 #endif 1619da57d7bSbt150084 1629da57d7bSbt150084 #endif /* _IXGBE_OSDEP_H */ 163