1da14cebeSEric Cheng /*
2da14cebeSEric Cheng  * CDDL HEADER START
3da14cebeSEric Cheng  *
4da14cebeSEric Cheng  * The contents of this file are subject to the terms of the
5da14cebeSEric Cheng  * Common Development and Distribution License (the "License").
6da14cebeSEric Cheng  * You may not use this file except in compliance with the License.
7da14cebeSEric Cheng  *
8da14cebeSEric Cheng  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da14cebeSEric Cheng  * or http://www.opensolaris.org/os/licensing.
10da14cebeSEric Cheng  * See the License for the specific language governing permissions
11da14cebeSEric Cheng  * and limitations under the License.
12da14cebeSEric Cheng  *
13da14cebeSEric Cheng  * When distributing Covered Code, include this CDDL HEADER in each
14da14cebeSEric Cheng  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15da14cebeSEric Cheng  * If applicable, add the following below this CDDL HEADER, with the
16da14cebeSEric Cheng  * fields enclosed by brackets "[]" replaced with your own identifying
17da14cebeSEric Cheng  * information: Portions Copyright [yyyy] [name of copyright owner]
18da14cebeSEric Cheng  *
19da14cebeSEric Cheng  * CDDL HEADER END
20da14cebeSEric Cheng  */
21da14cebeSEric Cheng 
22da14cebeSEric Cheng /*
23550b6e40SSowmini Varadhan  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2484de666eSRyan Zezeski  * Copyright (c) 2018, Joyent, Inc.
25d77e6e0fSPaul Winder  * Copyright 2020 RackTop Systems, Inc.
26*86e5bb79SLuqman Aden  * Copyright 2023 Oxide Computer Company
27da14cebeSEric Cheng  */
28da14cebeSEric Cheng 
29da14cebeSEric Cheng #ifndef	_SYS_MAC_PROVIDER_H
30da14cebeSEric Cheng #define	_SYS_MAC_PROVIDER_H
31da14cebeSEric Cheng 
32da14cebeSEric Cheng #include <sys/types.h>
33da14cebeSEric Cheng #include <sys/ddi.h>
34da14cebeSEric Cheng #include <sys/sunddi.h>
35da14cebeSEric Cheng #include <sys/stream.h>
3693a61d92SGarrett D'Amore #include <sys/mkdev.h>
37da14cebeSEric Cheng #include <sys/mac.h>
38550b6e40SSowmini Varadhan #include <sys/mac_flow.h>
39da14cebeSEric Cheng 
40da14cebeSEric Cheng /*
41da14cebeSEric Cheng  * MAC Provider Interface
42da14cebeSEric Cheng  */
43da14cebeSEric Cheng 
44da14cebeSEric Cheng #ifdef	__cplusplus
45da14cebeSEric Cheng extern "C" {
46da14cebeSEric Cheng #endif
47da14cebeSEric Cheng 
48da14cebeSEric Cheng /*
490dc2366fSVenugopal Iyer  * MAC version identifiers. Drivers compiled against the stable V1 version
500dc2366fSVenugopal Iyer  * of the API should register with MAC_VERSION_V1. ON drivers should use
510dc2366fSVenugopal Iyer  * MAC_VERSION. This is used by mac_alloc() mac_register() to
52da14cebeSEric Cheng  * verify that incompatible drivers don't register.
53da14cebeSEric Cheng  */
540dc2366fSVenugopal Iyer #define	MAC_VERSION_V1	0x1
550dc2366fSVenugopal Iyer #define	MAC_VERSION	MAC_VERSION_V1
56da14cebeSEric Cheng 
57da14cebeSEric Cheng /*
580dc2366fSVenugopal Iyer  * Possible values for ETHER_STAT_XCVR_INUSE statistic.
59da14cebeSEric Cheng  */
60da14cebeSEric Cheng 
61da14cebeSEric Cheng #define	XCVR_UNDEFINED		0
62da14cebeSEric Cheng #define	XCVR_NONE		1
63da14cebeSEric Cheng #define	XCVR_10			2
64da14cebeSEric Cheng #define	XCVR_100T4		3
65da14cebeSEric Cheng #define	XCVR_100X		4
66da14cebeSEric Cheng #define	XCVR_100T2		5
67da14cebeSEric Cheng #define	XCVR_1000X		6
68da14cebeSEric Cheng #define	XCVR_1000T		7
69da14cebeSEric Cheng 
70da14cebeSEric Cheng #ifdef	_KERNEL
71da14cebeSEric Cheng 
72da14cebeSEric Cheng /*
73da14cebeSEric Cheng  * Definitions for MAC Drivers Capabilities
74da14cebeSEric Cheng  */
75da14cebeSEric Cheng /*
76da14cebeSEric Cheng  * MAC layer capabilities.  These capabilities are handled by the drivers'
77da14cebeSEric Cheng  * mc_capab_get() callbacks.  Some capabilities require the driver to fill
78da14cebeSEric Cheng  * in a given data structure, and others are simply boolean capabilities.
79da14cebeSEric Cheng  * Note that capability values must be powers of 2 so that consumers and
80da14cebeSEric Cheng  * providers of this interface can keep track of which capabilities they
81da14cebeSEric Cheng  * care about by keeping a bitfield of these things around somewhere.
82da14cebeSEric Cheng  */
83da14cebeSEric Cheng typedef enum {
84da14cebeSEric Cheng 	/*
850dc2366fSVenugopal Iyer 	 * Public Capabilities (MAC_VERSION_V1)
86da14cebeSEric Cheng 	 */
870dc2366fSVenugopal Iyer 	MAC_CAPAB_HCKSUM	= 0x00000001, /* data is a uint32_t */
880dc2366fSVenugopal Iyer 	MAC_CAPAB_LSO		= 0x00000008, /* data is mac_capab_lso_t */
89da14cebeSEric Cheng 
90da14cebeSEric Cheng 	/*
910dc2366fSVenugopal Iyer 	 * Reserved capabilities, do not use
92da14cebeSEric Cheng 	 */
930dc2366fSVenugopal Iyer 	MAC_CAPAB_RESERVED1	= 0x00000002,
940dc2366fSVenugopal Iyer 	MAC_CAPAB_RESERVED2	= 0x00000004,
95da14cebeSEric Cheng 
960dc2366fSVenugopal Iyer 	/*
970dc2366fSVenugopal Iyer 	 * Private driver capabilities
980dc2366fSVenugopal Iyer 	 */
990dc2366fSVenugopal Iyer 	MAC_CAPAB_RINGS		= 0x00000010, /* data is mac_capab_rings_t */
1000dc2366fSVenugopal Iyer 	MAC_CAPAB_SHARES	= 0x00000020, /* data is mac_capab_share_t */
1010dc2366fSVenugopal Iyer 	MAC_CAPAB_MULTIFACTADDR = 0x00000040, /* mac_data_multifactaddr_t */
1020dc2366fSVenugopal Iyer 
1030dc2366fSVenugopal Iyer 	/*
1040dc2366fSVenugopal Iyer 	 * Private driver capabilities for use by the GLDv3 framework only
1050dc2366fSVenugopal Iyer 	 */
1060dc2366fSVenugopal Iyer 	MAC_CAPAB_VNIC		= 0x00010000, /* data is mac_capab_vnic_t */
1070dc2366fSVenugopal Iyer 	MAC_CAPAB_ANCHOR_VNIC	= 0x00020000, /* boolean only, no data */
1080dc2366fSVenugopal Iyer 	MAC_CAPAB_AGGR		= 0x00040000, /* data is mac_capab_aggr_t */
1090dc2366fSVenugopal Iyer 	MAC_CAPAB_NO_NATIVEVLAN	= 0x00080000, /* boolean only, no data */
1100dc2366fSVenugopal Iyer 	MAC_CAPAB_NO_ZCOPY	= 0x00100000, /* boolean only, no data */
1110dc2366fSVenugopal Iyer 	MAC_CAPAB_LEGACY	= 0x00200000, /* data is mac_capab_legacy_t */
11245d3dd98SRobert Mustacchi 	MAC_CAPAB_VRRP		= 0x00400000, /* data is mac_capab_vrrp_t */
11336589d6bSRobert Mustacchi 	MAC_CAPAB_OVERLAY	= 0x00800000, /* boolean only, no data */
11436589d6bSRobert Mustacchi 	MAC_CAPAB_TRANSCEIVER	= 0x01000000, /* mac_capab_transceiver_t */
115c1e9c696SRobert Mustacchi 	MAC_CAPAB_LED		= 0x02000000  /* data is mac_capab_led_t */
116da14cebeSEric Cheng } mac_capab_t;
117da14cebeSEric Cheng 
118da14cebeSEric Cheng /*
119da14cebeSEric Cheng  * LSO capability
120da14cebeSEric Cheng  */
121da14cebeSEric Cheng typedef struct lso_basic_tcp_ipv4_s {
122da14cebeSEric Cheng 	t_uscalar_t	lso_max;		/* maximum payload */
123da14cebeSEric Cheng } lso_basic_tcp_ipv4_t;
124da14cebeSEric Cheng 
12562366fbbSRobert Mustacchi typedef struct lso_basic_tcp_ipv6_s {
12662366fbbSRobert Mustacchi 	t_uscalar_t	lso_max;		/* maximum payload */
12762366fbbSRobert Mustacchi } lso_basic_tcp_ipv6_t;
12862366fbbSRobert Mustacchi 
129da14cebeSEric Cheng /*
130da14cebeSEric Cheng  * Currently supported flags for LSO.
131da14cebeSEric Cheng  */
13262366fbbSRobert Mustacchi #define	LSO_TX_BASIC_TCP_IPV4	0x01		/* TCPv4 LSO capability */
13362366fbbSRobert Mustacchi #define	LSO_TX_BASIC_TCP_IPV6	0x02		/* TCPv6 LSO capability */
134da14cebeSEric Cheng 
135da14cebeSEric Cheng /*
136da14cebeSEric Cheng  * Future LSO capabilities can be added at the end of the mac_capab_lso_t.
137da14cebeSEric Cheng  * When such capability is added to the GLDv3 framework, the size of the
138da14cebeSEric Cheng  * mac_capab_lso_t it allocates and passes to the drivers increases. Older
139da14cebeSEric Cheng  * drivers wil access only the (upper) sections of that structure, that is the
140da14cebeSEric Cheng  * sections carrying the capabilities they understand. This ensures the
141da14cebeSEric Cheng  * interface can be safely extended in a binary compatible way.
142da14cebeSEric Cheng  */
143da14cebeSEric Cheng typedef	struct mac_capab_lso_s {
144da14cebeSEric Cheng 	t_uscalar_t		lso_flags;
145da14cebeSEric Cheng 	lso_basic_tcp_ipv4_t	lso_basic_tcp_ipv4;
14662366fbbSRobert Mustacchi 	lso_basic_tcp_ipv6_t	lso_basic_tcp_ipv6;
147da14cebeSEric Cheng 	/* Add future lso capabilities here */
148da14cebeSEric Cheng } mac_capab_lso_t;
149da14cebeSEric Cheng 
150da14cebeSEric Cheng /*
151da14cebeSEric Cheng  * Multiple Factory MAC Addresses Capability
152da14cebeSEric Cheng  */
153da14cebeSEric Cheng typedef struct mac_capab_multifactaddr_s {
154da14cebeSEric Cheng 	/*
155da14cebeSEric Cheng 	 * Number of factory addresses
156da14cebeSEric Cheng 	 */
157da14cebeSEric Cheng 	uint_t		mcm_naddr;
158da14cebeSEric Cheng 
159da14cebeSEric Cheng 	/*
160da14cebeSEric Cheng 	 * Callbacks to query all the factory addresses.
161da14cebeSEric Cheng 	 */
162da14cebeSEric Cheng 	void		(*mcm_getaddr)(void *, uint_t, uint8_t *);
163da14cebeSEric Cheng } mac_capab_multifactaddr_t;
164da14cebeSEric Cheng 
165da14cebeSEric Cheng /*
1665d460eafSCathy Zhou  * Info and callbacks of legacy devices.
1675d460eafSCathy Zhou  */
1685d460eafSCathy Zhou typedef struct mac_capab_legacy_s {
1695d460eafSCathy Zhou 	/*
1705d460eafSCathy Zhou 	 * Notifications that the legacy device does not support.
1715d460eafSCathy Zhou 	 */
1725d460eafSCathy Zhou 	uint32_t	ml_unsup_note;
1735d460eafSCathy Zhou 	/*
1745d460eafSCathy Zhou 	 * dev_t of the legacy device; can be held to force attach.
1755d460eafSCathy Zhou 	 */
1765d460eafSCathy Zhou 	dev_t		ml_dev;
1775d460eafSCathy Zhou 	boolean_t	(*ml_active_set)(void *);
1785d460eafSCathy Zhou 	void		(*ml_active_clear)(void *);
1795d460eafSCathy Zhou 	int		(*ml_fastpath_disable)(void *);
1805d460eafSCathy Zhou 	void		(*ml_fastpath_enable)(void *);
1815d460eafSCathy Zhou } mac_capab_legacy_t;
1825d460eafSCathy Zhou 
1830dc2366fSVenugopal Iyer typedef struct __mac_prop_info_handle *mac_prop_info_handle_t;
1840dc2366fSVenugopal Iyer 
1855d460eafSCathy Zhou /*
186da14cebeSEric Cheng  * MAC driver entry point types.
187da14cebeSEric Cheng  */
188da14cebeSEric Cheng typedef int		(*mac_getstat_t)(void *, uint_t, uint64_t *);
189da14cebeSEric Cheng typedef	int		(*mac_start_t)(void *);
190da14cebeSEric Cheng typedef void		(*mac_stop_t)(void *);
191da14cebeSEric Cheng typedef int		(*mac_setpromisc_t)(void *, boolean_t);
192da14cebeSEric Cheng typedef int		(*mac_multicst_t)(void *, boolean_t, const uint8_t *);
193da14cebeSEric Cheng typedef int		(*mac_unicst_t)(void *, const uint8_t *);
194da14cebeSEric Cheng typedef void		(*mac_ioctl_t)(void *, queue_t *, mblk_t *);
195da14cebeSEric Cheng typedef void		(*mac_resources_t)(void *);
196da14cebeSEric Cheng typedef mblk_t		*(*mac_tx_t)(void *, mblk_t *);
197da14cebeSEric Cheng typedef	boolean_t	(*mac_getcapab_t)(void *, mac_capab_t, void *);
198da14cebeSEric Cheng typedef	int		(*mac_open_t)(void *);
199da14cebeSEric Cheng typedef void		(*mac_close_t)(void *);
200da14cebeSEric Cheng typedef	int		(*mac_set_prop_t)(void *, const char *, mac_prop_id_t,
201da14cebeSEric Cheng 			    uint_t, const void *);
202da14cebeSEric Cheng typedef	int		(*mac_get_prop_t)(void *, const char *, mac_prop_id_t,
2030dc2366fSVenugopal Iyer 			    uint_t, void *);
2040dc2366fSVenugopal Iyer typedef void		(*mac_prop_info_t)(void *, const char *, mac_prop_id_t,
2050dc2366fSVenugopal Iyer 			    mac_prop_info_handle_t);
206da14cebeSEric Cheng 
207da14cebeSEric Cheng /*
2080dc2366fSVenugopal Iyer  * Driver callbacks. The following capabilities are optional, and if
2090dc2366fSVenugopal Iyer  * implemented by the driver, must have a corresponding MC_ flag set
2100dc2366fSVenugopal Iyer  * in the mc_callbacks field.
2110dc2366fSVenugopal Iyer  *
212da14cebeSEric Cheng  * Any future additions to this list must also be accompanied by an
213da14cebeSEric Cheng  * associated mc_callbacks flag so that the framework can grow without
214da14cebeSEric Cheng  * affecting the binary compatibility of the interface.
215da14cebeSEric Cheng  */
216da14cebeSEric Cheng typedef struct mac_callbacks_s {
217da14cebeSEric Cheng 	uint_t		mc_callbacks;	/* Denotes which callbacks are set */
218da14cebeSEric Cheng 	mac_getstat_t	mc_getstat;	/* Get the value of a statistic */
219da14cebeSEric Cheng 	mac_start_t	mc_start;	/* Start the device */
220da14cebeSEric Cheng 	mac_stop_t	mc_stop;	/* Stop the device */
221da14cebeSEric Cheng 	mac_setpromisc_t mc_setpromisc;	/* Enable or disable promiscuous mode */
222da14cebeSEric Cheng 	mac_multicst_t	mc_multicst;	/* Enable or disable a multicast addr */
223da14cebeSEric Cheng 	mac_unicst_t	mc_unicst;	/* Set the unicast MAC address */
224da14cebeSEric Cheng 	mac_tx_t	mc_tx;		/* Transmit a packet */
2250dc2366fSVenugopal Iyer 	void		*mc_reserved;	/* Reserved, do not use */
226da14cebeSEric Cheng 	mac_ioctl_t	mc_ioctl;	/* Process an unknown ioctl */
227da14cebeSEric Cheng 	mac_getcapab_t	mc_getcapab;	/* Get capability information */
228da14cebeSEric Cheng 	mac_open_t	mc_open;	/* Open the device */
229da14cebeSEric Cheng 	mac_close_t	mc_close;	/* Close the device */
230da14cebeSEric Cheng 	mac_set_prop_t	mc_setprop;
231da14cebeSEric Cheng 	mac_get_prop_t	mc_getprop;
2320dc2366fSVenugopal Iyer 	mac_prop_info_t	mc_propinfo;
233da14cebeSEric Cheng } mac_callbacks_t;
234da14cebeSEric Cheng 
2350dc2366fSVenugopal Iyer /*
2360dc2366fSVenugopal Iyer  * Flags for mc_callbacks.  Requiring drivers to set the flags associated
2370dc2366fSVenugopal Iyer  * with optional callbacks initialized in the structure allows the mac
2380dc2366fSVenugopal Iyer  * module to add optional callbacks in the future without requiring drivers
2390dc2366fSVenugopal Iyer  * to recompile.
2400dc2366fSVenugopal Iyer  */
2410dc2366fSVenugopal Iyer #define	MC_RESERVED	0x0001
2420dc2366fSVenugopal Iyer #define	MC_IOCTL	0x0002
2430dc2366fSVenugopal Iyer #define	MC_GETCAPAB	0x0004
2440dc2366fSVenugopal Iyer #define	MC_OPEN		0x0008
2450dc2366fSVenugopal Iyer #define	MC_CLOSE	0x0010
2460dc2366fSVenugopal Iyer #define	MC_SETPROP	0x0020
2470dc2366fSVenugopal Iyer #define	MC_GETPROP	0x0040
2480dc2366fSVenugopal Iyer #define	MC_PROPINFO	0x0080
2490dc2366fSVenugopal Iyer #define	MC_PROPERTIES	(MC_SETPROP | MC_GETPROP | MC_PROPINFO)
250da14cebeSEric Cheng 
251da14cebeSEric Cheng /*
252da14cebeSEric Cheng  * Virtualization Capabilities
253da14cebeSEric Cheng  */
25445948e49SRyan Zezeski 
255da14cebeSEric Cheng /*
25645948e49SRyan Zezeski  * The type of ring classification. This is used by MAC to determine
25745948e49SRyan Zezeski  * what, if any, processing it has to do upon receiving traffic on a
25845948e49SRyan Zezeski  * particular Rx ring.
25945948e49SRyan Zezeski  *
26045948e49SRyan Zezeski  * MAC_NO_CLASSIFIER
26145948e49SRyan Zezeski  *
26245948e49SRyan Zezeski  *	No classification has been set. No traffic should cross an Rx
26345948e49SRyan Zezeski  *	ring in this state.
26445948e49SRyan Zezeski  *
26545948e49SRyan Zezeski  * MAC_SW_CLASSIFIER
26645948e49SRyan Zezeski  *
26745948e49SRyan Zezeski  *	The driver delivers traffic for multiple clients to this ring.
26845948e49SRyan Zezeski  *	All traffic must be software classified by MAC to guarantee
26945948e49SRyan Zezeski  *	delivery to the correct client. This classification type may
27045948e49SRyan Zezeski  *	be chosen for several reasons.
27145948e49SRyan Zezeski  *
27245948e49SRyan Zezeski  *	o The driver provides only one group and there are multiple
27345948e49SRyan Zezeski  *	  clients using the MAC.
27445948e49SRyan Zezeski  *
27545948e49SRyan Zezeski  *	o The driver provides some hardware filtering but not enough
27645948e49SRyan Zezeski  *	  to fully classify the traffic. E.g., a VLAN VNIC requires L2
27745948e49SRyan Zezeski  *	  unicast address filtering as well as VLAN filtering, but
27845948e49SRyan Zezeski  *	  some drivers may only support the former.
27945948e49SRyan Zezeski  *
28045948e49SRyan Zezeski  *	o The ring belongs to the default group. The default group
28145948e49SRyan Zezeski  *	  acts as a spillover for all clients that can't reserve an
28245948e49SRyan Zezeski  *	  exclusive group. It also handles multicast traffic for all
28345948e49SRyan Zezeski  *	  clients. For these reasons, the default group's rings are
28445948e49SRyan Zezeski  *	  always software classified.
28545948e49SRyan Zezeski  *
28645948e49SRyan Zezeski  * MAC_HW_CLASSIFIER
28745948e49SRyan Zezeski  *
28845948e49SRyan Zezeski  *	The driver delivers traffic for a single MAC client across
28945948e49SRyan Zezeski  *	this ring. With this guarantee, MAC can simply pass the
29045948e49SRyan Zezeski  *	traffic up the stack or even allow polling of the ring.
29145948e49SRyan Zezeski  *
29245948e49SRyan Zezeski  * MAC_PASSTHRU_CLASSIFIER
29345948e49SRyan Zezeski  *
29445948e49SRyan Zezeski  *	The ring is in "passthru" mode. In this mode we bypass all of
29545948e49SRyan Zezeski  *	the typical MAC processing and pass the traffic directly to
29645948e49SRyan Zezeski  *	the mr_pt_fn callback, see mac_rx_common(). This is used in
29745948e49SRyan Zezeski  *	cases where there is another module acting as MAC provider on
29845948e49SRyan Zezeski  *	behalf of the driver. E.g., link aggregations use this mode to
29945948e49SRyan Zezeski  *	take full control of the port's rings; allowing it to enforce
30045948e49SRyan Zezeski  *	LACP protocols and aggregate rings across discrete drivers.
301da14cebeSEric Cheng  */
302da14cebeSEric Cheng typedef enum {
303da14cebeSEric Cheng 	MAC_NO_CLASSIFIER = 0,
304da14cebeSEric Cheng 	MAC_SW_CLASSIFIER,
30545948e49SRyan Zezeski 	MAC_HW_CLASSIFIER,
30645948e49SRyan Zezeski 	MAC_PASSTHRU_CLASSIFIER
307da14cebeSEric Cheng } mac_classify_type_t;
308da14cebeSEric Cheng 
309da14cebeSEric Cheng typedef	void	(*mac_rx_func_t)(void *, mac_resource_handle_t, mblk_t *,
310da14cebeSEric Cheng     boolean_t);
311da14cebeSEric Cheng 
312da14cebeSEric Cheng /*
313da14cebeSEric Cheng  * The virtualization level conveys the extent of the NIC hardware assistance
314da14cebeSEric Cheng  * for traffic steering employed for virtualization:
315da14cebeSEric Cheng  *
316da14cebeSEric Cheng  * MAC_VIRT_NONE:	No assist for v12n.
317da14cebeSEric Cheng  *
318da14cebeSEric Cheng  * MAC_VIRT_LEVEL1:	Multiple Rx rings with MAC address level
319da14cebeSEric Cheng  *			classification between groups of rings.
320da14cebeSEric Cheng  *			Requires the support of the MAC_CAPAB_RINGS
321da14cebeSEric Cheng  *			capability.
322da14cebeSEric Cheng  *
323da14cebeSEric Cheng  * MAC_VIRT_HIO:	Hybrid I/O capable MAC. Require the support
324da14cebeSEric Cheng  *			of the MAC_CAPAB_SHARES capability.
325da14cebeSEric Cheng  */
326da14cebeSEric Cheng #define	MAC_VIRT_NONE		0x0
327da14cebeSEric Cheng #define	MAC_VIRT_LEVEL1		0x1
328da14cebeSEric Cheng #define	MAC_VIRT_HIO		0x2
329da14cebeSEric Cheng 
330da14cebeSEric Cheng typedef enum {
331da14cebeSEric Cheng 	MAC_RING_TYPE_RX = 1,	/* Receive ring */
332da14cebeSEric Cheng 	MAC_RING_TYPE_TX	/* Transmit ring */
333da14cebeSEric Cheng } mac_ring_type_t;
334da14cebeSEric Cheng 
335da14cebeSEric Cheng /*
33684de666eSRyan Zezeski  * The value VLAN_ID_NONE (VID 0) means a client does not have
33784de666eSRyan Zezeski  * membership to any VLAN. However, this statement is true for both
33884de666eSRyan Zezeski  * untagged packets and priority tagged packets leading to confusion
33984de666eSRyan Zezeski  * over what semantic is intended. To the provider, VID 0 is a valid
34084de666eSRyan Zezeski  * VID when priority tagging is in play. To MAC and everything above
34184de666eSRyan Zezeski  * VLAN_ID_NONE almost universally implies untagged traffic. Thus, we
34284de666eSRyan Zezeski  * convert VLAN_ID_NONE to a sentinel value (MAC_VLAN_UNTAGGED) at the
34384de666eSRyan Zezeski  * border between MAC and MAC provider. This informs the provider that
34484de666eSRyan Zezeski  * the client is interested in untagged traffic and the provider
34584de666eSRyan Zezeski  * should set any relevant bits to receive such traffic.
34684de666eSRyan Zezeski  *
34784de666eSRyan Zezeski  * Currently, the API between MAC and the provider passes the VID as a
34884de666eSRyan Zezeski  * unit16_t. In the future this could actually be the entire TCI mask
34984de666eSRyan Zezeski  * (PCP, DEI, and VID). This current scheme is safe in that potential
35084de666eSRyan Zezeski  * future world as well; as 0xFFFF is not a valid TCI (the 0xFFF VID
35184de666eSRyan Zezeski  * is reserved and never transmitted across networks).
35284de666eSRyan Zezeski  */
35384de666eSRyan Zezeski #define	MAC_VLAN_UNTAGGED		UINT16_MAX
35484de666eSRyan Zezeski #define	MAC_VLAN_UNTAGGED_VID(vid)	\
35584de666eSRyan Zezeski 	(((vid) == VLAN_ID_NONE) ? MAC_VLAN_UNTAGGED : (vid))
35684de666eSRyan Zezeski 
35784de666eSRyan Zezeski /*
358da14cebeSEric Cheng  * Grouping type of a ring group
359da14cebeSEric Cheng  *
360da14cebeSEric Cheng  * MAC_GROUP_TYPE_STATIC: The ring group can not be re-grouped.
361da14cebeSEric Cheng  * MAC_GROUP_TYPE_DYNAMIC: The ring group support dynamic re-grouping
362da14cebeSEric Cheng  */
363da14cebeSEric Cheng typedef enum {
364da14cebeSEric Cheng 	MAC_GROUP_TYPE_STATIC = 1,	/* Static ring group */
365da14cebeSEric Cheng 	MAC_GROUP_TYPE_DYNAMIC		/* Dynamic ring group */
366da14cebeSEric Cheng } mac_group_type_t;
367da14cebeSEric Cheng 
368da14cebeSEric Cheng typedef	struct __mac_ring_driver	*mac_ring_driver_t;
369da14cebeSEric Cheng typedef	struct __mac_group_driver	*mac_group_driver_t;
370da14cebeSEric Cheng 
371da14cebeSEric Cheng typedef	struct mac_ring_info_s mac_ring_info_t;
372da14cebeSEric Cheng typedef	struct mac_group_info_s mac_group_info_t;
373da14cebeSEric Cheng 
374da14cebeSEric Cheng typedef void	(*mac_get_ring_t)(void *, mac_ring_type_t, const int, const int,
375da14cebeSEric Cheng     mac_ring_info_t *, mac_ring_handle_t);
376da14cebeSEric Cheng typedef void	(*mac_get_group_t)(void *, mac_ring_type_t, const int,
377da14cebeSEric Cheng     mac_group_info_t *, mac_group_handle_t);
378da14cebeSEric Cheng 
379da14cebeSEric Cheng typedef void	(*mac_group_add_ring_t)(mac_group_driver_t,
380da14cebeSEric Cheng     mac_ring_driver_t, mac_ring_type_t);
381da14cebeSEric Cheng typedef void	(*mac_group_rem_ring_t)(mac_group_driver_t,
382da14cebeSEric Cheng     mac_ring_driver_t, mac_ring_type_t);
383da14cebeSEric Cheng 
384da14cebeSEric Cheng /*
385da14cebeSEric Cheng  * Multiple Rings Capability
386da14cebeSEric Cheng  */
387da14cebeSEric Cheng typedef struct	mac_capab_rings_s {
388da14cebeSEric Cheng 	mac_ring_type_t		mr_type;	/* Ring type: Rx vs Tx */
389da14cebeSEric Cheng 	mac_group_type_t	mr_group_type;	/* Dynamic vs static grouping */
390da14cebeSEric Cheng 	uint_t			mr_rnum;	/* Number of rings */
391da14cebeSEric Cheng 	uint_t			mr_gnum;	/* Number of ring groups */
392da14cebeSEric Cheng 	mac_get_ring_t		mr_rget;	/* Get ring from driver */
393da14cebeSEric Cheng 	mac_get_group_t		mr_gget;	/* Get ring group from driver */
394da14cebeSEric Cheng 	mac_group_add_ring_t	mr_gaddring;	/* Add ring into a group */
395da14cebeSEric Cheng 	mac_group_rem_ring_t	mr_gremring;	/* Remove ring from a group */
396da14cebeSEric Cheng } mac_capab_rings_t;
397da14cebeSEric Cheng 
398da14cebeSEric Cheng /*
399da14cebeSEric Cheng  * Common ring functions and driver interfaces
400da14cebeSEric Cheng  */
401da14cebeSEric Cheng typedef	int	(*mac_ring_start_t)(mac_ring_driver_t, uint64_t);
402da14cebeSEric Cheng typedef	void	(*mac_ring_stop_t)(mac_ring_driver_t);
403da14cebeSEric Cheng 
404da14cebeSEric Cheng typedef	mblk_t	*(*mac_ring_send_t)(void *, mblk_t *);
405da14cebeSEric Cheng typedef	mblk_t	*(*mac_ring_poll_t)(void *, int);
406da14cebeSEric Cheng 
4070dc2366fSVenugopal Iyer typedef int	(*mac_ring_stat_t)(mac_ring_driver_t, uint_t, uint64_t *);
4080dc2366fSVenugopal Iyer 
409da14cebeSEric Cheng typedef struct mac_ring_info_s {
410da14cebeSEric Cheng 	mac_ring_driver_t	mri_driver;
411da14cebeSEric Cheng 	mac_ring_start_t	mri_start;
412da14cebeSEric Cheng 	mac_ring_stop_t		mri_stop;
413da14cebeSEric Cheng 	mac_intr_t		mri_intr;
414da14cebeSEric Cheng 	union {
415da14cebeSEric Cheng 		mac_ring_send_t	send;
416da14cebeSEric Cheng 		mac_ring_poll_t	poll;
417da14cebeSEric Cheng 	} mrfunion;
4180dc2366fSVenugopal Iyer 	mac_ring_stat_t		mri_stat;
41945948e49SRyan Zezeski 
4200dc2366fSVenugopal Iyer 	/*
4210dc2366fSVenugopal Iyer 	 * mri_flags will have some bits set to indicate some special
4220dc2366fSVenugopal Iyer 	 * property/feature of a ring like serialization needed for a
4230dc2366fSVenugopal Iyer 	 * Tx ring or packets should always need enqueuing on Rx side,
4240dc2366fSVenugopal Iyer 	 * etc.
4250dc2366fSVenugopal Iyer 	 */
4260dc2366fSVenugopal Iyer 	uint_t			mri_flags;
427da14cebeSEric Cheng } mac_ring_info_s;
428da14cebeSEric Cheng 
429da14cebeSEric Cheng #define	mri_tx			mrfunion.send
430da14cebeSEric Cheng #define	mri_poll		mrfunion.poll
431da14cebeSEric Cheng 
4320dc2366fSVenugopal Iyer /*
4330dc2366fSVenugopal Iyer  * #defines for mri_flags. The flags are temporary flags that are provided
4340dc2366fSVenugopal Iyer  * only to workaround issues in specific drivers, and they will be
4350dc2366fSVenugopal Iyer  * removed in the future.
43684de666eSRyan Zezeski  *
43784de666eSRyan Zezeski  * These are consumed only by sun4v and neptune (nxge).
4380dc2366fSVenugopal Iyer  */
4390dc2366fSVenugopal Iyer #define	MAC_RING_TX_SERIALIZE		0x1
4400dc2366fSVenugopal Iyer #define	MAC_RING_RX_ENQUEUE		0x2
4410dc2366fSVenugopal Iyer 
442da14cebeSEric Cheng typedef	int	(*mac_group_start_t)(mac_group_driver_t);
443da14cebeSEric Cheng typedef	void	(*mac_group_stop_t)(mac_group_driver_t);
444da14cebeSEric Cheng typedef	int	(*mac_add_mac_addr_t)(void *, const uint8_t *);
445da14cebeSEric Cheng typedef	int	(*mac_rem_mac_addr_t)(void *, const uint8_t *);
44684de666eSRyan Zezeski typedef int	(*mac_add_vlan_filter_t)(mac_group_driver_t, uint16_t);
44784de666eSRyan Zezeski typedef int	(*mac_rem_vlan_filter_t)(mac_group_driver_t, uint16_t);
448da14cebeSEric Cheng 
449da14cebeSEric Cheng struct mac_group_info_s {
450da14cebeSEric Cheng 	mac_group_driver_t	mgi_driver;	/* Driver reference */
451da14cebeSEric Cheng 	mac_group_start_t	mgi_start;	/* Start the group */
452da14cebeSEric Cheng 	mac_group_stop_t	mgi_stop;	/* Stop the group */
453da14cebeSEric Cheng 	uint_t			mgi_count;	/* Count of rings */
454da14cebeSEric Cheng 	mac_intr_t		mgi_intr;	/* Optional per-group intr */
455da14cebeSEric Cheng 
45684de666eSRyan Zezeski 	/* Only used for Rx groups */
457da14cebeSEric Cheng 	mac_add_mac_addr_t	mgi_addmac;	/* Add a MAC address */
458da14cebeSEric Cheng 	mac_rem_mac_addr_t	mgi_remmac;	/* Remove a MAC address */
45984de666eSRyan Zezeski 	mac_add_vlan_filter_t	mgi_addvlan;	/* Add a VLAN filter */
46084de666eSRyan Zezeski 	mac_rem_vlan_filter_t	mgi_remvlan;	/* Remove a VLAN filter */
461da14cebeSEric Cheng };
462da14cebeSEric Cheng 
463da14cebeSEric Cheng /*
464da14cebeSEric Cheng  * Share management functions.
465da14cebeSEric Cheng  */
466da14cebeSEric Cheng typedef uint64_t mac_share_handle_t;
467da14cebeSEric Cheng 
468da14cebeSEric Cheng /*
469da14cebeSEric Cheng  * Allocate and free a share. Returns ENOSPC if all shares have been
470da14cebeSEric Cheng  * previously allocated.
471da14cebeSEric Cheng  */
472da14cebeSEric Cheng typedef int (*mac_alloc_share_t)(void *, mac_share_handle_t *);
473da14cebeSEric Cheng typedef void (*mac_free_share_t)(mac_share_handle_t);
474da14cebeSEric Cheng 
475da14cebeSEric Cheng /*
476da14cebeSEric Cheng  * Bind and unbind a share. Binding a share allows a domain
477da14cebeSEric Cheng  * to have direct access to the groups and rings associated with
478da14cebeSEric Cheng  * that share.
479da14cebeSEric Cheng  */
480da14cebeSEric Cheng typedef int (*mac_bind_share_t)(mac_share_handle_t, uint64_t, uint64_t *);
481da14cebeSEric Cheng typedef void (*mac_unbind_share_t)(mac_share_handle_t);
482da14cebeSEric Cheng 
483da14cebeSEric Cheng /*
484da14cebeSEric Cheng  * Return information on about a share.
485da14cebeSEric Cheng  */
486da14cebeSEric Cheng typedef void (*mac_share_query_t)(mac_share_handle_t, mac_ring_type_t,
487da14cebeSEric Cheng     mac_ring_handle_t *, uint_t *);
488da14cebeSEric Cheng 
489da14cebeSEric Cheng /*
490da14cebeSEric Cheng  * Basic idea, bind previously created ring groups to shares
491da14cebeSEric Cheng  * for them to be exported (or shared) by another domain.
492da14cebeSEric Cheng  * These interfaces bind/unbind the ring group to a share.
493da14cebeSEric Cheng  * The groups and their rings will be shared with the guest
494da14cebeSEric Cheng  * as soon as the share is bound.
495da14cebeSEric Cheng  */
496da14cebeSEric Cheng typedef int (*mac_share_add_group_t)(mac_share_handle_t,
497da14cebeSEric Cheng     mac_group_driver_t);
498da14cebeSEric Cheng typedef int (*mac_share_rem_group_t)(mac_share_handle_t,
499da14cebeSEric Cheng     mac_group_driver_t);
500da14cebeSEric Cheng 
501da14cebeSEric Cheng typedef struct  mac_capab_share_s {
502da14cebeSEric Cheng 	uint_t			ms_snum;	/* Number of shares (vr's) */
503da14cebeSEric Cheng 	void			*ms_handle;	/* Handle to driver. */
504da14cebeSEric Cheng 	mac_alloc_share_t	ms_salloc;	/* Get a share from driver. */
505da14cebeSEric Cheng 	mac_free_share_t	ms_sfree;	/* Return a share to driver. */
506da14cebeSEric Cheng 	mac_share_add_group_t	ms_sadd;	/* Add a group to the share. */
507da14cebeSEric Cheng 	mac_share_rem_group_t	ms_sremove;	/* Remove group from share. */
508da14cebeSEric Cheng 	mac_share_query_t	ms_squery;	/* Query share constraints */
509da14cebeSEric Cheng 	mac_bind_share_t	ms_sbind;	/* Bind a share */
510da14cebeSEric Cheng 	mac_unbind_share_t	ms_sunbind;	/* Unbind a share */
511da14cebeSEric Cheng } mac_capab_share_t;
512da14cebeSEric Cheng 
5131cb875aeSCathy Zhou typedef struct mac_capab_vrrp_s {
5141cb875aeSCathy Zhou 	/* IPv6 or IPv4? */
5151cb875aeSCathy Zhou 	int		mcv_af;
5161cb875aeSCathy Zhou } mac_capab_vrrp_t;
5171cb875aeSCathy Zhou 
518da14cebeSEric Cheng /*
51945d3dd98SRobert Mustacchi  * Transceiver capability
52045d3dd98SRobert Mustacchi  */
52145d3dd98SRobert Mustacchi typedef struct mac_transceiver_info mac_transceiver_info_t;
52245d3dd98SRobert Mustacchi 
52345d3dd98SRobert Mustacchi typedef struct mac_capab_transceiver {
52445d3dd98SRobert Mustacchi 	uint_t	mct_flags;
52545d3dd98SRobert Mustacchi 	uint_t	mct_ntransceivers;
52645d3dd98SRobert Mustacchi 	int	(*mct_info)(void *, uint_t, mac_transceiver_info_t *);
52745d3dd98SRobert Mustacchi 	int	(*mct_read)(void *, uint_t, uint_t, void *, size_t, off_t,
52845d3dd98SRobert Mustacchi 		    size_t *);
52945d3dd98SRobert Mustacchi } mac_capab_transceiver_t;
53045d3dd98SRobert Mustacchi 
53145d3dd98SRobert Mustacchi /*
532c1e9c696SRobert Mustacchi  * LED capability
533c1e9c696SRobert Mustacchi  */
534c1e9c696SRobert Mustacchi typedef struct mac_capab_led {
535c1e9c696SRobert Mustacchi 	uint_t		mcl_flags;
536c1e9c696SRobert Mustacchi 	mac_led_mode_t	mcl_modes;
537c1e9c696SRobert Mustacchi 	int		(*mcl_set)(void *, mac_led_mode_t, uint_t);
538c1e9c696SRobert Mustacchi } mac_capab_led_t;
539c1e9c696SRobert Mustacchi 
540c1e9c696SRobert Mustacchi /*
541da14cebeSEric Cheng  * MAC registration interface
542da14cebeSEric Cheng  */
543da14cebeSEric Cheng typedef struct mac_register_s {
544da14cebeSEric Cheng 	uint_t			m_version;	/* set by mac_alloc() */
545da14cebeSEric Cheng 	const char		*m_type_ident;
546da14cebeSEric Cheng 	void			*m_driver;	/* Driver private data */
547da14cebeSEric Cheng 	dev_info_t		*m_dip;
548da14cebeSEric Cheng 	uint_t			m_instance;
549da14cebeSEric Cheng 	uint8_t			*m_src_addr;
550da14cebeSEric Cheng 	uint8_t			*m_dst_addr;
551da14cebeSEric Cheng 	mac_callbacks_t		*m_callbacks;
552da14cebeSEric Cheng 	uint_t			m_min_sdu;
553da14cebeSEric Cheng 	uint_t			m_max_sdu;
554da14cebeSEric Cheng 	void			*m_pdata;
555da14cebeSEric Cheng 	size_t			m_pdata_size;
5560dc2366fSVenugopal Iyer 	char			**m_priv_props;
557da14cebeSEric Cheng 	uint32_t		m_margin;
558da14cebeSEric Cheng 	uint32_t		m_v12n;		/* Virtualization level */
5591eee170aSErik Nordmark 	uint_t			m_multicast_sdu;
560da14cebeSEric Cheng } mac_register_t;
561da14cebeSEric Cheng 
562da14cebeSEric Cheng /*
563da14cebeSEric Cheng  * Driver interface functions.
564da14cebeSEric Cheng  */
56589c6130dSSowmini Varadhan extern mac_protect_t		*mac_protect_get(mac_handle_t);
566da14cebeSEric Cheng extern void			mac_sdu_get(mac_handle_t, uint_t *, uint_t *);
5671eee170aSErik Nordmark extern void			mac_sdu_get2(mac_handle_t, uint_t *, uint_t *,
5681eee170aSErik Nordmark 				    uint_t *);
569da14cebeSEric Cheng extern int			mac_maxsdu_update(mac_handle_t, uint_t);
5701eee170aSErik Nordmark extern int			mac_maxsdu_update2(mac_handle_t, uint_t,
5711eee170aSErik Nordmark 				    uint_t);
572da14cebeSEric Cheng 
573da14cebeSEric Cheng extern mac_register_t		*mac_alloc(uint_t);
574da14cebeSEric Cheng extern void			mac_free(mac_register_t *);
575da14cebeSEric Cheng extern int			mac_register(mac_register_t *, mac_handle_t *);
576da14cebeSEric Cheng extern int			mac_disable_nowait(mac_handle_t);
577da14cebeSEric Cheng extern int			mac_disable(mac_handle_t);
578da14cebeSEric Cheng extern int			mac_unregister(mac_handle_t);
579da14cebeSEric Cheng extern void			mac_rx(mac_handle_t, mac_resource_handle_t,
580da14cebeSEric Cheng 				    mblk_t *);
581da14cebeSEric Cheng extern void			mac_rx_ring(mac_handle_t, mac_ring_handle_t,
582da14cebeSEric Cheng 				    mblk_t *, uint64_t);
583da14cebeSEric Cheng extern void			mac_link_update(mac_handle_t, link_state_t);
5844eaa4710SRishi Srivatsavai extern void			mac_link_redo(mac_handle_t, link_state_t);
585da14cebeSEric Cheng extern void			mac_unicst_update(mac_handle_t,
586da14cebeSEric Cheng 				    const uint8_t *);
5872b24ab6bSSebastien Roy extern void			mac_dst_update(mac_handle_t, const uint8_t *);
588da14cebeSEric Cheng extern void			mac_tx_update(mac_handle_t);
589da14cebeSEric Cheng extern void			mac_tx_ring_update(mac_handle_t,
590da14cebeSEric Cheng 				    mac_ring_handle_t);
591da14cebeSEric Cheng extern void			mac_capab_update(mac_handle_t);
592da14cebeSEric Cheng extern int			mac_pdata_update(mac_handle_t, void *,
593da14cebeSEric Cheng 				    size_t);
594da14cebeSEric Cheng extern void			mac_multicast_refresh(mac_handle_t,
595da14cebeSEric Cheng 				    mac_multicst_t, void *, boolean_t);
596da14cebeSEric Cheng extern void			mac_unicst_refresh(mac_handle_t, mac_unicst_t,
597da14cebeSEric Cheng 				    void *);
598da14cebeSEric Cheng extern void			mac_promisc_refresh(mac_handle_t,
599da14cebeSEric Cheng 				    mac_setpromisc_t, void *);
600da14cebeSEric Cheng extern boolean_t		mac_margin_update(mac_handle_t, uint32_t);
601da14cebeSEric Cheng extern void			mac_margin_get(mac_handle_t, uint32_t *);
602da14cebeSEric Cheng extern int			mac_margin_remove(mac_handle_t, uint32_t);
603da14cebeSEric Cheng extern int			mac_margin_add(mac_handle_t, uint32_t *,
604da14cebeSEric Cheng 				    boolean_t);
605da14cebeSEric Cheng extern void			mac_init_ops(struct dev_ops *, const char *);
606da14cebeSEric Cheng extern void			mac_fini_ops(struct dev_ops *);
60761af1958SGarrett D'Amore extern int			mac_devt_to_instance(dev_t);
608*86e5bb79SLuqman Aden extern int			mac_getinfo(dev_info_t *, ddi_info_cmd_t,
609*86e5bb79SLuqman Aden 				    void *, void **);
61061af1958SGarrett D'Amore extern minor_t			mac_private_minor(void);
6110dc2366fSVenugopal Iyer extern void			mac_ring_intr_set(mac_ring_handle_t,
6120dc2366fSVenugopal Iyer 				    ddi_intr_handle_t);
6130dc2366fSVenugopal Iyer 
614da14cebeSEric Cheng 
615da14cebeSEric Cheng extern mactype_register_t	*mactype_alloc(uint_t);
616da14cebeSEric Cheng extern void			mactype_free(mactype_register_t *);
617da14cebeSEric Cheng extern int			mactype_register(mactype_register_t *);
618da14cebeSEric Cheng extern int			mactype_unregister(const char *);
619da14cebeSEric Cheng 
620da14cebeSEric Cheng extern boolean_t		mac_unicst_verify(mac_handle_t,
621da14cebeSEric Cheng 				    const uint8_t *, uint_t);
622da14cebeSEric Cheng 
623da14cebeSEric Cheng extern int			mac_group_add_ring(mac_group_handle_t, int);
624da14cebeSEric Cheng extern void			mac_group_rem_ring(mac_group_handle_t,
625da14cebeSEric Cheng 				    mac_ring_handle_t);
6260dc2366fSVenugopal Iyer extern mac_ring_handle_t	mac_find_ring(mac_group_handle_t, int);
6270dc2366fSVenugopal Iyer 
6280dc2366fSVenugopal Iyer extern void			mac_prop_info_set_default_uint8(
6290dc2366fSVenugopal Iyer 				    mac_prop_info_handle_t, uint8_t);
6300dc2366fSVenugopal Iyer extern void			mac_prop_info_set_default_str(
6310dc2366fSVenugopal Iyer 				    mac_prop_info_handle_t, const char *);
6320dc2366fSVenugopal Iyer extern void			mac_prop_info_set_default_uint64(
6330dc2366fSVenugopal Iyer 				    mac_prop_info_handle_t, uint64_t);
6340dc2366fSVenugopal Iyer extern void			mac_prop_info_set_default_uint32(
6350dc2366fSVenugopal Iyer 				    mac_prop_info_handle_t, uint32_t);
6360dc2366fSVenugopal Iyer extern void			mac_prop_info_set_default_link_flowctrl(
6370dc2366fSVenugopal Iyer 				    mac_prop_info_handle_t, link_flowctrl_t);
638d77e6e0fSPaul Winder extern void			mac_prop_info_set_default_fec(
639d77e6e0fSPaul Winder 				    mac_prop_info_handle_t, link_fec_t);
6400dc2366fSVenugopal Iyer extern void			mac_prop_info_set_range_uint32(
6410dc2366fSVenugopal Iyer 				    mac_prop_info_handle_t,
6420dc2366fSVenugopal Iyer 				    uint32_t, uint32_t);
6430dc2366fSVenugopal Iyer extern void			mac_prop_info_set_perm(mac_prop_info_handle_t,
6440dc2366fSVenugopal Iyer 				    uint8_t);
6450dc2366fSVenugopal Iyer 
646ec71f88eSPatrick Mooney extern void			mac_hcksum_get(const mblk_t *, uint32_t *,
6470dc2366fSVenugopal Iyer 				    uint32_t *, uint32_t *, uint32_t *,
6480dc2366fSVenugopal Iyer 				    uint32_t *);
6490dc2366fSVenugopal Iyer extern void			mac_hcksum_set(mblk_t *, uint32_t, uint32_t,
6500dc2366fSVenugopal Iyer 				    uint32_t, uint32_t, uint32_t);
651ec71f88eSPatrick Mooney extern void			mac_hcksum_clone(const mblk_t *, mblk_t *);
6520dc2366fSVenugopal Iyer 
6530dc2366fSVenugopal Iyer extern void			mac_lso_get(mblk_t *, uint32_t *, uint32_t *);
654da14cebeSEric Cheng 
65545d3dd98SRobert Mustacchi extern void			mac_transceiver_info_set_present(
65645d3dd98SRobert Mustacchi 				    mac_transceiver_info_t *,
65745d3dd98SRobert Mustacchi 				    boolean_t);
65845d3dd98SRobert Mustacchi extern void			mac_transceiver_info_set_usable(
65945d3dd98SRobert Mustacchi 				    mac_transceiver_info_t *,
66045d3dd98SRobert Mustacchi 				    boolean_t);
66145d3dd98SRobert Mustacchi 
662d240edafSRobert Mustacchi /*
663d240edafSRobert Mustacchi  * This represents a provisional set of currently illumos-private APIs to get
664d240edafSRobert Mustacchi  * information about a mblk_t chain's type. This is an evolving interface.
665d240edafSRobert Mustacchi  */
666d240edafSRobert Mustacchi typedef enum mac_ether_offload_flags {
667d240edafSRobert Mustacchi 	MEOI_L2INFO_SET		= 1 << 0,
668d240edafSRobert Mustacchi 	MEOI_VLAN_TAGGED	= 1 << 1,
669d240edafSRobert Mustacchi 	MEOI_L3INFO_SET		= 1 << 2,
670d240edafSRobert Mustacchi 	MEOI_L4INFO_SET		= 1 << 3
671d240edafSRobert Mustacchi } mac_ether_offload_flags_t;
672d240edafSRobert Mustacchi 
673d240edafSRobert Mustacchi typedef struct mac_ether_offload_info {
674d240edafSRobert Mustacchi 	mac_ether_offload_flags_t	meoi_flags;	/* What's valid? */
675d240edafSRobert Mustacchi 	size_t		meoi_len;	/* Total message length */
676d240edafSRobert Mustacchi 	uint8_t		meoi_l2hlen;	/* How long is the Ethernet header? */
677d240edafSRobert Mustacchi 	uint16_t	meoi_l3proto;	/* What's the Ethertype */
678d240edafSRobert Mustacchi 	uint8_t		meoi_l3hlen;	/* How long is the header? */
679d240edafSRobert Mustacchi 	uint8_t		meoi_l4proto;	/* What is the payload type? */
680d240edafSRobert Mustacchi 	uint8_t		meoi_l4hlen;	/* How long is the L4 header */
681d240edafSRobert Mustacchi } mac_ether_offload_info_t;
682d240edafSRobert Mustacchi 
683d240edafSRobert Mustacchi extern int			mac_ether_offload_info(mblk_t *,
684d240edafSRobert Mustacchi 				    mac_ether_offload_info_t *);
685d240edafSRobert Mustacchi 
686d240edafSRobert Mustacchi 
687da14cebeSEric Cheng #endif	/* _KERNEL */
688da14cebeSEric Cheng 
689da14cebeSEric Cheng #ifdef	__cplusplus
690da14cebeSEric Cheng }
691da14cebeSEric Cheng #endif
692da14cebeSEric Cheng 
693da14cebeSEric Cheng #endif /* _SYS_MAC_PROVIDER_H */
694