xref: /illumos-gate/usr/src/uts/common/sys/mac_provider.h (revision b8052df9f609edb713f6828c9eecc3d7be19dfb3)
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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright (c) 2018, Joyent, Inc.
25  * Copyright 2020 RackTop Systems, Inc.
26  */
27 
28 #ifndef	_SYS_MAC_PROVIDER_H
29 #define	_SYS_MAC_PROVIDER_H
30 
31 #include <sys/types.h>
32 #include <sys/ddi.h>
33 #include <sys/sunddi.h>
34 #include <sys/stream.h>
35 #include <sys/mkdev.h>
36 #include <sys/mac.h>
37 #include <sys/mac_flow.h>
38 
39 /*
40  * MAC Provider Interface
41  */
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 /*
48  * MAC version identifiers. Drivers compiled against the stable V1 version
49  * of the API should register with MAC_VERSION_V1. ON drivers should use
50  * MAC_VERSION. This is used by mac_alloc() mac_register() to
51  * verify that incompatible drivers don't register.
52  */
53 #define	MAC_VERSION_V1	0x1
54 #define	MAC_VERSION	MAC_VERSION_V1
55 
56 /*
57  * Possible values for ETHER_STAT_XCVR_INUSE statistic.
58  */
59 
60 #define	XCVR_UNDEFINED		0
61 #define	XCVR_NONE		1
62 #define	XCVR_10			2
63 #define	XCVR_100T4		3
64 #define	XCVR_100X		4
65 #define	XCVR_100T2		5
66 #define	XCVR_1000X		6
67 #define	XCVR_1000T		7
68 
69 #ifdef	_KERNEL
70 
71 /*
72  * Definitions for MAC Drivers Capabilities
73  */
74 /*
75  * MAC layer capabilities.  These capabilities are handled by the drivers'
76  * mc_capab_get() callbacks.  Some capabilities require the driver to fill
77  * in a given data structure, and others are simply boolean capabilities.
78  * Note that capability values must be powers of 2 so that consumers and
79  * providers of this interface can keep track of which capabilities they
80  * care about by keeping a bitfield of these things around somewhere.
81  */
82 typedef enum {
83 	/*
84 	 * Public Capabilities (MAC_VERSION_V1)
85 	 */
86 	MAC_CAPAB_HCKSUM	= 0x00000001, /* data is a uint32_t */
87 	MAC_CAPAB_LSO		= 0x00000008, /* data is mac_capab_lso_t */
88 
89 	/*
90 	 * Reserved capabilities, do not use
91 	 */
92 	MAC_CAPAB_RESERVED1	= 0x00000002,
93 	MAC_CAPAB_RESERVED2	= 0x00000004,
94 
95 	/*
96 	 * Private driver capabilities
97 	 */
98 	MAC_CAPAB_RINGS		= 0x00000010, /* data is mac_capab_rings_t */
99 	MAC_CAPAB_SHARES	= 0x00000020, /* data is mac_capab_share_t */
100 	MAC_CAPAB_MULTIFACTADDR = 0x00000040, /* mac_data_multifactaddr_t */
101 
102 	/*
103 	 * Private driver capabilities for use by the GLDv3 framework only
104 	 */
105 	MAC_CAPAB_VNIC		= 0x00010000, /* data is mac_capab_vnic_t */
106 	MAC_CAPAB_ANCHOR_VNIC	= 0x00020000, /* boolean only, no data */
107 	MAC_CAPAB_AGGR		= 0x00040000, /* data is mac_capab_aggr_t */
108 	MAC_CAPAB_NO_NATIVEVLAN	= 0x00080000, /* boolean only, no data */
109 	MAC_CAPAB_NO_ZCOPY	= 0x00100000, /* boolean only, no data */
110 	MAC_CAPAB_LEGACY	= 0x00200000, /* data is mac_capab_legacy_t */
111 	MAC_CAPAB_VRRP		= 0x00400000, /* data is mac_capab_vrrp_t */
112 	MAC_CAPAB_OVERLAY	= 0x00800000, /* boolean only, no data */
113 	MAC_CAPAB_TRANSCEIVER	= 0x01000000, /* mac_capab_transceiver_t */
114 	MAC_CAPAB_LED		= 0x02000000  /* data is mac_capab_led_t */
115 } mac_capab_t;
116 
117 /*
118  * LSO capability
119  */
120 typedef struct lso_basic_tcp_ipv4_s {
121 	t_uscalar_t	lso_max;		/* maximum payload */
122 } lso_basic_tcp_ipv4_t;
123 
124 typedef struct lso_basic_tcp_ipv6_s {
125 	t_uscalar_t	lso_max;		/* maximum payload */
126 } lso_basic_tcp_ipv6_t;
127 
128 /*
129  * Currently supported flags for LSO.
130  */
131 #define	LSO_TX_BASIC_TCP_IPV4	0x01		/* TCPv4 LSO capability */
132 #define	LSO_TX_BASIC_TCP_IPV6	0x02		/* TCPv6 LSO capability */
133 
134 /*
135  * Future LSO capabilities can be added at the end of the mac_capab_lso_t.
136  * When such capability is added to the GLDv3 framework, the size of the
137  * mac_capab_lso_t it allocates and passes to the drivers increases. Older
138  * drivers wil access only the (upper) sections of that structure, that is the
139  * sections carrying the capabilities they understand. This ensures the
140  * interface can be safely extended in a binary compatible way.
141  */
142 typedef	struct mac_capab_lso_s {
143 	t_uscalar_t		lso_flags;
144 	lso_basic_tcp_ipv4_t	lso_basic_tcp_ipv4;
145 	lso_basic_tcp_ipv6_t	lso_basic_tcp_ipv6;
146 	/* Add future lso capabilities here */
147 } mac_capab_lso_t;
148 
149 /*
150  * Multiple Factory MAC Addresses Capability
151  */
152 typedef struct mac_capab_multifactaddr_s {
153 	/*
154 	 * Number of factory addresses
155 	 */
156 	uint_t		mcm_naddr;
157 
158 	/*
159 	 * Callbacks to query all the factory addresses.
160 	 */
161 	void		(*mcm_getaddr)(void *, uint_t, uint8_t *);
162 } mac_capab_multifactaddr_t;
163 
164 /*
165  * Info and callbacks of legacy devices.
166  */
167 typedef struct mac_capab_legacy_s {
168 	/*
169 	 * Notifications that the legacy device does not support.
170 	 */
171 	uint32_t	ml_unsup_note;
172 	/*
173 	 * dev_t of the legacy device; can be held to force attach.
174 	 */
175 	dev_t		ml_dev;
176 	boolean_t	(*ml_active_set)(void *);
177 	void		(*ml_active_clear)(void *);
178 	int		(*ml_fastpath_disable)(void *);
179 	void		(*ml_fastpath_enable)(void *);
180 } mac_capab_legacy_t;
181 
182 typedef struct __mac_prop_info_handle *mac_prop_info_handle_t;
183 
184 /*
185  * MAC driver entry point types.
186  */
187 typedef int		(*mac_getstat_t)(void *, uint_t, uint64_t *);
188 typedef	int		(*mac_start_t)(void *);
189 typedef void		(*mac_stop_t)(void *);
190 typedef int		(*mac_setpromisc_t)(void *, boolean_t);
191 typedef int		(*mac_multicst_t)(void *, boolean_t, const uint8_t *);
192 typedef int		(*mac_unicst_t)(void *, const uint8_t *);
193 typedef void		(*mac_ioctl_t)(void *, queue_t *, mblk_t *);
194 typedef void		(*mac_resources_t)(void *);
195 typedef mblk_t		*(*mac_tx_t)(void *, mblk_t *);
196 typedef	boolean_t	(*mac_getcapab_t)(void *, mac_capab_t, void *);
197 typedef	int		(*mac_open_t)(void *);
198 typedef void		(*mac_close_t)(void *);
199 typedef	int		(*mac_set_prop_t)(void *, const char *, mac_prop_id_t,
200 			    uint_t, const void *);
201 typedef	int		(*mac_get_prop_t)(void *, const char *, mac_prop_id_t,
202 			    uint_t, void *);
203 typedef void		(*mac_prop_info_t)(void *, const char *, mac_prop_id_t,
204 			    mac_prop_info_handle_t);
205 
206 /*
207  * Driver callbacks. The following capabilities are optional, and if
208  * implemented by the driver, must have a corresponding MC_ flag set
209  * in the mc_callbacks field.
210  *
211  * Any future additions to this list must also be accompanied by an
212  * associated mc_callbacks flag so that the framework can grow without
213  * affecting the binary compatibility of the interface.
214  */
215 typedef struct mac_callbacks_s {
216 	uint_t		mc_callbacks;	/* Denotes which callbacks are set */
217 	mac_getstat_t	mc_getstat;	/* Get the value of a statistic */
218 	mac_start_t	mc_start;	/* Start the device */
219 	mac_stop_t	mc_stop;	/* Stop the device */
220 	mac_setpromisc_t mc_setpromisc;	/* Enable or disable promiscuous mode */
221 	mac_multicst_t	mc_multicst;	/* Enable or disable a multicast addr */
222 	mac_unicst_t	mc_unicst;	/* Set the unicast MAC address */
223 	mac_tx_t	mc_tx;		/* Transmit a packet */
224 	void		*mc_reserved;	/* Reserved, do not use */
225 	mac_ioctl_t	mc_ioctl;	/* Process an unknown ioctl */
226 	mac_getcapab_t	mc_getcapab;	/* Get capability information */
227 	mac_open_t	mc_open;	/* Open the device */
228 	mac_close_t	mc_close;	/* Close the device */
229 	mac_set_prop_t	mc_setprop;
230 	mac_get_prop_t	mc_getprop;
231 	mac_prop_info_t	mc_propinfo;
232 } mac_callbacks_t;
233 
234 /*
235  * Flags for mc_callbacks.  Requiring drivers to set the flags associated
236  * with optional callbacks initialized in the structure allows the mac
237  * module to add optional callbacks in the future without requiring drivers
238  * to recompile.
239  */
240 #define	MC_RESERVED	0x0001
241 #define	MC_IOCTL	0x0002
242 #define	MC_GETCAPAB	0x0004
243 #define	MC_OPEN		0x0008
244 #define	MC_CLOSE	0x0010
245 #define	MC_SETPROP	0x0020
246 #define	MC_GETPROP	0x0040
247 #define	MC_PROPINFO	0x0080
248 #define	MC_PROPERTIES	(MC_SETPROP | MC_GETPROP | MC_PROPINFO)
249 
250 /*
251  * Virtualization Capabilities
252  */
253 
254 /*
255  * The type of ring classification. This is used by MAC to determine
256  * what, if any, processing it has to do upon receiving traffic on a
257  * particular Rx ring.
258  *
259  * MAC_NO_CLASSIFIER
260  *
261  *	No classification has been set. No traffic should cross an Rx
262  *	ring in this state.
263  *
264  * MAC_SW_CLASSIFIER
265  *
266  *	The driver delivers traffic for multiple clients to this ring.
267  *	All traffic must be software classified by MAC to guarantee
268  *	delivery to the correct client. This classification type may
269  *	be chosen for several reasons.
270  *
271  *	o The driver provides only one group and there are multiple
272  *	  clients using the MAC.
273  *
274  *	o The driver provides some hardware filtering but not enough
275  *	  to fully classify the traffic. E.g., a VLAN VNIC requires L2
276  *	  unicast address filtering as well as VLAN filtering, but
277  *	  some drivers may only support the former.
278  *
279  *	o The ring belongs to the default group. The default group
280  *	  acts as a spillover for all clients that can't reserve an
281  *	  exclusive group. It also handles multicast traffic for all
282  *	  clients. For these reasons, the default group's rings are
283  *	  always software classified.
284  *
285  * MAC_HW_CLASSIFIER
286  *
287  *	The driver delivers traffic for a single MAC client across
288  *	this ring. With this guarantee, MAC can simply pass the
289  *	traffic up the stack or even allow polling of the ring.
290  *
291  * MAC_PASSTHRU_CLASSIFIER
292  *
293  *	The ring is in "passthru" mode. In this mode we bypass all of
294  *	the typical MAC processing and pass the traffic directly to
295  *	the mr_pt_fn callback, see mac_rx_common(). This is used in
296  *	cases where there is another module acting as MAC provider on
297  *	behalf of the driver. E.g., link aggregations use this mode to
298  *	take full control of the port's rings; allowing it to enforce
299  *	LACP protocols and aggregate rings across discrete drivers.
300  */
301 typedef enum {
302 	MAC_NO_CLASSIFIER = 0,
303 	MAC_SW_CLASSIFIER,
304 	MAC_HW_CLASSIFIER,
305 	MAC_PASSTHRU_CLASSIFIER
306 } mac_classify_type_t;
307 
308 typedef	void	(*mac_rx_func_t)(void *, mac_resource_handle_t, mblk_t *,
309     boolean_t);
310 
311 /*
312  * The virtualization level conveys the extent of the NIC hardware assistance
313  * for traffic steering employed for virtualization:
314  *
315  * MAC_VIRT_NONE:	No assist for v12n.
316  *
317  * MAC_VIRT_LEVEL1:	Multiple Rx rings with MAC address level
318  *			classification between groups of rings.
319  *			Requires the support of the MAC_CAPAB_RINGS
320  *			capability.
321  *
322  * MAC_VIRT_HIO:	Hybrid I/O capable MAC. Require the support
323  *			of the MAC_CAPAB_SHARES capability.
324  */
325 #define	MAC_VIRT_NONE		0x0
326 #define	MAC_VIRT_LEVEL1		0x1
327 #define	MAC_VIRT_HIO		0x2
328 
329 typedef enum {
330 	MAC_RING_TYPE_RX = 1,	/* Receive ring */
331 	MAC_RING_TYPE_TX	/* Transmit ring */
332 } mac_ring_type_t;
333 
334 /*
335  * The value VLAN_ID_NONE (VID 0) means a client does not have
336  * membership to any VLAN. However, this statement is true for both
337  * untagged packets and priority tagged packets leading to confusion
338  * over what semantic is intended. To the provider, VID 0 is a valid
339  * VID when priority tagging is in play. To MAC and everything above
340  * VLAN_ID_NONE almost universally implies untagged traffic. Thus, we
341  * convert VLAN_ID_NONE to a sentinel value (MAC_VLAN_UNTAGGED) at the
342  * border between MAC and MAC provider. This informs the provider that
343  * the client is interested in untagged traffic and the provider
344  * should set any relevant bits to receive such traffic.
345  *
346  * Currently, the API between MAC and the provider passes the VID as a
347  * unit16_t. In the future this could actually be the entire TCI mask
348  * (PCP, DEI, and VID). This current scheme is safe in that potential
349  * future world as well; as 0xFFFF is not a valid TCI (the 0xFFF VID
350  * is reserved and never transmitted across networks).
351  */
352 #define	MAC_VLAN_UNTAGGED		UINT16_MAX
353 #define	MAC_VLAN_UNTAGGED_VID(vid)	\
354 	(((vid) == VLAN_ID_NONE) ? MAC_VLAN_UNTAGGED : (vid))
355 
356 /*
357  * Grouping type of a ring group
358  *
359  * MAC_GROUP_TYPE_STATIC: The ring group can not be re-grouped.
360  * MAC_GROUP_TYPE_DYNAMIC: The ring group support dynamic re-grouping
361  */
362 typedef enum {
363 	MAC_GROUP_TYPE_STATIC = 1,	/* Static ring group */
364 	MAC_GROUP_TYPE_DYNAMIC		/* Dynamic ring group */
365 } mac_group_type_t;
366 
367 typedef	struct __mac_ring_driver	*mac_ring_driver_t;
368 typedef	struct __mac_group_driver	*mac_group_driver_t;
369 
370 typedef	struct mac_ring_info_s mac_ring_info_t;
371 typedef	struct mac_group_info_s mac_group_info_t;
372 
373 typedef void	(*mac_get_ring_t)(void *, mac_ring_type_t, const int, const int,
374     mac_ring_info_t *, mac_ring_handle_t);
375 typedef void	(*mac_get_group_t)(void *, mac_ring_type_t, const int,
376     mac_group_info_t *, mac_group_handle_t);
377 
378 typedef void	(*mac_group_add_ring_t)(mac_group_driver_t,
379     mac_ring_driver_t, mac_ring_type_t);
380 typedef void	(*mac_group_rem_ring_t)(mac_group_driver_t,
381     mac_ring_driver_t, mac_ring_type_t);
382 
383 /*
384  * Multiple Rings Capability
385  */
386 typedef struct	mac_capab_rings_s {
387 	mac_ring_type_t		mr_type;	/* Ring type: Rx vs Tx */
388 	mac_group_type_t	mr_group_type;	/* Dynamic vs static grouping */
389 	uint_t			mr_rnum;	/* Number of rings */
390 	uint_t			mr_gnum;	/* Number of ring groups */
391 	mac_get_ring_t		mr_rget;	/* Get ring from driver */
392 	mac_get_group_t		mr_gget;	/* Get ring group from driver */
393 	mac_group_add_ring_t	mr_gaddring;	/* Add ring into a group */
394 	mac_group_rem_ring_t	mr_gremring;	/* Remove ring from a group */
395 } mac_capab_rings_t;
396 
397 /*
398  * Common ring functions and driver interfaces
399  */
400 typedef	int	(*mac_ring_start_t)(mac_ring_driver_t, uint64_t);
401 typedef	void	(*mac_ring_stop_t)(mac_ring_driver_t);
402 
403 typedef	mblk_t	*(*mac_ring_send_t)(void *, mblk_t *);
404 typedef	mblk_t	*(*mac_ring_poll_t)(void *, int);
405 
406 typedef int	(*mac_ring_stat_t)(mac_ring_driver_t, uint_t, uint64_t *);
407 
408 typedef struct mac_ring_info_s {
409 	mac_ring_driver_t	mri_driver;
410 	mac_ring_start_t	mri_start;
411 	mac_ring_stop_t		mri_stop;
412 	mac_intr_t		mri_intr;
413 	union {
414 		mac_ring_send_t	send;
415 		mac_ring_poll_t	poll;
416 	} mrfunion;
417 	mac_ring_stat_t		mri_stat;
418 
419 	/*
420 	 * mri_flags will have some bits set to indicate some special
421 	 * property/feature of a ring like serialization needed for a
422 	 * Tx ring or packets should always need enqueuing on Rx side,
423 	 * etc.
424 	 */
425 	uint_t			mri_flags;
426 } mac_ring_info_s;
427 
428 #define	mri_tx			mrfunion.send
429 #define	mri_poll		mrfunion.poll
430 
431 /*
432  * #defines for mri_flags. The flags are temporary flags that are provided
433  * only to workaround issues in specific drivers, and they will be
434  * removed in the future.
435  *
436  * These are consumed only by sun4v and neptune (nxge).
437  */
438 #define	MAC_RING_TX_SERIALIZE		0x1
439 #define	MAC_RING_RX_ENQUEUE		0x2
440 
441 typedef	int	(*mac_group_start_t)(mac_group_driver_t);
442 typedef	void	(*mac_group_stop_t)(mac_group_driver_t);
443 typedef	int	(*mac_add_mac_addr_t)(void *, const uint8_t *);
444 typedef	int	(*mac_rem_mac_addr_t)(void *, const uint8_t *);
445 typedef int	(*mac_add_vlan_filter_t)(mac_group_driver_t, uint16_t);
446 typedef int	(*mac_rem_vlan_filter_t)(mac_group_driver_t, uint16_t);
447 
448 struct mac_group_info_s {
449 	mac_group_driver_t	mgi_driver;	/* Driver reference */
450 	mac_group_start_t	mgi_start;	/* Start the group */
451 	mac_group_stop_t	mgi_stop;	/* Stop the group */
452 	uint_t			mgi_count;	/* Count of rings */
453 	mac_intr_t		mgi_intr;	/* Optional per-group intr */
454 
455 	/* Only used for Rx groups */
456 	mac_add_mac_addr_t	mgi_addmac;	/* Add a MAC address */
457 	mac_rem_mac_addr_t	mgi_remmac;	/* Remove a MAC address */
458 	mac_add_vlan_filter_t	mgi_addvlan;	/* Add a VLAN filter */
459 	mac_rem_vlan_filter_t	mgi_remvlan;	/* Remove a VLAN filter */
460 };
461 
462 /*
463  * Share management functions.
464  */
465 typedef uint64_t mac_share_handle_t;
466 
467 /*
468  * Allocate and free a share. Returns ENOSPC if all shares have been
469  * previously allocated.
470  */
471 typedef int (*mac_alloc_share_t)(void *, mac_share_handle_t *);
472 typedef void (*mac_free_share_t)(mac_share_handle_t);
473 
474 /*
475  * Bind and unbind a share. Binding a share allows a domain
476  * to have direct access to the groups and rings associated with
477  * that share.
478  */
479 typedef int (*mac_bind_share_t)(mac_share_handle_t, uint64_t, uint64_t *);
480 typedef void (*mac_unbind_share_t)(mac_share_handle_t);
481 
482 /*
483  * Return information on about a share.
484  */
485 typedef void (*mac_share_query_t)(mac_share_handle_t, mac_ring_type_t,
486     mac_ring_handle_t *, uint_t *);
487 
488 /*
489  * Basic idea, bind previously created ring groups to shares
490  * for them to be exported (or shared) by another domain.
491  * These interfaces bind/unbind the ring group to a share.
492  * The groups and their rings will be shared with the guest
493  * as soon as the share is bound.
494  */
495 typedef int (*mac_share_add_group_t)(mac_share_handle_t,
496     mac_group_driver_t);
497 typedef int (*mac_share_rem_group_t)(mac_share_handle_t,
498     mac_group_driver_t);
499 
500 typedef struct  mac_capab_share_s {
501 	uint_t			ms_snum;	/* Number of shares (vr's) */
502 	void			*ms_handle;	/* Handle to driver. */
503 	mac_alloc_share_t	ms_salloc;	/* Get a share from driver. */
504 	mac_free_share_t	ms_sfree;	/* Return a share to driver. */
505 	mac_share_add_group_t	ms_sadd;	/* Add a group to the share. */
506 	mac_share_rem_group_t	ms_sremove;	/* Remove group from share. */
507 	mac_share_query_t	ms_squery;	/* Query share constraints */
508 	mac_bind_share_t	ms_sbind;	/* Bind a share */
509 	mac_unbind_share_t	ms_sunbind;	/* Unbind a share */
510 } mac_capab_share_t;
511 
512 typedef struct mac_capab_vrrp_s {
513 	/* IPv6 or IPv4? */
514 	int		mcv_af;
515 } mac_capab_vrrp_t;
516 
517 /*
518  * Transceiver capability
519  */
520 typedef struct mac_transceiver_info mac_transceiver_info_t;
521 
522 typedef struct mac_capab_transceiver {
523 	uint_t	mct_flags;
524 	uint_t	mct_ntransceivers;
525 	int	(*mct_info)(void *, uint_t, mac_transceiver_info_t *);
526 	int	(*mct_read)(void *, uint_t, uint_t, void *, size_t, off_t,
527 		    size_t *);
528 } mac_capab_transceiver_t;
529 
530 /*
531  * LED capability
532  */
533 typedef struct mac_capab_led {
534 	uint_t		mcl_flags;
535 	mac_led_mode_t	mcl_modes;
536 	int		(*mcl_set)(void *, mac_led_mode_t, uint_t);
537 } mac_capab_led_t;
538 
539 /*
540  * MAC registration interface
541  */
542 typedef struct mac_register_s {
543 	uint_t			m_version;	/* set by mac_alloc() */
544 	const char		*m_type_ident;
545 	void			*m_driver;	/* Driver private data */
546 	dev_info_t		*m_dip;
547 	uint_t			m_instance;
548 	uint8_t			*m_src_addr;
549 	uint8_t			*m_dst_addr;
550 	mac_callbacks_t		*m_callbacks;
551 	uint_t			m_min_sdu;
552 	uint_t			m_max_sdu;
553 	void			*m_pdata;
554 	size_t			m_pdata_size;
555 	char			**m_priv_props;
556 	uint32_t		m_margin;
557 	uint32_t		m_v12n;		/* Virtualization level */
558 	uint_t			m_multicast_sdu;
559 } mac_register_t;
560 
561 /*
562  * Driver interface functions.
563  */
564 extern mac_protect_t		*mac_protect_get(mac_handle_t);
565 extern void			mac_sdu_get(mac_handle_t, uint_t *, uint_t *);
566 extern void			mac_sdu_get2(mac_handle_t, uint_t *, uint_t *,
567 				    uint_t *);
568 extern int			mac_maxsdu_update(mac_handle_t, uint_t);
569 extern int			mac_maxsdu_update2(mac_handle_t, uint_t,
570 				    uint_t);
571 
572 extern mac_register_t		*mac_alloc(uint_t);
573 extern void			mac_free(mac_register_t *);
574 extern int			mac_register(mac_register_t *, mac_handle_t *);
575 extern int			mac_disable_nowait(mac_handle_t);
576 extern int			mac_disable(mac_handle_t);
577 extern int			mac_unregister(mac_handle_t);
578 extern void			mac_rx(mac_handle_t, mac_resource_handle_t,
579 				    mblk_t *);
580 extern void			mac_rx_ring(mac_handle_t, mac_ring_handle_t,
581 				    mblk_t *, uint64_t);
582 extern void			mac_link_update(mac_handle_t, link_state_t);
583 extern void			mac_link_redo(mac_handle_t, link_state_t);
584 extern void			mac_unicst_update(mac_handle_t,
585 				    const uint8_t *);
586 extern void			mac_dst_update(mac_handle_t, const uint8_t *);
587 extern void			mac_tx_update(mac_handle_t);
588 extern void			mac_tx_ring_update(mac_handle_t,
589 				    mac_ring_handle_t);
590 extern void			mac_capab_update(mac_handle_t);
591 extern int			mac_pdata_update(mac_handle_t, void *,
592 				    size_t);
593 extern void			mac_multicast_refresh(mac_handle_t,
594 				    mac_multicst_t, void *, boolean_t);
595 extern void			mac_unicst_refresh(mac_handle_t, mac_unicst_t,
596 				    void *);
597 extern void			mac_promisc_refresh(mac_handle_t,
598 				    mac_setpromisc_t, void *);
599 extern boolean_t		mac_margin_update(mac_handle_t, uint32_t);
600 extern void			mac_margin_get(mac_handle_t, uint32_t *);
601 extern int			mac_margin_remove(mac_handle_t, uint32_t);
602 extern int			mac_margin_add(mac_handle_t, uint32_t *,
603 				    boolean_t);
604 extern void			mac_init_ops(struct dev_ops *, const char *);
605 extern void			mac_fini_ops(struct dev_ops *);
606 extern int			mac_devt_to_instance(dev_t);
607 extern minor_t			mac_private_minor(void);
608 extern void			mac_ring_intr_set(mac_ring_handle_t,
609 				    ddi_intr_handle_t);
610 
611 
612 extern mactype_register_t	*mactype_alloc(uint_t);
613 extern void			mactype_free(mactype_register_t *);
614 extern int			mactype_register(mactype_register_t *);
615 extern int			mactype_unregister(const char *);
616 
617 extern boolean_t		mac_unicst_verify(mac_handle_t,
618 				    const uint8_t *, uint_t);
619 
620 extern int			mac_group_add_ring(mac_group_handle_t, int);
621 extern void			mac_group_rem_ring(mac_group_handle_t,
622 				    mac_ring_handle_t);
623 extern mac_ring_handle_t	mac_find_ring(mac_group_handle_t, int);
624 
625 extern void			mac_prop_info_set_default_uint8(
626 				    mac_prop_info_handle_t, uint8_t);
627 extern void			mac_prop_info_set_default_str(
628 				    mac_prop_info_handle_t, const char *);
629 extern void			mac_prop_info_set_default_uint64(
630 				    mac_prop_info_handle_t, uint64_t);
631 extern void			mac_prop_info_set_default_uint32(
632 				    mac_prop_info_handle_t, uint32_t);
633 extern void			mac_prop_info_set_default_link_flowctrl(
634 				    mac_prop_info_handle_t, link_flowctrl_t);
635 extern void			mac_prop_info_set_default_fec(
636 				    mac_prop_info_handle_t, link_fec_t);
637 extern void			mac_prop_info_set_range_uint32(
638 				    mac_prop_info_handle_t,
639 				    uint32_t, uint32_t);
640 extern void			mac_prop_info_set_perm(mac_prop_info_handle_t,
641 				    uint8_t);
642 
643 extern void			mac_hcksum_get(const mblk_t *, uint32_t *,
644 				    uint32_t *, uint32_t *, uint32_t *,
645 				    uint32_t *);
646 extern void			mac_hcksum_set(mblk_t *, uint32_t, uint32_t,
647 				    uint32_t, uint32_t, uint32_t);
648 extern void			mac_hcksum_clone(const mblk_t *, mblk_t *);
649 
650 extern void			mac_lso_get(mblk_t *, uint32_t *, uint32_t *);
651 
652 extern void			mac_transceiver_info_set_present(
653 				    mac_transceiver_info_t *,
654 				    boolean_t);
655 extern void			mac_transceiver_info_set_usable(
656 				    mac_transceiver_info_t *,
657 				    boolean_t);
658 
659 /*
660  * This represents a provisional set of currently illumos-private APIs to get
661  * information about a mblk_t chain's type. This is an evolving interface.
662  */
663 typedef enum mac_ether_offload_flags {
664 	MEOI_L2INFO_SET		= 1 << 0,
665 	MEOI_VLAN_TAGGED	= 1 << 1,
666 	MEOI_L3INFO_SET		= 1 << 2,
667 	MEOI_L4INFO_SET		= 1 << 3
668 } mac_ether_offload_flags_t;
669 
670 typedef struct mac_ether_offload_info {
671 	mac_ether_offload_flags_t	meoi_flags;	/* What's valid? */
672 	size_t		meoi_len;	/* Total message length */
673 	uint8_t		meoi_l2hlen;	/* How long is the Ethernet header? */
674 	uint16_t	meoi_l3proto;	/* What's the Ethertype */
675 	uint8_t		meoi_l3hlen;	/* How long is the header? */
676 	uint8_t		meoi_l4proto;	/* What is the payload type? */
677 	uint8_t		meoi_l4hlen;	/* How long is the L4 header */
678 } mac_ether_offload_info_t;
679 
680 extern int			mac_ether_offload_info(mblk_t *,
681 				    mac_ether_offload_info_t *);
682 
683 
684 #endif	/* _KERNEL */
685 
686 #ifdef	__cplusplus
687 }
688 #endif
689 
690 #endif /* _SYS_MAC_PROVIDER_H */
691