xref: /illumos-gate/usr/src/uts/common/sys/mac_ether.h (revision 5f8171005a0c33f3c67f7da52d41c2362c3fd891)
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 2009 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 /*
30  * Ethernet MAC Plugin
31  */
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #ifdef	_KERNEL
38 
39 #define	MAC_PLUGIN_IDENT_ETHER	"mac_ether"
40 
41 /*
42  * Do not reorder, and add only to the end of this list.
43  */
44 enum ether_stat {
45 	/* RFC 1643 stats */
46 	ETHER_STAT_ALIGN_ERRORS = MACTYPE_STAT_MIN,
47 	ETHER_STAT_FCS_ERRORS,
48 	ETHER_STAT_FIRST_COLLISIONS,
49 	ETHER_STAT_MULTI_COLLISIONS,
50 	ETHER_STAT_SQE_ERRORS,
51 	ETHER_STAT_DEFER_XMTS,
52 	ETHER_STAT_TX_LATE_COLLISIONS,
53 	ETHER_STAT_EX_COLLISIONS,
54 	ETHER_STAT_MACXMT_ERRORS,
55 	ETHER_STAT_CARRIER_ERRORS,
56 	ETHER_STAT_TOOLONG_ERRORS,
57 	ETHER_STAT_MACRCV_ERRORS,
58 
59 	/* MII/GMII stats */
60 	ETHER_STAT_XCVR_ADDR,
61 	ETHER_STAT_XCVR_ID,
62 	ETHER_STAT_XCVR_INUSE,
63 	ETHER_STAT_CAP_1000FDX,
64 	ETHER_STAT_CAP_1000HDX,
65 	ETHER_STAT_CAP_100FDX,
66 	ETHER_STAT_CAP_100HDX,
67 	ETHER_STAT_CAP_10FDX,
68 	ETHER_STAT_CAP_10HDX,
69 	ETHER_STAT_CAP_ASMPAUSE,
70 	ETHER_STAT_CAP_PAUSE,
71 	ETHER_STAT_CAP_AUTONEG,
72 	ETHER_STAT_ADV_CAP_1000FDX,
73 	ETHER_STAT_ADV_CAP_1000HDX,
74 	ETHER_STAT_ADV_CAP_100FDX,
75 	ETHER_STAT_ADV_CAP_100HDX,
76 	ETHER_STAT_ADV_CAP_10FDX,
77 	ETHER_STAT_ADV_CAP_10HDX,
78 	ETHER_STAT_ADV_CAP_ASMPAUSE,
79 	ETHER_STAT_ADV_CAP_PAUSE,
80 	ETHER_STAT_ADV_CAP_AUTONEG,
81 	ETHER_STAT_LP_CAP_1000FDX,
82 	ETHER_STAT_LP_CAP_1000HDX,
83 	ETHER_STAT_LP_CAP_100FDX,
84 	ETHER_STAT_LP_CAP_100HDX,
85 	ETHER_STAT_LP_CAP_10FDX,
86 	ETHER_STAT_LP_CAP_10HDX,
87 	ETHER_STAT_LP_CAP_ASMPAUSE,
88 	ETHER_STAT_LP_CAP_PAUSE,
89 	ETHER_STAT_LP_CAP_AUTONEG,
90 	ETHER_STAT_LINK_ASMPAUSE,
91 	ETHER_STAT_LINK_PAUSE,
92 	ETHER_STAT_LINK_AUTONEG,
93 	ETHER_STAT_LINK_DUPLEX,
94 
95 	ETHER_STAT_TOOSHORT_ERRORS,
96 	ETHER_STAT_CAP_REMFAULT,
97 	ETHER_STAT_ADV_REMFAULT,
98 	ETHER_STAT_LP_REMFAULT,
99 
100 	ETHER_STAT_JABBER_ERRORS,
101 	ETHER_STAT_CAP_100T4,
102 	ETHER_STAT_ADV_CAP_100T4,
103 	ETHER_STAT_LP_CAP_100T4,
104 
105 	ETHER_STAT_CAP_10GFDX,
106 	ETHER_STAT_ADV_CAP_10GFDX,
107 	ETHER_STAT_LP_CAP_10GFDX,
108 };
109 
110 #define	ETHER_NSTAT	(ETHER_STAT_LP_CAP_10GFDX - ETHER_STAT_ALIGN_ERRORS + 1)
111 
112 #define	ETHER_STAT_ISACOUNTER(_ether_stat)				\
113 	    ((_ether_stat) == ETHER_STAT_ALIGN_ERRORS ||		\
114 		(_ether_stat) == ETHER_STAT_FCS_ERRORS ||		\
115 		(_ether_stat) == ETHER_STAT_FIRST_COLLISIONS ||		\
116 		(_ether_stat) == ETHER_STAT_MULTI_COLLISIONS ||		\
117 		(_ether_stat) == ETHER_STAT_SQE_ERRORS ||		\
118 		(_ether_stat) == ETHER_STAT_DEFER_XMTS ||		\
119 		(_ether_stat) == ETHER_STAT_TX_LATE_COLLISIONS ||	\
120 		(_ether_stat) == ETHER_STAT_EX_COLLISIONS ||		\
121 		(_ether_stat) == ETHER_STAT_MACXMT_ERRORS ||		\
122 		(_ether_stat) == ETHER_STAT_CARRIER_ERRORS ||		\
123 		(_ether_stat) == ETHER_STAT_TOOLONG_ERRORS ||		\
124 		(_ether_stat) == ETHER_STAT_TOOSHORT_ERRORS ||		\
125 		(_ether_stat) == ETHER_STAT_JABBER_ERRORS ||		\
126 		(_ether_stat) == ETHER_STAT_MACRCV_ERRORS)
127 
128 /*
129  * Some drivers have a need to determine if a particular stat is a MII/GMII
130  * physical layer 802.3 stat.
131  */
132 #define	ETHER_STAT_ISMII(_ether_stat)					\
133 	((_ether_stat) == ETHER_STAT_XCVR_ADDR ||			\
134 	    (_ether_stat) == ETHER_STAT_XCVR_ID ||			\
135 	    (_ether_stat) == ETHER_STAT_XCVR_INUSE ||			\
136 	    (_ether_stat) == ETHER_STAT_CAP_1000FDX ||			\
137 	    (_ether_stat) == ETHER_STAT_CAP_1000HDX ||			\
138 	    (_ether_stat) == ETHER_STAT_CAP_100FDX ||			\
139 	    (_ether_stat) == ETHER_STAT_CAP_100HDX ||			\
140 	    (_ether_stat) == ETHER_STAT_CAP_10FDX ||			\
141 	    (_ether_stat) == ETHER_STAT_CAP_10HDX ||			\
142 	    (_ether_stat) == ETHER_STAT_CAP_ASMPAUSE ||			\
143 	    (_ether_stat) == ETHER_STAT_CAP_PAUSE ||			\
144 	    (_ether_stat) == ETHER_STAT_CAP_AUTONEG ||			\
145 	    (_ether_stat) == ETHER_STAT_CAP_REMFAULT ||			\
146 	    (_ether_stat) == ETHER_STAT_CAP_100T4 ||			\
147 	    (_ether_stat) == ETHER_STAT_ADV_CAP_1000FDX ||		\
148 	    (_ether_stat) == ETHER_STAT_ADV_CAP_1000HDX ||		\
149 	    (_ether_stat) == ETHER_STAT_ADV_CAP_100FDX ||		\
150 	    (_ether_stat) == ETHER_STAT_ADV_CAP_100HDX ||		\
151 	    (_ether_stat) == ETHER_STAT_ADV_CAP_10FDX ||		\
152 	    (_ether_stat) == ETHER_STAT_ADV_CAP_10HDX ||		\
153 	    (_ether_stat) == ETHER_STAT_ADV_CAP_ASMPAUSE ||		\
154 	    (_ether_stat) == ETHER_STAT_ADV_CAP_PAUSE ||		\
155 	    (_ether_stat) == ETHER_STAT_ADV_CAP_AUTONEG ||		\
156 	    (_ether_stat) == ETHER_STAT_ADV_REMFAULT ||			\
157 	    (_ether_stat) == ETHER_STAT_ADV_CAP_100T4 ||		\
158 	    (_ether_stat) == ETHER_STAT_LP_CAP_1000FDX ||		\
159 	    (_ether_stat) == ETHER_STAT_LP_CAP_1000HDX ||		\
160 	    (_ether_stat) == ETHER_STAT_LP_CAP_100FDX ||		\
161 	    (_ether_stat) == ETHER_STAT_LP_CAP_100HDX ||		\
162 	    (_ether_stat) == ETHER_STAT_LP_CAP_10FDX ||			\
163 	    (_ether_stat) == ETHER_STAT_LP_CAP_10HDX ||			\
164 	    (_ether_stat) == ETHER_STAT_LP_CAP_ASMPAUSE ||		\
165 	    (_ether_stat) == ETHER_STAT_LP_CAP_PAUSE ||			\
166 	    (_ether_stat) == ETHER_STAT_LP_CAP_AUTONEG ||		\
167 	    (_ether_stat) == ETHER_STAT_LP_REMFAULT ||			\
168 	    (_ether_stat) == ETHER_STAT_LP_CAP_100T4 ||			\
169 	    (_ether_stat) == ETHER_STAT_LINK_ASMPAUSE ||		\
170 	    (_ether_stat) == ETHER_STAT_LINK_PAUSE ||			\
171 	    (_ether_stat) == ETHER_STAT_LINK_AUTONEG ||			\
172 	    (_ether_stat) == ETHER_STAT_LINK_DUPLEX)
173 
174 #endif	/* _KERNEL */
175 
176 #ifdef	__cplusplus
177 }
178 #endif
179 
180 #endif /* _SYS_MAC_ETHER_H */
181