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 /*
221852Syz147064  * Copyright 2006 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 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/mac.h>
322311Sseb #include <net/if.h>
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifdef	__cplusplus
350Sstevel@tonic-gate extern "C" {
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate 
382311Sseb /*
392412Sseb  * Statistics maintained internally by the mac module.
402311Sseb  */
412412Sseb enum mac_mod_stat {
422311Sseb 	MAC_STAT_LINK_STATE,
432311Sseb 	MAC_STAT_LINK_UP,
442412Sseb 	MAC_STAT_PROMISC
452311Sseb };
462311Sseb 
470Sstevel@tonic-gate typedef struct mac_multicst_addr_s	mac_multicst_addr_t;
480Sstevel@tonic-gate 
490Sstevel@tonic-gate struct mac_multicst_addr_s {
500Sstevel@tonic-gate 	mac_multicst_addr_t	*mma_nextp;
510Sstevel@tonic-gate 	uint_t			mma_ref;
522311Sseb 	uint8_t			mma_addr[MAXMACADDRLEN];
530Sstevel@tonic-gate };
540Sstevel@tonic-gate 
550Sstevel@tonic-gate typedef struct mac_notify_fn_s		mac_notify_fn_t;
560Sstevel@tonic-gate 
570Sstevel@tonic-gate struct mac_notify_fn_s {
580Sstevel@tonic-gate 	mac_notify_fn_t		*mnf_nextp;
590Sstevel@tonic-gate 	mac_notify_t		mnf_fn;
600Sstevel@tonic-gate 	void			*mnf_arg;
610Sstevel@tonic-gate };
620Sstevel@tonic-gate 
630Sstevel@tonic-gate typedef struct mac_rx_fn_s		mac_rx_fn_t;
640Sstevel@tonic-gate 
650Sstevel@tonic-gate struct mac_rx_fn_s {
660Sstevel@tonic-gate 	mac_rx_fn_t		*mrf_nextp;
670Sstevel@tonic-gate 	mac_rx_t		mrf_fn;
680Sstevel@tonic-gate 	void			*mrf_arg;
690Sstevel@tonic-gate };
700Sstevel@tonic-gate 
710Sstevel@tonic-gate typedef struct mac_txloop_fn_s		mac_txloop_fn_t;
720Sstevel@tonic-gate 
730Sstevel@tonic-gate struct mac_txloop_fn_s {
740Sstevel@tonic-gate 	mac_txloop_fn_t		*mtf_nextp;
750Sstevel@tonic-gate 	mac_txloop_t		mtf_fn;
760Sstevel@tonic-gate 	void			*mtf_arg;
770Sstevel@tonic-gate };
780Sstevel@tonic-gate 
792311Sseb typedef struct mactype_s {
802311Sseb 	const char	*mt_ident;
812311Sseb 	uint32_t	mt_ref;
822311Sseb 	uint_t		mt_type;
83*3147Sxc151355 	uint_t		mt_nativetype;
842311Sseb 	size_t		mt_addr_length;
852311Sseb 	uint8_t		*mt_brdcst_addr;
862311Sseb 	mactype_ops_t	mt_ops;
872311Sseb 	mac_stat_info_t	*mt_stats;	/* array of mac_stat_info_t elements */
882311Sseb 	size_t		mt_statcount;	/* number of elements in mt_stats */
892311Sseb } mactype_t;
900Sstevel@tonic-gate 
912311Sseb /*
922311Sseb  * Each registered MAC is associated with a mac_t structure.
932311Sseb  */
942311Sseb typedef struct mac_impl_s {
952311Sseb 	char			mi_name[LIFNAMSIZ];
962311Sseb 	const char		*mi_drvname;
972311Sseb 	uint_t			mi_instance;
982311Sseb 	void			*mi_driver;	/* Driver private data */
992311Sseb 	mac_info_t		mi_info;
1002311Sseb 	mactype_t		*mi_type;
1012311Sseb 	void			*mi_pdata;
1022311Sseb 	size_t			mi_pdata_size;
1032311Sseb 	mac_callbacks_t		*mi_callbacks;
1042311Sseb 	dev_info_t		*mi_dip;
1050Sstevel@tonic-gate 	uint32_t		mi_ref;
1061852Syz147064 	boolean_t		mi_disabled;
1070Sstevel@tonic-gate 	krwlock_t		mi_state_lock;
1080Sstevel@tonic-gate 	uint_t			mi_active;
1090Sstevel@tonic-gate 	krwlock_t		mi_data_lock;
1102311Sseb 	link_state_t		mi_linkstate;
1110Sstevel@tonic-gate 	uint_t			mi_promisc;
1120Sstevel@tonic-gate 	uint_t			mi_devpromisc;
1132311Sseb 	uint8_t			mi_addr[MAXMACADDRLEN];
1142311Sseb 	uint8_t			mi_dstaddr[MAXMACADDRLEN];
1150Sstevel@tonic-gate 	mac_multicst_addr_t	*mi_mmap;
1160Sstevel@tonic-gate 	krwlock_t		mi_notify_lock;
1170Sstevel@tonic-gate 	mac_notify_fn_t		*mi_mnfp;
1181852Syz147064 	kmutex_t		mi_notify_ref_lock;
1191852Syz147064 	uint32_t		mi_notify_ref;
1201852Syz147064 	kcondvar_t		mi_notify_cv;
1210Sstevel@tonic-gate 	krwlock_t		mi_rx_lock;
1220Sstevel@tonic-gate 	mac_rx_fn_t		*mi_mrfp;
1230Sstevel@tonic-gate 	krwlock_t		mi_txloop_lock;
1240Sstevel@tonic-gate 	mac_txloop_fn_t		*mi_mtfp;
1250Sstevel@tonic-gate 	krwlock_t		mi_resource_lock;
1260Sstevel@tonic-gate 	mac_resource_add_t	mi_resource_add;
1270Sstevel@tonic-gate 	void			*mi_resource_add_arg;
1280Sstevel@tonic-gate 	kstat_t			*mi_ksp;
1292311Sseb 	uint_t			mi_kstat_count;
1300Sstevel@tonic-gate 	kmutex_t		mi_activelink_lock;
1310Sstevel@tonic-gate 	boolean_t		mi_activelink;
13256Smeem 	mac_txinfo_t		mi_txinfo;
13356Smeem 	mac_txinfo_t		mi_txloopinfo;
1342311Sseb } mac_impl_t;
1352311Sseb 
1362311Sseb #define	mi_getstat	mi_callbacks->mc_getstat
1372311Sseb #define	mi_start	mi_callbacks->mc_start
1382311Sseb #define	mi_stop		mi_callbacks->mc_stop
1392311Sseb #define	mi_setpromisc	mi_callbacks->mc_setpromisc
1402311Sseb #define	mi_multicst	mi_callbacks->mc_multicst
1412311Sseb #define	mi_unicst	mi_callbacks->mc_unicst
1422311Sseb #define	mi_resources	mi_callbacks->mc_resources
1432311Sseb #define	mi_tx		mi_callbacks->mc_tx
1442311Sseb #define	mi_ioctl	mi_callbacks->mc_ioctl
1452311Sseb #define	mi_getcapab	mi_callbacks->mc_getcapab
1460Sstevel@tonic-gate 
1471852Syz147064 typedef struct mac_notify_task_arg {
1481852Syz147064 	mac_impl_t		*mnt_mip;
1491852Syz147064 	mac_notify_type_t	mnt_type;
1501852Syz147064 } mac_notify_task_arg_t;
1511852Syz147064 
1520Sstevel@tonic-gate extern void	mac_init(void);
1530Sstevel@tonic-gate extern int	mac_fini(void);
1540Sstevel@tonic-gate 
1550Sstevel@tonic-gate extern void	mac_stat_create(mac_impl_t *);
1560Sstevel@tonic-gate extern void	mac_stat_destroy(mac_impl_t *);
1572311Sseb extern uint64_t	mac_stat_default(mac_impl_t *, uint_t);
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate #ifdef	__cplusplus
1600Sstevel@tonic-gate }
1610Sstevel@tonic-gate #endif
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate #endif	/* _SYS_MAC_IMPL_H */
164