19da57d7bSbt /*
29da57d7bSbt  * CDDL HEADER START
39da57d7bSbt  *
4*73cd555cSBin Tu - Sun Microsystems - Beijing China  * Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
59da57d7bSbt  * The contents of this file are subject to the terms of the
69da57d7bSbt  * Common Development and Distribution License (the "License").
79da57d7bSbt  * You may not use this file except in compliance with the License.
89da57d7bSbt  *
99da57d7bSbt  * You can obtain a copy of the license at:
109da57d7bSbt  *      http://www.opensolaris.org/os/licensing.
119da57d7bSbt  * See the License for the specific language governing permissions
129da57d7bSbt  * and limitations under the License.
139da57d7bSbt  *
149da57d7bSbt  * When using or redistributing this file, you may do so under the
159da57d7bSbt  * License only. No other modification of this header is permitted.
169da57d7bSbt  *
179da57d7bSbt  * If applicable, add the following below this CDDL HEADER, with the
189da57d7bSbt  * fields enclosed by brackets "[]" replaced with your own identifying
199da57d7bSbt  * information: Portions Copyright [yyyy] [name of copyright owner]
209da57d7bSbt  *
219da57d7bSbt  * CDDL HEADER END
229da57d7bSbt  */
239da57d7bSbt 
249da57d7bSbt /*
2513740cb2SPaul Guo  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
26*73cd555cSBin Tu - Sun Microsystems - Beijing China  * Use is subject to license terms.
279da57d7bSbt  */
289da57d7bSbt 
299da57d7bSbt #ifndef	_IXGBE_OSDEP_H
309da57d7bSbt #define	_IXGBE_OSDEP_H
319da57d7bSbt 
329da57d7bSbt #ifdef __cplusplus
339da57d7bSbt extern "C" {
349da57d7bSbt #endif
359da57d7bSbt 
369da57d7bSbt #include <sys/types.h>
37*73cd555cSBin Tu - Sun Microsystems - Beijing China #include <sys/byteorder.h>
389da57d7bSbt #include <sys/conf.h>
399da57d7bSbt #include <sys/debug.h>
409da57d7bSbt #include <sys/stropts.h>
419da57d7bSbt #include <sys/stream.h>
429da57d7bSbt #include <sys/strlog.h>
439da57d7bSbt #include <sys/kmem.h>
449da57d7bSbt #include <sys/stat.h>
459da57d7bSbt #include <sys/kstat.h>
469da57d7bSbt #include <sys/modctl.h>
479da57d7bSbt #include <sys/errno.h>
489da57d7bSbt #include <sys/ddi.h>
499da57d7bSbt #include <sys/dditypes.h>
509da57d7bSbt #include <sys/sunddi.h>
519da57d7bSbt #include <sys/pci.h>
529da57d7bSbt #include <sys/atomic.h>
539da57d7bSbt #include <sys/note.h>
549da57d7bSbt #include "ixgbe_debug.h"
559da57d7bSbt 
569da57d7bSbt /* function declarations */
579da57d7bSbt struct ixgbe_hw;
589da57d7bSbt uint16_t ixgbe_read_pci_cfg(struct ixgbe_hw *, uint32_t);
59*73cd555cSBin Tu - Sun Microsystems - Beijing China void ixgbe_write_pci_cfg(struct ixgbe_hw *, uint32_t, uint32_t);
609da57d7bSbt 
619da57d7bSbt #define	usec_delay(x)		drv_usecwait(x)
629da57d7bSbt #define	msec_delay(x)		drv_usecwait(x * 1000)
639da57d7bSbt 
649da57d7bSbt #define	OS_DEP(hw)		((struct ixgbe_osdep *)((hw)->back))
659da57d7bSbt 
6613740cb2SPaul Guo #define	false		B_FALSE
6713740cb2SPaul Guo #define	true		B_TRUE
689da57d7bSbt 
699da57d7bSbt #define	IXGBE_READ_PCIE_WORD 	ixgbe_read_pci_cfg
70*73cd555cSBin Tu - Sun Microsystems - Beijing China #define	IXGBE_WRITE_PCIE_WORD 	ixgbe_write_pci_cfg
719da57d7bSbt #define	CMD_MEM_WRT_INVALIDATE	0x0010	/* BIT_4 */
729da57d7bSbt #define	PCI_COMMAND_REGISTER	0x04
739da57d7bSbt #define	PCI_EX_CONF_CAP		0xE0
749da57d7bSbt #define	MAX_NUM_UNICAST_ADDRESSES 0x10
759da57d7bSbt #define	MAX_NUM_MULTICAST_ADDRESSES 0x1000
769da57d7bSbt #define	SPEED_10GB		10000
779da57d7bSbt #define	SPEED_1GB		1000
789da57d7bSbt #define	SPEED_100		100
799da57d7bSbt #define	FULL_DUPLEX		2
809da57d7bSbt 
819da57d7bSbt #define	IXGBE_WRITE_FLUSH(a)	(void) IXGBE_READ_REG(a, IXGBE_STATUS)
829da57d7bSbt 
839da57d7bSbt #define	IXGBE_WRITE_REG(a, reg, value)	\
8413740cb2SPaul Guo 	ddi_put32((OS_DEP(a))->reg_handle, \
8513740cb2SPaul Guo 	    (uint32_t *)((uintptr_t)(a)->hw_addr + reg), (value))
869da57d7bSbt 
879da57d7bSbt #define	IXGBE_READ_REG(a, reg)	\
8813740cb2SPaul Guo 	ddi_get32((OS_DEP(a))->reg_handle, \
8913740cb2SPaul Guo 	    (uint32_t *)((uintptr_t)(a)->hw_addr + reg))
909da57d7bSbt 
91*73cd555cSBin Tu - Sun Microsystems - Beijing China #define	IXGBE_WRITE_REG64(hw, reg, value)	\
92*73cd555cSBin Tu - Sun Microsystems - Beijing China 	do {								\
93*73cd555cSBin Tu - Sun Microsystems - Beijing China 		IXGBE_WRITE_REG(hw, reg, (u32) value);			\
94*73cd555cSBin Tu - Sun Microsystems - Beijing China 		IXGBE_WRITE_REG(hw, reg + 4, (u32) (value >> 32));	\
95*73cd555cSBin Tu - Sun Microsystems - Beijing China 		_NOTE(CONSTCOND)					\
96*73cd555cSBin Tu - Sun Microsystems - Beijing China 	} while (0)
97*73cd555cSBin Tu - Sun Microsystems - Beijing China 
989da57d7bSbt #define	msec_delay_irq	msec_delay
99*73cd555cSBin Tu - Sun Microsystems - Beijing China #define	IXGBE_HTONL	htonl
1009da57d7bSbt 
1019da57d7bSbt #define	UNREFERENCED_PARAMETER(x)	_NOTE(ARGUNUSED(x))
1029da57d7bSbt 
1039da57d7bSbt typedef	int8_t		s8;
1049da57d7bSbt typedef	int16_t		s16;
1059da57d7bSbt typedef	int32_t		s32;
1069da57d7bSbt typedef	int64_t		s64;
1079da57d7bSbt typedef uint8_t		u8;
1089da57d7bSbt typedef	uint16_t 	u16;
1099da57d7bSbt typedef	uint32_t	u32;
1109da57d7bSbt typedef	uint64_t	u64;
1119da57d7bSbt typedef boolean_t	bool;
1129da57d7bSbt 
1139da57d7bSbt struct ixgbe_osdep {
1149da57d7bSbt 	ddi_acc_handle_t reg_handle;
1159da57d7bSbt 	ddi_acc_handle_t cfg_handle;
1169da57d7bSbt 	struct ixgbe *ixgbe;
1179da57d7bSbt };
1189da57d7bSbt 
1199da57d7bSbt #ifdef __cplusplus
1209da57d7bSbt }
1219da57d7bSbt #endif
1229da57d7bSbt 
1239da57d7bSbt #endif	/* _IXGBE_OSDEP_H */
124