xref: /onnv-gate/usr/src/uts/common/io/igb/igb_osdep.h (revision 11155:1d6534291026)
15779Sxy150489 /*
25779Sxy150489  * CDDL HEADER START
35779Sxy150489  *
48571SChenlu.Chen@Sun.COM  * Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
55779Sxy150489  * The contents of this file are subject to the terms of the
65779Sxy150489  * Common Development and Distribution License (the "License").
75779Sxy150489  * You may not use this file except in compliance with the License.
85779Sxy150489  *
98571SChenlu.Chen@Sun.COM  * You can obtain a copy of the license at:
108571SChenlu.Chen@Sun.COM  *	http://www.opensolaris.org/os/licensing.
115779Sxy150489  * See the License for the specific language governing permissions
125779Sxy150489  * and limitations under the License.
135779Sxy150489  *
148571SChenlu.Chen@Sun.COM  * When using or redistributing this file, you may do so under the
158571SChenlu.Chen@Sun.COM  * License only. No other modification of this header is permitted.
168571SChenlu.Chen@Sun.COM  *
175779Sxy150489  * If applicable, add the following below this CDDL HEADER, with the
185779Sxy150489  * fields enclosed by brackets "[]" replaced with your own identifying
195779Sxy150489  * information: Portions Copyright [yyyy] [name of copyright owner]
205779Sxy150489  *
215779Sxy150489  * CDDL HEADER END
225779Sxy150489  */
235779Sxy150489 
245779Sxy150489 /*
258571SChenlu.Chen@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
268571SChenlu.Chen@Sun.COM  * Use is subject to license terms of the CDDL.
275779Sxy150489  */
285779Sxy150489 
295779Sxy150489 #ifndef	_IGB_OSDEP_H
305779Sxy150489 #define	_IGB_OSDEP_H
315779Sxy150489 
325779Sxy150489 #ifdef __cplusplus
335779Sxy150489 extern "C" {
345779Sxy150489 #endif
355779Sxy150489 
365779Sxy150489 #include <sys/types.h>
375779Sxy150489 #include <sys/conf.h>
385779Sxy150489 #include <sys/debug.h>
395779Sxy150489 #include <sys/stropts.h>
405779Sxy150489 #include <sys/stream.h>
415779Sxy150489 #include <sys/strlog.h>
425779Sxy150489 #include <sys/kmem.h>
435779Sxy150489 #include <sys/stat.h>
445779Sxy150489 #include <sys/kstat.h>
455779Sxy150489 #include <sys/modctl.h>
465779Sxy150489 #include <sys/errno.h>
475779Sxy150489 #include <sys/ddi.h>
485779Sxy150489 #include <sys/dditypes.h>
495779Sxy150489 #include <sys/sunddi.h>
505779Sxy150489 #include <sys/pci.h>
5110319SJason.Xu@Sun.COM #include <sys/pci_cap.h>
525779Sxy150489 #include <sys/atomic.h>
535779Sxy150489 #include <sys/note.h>
545779Sxy150489 #include "igb_debug.h"
555779Sxy150489 
565779Sxy150489 #define	usec_delay(x)		drv_usecwait(x)
575779Sxy150489 #define	msec_delay(x)		drv_usecwait(x * 1000)
588571SChenlu.Chen@Sun.COM #define	msec_delay_irq		msec_delay
595779Sxy150489 
605779Sxy150489 #ifdef IGB_DEBUG
615779Sxy150489 #define	DEBUGOUT(S)		IGB_DEBUGLOG_0(NULL, S)
625779Sxy150489 #define	DEBUGOUT1(S, A)		IGB_DEBUGLOG_1(NULL, S, A)
635779Sxy150489 #define	DEBUGOUT2(S, A, B)	IGB_DEBUGLOG_2(NULL, S, A, B)
645779Sxy150489 #define	DEBUGOUT3(S, A, B, C)	IGB_DEBUGLOG_3(NULL, S, A, B, C)
655779Sxy150489 #else
665779Sxy150489 #define	DEBUGOUT(S)
675779Sxy150489 #define	DEBUGOUT1(S, A)
685779Sxy150489 #define	DEBUGOUT2(S, A, B)
695779Sxy150489 #define	DEBUGOUT3(S, A, B, C)
708571SChenlu.Chen@Sun.COM #endif
718571SChenlu.Chen@Sun.COM 
72*11155SJason.Xu@Sun.COM #define	DEBUGFUNC(f)
735779Sxy150489 
745779Sxy150489 #define	OS_DEP(hw)		((struct igb_osdep *)((hw)->back))
755779Sxy150489 
768571SChenlu.Chen@Sun.COM #define	false			B_FALSE
778571SChenlu.Chen@Sun.COM #define	true			B_TRUE
785779Sxy150489 
795779Sxy150489 #define	CMD_MEM_WRT_INVALIDATE	0x0010	/* BIT_4 */
805779Sxy150489 #define	PCI_COMMAND_REGISTER	0x04
815779Sxy150489 #define	PCI_EX_CONF_CAP		0xE0
825779Sxy150489 
835779Sxy150489 
845779Sxy150489 /*
855779Sxy150489  * Constants used in setting flow control thresholds
865779Sxy150489  */
875779Sxy150489 #define	E1000_PBA_MASK		0xffff
885779Sxy150489 #define	E1000_PBA_SHIFT		10
895779Sxy150489 #define	E1000_FC_HIGH_DIFF	0x1638 /* High: 5688 bytes below Rx FIFO size */
905779Sxy150489 #define	E1000_FC_LOW_DIFF	0x1640 /* Low: 5696 bytes below Rx FIFO size */
915779Sxy150489 #define	E1000_FC_PAUSE_TIME	0x0680 /* 858 usec */
925779Sxy150489 
935779Sxy150489 /* PHY Extended Status Register */
945779Sxy150489 #define	IEEE_ESR_1000T_HD_CAPS	0x1000	/* 1000T HD capable */
955779Sxy150489 #define	IEEE_ESR_1000T_FD_CAPS	0x2000	/* 1000T FD capable */
965779Sxy150489 #define	IEEE_ESR_1000X_HD_CAPS	0x4000	/* 1000X HD capable */
975779Sxy150489 #define	IEEE_ESR_1000X_FD_CAPS	0x8000	/* 1000X FD capable */
985779Sxy150489 
998275SEric Cheng /* VMDq MODE supported by hardware */
1008275SEric Cheng #define	E1000_VMDQ_OFF		0
1018275SEric Cheng #define	E1000_VMDQ_MAC		1
1028275SEric Cheng #define	E1000_VMDQ_MAC_RSS	2
1038275SEric Cheng 
1048275SEric Cheng /* VMDq based on packet destination MAC address */
1058275SEric Cheng #define	E1000_MRQC_ENABLE_VMDQ_MAC_GROUP	0x00000003
1068275SEric Cheng /* VMDq based on packet destination MAC address and RSS */
1078275SEric Cheng #define	E1000_MRQC_ENABLE_VMDQ_MAC_RSS_GROUP	0x00000005
1088275SEric Cheng /* The default queue in each VMDqs */
1098275SEric Cheng #define	E1000_VMDQ_MAC_GROUP_DEFAULT_QUEUE	0x100
1108275SEric Cheng 
1115779Sxy150489 #define	E1000_WRITE_FLUSH(a)	(void) E1000_READ_REG(a, E1000_STATUS)
1125779Sxy150489 
1135779Sxy150489 #define	E1000_WRITE_REG(hw, reg, value)	\
1145779Sxy150489 	ddi_put32((OS_DEP(hw))->reg_handle, \
1155779Sxy150489 	    (uint32_t *)((uintptr_t)(hw)->hw_addr + reg), (value))
1165779Sxy150489 
1175779Sxy150489 #define	E1000_READ_REG(hw, reg)	\
1185779Sxy150489 	ddi_get32((OS_DEP(hw))->reg_handle, \
1195779Sxy150489 	    (uint32_t *)((uintptr_t)(hw)->hw_addr + reg))
1205779Sxy150489 
1215779Sxy150489 #define	E1000_WRITE_REG_ARRAY(hw, reg, offset, value)	\
1225779Sxy150489 	ddi_put32((OS_DEP(hw))->reg_handle, \
1235779Sxy150489 	    (uint32_t *)((uintptr_t)(hw)->hw_addr + reg + ((offset) << 2)), \
1245779Sxy150489 	    (value))
1255779Sxy150489 
1265779Sxy150489 #define	E1000_READ_REG_ARRAY(hw, reg, offset)	\
1275779Sxy150489 	ddi_get32((OS_DEP(hw))->reg_handle, \
1285779Sxy150489 	    (uint32_t *)((uintptr_t)(hw)->hw_addr + reg + ((offset) << 2)))
1295779Sxy150489 
1305779Sxy150489 #define	E1000_WRITE_REG_ARRAY_DWORD(a, reg, offset, value)	\
1315779Sxy150489 	E1000_WRITE_REG_ARRAY(a, reg, offset, value)
1325779Sxy150489 #define	E1000_READ_REG_ARRAY_DWORD(a, reg, offset)		\
1335779Sxy150489 	E1000_READ_REG_ARRAY(a, reg, offset)
1345779Sxy150489 
1358571SChenlu.Chen@Sun.COM #define	UNREFERENCED_1PARAMETER(_p)		_NOTE(ARGUNUSED(_p))
1368571SChenlu.Chen@Sun.COM #define	UNREFERENCED_2PARAMETER(_p, _q)		_NOTE(ARGUNUSED(_p, _q))
1378571SChenlu.Chen@Sun.COM #define	UNREFERENCED_3PARAMETER(_p, _q, _r)	_NOTE(ARGUNUSED(_p, _q, _r))
1388571SChenlu.Chen@Sun.COM #define	UNREFERENCED_4PARAMETER(_p, _q, _r, _s)	_NOTE(ARGUNUSED(_p, _q, _r, _s))
1398571SChenlu.Chen@Sun.COM #define	UNREFERENCED_5PARAMETER(_p, _q, _r, _s, _t)	\
1408571SChenlu.Chen@Sun.COM 	_NOTE(ARGUNUSED(_p, _q, _r, _s, _t))
1415779Sxy150489 
1428571SChenlu.Chen@Sun.COM #define	__le16		u16
1438571SChenlu.Chen@Sun.COM #define	__le32		u32
1448571SChenlu.Chen@Sun.COM #define	__le64		u64
1455779Sxy150489 
1465779Sxy150489 typedef	int8_t		s8;
1475779Sxy150489 typedef	int16_t		s16;
1485779Sxy150489 typedef	int32_t		s32;
1495779Sxy150489 typedef	int64_t		s64;
1505779Sxy150489 typedef uint8_t		u8;
1515779Sxy150489 typedef	uint16_t 	u16;
1525779Sxy150489 typedef	uint32_t	u32;
1535779Sxy150489 typedef	uint64_t	u64;
1547072Sxy150489 typedef	boolean_t	bool;
1555779Sxy150489 
1565779Sxy150489 struct igb_osdep {
1575779Sxy150489 	ddi_acc_handle_t reg_handle;
1585779Sxy150489 	ddi_acc_handle_t cfg_handle;
1595779Sxy150489 	struct igb *igb;
1605779Sxy150489 };
1615779Sxy150489 
1625779Sxy150489 
1635779Sxy150489 #ifdef __cplusplus
1645779Sxy150489 }
1655779Sxy150489 #endif
1665779Sxy150489 
1675779Sxy150489 #endif	/* _IGB_OSDEP_H */
168