xref: /onnv-gate/usr/src/uts/common/sys/mac_provider.h (revision 9700:30f7ca17cb40)
18275SEric Cheng /*
28275SEric Cheng  * CDDL HEADER START
38275SEric Cheng  *
48275SEric Cheng  * The contents of this file are subject to the terms of the
58275SEric Cheng  * Common Development and Distribution License (the "License").
68275SEric Cheng  * You may not use this file except in compliance with the License.
78275SEric Cheng  *
88275SEric Cheng  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
98275SEric Cheng  * or http://www.opensolaris.org/os/licensing.
108275SEric Cheng  * See the License for the specific language governing permissions
118275SEric Cheng  * and limitations under the License.
128275SEric Cheng  *
138275SEric Cheng  * When distributing Covered Code, include this CDDL HEADER in each
148275SEric Cheng  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
158275SEric Cheng  * If applicable, add the following below this CDDL HEADER, with the
168275SEric Cheng  * fields enclosed by brackets "[]" replaced with your own identifying
178275SEric Cheng  * information: Portions Copyright [yyyy] [name of copyright owner]
188275SEric Cheng  *
198275SEric Cheng  * CDDL HEADER END
208275SEric Cheng  */
218275SEric Cheng 
228275SEric Cheng /*
238833SVenu.Iyer@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
248275SEric Cheng  * Use is subject to license terms.
258275SEric Cheng  */
268275SEric Cheng 
278275SEric Cheng #ifndef	_SYS_MAC_PROVIDER_H
288275SEric Cheng #define	_SYS_MAC_PROVIDER_H
298275SEric Cheng 
308275SEric Cheng #include <sys/types.h>
318275SEric Cheng #include <sys/ddi.h>
328275SEric Cheng #include <sys/sunddi.h>
338275SEric Cheng #include <sys/stream.h>
348275SEric Cheng #include <sys/mac_flow.h>
358275SEric Cheng #include <sys/mac.h>
368275SEric Cheng 
378275SEric Cheng /*
388275SEric Cheng  * MAC Provider Interface
398275SEric Cheng  */
408275SEric Cheng 
418275SEric Cheng #ifdef	__cplusplus
428275SEric Cheng extern "C" {
438275SEric Cheng #endif
448275SEric Cheng 
458275SEric Cheng /*
468275SEric Cheng  * MAC version identifier.  This is used by mac_alloc() mac_register() to
478275SEric Cheng  * verify that incompatible drivers don't register.
488275SEric Cheng  */
498400SNicolas.Droux@Sun.COM #define	MAC_VERSION	0x2
508275SEric Cheng 
518275SEric Cheng /*
528275SEric Cheng  * Opaque handle types
538275SEric Cheng  */
548275SEric Cheng typedef struct __mac_rule_handle	*mac_rule_handle_t;
558275SEric Cheng 
568275SEric Cheng /*
578275SEric Cheng  * Statistics
588275SEric Cheng  */
598275SEric Cheng 
608275SEric Cheng #define	XCVR_UNDEFINED		0
618275SEric Cheng #define	XCVR_NONE		1
628275SEric Cheng #define	XCVR_10			2
638275SEric Cheng #define	XCVR_100T4		3
648275SEric Cheng #define	XCVR_100X		4
658275SEric Cheng #define	XCVR_100T2		5
668275SEric Cheng #define	XCVR_1000X		6
678275SEric Cheng #define	XCVR_1000T		7
688275SEric Cheng 
698275SEric Cheng #ifdef	_KERNEL
708275SEric Cheng 
718275SEric Cheng /*
728275SEric Cheng  * Definitions for MAC Drivers Capabilities
738275SEric Cheng  */
748275SEric Cheng /*
758275SEric Cheng  * MAC layer capabilities.  These capabilities are handled by the drivers'
768275SEric Cheng  * mc_capab_get() callbacks.  Some capabilities require the driver to fill
778275SEric Cheng  * in a given data structure, and others are simply boolean capabilities.
788275SEric Cheng  * Note that capability values must be powers of 2 so that consumers and
798275SEric Cheng  * providers of this interface can keep track of which capabilities they
808275SEric Cheng  * care about by keeping a bitfield of these things around somewhere.
818275SEric Cheng  */
828275SEric Cheng typedef enum {
838275SEric Cheng 	/*
848275SEric Cheng 	 * Capabilities reserved for internal use only
858275SEric Cheng 	 */
868275SEric Cheng 	MAC_CAPAB_VNIC		= 0x0001, /* data is mac_capab_vnic_t */
878275SEric Cheng 	MAC_CAPAB_ANCHOR_VNIC	= 0x0002, /* boolean only, no data */
888275SEric Cheng 	MAC_CAPAB_AGGR		= 0x0004, /* data is mac_capab_aggr_t */
898275SEric Cheng 	MAC_CAPAB_NO_NATIVEVLAN	= 0x0008, /* boolean only, no data */
908275SEric Cheng 	MAC_CAPAB_NO_ZCOPY	= 0x0010, /* boolean only, no data */
918275SEric Cheng 	MAC_CAPAB_LEGACY	= 0x0020, /* data is mac_capab_legacy_t */
928275SEric Cheng 
938275SEric Cheng 	/*
948275SEric Cheng 	 * Public Capabilities
958275SEric Cheng 	 */
968275SEric Cheng 	MAC_CAPAB_HCKSUM	= 0x0100, /* data is a uint32_t */
978275SEric Cheng 	MAC_CAPAB_LSO		= 0x0200, /* data is mac_capab_lso_t */
988275SEric Cheng 	MAC_CAPAB_RINGS		= 0x0400, /* data is mac_capab_rings_t */
998275SEric Cheng 	MAC_CAPAB_MULTIFACTADDR = 0x0800, /* mac_data_multifactaddr_t */
1008275SEric Cheng 	MAC_CAPAB_SHARES	= 0x1000 /* data is mac_capab_share_t */
1018275SEric Cheng 
1028275SEric Cheng 	/* add new capabilities here */
1038275SEric Cheng } mac_capab_t;
1048275SEric Cheng 
1058275SEric Cheng 
1068275SEric Cheng /*
1078275SEric Cheng  * LSO capability
1088275SEric Cheng  */
1098275SEric Cheng typedef struct lso_basic_tcp_ipv4_s {
1108275SEric Cheng 	t_uscalar_t	lso_max;		/* maximum payload */
1118275SEric Cheng } lso_basic_tcp_ipv4_t;
1128275SEric Cheng 
1138275SEric Cheng /*
1148275SEric Cheng  * Currently supported flags for LSO.
1158275SEric Cheng  */
1168275SEric Cheng #define	LSO_TX_BASIC_TCP_IPV4	0x01		/* TCP LSO capability */
1178275SEric Cheng 
1188275SEric Cheng /*
1198275SEric Cheng  * Future LSO capabilities can be added at the end of the mac_capab_lso_t.
1208275SEric Cheng  * When such capability is added to the GLDv3 framework, the size of the
1218275SEric Cheng  * mac_capab_lso_t it allocates and passes to the drivers increases. Older
1228275SEric Cheng  * drivers wil access only the (upper) sections of that structure, that is the
1238275SEric Cheng  * sections carrying the capabilities they understand. This ensures the
1248275SEric Cheng  * interface can be safely extended in a binary compatible way.
1258275SEric Cheng  */
1268275SEric Cheng typedef	struct mac_capab_lso_s {
1278275SEric Cheng 	t_uscalar_t		lso_flags;
1288275SEric Cheng 	lso_basic_tcp_ipv4_t	lso_basic_tcp_ipv4;
1298275SEric Cheng 	/* Add future lso capabilities here */
1308275SEric Cheng } mac_capab_lso_t;
1318275SEric Cheng 
1328275SEric Cheng /*
1338275SEric Cheng  * Multiple Factory MAC Addresses Capability
1348275SEric Cheng  */
1358275SEric Cheng typedef struct mac_capab_multifactaddr_s {
1368275SEric Cheng 	/*
1378275SEric Cheng 	 * Number of factory addresses
1388275SEric Cheng 	 */
1398275SEric Cheng 	uint_t		mcm_naddr;
1408275SEric Cheng 
1418275SEric Cheng 	/*
1428275SEric Cheng 	 * Callbacks to query all the factory addresses.
1438275SEric Cheng 	 */
1448275SEric Cheng 	void		(*mcm_getaddr)(void *, uint_t, uint8_t *);
1458275SEric Cheng } mac_capab_multifactaddr_t;
1468275SEric Cheng 
1478275SEric Cheng /*
1489073SCathy.Zhou@Sun.COM  * Info and callbacks of legacy devices.
1499073SCathy.Zhou@Sun.COM  */
1509073SCathy.Zhou@Sun.COM typedef struct mac_capab_legacy_s {
1519073SCathy.Zhou@Sun.COM 	/*
1529073SCathy.Zhou@Sun.COM 	 * Notifications that the legacy device does not support.
1539073SCathy.Zhou@Sun.COM 	 */
1549073SCathy.Zhou@Sun.COM 	uint32_t	ml_unsup_note;
1559073SCathy.Zhou@Sun.COM 	/*
1569073SCathy.Zhou@Sun.COM 	 * dev_t of the legacy device; can be held to force attach.
1579073SCathy.Zhou@Sun.COM 	 */
1589073SCathy.Zhou@Sun.COM 	dev_t		ml_dev;
1599073SCathy.Zhou@Sun.COM 	boolean_t	(*ml_active_set)(void *);
1609073SCathy.Zhou@Sun.COM 	void		(*ml_active_clear)(void *);
1619073SCathy.Zhou@Sun.COM 	int		(*ml_fastpath_disable)(void *);
1629073SCathy.Zhou@Sun.COM 	void		(*ml_fastpath_enable)(void *);
1639073SCathy.Zhou@Sun.COM } mac_capab_legacy_t;
1649073SCathy.Zhou@Sun.COM 
1659073SCathy.Zhou@Sun.COM /*
1668275SEric Cheng  * MAC driver entry point types.
1678275SEric Cheng  */
1688275SEric Cheng typedef int		(*mac_getstat_t)(void *, uint_t, uint64_t *);
1698275SEric Cheng typedef	int		(*mac_start_t)(void *);
1708275SEric Cheng typedef void		(*mac_stop_t)(void *);
1718275SEric Cheng typedef int		(*mac_setpromisc_t)(void *, boolean_t);
1728275SEric Cheng typedef int		(*mac_multicst_t)(void *, boolean_t, const uint8_t *);
1738275SEric Cheng typedef int		(*mac_unicst_t)(void *, const uint8_t *);
1748275SEric Cheng typedef void		(*mac_ioctl_t)(void *, queue_t *, mblk_t *);
1758275SEric Cheng typedef void		(*mac_resources_t)(void *);
1768275SEric Cheng typedef mblk_t		*(*mac_tx_t)(void *, mblk_t *);
1778275SEric Cheng typedef	boolean_t	(*mac_getcapab_t)(void *, mac_capab_t, void *);
1788275SEric Cheng typedef	int		(*mac_open_t)(void *);
1798275SEric Cheng typedef void		(*mac_close_t)(void *);
1808275SEric Cheng typedef	int		(*mac_set_prop_t)(void *, const char *, mac_prop_id_t,
1818275SEric Cheng 			    uint_t, const void *);
1828275SEric Cheng typedef	int		(*mac_get_prop_t)(void *, const char *, mac_prop_id_t,
1838275SEric Cheng 			    uint_t, uint_t, void *, uint_t *);
1848275SEric Cheng 
1858275SEric Cheng /*
1868275SEric Cheng  * Drivers must set all of these callbacks except for mc_resources,
1878275SEric Cheng  * mc_ioctl, and mc_getcapab, which are optional.  If any of these optional
1888275SEric Cheng  * callbacks are set, their appropriate flags must be set in mc_callbacks.
1898275SEric Cheng  * Any future additions to this list must also be accompanied by an
1908275SEric Cheng  * associated mc_callbacks flag so that the framework can grow without
1918275SEric Cheng  * affecting the binary compatibility of the interface.
1928275SEric Cheng  */
1938275SEric Cheng typedef struct mac_callbacks_s {
1948275SEric Cheng 	uint_t		mc_callbacks;	/* Denotes which callbacks are set */
1958275SEric Cheng 	mac_getstat_t	mc_getstat;	/* Get the value of a statistic */
1968275SEric Cheng 	mac_start_t	mc_start;	/* Start the device */
1978275SEric Cheng 	mac_stop_t	mc_stop;	/* Stop the device */
1988275SEric Cheng 	mac_setpromisc_t mc_setpromisc;	/* Enable or disable promiscuous mode */
1998275SEric Cheng 	mac_multicst_t	mc_multicst;	/* Enable or disable a multicast addr */
2008275SEric Cheng 	mac_unicst_t	mc_unicst;	/* Set the unicast MAC address */
2018275SEric Cheng 	mac_tx_t	mc_tx;		/* Transmit a packet */
2028275SEric Cheng 	mac_ioctl_t	mc_ioctl;	/* Process an unknown ioctl */
2038275SEric Cheng 	mac_getcapab_t	mc_getcapab;	/* Get capability information */
2048275SEric Cheng 	mac_open_t	mc_open;	/* Open the device */
2058275SEric Cheng 	mac_close_t	mc_close;	/* Close the device */
2068275SEric Cheng 	mac_set_prop_t	mc_setprop;
2078275SEric Cheng 	mac_get_prop_t	mc_getprop;
2088275SEric Cheng } mac_callbacks_t;
2098275SEric Cheng 
2108275SEric Cheng typedef struct mac_priv_prop_s {
2118275SEric Cheng 	char	mpp_name[MAXLINKPROPNAME];
2128275SEric Cheng 	uint_t	mpp_flags;
2138275SEric Cheng } mac_priv_prop_t;
2148275SEric Cheng 
2158275SEric Cheng /*
2168275SEric Cheng  * Virtualization Capabilities
2178275SEric Cheng  */
2188275SEric Cheng /*
2198275SEric Cheng  * The ordering of entries below is important. MAC_HW_CLASSIFIER
2208275SEric Cheng  * is the cutoff below which are entries which don't depend on
2218275SEric Cheng  * H/W. MAC_HW_CLASSIFIER and entries after that are cases where
2228275SEric Cheng  * H/W has been updated through add/modify/delete APIs.
2238275SEric Cheng  */
2248275SEric Cheng typedef enum {
2258275SEric Cheng 	MAC_NO_CLASSIFIER = 0,
2268275SEric Cheng 	MAC_SW_CLASSIFIER,
2278275SEric Cheng 	MAC_HW_CLASSIFIER
2288275SEric Cheng } mac_classify_type_t;
2298275SEric Cheng 
2308275SEric Cheng typedef	void	(*mac_rx_func_t)(void *, mac_resource_handle_t, mblk_t *,
2318275SEric Cheng     boolean_t);
2328275SEric Cheng 
2338275SEric Cheng /*
2348275SEric Cheng  * The virtualization level conveys the extent of the NIC hardware assistance
2358275SEric Cheng  * for traffic steering employed for virtualization:
2368275SEric Cheng  *
2378275SEric Cheng  * MAC_VIRT_NONE:	No assist for v12n.
2388275SEric Cheng  *
2398275SEric Cheng  * MAC_VIRT_LEVEL1:	Multiple Rx rings with MAC address level
2408275SEric Cheng  *			classification between groups of rings.
2418275SEric Cheng  *			Requires the support of the MAC_CAPAB_RINGS
2428275SEric Cheng  *			capability.
2438275SEric Cheng  *
2448275SEric Cheng  * MAC_VIRT_HIO:	Hybrid I/O capable MAC. Require the support
2458275SEric Cheng  *			of the MAC_CAPAB_SHARES capability.
2468275SEric Cheng  *
2478275SEric Cheng  * MAC_VIRT_SERIALIZE:	Temporary flag *ONLY* for nxge. Mac layer
2488275SEric Cheng  *			uses this to enable mac Tx serializer on
2498275SEric Cheng  *			outbound traffic and to always enqueue
2508275SEric Cheng  * 			incoming traffic on Rx soft rings in mac.
2518275SEric Cheng  */
2528275SEric Cheng #define	MAC_VIRT_NONE		0x0
2538275SEric Cheng #define	MAC_VIRT_LEVEL1		0x1
2548275SEric Cheng #define	MAC_VIRT_HIO		0x2
2558275SEric Cheng #define	MAC_VIRT_SERIALIZE	0x4
2568275SEric Cheng 
2578275SEric Cheng typedef enum {
2588275SEric Cheng 	MAC_RING_TYPE_RX = 1,	/* Receive ring */
2598275SEric Cheng 	MAC_RING_TYPE_TX	/* Transmit ring */
2608275SEric Cheng } mac_ring_type_t;
2618275SEric Cheng 
262*9700SVenu.Iyer@Sun.COM #define	MAX_RINGS_PER_GROUP	128
2638275SEric Cheng 
2648275SEric Cheng /*
2658275SEric Cheng  * Grouping type of a ring group
2668275SEric Cheng  *
2678275SEric Cheng  * MAC_GROUP_TYPE_STATIC: The ring group can not be re-grouped.
2688275SEric Cheng  * MAC_GROUP_TYPE_DYNAMIC: The ring group support dynamic re-grouping
2698275SEric Cheng  */
2708275SEric Cheng typedef enum {
2718275SEric Cheng 	MAC_GROUP_TYPE_STATIC = 1,	/* Static ring group */
2728275SEric Cheng 	MAC_GROUP_TYPE_DYNAMIC		/* Dynamic ring group */
2738275SEric Cheng } mac_group_type_t;
2748275SEric Cheng 
2758275SEric Cheng typedef	struct __mac_ring_driver	*mac_ring_driver_t;
2768275SEric Cheng typedef	struct __mac_group_driver	*mac_group_driver_t;
2778275SEric Cheng 
2788275SEric Cheng typedef	struct mac_ring_info_s mac_ring_info_t;
2798275SEric Cheng typedef	struct mac_group_info_s mac_group_info_t;
2808275SEric Cheng 
2818275SEric Cheng typedef void	(*mac_get_ring_t)(void *, mac_ring_type_t, const int, const int,
2828275SEric Cheng     mac_ring_info_t *, mac_ring_handle_t);
2838275SEric Cheng typedef void	(*mac_get_group_t)(void *, mac_ring_type_t, const int,
2848275SEric Cheng     mac_group_info_t *, mac_group_handle_t);
2858275SEric Cheng 
2868275SEric Cheng typedef void	(*mac_group_add_ring_t)(mac_group_driver_t,
2878275SEric Cheng     mac_ring_driver_t, mac_ring_type_t);
2888275SEric Cheng typedef void	(*mac_group_rem_ring_t)(mac_group_driver_t,
2898275SEric Cheng     mac_ring_driver_t, mac_ring_type_t);
2908275SEric Cheng 
2918275SEric Cheng /*
2928275SEric Cheng  * Multiple Rings Capability
2938275SEric Cheng  */
2948275SEric Cheng typedef struct	mac_capab_rings_s {
2958275SEric Cheng 	mac_ring_type_t		mr_type;	/* Ring type: Rx vs Tx */
2968275SEric Cheng 	mac_group_type_t	mr_group_type;	/* Dynamic vs static grouping */
2978275SEric Cheng 	uint_t			mr_rnum;	/* Number of rings */
2988275SEric Cheng 	uint_t			mr_gnum;	/* Number of ring groups */
2998275SEric Cheng 	mac_get_ring_t		mr_rget;	/* Get ring from driver */
3008275SEric Cheng 	mac_get_group_t		mr_gget;	/* Get ring group from driver */
3018275SEric Cheng 	mac_group_add_ring_t	mr_gaddring;	/* Add ring into a group */
3028275SEric Cheng 	mac_group_rem_ring_t	mr_gremring;	/* Remove ring from a group */
3038275SEric Cheng } mac_capab_rings_t;
3048275SEric Cheng 
3058275SEric Cheng /*
3068275SEric Cheng  * Common ring functions and driver interfaces
3078275SEric Cheng  */
3088275SEric Cheng typedef	int	(*mac_ring_start_t)(mac_ring_driver_t, uint64_t);
3098275SEric Cheng typedef	void	(*mac_ring_stop_t)(mac_ring_driver_t);
3108275SEric Cheng 
3118275SEric Cheng typedef	mblk_t	*(*mac_ring_send_t)(void *, mblk_t *);
3128275SEric Cheng typedef	mblk_t	*(*mac_ring_poll_t)(void *, int);
3138275SEric Cheng 
3148275SEric Cheng typedef struct mac_ring_info_s {
3158275SEric Cheng 	mac_ring_driver_t	mri_driver;
3168275SEric Cheng 	mac_ring_start_t	mri_start;
3178275SEric Cheng 	mac_ring_stop_t		mri_stop;
3188275SEric Cheng 	mac_intr_t		mri_intr;
3198275SEric Cheng 	union {
3208275SEric Cheng 		mac_ring_send_t	send;
3218275SEric Cheng 		mac_ring_poll_t	poll;
3228275SEric Cheng 	} mrfunion;
3238275SEric Cheng } mac_ring_info_s;
3248275SEric Cheng 
3258275SEric Cheng #define	mri_tx			mrfunion.send
3268275SEric Cheng #define	mri_poll		mrfunion.poll
3278275SEric Cheng 
3288275SEric Cheng typedef	int	(*mac_group_start_t)(mac_group_driver_t);
3298275SEric Cheng typedef	void	(*mac_group_stop_t)(mac_group_driver_t);
3308275SEric Cheng typedef	int	(*mac_add_mac_addr_t)(void *, const uint8_t *);
3318275SEric Cheng typedef	int	(*mac_rem_mac_addr_t)(void *, const uint8_t *);
3328275SEric Cheng 
3338275SEric Cheng struct mac_group_info_s {
3348275SEric Cheng 	mac_group_driver_t	mgi_driver;	/* Driver reference */
3358275SEric Cheng 	mac_group_start_t	mgi_start;	/* Start the group */
3368275SEric Cheng 	mac_group_stop_t	mgi_stop;	/* Stop the group */
3378275SEric Cheng 	uint_t			mgi_count;	/* Count of rings */
3388275SEric Cheng 	mac_intr_t		mgi_intr;	/* Optional per-group intr */
3398275SEric Cheng 
3408275SEric Cheng 	/* Only used for rx groups */
3418275SEric Cheng 	mac_add_mac_addr_t	mgi_addmac;	/* Add a MAC address */
3428275SEric Cheng 	mac_rem_mac_addr_t	mgi_remmac;	/* Remove a MAC address */
3438275SEric Cheng };
3448275SEric Cheng 
3458275SEric Cheng /*
3468275SEric Cheng  * Share management functions.
3478275SEric Cheng  */
3488275SEric Cheng typedef uint64_t mac_share_handle_t;
3498275SEric Cheng 
3508275SEric Cheng /*
3518275SEric Cheng  * Allocate and free a share. Returns ENOSPC if all shares have been
3528275SEric Cheng  * previously allocated.
3538275SEric Cheng  */
3548275SEric Cheng typedef int (*mac_alloc_share_t)(void *, mac_share_handle_t *);
3558275SEric Cheng typedef void (*mac_free_share_t)(mac_share_handle_t);
3568275SEric Cheng 
3578275SEric Cheng /*
3588275SEric Cheng  * Bind and unbind a share. Binding a share allows a domain
3598275SEric Cheng  * to have direct access to the groups and rings associated with
3608275SEric Cheng  * that share.
3618275SEric Cheng  */
3628275SEric Cheng typedef int (*mac_bind_share_t)(mac_share_handle_t, uint64_t, uint64_t *);
3638275SEric Cheng typedef void (*mac_unbind_share_t)(mac_share_handle_t);
3648275SEric Cheng 
3658275SEric Cheng /*
3668275SEric Cheng  * Return information on about a share.
3678275SEric Cheng  */
3688275SEric Cheng typedef void (*mac_share_query_t)(mac_share_handle_t, mac_ring_type_t,
3698275SEric Cheng     mac_ring_handle_t *, uint_t *);
3708275SEric Cheng 
3718275SEric Cheng /*
3728275SEric Cheng  * Basic idea, bind previously created ring groups to shares
3738275SEric Cheng  * for them to be exported (or shared) by another domain.
3748275SEric Cheng  * These interfaces bind/unbind the ring group to a share.
3758275SEric Cheng  * The groups and their rings will be shared with the guest
3768275SEric Cheng  * as soon as the share is bound.
3778275SEric Cheng  */
3788275SEric Cheng typedef int (*mac_share_add_group_t)(mac_share_handle_t,
3798275SEric Cheng     mac_group_driver_t);
3808275SEric Cheng typedef int (*mac_share_rem_group_t)(mac_share_handle_t,
3818275SEric Cheng     mac_group_driver_t);
3828275SEric Cheng 
3838275SEric Cheng typedef struct  mac_capab_share_s {
3848275SEric Cheng 	uint_t			ms_snum;	/* Number of shares (vr's) */
3858275SEric Cheng 	void			*ms_handle;	/* Handle to driver. */
3868275SEric Cheng 	mac_alloc_share_t	ms_salloc;	/* Get a share from driver. */
3878275SEric Cheng 	mac_free_share_t	ms_sfree;	/* Return a share to driver. */
3888275SEric Cheng 	mac_share_add_group_t	ms_sadd;	/* Add a group to the share. */
3898275SEric Cheng 	mac_share_rem_group_t	ms_sremove;	/* Remove group from share. */
3908275SEric Cheng 	mac_share_query_t	ms_squery;	/* Query share constraints */
3918275SEric Cheng 	mac_bind_share_t	ms_sbind;	/* Bind a share */
3928275SEric Cheng 	mac_unbind_share_t	ms_sunbind;	/* Unbind a share */
3938275SEric Cheng } mac_capab_share_t;
3948275SEric Cheng 
3958275SEric Cheng /*
3968275SEric Cheng  * MAC registration interface
3978275SEric Cheng  */
3988275SEric Cheng typedef struct mac_register_s {
3998275SEric Cheng 	uint_t			m_version;	/* set by mac_alloc() */
4008275SEric Cheng 	const char		*m_type_ident;
4018275SEric Cheng 	void			*m_driver;	/* Driver private data */
4028275SEric Cheng 	dev_info_t		*m_dip;
4038275SEric Cheng 	uint_t			m_instance;
4048275SEric Cheng 	uint8_t			*m_src_addr;
4058275SEric Cheng 	uint8_t			*m_dst_addr;
4068275SEric Cheng 	mac_callbacks_t		*m_callbacks;
4078275SEric Cheng 	uint_t			m_min_sdu;
4088275SEric Cheng 	uint_t			m_max_sdu;
4098275SEric Cheng 	void			*m_pdata;
4108275SEric Cheng 	size_t			m_pdata_size;
4118275SEric Cheng 	uint32_t		m_margin;
4128275SEric Cheng 	mac_priv_prop_t		*m_priv_props;
4138275SEric Cheng 	size_t			m_priv_prop_count;
4148275SEric Cheng 	uint32_t		m_v12n;		/* Virtualization level */
4158275SEric Cheng } mac_register_t;
4168275SEric Cheng 
4178275SEric Cheng /*
4188275SEric Cheng  * Flags for mc_callbacks.  Requiring drivers to set the flags associated
4198275SEric Cheng  * with optional callbacks initialized in the structure allows the mac
4208275SEric Cheng  * module to add optional callbacks in the future without requiring drivers
4218275SEric Cheng  * to recompile.
4228275SEric Cheng  */
4238275SEric Cheng #define	MC_IOCTL	0x001
4248275SEric Cheng #define	MC_GETCAPAB	0x002
4258275SEric Cheng #define	MC_OPEN		0x004
4268275SEric Cheng #define	MC_CLOSE	0x008
4278275SEric Cheng #define	MC_SETPROP	0x010
4288275SEric Cheng #define	MC_GETPROP	0x020
4298275SEric Cheng 
4308275SEric Cheng /*
4318275SEric Cheng  * Driver interface functions.
4328275SEric Cheng  */
4338275SEric Cheng extern void			mac_sdu_get(mac_handle_t, uint_t *, uint_t *);
4348275SEric Cheng extern int			mac_maxsdu_update(mac_handle_t, uint_t);
4358275SEric Cheng 
4368275SEric Cheng extern mac_register_t		*mac_alloc(uint_t);
4378275SEric Cheng extern void			mac_free(mac_register_t *);
4388275SEric Cheng extern int			mac_register(mac_register_t *, mac_handle_t *);
4398275SEric Cheng extern int			mac_disable_nowait(mac_handle_t);
4408275SEric Cheng extern int			mac_disable(mac_handle_t);
4418275SEric Cheng extern int  			mac_unregister(mac_handle_t);
4428275SEric Cheng extern void 			mac_rx(mac_handle_t, mac_resource_handle_t,
4438275SEric Cheng 				    mblk_t *);
4448275SEric Cheng extern void 			mac_rx_ring(mac_handle_t, mac_ring_handle_t,
4458275SEric Cheng 				    mblk_t *, uint64_t);
4468275SEric Cheng extern void 			mac_link_update(mac_handle_t, link_state_t);
4478275SEric Cheng extern void 			mac_unicst_update(mac_handle_t,
4488275SEric Cheng 				    const uint8_t *);
4498275SEric Cheng extern void			mac_tx_update(mac_handle_t);
4508275SEric Cheng extern void			mac_tx_ring_update(mac_handle_t,
4518275SEric Cheng 				    mac_ring_handle_t);
4528275SEric Cheng extern void			mac_capab_update(mac_handle_t);
4538275SEric Cheng extern int			mac_pdata_update(mac_handle_t, void *,
4548275SEric Cheng 				    size_t);
4558275SEric Cheng extern void			mac_multicast_refresh(mac_handle_t,
4568275SEric Cheng 				    mac_multicst_t, void *, boolean_t);
4578275SEric Cheng extern void			mac_unicst_refresh(mac_handle_t, mac_unicst_t,
4588275SEric Cheng 				    void *);
4598275SEric Cheng extern void			mac_promisc_refresh(mac_handle_t,
4608275SEric Cheng 				    mac_setpromisc_t, void *);
4618275SEric Cheng extern boolean_t		mac_margin_update(mac_handle_t, uint32_t);
4628275SEric Cheng extern void			mac_margin_get(mac_handle_t, uint32_t *);
4638275SEric Cheng extern int			mac_margin_remove(mac_handle_t, uint32_t);
4648275SEric Cheng extern int			mac_margin_add(mac_handle_t, uint32_t *,
4658275SEric Cheng 				    boolean_t);
4668275SEric Cheng extern void			mac_init_ops(struct dev_ops *, const char *);
4678275SEric Cheng extern void			mac_fini_ops(struct dev_ops *);
4688275SEric Cheng 
4698275SEric Cheng extern mactype_register_t	*mactype_alloc(uint_t);
4708275SEric Cheng extern void			mactype_free(mactype_register_t *);
4718275SEric Cheng extern int			mactype_register(mactype_register_t *);
4728275SEric Cheng extern int			mactype_unregister(const char *);
4738275SEric Cheng 
4748275SEric Cheng extern boolean_t		mac_unicst_verify(mac_handle_t,
4758275SEric Cheng 				    const uint8_t *, uint_t);
4768275SEric Cheng 
4778275SEric Cheng extern int			mac_group_add_ring(mac_group_handle_t, int);
4788275SEric Cheng extern void			mac_group_rem_ring(mac_group_handle_t,
4798275SEric Cheng 				    mac_ring_handle_t);
4808275SEric Cheng 
4818275SEric Cheng #endif	/* _KERNEL */
4828275SEric Cheng 
4838275SEric Cheng #ifdef	__cplusplus
4848275SEric Cheng }
4858275SEric Cheng #endif
4868275SEric Cheng 
4878275SEric Cheng #endif /* _SYS_MAC_PROVIDER_H */
488