xref: /onnv-gate/usr/src/uts/common/sys/softmac_impl.h (revision 11042:2d6e217af1b4)
15895Syz147064 /*
25895Syz147064  * CDDL HEADER START
35895Syz147064  *
45895Syz147064  * The contents of this file are subject to the terms of the
55895Syz147064  * Common Development and Distribution License (the "License").
65895Syz147064  * You may not use this file except in compliance with the License.
75895Syz147064  *
85895Syz147064  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95895Syz147064  * or http://www.opensolaris.org/os/licensing.
105895Syz147064  * See the License for the specific language governing permissions
115895Syz147064  * and limitations under the License.
125895Syz147064  *
135895Syz147064  * When distributing Covered Code, include this CDDL HEADER in each
145895Syz147064  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155895Syz147064  * If applicable, add the following below this CDDL HEADER, with the
165895Syz147064  * fields enclosed by brackets "[]" replaced with your own identifying
175895Syz147064  * information: Portions Copyright [yyyy] [name of copyright owner]
185895Syz147064  *
195895Syz147064  * CDDL HEADER END
205895Syz147064  */
215895Syz147064 /*
228527SCathy.Zhou@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
235895Syz147064  * Use is subject to license terms.
245895Syz147064  */
255895Syz147064 
265895Syz147064 #ifndef	_SYS_SOFTMAC_IMPL_H
275895Syz147064 #define	_SYS_SOFTMAC_IMPL_H
285895Syz147064 
295895Syz147064 #include <sys/types.h>
305895Syz147064 #include <sys/ethernet.h>
315895Syz147064 #include <sys/taskq.h>
325895Syz147064 #include <sys/sunddi.h>
335895Syz147064 #include <sys/sunldi.h>
345895Syz147064 #include <sys/strsun.h>
355895Syz147064 #include <sys/stream.h>
365895Syz147064 #include <sys/dlpi.h>
375895Syz147064 #include <sys/mac.h>
388275SEric Cheng #include <sys/mac_provider.h>
398275SEric Cheng #include <sys/mac_client.h>
408275SEric Cheng #include <sys/mac_client_priv.h>
415895Syz147064 #include <sys/mac_ether.h>
425895Syz147064 
435895Syz147064 #ifdef	__cplusplus
445895Syz147064 extern "C" {
455895Syz147064 #endif
465895Syz147064 
479073SCathy.Zhou@Sun.COM typedef void	(*softmac_rx_t)(void *, mac_resource_handle_t, mblk_t *,
489073SCathy.Zhou@Sun.COM 		    mac_header_info_t *);
499073SCathy.Zhou@Sun.COM 
509073SCathy.Zhou@Sun.COM typedef struct softmac_lower_rxinfo_s {
519073SCathy.Zhou@Sun.COM 	softmac_rx_t	slr_rx;
529073SCathy.Zhou@Sun.COM 	void		*slr_arg;
539073SCathy.Zhou@Sun.COM } softmac_lower_rxinfo_t;
549073SCathy.Zhou@Sun.COM 
555895Syz147064 typedef struct softmac_lower_s {
569073SCathy.Zhou@Sun.COM 	ldi_handle_t		sl_lh;
575895Syz147064 	struct softmac		*sl_softmac;
585895Syz147064 	queue_t			*sl_wq;
599073SCathy.Zhou@Sun.COM 	struct softmac_upper_s	*sl_sup;
609073SCathy.Zhou@Sun.COM 	softmac_lower_rxinfo_t	*sl_rxinfo;
615895Syz147064 
625895Syz147064 	/*
635895Syz147064 	 * When a control message is processed, either sl_pending_prim or
645895Syz147064 	 * sl_pending_ioctl will be set.  They will be cleared when the
655895Syz147064 	 * acknowledgement of the specific control message is received
665895Syz147064 	 * from the underlying legacy driver.
675895Syz147064 	 */
685895Syz147064 	kmutex_t		sl_mutex;
695895Syz147064 	kcondvar_t		sl_cv;
705895Syz147064 	t_uscalar_t		sl_pending_prim;
715895Syz147064 	boolean_t		sl_pending_ioctl;
725895Syz147064 	mblk_t			*sl_ack_mp;
735895Syz147064 } softmac_lower_t;
745895Syz147064 
758275SEric Cheng typedef enum {
765895Syz147064 	SOFTMAC_INITIALIZED,
775895Syz147064 	SOFTMAC_READY
788275SEric Cheng } softmac_lower_state_t;
798275SEric Cheng 
808275SEric Cheng typedef enum {
818275SEric Cheng 	SOFTMAC_UNINIT,
828275SEric Cheng 	SOFTMAC_ATTACH_INPROG,
838275SEric Cheng 	SOFTMAC_ATTACH_DONE,
848275SEric Cheng 	SOFTMAC_DETACH_INPROG,
858275SEric Cheng } softmac_state_t;
865895Syz147064 
875895Syz147064 typedef struct softmac_dev_s {
885895Syz147064 	dev_t	sd_dev;
895895Syz147064 } softmac_dev_t;
905895Syz147064 
915895Syz147064 /*
925895Syz147064  * smac_flag values.
935895Syz147064  */
945895Syz147064 #define	SOFTMAC_GLDV3		0x01
955895Syz147064 #define	SOFTMAC_NOSUPP		0x02
968275SEric Cheng #define	SOFTMAC_NEED_RECREATE	0x04
978275SEric Cheng #define	SOFTMAC_NOTIFY_QUIT	0x08
988275SEric Cheng 
998275SEric Cheng #define	SMAC_NONZERO_NODECNT(softmac)		\
1008275SEric Cheng 	((softmac->smac_softmac[0] != NULL) +	\
1018275SEric Cheng 	(softmac->smac_softmac[1] != NULL))
1025895Syz147064 
1035895Syz147064 /*
1045895Syz147064  * The softmac structure allows all minor nodes (at most two, style-1 and
1055895Syz147064  * style-2) for the same device to be processed.  A softmac_dev_t will be
1065895Syz147064  * created for each minor node.
1075895Syz147064  *
1085895Syz147064  * We try to "register" the mac after all the softmac_dev_t's are processed so
1095895Syz147064  * that even if DLPI operations fail (because of driver bugs) for one minor
1105895Syz147064  * node, the other minor node can still be used to register the mac.
1115895Syz147064  * (Specifically, an incorrect xxx_getinfo() implementation will cause style-2
1125895Syz147064  * minor node mac registration to fail.)
1139073SCathy.Zhou@Sun.COM  *
1149073SCathy.Zhou@Sun.COM  * Locking description:
1159073SCathy.Zhou@Sun.COM  *	WO: write once, valid the life time.
1165895Syz147064  */
1175895Syz147064 typedef struct softmac {
1189073SCathy.Zhou@Sun.COM 	char		smac_devname[MAXNAMELEN];	/* WO */
1199073SCathy.Zhou@Sun.COM 	major_t		smac_umajor;			/* WO */
1209073SCathy.Zhou@Sun.COM 	int		smac_uppa;			/* WO */
1219073SCathy.Zhou@Sun.COM 	uint32_t	smac_cnt;	/* WO, # of minor nodes */
1229073SCathy.Zhou@Sun.COM 
1239073SCathy.Zhou@Sun.COM 	kmutex_t	smac_mutex;
1249073SCathy.Zhou@Sun.COM 	kcondvar_t	smac_cv;
1259073SCathy.Zhou@Sun.COM 	softmac_state_t	smac_state;		/* smac_mutex */
1265895Syz147064 	/*
1275895Syz147064 	 * The smac_hold_cnt field increases when softmac_hold_device() is
1285895Syz147064 	 * called to force the dls_vlan_t of the device to be created.  The
1295895Syz147064 	 * device pre-detach fails if this counter is not 0.
1305895Syz147064 	 */
1319073SCathy.Zhou@Sun.COM 	uint32_t	smac_hold_cnt;		/* smac_mutex */
1329073SCathy.Zhou@Sun.COM 	uint32_t	smac_flags;		/* smac_mutex */
1339073SCathy.Zhou@Sun.COM 	int		smac_attacherr;		/* smac_mutex */
1345895Syz147064 	mac_handle_t	smac_mh;
1359073SCathy.Zhou@Sun.COM 	softmac_dev_t	*smac_softmac[2];	/* smac_mutex */
1369073SCathy.Zhou@Sun.COM 
1375895Syz147064 	/*
1385895Syz147064 	 * Number of minor nodes whose post-attach routine has succeeded.
1395895Syz147064 	 * This should be the same as the numbers of softmac_dev_t.
1405895Syz147064 	 * Note that it does not imply SOFTMAC_ATTACH_DONE as the taskq might
1415895Syz147064 	 * be still ongoing.
1425895Syz147064 	 */
1439073SCathy.Zhou@Sun.COM 	uint32_t	smac_attachok_cnt;	/* smac_mutex */
1445895Syz147064 	/*
1455895Syz147064 	 * Number of softmac_dev_t left when pre-detach fails. This is used
1465895Syz147064 	 * to indicate whether postattach is called because of a failed
1475895Syz147064 	 * pre-detach.
1485895Syz147064 	 */
1499073SCathy.Zhou@Sun.COM 	uint32_t	smac_attached_left;	/* smac_mutex */
1505895Syz147064 
1515895Syz147064 	/*
1528275SEric Cheng 	 * Thread handles the DL_NOTIFY_IND message from the lower stream.
1538275SEric Cheng 	 */
1549073SCathy.Zhou@Sun.COM 	kthread_t	*smac_notify_thread;	/* smac_mutex */
1558275SEric Cheng 	/*
1568275SEric Cheng 	 * Head and tail of the DL_NOTIFY_IND messsages.
1578275SEric Cheng 	 */
1589073SCathy.Zhou@Sun.COM 	mblk_t		*smac_notify_head;	/* smac_mutex */
1599073SCathy.Zhou@Sun.COM 	mblk_t		*smac_notify_tail;	/* smac_mutex */
1608275SEric Cheng 
1618275SEric Cheng 	/*
1625895Syz147064 	 * The remaining fields are used to register the MAC for a legacy
1635895Syz147064 	 * device.  They are set in softmac_mac_register() and do not change.
1645895Syz147064 	 * One can access them when mac_register() is done without locks.
1655895Syz147064 	 */
1665895Syz147064 
1675895Syz147064 	/*
1685895Syz147064 	 * media type is needed for create <link name, linkid> mapping, so
1695895Syz147064 	 * it is set for GLDv3 device as well
1705895Syz147064 	 */
1715895Syz147064 	uint_t		smac_media;
1725895Syz147064 	/* DLPI style of the underlying device */
1735895Syz147064 	int		smac_style;
1745895Syz147064 	dev_t		smac_dev;
1755895Syz147064 	size_t		smac_saplen;
1765895Syz147064 	size_t		smac_addrlen;
1775895Syz147064 	uchar_t		smac_unicst_addr[MAXMACADDRLEN];
1785895Syz147064 	uint_t		smac_min_sdu;
1795895Syz147064 	uint_t		smac_max_sdu;
1805895Syz147064 	uint32_t	smac_margin;
1815895Syz147064 
1825895Syz147064 	/* Notifications the underlying driver can support. */
1835895Syz147064 	uint32_t	smac_notifications;
1845895Syz147064 
1855895Syz147064 	/*
1865895Syz147064 	 * Capabilities of the underlying driver.
1875895Syz147064 	 */
1885895Syz147064 	uint32_t	smac_capab_flags;
1895895Syz147064 	uint32_t	smac_hcksum_txflags;
1905895Syz147064 	boolean_t	smac_no_capability_req;
1915895Syz147064 	dl_capab_mdt_t	smac_mdt_capab;
1925895Syz147064 	boolean_t	smac_mdt;
1935895Syz147064 
1949073SCathy.Zhou@Sun.COM 	/*
1959073SCathy.Zhou@Sun.COM 	 * Lower stream structure, accessed by the MAC provider API. The GLDv3
1969073SCathy.Zhou@Sun.COM 	 * framework assures it's validity.
1979073SCathy.Zhou@Sun.COM 	 */
1985895Syz147064 	softmac_lower_t	*smac_lower;
1999073SCathy.Zhou@Sun.COM 
2009073SCathy.Zhou@Sun.COM 	kmutex_t	smac_active_mutex;
2019073SCathy.Zhou@Sun.COM 	/*
2029073SCathy.Zhou@Sun.COM 	 * Set by xxx_active_set() when aggregation is created.
2039073SCathy.Zhou@Sun.COM 	 */
2049073SCathy.Zhou@Sun.COM 	boolean_t	smac_active;	/* smac_active_mutex */
2059073SCathy.Zhou@Sun.COM 	/*
2069073SCathy.Zhou@Sun.COM 	 * Numbers of the bounded streams in the fast-path mode.
2079073SCathy.Zhou@Sun.COM 	 */
2089073SCathy.Zhou@Sun.COM 	uint32_t	smac_nactive;	/* smac_active_mutex */
2099073SCathy.Zhou@Sun.COM 
2109073SCathy.Zhou@Sun.COM 	kmutex_t	smac_fp_mutex;
2119073SCathy.Zhou@Sun.COM 	kcondvar_t	smac_fp_cv;
2129073SCathy.Zhou@Sun.COM 	/*
2139073SCathy.Zhou@Sun.COM 	 * numbers of clients that request to disable fastpath.
2149073SCathy.Zhou@Sun.COM 	 */
2159073SCathy.Zhou@Sun.COM 	uint32_t	smac_fp_disable_clients;	/* smac_fp_mutex */
2169073SCathy.Zhou@Sun.COM 	boolean_t	smac_fastpath_admin_disabled;	/* smac_fp_mutex */
2179073SCathy.Zhou@Sun.COM 
2189073SCathy.Zhou@Sun.COM 	/*
2199073SCathy.Zhou@Sun.COM 	 * stream list over this softmac.
2209073SCathy.Zhou@Sun.COM 	 */
2219073SCathy.Zhou@Sun.COM 	list_t			smac_sup_list;		/* smac_fp_mutex */
2225895Syz147064 } softmac_t;
2235895Syz147064 
2245895Syz147064 typedef struct smac_ioc_start_s {
2255895Syz147064 	softmac_lower_t	*si_slp;
2265895Syz147064 } smac_ioc_start_t;
2275895Syz147064 
2285895Syz147064 #define	SMAC_IOC	('S' << 24 | 'M' << 16 | 'C' << 8)
2295895Syz147064 #define	SMAC_IOC_START	(SMAC_IOC | 0x01)
2305895Syz147064 
2319073SCathy.Zhou@Sun.COM /*
2329073SCathy.Zhou@Sun.COM  * The su_mode of a non-IP/ARP stream is UNKNOWN, and the su_mode of an IP/ARP
2339073SCathy.Zhou@Sun.COM  * stream is either SLOWPATH or FASTPATH.
2349073SCathy.Zhou@Sun.COM  */
2359073SCathy.Zhou@Sun.COM #define	SOFTMAC_UNKNOWN		0x00
2369073SCathy.Zhou@Sun.COM #define	SOFTMAC_SLOWPATH	0x01
2379073SCathy.Zhou@Sun.COM #define	SOFTMAC_FASTPATH	0x02
2389073SCathy.Zhou@Sun.COM 
2399073SCathy.Zhou@Sun.COM typedef struct softmac_switch_req_s {
2409073SCathy.Zhou@Sun.COM 	list_node_t	ssq_req_list_node;
2419073SCathy.Zhou@Sun.COM 	uint32_t	ssq_expected_mode;
2429073SCathy.Zhou@Sun.COM } softmac_switch_req_t;
2439073SCathy.Zhou@Sun.COM 
2449073SCathy.Zhou@Sun.COM #define	DATAPATH_MODE(softmac)						\
2459073SCathy.Zhou@Sun.COM 	((((softmac)->smac_fp_disable_clients != 0) ||			\
2469073SCathy.Zhou@Sun.COM 	(softmac)->smac_fastpath_admin_disabled) ? SOFTMAC_SLOWPATH :	\
2479073SCathy.Zhou@Sun.COM 	SOFTMAC_FASTPATH)
2489073SCathy.Zhou@Sun.COM 
2499073SCathy.Zhou@Sun.COM 
2509073SCathy.Zhou@Sun.COM /*
2519073SCathy.Zhou@Sun.COM  * Locking description:
2529073SCathy.Zhou@Sun.COM  *
2539073SCathy.Zhou@Sun.COM  *	WO: Set once and valid for life;
2549073SCathy.Zhou@Sun.COM  *	SL: Serialized by the control path (softmac_wput_nondata_task())
2559073SCathy.Zhou@Sun.COM  */
2569073SCathy.Zhou@Sun.COM typedef struct softmac_upper_s {
2579073SCathy.Zhou@Sun.COM 	softmac_t		*su_softmac;	/* WO */
2589073SCathy.Zhou@Sun.COM 	queue_t			*su_rq;		/* WO */
2599073SCathy.Zhou@Sun.COM 	queue_t			*su_wq;		/* WO */
2609073SCathy.Zhou@Sun.COM 
2619073SCathy.Zhou@Sun.COM 	/*
2629073SCathy.Zhou@Sun.COM 	 * List of upper streams that has pending DLPI messages to be processed.
2639073SCathy.Zhou@Sun.COM 	 */
2649073SCathy.Zhou@Sun.COM 	list_node_t		su_taskq_list_node; /* softmac_taskq_lock */
2659073SCathy.Zhou@Sun.COM 
2669073SCathy.Zhou@Sun.COM 	/*
2679073SCathy.Zhou@Sun.COM 	 * non-NULL for IP/ARP streams in the fast-path mode
2689073SCathy.Zhou@Sun.COM 	 */
2699073SCathy.Zhou@Sun.COM 	softmac_lower_t		*su_slp;	/* SL & su_mutex */
2709073SCathy.Zhou@Sun.COM 
2719073SCathy.Zhou@Sun.COM 	/*
2729073SCathy.Zhou@Sun.COM 	 * List of all IP/ARP upperstreams on the same softmac (including
2739073SCathy.Zhou@Sun.COM 	 * the ones in both data-path modes).
2749073SCathy.Zhou@Sun.COM 	 */
2759073SCathy.Zhou@Sun.COM 	list_node_t		su_list_node;	/* smac_fp_mutex */
2769073SCathy.Zhou@Sun.COM 
2779073SCathy.Zhou@Sun.COM 	/*
2789073SCathy.Zhou@Sun.COM 	 * List of datapath switch requests.
2799073SCathy.Zhou@Sun.COM 	 */
2809073SCathy.Zhou@Sun.COM 	list_t			su_req_list;	/* smac_fp_mutex */
2819073SCathy.Zhou@Sun.COM 
2829073SCathy.Zhou@Sun.COM 	/*
2839073SCathy.Zhou@Sun.COM 	 * Place holder of RX callbacks used to handles data messages comes
2849073SCathy.Zhou@Sun.COM 	 * from the dedicated-lower-stream associated with the IP/ARP stream.
2859073SCathy.Zhou@Sun.COM 	 * Another RX callback is softmac_drop_rxinfo, which is a global
2869073SCathy.Zhou@Sun.COM 	 * variable.
2879073SCathy.Zhou@Sun.COM 	 */
2889073SCathy.Zhou@Sun.COM 	softmac_lower_rxinfo_t	su_rxinfo;		/* WO */
2899073SCathy.Zhou@Sun.COM 	softmac_lower_rxinfo_t	su_direct_rxinfo;	/* WO */
2909073SCathy.Zhou@Sun.COM 
2919073SCathy.Zhou@Sun.COM 	/*
2929073SCathy.Zhou@Sun.COM 	 * Used to serialize the DLPI operation and fastpath<->slowpath
2939073SCathy.Zhou@Sun.COM 	 * switching over operation.
2949073SCathy.Zhou@Sun.COM 	 */
2959073SCathy.Zhou@Sun.COM 	kmutex_t		su_disp_mutex;
2969073SCathy.Zhou@Sun.COM 	kcondvar_t		su_disp_cv;
2979073SCathy.Zhou@Sun.COM 	mblk_t			*su_pending_head;	/* su_disp_mutex */
2989073SCathy.Zhou@Sun.COM 	mblk_t			*su_pending_tail;	/* su_disp_mutex */
2999073SCathy.Zhou@Sun.COM 	boolean_t		su_dlpi_pending;	/* su_disp_mutex */
3009073SCathy.Zhou@Sun.COM 	boolean_t		su_closing;		/* su_disp_mutex */
3019073SCathy.Zhou@Sun.COM 
3029073SCathy.Zhou@Sun.COM 	uint32_t		su_bound : 1,		/* SL */
3039073SCathy.Zhou@Sun.COM 				su_active : 1,		/* SL */
304*11042SErik.Nordmark@Sun.COM 				su_direct : 1,		/* SL */
305*11042SErik.Nordmark@Sun.COM 				su_is_arp : 1,
306*11042SErik.Nordmark@Sun.COM 				su_pad_to_32:28;
3079073SCathy.Zhou@Sun.COM 
3089073SCathy.Zhou@Sun.COM 	/*
3099073SCathy.Zhou@Sun.COM 	 * Used for fastpath data path.
3109073SCathy.Zhou@Sun.COM 	 */
3119073SCathy.Zhou@Sun.COM 	kmutex_t		su_mutex;
3129073SCathy.Zhou@Sun.COM 	kcondvar_t		su_cv;
3139073SCathy.Zhou@Sun.COM 	mblk_t			*su_tx_flow_mp;		/* su_mutex */
3149073SCathy.Zhou@Sun.COM 	boolean_t		su_tx_busy;		/* su_mutex */
3159073SCathy.Zhou@Sun.COM 	/*
3169073SCathy.Zhou@Sun.COM 	 * Number of softmac_srv() operation in fastpath processing.
3179073SCathy.Zhou@Sun.COM 	 */
3189073SCathy.Zhou@Sun.COM 	uint32_t		su_tx_inprocess;	/* su_mutex */
3199073SCathy.Zhou@Sun.COM 	/*
3209073SCathy.Zhou@Sun.COM 	 * SOFTMAC_SLOWPATH or SOFTMAC_FASTPATH
3219073SCathy.Zhou@Sun.COM 	 */
3229073SCathy.Zhou@Sun.COM 	uint32_t		su_mode;		/* SL & su_mutex */
3239073SCathy.Zhou@Sun.COM 
3249073SCathy.Zhou@Sun.COM 	/*
3259073SCathy.Zhou@Sun.COM 	 * Whether this stream is already scheduled in softmac_taskq_list.
3269073SCathy.Zhou@Sun.COM 	 */
3279073SCathy.Zhou@Sun.COM 	boolean_t		su_taskq_scheduled;	/* softmac_taskq_lock */
3289738SCathy.Zhou@Sun.COM 
3299738SCathy.Zhou@Sun.COM 	/*
3309738SCathy.Zhou@Sun.COM 	 * The DLD_CAPAB_DIRECT related notify callback.
3319738SCathy.Zhou@Sun.COM 	 */
3329738SCathy.Zhou@Sun.COM 	mac_tx_notify_t		su_tx_notify_func;	/* su_mutex */
3339738SCathy.Zhou@Sun.COM 	void			*su_tx_notify_arg;	/* su_mutex */
3349073SCathy.Zhou@Sun.COM } softmac_upper_t;
3359073SCathy.Zhou@Sun.COM 
3369073SCathy.Zhou@Sun.COM #define	SOFTMAC_EQ_PENDING(sup, mp) {					\
3379073SCathy.Zhou@Sun.COM 	if ((sup)->su_pending_head == NULL) {				\
3389073SCathy.Zhou@Sun.COM 		(sup)->su_pending_head = (sup)->su_pending_tail = (mp);	\
3399073SCathy.Zhou@Sun.COM 	} else {							\
3409073SCathy.Zhou@Sun.COM 		(sup)->su_pending_tail->b_next = (mp);			\
3419073SCathy.Zhou@Sun.COM 		(sup)->su_pending_tail = (mp);				\
3429073SCathy.Zhou@Sun.COM 	}								\
3439073SCathy.Zhou@Sun.COM }
3449073SCathy.Zhou@Sun.COM 
3459073SCathy.Zhou@Sun.COM #define	SOFTMAC_DQ_PENDING(sup, mpp) {					\
3469073SCathy.Zhou@Sun.COM 	if ((sup)->su_pending_head == NULL) {				\
3479073SCathy.Zhou@Sun.COM 		*(mpp) = NULL;						\
3489073SCathy.Zhou@Sun.COM 	} else {							\
3499073SCathy.Zhou@Sun.COM 		*(mpp) = (sup)->su_pending_head;			\
3509073SCathy.Zhou@Sun.COM 		if (((sup)->su_pending_head = (*(mpp))->b_next) == NULL)\
3519073SCathy.Zhou@Sun.COM 			(sup)->su_pending_tail = NULL;			\
3529073SCathy.Zhou@Sun.COM 		(*(mpp))->b_next = NULL;				\
3539073SCathy.Zhou@Sun.COM 	}								\
3549073SCathy.Zhou@Sun.COM }
3559073SCathy.Zhou@Sun.COM 
3569073SCathy.Zhou@Sun.COM /*
3579073SCathy.Zhou@Sun.COM  * A macro to check whether the write-queue of the lower stream is full
3589073SCathy.Zhou@Sun.COM  * and packets need to be enqueued.
3599073SCathy.Zhou@Sun.COM  *
3609073SCathy.Zhou@Sun.COM  * Because softmac is pushed right above the underlying device and
3619073SCathy.Zhou@Sun.COM  * _I_INSERT/_I_REMOVE is not processed in the lower stream, it is
3629073SCathy.Zhou@Sun.COM  * safe to directly access the q_next pointer.
3639073SCathy.Zhou@Sun.COM  */
3649073SCathy.Zhou@Sun.COM #define	SOFTMAC_CANPUTNEXT(q)	\
3659073SCathy.Zhou@Sun.COM 	(!((q)->q_next->q_nfsrv->q_flag & QFULL) || canput((q)->q_next))
3669073SCathy.Zhou@Sun.COM 
3679073SCathy.Zhou@Sun.COM 
3685895Syz147064 extern dev_info_t		*softmac_dip;
3695895Syz147064 #define	SOFTMAC_DEV_NAME	"softmac"
3705895Syz147064 
3715895Syz147064 extern int	softmac_send_bind_req(softmac_lower_t *, uint_t);
3729073SCathy.Zhou@Sun.COM extern int	softmac_send_unbind_req(softmac_lower_t *);
3735895Syz147064 extern int	softmac_send_notify_req(softmac_lower_t *, uint32_t);
3745895Syz147064 extern int	softmac_send_promisc_req(softmac_lower_t *, t_uscalar_t,
3755895Syz147064     boolean_t);
3769073SCathy.Zhou@Sun.COM extern void	softmac_init();
3779073SCathy.Zhou@Sun.COM extern void	softmac_fini();
3789073SCathy.Zhou@Sun.COM extern void	softmac_fp_init();
3799073SCathy.Zhou@Sun.COM extern void	softmac_fp_fini();
3809073SCathy.Zhou@Sun.COM extern boolean_t softmac_busy();
3815895Syz147064 extern int	softmac_fill_capab(ldi_handle_t, softmac_t *);
3825895Syz147064 extern int	softmac_capab_enable(softmac_lower_t *);
3839073SCathy.Zhou@Sun.COM extern void	softmac_rput_process_notdata(queue_t *, softmac_upper_t *,
3849073SCathy.Zhou@Sun.COM     mblk_t *);
3855895Syz147064 extern void	softmac_rput_process_data(softmac_lower_t *, mblk_t *);
3869073SCathy.Zhou@Sun.COM extern int	softmac_output(softmac_lower_t *, mblk_t *, t_uscalar_t,
3879073SCathy.Zhou@Sun.COM     t_uscalar_t, mblk_t **);
3889073SCathy.Zhou@Sun.COM extern int	softmac_mexchange_error_ack(mblk_t **, t_uscalar_t,
3899073SCathy.Zhou@Sun.COM     t_uscalar_t, t_uscalar_t);
3905895Syz147064 
3915895Syz147064 extern int	softmac_m_promisc(void *, boolean_t);
3925895Syz147064 extern int	softmac_m_multicst(void *, boolean_t, const uint8_t *);
3935895Syz147064 extern int	softmac_m_unicst(void *, const uint8_t *);
3945895Syz147064 extern void	softmac_m_ioctl(void *, queue_t *, mblk_t *);
3955895Syz147064 extern int	softmac_m_stat(void *, uint_t, uint64_t *);
3965895Syz147064 extern mblk_t	*softmac_m_tx(void *, mblk_t *);
3975895Syz147064 extern int	softmac_proto_tx(softmac_lower_t *, mblk_t *, mblk_t **);
3985895Syz147064 extern void	softmac_ioctl_tx(softmac_lower_t *, mblk_t *, mblk_t **);
3998275SEric Cheng extern void	softmac_notify_thread(void *);
4005895Syz147064 
4019073SCathy.Zhou@Sun.COM extern int	softmac_hold(dev_t, softmac_t **);
4029073SCathy.Zhou@Sun.COM extern void	softmac_rele(softmac_t *);
4039073SCathy.Zhou@Sun.COM extern int	softmac_lower_setup(softmac_t *, softmac_upper_t *,
4049073SCathy.Zhou@Sun.COM     softmac_lower_t **);
4059073SCathy.Zhou@Sun.COM extern boolean_t	softmac_active_set(void *);
4069073SCathy.Zhou@Sun.COM extern void	softmac_active_clear(void *);
4079073SCathy.Zhou@Sun.COM extern int	softmac_fastpath_disable(void *);
4089073SCathy.Zhou@Sun.COM extern void	softmac_fastpath_enable(void *);
4099073SCathy.Zhou@Sun.COM extern int	softmac_datapath_switch(softmac_t *, boolean_t, boolean_t);
4109073SCathy.Zhou@Sun.COM 
4119073SCathy.Zhou@Sun.COM extern void	softmac_wput_data(softmac_upper_t *, mblk_t *);
4129073SCathy.Zhou@Sun.COM extern void	softmac_wput_nondata(softmac_upper_t *, mblk_t *);
4139073SCathy.Zhou@Sun.COM extern void	softmac_upperstream_close(softmac_upper_t *);
4149073SCathy.Zhou@Sun.COM 
4155895Syz147064 #ifdef	__cplusplus
4165895Syz147064 }
4175895Syz147064 #endif
4185895Syz147064 
4195895Syz147064 #endif	/* _SYS_SOFTMAC_IMPL_H */
420