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