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