xref: /onnv-gate/usr/src/uts/common/sys/mac.h (revision 2311:2d86e52dcdf0)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*2311Sseb  * Common Development and Distribution License (the "License").
6*2311Sseb  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*2311Sseb  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_MAC_H
270Sstevel@tonic-gate #define	_SYS_MAC_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/ddi.h>
320Sstevel@tonic-gate #include <sys/sunddi.h>
330Sstevel@tonic-gate #include <sys/stream.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate /*
360Sstevel@tonic-gate  * MAC Services Module
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifdef	__cplusplus
400Sstevel@tonic-gate extern "C" {
410Sstevel@tonic-gate #endif
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate  * MAC Information (text emitted by modinfo(1m))
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate #define	MAC_INFO	"MAC Services v%I%"
470Sstevel@tonic-gate 
480Sstevel@tonic-gate /*
49*2311Sseb  * MAC version identifier.  This is used by mac_alloc() mac_register() to
50*2311Sseb  * verify that incompatible drivers don't register.
51*2311Sseb  */
52*2311Sseb #define	MAC_VERSION	0x1
53*2311Sseb 
54*2311Sseb /*
55*2311Sseb  * MAC-Type version identifier.  This is used by mactype_alloc() and
56*2311Sseb  * mactype_register() to verify that incompatible MAC-Type plugins don't
57*2311Sseb  * register.
58*2311Sseb  */
59*2311Sseb #define	MACTYPE_VERSION	0x1
60*2311Sseb 
61*2311Sseb /*
620Sstevel@tonic-gate  * Statistics
630Sstevel@tonic-gate  */
640Sstevel@tonic-gate 
650Sstevel@tonic-gate #define	XCVR_UNDEFINED		0
660Sstevel@tonic-gate #define	XCVR_NONE		1
670Sstevel@tonic-gate #define	XCVR_10			2
680Sstevel@tonic-gate #define	XCVR_100T4		3
690Sstevel@tonic-gate #define	XCVR_100X		4
700Sstevel@tonic-gate #define	XCVR_100T2		5
710Sstevel@tonic-gate #define	XCVR_1000X		6
720Sstevel@tonic-gate #define	XCVR_1000T		7
730Sstevel@tonic-gate 
740Sstevel@tonic-gate typedef enum {
750Sstevel@tonic-gate 	LINK_STATE_UNKNOWN = -1,
760Sstevel@tonic-gate 	LINK_STATE_DOWN,
770Sstevel@tonic-gate 	LINK_STATE_UP
780Sstevel@tonic-gate } link_state_t;
790Sstevel@tonic-gate 
800Sstevel@tonic-gate typedef enum {
810Sstevel@tonic-gate 	LINK_DUPLEX_UNKNOWN = 0,
820Sstevel@tonic-gate 	LINK_DUPLEX_HALF,
830Sstevel@tonic-gate 	LINK_DUPLEX_FULL
840Sstevel@tonic-gate } link_duplex_t;
850Sstevel@tonic-gate 
860Sstevel@tonic-gate #ifdef	_KERNEL
870Sstevel@tonic-gate 
88*2311Sseb typedef struct mac_stat_info_s {
89*2311Sseb 	uint_t		msi_stat;
90*2311Sseb 	char		*msi_name;
91*2311Sseb 	uint_t		msi_type;	/* as defined in kstat_named_init(9F) */
92*2311Sseb 	uint64_t	msi_default;
93*2311Sseb } mac_stat_info_t;
94*2311Sseb 
95*2311Sseb /*
96*2311Sseb  * There are three ranges of statistics values.  0 to 1 - MAC_STAT_MIN are
97*2311Sseb  * interface statistics maintained by the mac module.  MAC_STAT_MIN to 1 -
98*2311Sseb  * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and
99*2311Sseb  * maintained by each driver.  MACTYPE_STAT_MIN and above are statistics
100*2311Sseb  * defined by MAC-Type plugins and maintained by each driver.
101*2311Sseb  */
102*2311Sseb #define	MAC_STAT_MIN		1000
103*2311Sseb #define	MACTYPE_STAT_MIN	2000
104*2311Sseb 
105*2311Sseb #define	IS_MAC_STAT(stat)	\
106*2311Sseb 	(stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN)
107*2311Sseb #define	IS_MACTYPE_STAT(stat)	(stat >= MACTYPE_STAT_MIN)
108*2311Sseb 
109*2311Sseb enum mac_driver_stat {
110*2311Sseb 	/* MIB-II stats (RFC 1213 and RFC 1573) */
111*2311Sseb 	MAC_STAT_IFSPEED = MAC_STAT_MIN,
1120Sstevel@tonic-gate 	MAC_STAT_MULTIRCV,
1130Sstevel@tonic-gate 	MAC_STAT_BRDCSTRCV,
1140Sstevel@tonic-gate 	MAC_STAT_MULTIXMT,
1150Sstevel@tonic-gate 	MAC_STAT_BRDCSTXMT,
1160Sstevel@tonic-gate 	MAC_STAT_NORCVBUF,
1170Sstevel@tonic-gate 	MAC_STAT_IERRORS,
1180Sstevel@tonic-gate 	MAC_STAT_UNKNOWNS,
1190Sstevel@tonic-gate 	MAC_STAT_NOXMTBUF,
1200Sstevel@tonic-gate 	MAC_STAT_OERRORS,
1210Sstevel@tonic-gate 	MAC_STAT_COLLISIONS,
1220Sstevel@tonic-gate 	MAC_STAT_RBYTES,
1230Sstevel@tonic-gate 	MAC_STAT_IPACKETS,
1240Sstevel@tonic-gate 	MAC_STAT_OBYTES,
125*2311Sseb 	MAC_STAT_OPACKETS
126*2311Sseb };
1270Sstevel@tonic-gate 
128*2311Sseb #define	MAC_NSTAT	(MAC_STAT_OPACKETS - MAC_STAT_IFSPEED + 1)
1290Sstevel@tonic-gate 
130*2311Sseb #define	MAC_STAT_ISACOUNTER(_stat) (		\
131*2311Sseb 	    (_stat) == MAC_STAT_MULTIRCV ||	\
132*2311Sseb 	    (_stat) == MAC_STAT_BRDCSTRCV ||	\
133*2311Sseb 	    (_stat) == MAC_STAT_MULTIXMT ||	\
134*2311Sseb 	    (_stat) == MAC_STAT_BRDCSTXMT ||	\
135*2311Sseb 	    (_stat) == MAC_STAT_NORCVBUF ||	\
136*2311Sseb 	    (_stat) == MAC_STAT_IERRORS ||	\
137*2311Sseb 	    (_stat) == MAC_STAT_UNKNOWNS ||	\
138*2311Sseb 	    (_stat) == MAC_STAT_NOXMTBUF ||	\
139*2311Sseb 	    (_stat) == MAC_STAT_OERRORS ||	\
140*2311Sseb 	    (_stat) == MAC_STAT_COLLISIONS ||	\
141*2311Sseb 	    (_stat) == MAC_STAT_RBYTES ||	\
142*2311Sseb 	    (_stat) == MAC_STAT_IPACKETS ||	\
143*2311Sseb 	    (_stat) == MAC_STAT_OBYTES ||	\
144*2311Sseb 	    (_stat) == MAC_STAT_OPACKETS)
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate /*
1470Sstevel@tonic-gate  * Maximum MAC address length
1480Sstevel@tonic-gate  */
149*2311Sseb #define	MAXMACADDRLEN	20
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate /*
1520Sstevel@tonic-gate  * Immutable information. (This may not be modified after registration).
1530Sstevel@tonic-gate  */
1540Sstevel@tonic-gate typedef struct mac_info_s {
1550Sstevel@tonic-gate 	uint_t		mi_media;
1560Sstevel@tonic-gate 	uint_t		mi_sdu_min;
1570Sstevel@tonic-gate 	uint_t		mi_sdu_max;
1580Sstevel@tonic-gate 	uint_t		mi_addr_length;
159*2311Sseb 	uint8_t		*mi_unicst_addr;
160*2311Sseb 	uint8_t		*mi_brdcst_addr;
1610Sstevel@tonic-gate } mac_info_t;
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate /*
164*2311Sseb  * MAC layer capabilities.  These capabilities are handled by the drivers'
165*2311Sseb  * mc_capab_get() callbacks.  Some capabilities require the driver to fill
166*2311Sseb  * in a given data structure, and others are simply boolean capabilities.
167*2311Sseb  * Note that capability values must be powers of 2 so that consumers and
168*2311Sseb  * providers of this interface can keep track of which capabilities they
169*2311Sseb  * care about by keeping a bitfield of these things around somewhere.
1700Sstevel@tonic-gate  */
171*2311Sseb typedef enum {
172*2311Sseb 	MAC_CAPAB_HCKSUM	= 0x01,	/* data is a uint32_t for the txflags */
173*2311Sseb 	MAC_CAPAB_POLL		= 0x02	/* boolean only, no data */
174*2311Sseb 	/* add new capabilities here */
175*2311Sseb } mac_capab_t;
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate /*
1780Sstevel@tonic-gate  * MAC driver entry point types.
1790Sstevel@tonic-gate  */
180*2311Sseb typedef int		(*mac_getstat_t)(void *, uint_t, uint64_t *);
1810Sstevel@tonic-gate typedef	int		(*mac_start_t)(void *);
1820Sstevel@tonic-gate typedef void		(*mac_stop_t)(void *);
183*2311Sseb typedef int		(*mac_setpromisc_t)(void *, boolean_t);
1840Sstevel@tonic-gate typedef int		(*mac_multicst_t)(void *, boolean_t, const uint8_t *);
1850Sstevel@tonic-gate typedef int		(*mac_unicst_t)(void *, const uint8_t *);
186*2311Sseb typedef void		(*mac_ioctl_t)(void *, queue_t *, mblk_t *);
1870Sstevel@tonic-gate typedef void		(*mac_resources_t)(void *);
1880Sstevel@tonic-gate typedef mblk_t		*(*mac_tx_t)(void *, mblk_t *);
189*2311Sseb typedef	boolean_t	(*mac_getcapab_t)(void *, mac_capab_t, void *);
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate /*
192*2311Sseb  * Drivers must set all of these callbacks except for mc_resources,
193*2311Sseb  * mc_ioctl, and mc_getcapab, which are optional.  If any of these optional
194*2311Sseb  * callbacks are set, their appropriate flags must be set in mc_callbacks.
195*2311Sseb  * Any future additions to this list must also be accompanied by an
196*2311Sseb  * associated mc_callbacks flag so that the framework can grow without
197*2311Sseb  * affecting the binary compatibility of the interface.
1980Sstevel@tonic-gate  */
199*2311Sseb typedef struct mac_callbacks_s {
200*2311Sseb 	uint_t		mc_callbacks;	/* Denotes which callbacks are set */
201*2311Sseb 	mac_getstat_t	mc_getstat;	/* Get the value of a statistic */
202*2311Sseb 	mac_start_t	mc_start;	/* Start the device */
203*2311Sseb 	mac_stop_t	mc_stop;	/* Stop the device */
204*2311Sseb 	mac_setpromisc_t mc_setpromisc;	/* Enable or disable promiscuous mode */
205*2311Sseb 	mac_multicst_t	mc_multicst;	/* Enable or disable a multicast addr */
206*2311Sseb 	mac_unicst_t	mc_unicst;	/* Set the unicast MAC address */
207*2311Sseb 	mac_tx_t	mc_tx;		/* Transmit a packet */
208*2311Sseb 	mac_resources_t	mc_resources;	/* Get the device resources */
209*2311Sseb 	mac_ioctl_t	mc_ioctl;	/* Process an unknown ioctl */
210*2311Sseb 	mac_getcapab_t	mc_getcapab;	/* Get capability information */
211*2311Sseb } mac_callbacks_t;
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate /*
214*2311Sseb  * Flags for mc_callbacks.  Requiring drivers to set the flags associated
215*2311Sseb  * with optional callbacks initialized in the structure allows the mac
216*2311Sseb  * module to add optional callbacks in the future without requiring drivers
217*2311Sseb  * to recompile.
2180Sstevel@tonic-gate  */
219*2311Sseb #define	MC_RESOURCES	0x001
220*2311Sseb #define	MC_IOCTL	0x002
221*2311Sseb #define	MC_GETCAPAB	0x004
222*2311Sseb 
223*2311Sseb typedef struct mac_register_s {
224*2311Sseb 	uint_t		m_version;	/* set by mac_alloc() */
225*2311Sseb 	const char	*m_type_ident;
226*2311Sseb 	void		*m_driver;	/* Driver private data */
227*2311Sseb 	dev_info_t	*m_dip;
228*2311Sseb 	uint_t		m_instance;
229*2311Sseb 	uint8_t		*m_src_addr;
230*2311Sseb 	uint8_t		*m_dst_addr;
231*2311Sseb 	mac_callbacks_t	*m_callbacks;
232*2311Sseb 	uint_t		m_min_sdu;
233*2311Sseb 	uint_t		m_max_sdu;
234*2311Sseb 	void		*m_pdata;
235*2311Sseb 	size_t		m_pdata_size;
236*2311Sseb } mac_register_t;
2370Sstevel@tonic-gate 
2380Sstevel@tonic-gate /*
2390Sstevel@tonic-gate  * Opaque handle types.
2400Sstevel@tonic-gate  */
241*2311Sseb typedef	struct mac_t			*mac_handle_t;
2420Sstevel@tonic-gate typedef struct __mac_notify_handle	*mac_notify_handle_t;
2430Sstevel@tonic-gate typedef struct __mac_rx_handle		*mac_rx_handle_t;
2440Sstevel@tonic-gate typedef struct __mac_txloop_handle	*mac_txloop_handle_t;
2450Sstevel@tonic-gate typedef struct __mac_resource_handle	*mac_resource_handle_t;
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate /*
2480Sstevel@tonic-gate  * MAC interface callback types.
2490Sstevel@tonic-gate  */
2500Sstevel@tonic-gate typedef enum {
2510Sstevel@tonic-gate 	MAC_NOTE_LINK,
2520Sstevel@tonic-gate 	MAC_NOTE_PROMISC,
2530Sstevel@tonic-gate 	MAC_NOTE_UNICST,
2540Sstevel@tonic-gate 	MAC_NOTE_TX,
2550Sstevel@tonic-gate 	MAC_NOTE_RESOURCE,
2560Sstevel@tonic-gate 	MAC_NOTE_DEVPROMISC,
257*2311Sseb 	MAC_NOTE_FASTPATH_FLUSH,
2580Sstevel@tonic-gate 	MAC_NNOTE	/* must be the last entry */
2590Sstevel@tonic-gate } mac_notify_type_t;
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate typedef void		(*mac_notify_t)(void *, mac_notify_type_t);
2620Sstevel@tonic-gate typedef void		(*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *);
2630Sstevel@tonic-gate typedef void		(*mac_txloop_t)(void *, mblk_t *);
2640Sstevel@tonic-gate typedef void		(*mac_blank_t)(void *, time_t, uint_t);
2650Sstevel@tonic-gate 
2660Sstevel@tonic-gate /*
2670Sstevel@tonic-gate  * MAC promiscuous types
2680Sstevel@tonic-gate  */
2690Sstevel@tonic-gate typedef enum {
2700Sstevel@tonic-gate 	MAC_PROMISC = 0x01,		/* MAC instance is promiscuous */
2710Sstevel@tonic-gate 	MAC_DEVPROMISC = 0x02		/* Device is promiscuous */
2720Sstevel@tonic-gate } mac_promisc_type_t;
2730Sstevel@tonic-gate 
2740Sstevel@tonic-gate /*
2750Sstevel@tonic-gate  * MAC resource types
2760Sstevel@tonic-gate  */
2770Sstevel@tonic-gate typedef enum {
2780Sstevel@tonic-gate 	MAC_RX_FIFO = 1
2790Sstevel@tonic-gate } mac_resource_type_t;
2800Sstevel@tonic-gate 
2810Sstevel@tonic-gate typedef struct mac_rx_fifo_s {
2820Sstevel@tonic-gate 	mac_resource_type_t	mrf_type;	/* MAC_RX_FIFO */
2830Sstevel@tonic-gate 	mac_blank_t		mrf_blank;
2840Sstevel@tonic-gate 	void			*mrf_arg;
2850Sstevel@tonic-gate 	time_t			mrf_normal_blank_time;
2860Sstevel@tonic-gate 	uint_t			mrf_normal_pkt_count;
2870Sstevel@tonic-gate } mac_rx_fifo_t;
2880Sstevel@tonic-gate 
28956Smeem typedef struct mac_txinfo_s {
29056Smeem 	mac_tx_t		mt_fn;
29156Smeem 	void			*mt_arg;
29256Smeem } mac_txinfo_t;
29356Smeem 
2940Sstevel@tonic-gate typedef union mac_resource_u {
2950Sstevel@tonic-gate 	mac_resource_type_t	mr_type;
2960Sstevel@tonic-gate 	mac_rx_fifo_t		mr_fifo;
2970Sstevel@tonic-gate } mac_resource_t;
2980Sstevel@tonic-gate 
2990Sstevel@tonic-gate typedef mac_resource_handle_t	(*mac_resource_add_t)(void *, mac_resource_t *);
3000Sstevel@tonic-gate 
301*2311Sseb typedef enum {
302*2311Sseb 	MAC_ADDRTYPE_UNICAST,
303*2311Sseb 	MAC_ADDRTYPE_MULTICAST,
304*2311Sseb 	MAC_ADDRTYPE_BROADCAST
305*2311Sseb } mac_addrtype_t;
306*2311Sseb 
307*2311Sseb typedef struct mac_header_info_s {
308*2311Sseb 	size_t		mhi_hdrsize;
309*2311Sseb 	size_t		mhi_pktsize;
310*2311Sseb 	const uint8_t	*mhi_daddr;
311*2311Sseb 	const uint8_t	*mhi_saddr;
312*2311Sseb 	uint32_t	mhi_origsap;
313*2311Sseb 	uint32_t	mhi_bindsap;
314*2311Sseb 	mac_addrtype_t	mhi_dsttype;
315*2311Sseb } mac_header_info_t;
316*2311Sseb 
317*2311Sseb /*
318*2311Sseb  * MAC-Type plugin interfaces
319*2311Sseb  */
320*2311Sseb 
321*2311Sseb typedef int		(*mtops_addr_verify_t)(const void *, void *);
322*2311Sseb typedef boolean_t	(*mtops_sap_verify_t)(uint32_t, uint32_t *, void *);
323*2311Sseb typedef mblk_t		*(*mtops_header_t)(const void *, const void *,
324*2311Sseb     uint32_t, void *, mblk_t *, size_t);
325*2311Sseb typedef int		(*mtops_header_info_t)(mblk_t *, void *,
326*2311Sseb     mac_header_info_t *);
327*2311Sseb typedef boolean_t	(*mtops_pdata_verify_t)(void *, size_t);
328*2311Sseb typedef	mblk_t		*(*mtops_header_modify_t)(mblk_t *, void *);
329*2311Sseb 
330*2311Sseb typedef struct mactype_ops_s {
331*2311Sseb 	uint_t			mtops_ops;
332*2311Sseb 	/*
333*2311Sseb 	 * mtops_unicst_verify() returns 0 if the given address is a valid
334*2311Sseb 	 * unicast address, or a non-zero errno otherwise.
335*2311Sseb 	 */
336*2311Sseb 	mtops_addr_verify_t	mtops_unicst_verify;
337*2311Sseb 	/*
338*2311Sseb 	 * mtops_multicst_verify() returns 0 if the given address is a
339*2311Sseb 	 * valid multicast address, or a non-zero errno otherwise.  If the
340*2311Sseb 	 * media doesn't support multicast, ENOTSUP should be returned (for
341*2311Sseb 	 * example).
342*2311Sseb 	 */
343*2311Sseb 	mtops_addr_verify_t	mtops_multicst_verify;
344*2311Sseb 	/*
345*2311Sseb 	 * mtops_sap_verify() returns B_TRUE if the given SAP is a valid
346*2311Sseb 	 * SAP value, or B_FALSE otherwise.
347*2311Sseb 	 */
348*2311Sseb 	mtops_sap_verify_t	mtops_sap_verify;
349*2311Sseb 	/*
350*2311Sseb 	 * mtops_header() is used to allocate and construct a MAC header.
351*2311Sseb 	 */
352*2311Sseb 	mtops_header_t		mtops_header;
353*2311Sseb 	/*
354*2311Sseb 	 * mtops_header_info() is used to gather information on a given MAC
355*2311Sseb 	 * header.
356*2311Sseb 	 */
357*2311Sseb 	mtops_header_info_t	mtops_header_info;
358*2311Sseb 	/*
359*2311Sseb 	 * mtops_pdata_verify() is used to verify the validity of MAC
360*2311Sseb 	 * plugin data.  It is called by mac_register() if the driver has
361*2311Sseb 	 * supplied MAC plugin data, and also by mac_pdata_update() when
362*2311Sseb 	 * drivers update the data.
363*2311Sseb 	 */
364*2311Sseb 	mtops_pdata_verify_t	mtops_pdata_verify;
365*2311Sseb 	/*
366*2311Sseb 	 * mtops_header_cook() is an optional callback that converts (or
367*2311Sseb 	 * "cooks") the given raw header (as sent by a raw DLPI consumer)
368*2311Sseb 	 * into one that is appropriate to send down to the MAC driver.
369*2311Sseb 	 * Following the example above, an Ethernet header sent down by a
370*2311Sseb 	 * DLPI consumer would be converted to whatever header the MAC
371*2311Sseb 	 * driver expects.
372*2311Sseb 	 */
373*2311Sseb 	mtops_header_modify_t	mtops_header_cook;
374*2311Sseb 	/*
375*2311Sseb 	 * mtops_header_uncook() is an optional callback that does the
376*2311Sseb 	 * opposite of mtops_header_cook().  It "uncooks" a given MAC
377*2311Sseb 	 * header (as received from the driver) for consumption by raw DLPI
378*2311Sseb 	 * consumers.  For example, for a non-Ethernet plugin that wants
379*2311Sseb 	 * raw DLPI consumers to be fooled into thinking that the device
380*2311Sseb 	 * provides Ethernet access, this callback would modify the given
381*2311Sseb 	 * mblk_t such that the MAC header is converted to an Ethernet
382*2311Sseb 	 * header.
383*2311Sseb 	 */
384*2311Sseb 	mtops_header_modify_t	mtops_header_uncook;
385*2311Sseb } mactype_ops_t;
386*2311Sseb 
387*2311Sseb /*
388*2311Sseb  * mtops_ops exists for the plugin to enumerate the optional callback
389*2311Sseb  * entrypoints it has defined.  This allows the mac module to define
390*2311Sseb  * additional plugin entrypoints in mactype_ops_t without breaking backward
391*2311Sseb  * compatibility with old plugins.
392*2311Sseb  */
393*2311Sseb #define	MTOPS_PDATA_VERIFY	0x001
394*2311Sseb #define	MTOPS_HEADER_COOK	0x002
395*2311Sseb #define	MTOPS_HEADER_UNCOOK	0x004
396*2311Sseb 
397*2311Sseb typedef struct mactype_register_s {
398*2311Sseb 	uint_t		mtr_version;	/* set by mactype_alloc() */
399*2311Sseb 	const char	*mtr_ident;
400*2311Sseb 	mactype_ops_t	*mtr_ops;
401*2311Sseb 	uint_t		mtr_mactype;
402*2311Sseb 	uint_t		mtr_addrlen;
403*2311Sseb 	uint8_t		*mtr_brdcst_addr;
404*2311Sseb 	mac_stat_info_t	*mtr_stats;
405*2311Sseb 	size_t		mtr_statcount;
406*2311Sseb } mactype_register_t;
407*2311Sseb 
4080Sstevel@tonic-gate /*
4090Sstevel@tonic-gate  * Client interface functions.
4100Sstevel@tonic-gate  */
4110Sstevel@tonic-gate extern int			mac_open(const char *, uint_t, mac_handle_t *);
4120Sstevel@tonic-gate extern void			mac_close(mac_handle_t);
4130Sstevel@tonic-gate extern const mac_info_t		*mac_info(mac_handle_t);
414269Sericheng extern boolean_t		mac_info_get(const char *, mac_info_t *);
415*2311Sseb extern uint64_t			mac_stat_get(mac_handle_t, uint_t);
4160Sstevel@tonic-gate extern int			mac_start(mac_handle_t);
4170Sstevel@tonic-gate extern void			mac_stop(mac_handle_t);
4180Sstevel@tonic-gate extern int			mac_promisc_set(mac_handle_t, boolean_t,
4190Sstevel@tonic-gate     mac_promisc_type_t);
4200Sstevel@tonic-gate extern boolean_t		mac_promisc_get(mac_handle_t,
4210Sstevel@tonic-gate     mac_promisc_type_t);
4220Sstevel@tonic-gate extern int 			mac_multicst_add(mac_handle_t, const uint8_t *);
4230Sstevel@tonic-gate extern int 			mac_multicst_remove(mac_handle_t,
4240Sstevel@tonic-gate     const uint8_t *);
4250Sstevel@tonic-gate extern int			mac_unicst_set(mac_handle_t, const uint8_t *);
4260Sstevel@tonic-gate extern void			mac_unicst_get(mac_handle_t, uint8_t *);
427*2311Sseb extern void			mac_dest_get(mac_handle_t, uint8_t *);
4280Sstevel@tonic-gate extern void			mac_resources(mac_handle_t);
4290Sstevel@tonic-gate extern void			mac_ioctl(mac_handle_t, queue_t *, mblk_t *);
43056Smeem extern const mac_txinfo_t	*mac_tx_get(mac_handle_t);
4310Sstevel@tonic-gate extern link_state_t		mac_link_get(mac_handle_t);
4320Sstevel@tonic-gate extern mac_notify_handle_t	mac_notify_add(mac_handle_t, mac_notify_t,
4330Sstevel@tonic-gate     void *);
4340Sstevel@tonic-gate extern void			mac_notify_remove(mac_handle_t,
4350Sstevel@tonic-gate     mac_notify_handle_t);
4360Sstevel@tonic-gate extern void			mac_notify(mac_handle_t);
4370Sstevel@tonic-gate extern mac_rx_handle_t		mac_rx_add(mac_handle_t, mac_rx_t, void *);
4380Sstevel@tonic-gate extern void			mac_rx_remove(mac_handle_t, mac_rx_handle_t);
4390Sstevel@tonic-gate extern mblk_t			*mac_txloop(void *, mblk_t *);
4400Sstevel@tonic-gate extern mac_txloop_handle_t	mac_txloop_add(mac_handle_t, mac_txloop_t,
4410Sstevel@tonic-gate     void *);
4420Sstevel@tonic-gate extern void			mac_txloop_remove(mac_handle_t,
4430Sstevel@tonic-gate     mac_txloop_handle_t);
4440Sstevel@tonic-gate extern boolean_t		mac_active_set(mac_handle_t);
4450Sstevel@tonic-gate extern void			mac_active_clear(mac_handle_t);
4460Sstevel@tonic-gate extern void			mac_resource_set(mac_handle_t,
4470Sstevel@tonic-gate     mac_resource_add_t, void *);
448269Sericheng extern dev_info_t		*mac_devinfo_get(mac_handle_t);
449*2311Sseb extern boolean_t		mac_capab_get(mac_handle_t, mac_capab_t,
450*2311Sseb     void *);
451*2311Sseb extern boolean_t		mac_sap_verify(mac_handle_t, uint32_t,
452*2311Sseb     uint32_t *);
453*2311Sseb extern mblk_t			*mac_header(mac_handle_t, const uint8_t *,
454*2311Sseb     uint32_t, mblk_t *, size_t);
455*2311Sseb extern int			mac_header_info(mac_handle_t, mblk_t *,
456*2311Sseb     mac_header_info_t *);
457*2311Sseb extern mblk_t			*mac_header_cook(mac_handle_t, mblk_t *);
458*2311Sseb extern mblk_t			*mac_header_uncook(mac_handle_t, mblk_t *);
4590Sstevel@tonic-gate 
4600Sstevel@tonic-gate /*
4610Sstevel@tonic-gate  * Driver interface functions.
4620Sstevel@tonic-gate  */
463*2311Sseb extern mac_register_t		*mac_alloc(uint_t);
464*2311Sseb extern void			mac_free(mac_register_t *);
465*2311Sseb extern int			mac_register(mac_register_t *, mac_handle_t *);
466*2311Sseb extern int  			mac_unregister(mac_handle_t);
467*2311Sseb extern void 			mac_rx(mac_handle_t, mac_resource_handle_t,
4680Sstevel@tonic-gate     mblk_t *);
469*2311Sseb extern void 			mac_link_update(mac_handle_t, link_state_t);
470*2311Sseb extern void 			mac_unicst_update(mac_handle_t,
471*2311Sseb     const uint8_t *);
472*2311Sseb extern void			mac_tx_update(mac_handle_t);
473*2311Sseb extern void			mac_resource_update(mac_handle_t);
474*2311Sseb extern mac_resource_handle_t	mac_resource_add(mac_handle_t,
475*2311Sseb     mac_resource_t *);
476*2311Sseb extern int			mac_pdata_update(mac_handle_t, void *,
477*2311Sseb     size_t);
478*2311Sseb extern void			mac_multicst_refresh(mac_handle_t,
479*2311Sseb     mac_multicst_t, void *, boolean_t);
480*2311Sseb extern void			mac_unicst_refresh(mac_handle_t, mac_unicst_t,
4810Sstevel@tonic-gate     void *);
482*2311Sseb extern void			mac_promisc_refresh(mac_handle_t,
483*2311Sseb     mac_setpromisc_t, void *);
484269Sericheng extern void			mac_init_ops(struct dev_ops *, const char *);
485269Sericheng extern void			mac_fini_ops(struct dev_ops *);
486*2311Sseb extern mactype_register_t	*mactype_alloc(uint_t);
487*2311Sseb extern void			mactype_free(mactype_register_t *);
488*2311Sseb extern int			mactype_register(mactype_register_t *);
489*2311Sseb extern int			mactype_unregister(const char *);
4900Sstevel@tonic-gate 
4910Sstevel@tonic-gate #endif	/* _KERNEL */
4920Sstevel@tonic-gate 
4930Sstevel@tonic-gate #ifdef	__cplusplus
4940Sstevel@tonic-gate }
4950Sstevel@tonic-gate #endif
4960Sstevel@tonic-gate 
4970Sstevel@tonic-gate #endif /* _SYS_MAC_H */
498