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