xref: /onnv-gate/usr/src/uts/common/sys/mac_ether.h (revision 4089:32330c723688)
12311Sseb /*
22311Sseb  * CDDL HEADER START
32311Sseb  *
42311Sseb  * The contents of this file are subject to the terms of the
52311Sseb  * Common Development and Distribution License (the "License").
62311Sseb  * You may not use this file except in compliance with the License.
72311Sseb  *
82311Sseb  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92311Sseb  * or http://www.opensolaris.org/os/licensing.
102311Sseb  * See the License for the specific language governing permissions
112311Sseb  * and limitations under the License.
122311Sseb  *
132311Sseb  * When distributing Covered Code, include this CDDL HEADER in each
142311Sseb  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152311Sseb  * If applicable, add the following below this CDDL HEADER, with the
162311Sseb  * fields enclosed by brackets "[]" replaced with your own identifying
172311Sseb  * information: Portions Copyright [yyyy] [name of copyright owner]
182311Sseb  *
192311Sseb  * CDDL HEADER END
202311Sseb  */
212311Sseb /*
22*4089Sgd78059  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
232311Sseb  * Use is subject to license terms.
242311Sseb  */
252311Sseb 
262311Sseb #ifndef	_SYS_MAC_ETHER_H
272311Sseb #define	_SYS_MAC_ETHER_H
282311Sseb 
292311Sseb #pragma ident	"%Z%%M%	%I%	%E% SMI"
302311Sseb 
312311Sseb /*
322311Sseb  * Ethernet MAC Plugin
332311Sseb  */
342311Sseb 
352311Sseb #ifdef	__cplusplus
362311Sseb extern "C" {
372311Sseb #endif
382311Sseb 
392311Sseb #ifdef	_KERNEL
402311Sseb 
412311Sseb #define	MAC_PLUGIN_IDENT_ETHER	"mac_ether"
422311Sseb 
43*4089Sgd78059 /*
44*4089Sgd78059  * Do not reorder, and add only to the end of this list.
45*4089Sgd78059  */
462311Sseb enum ether_stat {
472311Sseb 	/* RFC 1643 stats */
482311Sseb 	ETHER_STAT_ALIGN_ERRORS = MACTYPE_STAT_MIN,
492311Sseb 	ETHER_STAT_FCS_ERRORS,
502311Sseb 	ETHER_STAT_FIRST_COLLISIONS,
512311Sseb 	ETHER_STAT_MULTI_COLLISIONS,
522311Sseb 	ETHER_STAT_SQE_ERRORS,
532311Sseb 	ETHER_STAT_DEFER_XMTS,
542311Sseb 	ETHER_STAT_TX_LATE_COLLISIONS,
552311Sseb 	ETHER_STAT_EX_COLLISIONS,
562311Sseb 	ETHER_STAT_MACXMT_ERRORS,
572311Sseb 	ETHER_STAT_CARRIER_ERRORS,
582311Sseb 	ETHER_STAT_TOOLONG_ERRORS,
592311Sseb 	ETHER_STAT_MACRCV_ERRORS,
602311Sseb 
612311Sseb 	/* MII/GMII stats */
622311Sseb 	ETHER_STAT_XCVR_ADDR,
632311Sseb 	ETHER_STAT_XCVR_ID,
642311Sseb 	ETHER_STAT_XCVR_INUSE,
652311Sseb 	ETHER_STAT_CAP_1000FDX,
662311Sseb 	ETHER_STAT_CAP_1000HDX,
672311Sseb 	ETHER_STAT_CAP_100FDX,
682311Sseb 	ETHER_STAT_CAP_100HDX,
692311Sseb 	ETHER_STAT_CAP_10FDX,
702311Sseb 	ETHER_STAT_CAP_10HDX,
712311Sseb 	ETHER_STAT_CAP_ASMPAUSE,
722311Sseb 	ETHER_STAT_CAP_PAUSE,
732311Sseb 	ETHER_STAT_CAP_AUTONEG,
742311Sseb 	ETHER_STAT_ADV_CAP_1000FDX,
752311Sseb 	ETHER_STAT_ADV_CAP_1000HDX,
762311Sseb 	ETHER_STAT_ADV_CAP_100FDX,
772311Sseb 	ETHER_STAT_ADV_CAP_100HDX,
782311Sseb 	ETHER_STAT_ADV_CAP_10FDX,
792311Sseb 	ETHER_STAT_ADV_CAP_10HDX,
802311Sseb 	ETHER_STAT_ADV_CAP_ASMPAUSE,
812311Sseb 	ETHER_STAT_ADV_CAP_PAUSE,
822311Sseb 	ETHER_STAT_ADV_CAP_AUTONEG,
832311Sseb 	ETHER_STAT_LP_CAP_1000FDX,
842311Sseb 	ETHER_STAT_LP_CAP_1000HDX,
852311Sseb 	ETHER_STAT_LP_CAP_100FDX,
862311Sseb 	ETHER_STAT_LP_CAP_100HDX,
872311Sseb 	ETHER_STAT_LP_CAP_10FDX,
882311Sseb 	ETHER_STAT_LP_CAP_10HDX,
892311Sseb 	ETHER_STAT_LP_CAP_ASMPAUSE,
902311Sseb 	ETHER_STAT_LP_CAP_PAUSE,
912311Sseb 	ETHER_STAT_LP_CAP_AUTONEG,
922311Sseb 	ETHER_STAT_LINK_ASMPAUSE,
932311Sseb 	ETHER_STAT_LINK_PAUSE,
942311Sseb 	ETHER_STAT_LINK_AUTONEG,
95*4089Sgd78059 	ETHER_STAT_LINK_DUPLEX,
96*4089Sgd78059 
97*4089Sgd78059 	ETHER_STAT_TOOSHORT_ERRORS,
98*4089Sgd78059 	ETHER_STAT_CAP_REMFAULT,
99*4089Sgd78059 	ETHER_STAT_ADV_REMFAULT,
100*4089Sgd78059 	ETHER_STAT_LP_REMFAULT
1012311Sseb };
1022311Sseb 
103*4089Sgd78059 #define	ETHER_NSTAT	(ETHER_STAT_LP_REMFAULT - ETHER_STAT_ALIGN_ERRORS + 1)
1042311Sseb 
1052311Sseb #define	ETHER_STAT_ISACOUNTER(_ether_stat)				\
1062311Sseb 	    ((_ether_stat) == ETHER_STAT_ALIGN_ERRORS ||		\
1072311Sseb 		(_ether_stat) == ETHER_STAT_FCS_ERRORS ||		\
1082311Sseb 		(_ether_stat) == ETHER_STAT_FIRST_COLLISIONS ||		\
1092311Sseb 		(_ether_stat) == ETHER_STAT_MULTI_COLLISIONS ||		\
1102311Sseb 		(_ether_stat) == ETHER_STAT_SQE_ERRORS ||		\
1112311Sseb 		(_ether_stat) == ETHER_STAT_DEFER_XMTS ||		\
1122311Sseb 		(_ether_stat) == ETHER_STAT_TX_LATE_COLLISIONS ||	\
1132311Sseb 		(_ether_stat) == ETHER_STAT_EX_COLLISIONS ||		\
1142311Sseb 		(_ether_stat) == ETHER_STAT_MACXMT_ERRORS ||		\
1152311Sseb 		(_ether_stat) == ETHER_STAT_CARRIER_ERRORS ||		\
1162311Sseb 		(_ether_stat) == ETHER_STAT_TOOLONG_ERRORS ||		\
117*4089Sgd78059 		(_ether_stat) == ETHER_STAT_TOOSHORT_ERRORS ||		\
1182311Sseb 		(_ether_stat) == ETHER_STAT_MACRCV_ERRORS)
1192311Sseb 
1202311Sseb /*
1212311Sseb  * Some drivers have a need to determine if a particular stat is a MII/GMII
1222311Sseb  * physical layer 802.3 stat.
1232311Sseb  */
1242311Sseb #define	ETHER_STAT_ISMII(_ether_stat)					\
1252311Sseb 	((_ether_stat) == ETHER_STAT_XCVR_ADDR ||			\
1262311Sseb 	    (_ether_stat) == ETHER_STAT_XCVR_ID ||			\
1272311Sseb 	    (_ether_stat) == ETHER_STAT_XCVR_INUSE ||			\
1282311Sseb 	    (_ether_stat) == ETHER_STAT_CAP_1000FDX ||			\
1292311Sseb 	    (_ether_stat) == ETHER_STAT_CAP_1000HDX ||			\
1302311Sseb 	    (_ether_stat) == ETHER_STAT_CAP_100FDX ||			\
1312311Sseb 	    (_ether_stat) == ETHER_STAT_CAP_100HDX ||			\
1322311Sseb 	    (_ether_stat) == ETHER_STAT_CAP_10FDX ||			\
1332311Sseb 	    (_ether_stat) == ETHER_STAT_CAP_10HDX ||			\
1342311Sseb 	    (_ether_stat) == ETHER_STAT_CAP_ASMPAUSE ||			\
1352311Sseb 	    (_ether_stat) == ETHER_STAT_CAP_PAUSE ||			\
1362311Sseb 	    (_ether_stat) == ETHER_STAT_CAP_AUTONEG ||			\
137*4089Sgd78059 	    (_ether_stat) == ETHER_STAT_CAP_REMFAULT ||			\
1382311Sseb 	    (_ether_stat) == ETHER_STAT_ADV_CAP_1000FDX ||		\
1392311Sseb 	    (_ether_stat) == ETHER_STAT_ADV_CAP_1000HDX ||		\
1402311Sseb 	    (_ether_stat) == ETHER_STAT_ADV_CAP_100FDX ||		\
1412311Sseb 	    (_ether_stat) == ETHER_STAT_ADV_CAP_100HDX ||		\
1422311Sseb 	    (_ether_stat) == ETHER_STAT_ADV_CAP_10FDX ||		\
1432311Sseb 	    (_ether_stat) == ETHER_STAT_ADV_CAP_10HDX ||		\
1442311Sseb 	    (_ether_stat) == ETHER_STAT_ADV_CAP_ASMPAUSE ||		\
1452311Sseb 	    (_ether_stat) == ETHER_STAT_ADV_CAP_PAUSE ||		\
1462311Sseb 	    (_ether_stat) == ETHER_STAT_ADV_CAP_AUTONEG ||		\
147*4089Sgd78059 	    (_ether_stat) == ETHER_STAT_ADV_REMFAULT ||			\
1482311Sseb 	    (_ether_stat) == ETHER_STAT_LP_CAP_1000FDX ||		\
1492311Sseb 	    (_ether_stat) == ETHER_STAT_LP_CAP_1000HDX ||		\
1502311Sseb 	    (_ether_stat) == ETHER_STAT_LP_CAP_100FDX ||		\
1512311Sseb 	    (_ether_stat) == ETHER_STAT_LP_CAP_100HDX ||		\
1522311Sseb 	    (_ether_stat) == ETHER_STAT_LP_CAP_10FDX ||			\
1532311Sseb 	    (_ether_stat) == ETHER_STAT_LP_CAP_10HDX ||			\
1542311Sseb 	    (_ether_stat) == ETHER_STAT_LP_CAP_ASMPAUSE ||		\
1552311Sseb 	    (_ether_stat) == ETHER_STAT_LP_CAP_PAUSE ||			\
1562311Sseb 	    (_ether_stat) == ETHER_STAT_LP_CAP_AUTONEG ||		\
157*4089Sgd78059 	    (_ether_stat) == ETHER_STAT_LP_REMFAULT ||			\
1582311Sseb 	    (_ether_stat) == ETHER_STAT_LINK_ASMPAUSE ||		\
1592311Sseb 	    (_ether_stat) == ETHER_STAT_LINK_PAUSE ||			\
1602311Sseb 	    (_ether_stat) == ETHER_STAT_LINK_AUTONEG ||			\
1612311Sseb 	    (_ether_stat) == ETHER_STAT_LINK_DUPLEX)
1622311Sseb 
1632311Sseb #endif	/* _KERNEL */
1642311Sseb 
1652311Sseb #ifdef	__cplusplus
1662311Sseb }
1672311Sseb #endif
1682311Sseb 
1692311Sseb #endif /* _SYS_MAC_ETHER_H */
170