xref: /titanic_52/usr/src/uts/common/sys/mac.h (revision 948f2876ce2a3010558f4f6937e16086ebcd36f2)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_MAC_H
27 #define	_SYS_MAC_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <sys/ddi.h>
33 #include <sys/sunddi.h>
34 #include <sys/stream.h>
35 
36 /*
37  * MAC Services Module
38  */
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 /*
45  * MAC Information (text emitted by modinfo(1m))
46  */
47 #define	MAC_INFO	"MAC Services v%I%"
48 
49 /*
50  * MAC version identifier.  This is used by mac_alloc() mac_register() to
51  * verify that incompatible drivers don't register.
52  */
53 #define	MAC_VERSION	0x1
54 
55 /*
56  * MAC-Type version identifier.  This is used by mactype_alloc() and
57  * mactype_register() to verify that incompatible MAC-Type plugins don't
58  * register.
59  */
60 #define	MACTYPE_VERSION	0x1
61 
62 /*
63  * Statistics
64  */
65 
66 #define	XCVR_UNDEFINED		0
67 #define	XCVR_NONE		1
68 #define	XCVR_10			2
69 #define	XCVR_100T4		3
70 #define	XCVR_100X		4
71 #define	XCVR_100T2		5
72 #define	XCVR_1000X		6
73 #define	XCVR_1000T		7
74 
75 typedef enum {
76 	LINK_STATE_UNKNOWN = -1,
77 	LINK_STATE_DOWN,
78 	LINK_STATE_UP
79 } link_state_t;
80 
81 typedef enum {
82 	LINK_DUPLEX_UNKNOWN = 0,
83 	LINK_DUPLEX_HALF,
84 	LINK_DUPLEX_FULL
85 } link_duplex_t;
86 
87 #ifdef	_KERNEL
88 
89 typedef struct mac_stat_info_s {
90 	uint_t		msi_stat;
91 	char		*msi_name;
92 	uint_t		msi_type;	/* as defined in kstat_named_init(9F) */
93 	uint64_t	msi_default;
94 } mac_stat_info_t;
95 
96 /*
97  * There are three ranges of statistics values.  0 to 1 - MAC_STAT_MIN are
98  * interface statistics maintained by the mac module.  MAC_STAT_MIN to 1 -
99  * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and
100  * maintained by each driver.  MACTYPE_STAT_MIN and above are statistics
101  * defined by MAC-Type plugins and maintained by each driver.
102  */
103 #define	MAC_STAT_MIN		1000
104 #define	MACTYPE_STAT_MIN	2000
105 
106 #define	IS_MAC_STAT(stat)	\
107 	(stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN)
108 #define	IS_MACTYPE_STAT(stat)	(stat >= MACTYPE_STAT_MIN)
109 
110 /*
111  * Do not reorder, and add only to the end of this list.
112  */
113 enum mac_driver_stat {
114 	/* MIB-II stats (RFC 1213 and RFC 1573) */
115 	MAC_STAT_IFSPEED = MAC_STAT_MIN,
116 	MAC_STAT_MULTIRCV,
117 	MAC_STAT_BRDCSTRCV,
118 	MAC_STAT_MULTIXMT,
119 	MAC_STAT_BRDCSTXMT,
120 	MAC_STAT_NORCVBUF,
121 	MAC_STAT_IERRORS,
122 	MAC_STAT_UNKNOWNS,
123 	MAC_STAT_NOXMTBUF,
124 	MAC_STAT_OERRORS,
125 	MAC_STAT_COLLISIONS,
126 	MAC_STAT_RBYTES,
127 	MAC_STAT_IPACKETS,
128 	MAC_STAT_OBYTES,
129 	MAC_STAT_OPACKETS,
130 	MAC_STAT_UNDERFLOWS,
131 	MAC_STAT_OVERFLOWS
132 };
133 
134 #define	MAC_NSTAT	(MAC_STAT_OVERFLOWS - MAC_STAT_IFSPEED + 1)
135 
136 #define	MAC_STAT_ISACOUNTER(_stat) (		\
137 	    (_stat) == MAC_STAT_MULTIRCV ||	\
138 	    (_stat) == MAC_STAT_BRDCSTRCV ||	\
139 	    (_stat) == MAC_STAT_MULTIXMT ||	\
140 	    (_stat) == MAC_STAT_BRDCSTXMT ||	\
141 	    (_stat) == MAC_STAT_NORCVBUF ||	\
142 	    (_stat) == MAC_STAT_IERRORS ||	\
143 	    (_stat) == MAC_STAT_UNKNOWNS ||	\
144 	    (_stat) == MAC_STAT_NOXMTBUF ||	\
145 	    (_stat) == MAC_STAT_OERRORS ||	\
146 	    (_stat) == MAC_STAT_COLLISIONS ||	\
147 	    (_stat) == MAC_STAT_RBYTES ||	\
148 	    (_stat) == MAC_STAT_IPACKETS ||	\
149 	    (_stat) == MAC_STAT_OBYTES ||	\
150 	    (_stat) == MAC_STAT_OPACKETS ||	\
151 	    (_stat) == MAC_STAT_UNDERFLOWS ||	\
152 	    (_stat) == MAC_STAT_OVERFLOWS)
153 
154 /*
155  * Maximum MAC address length
156  */
157 #define	MAXMACADDRLEN	20
158 
159 /*
160  * Immutable information. (This may not be modified after registration).
161  */
162 typedef struct mac_info_s {
163 	uint_t		mi_media;
164 	uint_t		mi_nativemedia;
165 	uint_t		mi_sdu_min;
166 	uint_t		mi_sdu_max;
167 	uint_t		mi_addr_length;
168 	uint8_t		*mi_unicst_addr;
169 	uint8_t		*mi_brdcst_addr;
170 } mac_info_t;
171 
172 /*
173  * LSO capability
174  */
175 typedef struct lso_basic_tcp_ipv4_s {
176 	t_uscalar_t	lso_max;		/* maximum payload */
177 } lso_basic_tcp_ipv4_t;
178 
179 /*
180  * Future LSO capabilities can be added at the end of the mac_capab_lso_t.
181  * When such capability is added to the GLDv3 framework, the size of the
182  * mac_capab_lso_t it allocates and passes to the drivers increases. Older
183  * drivers wil access only the (upper) sections of that structure, that is the
184  * sections carrying the capabilities they understand. This ensures the
185  * interface can be safely extended in a binary compatible way.
186  */
187 typedef	struct mac_capab_lso_s {
188 	t_uscalar_t		lso_flags;
189 	lso_basic_tcp_ipv4_t	lso_basic_tcp_ipv4;
190 	/* Add future lso capabilities here */
191 } mac_capab_lso_t;
192 
193 /*
194  * MAC layer capabilities.  These capabilities are handled by the drivers'
195  * mc_capab_get() callbacks.  Some capabilities require the driver to fill
196  * in a given data structure, and others are simply boolean capabilities.
197  * Note that capability values must be powers of 2 so that consumers and
198  * providers of this interface can keep track of which capabilities they
199  * care about by keeping a bitfield of these things around somewhere.
200  */
201 typedef enum {
202 	MAC_CAPAB_HCKSUM	= 0x01,	/* data is a uint32_t for the txflags */
203 	MAC_CAPAB_POLL		= 0x02,	/* boolean only, no data */
204 	MAC_CAPAB_MULTIADDRESS	= 0x04,	/* data is multiaddress_capab_t */
205 	MAC_CAPAB_LSO		= 0x08	/* data is mac_capab_lso_t */
206 	/* add new capabilities here */
207 } mac_capab_t;
208 
209 typedef int mac_addr_slot_t;
210 
211 /* mma_flags values */
212 #define	MMAC_SLOT_USED		0x1   /* address slot used */
213 #define	MMAC_SLOT_UNUSED	0x2   /* free address slot */
214 #define	MMAC_VENDOR_ADDR	0x4   /* address returned is vendor supplied */
215 
216 typedef struct mac_multi_address_s {
217 	mac_addr_slot_t	mma_slot;	/* slot for add/remove/get/set */
218 	uint_t		mma_addrlen;
219 	uint8_t		mma_addr[MAXMACADDRLEN];
220 	uint_t		mma_flags;
221 } mac_multi_addr_t;
222 
223 typedef int	(*maddr_reserve_t)(void *, mac_multi_addr_t *);
224 typedef int	(*maddr_add_t)(void *, mac_multi_addr_t *);
225 typedef int	(*maddr_remove_t)(void *, mac_addr_slot_t);
226 typedef int	(*maddr_modify_t)(void *, mac_multi_addr_t *);
227 typedef int	(*maddr_get_t)(void *, mac_multi_addr_t *);
228 
229 /* maddr_flag values */
230 #define	MADDR_VENDOR_ADDR	0x01	/* addr returned is vendor supplied */
231 
232 /* multiple mac address: add/remove/set/get mac address */
233 typedef struct multiaddress_capab_s {
234 	int		maddr_naddr;	/* total addresses */
235 	int		maddr_naddrfree;	/* free address slots */
236 	uint_t		maddr_flag;	/* MADDR_VENDOR_ADDR bit can be set */
237 	/* driver entry points */
238 	void		*maddr_handle;	/* cookie to be used for the calls */
239 	maddr_reserve_t	maddr_reserve;	/* reserve a factory address */
240 	maddr_add_t	maddr_add;	/* add a new unicst address */
241 	maddr_remove_t	maddr_remove;	/* remove an added address */
242 	maddr_modify_t	maddr_modify;	/* modify an added address */
243 	maddr_get_t	maddr_get;	/* get address from specified slot */
244 } multiaddress_capab_t;
245 
246 /*
247  * MAC driver entry point types.
248  */
249 typedef int		(*mac_getstat_t)(void *, uint_t, uint64_t *);
250 typedef	int		(*mac_start_t)(void *);
251 typedef void		(*mac_stop_t)(void *);
252 typedef int		(*mac_setpromisc_t)(void *, boolean_t);
253 typedef int		(*mac_multicst_t)(void *, boolean_t, const uint8_t *);
254 typedef int		(*mac_unicst_t)(void *, const uint8_t *);
255 typedef void		(*mac_ioctl_t)(void *, queue_t *, mblk_t *);
256 typedef void		(*mac_resources_t)(void *);
257 typedef mblk_t		*(*mac_tx_t)(void *, mblk_t *);
258 typedef	boolean_t	(*mac_getcapab_t)(void *, mac_capab_t, void *);
259 
260 /*
261  * Drivers must set all of these callbacks except for mc_resources,
262  * mc_ioctl, and mc_getcapab, which are optional.  If any of these optional
263  * callbacks are set, their appropriate flags must be set in mc_callbacks.
264  * Any future additions to this list must also be accompanied by an
265  * associated mc_callbacks flag so that the framework can grow without
266  * affecting the binary compatibility of the interface.
267  */
268 typedef struct mac_callbacks_s {
269 	uint_t		mc_callbacks;	/* Denotes which callbacks are set */
270 	mac_getstat_t	mc_getstat;	/* Get the value of a statistic */
271 	mac_start_t	mc_start;	/* Start the device */
272 	mac_stop_t	mc_stop;	/* Stop the device */
273 	mac_setpromisc_t mc_setpromisc;	/* Enable or disable promiscuous mode */
274 	mac_multicst_t	mc_multicst;	/* Enable or disable a multicast addr */
275 	mac_unicst_t	mc_unicst;	/* Set the unicast MAC address */
276 	mac_tx_t	mc_tx;		/* Transmit a packet */
277 	mac_resources_t	mc_resources;	/* Get the device resources */
278 	mac_ioctl_t	mc_ioctl;	/* Process an unknown ioctl */
279 	mac_getcapab_t	mc_getcapab;	/* Get capability information */
280 } mac_callbacks_t;
281 
282 /*
283  * Flags for mc_callbacks.  Requiring drivers to set the flags associated
284  * with optional callbacks initialized in the structure allows the mac
285  * module to add optional callbacks in the future without requiring drivers
286  * to recompile.
287  */
288 #define	MC_RESOURCES	0x001
289 #define	MC_IOCTL	0x002
290 #define	MC_GETCAPAB	0x004
291 
292 typedef struct mac_register_s {
293 	uint_t		m_version;	/* set by mac_alloc() */
294 	const char	*m_type_ident;
295 	void		*m_driver;	/* Driver private data */
296 	dev_info_t	*m_dip;
297 	uint_t		m_instance;
298 	uint8_t		*m_src_addr;
299 	uint8_t		*m_dst_addr;
300 	mac_callbacks_t	*m_callbacks;
301 	uint_t		m_min_sdu;
302 	uint_t		m_max_sdu;
303 	void		*m_pdata;
304 	size_t		m_pdata_size;
305 } mac_register_t;
306 
307 /*
308  * Opaque handle types.
309  */
310 typedef	struct mac_t			*mac_handle_t;
311 typedef struct __mac_notify_handle	*mac_notify_handle_t;
312 typedef struct __mac_rx_handle		*mac_rx_handle_t;
313 typedef struct __mac_txloop_handle	*mac_txloop_handle_t;
314 typedef struct __mac_resource_handle	*mac_resource_handle_t;
315 
316 /*
317  * MAC interface callback types.
318  */
319 typedef enum {
320 	MAC_NOTE_LINK,
321 	MAC_NOTE_PROMISC,
322 	MAC_NOTE_UNICST,
323 	MAC_NOTE_TX,
324 	MAC_NOTE_RESOURCE,
325 	MAC_NOTE_DEVPROMISC,
326 	MAC_NOTE_FASTPATH_FLUSH,
327 	MAC_NNOTE	/* must be the last entry */
328 } mac_notify_type_t;
329 
330 typedef void		(*mac_notify_t)(void *, mac_notify_type_t);
331 typedef void		(*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *);
332 typedef void		(*mac_txloop_t)(void *, mblk_t *);
333 typedef void		(*mac_blank_t)(void *, time_t, uint_t);
334 
335 /*
336  * MAC promiscuous types
337  */
338 typedef enum {
339 	MAC_PROMISC = 0x01,		/* MAC instance is promiscuous */
340 	MAC_DEVPROMISC = 0x02		/* Device is promiscuous */
341 } mac_promisc_type_t;
342 
343 /*
344  * MAC resource types
345  */
346 typedef enum {
347 	MAC_RX_FIFO = 1
348 } mac_resource_type_t;
349 
350 typedef struct mac_rx_fifo_s {
351 	mac_resource_type_t	mrf_type;	/* MAC_RX_FIFO */
352 	mac_blank_t		mrf_blank;
353 	void			*mrf_arg;
354 	time_t			mrf_normal_blank_time;
355 	uint_t			mrf_normal_pkt_count;
356 } mac_rx_fifo_t;
357 
358 typedef struct mac_txinfo_s {
359 	mac_tx_t		mt_fn;
360 	void			*mt_arg;
361 } mac_txinfo_t;
362 
363 typedef union mac_resource_u {
364 	mac_resource_type_t	mr_type;
365 	mac_rx_fifo_t		mr_fifo;
366 } mac_resource_t;
367 
368 typedef mac_resource_handle_t	(*mac_resource_add_t)(void *, mac_resource_t *);
369 
370 typedef enum {
371 	MAC_ADDRTYPE_UNICAST,
372 	MAC_ADDRTYPE_MULTICAST,
373 	MAC_ADDRTYPE_BROADCAST
374 } mac_addrtype_t;
375 
376 typedef struct mac_header_info_s {
377 	size_t		mhi_hdrsize;
378 	size_t		mhi_pktsize;
379 	const uint8_t	*mhi_daddr;
380 	const uint8_t	*mhi_saddr;
381 	uint32_t	mhi_origsap;
382 	uint32_t	mhi_bindsap;
383 	mac_addrtype_t	mhi_dsttype;
384 	boolean_t	mhi_istagged;
385 	uint16_t	mhi_tci;
386 } mac_header_info_t;
387 
388 /*
389  * MAC-Type plugin interfaces
390  */
391 
392 typedef int		(*mtops_addr_verify_t)(const void *, void *);
393 typedef boolean_t	(*mtops_sap_verify_t)(uint32_t, uint32_t *, void *);
394 typedef mblk_t		*(*mtops_header_t)(const void *, const void *,
395     uint32_t, void *, mblk_t *, size_t);
396 typedef int		(*mtops_header_info_t)(mblk_t *, void *,
397     mac_header_info_t *);
398 typedef boolean_t	(*mtops_pdata_verify_t)(void *, size_t);
399 typedef	mblk_t		*(*mtops_header_modify_t)(mblk_t *, void *);
400 typedef void		(*mtops_link_details_t)(char *, size_t, mac_handle_t,
401     void *);
402 
403 typedef struct mactype_ops_s {
404 	uint_t			mtops_ops;
405 	/*
406 	 * mtops_unicst_verify() returns 0 if the given address is a valid
407 	 * unicast address, or a non-zero errno otherwise.
408 	 */
409 	mtops_addr_verify_t	mtops_unicst_verify;
410 	/*
411 	 * mtops_multicst_verify() returns 0 if the given address is a
412 	 * valid multicast address, or a non-zero errno otherwise.  If the
413 	 * media doesn't support multicast, ENOTSUP should be returned (for
414 	 * example).
415 	 */
416 	mtops_addr_verify_t	mtops_multicst_verify;
417 	/*
418 	 * mtops_sap_verify() returns B_TRUE if the given SAP is a valid
419 	 * SAP value, or B_FALSE otherwise.
420 	 */
421 	mtops_sap_verify_t	mtops_sap_verify;
422 	/*
423 	 * mtops_header() is used to allocate and construct a MAC header.
424 	 */
425 	mtops_header_t		mtops_header;
426 	/*
427 	 * mtops_header_info() is used to gather information on a given MAC
428 	 * header.
429 	 */
430 	mtops_header_info_t	mtops_header_info;
431 	/*
432 	 * mtops_pdata_verify() is used to verify the validity of MAC
433 	 * plugin data.  It is called by mac_register() if the driver has
434 	 * supplied MAC plugin data, and also by mac_pdata_update() when
435 	 * drivers update the data.
436 	 */
437 	mtops_pdata_verify_t	mtops_pdata_verify;
438 	/*
439 	 * mtops_header_cook() is an optional callback that converts (or
440 	 * "cooks") the given raw header (as sent by a raw DLPI consumer)
441 	 * into one that is appropriate to send down to the MAC driver.
442 	 * Following the example above, an Ethernet header sent down by a
443 	 * DLPI consumer would be converted to whatever header the MAC
444 	 * driver expects.
445 	 */
446 	mtops_header_modify_t	mtops_header_cook;
447 	/*
448 	 * mtops_header_uncook() is an optional callback that does the
449 	 * opposite of mtops_header_cook().  It "uncooks" a given MAC
450 	 * header (as received from the driver) for consumption by raw DLPI
451 	 * consumers.  For example, for a non-Ethernet plugin that wants
452 	 * raw DLPI consumers to be fooled into thinking that the device
453 	 * provides Ethernet access, this callback would modify the given
454 	 * mblk_t such that the MAC header is converted to an Ethernet
455 	 * header.
456 	 */
457 	mtops_header_modify_t	mtops_header_uncook;
458 	/*
459 	 * mtops_link_details() is an optional callback that provides
460 	 * extended information about the link state.  Its primary purpose
461 	 * is to provide type-specific support for syslog contents on
462 	 * link up events.  If no implementation is provided, then a default
463 	 * implementation will be used.
464 	 */
465 	mtops_link_details_t	mtops_link_details;
466 } mactype_ops_t;
467 
468 /*
469  * mtops_ops exists for the plugin to enumerate the optional callback
470  * entrypoints it has defined.  This allows the mac module to define
471  * additional plugin entrypoints in mactype_ops_t without breaking backward
472  * compatibility with old plugins.
473  */
474 #define	MTOPS_PDATA_VERIFY	0x001
475 #define	MTOPS_HEADER_COOK	0x002
476 #define	MTOPS_HEADER_UNCOOK	0x004
477 #define	MTOPS_LINK_DETAILS	0x008
478 
479 typedef struct mactype_register_s {
480 	uint_t		mtr_version;	/* set by mactype_alloc() */
481 	const char	*mtr_ident;
482 	mactype_ops_t	*mtr_ops;
483 	uint_t		mtr_mactype;
484 	uint_t		mtr_nativetype;
485 	uint_t		mtr_addrlen;
486 	uint8_t		*mtr_brdcst_addr;
487 	mac_stat_info_t	*mtr_stats;
488 	size_t		mtr_statcount;
489 } mactype_register_t;
490 
491 /*
492  * Client interface functions.
493  */
494 extern int			mac_open(const char *, uint_t, mac_handle_t *);
495 extern void			mac_close(mac_handle_t);
496 extern const mac_info_t		*mac_info(mac_handle_t);
497 extern boolean_t		mac_info_get(const char *, mac_info_t *);
498 extern uint64_t			mac_stat_get(mac_handle_t, uint_t);
499 extern int			mac_start(mac_handle_t);
500 extern void			mac_stop(mac_handle_t);
501 extern int			mac_promisc_set(mac_handle_t, boolean_t,
502     mac_promisc_type_t);
503 extern boolean_t		mac_promisc_get(mac_handle_t,
504     mac_promisc_type_t);
505 extern int 			mac_multicst_add(mac_handle_t, const uint8_t *);
506 extern int 			mac_multicst_remove(mac_handle_t,
507     const uint8_t *);
508 extern boolean_t		mac_unicst_verify(mac_handle_t,
509     const uint8_t *, uint_t);
510 extern int			mac_unicst_set(mac_handle_t, const uint8_t *);
511 extern void			mac_unicst_get(mac_handle_t, uint8_t *);
512 extern void			mac_dest_get(mac_handle_t, uint8_t *);
513 extern void			mac_resources(mac_handle_t);
514 extern void			mac_ioctl(mac_handle_t, queue_t *, mblk_t *);
515 extern const mac_txinfo_t	*mac_tx_get(mac_handle_t);
516 extern link_state_t		mac_link_get(mac_handle_t);
517 extern mac_notify_handle_t	mac_notify_add(mac_handle_t, mac_notify_t,
518     void *);
519 extern void			mac_notify_remove(mac_handle_t,
520     mac_notify_handle_t);
521 extern void			mac_notify(mac_handle_t);
522 extern mac_rx_handle_t		mac_rx_add(mac_handle_t, mac_rx_t, void *);
523 extern void			mac_rx_remove(mac_handle_t, mac_rx_handle_t);
524 extern mblk_t			*mac_txloop(void *, mblk_t *);
525 extern mac_txloop_handle_t	mac_txloop_add(mac_handle_t, mac_txloop_t,
526     void *);
527 extern void			mac_txloop_remove(mac_handle_t,
528     mac_txloop_handle_t);
529 extern boolean_t		mac_active_set(mac_handle_t);
530 extern void			mac_active_clear(mac_handle_t);
531 extern void			mac_resource_set(mac_handle_t,
532     mac_resource_add_t, void *);
533 extern dev_info_t		*mac_devinfo_get(mac_handle_t);
534 extern boolean_t		mac_capab_get(mac_handle_t, mac_capab_t,
535     void *);
536 extern boolean_t		mac_sap_verify(mac_handle_t, uint32_t,
537     uint32_t *);
538 extern mblk_t			*mac_header(mac_handle_t, const uint8_t *,
539     uint32_t, mblk_t *, size_t);
540 extern int			mac_header_info(mac_handle_t, mblk_t *,
541     mac_header_info_t *);
542 extern mblk_t			*mac_header_cook(mac_handle_t, mblk_t *);
543 extern mblk_t			*mac_header_uncook(mac_handle_t, mblk_t *);
544 
545 /*
546  * Driver interface functions.
547  */
548 extern mac_register_t		*mac_alloc(uint_t);
549 extern void			mac_free(mac_register_t *);
550 extern int			mac_register(mac_register_t *, mac_handle_t *);
551 extern int  			mac_unregister(mac_handle_t);
552 extern void 			mac_rx(mac_handle_t, mac_resource_handle_t,
553     mblk_t *);
554 extern void 			mac_link_update(mac_handle_t, link_state_t);
555 extern void 			mac_unicst_update(mac_handle_t,
556     const uint8_t *);
557 extern void			mac_tx_update(mac_handle_t);
558 extern void			mac_resource_update(mac_handle_t);
559 extern mac_resource_handle_t	mac_resource_add(mac_handle_t,
560     mac_resource_t *);
561 extern int			mac_pdata_update(mac_handle_t, void *,
562     size_t);
563 extern void			mac_multicst_refresh(mac_handle_t,
564     mac_multicst_t, void *, boolean_t);
565 extern void			mac_unicst_refresh(mac_handle_t, mac_unicst_t,
566     void *);
567 extern void			mac_promisc_refresh(mac_handle_t,
568     mac_setpromisc_t, void *);
569 extern void			mac_init_ops(struct dev_ops *, const char *);
570 extern void			mac_fini_ops(struct dev_ops *);
571 extern mactype_register_t	*mactype_alloc(uint_t);
572 extern void			mactype_free(mactype_register_t *);
573 extern int			mactype_register(mactype_register_t *);
574 extern int			mactype_unregister(const char *);
575 extern int			mac_vlan_create(mac_handle_t, const char *,
576     minor_t);
577 extern void			mac_vlan_remove(mac_handle_t, const char *);
578 
579 #endif	/* _KERNEL */
580 
581 #ifdef	__cplusplus
582 }
583 #endif
584 
585 #endif /* _SYS_MAC_H */
586