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