xref: /illumos-gate/usr/src/uts/common/sys/mac_ether.h (revision 5f82aa32fbc5dc2c59bca6ff315f44a4c4c9ea86)
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  * Copyright 2015 Garrett D'Amore <garrett@damore.org>
26  * Copyright 2016 Joyent, Inc.
27  */
28 
29 #ifndef	_SYS_MAC_ETHER_H
30 #define	_SYS_MAC_ETHER_H
31 
32 /*
33  * Ethernet MAC Plugin
34  */
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #ifdef	_KERNEL
41 
42 #define	MAC_PLUGIN_IDENT_ETHER	"mac_ether"
43 
44 /*
45  * Do not reorder, and add only to the end of this list.
46  */
47 enum ether_stat {
48 	/* RFC 1643 stats */
49 	ETHER_STAT_ALIGN_ERRORS = MACTYPE_STAT_MIN,
50 	ETHER_STAT_FCS_ERRORS,
51 	ETHER_STAT_FIRST_COLLISIONS,
52 	ETHER_STAT_MULTI_COLLISIONS,
53 	ETHER_STAT_SQE_ERRORS,
54 	ETHER_STAT_DEFER_XMTS,
55 	ETHER_STAT_TX_LATE_COLLISIONS,
56 	ETHER_STAT_EX_COLLISIONS,
57 	ETHER_STAT_MACXMT_ERRORS,
58 	ETHER_STAT_CARRIER_ERRORS,
59 	ETHER_STAT_TOOLONG_ERRORS,
60 	ETHER_STAT_MACRCV_ERRORS,
61 
62 	/* MII/GMII stats */
63 	ETHER_STAT_XCVR_ADDR,
64 	ETHER_STAT_XCVR_ID,
65 	ETHER_STAT_XCVR_INUSE,
66 	ETHER_STAT_CAP_1000FDX,
67 	ETHER_STAT_CAP_1000HDX,
68 	ETHER_STAT_CAP_100FDX,
69 	ETHER_STAT_CAP_100HDX,
70 	ETHER_STAT_CAP_10FDX,
71 	ETHER_STAT_CAP_10HDX,
72 	ETHER_STAT_CAP_ASMPAUSE,
73 	ETHER_STAT_CAP_PAUSE,
74 	ETHER_STAT_CAP_AUTONEG,
75 	ETHER_STAT_ADV_CAP_1000FDX,
76 	ETHER_STAT_ADV_CAP_1000HDX,
77 	ETHER_STAT_ADV_CAP_100FDX,
78 	ETHER_STAT_ADV_CAP_100HDX,
79 	ETHER_STAT_ADV_CAP_10FDX,
80 	ETHER_STAT_ADV_CAP_10HDX,
81 	ETHER_STAT_ADV_CAP_ASMPAUSE,
82 	ETHER_STAT_ADV_CAP_PAUSE,
83 	ETHER_STAT_ADV_CAP_AUTONEG,
84 	ETHER_STAT_LP_CAP_1000FDX,
85 	ETHER_STAT_LP_CAP_1000HDX,
86 	ETHER_STAT_LP_CAP_100FDX,
87 	ETHER_STAT_LP_CAP_100HDX,
88 	ETHER_STAT_LP_CAP_10FDX,
89 	ETHER_STAT_LP_CAP_10HDX,
90 	ETHER_STAT_LP_CAP_ASMPAUSE,
91 	ETHER_STAT_LP_CAP_PAUSE,
92 	ETHER_STAT_LP_CAP_AUTONEG,
93 	ETHER_STAT_LINK_ASMPAUSE,
94 	ETHER_STAT_LINK_PAUSE,
95 	ETHER_STAT_LINK_AUTONEG,
96 	ETHER_STAT_LINK_DUPLEX,
97 
98 	ETHER_STAT_TOOSHORT_ERRORS,
99 	ETHER_STAT_CAP_REMFAULT,
100 	ETHER_STAT_ADV_REMFAULT,
101 	ETHER_STAT_LP_REMFAULT,
102 
103 	ETHER_STAT_JABBER_ERRORS,
104 	ETHER_STAT_CAP_100T4,
105 	ETHER_STAT_ADV_CAP_100T4,
106 	ETHER_STAT_LP_CAP_100T4,
107 
108 	ETHER_STAT_CAP_10GFDX,
109 	ETHER_STAT_ADV_CAP_10GFDX,
110 	ETHER_STAT_LP_CAP_10GFDX,
111 
112 	ETHER_STAT_CAP_40GFDX,
113 	ETHER_STAT_ADV_CAP_40GFDX,
114 	ETHER_STAT_LP_CAP_40GFDX,
115 
116 	ETHER_STAT_CAP_100GFDX,
117 	ETHER_STAT_ADV_CAP_100GFDX,
118 	ETHER_STAT_LP_CAP_100GFDX,
119 
120 	ETHER_STAT_CAP_2500FDX,
121 	ETHER_STAT_ADV_CAP_2500FDX,
122 	ETHER_STAT_LP_CAP_2500FDX,
123 
124 	ETHER_STAT_CAP_5000FDX,
125 	ETHER_STAT_ADV_CAP_5000FDX,
126 	ETHER_STAT_LP_CAP_5000FDX,
127 
128 	ETHER_STAT_CAP_25GFDX,
129 	ETHER_STAT_ADV_CAP_25GFDX,
130 	ETHER_STAT_LP_CAP_25GFDX,
131 
132 	ETHER_STAT_CAP_50GFDX,
133 	ETHER_STAT_ADV_CAP_50GFDX,
134 	ETHER_STAT_LP_CAP_50GFDX,
135 };
136 
137 #define	ETHER_NSTAT	\
138 	(ETHER_STAT_LP_CAP_50GFDX - ETHER_STAT_ALIGN_ERRORS + 1)
139 
140 #define	ETHER_STAT_ISACOUNTER(_ether_stat)				\
141 	    ((_ether_stat) == ETHER_STAT_ALIGN_ERRORS ||		\
142 		(_ether_stat) == ETHER_STAT_FCS_ERRORS ||		\
143 		(_ether_stat) == ETHER_STAT_FIRST_COLLISIONS ||		\
144 		(_ether_stat) == ETHER_STAT_MULTI_COLLISIONS ||		\
145 		(_ether_stat) == ETHER_STAT_SQE_ERRORS ||		\
146 		(_ether_stat) == ETHER_STAT_DEFER_XMTS ||		\
147 		(_ether_stat) == ETHER_STAT_TX_LATE_COLLISIONS ||	\
148 		(_ether_stat) == ETHER_STAT_EX_COLLISIONS ||		\
149 		(_ether_stat) == ETHER_STAT_MACXMT_ERRORS ||		\
150 		(_ether_stat) == ETHER_STAT_CARRIER_ERRORS ||		\
151 		(_ether_stat) == ETHER_STAT_TOOLONG_ERRORS ||		\
152 		(_ether_stat) == ETHER_STAT_TOOSHORT_ERRORS ||		\
153 		(_ether_stat) == ETHER_STAT_JABBER_ERRORS ||		\
154 		(_ether_stat) == ETHER_STAT_MACRCV_ERRORS)
155 
156 #endif	/* _KERNEL */
157 
158 #ifdef	__cplusplus
159 }
160 #endif
161 
162 #endif /* _SYS_MAC_ETHER_H */
163