xref: /titanic_51/usr/src/uts/common/sys/mac.h (revision 210db2243d3b5ca39c96a4c34c6d9453ddfbeaa9)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_MAC_H
287c478bd9Sstevel@tonic-gate #define	_SYS_MAC_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
337c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
347c478bd9Sstevel@tonic-gate #include <sys/stream.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate /*
377c478bd9Sstevel@tonic-gate  * MAC Services Module
387c478bd9Sstevel@tonic-gate  */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
417c478bd9Sstevel@tonic-gate extern "C" {
427c478bd9Sstevel@tonic-gate #endif
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * Module name.
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate #define	MAC_MODULE_NAME	"mac"
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * MAC Information (text emitted by modinfo(1m))
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate #define	MAC_INFO	"MAC Services v%I%"
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  * Statistics
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #define	XCVR_UNDEFINED		0
597c478bd9Sstevel@tonic-gate #define	XCVR_NONE		1
607c478bd9Sstevel@tonic-gate #define	XCVR_10			2
617c478bd9Sstevel@tonic-gate #define	XCVR_100T4		3
627c478bd9Sstevel@tonic-gate #define	XCVR_100X		4
637c478bd9Sstevel@tonic-gate #define	XCVR_100T2		5
647c478bd9Sstevel@tonic-gate #define	XCVR_1000X		6
657c478bd9Sstevel@tonic-gate #define	XCVR_1000T		7
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate typedef enum {
687c478bd9Sstevel@tonic-gate 	LINK_STATE_UNKNOWN = -1,
697c478bd9Sstevel@tonic-gate 	LINK_STATE_DOWN,
707c478bd9Sstevel@tonic-gate 	LINK_STATE_UP
717c478bd9Sstevel@tonic-gate } link_state_t;
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate typedef enum {
747c478bd9Sstevel@tonic-gate 	LINK_DUPLEX_UNKNOWN = 0,
757c478bd9Sstevel@tonic-gate 	LINK_DUPLEX_HALF,
767c478bd9Sstevel@tonic-gate 	LINK_DUPLEX_FULL
777c478bd9Sstevel@tonic-gate } link_duplex_t;
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate enum mac_stat {
827c478bd9Sstevel@tonic-gate 	/*
837c478bd9Sstevel@tonic-gate 	 * PSARC 1997/198 (MIB-II kstats)
847c478bd9Sstevel@tonic-gate 	 */
857c478bd9Sstevel@tonic-gate 	MAC_STAT_IFSPEED,
867c478bd9Sstevel@tonic-gate 	MAC_STAT_MULTIRCV,
877c478bd9Sstevel@tonic-gate 	MAC_STAT_BRDCSTRCV,
887c478bd9Sstevel@tonic-gate 	MAC_STAT_MULTIXMT,
897c478bd9Sstevel@tonic-gate 	MAC_STAT_BRDCSTXMT,
907c478bd9Sstevel@tonic-gate 	MAC_STAT_NORCVBUF,
917c478bd9Sstevel@tonic-gate 	MAC_STAT_IERRORS,
927c478bd9Sstevel@tonic-gate 	MAC_STAT_UNKNOWNS,
937c478bd9Sstevel@tonic-gate 	MAC_STAT_NOXMTBUF,
947c478bd9Sstevel@tonic-gate 	MAC_STAT_OERRORS,
957c478bd9Sstevel@tonic-gate 	MAC_STAT_COLLISIONS,
967c478bd9Sstevel@tonic-gate 	MAC_STAT_RBYTES,
977c478bd9Sstevel@tonic-gate 	MAC_STAT_IPACKETS,
987c478bd9Sstevel@tonic-gate 	MAC_STAT_OBYTES,
997c478bd9Sstevel@tonic-gate 	MAC_STAT_OPACKETS,
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate 	/*
1027c478bd9Sstevel@tonic-gate 	 * PSARC 1997/247 (RFC 1643 kstats)
1037c478bd9Sstevel@tonic-gate 	 */
1047c478bd9Sstevel@tonic-gate 	MAC_STAT_ALIGN_ERRORS,
1057c478bd9Sstevel@tonic-gate 	MAC_STAT_FCS_ERRORS,
1067c478bd9Sstevel@tonic-gate 	MAC_STAT_FIRST_COLLISIONS,
1077c478bd9Sstevel@tonic-gate 	MAC_STAT_MULTI_COLLISIONS,
1087c478bd9Sstevel@tonic-gate 	MAC_STAT_SQE_ERRORS,
1097c478bd9Sstevel@tonic-gate 	MAC_STAT_DEFER_XMTS,
1107c478bd9Sstevel@tonic-gate 	MAC_STAT_TX_LATE_COLLISIONS,
1117c478bd9Sstevel@tonic-gate 	MAC_STAT_EX_COLLISIONS,
1127c478bd9Sstevel@tonic-gate 	MAC_STAT_MACXMT_ERRORS,
1137c478bd9Sstevel@tonic-gate 	MAC_STAT_CARRIER_ERRORS,
1147c478bd9Sstevel@tonic-gate 	MAC_STAT_TOOLONG_ERRORS,
1157c478bd9Sstevel@tonic-gate 	MAC_STAT_MACRCV_ERRORS,
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate 	/*
1187c478bd9Sstevel@tonic-gate 	 * PSARC 2003/581 (MII/GMII kstats)
1197c478bd9Sstevel@tonic-gate 	 */
1207c478bd9Sstevel@tonic-gate 	MAC_STAT_XCVR_ADDR,
1217c478bd9Sstevel@tonic-gate 	MAC_STAT_XCVR_ID,
1227c478bd9Sstevel@tonic-gate 	MAC_STAT_XCVR_INUSE,
1237c478bd9Sstevel@tonic-gate 	MAC_STAT_CAP_1000FDX,
1247c478bd9Sstevel@tonic-gate 	MAC_STAT_CAP_1000HDX,
1257c478bd9Sstevel@tonic-gate 	MAC_STAT_CAP_100FDX,
1267c478bd9Sstevel@tonic-gate 	MAC_STAT_CAP_100HDX,
1277c478bd9Sstevel@tonic-gate 	MAC_STAT_CAP_10FDX,
1287c478bd9Sstevel@tonic-gate 	MAC_STAT_CAP_10HDX,
1297c478bd9Sstevel@tonic-gate 	MAC_STAT_CAP_ASMPAUSE,
1307c478bd9Sstevel@tonic-gate 	MAC_STAT_CAP_PAUSE,
1317c478bd9Sstevel@tonic-gate 	MAC_STAT_CAP_AUTONEG,
1327c478bd9Sstevel@tonic-gate 	MAC_STAT_ADV_CAP_1000FDX,
1337c478bd9Sstevel@tonic-gate 	MAC_STAT_ADV_CAP_1000HDX,
1347c478bd9Sstevel@tonic-gate 	MAC_STAT_ADV_CAP_100FDX,
1357c478bd9Sstevel@tonic-gate 	MAC_STAT_ADV_CAP_100HDX,
1367c478bd9Sstevel@tonic-gate 	MAC_STAT_ADV_CAP_10FDX,
1377c478bd9Sstevel@tonic-gate 	MAC_STAT_ADV_CAP_10HDX,
1387c478bd9Sstevel@tonic-gate 	MAC_STAT_ADV_CAP_ASMPAUSE,
1397c478bd9Sstevel@tonic-gate 	MAC_STAT_ADV_CAP_PAUSE,
1407c478bd9Sstevel@tonic-gate 	MAC_STAT_ADV_CAP_AUTONEG,
1417c478bd9Sstevel@tonic-gate 	MAC_STAT_LP_CAP_1000FDX,
1427c478bd9Sstevel@tonic-gate 	MAC_STAT_LP_CAP_1000HDX,
1437c478bd9Sstevel@tonic-gate 	MAC_STAT_LP_CAP_100FDX,
1447c478bd9Sstevel@tonic-gate 	MAC_STAT_LP_CAP_100HDX,
1457c478bd9Sstevel@tonic-gate 	MAC_STAT_LP_CAP_10FDX,
1467c478bd9Sstevel@tonic-gate 	MAC_STAT_LP_CAP_10HDX,
1477c478bd9Sstevel@tonic-gate 	MAC_STAT_LP_CAP_ASMPAUSE,
1487c478bd9Sstevel@tonic-gate 	MAC_STAT_LP_CAP_PAUSE,
1497c478bd9Sstevel@tonic-gate 	MAC_STAT_LP_CAP_AUTONEG,
1507c478bd9Sstevel@tonic-gate 	MAC_STAT_LINK_ASMPAUSE,
1517c478bd9Sstevel@tonic-gate 	MAC_STAT_LINK_PAUSE,
1527c478bd9Sstevel@tonic-gate 	MAC_STAT_LINK_AUTONEG,
1537c478bd9Sstevel@tonic-gate 	MAC_STAT_LINK_DUPLEX,
1547c478bd9Sstevel@tonic-gate 	MAC_NSTAT	/* must be the last entry */
1557c478bd9Sstevel@tonic-gate };
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate /*
1587c478bd9Sstevel@tonic-gate  * Maximum MAC address length
1597c478bd9Sstevel@tonic-gate  */
1607c478bd9Sstevel@tonic-gate #define	MAXADDRLEN	20
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate /*
1637c478bd9Sstevel@tonic-gate  * Immutable information. (This may not be modified after registration).
1647c478bd9Sstevel@tonic-gate  */
1657c478bd9Sstevel@tonic-gate typedef struct mac_info_s {
1667c478bd9Sstevel@tonic-gate 	uint_t		mi_media;
1677c478bd9Sstevel@tonic-gate 	uint_t		mi_sdu_min;
1687c478bd9Sstevel@tonic-gate 	uint_t		mi_sdu_max;
1697c478bd9Sstevel@tonic-gate 	uint32_t	mi_cksum;
1707c478bd9Sstevel@tonic-gate 	uint32_t	mi_poll;
1717c478bd9Sstevel@tonic-gate 	uint_t		mi_addr_length;
1727c478bd9Sstevel@tonic-gate 	uint8_t		mi_unicst_addr[MAXADDRLEN];
1737c478bd9Sstevel@tonic-gate 	uint8_t		mi_brdcst_addr[MAXADDRLEN];
1747c478bd9Sstevel@tonic-gate 	boolean_t	mi_stat[MAC_NSTAT];
1757c478bd9Sstevel@tonic-gate } mac_info_t;
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate #define	MAC_STAT_MIB(_mi_stat) \
1787c478bd9Sstevel@tonic-gate { \
1797c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_IFSPEED] = B_TRUE; \
1807c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_MULTIRCV] = B_TRUE; \
1817c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_BRDCSTRCV] = B_TRUE; \
1827c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_MULTIXMT] = B_TRUE; \
1837c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_BRDCSTXMT] = B_TRUE; \
1847c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_NORCVBUF] = B_TRUE; \
1857c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_IERRORS] = B_TRUE; \
1867c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_UNKNOWNS] = B_TRUE; \
1877c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_NOXMTBUF] = B_TRUE; \
1887c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_OERRORS] = B_TRUE; \
1897c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_COLLISIONS] = B_TRUE; \
1907c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_RBYTES] = B_TRUE; \
1917c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_IPACKETS] = B_TRUE; \
1927c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_OBYTES] = B_TRUE; \
1937c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_OPACKETS] = B_TRUE; \
1947c478bd9Sstevel@tonic-gate }
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate #define	MAC_STAT_ETHER(_mi_stat) \
1977c478bd9Sstevel@tonic-gate { \
1987c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_ALIGN_ERRORS] = B_TRUE; \
1997c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_FCS_ERRORS] = B_TRUE; \
2007c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_FIRST_COLLISIONS] = B_TRUE; \
2017c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_MULTI_COLLISIONS] = B_TRUE; \
2027c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_SQE_ERRORS] = B_TRUE; \
2037c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_DEFER_XMTS] = B_TRUE; \
2047c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_TX_LATE_COLLISIONS] = B_TRUE; \
2057c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_EX_COLLISIONS] = B_TRUE; \
2067c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_MACXMT_ERRORS] = B_TRUE; \
2077c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_CARRIER_ERRORS] = B_TRUE; \
2087c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_TOOLONG_ERRORS] = B_TRUE; \
2097c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_MACRCV_ERRORS] = B_TRUE; \
2107c478bd9Sstevel@tonic-gate }
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate #define	MAC_STAT_MII(_mi_stat) \
2137c478bd9Sstevel@tonic-gate { \
2147c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_XCVR_ADDR] = B_TRUE; \
2157c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_XCVR_ID] = B_TRUE; \
2167c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_XCVR_INUSE] = B_TRUE; \
2177c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_CAP_1000FDX] = B_TRUE; \
2187c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_CAP_1000HDX] = B_TRUE; \
2197c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_CAP_100FDX] = B_TRUE; \
2207c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_CAP_100HDX] = B_TRUE; \
2217c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_CAP_10FDX] = B_TRUE; \
2227c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_CAP_10HDX] = B_TRUE; \
2237c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_CAP_ASMPAUSE] = B_TRUE; \
2247c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_CAP_PAUSE] = B_TRUE; \
2257c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_CAP_AUTONEG] = B_TRUE; \
2267c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_ADV_CAP_1000FDX] = B_TRUE; \
2277c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_ADV_CAP_1000HDX] = B_TRUE; \
2287c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_ADV_CAP_100FDX] = B_TRUE; \
2297c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_ADV_CAP_100HDX] = B_TRUE; \
2307c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_ADV_CAP_10FDX] = B_TRUE; \
2317c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_ADV_CAP_10HDX] = B_TRUE; \
2327c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_ADV_CAP_ASMPAUSE] = B_TRUE; \
2337c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_ADV_CAP_PAUSE] = B_TRUE; \
2347c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_ADV_CAP_AUTONEG] = B_TRUE; \
2357c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LP_CAP_1000FDX] = B_TRUE; \
2367c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LP_CAP_1000HDX] = B_TRUE; \
2377c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LP_CAP_100FDX] = B_TRUE; \
2387c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LP_CAP_100HDX] = B_TRUE; \
2397c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LP_CAP_10FDX] = B_TRUE; \
2407c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LP_CAP_10HDX] = B_TRUE; \
2417c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LP_CAP_ASMPAUSE] = B_TRUE; \
2427c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LP_CAP_PAUSE] = B_TRUE; \
2437c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LP_CAP_AUTONEG] = B_TRUE; \
2447c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LINK_ASMPAUSE] = B_TRUE; \
2457c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LINK_PAUSE] = B_TRUE; \
2467c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LINK_AUTONEG] = B_TRUE; \
2477c478bd9Sstevel@tonic-gate 	(_mi_stat)[MAC_STAT_LINK_DUPLEX] = B_TRUE; \
2487c478bd9Sstevel@tonic-gate }
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate /*
2517c478bd9Sstevel@tonic-gate  * MAC version identifer (for debugging)
2527c478bd9Sstevel@tonic-gate  */
2537c478bd9Sstevel@tonic-gate #define	MAC_IDENT	"%I%"
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate /*
2567c478bd9Sstevel@tonic-gate  * MAC driver entry point types.
2577c478bd9Sstevel@tonic-gate  */
2587c478bd9Sstevel@tonic-gate typedef uint64_t	(*mac_stat_t)(void *, enum mac_stat);
2597c478bd9Sstevel@tonic-gate typedef	int		(*mac_start_t)(void *);
2607c478bd9Sstevel@tonic-gate typedef void		(*mac_stop_t)(void *);
2617c478bd9Sstevel@tonic-gate typedef int		(*mac_promisc_t)(void *, boolean_t);
2627c478bd9Sstevel@tonic-gate typedef int		(*mac_multicst_t)(void *, boolean_t, const uint8_t *);
2637c478bd9Sstevel@tonic-gate typedef int		(*mac_unicst_t)(void *, const uint8_t *);
2647c478bd9Sstevel@tonic-gate typedef void		(*mac_resources_t)(void *);
2657c478bd9Sstevel@tonic-gate typedef void		(*mac_ioctl_t)(void *, queue_t *, mblk_t *);
2667c478bd9Sstevel@tonic-gate typedef mblk_t		*(*mac_tx_t)(void *, mblk_t *);
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate /*
2697c478bd9Sstevel@tonic-gate  * MAC extensions. (Currently there are non defined).
2707c478bd9Sstevel@tonic-gate  */
2717c478bd9Sstevel@tonic-gate typedef struct mac_ext_s	mac_ext_t;
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate /*
2747c478bd9Sstevel@tonic-gate  * MAC implementation private data.
2757c478bd9Sstevel@tonic-gate  */
2767c478bd9Sstevel@tonic-gate typedef struct mac_impl_s	mac_impl_t;
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate /*
2797c478bd9Sstevel@tonic-gate  * MAC structure: supplied by the driver.
2807c478bd9Sstevel@tonic-gate  */
2817c478bd9Sstevel@tonic-gate typedef struct mac {
2827c478bd9Sstevel@tonic-gate 	const char	*m_ident;	/* MAC_IDENT */
2837c478bd9Sstevel@tonic-gate 	mac_ext_t	*m_extp;
2847c478bd9Sstevel@tonic-gate 	mac_impl_t	*m_impl;	/* MAC private data */
2857c478bd9Sstevel@tonic-gate 	void		*m_driver;	/* Driver private data */
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate 	dev_info_t	*m_dip;
2887c478bd9Sstevel@tonic-gate 	uint_t		m_port;
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate 	mac_info_t	m_info;
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate 	mac_stat_t	m_stat;
2937c478bd9Sstevel@tonic-gate 	mac_start_t	m_start;
2947c478bd9Sstevel@tonic-gate 	mac_stop_t	m_stop;
2957c478bd9Sstevel@tonic-gate 	mac_promisc_t	m_promisc;
2967c478bd9Sstevel@tonic-gate 	mac_multicst_t	m_multicst;
2977c478bd9Sstevel@tonic-gate 	mac_unicst_t	m_unicst;
2987c478bd9Sstevel@tonic-gate 	mac_resources_t	m_resources;
2997c478bd9Sstevel@tonic-gate 	mac_ioctl_t	m_ioctl;
3007c478bd9Sstevel@tonic-gate 	mac_tx_t	m_tx;
3017c478bd9Sstevel@tonic-gate } mac_t;
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate /*
3047c478bd9Sstevel@tonic-gate  * Construct the name of a MAC interface.
3057c478bd9Sstevel@tonic-gate  */
3067c478bd9Sstevel@tonic-gate #define	MAC_NAME(_name, _dev, _port) \
3077c478bd9Sstevel@tonic-gate 	(void) snprintf((_name), MAXNAMELEN - 1, "%s/%u", (_dev), (_port))
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate /*
3107c478bd9Sstevel@tonic-gate  * Opaque handle types.
3117c478bd9Sstevel@tonic-gate  */
3127c478bd9Sstevel@tonic-gate typedef	struct __mac_handle		*mac_handle_t;
3137c478bd9Sstevel@tonic-gate typedef struct __mac_notify_handle	*mac_notify_handle_t;
3147c478bd9Sstevel@tonic-gate typedef struct __mac_rx_handle		*mac_rx_handle_t;
3157c478bd9Sstevel@tonic-gate typedef struct __mac_txloop_handle	*mac_txloop_handle_t;
3167c478bd9Sstevel@tonic-gate typedef struct __mac_resource_handle	*mac_resource_handle_t;
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate /*
3197c478bd9Sstevel@tonic-gate  * MAC interface callback types.
3207c478bd9Sstevel@tonic-gate  */
3217c478bd9Sstevel@tonic-gate typedef enum {
3227c478bd9Sstevel@tonic-gate 	MAC_NOTE_LINK,
3237c478bd9Sstevel@tonic-gate 	MAC_NOTE_PROMISC,
3247c478bd9Sstevel@tonic-gate 	MAC_NOTE_UNICST,
3257c478bd9Sstevel@tonic-gate 	MAC_NOTE_TX,
3267c478bd9Sstevel@tonic-gate 	MAC_NOTE_RESOURCE,
3277c478bd9Sstevel@tonic-gate 	MAC_NOTE_DEVPROMISC,
3287c478bd9Sstevel@tonic-gate 	MAC_NNOTE	/* must be the last entry */
3297c478bd9Sstevel@tonic-gate } mac_notify_type_t;
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate typedef void		(*mac_notify_t)(void *, mac_notify_type_t);
3327c478bd9Sstevel@tonic-gate typedef void		(*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *);
3337c478bd9Sstevel@tonic-gate typedef void		(*mac_txloop_t)(void *, mblk_t *);
3347c478bd9Sstevel@tonic-gate typedef void		(*mac_blank_t)(void *, time_t, uint_t);
3357c478bd9Sstevel@tonic-gate 
3367c478bd9Sstevel@tonic-gate /*
3377c478bd9Sstevel@tonic-gate  * MAC promiscuous types
3387c478bd9Sstevel@tonic-gate  */
3397c478bd9Sstevel@tonic-gate typedef enum {
3407c478bd9Sstevel@tonic-gate 	MAC_PROMISC = 0x01,		/* MAC instance is promiscuous */
3417c478bd9Sstevel@tonic-gate 	MAC_DEVPROMISC = 0x02		/* Device is promiscuous */
3427c478bd9Sstevel@tonic-gate } mac_promisc_type_t;
3437c478bd9Sstevel@tonic-gate 
3447c478bd9Sstevel@tonic-gate /*
3457c478bd9Sstevel@tonic-gate  * MAC resource types
3467c478bd9Sstevel@tonic-gate  */
3477c478bd9Sstevel@tonic-gate typedef enum {
3487c478bd9Sstevel@tonic-gate 	MAC_RX_FIFO = 1
3497c478bd9Sstevel@tonic-gate } mac_resource_type_t;
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate typedef struct mac_rx_fifo_s {
3527c478bd9Sstevel@tonic-gate 	mac_resource_type_t	mrf_type;	/* MAC_RX_FIFO */
3537c478bd9Sstevel@tonic-gate 	mac_blank_t		mrf_blank;
3547c478bd9Sstevel@tonic-gate 	void			*mrf_arg;
3557c478bd9Sstevel@tonic-gate 	time_t			mrf_normal_blank_time;
3567c478bd9Sstevel@tonic-gate 	uint_t			mrf_normal_pkt_count;
3577c478bd9Sstevel@tonic-gate } mac_rx_fifo_t;
3587c478bd9Sstevel@tonic-gate 
35998b1442aSmeem typedef struct mac_txinfo_s {
36098b1442aSmeem 	mac_tx_t		mt_fn;
36198b1442aSmeem 	void			*mt_arg;
36298b1442aSmeem } mac_txinfo_t;
36398b1442aSmeem 
3647c478bd9Sstevel@tonic-gate typedef union mac_resource_u {
3657c478bd9Sstevel@tonic-gate 	mac_resource_type_t	mr_type;
3667c478bd9Sstevel@tonic-gate 	mac_rx_fifo_t		mr_fifo;
3677c478bd9Sstevel@tonic-gate } mac_resource_t;
3687c478bd9Sstevel@tonic-gate 
3697c478bd9Sstevel@tonic-gate typedef mac_resource_handle_t	(*mac_resource_add_t)(void *, mac_resource_t *);
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate /*
3727c478bd9Sstevel@tonic-gate  * Client interface functions.
3737c478bd9Sstevel@tonic-gate  */
3747c478bd9Sstevel@tonic-gate extern int			mac_open(const char *, uint_t, mac_handle_t *);
3757c478bd9Sstevel@tonic-gate extern void			mac_close(mac_handle_t);
3767c478bd9Sstevel@tonic-gate extern const mac_info_t		*mac_info(mac_handle_t);
377*210db224Sericheng extern boolean_t		mac_info_get(const char *, mac_info_t *);
3787c478bd9Sstevel@tonic-gate extern uint64_t			mac_stat_get(mac_handle_t, enum mac_stat);
3797c478bd9Sstevel@tonic-gate extern int			mac_start(mac_handle_t);
3807c478bd9Sstevel@tonic-gate extern void			mac_stop(mac_handle_t);
3817c478bd9Sstevel@tonic-gate extern int			mac_promisc_set(mac_handle_t, boolean_t,
3827c478bd9Sstevel@tonic-gate     mac_promisc_type_t);
3837c478bd9Sstevel@tonic-gate extern boolean_t		mac_promisc_get(mac_handle_t,
3847c478bd9Sstevel@tonic-gate     mac_promisc_type_t);
3857c478bd9Sstevel@tonic-gate extern int 			mac_multicst_add(mac_handle_t, const uint8_t *);
3867c478bd9Sstevel@tonic-gate extern int 			mac_multicst_remove(mac_handle_t,
3877c478bd9Sstevel@tonic-gate     const uint8_t *);
3887c478bd9Sstevel@tonic-gate extern int			mac_unicst_set(mac_handle_t, const uint8_t *);
3897c478bd9Sstevel@tonic-gate extern void			mac_unicst_get(mac_handle_t, uint8_t *);
3907c478bd9Sstevel@tonic-gate extern void			mac_resources(mac_handle_t);
3917c478bd9Sstevel@tonic-gate extern void			mac_ioctl(mac_handle_t, queue_t *, mblk_t *);
39298b1442aSmeem extern const mac_txinfo_t	*mac_tx_get(mac_handle_t);
3937c478bd9Sstevel@tonic-gate extern link_state_t		mac_link_get(mac_handle_t);
3947c478bd9Sstevel@tonic-gate extern mac_notify_handle_t	mac_notify_add(mac_handle_t, mac_notify_t,
3957c478bd9Sstevel@tonic-gate     void *);
3967c478bd9Sstevel@tonic-gate extern void			mac_notify_remove(mac_handle_t,
3977c478bd9Sstevel@tonic-gate     mac_notify_handle_t);
3987c478bd9Sstevel@tonic-gate extern void			mac_notify(mac_handle_t);
3997c478bd9Sstevel@tonic-gate extern mac_rx_handle_t		mac_rx_add(mac_handle_t, mac_rx_t, void *);
4007c478bd9Sstevel@tonic-gate extern void			mac_rx_remove(mac_handle_t, mac_rx_handle_t);
4017c478bd9Sstevel@tonic-gate extern mblk_t			*mac_txloop(void *, mblk_t *);
4027c478bd9Sstevel@tonic-gate extern mac_txloop_handle_t	mac_txloop_add(mac_handle_t, mac_txloop_t,
4037c478bd9Sstevel@tonic-gate     void *);
4047c478bd9Sstevel@tonic-gate extern void			mac_txloop_remove(mac_handle_t,
4057c478bd9Sstevel@tonic-gate     mac_txloop_handle_t);
4067c478bd9Sstevel@tonic-gate extern boolean_t		mac_active_set(mac_handle_t);
4077c478bd9Sstevel@tonic-gate extern void			mac_active_clear(mac_handle_t);
4087c478bd9Sstevel@tonic-gate extern void			mac_resource_set(mac_handle_t,
4097c478bd9Sstevel@tonic-gate     mac_resource_add_t, void *);
410*210db224Sericheng extern dev_info_t		*mac_devinfo_get(mac_handle_t);
4117c478bd9Sstevel@tonic-gate 
4127c478bd9Sstevel@tonic-gate /*
4137c478bd9Sstevel@tonic-gate  * Driver interface functions.
4147c478bd9Sstevel@tonic-gate  */
4157c478bd9Sstevel@tonic-gate extern int  			mac_register(mac_t *);
4167c478bd9Sstevel@tonic-gate extern int  			mac_unregister(mac_t *);
4177c478bd9Sstevel@tonic-gate extern void 			mac_rx(mac_t *, mac_resource_handle_t,
4187c478bd9Sstevel@tonic-gate     mblk_t *);
4197c478bd9Sstevel@tonic-gate extern void 			mac_link_update(mac_t *, link_state_t);
4207c478bd9Sstevel@tonic-gate extern void 			mac_unicst_update(mac_t *, const uint8_t *);
4217c478bd9Sstevel@tonic-gate extern void			mac_tx_update(mac_t *);
4227c478bd9Sstevel@tonic-gate extern void			mac_resource_update(mac_t *);
4237c478bd9Sstevel@tonic-gate extern mac_resource_handle_t	mac_resource_add(mac_t *, mac_resource_t *);
4247c478bd9Sstevel@tonic-gate extern void			mac_multicst_refresh(mac_t *, mac_multicst_t,
4257c478bd9Sstevel@tonic-gate     void *, boolean_t);
4267c478bd9Sstevel@tonic-gate extern void			mac_unicst_refresh(mac_t *, mac_unicst_t,
4277c478bd9Sstevel@tonic-gate     void *);
4287c478bd9Sstevel@tonic-gate extern void			mac_promisc_refresh(mac_t *, mac_promisc_t,
4297c478bd9Sstevel@tonic-gate     void *);
430*210db224Sericheng extern void			mac_init_ops(struct dev_ops *, const char *);
431*210db224Sericheng extern void			mac_fini_ops(struct dev_ops *);
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
4347c478bd9Sstevel@tonic-gate 
4357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4367c478bd9Sstevel@tonic-gate }
4377c478bd9Sstevel@tonic-gate #endif
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate #endif /* _SYS_MAC_H */
440