xref: /onnv-gate/usr/src/uts/common/sys/mac_impl.h (revision 10616)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51852Syz147064  * Common Development and Distribution License (the "License").
61852Syz147064  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
228833SVenu.Iyer@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_MAC_IMPL_H
270Sstevel@tonic-gate #define	_SYS_MAC_IMPL_H
280Sstevel@tonic-gate 
298275SEric Cheng #include <sys/modhash.h>
308275SEric Cheng #include <sys/mac_client.h>
318275SEric Cheng #include <sys/mac_provider.h>
3210491SRishi.Srivatsavai@Sun.COM #include <sys/note.h>
332311Sseb #include <net/if.h>
348275SEric Cheng #include <sys/mac_flow_impl.h>
358275SEric Cheng #include <netinet/ip6.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifdef	__cplusplus
380Sstevel@tonic-gate extern "C" {
390Sstevel@tonic-gate #endif
400Sstevel@tonic-gate 
415895Syz147064 typedef struct mac_margin_req_s	mac_margin_req_t;
425895Syz147064 
435895Syz147064 struct mac_margin_req_s {
445895Syz147064 	mac_margin_req_t	*mmr_nextp;
455895Syz147064 	uint_t			mmr_ref;
465895Syz147064 	uint32_t		mmr_margin;
475895Syz147064 };
485895Syz147064 
498275SEric Cheng /* Generic linked chain type */
508275SEric Cheng typedef	struct mac_chain_s {
518275SEric Cheng 	struct mac_chain_s	*next;
528275SEric Cheng 	void			*item;
538275SEric Cheng } mac_chain_t;
548275SEric Cheng 
558275SEric Cheng /*
568275SEric Cheng  * Generic mac callback list manipulation structures and macros. The mac_cb_t
578275SEric Cheng  * represents a general callback list element embedded in a particular
588275SEric Cheng  * data structure such as a mac_notify_cb_t or a mac_promisc_impl_t.
598275SEric Cheng  * The mac_cb_info_t represents general information about list walkers.
608275SEric Cheng  * Please see the comments above mac_callback_add for more information.
618275SEric Cheng  */
628275SEric Cheng /* mcb_flags */
638275SEric Cheng #define	MCB_CONDEMNED		0x1		/* Logically deleted */
648275SEric Cheng #define	MCB_NOTIFY_CB_T		0x2
658275SEric Cheng #define	MCB_TX_NOTIFY_CB_T	0x4
660Sstevel@tonic-gate 
678275SEric Cheng typedef struct mac_cb_s {
688275SEric Cheng 	struct mac_cb_s		*mcb_nextp;	/* Linked list of callbacks */
698275SEric Cheng 	void			*mcb_objp;	/* Ptr to enclosing object  */
708275SEric Cheng 	size_t			mcb_objsize;	/* Sizeof the enclosing obj */
718275SEric Cheng 	uint_t			mcb_flags;
728275SEric Cheng } mac_cb_t;
730Sstevel@tonic-gate 
748275SEric Cheng typedef struct mac_cb_info_s {
758275SEric Cheng 	kmutex_t	*mcbi_lockp;
768275SEric Cheng 	kcondvar_t	mcbi_cv;
778275SEric Cheng 	uint_t		mcbi_del_cnt;		/* Deleted callback cnt */
788275SEric Cheng 	uint_t		mcbi_walker_cnt;	/* List walker count */
798275SEric Cheng } mac_cb_info_t;
808275SEric Cheng 
818275SEric Cheng typedef struct mac_notify_cb_s {
828275SEric Cheng 	mac_cb_t	mncb_link;		/* Linked list of callbacks */
838275SEric Cheng 	mac_notify_t	mncb_fn;		/* callback function */
848275SEric Cheng 	void		*mncb_arg;		/* callback argument */
858275SEric Cheng 	struct mac_impl_s *mncb_mip;
868275SEric Cheng } mac_notify_cb_t;
870Sstevel@tonic-gate 
888275SEric Cheng /*
898275SEric Cheng  * mac_callback_add(listinfo, listhead, listelement)
908275SEric Cheng  * mac_callback_remove(listinfo, listhead, listelement)
918275SEric Cheng  */
928275SEric Cheng typedef boolean_t (*mcb_func_t)(mac_cb_info_t *, mac_cb_t **, mac_cb_t *);
938275SEric Cheng 
948275SEric Cheng #define	MAC_CALLBACK_WALKER_INC(mcbi) {				\
958275SEric Cheng 	mutex_enter((mcbi)->mcbi_lockp);			\
968275SEric Cheng 	(mcbi)->mcbi_walker_cnt++;				\
978275SEric Cheng 	mutex_exit((mcbi)->mcbi_lockp);				\
988275SEric Cheng }
998275SEric Cheng 
1008275SEric Cheng #define	MAC_CALLBACK_WALKER_INC_HELD(mcbi)	(mcbi)->mcbi_walker_cnt++;
1010Sstevel@tonic-gate 
1028275SEric Cheng #define	MAC_CALLBACK_WALKER_DCR(mcbi, headp) {			\
1038275SEric Cheng 	mac_cb_t	*rmlist;				\
1048275SEric Cheng 								\
1058275SEric Cheng 	mutex_enter((mcbi)->mcbi_lockp);			\
1068275SEric Cheng 	if (--(mcbi)->mcbi_walker_cnt == 0 && (mcbi)->mcbi_del_cnt != 0) { \
1078275SEric Cheng 		rmlist = mac_callback_walker_cleanup((mcbi), headp);	\
1088275SEric Cheng 		mac_callback_free(rmlist);			\
1098275SEric Cheng 		cv_broadcast(&(mcbi)->mcbi_cv);			\
1108275SEric Cheng 	}							\
1118275SEric Cheng 	mutex_exit((mcbi)->mcbi_lockp);				\
1128275SEric Cheng }
1130Sstevel@tonic-gate 
1148275SEric Cheng #define	MAC_PROMISC_WALKER_INC(mip)				\
1158275SEric Cheng 	MAC_CALLBACK_WALKER_INC(&(mip)->mi_promisc_cb_info)
1168275SEric Cheng 
1178275SEric Cheng #define	MAC_PROMISC_WALKER_DCR(mip) {				\
1188275SEric Cheng 	mac_cb_info_t	*mcbi;					\
1198275SEric Cheng 								\
1208275SEric Cheng 	mcbi = &(mip)->mi_promisc_cb_info;			\
1218275SEric Cheng 	mutex_enter(mcbi->mcbi_lockp);				\
1228275SEric Cheng 	if (--mcbi->mcbi_walker_cnt == 0 && mcbi->mcbi_del_cnt != 0) { \
1238275SEric Cheng 		i_mac_promisc_walker_cleanup(mip);		\
1248275SEric Cheng 		cv_broadcast(&mcbi->mcbi_cv);			\
1258275SEric Cheng 	}							\
1268275SEric Cheng 	mutex_exit(mcbi->mcbi_lockp);				\
1278275SEric Cheng }
1280Sstevel@tonic-gate 
1292311Sseb typedef struct mactype_s {
1302311Sseb 	const char	*mt_ident;
1312311Sseb 	uint32_t	mt_ref;
1322311Sseb 	uint_t		mt_type;
1333147Sxc151355 	uint_t		mt_nativetype;
1342311Sseb 	size_t		mt_addr_length;
1352311Sseb 	uint8_t		*mt_brdcst_addr;
1362311Sseb 	mactype_ops_t	mt_ops;
1372311Sseb 	mac_stat_info_t	*mt_stats;	/* array of mac_stat_info_t elements */
1382311Sseb 	size_t		mt_statcount;	/* number of elements in mt_stats */
1396512Ssowmini 	mac_ndd_mapping_t *mt_mapping;
1406512Ssowmini 	size_t		mt_mappingcount;
1412311Sseb } mactype_t;
1420Sstevel@tonic-gate 
1438275SEric Cheng /*
1448275SEric Cheng  * Multiple rings implementation.
1458275SEric Cheng  */
1468275SEric Cheng typedef	enum {
1478275SEric Cheng 	MAC_GROUP_STATE_UNINIT	= 0,	/* initial state of data structure */
1488275SEric Cheng 	MAC_GROUP_STATE_REGISTERED,	/* hooked with h/w group */
1498275SEric Cheng 	MAC_GROUP_STATE_RESERVED,	/* group is reserved and opened */
1508275SEric Cheng 	MAC_GROUP_STATE_SHARED		/* default group shared among */
1518275SEric Cheng 					/* multiple mac clients */
1528275SEric Cheng } mac_group_state_t;
1535084Sjohnlev 
1548275SEric Cheng typedef	struct mac_ring_s mac_ring_t;
1558275SEric Cheng typedef	struct mac_group_s mac_group_t;
1568275SEric Cheng 
1578275SEric Cheng /*
1588275SEric Cheng  * Ring data structure for ring control and management.
1598275SEric Cheng  */
1608275SEric Cheng typedef enum {
1618275SEric Cheng 	MR_FREE,		/* Available for assignment to flows */
1628275SEric Cheng 	MR_NEWLY_ADDED,		/* Just assigned to another group */
1638275SEric Cheng 	MR_INUSE		/* Assigned to an SRS */
1648275SEric Cheng } mac_ring_state_t;
1658275SEric Cheng 
1668275SEric Cheng /* mr_flag values */
1678275SEric Cheng #define	MR_INCIPIENT	0x1
1688275SEric Cheng #define	MR_CONDEMNED	0x2
1698275SEric Cheng #define	MR_QUIESCE	0x4
1708275SEric Cheng 
1718275SEric Cheng struct mac_ring_s {
1728275SEric Cheng 	int			mr_index;	/* index in the original list */
1738275SEric Cheng 	mac_ring_type_t		mr_type;	/* ring type */
1748275SEric Cheng 	mac_ring_t		*mr_next;	/* next ring in the chain */
1758275SEric Cheng 	mac_group_handle_t	mr_gh;		/* reference to group */
1768275SEric Cheng 
1778275SEric Cheng 	mac_classify_type_t	mr_classify_type;	/* HW vs SW */
1788275SEric Cheng 	struct mac_soft_ring_set_s *mr_srs;		/* associated SRS */
1798275SEric Cheng 	uint_t			mr_refcnt;		/* Ring references */
1808275SEric Cheng 	/* ring generation no. to guard against drivers using stale rings */
1818275SEric Cheng 	uint64_t		mr_gen_num;
1828275SEric Cheng 
1838275SEric Cheng 	kmutex_t		mr_lock;
1848275SEric Cheng 	kcondvar_t		mr_cv;			/* mr_lock */
1858275SEric Cheng 	mac_ring_state_t	mr_state;		/* mr_lock */
1868275SEric Cheng 	uint_t			mr_flag;		/* mr_lock */
1878275SEric Cheng 
1888275SEric Cheng 	mac_ring_info_t		mr_info;	/* driver supplied info */
1898275SEric Cheng };
1908275SEric Cheng #define	mr_driver		mr_info.mri_driver
1918275SEric Cheng #define	mr_start		mr_info.mri_start
1928275SEric Cheng #define	mr_stop			mr_info.mri_stop
1938275SEric Cheng 
1948275SEric Cheng #define	MAC_RING_MARK(mr, flag)		\
1958275SEric Cheng 	(mr)->mr_flag |= flag;
1968275SEric Cheng 
1978275SEric Cheng #define	MAC_RING_UNMARK(mr, flag)	\
1988275SEric Cheng 	(mr)->mr_flag &= ~flag;
1998275SEric Cheng 
2008275SEric Cheng /*
2018275SEric Cheng  * Reference hold and release on mac_ring_t 'mr'
2028275SEric Cheng  */
2038275SEric Cheng #define	MR_REFHOLD_LOCKED(mr)		{		\
2048275SEric Cheng 	ASSERT(MUTEX_HELD(&mr->mr_lock));		\
2058275SEric Cheng 	(mr)->mr_refcnt++;				\
2065084Sjohnlev }
2075084Sjohnlev 
2088275SEric Cheng #define	MR_REFRELE(mr)		{	 		\
2098275SEric Cheng 	mutex_enter(&(mr)->mr_lock);			\
2108275SEric Cheng 	ASSERT((mr)->mr_refcnt != 0);			\
2118275SEric Cheng 	(mr)->mr_refcnt--;				\
2128275SEric Cheng 	if ((mr)->mr_refcnt == 0 &&			\
2138275SEric Cheng 	    ((mr)->mr_flag & (MR_CONDEMNED | MR_QUIESCE))) \
2148275SEric Cheng 		cv_signal(&(mr)->mr_cv);		\
2158275SEric Cheng 	mutex_exit(&(mr)->mr_lock);			\
2165084Sjohnlev }
2175084Sjohnlev 
2188275SEric Cheng /*
2198275SEric Cheng  * Per mac client flow information associated with a RX group.
2208275SEric Cheng  * The entire structure is SL protected.
2218275SEric Cheng  */
2228275SEric Cheng typedef struct mac_grp_client {
2238275SEric Cheng 	struct mac_grp_client		*mgc_next;
2248275SEric Cheng 	struct mac_client_impl_s	*mgc_client;
2258275SEric Cheng } mac_grp_client_t;
2265084Sjohnlev 
2278275SEric Cheng #define	MAC_RX_GROUP_NO_CLIENT(g)	((g)->mrg_clients == NULL)
2288275SEric Cheng 
2298275SEric Cheng #define	MAC_RX_GROUP_ONLY_CLIENT(g)			\
2308275SEric Cheng 	((((g)->mrg_clients != NULL) &&			\
2318275SEric Cheng 	((g)->mrg_clients->mgc_next == NULL)) ?		\
2328275SEric Cheng 	(g)->mrg_clients->mgc_client : NULL)
2336512Ssowmini 
2342311Sseb /*
2358275SEric Cheng  * Common ring group data structure for ring control and management.
2368275SEric Cheng  * The entire structure is SL protected
2372311Sseb  */
2388275SEric Cheng struct mac_group_s {
2398275SEric Cheng 	int			mrg_index;	/* index in the list */
2408275SEric Cheng 	mac_ring_type_t		mrg_type;	/* ring type */
2418275SEric Cheng 	mac_group_state_t	mrg_state;	/* state of the group */
2428275SEric Cheng 	mac_group_t		*mrg_next;	/* next ring in the chain */
2438275SEric Cheng 	mac_handle_t		mrg_mh;		/* reference to MAC */
2448275SEric Cheng 	mac_ring_t		*mrg_rings;	/* grouped rings */
2458275SEric Cheng 	uint_t			mrg_cur_count;	/* actual size of group */
2468275SEric Cheng 
2478275SEric Cheng 	mac_grp_client_t	*mrg_clients;	/* clients list */
2488275SEric Cheng 
2498275SEric Cheng 	struct mac_client_impl_s *mrg_tx_client; /* TX client pointer */
2508275SEric Cheng 	mac_group_info_t	mrg_info;	/* driver supplied info */
2518275SEric Cheng };
2528275SEric Cheng 
2538275SEric Cheng #define	mrg_driver		mrg_info.mgi_driver
2548275SEric Cheng #define	mrg_start		mrg_info.mgi_start
2558275SEric Cheng #define	mrg_stop		mrg_info.mgi_stop
2568275SEric Cheng 
2578275SEric Cheng #define	GROUP_INTR_HANDLE(g)		(g)->mrg_info.mgi_intr.mi_handle
2588275SEric Cheng #define	GROUP_INTR_ENABLE_FUNC(g)	(g)->mrg_info.mgi_intr.mi_enable
2598275SEric Cheng #define	GROUP_INTR_DISABLE_FUNC(g)	(g)->mrg_info.mgi_intr.mi_disable
2608275SEric Cheng 
2618275SEric Cheng #define	MAC_DEFAULT_GROUP(mh)		(((mac_impl_t *)mh)->mi_rx_groups)
2628275SEric Cheng 
26310491SRishi.Srivatsavai@Sun.COM #define	MAC_RING_TX(mhp, rh, mp, rest) {				\
26410491SRishi.Srivatsavai@Sun.COM 	mac_ring_handle_t mrh = rh;					\
26510491SRishi.Srivatsavai@Sun.COM 	mac_impl_t *mimpl = (mac_impl_t *)mhp;				\
2668275SEric Cheng 	/*								\
26710491SRishi.Srivatsavai@Sun.COM 	 * Send packets through a selected tx ring, or through the 	\
26810491SRishi.Srivatsavai@Sun.COM 	 * default handler if there is no selected ring.		\
2698275SEric Cheng 	 */								\
27010491SRishi.Srivatsavai@Sun.COM 	if (mrh == NULL)						\
27110491SRishi.Srivatsavai@Sun.COM 		mrh = mimpl->mi_default_tx_ring;			\
27210491SRishi.Srivatsavai@Sun.COM 	if (mrh == NULL) {						\
27310491SRishi.Srivatsavai@Sun.COM 		rest = mimpl->mi_tx(mimpl->mi_driver, mp);		\
27410491SRishi.Srivatsavai@Sun.COM 	} else {							\
27510491SRishi.Srivatsavai@Sun.COM 		rest = mac_hwring_tx(mrh, mp);				\
27610491SRishi.Srivatsavai@Sun.COM 	}								\
27710491SRishi.Srivatsavai@Sun.COM }
27810491SRishi.Srivatsavai@Sun.COM 
27910491SRishi.Srivatsavai@Sun.COM /*
28010491SRishi.Srivatsavai@Sun.COM  * This is the final stop before reaching the underlying driver
28110491SRishi.Srivatsavai@Sun.COM  * or aggregation, so this is where the bridging hook is implemented.
28210491SRishi.Srivatsavai@Sun.COM  * Packets that are bridged will return through mac_bridge_tx(), with
28310491SRishi.Srivatsavai@Sun.COM  * rh nulled out if the bridge chooses to send output on a different
28410491SRishi.Srivatsavai@Sun.COM  * link due to forwarding.
28510491SRishi.Srivatsavai@Sun.COM  */
28610491SRishi.Srivatsavai@Sun.COM #define	MAC_TX(mip, rh, mp, share_bound) {				\
28710491SRishi.Srivatsavai@Sun.COM 	/*								\
28810491SRishi.Srivatsavai@Sun.COM 	 * If there is a bound Hybrid I/O share, send packets through 	\
28910491SRishi.Srivatsavai@Sun.COM 	 * the default tx ring. (When there's a bound Hybrid I/O share,	\
29010491SRishi.Srivatsavai@Sun.COM 	 * the tx rings of this client are mapped in the guest domain 	\
29110491SRishi.Srivatsavai@Sun.COM 	 * and not accessible from here.)				\
29210491SRishi.Srivatsavai@Sun.COM 	 */								\
29310491SRishi.Srivatsavai@Sun.COM 	_NOTE(CONSTANTCONDITION)					\
29410491SRishi.Srivatsavai@Sun.COM 	if (share_bound)						\
29510491SRishi.Srivatsavai@Sun.COM 		rh = NULL;						\
29610491SRishi.Srivatsavai@Sun.COM 	/*								\
29710491SRishi.Srivatsavai@Sun.COM 	 * Grab the proper transmit pointer and handle. Special 	\
29810491SRishi.Srivatsavai@Sun.COM 	 * optimization: we can test mi_bridge_link itself atomically,	\
29910491SRishi.Srivatsavai@Sun.COM 	 * and if that indicates no bridge send packets through tx ring.\
30010491SRishi.Srivatsavai@Sun.COM 	 */								\
30110491SRishi.Srivatsavai@Sun.COM 	if (mip->mi_bridge_link == NULL) {				\
30210491SRishi.Srivatsavai@Sun.COM 		MAC_RING_TX(mip, rh, mp, mp);				\
30310491SRishi.Srivatsavai@Sun.COM 	} else {							\
30410491SRishi.Srivatsavai@Sun.COM 		mp = mac_bridge_tx(mip, rh, mp);			\
30510491SRishi.Srivatsavai@Sun.COM 	}								\
3068275SEric Cheng }
3078275SEric Cheng 
3088275SEric Cheng /* mci_tx_flag */
3098275SEric Cheng #define	MCI_TX_QUIESCE	0x1
3108275SEric Cheng 
3118275SEric Cheng typedef struct mac_factory_addr_s {
3128275SEric Cheng 	boolean_t		mfa_in_use;
3138275SEric Cheng 	uint8_t			mfa_addr[MAXMACADDRLEN];
3148275SEric Cheng 	struct mac_client_impl_s	*mfa_client;
3158275SEric Cheng } mac_factory_addr_t;
3165895Syz147064 
3178275SEric Cheng typedef struct mac_mcast_addrs_s {
3188275SEric Cheng 	struct mac_mcast_addrs_s	*mma_next;
3198275SEric Cheng 	uint8_t				mma_addr[MAXMACADDRLEN];
3208275SEric Cheng 	int				mma_ref;
3218275SEric Cheng } mac_mcast_addrs_t;
3228275SEric Cheng 
3238275SEric Cheng typedef enum {
3248275SEric Cheng 	MAC_ADDRESS_TYPE_UNICAST_CLASSIFIED = 1,	/* hardware steering */
3258275SEric Cheng 	MAC_ADDRESS_TYPE_UNICAST_PROMISC		/* promiscuous mode */
3268275SEric Cheng } mac_address_type_t;
3278275SEric Cheng 
3288275SEric Cheng typedef struct mac_impl_s mac_impl_t;
3298275SEric Cheng 
3308275SEric Cheng typedef struct mac_address_s {
3318275SEric Cheng 	mac_address_type_t	ma_type;		/* address type */
3328275SEric Cheng 	int			ma_nusers;		/* number of users */
3338275SEric Cheng 							/* of that address */
3348275SEric Cheng 	struct mac_address_s	*ma_next;		/* next address */
3358275SEric Cheng 	uint8_t			ma_addr[MAXMACADDRLEN];	/* address value */
3368275SEric Cheng 	size_t			ma_len;			/* address length */
3378275SEric Cheng 	mac_group_t		*ma_group;		/* asscociated group */
3388275SEric Cheng 	mac_impl_t		*ma_mip;		/* MAC handle */
3398275SEric Cheng } mac_address_t;
3408275SEric Cheng 
3418275SEric Cheng extern krwlock_t i_mac_impl_lock;
3428275SEric Cheng extern mod_hash_t *i_mac_impl_hash;
3438275SEric Cheng extern kmem_cache_t *i_mac_impl_cachep;
3448275SEric Cheng extern uint_t i_mac_impl_count;
3455895Syz147064 
3468275SEric Cheng /*
3478275SEric Cheng  * Each registered MAC is associated with a mac_impl_t structure. The
3488275SEric Cheng  * structure represents the undelying hardware, in terms of definition,
3498275SEric Cheng  * resources (transmit, receive rings etc.), callback functions etc. It
3508275SEric Cheng  * also holds the table of MAC clients that are configured on the device.
3518275SEric Cheng  * The table is used for classifying incoming packets in software.
3528275SEric Cheng  *
3538275SEric Cheng  * The protection scheme uses 2 elements, a coarse serialization mechanism
3548275SEric Cheng  * called perimeter and a finer traditional lock based scheme. More details
3558275SEric Cheng  * can be found in the big block comment in mac.c.
3568275SEric Cheng  *
3578275SEric Cheng  * The protection scheme for each member of the mac_impl_t is described below.
3588275SEric Cheng  *
3598275SEric Cheng  * Write Once Only (WO): Typically these don't change for the lifetime of the
3608275SEric Cheng  * data structure. For example something in mac_impl_t that stays the same
3618275SEric Cheng  * from mac_register to mac_unregister, or something in a mac_client_impl_t
3628275SEric Cheng  * that stays the same from mac_client_open to mac_client_close.
3638275SEric Cheng  *
3648275SEric Cheng  * Serializer (SL): Protected by the Serializer. All SLOP operations on a
3658275SEric Cheng  * mac endpoint go through the serializer. MTOPs don't care about reading
3668275SEric Cheng  * these fields atomically.
3678275SEric Cheng  *
3688275SEric Cheng  * Lock: Traditional mutex/rw lock. Modify operations still go through the
3698275SEric Cheng  * mac serializer, the lock helps synchronize readers with writers.
3708275SEric Cheng  */
3718275SEric Cheng struct mac_impl_s {
3728275SEric Cheng 	krwlock_t		mi_rw_lock;
3738275SEric Cheng 	char			mi_name[LIFNAMSIZ];	/* WO */
3748275SEric Cheng 	uint32_t		mi_state_flags;
3758275SEric Cheng 	void			*mi_driver;		/* Driver private, WO */
3768275SEric Cheng 	mac_info_t		mi_info;		/* WO */
3778275SEric Cheng 	mactype_t		*mi_type;		/* WO */
3788275SEric Cheng 	void			*mi_pdata;		/* WO */
3798275SEric Cheng 	size_t			mi_pdata_size;		/* WO */
3808275SEric Cheng 	mac_callbacks_t		*mi_callbacks;		/* WO */
3818275SEric Cheng 	dev_info_t		*mi_dip;		/* WO */
3828275SEric Cheng 	uint32_t		mi_ref;			/* i_mac_impl_lock */
3838275SEric Cheng 	uint_t			mi_active;		/* SL */
3848275SEric Cheng 	link_state_t		mi_linkstate;		/* none */
38510491SRishi.Srivatsavai@Sun.COM 	link_state_t		mi_lowlinkstate;	/* none */
38610491SRishi.Srivatsavai@Sun.COM 	link_state_t		mi_lastlowlinkstate;	/* none */
3878275SEric Cheng 	uint_t			mi_devpromisc;		/* SL */
3888275SEric Cheng 	kmutex_t		mi_lock;
3898275SEric Cheng 	uint8_t			mi_addr[MAXMACADDRLEN];	/* mi_rw_lock */
3908275SEric Cheng 	uint8_t			mi_dstaddr[MAXMACADDRLEN]; /* mi_rw_lock */
391*10616SSebastien.Roy@Sun.COM 	boolean_t		mi_dstaddr_set;
3925895Syz147064 
3938275SEric Cheng 	/*
3948275SEric Cheng 	 * The mac perimeter. All client initiated create/modify operations
3958275SEric Cheng 	 * on a mac end point go through this.
3968275SEric Cheng 	 */
3978275SEric Cheng 	kmutex_t		mi_perim_lock;
3988275SEric Cheng 	kthread_t		*mi_perim_owner;	/* mi_perim_lock */
3998275SEric Cheng 	uint_t			mi_perim_ocnt;		/* mi_perim_lock */
4008275SEric Cheng 	kcondvar_t		mi_perim_cv;		/* mi_perim_lock */
4015895Syz147064 
4028275SEric Cheng 	/* mac notification callbacks */
4038275SEric Cheng 	kmutex_t		mi_notify_lock;
4048275SEric Cheng 	mac_cb_info_t		mi_notify_cb_info;	/* mi_notify_lock */
4058275SEric Cheng 	mac_cb_t		*mi_notify_cb_list;	/* mi_notify_lock */
4068275SEric Cheng 	kthread_t		*mi_notify_thread;	/* mi_notify_lock */
4078275SEric Cheng 	uint_t			mi_notify_bits;		/* mi_notify_lock */
4088275SEric Cheng 
4098275SEric Cheng 	uint32_t		mi_v12n_level;		/* Virt'ion readiness */
4108275SEric Cheng 
4118275SEric Cheng 	/*
4128275SEric Cheng 	 * RX groups, ring capability
4138275SEric Cheng 	 * Fields of this block are SL protected.
4148275SEric Cheng 	 */
4158275SEric Cheng 	mac_group_type_t	mi_rx_group_type;	/* grouping type */
4168275SEric Cheng 	uint_t			mi_rx_group_count;
4178275SEric Cheng 	mac_group_t		*mi_rx_groups;
4185895Syz147064 
4198275SEric Cheng 	mac_capab_rings_t	mi_rx_rings_cap;
4208275SEric Cheng 
4218275SEric Cheng 	/*
4228275SEric Cheng 	 * TX groups and ring capability, SL Protected.
4238275SEric Cheng 	 */
4248275SEric Cheng 	mac_group_type_t	mi_tx_group_type;	/* grouping type */
4258275SEric Cheng 	uint_t			mi_tx_group_count;
4268275SEric Cheng 	uint_t			mi_tx_group_free;
4278275SEric Cheng 	mac_group_t		*mi_tx_groups;
4288275SEric Cheng 
4298275SEric Cheng 	mac_capab_rings_t	mi_tx_rings_cap;
4308275SEric Cheng 
4318275SEric Cheng 	mac_ring_handle_t	mi_default_tx_ring;
4325895Syz147064 
4338275SEric Cheng 	/*
4348275SEric Cheng 	 * MAC address list. SL protected.
4358275SEric Cheng 	 */
4368275SEric Cheng 	mac_address_t		*mi_addresses;
4378275SEric Cheng 
4388275SEric Cheng 	/*
4398275SEric Cheng 	 * This MAC's table of sub-flows
4408275SEric Cheng 	 */
4418275SEric Cheng 	flow_tab_t		*mi_flow_tab;		/* WO */
4428275SEric Cheng 
4438275SEric Cheng 	kstat_t			*mi_ksp;		/* WO */
4448275SEric Cheng 	uint_t			mi_kstat_count;		/* WO */
4458275SEric Cheng 	uint_t			mi_nactiveclients;	/* SL */
4468275SEric Cheng 
4478275SEric Cheng 	/* for broadcast and multicast support */
4488275SEric Cheng 	struct mac_mcast_addrs_s *mi_mcast_addrs;	/* mi_rw_lock */
4498275SEric Cheng 	struct mac_bcast_grp_s *mi_bcast_grp;		/* mi_rw_lock */
4508275SEric Cheng 	uint_t			mi_bcast_ngrps;		/* mi_rw_lock */
4515895Syz147064 
4528275SEric Cheng 	/* list of MAC clients which opened this MAC */
4538275SEric Cheng 	struct mac_client_impl_s *mi_clients_list;	/* mi_rw_lock */
4548275SEric Cheng 	uint_t			mi_nclients;		/* mi_rw_lock */
4558833SVenu.Iyer@Sun.COM 	struct mac_client_impl_s *mi_single_active_client; /* mi_rw_lock */
4568275SEric Cheng 
4578275SEric Cheng 	uint32_t		mi_margin;		/* mi_rw_lock */
4588275SEric Cheng 	uint_t			mi_sdu_min;		/* mi_rw_lock */
4598275SEric Cheng 	uint_t			mi_sdu_max;		/* mi_rw_lock */
4608275SEric Cheng 
4618275SEric Cheng 	/*
4628275SEric Cheng 	 * Cache of factory MAC addresses provided by the driver. If
4638275SEric Cheng 	 * the driver doesn't provide multiple factory MAC addresses,
4648275SEric Cheng 	 * the mi_factory_addr is set to NULL, and mi_factory_addr_num
4658275SEric Cheng 	 * is set to zero.
4668275SEric Cheng 	 */
4678275SEric Cheng 	mac_factory_addr_t	*mi_factory_addr;	/* mi_rw_lock */
4688275SEric Cheng 	uint_t			mi_factory_addr_num;	/* mi_rw_lock */
4695895Syz147064 
4708275SEric Cheng 	/* for promiscuous mode support */
4718275SEric Cheng 	kmutex_t		mi_promisc_lock;
4728275SEric Cheng 	mac_cb_t		*mi_promisc_list;	/* mi_promisc_lock */
4738275SEric Cheng 	mac_cb_info_t		mi_promisc_cb_info;	/* mi_promisc_lock */
4748275SEric Cheng 
4758275SEric Cheng 	/* cache of rings over this mac_impl */
4768275SEric Cheng 	kmutex_t		mi_ring_lock;
4778275SEric Cheng 	mac_ring_t		*mi_ring_freelist;	/* mi_ring_lock */
4785895Syz147064 
4795895Syz147064 	/*
4808275SEric Cheng 	 * These are used for caching the properties, if any, for the
4818275SEric Cheng 	 * primary MAC client. If the MAC client is not yet in place
4828275SEric Cheng 	 * when the properties are set then we cache them here to be
4838275SEric Cheng 	 * applied to the MAC client when it is created.
4848275SEric Cheng 	 */
4858275SEric Cheng 	mac_resource_props_t	mi_resource_props;	/* SL */
48610491SRishi.Srivatsavai@Sun.COM 	uint16_t		mi_pvid;		/* SL */
4878275SEric Cheng 
4888275SEric Cheng 	minor_t			mi_minor;		/* WO */
4899073SCathy.Zhou@Sun.COM 	uint32_t		mi_oref;		/* SL */
4909073SCathy.Zhou@Sun.COM 	mac_capab_legacy_t	mi_capab_legacy;	/* WO */
4918275SEric Cheng 	dev_t			mi_phy_dev;		/* WO */
4929073SCathy.Zhou@Sun.COM 
4938275SEric Cheng 	/*
4945895Syz147064 	 * List of margin value requests added by mac clients. This list is
4955895Syz147064 	 * sorted: the first one has the greatest value.
4965895Syz147064 	 */
4975895Syz147064 	mac_margin_req_t	*mi_mmrp;
4986512Ssowmini 	mac_priv_prop_t		*mi_priv_prop;
4996512Ssowmini 	uint_t			mi_priv_prop_count;
5008275SEric Cheng 
5018275SEric Cheng 	/*
5028275SEric Cheng 	 * Hybrid I/O related definitions.
5038275SEric Cheng 	 */
5048275SEric Cheng 	mac_capab_share_t	mi_share_capab;
5058275SEric Cheng 
50610491SRishi.Srivatsavai@Sun.COM 	/*
50710491SRishi.Srivatsavai@Sun.COM 	 * Bridging hooks and limit values.  Uses mutex and reference counts
50810491SRishi.Srivatsavai@Sun.COM 	 * (bridging only) for data path.  Limits need no synchronization.
50910491SRishi.Srivatsavai@Sun.COM 	 */
51010491SRishi.Srivatsavai@Sun.COM 	mac_handle_t		mi_bridge_link;
51110491SRishi.Srivatsavai@Sun.COM 	kmutex_t		mi_bridge_lock;
51210491SRishi.Srivatsavai@Sun.COM 	uint32_t		mi_llimit;
51310491SRishi.Srivatsavai@Sun.COM 	uint32_t		mi_ldecay;
51410491SRishi.Srivatsavai@Sun.COM 
5158275SEric Cheng /* This should be the last block in this structure */
5168275SEric Cheng #ifdef DEBUG
5178275SEric Cheng #define	MAC_PERIM_STACK_DEPTH	15
5188275SEric Cheng 	int			mi_perim_stack_depth;
5198275SEric Cheng 	pc_t			mi_perim_stack[MAC_PERIM_STACK_DEPTH];
5208275SEric Cheng #endif
5218275SEric Cheng };
5228275SEric Cheng 
5238275SEric Cheng /* for mi_state_flags */
5248275SEric Cheng #define	MIS_DISABLED		0x0001
5258275SEric Cheng #define	MIS_IS_VNIC		0x0002
5268275SEric Cheng #define	MIS_IS_AGGR		0x0004
5278275SEric Cheng #define	MIS_NOTIFY_DONE		0x0008
5288275SEric Cheng #define	MIS_EXCLUSIVE		0x0010
5298275SEric Cheng #define	MIS_EXCLUSIVE_HELD	0x0020
5308275SEric Cheng #define	MIS_LEGACY		0x0040
53110491SRishi.Srivatsavai@Sun.COM #define	MIS_NO_ACTIVE		0x0080
53210491SRishi.Srivatsavai@Sun.COM #define	MIS_POLL_DISABLE	0x0100
5332311Sseb 
5342311Sseb #define	mi_getstat	mi_callbacks->mc_getstat
5352311Sseb #define	mi_start	mi_callbacks->mc_start
5362311Sseb #define	mi_stop		mi_callbacks->mc_stop
5375895Syz147064 #define	mi_open		mi_callbacks->mc_open
5385895Syz147064 #define	mi_close	mi_callbacks->mc_close
5392311Sseb #define	mi_setpromisc	mi_callbacks->mc_setpromisc
5402311Sseb #define	mi_multicst	mi_callbacks->mc_multicst
5412311Sseb #define	mi_unicst	mi_callbacks->mc_unicst
5422311Sseb #define	mi_tx		mi_callbacks->mc_tx
5432311Sseb #define	mi_ioctl	mi_callbacks->mc_ioctl
5442311Sseb #define	mi_getcapab	mi_callbacks->mc_getcapab
5450Sstevel@tonic-gate 
5468275SEric Cheng typedef struct mac_notify_task_arg {
5478275SEric Cheng 	mac_impl_t		*mnt_mip;
5488275SEric Cheng 	mac_notify_type_t	mnt_type;
5498275SEric Cheng 	mac_ring_t		*mnt_ring;
5508275SEric Cheng } mac_notify_task_arg_t;
5518275SEric Cheng 
5528275SEric Cheng typedef enum {
5538275SEric Cheng 	MAC_RX_NO_RESERVE,
5548275SEric Cheng 	MAC_RX_RESERVE_DEFAULT,
5558275SEric Cheng 	MAC_RX_RESERVE_NONDEFAULT
5568275SEric Cheng } mac_rx_group_reserve_type_t;
5578275SEric Cheng 
5588275SEric Cheng /*
5598275SEric Cheng  * XXX All MAC_DBG_PRTs must be replaced with call to dtrace probes. For now
5608275SEric Cheng  * it may be easier to have these printfs for easier debugging
5618275SEric Cheng  */
5628275SEric Cheng #ifdef DEBUG
5638275SEric Cheng extern int mac_dbg;
5648275SEric Cheng #define	MAC_DBG_PRT(a)	if (mac_dbg > 0) {(void) printf a; }
5658275SEric Cheng #else
5668275SEric Cheng #define	MAC_DBG_PRT(a)
5678275SEric Cheng #endif
5688275SEric Cheng 
5698275SEric Cheng /*
5708275SEric Cheng  * The mac_perim_handle_t is an opaque type that encodes the 'mip' pointer
5718275SEric Cheng  * and whether internally a mac_open was done when acquiring the perimeter.
5728275SEric Cheng  */
5738275SEric Cheng #define	MAC_ENCODE_MPH(mph, mh, need_close)		\
5748275SEric Cheng 	(mph) = (mac_perim_handle_t)((uintptr_t)(mh) | need_close)
5758275SEric Cheng 
5768275SEric Cheng #define	MAC_DECODE_MPH(mph, mip, need_close) {		\
5778275SEric Cheng 	mip = (mac_impl_t *)(((uintptr_t)mph) & ~0x1);	\
5788275SEric Cheng 	(need_close) = ((uintptr_t)mph & 0x1);		\
5798275SEric Cheng }
5808275SEric Cheng 
5818275SEric Cheng typedef struct mac_client_impl_s mac_client_impl_t;
5828275SEric Cheng 
5830Sstevel@tonic-gate extern void	mac_init(void);
5840Sstevel@tonic-gate extern int	mac_fini(void);
5850Sstevel@tonic-gate 
5860Sstevel@tonic-gate extern void	mac_stat_create(mac_impl_t *);
5870Sstevel@tonic-gate extern void	mac_stat_destroy(mac_impl_t *);
5882311Sseb extern uint64_t	mac_stat_default(mac_impl_t *, uint_t);
5898275SEric Cheng extern void	mac_ndd_ioctl(mac_impl_t *, queue_t *, mblk_t *);
5908275SEric Cheng extern void	mac_create_soft_ring_kstats(mac_impl_t *, int32_t);
5918275SEric Cheng extern boolean_t mac_ip_hdr_length_v6(mblk_t *, ip6_t *, uint16_t *,
5928275SEric Cheng     uint8_t *);
5930Sstevel@tonic-gate 
5948275SEric Cheng extern mblk_t *mac_copymsgchain_cksum(mblk_t *);
5958275SEric Cheng extern mblk_t *mac_fix_cksum(mblk_t *);
5968275SEric Cheng extern void mac_packet_print(mac_handle_t, mblk_t *);
5978275SEric Cheng extern void mac_rx_deliver(void *, mac_resource_handle_t, mblk_t *,
5988275SEric Cheng     mac_header_info_t *);
5998275SEric Cheng extern void mac_tx_notify(mac_impl_t *);
6008275SEric Cheng 
6018275SEric Cheng extern	boolean_t mac_callback_find(mac_cb_info_t *, mac_cb_t **, mac_cb_t *);
6028275SEric Cheng extern	void	mac_callback_add(mac_cb_info_t *, mac_cb_t **, mac_cb_t *);
6038275SEric Cheng extern	boolean_t mac_callback_remove(mac_cb_info_t *, mac_cb_t **, mac_cb_t *);
6048275SEric Cheng extern	void	mac_callback_remove_wait(mac_cb_info_t *);
6058275SEric Cheng extern	void	mac_callback_free(mac_cb_t *);
6068275SEric Cheng extern	mac_cb_t *mac_callback_walker_cleanup(mac_cb_info_t *, mac_cb_t **);
6078275SEric Cheng 
6088275SEric Cheng /* in mac_bcast.c */
6098275SEric Cheng extern void mac_bcast_init(void);
6108275SEric Cheng extern void mac_bcast_fini(void);
6118275SEric Cheng extern mac_impl_t *mac_bcast_grp_mip(void *);
6128275SEric Cheng extern int mac_bcast_add(mac_client_impl_t *, const uint8_t *, uint16_t,
6138275SEric Cheng     mac_addrtype_t);
6148275SEric Cheng extern void mac_bcast_delete(mac_client_impl_t *, const uint8_t *, uint16_t);
6158275SEric Cheng extern void mac_bcast_send(void *, void *, mblk_t *, boolean_t);
6168275SEric Cheng extern void mac_bcast_grp_free(void *);
6178275SEric Cheng extern void mac_bcast_refresh(mac_impl_t *, mac_multicst_t, void *,
6188275SEric Cheng     boolean_t);
6198275SEric Cheng extern void mac_client_bcast_refresh(mac_client_impl_t *, mac_multicst_t,
6208275SEric Cheng     void *, boolean_t);
6218275SEric Cheng 
6228275SEric Cheng /*
6238275SEric Cheng  * Grouping functions are used internally by MAC layer.
6248275SEric Cheng  */
6258275SEric Cheng extern int mac_group_addmac(mac_group_t *, const uint8_t *);
6268275SEric Cheng extern int mac_group_remmac(mac_group_t *, const uint8_t *);
6278275SEric Cheng extern int mac_rx_group_add_flow(mac_client_impl_t *, flow_entry_t *,
6288275SEric Cheng     mac_group_t *);
62910309SSriharsha.Basavapatna@Sun.COM extern mblk_t *mac_hwring_tx(mac_ring_handle_t, mblk_t *);
63010491SRishi.Srivatsavai@Sun.COM extern mblk_t *mac_bridge_tx(mac_impl_t *, mac_ring_handle_t, mblk_t *);
6318275SEric Cheng extern mac_ring_t *mac_reserve_tx_ring(mac_impl_t *, mac_ring_t *);
6328275SEric Cheng extern void mac_release_tx_ring(mac_ring_handle_t);
6338275SEric Cheng extern mac_group_t *mac_reserve_tx_group(mac_impl_t *, mac_share_handle_t);
6348275SEric Cheng extern void mac_release_tx_group(mac_impl_t *, mac_group_t *);
6358275SEric Cheng 
6368275SEric Cheng /*
6378275SEric Cheng  * MAC address functions are used internally by MAC layer.
6388275SEric Cheng  */
6398275SEric Cheng extern mac_address_t *mac_find_macaddr(mac_impl_t *, uint8_t *);
6408275SEric Cheng extern boolean_t mac_check_macaddr_shared(mac_address_t *);
6418275SEric Cheng extern int mac_update_macaddr(mac_address_t *, uint8_t *);
6428275SEric Cheng extern void mac_freshen_macaddr(mac_address_t *, uint8_t *);
6438275SEric Cheng extern void mac_retrieve_macaddr(mac_address_t *, uint8_t *);
6448275SEric Cheng extern void mac_init_macaddr(mac_impl_t *);
6458275SEric Cheng extern void mac_fini_macaddr(mac_impl_t *);
6468275SEric Cheng 
6478275SEric Cheng /*
6488275SEric Cheng  * Flow construction/destruction routines.
6498275SEric Cheng  * Not meant to be used by mac clients.
6508275SEric Cheng  */
6518275SEric Cheng extern int mac_link_flow_init(mac_client_handle_t, flow_entry_t *);
6528275SEric Cheng extern void mac_link_flow_clean(mac_client_handle_t, flow_entry_t *);
6538275SEric Cheng 
6548275SEric Cheng /*
6558400SNicolas.Droux@Sun.COM  * Fanout update routines called when the link speed of the NIC changes
6568400SNicolas.Droux@Sun.COM  * or when a MAC client's share is unbound.
6578275SEric Cheng  */
6588400SNicolas.Droux@Sun.COM extern void mac_fanout_recompute_client(mac_client_impl_t *);
6598275SEric Cheng extern void mac_fanout_recompute(mac_impl_t *);
6608275SEric Cheng 
6618275SEric Cheng /*
6628275SEric Cheng  * The following functions are used internally by the MAC layer to
6638275SEric Cheng  * add/remove/update flows associated with a mac_impl_t. They should
6648275SEric Cheng  * never be used directly by MAC clients.
6658275SEric Cheng  */
6668275SEric Cheng extern int mac_datapath_setup(mac_client_impl_t *, flow_entry_t *, uint32_t);
6678275SEric Cheng extern void mac_datapath_teardown(mac_client_impl_t *, flow_entry_t *,
6688275SEric Cheng     uint32_t);
6698275SEric Cheng extern void mac_srs_group_setup(mac_client_impl_t *, flow_entry_t *,
6708275SEric Cheng     mac_group_t *, uint32_t);
6718275SEric Cheng extern void mac_srs_group_teardown(mac_client_impl_t *, flow_entry_t *,
6728275SEric Cheng 	    uint32_t);
6738275SEric Cheng extern int mac_rx_classify_flow_quiesce(flow_entry_t *, void *);
6748275SEric Cheng extern int mac_rx_classify_flow_restart(flow_entry_t *, void *);
6758275SEric Cheng extern void mac_tx_client_quiesce(mac_client_impl_t *, uint_t);
6768275SEric Cheng extern void mac_tx_client_restart(mac_client_impl_t *);
6778275SEric Cheng extern void mac_client_quiesce(mac_client_impl_t *);
6788275SEric Cheng extern void mac_client_restart(mac_client_impl_t *);
6798275SEric Cheng 
6808275SEric Cheng extern void mac_flow_update_priority(mac_client_impl_t *, flow_entry_t *);
6818275SEric Cheng 
6828275SEric Cheng extern void mac_flow_rem_subflow(flow_entry_t *);
6838275SEric Cheng extern void mac_rename_flow(flow_entry_t *, const char *);
6848275SEric Cheng extern void mac_flow_set_name(flow_entry_t *, const char *);
6858275SEric Cheng 
6868275SEric Cheng extern mblk_t *mac_add_vlan_tag(mblk_t *, uint_t, uint16_t);
6878275SEric Cheng extern mblk_t *mac_add_vlan_tag_chain(mblk_t *, uint_t, uint16_t);
6888275SEric Cheng extern mblk_t *mac_strip_vlan_tag_chain(mblk_t *);
6898275SEric Cheng extern void mac_pkt_drop(void *, mac_resource_handle_t, mblk_t *, boolean_t);
6908275SEric Cheng extern mblk_t *mac_rx_flow(mac_handle_t, mac_resource_handle_t, mblk_t *);
6918275SEric Cheng 
6928275SEric Cheng extern void i_mac_share_alloc(mac_client_impl_t *);
6938275SEric Cheng extern void i_mac_share_free(mac_client_impl_t *);
6948275SEric Cheng extern void i_mac_perim_enter(mac_impl_t *);
6958275SEric Cheng extern void i_mac_perim_exit(mac_impl_t *);
6968275SEric Cheng extern int i_mac_perim_enter_nowait(mac_impl_t *);
6978275SEric Cheng extern void i_mac_tx_srs_notify(mac_impl_t *, mac_ring_handle_t);
6988275SEric Cheng extern int mac_hold(const char *, mac_impl_t **);
6998275SEric Cheng extern void mac_rele(mac_impl_t *);
7008275SEric Cheng extern int i_mac_disable(mac_impl_t *);
7018275SEric Cheng extern void i_mac_notify(mac_impl_t *, mac_notify_type_t);
7028275SEric Cheng extern void i_mac_notify_exit(mac_impl_t *);
7038275SEric Cheng extern void mac_rx_group_unmark(mac_group_t *, uint_t);
7048275SEric Cheng extern void mac_tx_client_flush(mac_client_impl_t *);
7058275SEric Cheng extern void mac_tx_client_block(mac_client_impl_t *);
7068275SEric Cheng extern void mac_tx_client_unblock(mac_client_impl_t *);
7079641SGirish.Moodalbail@Sun.COM extern int i_mac_promisc_set(mac_impl_t *, boolean_t);
7088275SEric Cheng extern void i_mac_promisc_walker_cleanup(mac_impl_t *);
7098275SEric Cheng extern mactype_t *mactype_getplugin(const char *);
7108275SEric Cheng extern void mac_addr_factory_init(mac_impl_t *);
7118275SEric Cheng extern void mac_addr_factory_fini(mac_impl_t *);
7128275SEric Cheng extern void mac_register_priv_prop(mac_impl_t *, mac_priv_prop_t *, uint_t);
7138275SEric Cheng extern void mac_unregister_priv_prop(mac_impl_t *);
7148275SEric Cheng extern int mac_init_rings(mac_impl_t *, mac_ring_type_t);
7158275SEric Cheng extern void mac_free_rings(mac_impl_t *, mac_ring_type_t);
7168275SEric Cheng 
7178275SEric Cheng extern int mac_start_group(mac_group_t *);
7188275SEric Cheng extern void mac_stop_group(mac_group_t *);
7198275SEric Cheng extern int mac_start_ring(mac_ring_t *);
7208275SEric Cheng extern void mac_stop_ring(mac_ring_t *);
7218400SNicolas.Droux@Sun.COM extern int mac_add_macaddr(mac_impl_t *, mac_group_t *, uint8_t *, boolean_t);
7228275SEric Cheng extern int mac_remove_macaddr(mac_address_t *);
7238275SEric Cheng 
7248275SEric Cheng extern void mac_set_rx_group_state(mac_group_t *, mac_group_state_t);
7258275SEric Cheng extern void mac_rx_group_add_client(mac_group_t *, mac_client_impl_t *);
7268275SEric Cheng extern void mac_rx_group_remove_client(mac_group_t *, mac_client_impl_t *)
7278275SEric Cheng ;
7288275SEric Cheng extern int i_mac_group_add_ring(mac_group_t *, mac_ring_t *, int);
7298275SEric Cheng extern void i_mac_group_rem_ring(mac_group_t *, mac_ring_t *, boolean_t);
7306512Ssowmini 
73110491SRishi.Srivatsavai@Sun.COM extern void mac_poll_state_change(mac_handle_t, boolean_t);
73210491SRishi.Srivatsavai@Sun.COM 
73310491SRishi.Srivatsavai@Sun.COM /* Global callbacks into the bridging module (when loaded) */
73410491SRishi.Srivatsavai@Sun.COM extern mac_bridge_tx_t mac_bridge_tx_cb;
73510491SRishi.Srivatsavai@Sun.COM extern mac_bridge_rx_t mac_bridge_rx_cb;
73610491SRishi.Srivatsavai@Sun.COM extern mac_bridge_ref_t mac_bridge_ref_cb;
73710491SRishi.Srivatsavai@Sun.COM extern mac_bridge_ls_t mac_bridge_ls_cb;
73810491SRishi.Srivatsavai@Sun.COM 
7390Sstevel@tonic-gate #ifdef	__cplusplus
7400Sstevel@tonic-gate }
7410Sstevel@tonic-gate #endif
7420Sstevel@tonic-gate 
7430Sstevel@tonic-gate #endif	/* _SYS_MAC_IMPL_H */
744