xref: /titanic_41/usr/src/uts/common/sys/mac_impl.h (revision ba2e4443695ee6a6f420a35cd4fc3d3346d22932)
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 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_MAC_IMPL_H
27 #define	_SYS_MAC_IMPL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/mac.h>
32 #include <net/if.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Statistics of class MAC_INTERFACE_STAT, maintained internally by the mac
40  * module.
41  */
42 enum mac_interface_stat {
43 	MAC_STAT_LINK_STATE,
44 	MAC_STAT_LINK_UP,
45 	MAC_STAT_PROMISC,
46 
47 	MAC_INTERFACE_NSTAT		/* Must be the last entry */
48 };
49 
50 typedef struct mac_multicst_addr_s	mac_multicst_addr_t;
51 
52 struct mac_multicst_addr_s {
53 	mac_multicst_addr_t	*mma_nextp;
54 	uint_t			mma_ref;
55 	uint8_t			mma_addr[MAXMACADDRLEN];
56 };
57 
58 typedef struct mac_notify_fn_s		mac_notify_fn_t;
59 
60 struct mac_notify_fn_s {
61 	mac_notify_fn_t		*mnf_nextp;
62 	mac_notify_t		mnf_fn;
63 	void			*mnf_arg;
64 };
65 
66 typedef struct mac_rx_fn_s		mac_rx_fn_t;
67 
68 struct mac_rx_fn_s {
69 	mac_rx_fn_t		*mrf_nextp;
70 	mac_rx_t		mrf_fn;
71 	void			*mrf_arg;
72 };
73 
74 typedef struct mac_txloop_fn_s		mac_txloop_fn_t;
75 
76 struct mac_txloop_fn_s {
77 	mac_txloop_fn_t		*mtf_nextp;
78 	mac_txloop_t		mtf_fn;
79 	void			*mtf_arg;
80 };
81 
82 typedef struct mactype_s {
83 	const char	*mt_ident;
84 	uint32_t	mt_ref;
85 	uint_t		mt_type;
86 	size_t		mt_addr_length;
87 	uint8_t		*mt_brdcst_addr;
88 	mactype_ops_t	mt_ops;
89 	mac_stat_info_t	*mt_stats;	/* array of mac_stat_info_t elements */
90 	size_t		mt_statcount;	/* number of elements in mt_stats */
91 } mactype_t;
92 
93 /*
94  * Each registered MAC is associated with a mac_t structure.
95  */
96 typedef struct mac_impl_s {
97 	char			mi_name[LIFNAMSIZ];
98 	const char		*mi_drvname;
99 	uint_t			mi_instance;
100 	void			*mi_driver;	/* Driver private data */
101 	mac_info_t		mi_info;
102 	mactype_t		*mi_type;
103 	void			*mi_pdata;
104 	size_t			mi_pdata_size;
105 	mac_callbacks_t		*mi_callbacks;
106 	dev_info_t		*mi_dip;
107 	uint32_t		mi_ref;
108 	boolean_t		mi_disabled;
109 	krwlock_t		mi_state_lock;
110 	uint_t			mi_active;
111 	krwlock_t		mi_data_lock;
112 	link_state_t		mi_linkstate;
113 	uint_t			mi_promisc;
114 	uint_t			mi_devpromisc;
115 	uint8_t			mi_addr[MAXMACADDRLEN];
116 	uint8_t			mi_dstaddr[MAXMACADDRLEN];
117 	mac_multicst_addr_t	*mi_mmap;
118 	krwlock_t		mi_notify_lock;
119 	mac_notify_fn_t		*mi_mnfp;
120 	kmutex_t		mi_notify_ref_lock;
121 	uint32_t		mi_notify_ref;
122 	kcondvar_t		mi_notify_cv;
123 	krwlock_t		mi_rx_lock;
124 	mac_rx_fn_t		*mi_mrfp;
125 	krwlock_t		mi_txloop_lock;
126 	mac_txloop_fn_t		*mi_mtfp;
127 	krwlock_t		mi_resource_lock;
128 	mac_resource_add_t	mi_resource_add;
129 	void			*mi_resource_add_arg;
130 	kstat_t			*mi_ksp;
131 	uint_t			mi_kstat_count;
132 	kmutex_t		mi_activelink_lock;
133 	boolean_t		mi_activelink;
134 	mac_txinfo_t		mi_txinfo;
135 	mac_txinfo_t		mi_txloopinfo;
136 } mac_impl_t;
137 
138 #define	mi_getstat	mi_callbacks->mc_getstat
139 #define	mi_start	mi_callbacks->mc_start
140 #define	mi_stop		mi_callbacks->mc_stop
141 #define	mi_setpromisc	mi_callbacks->mc_setpromisc
142 #define	mi_multicst	mi_callbacks->mc_multicst
143 #define	mi_unicst	mi_callbacks->mc_unicst
144 #define	mi_resources	mi_callbacks->mc_resources
145 #define	mi_tx		mi_callbacks->mc_tx
146 #define	mi_ioctl	mi_callbacks->mc_ioctl
147 #define	mi_getcapab	mi_callbacks->mc_getcapab
148 
149 typedef struct mac_notify_task_arg {
150 	mac_impl_t		*mnt_mip;
151 	mac_notify_type_t	mnt_type;
152 } mac_notify_task_arg_t;
153 
154 extern void	mac_init(void);
155 extern int	mac_fini(void);
156 
157 extern void	mac_stat_create(mac_impl_t *);
158 extern void	mac_stat_destroy(mac_impl_t *);
159 extern uint64_t	mac_stat_default(mac_impl_t *, uint_t);
160 
161 #ifdef	__cplusplus
162 }
163 #endif
164 
165 #endif	/* _SYS_MAC_IMPL_H */
166