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