xref: /illumos-gate/usr/src/uts/common/sys/mac_ether.h (revision 06e1a714)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_MAC_ETHER_H
27 #define	_SYS_MAC_ETHER_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Ethernet MAC Plugin
33  */
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #ifdef	_KERNEL
40 
41 #define	MAC_PLUGIN_IDENT_ETHER	"mac_ether"
42 
43 enum ether_stat {
44 	/* RFC 1643 stats */
45 	ETHER_STAT_ALIGN_ERRORS = MACTYPE_STAT_MIN,
46 	ETHER_STAT_FCS_ERRORS,
47 	ETHER_STAT_FIRST_COLLISIONS,
48 	ETHER_STAT_MULTI_COLLISIONS,
49 	ETHER_STAT_SQE_ERRORS,
50 	ETHER_STAT_DEFER_XMTS,
51 	ETHER_STAT_TX_LATE_COLLISIONS,
52 	ETHER_STAT_EX_COLLISIONS,
53 	ETHER_STAT_MACXMT_ERRORS,
54 	ETHER_STAT_CARRIER_ERRORS,
55 	ETHER_STAT_TOOLONG_ERRORS,
56 	ETHER_STAT_MACRCV_ERRORS,
57 
58 	/* MII/GMII stats */
59 	ETHER_STAT_XCVR_ADDR,
60 	ETHER_STAT_XCVR_ID,
61 	ETHER_STAT_XCVR_INUSE,
62 	ETHER_STAT_CAP_1000FDX,
63 	ETHER_STAT_CAP_1000HDX,
64 	ETHER_STAT_CAP_100FDX,
65 	ETHER_STAT_CAP_100HDX,
66 	ETHER_STAT_CAP_10FDX,
67 	ETHER_STAT_CAP_10HDX,
68 	ETHER_STAT_CAP_ASMPAUSE,
69 	ETHER_STAT_CAP_PAUSE,
70 	ETHER_STAT_CAP_AUTONEG,
71 	ETHER_STAT_ADV_CAP_1000FDX,
72 	ETHER_STAT_ADV_CAP_1000HDX,
73 	ETHER_STAT_ADV_CAP_100FDX,
74 	ETHER_STAT_ADV_CAP_100HDX,
75 	ETHER_STAT_ADV_CAP_10FDX,
76 	ETHER_STAT_ADV_CAP_10HDX,
77 	ETHER_STAT_ADV_CAP_ASMPAUSE,
78 	ETHER_STAT_ADV_CAP_PAUSE,
79 	ETHER_STAT_ADV_CAP_AUTONEG,
80 	ETHER_STAT_LP_CAP_1000FDX,
81 	ETHER_STAT_LP_CAP_1000HDX,
82 	ETHER_STAT_LP_CAP_100FDX,
83 	ETHER_STAT_LP_CAP_100HDX,
84 	ETHER_STAT_LP_CAP_10FDX,
85 	ETHER_STAT_LP_CAP_10HDX,
86 	ETHER_STAT_LP_CAP_ASMPAUSE,
87 	ETHER_STAT_LP_CAP_PAUSE,
88 	ETHER_STAT_LP_CAP_AUTONEG,
89 	ETHER_STAT_LINK_ASMPAUSE,
90 	ETHER_STAT_LINK_PAUSE,
91 	ETHER_STAT_LINK_AUTONEG,
92 	ETHER_STAT_LINK_DUPLEX
93 };
94 
95 #define	ETHER_NSTAT	(ETHER_STAT_LINK_DUPLEX - ETHER_STAT_ALIGN_ERRORS + 1)
96 
97 #define	ETHER_STAT_ISACOUNTER(_ether_stat)				\
98 	    ((_ether_stat) == ETHER_STAT_ALIGN_ERRORS ||		\
99 		(_ether_stat) == ETHER_STAT_FCS_ERRORS ||		\
100 		(_ether_stat) == ETHER_STAT_FIRST_COLLISIONS ||		\
101 		(_ether_stat) == ETHER_STAT_MULTI_COLLISIONS ||		\
102 		(_ether_stat) == ETHER_STAT_SQE_ERRORS ||		\
103 		(_ether_stat) == ETHER_STAT_DEFER_XMTS ||		\
104 		(_ether_stat) == ETHER_STAT_TX_LATE_COLLISIONS ||	\
105 		(_ether_stat) == ETHER_STAT_EX_COLLISIONS ||		\
106 		(_ether_stat) == ETHER_STAT_MACXMT_ERRORS ||		\
107 		(_ether_stat) == ETHER_STAT_CARRIER_ERRORS ||		\
108 		(_ether_stat) == ETHER_STAT_TOOLONG_ERRORS ||		\
109 		(_ether_stat) == ETHER_STAT_MACRCV_ERRORS)
110 
111 /*
112  * Some drivers have a need to determine if a particular stat is a MII/GMII
113  * physical layer 802.3 stat.
114  */
115 #define	ETHER_STAT_ISMII(_ether_stat)					\
116 	((_ether_stat) == ETHER_STAT_XCVR_ADDR ||			\
117 	    (_ether_stat) == ETHER_STAT_XCVR_ID ||			\
118 	    (_ether_stat) == ETHER_STAT_XCVR_INUSE ||			\
119 	    (_ether_stat) == ETHER_STAT_CAP_1000FDX ||			\
120 	    (_ether_stat) == ETHER_STAT_CAP_1000HDX ||			\
121 	    (_ether_stat) == ETHER_STAT_CAP_100FDX ||			\
122 	    (_ether_stat) == ETHER_STAT_CAP_100HDX ||			\
123 	    (_ether_stat) == ETHER_STAT_CAP_10FDX ||			\
124 	    (_ether_stat) == ETHER_STAT_CAP_10HDX ||			\
125 	    (_ether_stat) == ETHER_STAT_CAP_ASMPAUSE ||			\
126 	    (_ether_stat) == ETHER_STAT_CAP_PAUSE ||			\
127 	    (_ether_stat) == ETHER_STAT_CAP_AUTONEG ||			\
128 	    (_ether_stat) == ETHER_STAT_ADV_CAP_1000FDX ||		\
129 	    (_ether_stat) == ETHER_STAT_ADV_CAP_1000HDX ||		\
130 	    (_ether_stat) == ETHER_STAT_ADV_CAP_100FDX ||		\
131 	    (_ether_stat) == ETHER_STAT_ADV_CAP_100HDX ||		\
132 	    (_ether_stat) == ETHER_STAT_ADV_CAP_10FDX ||		\
133 	    (_ether_stat) == ETHER_STAT_ADV_CAP_10HDX ||		\
134 	    (_ether_stat) == ETHER_STAT_ADV_CAP_ASMPAUSE ||		\
135 	    (_ether_stat) == ETHER_STAT_ADV_CAP_PAUSE ||		\
136 	    (_ether_stat) == ETHER_STAT_ADV_CAP_AUTONEG ||		\
137 	    (_ether_stat) == ETHER_STAT_LP_CAP_1000FDX ||		\
138 	    (_ether_stat) == ETHER_STAT_LP_CAP_1000HDX ||		\
139 	    (_ether_stat) == ETHER_STAT_LP_CAP_100FDX ||		\
140 	    (_ether_stat) == ETHER_STAT_LP_CAP_100HDX ||		\
141 	    (_ether_stat) == ETHER_STAT_LP_CAP_10FDX ||			\
142 	    (_ether_stat) == ETHER_STAT_LP_CAP_10HDX ||			\
143 	    (_ether_stat) == ETHER_STAT_LP_CAP_ASMPAUSE ||		\
144 	    (_ether_stat) == ETHER_STAT_LP_CAP_PAUSE ||			\
145 	    (_ether_stat) == ETHER_STAT_LP_CAP_AUTONEG ||		\
146 	    (_ether_stat) == ETHER_STAT_LINK_ASMPAUSE ||		\
147 	    (_ether_stat) == ETHER_STAT_LINK_PAUSE ||			\
148 	    (_ether_stat) == ETHER_STAT_LINK_AUTONEG ||			\
149 	    (_ether_stat) == ETHER_STAT_LINK_DUPLEX)
150 
151 #endif	/* _KERNEL */
152 
153 #ifdef	__cplusplus
154 }
155 #endif
156 
157 #endif /* _SYS_MAC_ETHER_H */
158