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