xref: /titanic_50/usr/src/uts/common/sys/mac.h (revision 9a5d73e03cd3312ddb571a748c40a63c58bd66e5)
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 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_MAC_H
28 #define	_SYS_MAC_H
29 
30 #include <sys/types.h>
31 #include <sys/ddi.h>
32 #include <sys/sunddi.h>
33 #include <sys/stream.h>
34 #include <sys/mac_flow.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 v1.20"
48 
49 /*
50  * MAC-Type version identifier.  This is used by mactype_alloc() and
51  * mactype_register() to verify that incompatible MAC-Type plugins don't
52  * register.
53  */
54 #define	MACTYPE_VERSION	0x1
55 
56 /*
57  * Opaque handle types
58  */
59 typedef struct __mac_handle		*mac_handle_t;
60 typedef struct __mac_resource_handle	*mac_resource_handle_t;
61 typedef struct __mac_notify_handle	*mac_notify_handle_t;
62 typedef struct __mac_tx_notify_handle	*mac_tx_notify_handle_t;
63 typedef	struct __mac_intr_handle	*mac_intr_handle_t;
64 typedef	struct __mac_ring_handle	*mac_ring_handle_t;
65 typedef	struct __mac_group_handle	*mac_group_handle_t;
66 
67 #define	DATALINK_INVALID_LINKID	0
68 #define	DATALINK_ALL_LINKID	0
69 #define	DATALINK_MAX_LINKID	0xffffffff
70 
71 #define	MAC_MAX_MINOR	1000
72 
73 typedef	uint32_t		datalink_id_t;
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 typedef enum {
88 	LINK_FLOWCTRL_NONE = 0,
89 	LINK_FLOWCTRL_RX,
90 	LINK_FLOWCTRL_TX,
91 	LINK_FLOWCTRL_BI
92 } link_flowctrl_t;
93 
94 typedef enum {
95 	LINK_TAGMODE_VLANONLY = 0,
96 	LINK_TAGMODE_NORMAL
97 } link_tagmode_t;
98 
99 /*
100  * Maximum MAC address length
101  */
102 #define	MAXMACADDRLEN		20
103 
104 typedef enum {
105 	MAC_LOGTYPE_LINK = 1,
106 	MAC_LOGTYPE_FLOW
107 } mac_logtype_t;
108 
109 /*
110  * Encodings for public properties.
111  * A most significant bit value of 1 indicates private property, intended
112  * to allow private property implementations to use internal encodings
113  * if desired.
114  *
115  * Note that there are 2 sets of parameters: the *_EN_*
116  * values are those that the Administrator configures for autonegotiation.
117  * The _ADV_* values are those that are currently exposed over the wire.
118  */
119 #define	MAXLINKPROPNAME		256
120 #define	MAC_PROP_DEFAULT	0x0001
121 typedef enum {
122 	MAC_PROP_DUPLEX = 0x00000001,
123 	MAC_PROP_SPEED,
124 	MAC_PROP_STATUS,
125 	MAC_PROP_AUTONEG,
126 	MAC_PROP_EN_AUTONEG,
127 	MAC_PROP_MTU,
128 	MAC_PROP_ZONE,
129 	MAC_PROP_AUTOPUSH,
130 	MAC_PROP_FLOWCTRL,
131 	MAC_PROP_ADV_1000FDX_CAP,
132 	MAC_PROP_EN_1000FDX_CAP,
133 	MAC_PROP_ADV_1000HDX_CAP,
134 	MAC_PROP_EN_1000HDX_CAP,
135 	MAC_PROP_ADV_100FDX_CAP,
136 	MAC_PROP_EN_100FDX_CAP,
137 	MAC_PROP_ADV_100HDX_CAP,
138 	MAC_PROP_EN_100HDX_CAP,
139 	MAC_PROP_ADV_10FDX_CAP,
140 	MAC_PROP_EN_10FDX_CAP,
141 	MAC_PROP_ADV_10HDX_CAP,
142 	MAC_PROP_EN_10HDX_CAP,
143 	MAC_PROP_ADV_100T4_CAP,
144 	MAC_PROP_EN_100T4_CAP,
145 	MAC_PROP_WL_ESSID,
146 	MAC_PROP_WL_BSSID,
147 	MAC_PROP_WL_BSSTYPE,
148 	MAC_PROP_WL_LINKSTATUS,
149 	MAC_PROP_WL_DESIRED_RATES,
150 	MAC_PROP_WL_SUPPORTED_RATES,
151 	MAC_PROP_WL_AUTH_MODE,
152 	MAC_PROP_WL_ENCRYPTION,
153 	MAC_PROP_WL_RSSI,
154 	MAC_PROP_WL_PHY_CONFIG,
155 	MAC_PROP_WL_CAPABILITY,
156 	MAC_PROP_WL_WPA,
157 	MAC_PROP_WL_SCANRESULTS,
158 	MAC_PROP_WL_POWER_MODE,
159 	MAC_PROP_WL_RADIO,
160 	MAC_PROP_WL_ESS_LIST,
161 	MAC_PROP_WL_KEY_TAB,
162 	MAC_PROP_WL_CREATE_IBSS,
163 	MAC_PROP_WL_SETOPTIE,
164 	MAC_PROP_WL_DELKEY,
165 	MAC_PROP_WL_KEY,
166 	MAC_PROP_WL_MLME,
167 	MAC_PROP_MAXBW,
168 	MAC_PROP_PRIO,
169 	MAC_PROP_BIND_CPU,
170 	MAC_PROP_TAGMODE,
171 	MAC_PROP_PRIVATE = -1
172 } mac_prop_id_t;
173 
174 /*
175  * Flags to figure out r/w status of legacy ndd props.
176  */
177 #define	MAC_PROP_PERM_READ		0x0001
178 #define	MAC_PROP_PERM_WRITE		0x0010
179 #define	MAC_PROP_MAP_KSTAT		0x0100
180 #define	MAC_PROP_PERM_RW		(MAC_PROP_PERM_READ|MAC_PROP_PERM_WRITE)
181 #define	MAC_PROP_FLAGS_RK		(MAC_PROP_PERM_READ|MAC_PROP_MAP_KSTAT)
182 
183 #ifdef	_KERNEL
184 
185 /*
186  * There are three ranges of statistics values.  0 to 1 - MAC_STAT_MIN are
187  * interface statistics maintained by the mac module.  MAC_STAT_MIN to 1 -
188  * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and
189  * maintained by each driver.  MACTYPE_STAT_MIN and above are statistics
190  * defined by MAC-Type plugins and maintained by each driver.
191  */
192 #define	MAC_STAT_MIN		1000
193 #define	MACTYPE_STAT_MIN	2000
194 
195 #define	IS_MAC_STAT(stat)	\
196 	(stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN)
197 #define	IS_MACTYPE_STAT(stat)	(stat >= MACTYPE_STAT_MIN)
198 
199 /*
200  * Statistics maintained by the mac module, and possibly populated as link
201  * statistics.
202  */
203 enum mac_mod_stat {
204 	MAC_STAT_LINK_STATE,
205 	MAC_STAT_LINK_UP,
206 	MAC_STAT_PROMISC
207 };
208 
209 /*
210  * Do not reorder, and add only to the end of this list.
211  */
212 enum mac_driver_stat {
213 	/* MIB-II stats (RFC 1213 and RFC 1573) */
214 	MAC_STAT_IFSPEED = MAC_STAT_MIN,
215 	MAC_STAT_MULTIRCV,
216 	MAC_STAT_BRDCSTRCV,
217 	MAC_STAT_MULTIXMT,
218 	MAC_STAT_BRDCSTXMT,
219 	MAC_STAT_NORCVBUF,
220 	MAC_STAT_IERRORS,
221 	MAC_STAT_UNKNOWNS,
222 	MAC_STAT_NOXMTBUF,
223 	MAC_STAT_OERRORS,
224 	MAC_STAT_COLLISIONS,
225 	MAC_STAT_RBYTES,
226 	MAC_STAT_IPACKETS,
227 	MAC_STAT_OBYTES,
228 	MAC_STAT_OPACKETS,
229 	MAC_STAT_UNDERFLOWS,
230 	MAC_STAT_OVERFLOWS
231 };
232 
233 #define	MAC_NSTAT	(MAC_STAT_OVERFLOWS - MAC_STAT_IFSPEED + 1)
234 
235 #define	MAC_STAT_ISACOUNTER(_stat) (		\
236 	    (_stat) == MAC_STAT_MULTIRCV ||	\
237 	    (_stat) == MAC_STAT_BRDCSTRCV ||	\
238 	    (_stat) == MAC_STAT_MULTIXMT ||	\
239 	    (_stat) == MAC_STAT_BRDCSTXMT ||	\
240 	    (_stat) == MAC_STAT_NORCVBUF ||	\
241 	    (_stat) == MAC_STAT_IERRORS ||	\
242 	    (_stat) == MAC_STAT_UNKNOWNS ||	\
243 	    (_stat) == MAC_STAT_NOXMTBUF ||	\
244 	    (_stat) == MAC_STAT_OERRORS ||	\
245 	    (_stat) == MAC_STAT_COLLISIONS ||	\
246 	    (_stat) == MAC_STAT_RBYTES ||	\
247 	    (_stat) == MAC_STAT_IPACKETS ||	\
248 	    (_stat) == MAC_STAT_OBYTES ||	\
249 	    (_stat) == MAC_STAT_OPACKETS ||	\
250 	    (_stat) == MAC_STAT_UNDERFLOWS ||	\
251 	    (_stat) == MAC_STAT_OVERFLOWS)
252 
253 /*
254  * Immutable information. (This may not be modified after registration).
255  */
256 typedef struct mac_info_s {
257 	uint_t		mi_media;
258 	uint_t		mi_nativemedia;
259 	uint_t		mi_addr_length;
260 	uint8_t		*mi_unicst_addr;
261 	uint8_t		*mi_brdcst_addr;
262 } mac_info_t;
263 
264 /*
265  * Information for legacy devices.
266  */
267 typedef struct mac_capab_legacy_s {
268 	/*
269 	 * Notifications that the legacy device does not support.
270 	 */
271 	uint32_t	ml_unsup_note;
272 	/*
273 	 * dev_t of the legacy device; can be held to force attach.
274 	 */
275 	dev_t		ml_dev;
276 } mac_capab_legacy_t;
277 
278 /*
279  * When VNICs are created on top of the NIC, there are two levels
280  * of MAC layer, a lower MAC, which is the MAC layer at the level of the
281  * physical NIC, and an upper MAC, which is the MAC layer at the level
282  * of the VNIC. Each VNIC maps to a MAC client at the lower MAC, and
283  * the SRS and classification is done at the lower MAC level. The upper
284  * MAC is therefore for the most part pass-through, and therefore
285  * special processing needs to be done at the upper MAC layer when
286  * dealing with a VNIC.
287  *
288  * This capability allows the MAC layer to detect when a VNIC is being
289  * access, and implement the required shortcuts.
290  */
291 
292 typedef void *(*mac_client_handle_fn_t)(void *);
293 
294 typedef struct mac_capab_vnic_s {
295 	void			*mcv_arg;
296 	mac_client_handle_fn_t	mcv_mac_client_handle;
297 } mac_capab_vnic_t;
298 
299 typedef void (*mac_rename_fn_t)(const char *, void *);
300 typedef struct mac_capab_aggr_s {
301 	mac_rename_fn_t mca_rename_fn;
302 	int (*mca_unicst)(void *, const uint8_t *);
303 } mac_capab_aggr_t;
304 
305 typedef enum {
306 	MAC_NOTE_LINK,
307 	MAC_NOTE_PROMISC,
308 	MAC_NOTE_UNICST,
309 	MAC_NOTE_TX,
310 	MAC_NOTE_RESOURCE,
311 	MAC_NOTE_DEVPROMISC,
312 	MAC_NOTE_FASTPATH_FLUSH,
313 	MAC_NOTE_SDU_SIZE,
314 	MAC_NOTE_MARGIN,
315 	MAC_NOTE_CAPAB_CHG,
316 	MAC_NNOTE	/* must be the last entry */
317 } mac_notify_type_t;
318 
319 typedef void		(*mac_notify_t)(void *, mac_notify_type_t);
320 typedef void		(*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *,
321 			    boolean_t);
322 typedef	mblk_t		*(*mac_receive_t)(void *, int);
323 
324 /*
325  * MAC promiscuous types
326  */
327 typedef enum {
328 	MAC_PROMISC = 0x01,		/* MAC instance is promiscuous */
329 	MAC_DEVPROMISC = 0x02		/* Device is promiscuous */
330 } mac_promisc_type_t;
331 
332 /*
333  * MAC resource types
334  */
335 typedef enum {
336 	MAC_RX_FIFO = 1
337 } mac_resource_type_t;
338 
339 typedef	int	(*mac_intr_enable_t)(mac_intr_handle_t);
340 typedef	int	(*mac_intr_disable_t)(mac_intr_handle_t);
341 
342 typedef	struct mac_intr_s {
343 	mac_intr_handle_t	mi_handle;
344 	mac_intr_enable_t	mi_enable;
345 	mac_intr_disable_t	mi_disable;
346 } mac_intr_t;
347 
348 typedef struct mac_rx_fifo_s {
349 	mac_resource_type_t	mrf_type;	/* MAC_RX_FIFO */
350 	mac_intr_t		mrf_intr;
351 	mac_receive_t		mrf_receive;
352 	void			*mrf_rx_arg;
353 	uint32_t		mrf_flow_priority;
354 	/*
355 	 * The CPU this flow is to be processed on. With intrd and future
356 	 * things, we should know which CPU the flow needs to be processed
357 	 * and get a squeue assigned on that CPU.
358 	 */
359 	uint_t			mrf_cpu_id;
360 } mac_rx_fifo_t;
361 
362 #define	mrf_intr_handle		mrf_intr.mi_handle
363 #define	mrf_intr_enable		mrf_intr.mi_enable
364 #define	mrf_intr_disable	mrf_intr.mi_disable
365 
366 typedef union mac_resource_u {
367 	mac_resource_type_t	mr_type;
368 	mac_rx_fifo_t		mr_fifo;
369 } mac_resource_t;
370 
371 typedef enum {
372 	MAC_ADDRTYPE_UNICAST,
373 	MAC_ADDRTYPE_MULTICAST,
374 	MAC_ADDRTYPE_BROADCAST
375 } mac_addrtype_t;
376 
377 typedef struct mac_header_info_s {
378 	size_t		mhi_hdrsize;
379 	size_t		mhi_pktsize;
380 	const uint8_t	*mhi_daddr;
381 	const uint8_t	*mhi_saddr;
382 	uint32_t	mhi_origsap;
383 	uint32_t	mhi_bindsap;
384 	mac_addrtype_t	mhi_dsttype;
385 	uint16_t	mhi_tci;
386 	boolean_t	mhi_istagged;
387 } mac_header_info_t;
388 
389 /*
390  * Function pointer to match dls client signature. Should be same as
391  * dls_rx_t to allow a soft ring to bypass DLS layer and call a DLS
392  * client directly.
393  */
394 typedef	void		(*mac_direct_rx_t)(void *, mac_resource_handle_t,
395 				mblk_t *, mac_header_info_t *);
396 
397 typedef mac_resource_handle_t	(*mac_resource_add_t)(void *, mac_resource_t *);
398 typedef int			(*mac_resource_bind_t)(void *,
399     mac_resource_handle_t, processorid_t);
400 typedef void			(*mac_resource_remove_t)(void *, void *);
401 typedef void			(*mac_resource_quiesce_t)(void *, void *);
402 typedef void			(*mac_resource_restart_t)(void *, void *);
403 typedef int			(*mac_resource_modify_t)(void *, void *,
404 				    mac_resource_t *);
405 typedef	void			(*mac_change_upcall_t)(void *, mac_direct_rx_t,
406     void *);
407 
408 /*
409  * MAC-Type plugin interfaces
410  */
411 
412 typedef int		(*mtops_addr_verify_t)(const void *, void *);
413 typedef boolean_t	(*mtops_sap_verify_t)(uint32_t, uint32_t *, void *);
414 typedef mblk_t		*(*mtops_header_t)(const void *, const void *,
415     uint32_t, void *, mblk_t *, size_t);
416 typedef int		(*mtops_header_info_t)(mblk_t *, void *,
417     mac_header_info_t *);
418 typedef boolean_t	(*mtops_pdata_verify_t)(void *, size_t);
419 typedef	mblk_t		*(*mtops_header_modify_t)(mblk_t *, void *);
420 typedef void		(*mtops_link_details_t)(char *, size_t, mac_handle_t,
421     void *);
422 
423 typedef struct mactype_ops_s {
424 	uint_t			mtops_ops;
425 	/*
426 	 * mtops_unicst_verify() returns 0 if the given address is a valid
427 	 * unicast address, or a non-zero errno otherwise.
428 	 */
429 	mtops_addr_verify_t	mtops_unicst_verify;
430 	/*
431 	 * mtops_multicst_verify() returns 0 if the given address is a
432 	 * valid multicast address, or a non-zero errno otherwise.  If the
433 	 * media doesn't support multicast, ENOTSUP should be returned (for
434 	 * example).
435 	 */
436 	mtops_addr_verify_t	mtops_multicst_verify;
437 	/*
438 	 * mtops_sap_verify() returns B_TRUE if the given SAP is a valid
439 	 * SAP value, or B_FALSE otherwise.
440 	 */
441 	mtops_sap_verify_t	mtops_sap_verify;
442 	/*
443 	 * mtops_header() is used to allocate and construct a MAC header.
444 	 */
445 	mtops_header_t		mtops_header;
446 	/*
447 	 * mtops_header_info() is used to gather information on a given MAC
448 	 * header.
449 	 */
450 	mtops_header_info_t	mtops_header_info;
451 	/*
452 	 * mtops_pdata_verify() is used to verify the validity of MAC
453 	 * plugin data.  It is called by mac_register() if the driver has
454 	 * supplied MAC plugin data, and also by mac_pdata_update() when
455 	 * drivers update the data.
456 	 */
457 	mtops_pdata_verify_t	mtops_pdata_verify;
458 	/*
459 	 * mtops_header_cook() is an optional callback that converts (or
460 	 * "cooks") the given raw header (as sent by a raw DLPI consumer)
461 	 * into one that is appropriate to send down to the MAC driver.
462 	 * Following the example above, an Ethernet header sent down by a
463 	 * DLPI consumer would be converted to whatever header the MAC
464 	 * driver expects.
465 	 */
466 	mtops_header_modify_t	mtops_header_cook;
467 	/*
468 	 * mtops_header_uncook() is an optional callback that does the
469 	 * opposite of mtops_header_cook().  It "uncooks" a given MAC
470 	 * header (as received from the driver) for consumption by raw DLPI
471 	 * consumers.  For example, for a non-Ethernet plugin that wants
472 	 * raw DLPI consumers to be fooled into thinking that the device
473 	 * provides Ethernet access, this callback would modify the given
474 	 * mblk_t such that the MAC header is converted to an Ethernet
475 	 * header.
476 	 */
477 	mtops_header_modify_t	mtops_header_uncook;
478 	/*
479 	 * mtops_link_details() is an optional callback that provides
480 	 * extended information about the link state.  Its primary purpose
481 	 * is to provide type-specific support for syslog contents on
482 	 * link up events.  If no implementation is provided, then a default
483 	 * implementation will be used.
484 	 */
485 	mtops_link_details_t	mtops_link_details;
486 } mactype_ops_t;
487 
488 /*
489  * mtops_ops exists for the plugin to enumerate the optional callback
490  * entrypoints it has defined.  This allows the mac module to define
491  * additional plugin entrypoints in mactype_ops_t without breaking backward
492  * compatibility with old plugins.
493  */
494 #define	MTOPS_PDATA_VERIFY	0x001
495 #define	MTOPS_HEADER_COOK	0x002
496 #define	MTOPS_HEADER_UNCOOK	0x004
497 #define	MTOPS_LINK_DETAILS	0x008
498 
499 /*
500  * Provide mapping for legacy ndd ioctls relevant to that mactype.
501  * Note that the ndd ioctls are obsolete, and may be removed in a future
502  * release of Solaris. The ndd ioctls are not typically used in legacy
503  * ethernet drivers. New datalink drivers of all link-types should use
504  * dladm(1m) interfaces for administering tunables and not have to provide
505  * a mapping.
506  */
507 typedef struct mac_ndd_mapping_s {
508 	char		*mp_name;
509 	union {
510 		mac_prop_id_t   u_id;
511 		uint_t		u_kstat;
512 	} u_mp_id;
513 	long		mp_minval;
514 	long		mp_maxval;
515 	size_t		mp_valsize;
516 	int		mp_flags;
517 } mac_ndd_mapping_t;
518 
519 #define	mp_prop_id	u_mp_id.u_id
520 #define	mp_kstat	u_mp_id.u_kstat
521 
522 typedef struct mac_stat_info_s {
523 	uint_t		msi_stat;
524 	char		*msi_name;
525 	uint_t		msi_type;	/* as defined in kstat_named_init(9F) */
526 	uint64_t	msi_default;
527 } mac_stat_info_t;
528 
529 typedef struct mactype_register_s {
530 	uint_t		mtr_version;	/* set by mactype_alloc() */
531 	const char	*mtr_ident;
532 	mactype_ops_t	*mtr_ops;
533 	uint_t		mtr_mactype;
534 	uint_t		mtr_nativetype;
535 	uint_t		mtr_addrlen;
536 	uint8_t		*mtr_brdcst_addr;
537 	mac_stat_info_t	*mtr_stats;
538 	size_t		mtr_statcount;
539 	mac_ndd_mapping_t *mtr_mapping;
540 	size_t		mtr_mappingcount;
541 } mactype_register_t;
542 
543 typedef struct mac_prop_s {
544 	mac_prop_id_t	mp_id;
545 	char		*mp_name;
546 	uint_t		mp_flags;
547 } mac_prop_t;
548 
549 /*
550  * Driver interface functions.
551  */
552 extern int			mac_open_by_linkid(datalink_id_t,
553 				    mac_handle_t *);
554 extern int			mac_open_by_linkname(const char *,
555 				    mac_handle_t *);
556 extern const char		*mac_name(mac_handle_t);
557 extern minor_t			mac_minor(mac_handle_t);
558 extern minor_t			mac_minor_hold(boolean_t);
559 extern void			mac_minor_rele(minor_t);
560 extern void			mac_sdu_get(mac_handle_t, uint_t *, uint_t *);
561 extern int			mac_maxsdu_update(mac_handle_t, uint_t);
562 
563 extern void 			mac_unicst_update(mac_handle_t,
564 				    const uint8_t *);
565 extern void			mac_resource_update(mac_handle_t);
566 extern void			mac_capab_update(mac_handle_t);
567 extern int			mac_pdata_update(mac_handle_t, void *,
568 				    size_t);
569 extern boolean_t		mac_margin_update(mac_handle_t, uint32_t);
570 extern void			mac_margin_get(mac_handle_t, uint32_t *);
571 extern int			mac_margin_remove(mac_handle_t, uint32_t);
572 extern int			mac_margin_add(mac_handle_t, uint32_t *,
573 				    boolean_t);
574 
575 extern mactype_register_t	*mactype_alloc(uint_t);
576 extern void			mactype_free(mactype_register_t *);
577 extern int			mactype_register(mactype_register_t *);
578 extern int			mactype_unregister(const char *);
579 
580 extern void			mac_start_logusage(mac_logtype_t, uint_t);
581 extern void			mac_stop_logusage(mac_logtype_t);
582 
583 extern mac_handle_t		mac_get_lower_mac_handle(mac_handle_t);
584 
585 /*
586  * Packet hashing for distribution to multiple ports and rings.
587  */
588 
589 #define	MAC_PKT_HASH_L2		0x01
590 #define	MAC_PKT_HASH_L3		0x02
591 #define	MAC_PKT_HASH_L4		0x04
592 
593 extern uint64_t			mac_pkt_hash(uint_t, mblk_t *, uint8_t,
594 				    boolean_t);
595 
596 #endif	/* _KERNEL */
597 
598 #ifdef	__cplusplus
599 }
600 #endif
601 
602 #endif /* _SYS_MAC_H */
603