1d62bc4baSyz147064 /*
2d62bc4baSyz147064  * CDDL HEADER START
3d62bc4baSyz147064  *
4d62bc4baSyz147064  * The contents of this file are subject to the terms of the
5d62bc4baSyz147064  * Common Development and Distribution License (the "License").
6d62bc4baSyz147064  * You may not use this file except in compliance with the License.
7d62bc4baSyz147064  *
8d62bc4baSyz147064  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9d62bc4baSyz147064  * or http://www.opensolaris.org/os/licensing.
10d62bc4baSyz147064  * See the License for the specific language governing permissions
11d62bc4baSyz147064  * and limitations under the License.
12d62bc4baSyz147064  *
13d62bc4baSyz147064  * When distributing Covered Code, include this CDDL HEADER in each
14d62bc4baSyz147064  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15d62bc4baSyz147064  * If applicable, add the following below this CDDL HEADER, with the
16d62bc4baSyz147064  * fields enclosed by brackets "[]" replaced with your own identifying
17d62bc4baSyz147064  * information: Portions Copyright [yyyy] [name of copyright owner]
18d62bc4baSyz147064  *
19d62bc4baSyz147064  * CDDL HEADER END
20d62bc4baSyz147064  */
21d62bc4baSyz147064 /*
2265041820SCathy Zhou  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23d62bc4baSyz147064  * Use is subject to license terms.
24*9b664393SGarrett D'Amore  *
25*9b664393SGarrett D'Amore  * Copyright 2022 Garrett D'Amore
26d62bc4baSyz147064  */
27d62bc4baSyz147064 
28d62bc4baSyz147064 #ifndef	_SYS_SOFTMAC_IMPL_H
29d62bc4baSyz147064 #define	_SYS_SOFTMAC_IMPL_H
30d62bc4baSyz147064 
31d62bc4baSyz147064 #include <sys/types.h>
32d62bc4baSyz147064 #include <sys/ethernet.h>
33d62bc4baSyz147064 #include <sys/taskq.h>
34d62bc4baSyz147064 #include <sys/sunddi.h>
35d62bc4baSyz147064 #include <sys/sunldi.h>
36d62bc4baSyz147064 #include <sys/strsun.h>
37d62bc4baSyz147064 #include <sys/stream.h>
38d62bc4baSyz147064 #include <sys/dlpi.h>
39d62bc4baSyz147064 #include <sys/mac.h>
40da14cebeSEric Cheng #include <sys/mac_provider.h>
41da14cebeSEric Cheng #include <sys/mac_client.h>
42da14cebeSEric Cheng #include <sys/mac_client_priv.h>
43d62bc4baSyz147064 #include <sys/mac_ether.h>
44d62bc4baSyz147064 
45d62bc4baSyz147064 #ifdef	__cplusplus
46d62bc4baSyz147064 extern "C" {
47d62bc4baSyz147064 #endif
48d62bc4baSyz147064 
495d460eafSCathy Zhou typedef void	(*softmac_rx_t)(void *, mac_resource_handle_t, mblk_t *,
505d460eafSCathy Zhou 		    mac_header_info_t *);
515d460eafSCathy Zhou 
525d460eafSCathy Zhou typedef struct softmac_lower_rxinfo_s {
535d460eafSCathy Zhou 	softmac_rx_t	slr_rx;
545d460eafSCathy Zhou 	void		*slr_arg;
555d460eafSCathy Zhou } softmac_lower_rxinfo_t;
565d460eafSCathy Zhou 
57d62bc4baSyz147064 typedef struct softmac_lower_s {
585d460eafSCathy Zhou 	ldi_handle_t		sl_lh;
59d62bc4baSyz147064 	struct softmac		*sl_softmac;
60d62bc4baSyz147064 	queue_t			*sl_wq;
615d460eafSCathy Zhou 	struct softmac_upper_s	*sl_sup;
625d460eafSCathy Zhou 	softmac_lower_rxinfo_t	*sl_rxinfo;
63d62bc4baSyz147064 
64d62bc4baSyz147064 	/*
65d62bc4baSyz147064 	 * When a control message is processed, either sl_pending_prim or
66d62bc4baSyz147064 	 * sl_pending_ioctl will be set.  They will be cleared when the
67d62bc4baSyz147064 	 * acknowledgement of the specific control message is received
68d62bc4baSyz147064 	 * from the underlying legacy driver.
69d62bc4baSyz147064 	 */
70d62bc4baSyz147064 	kmutex_t		sl_mutex;
71d62bc4baSyz147064 	kcondvar_t		sl_cv;
72d62bc4baSyz147064 	t_uscalar_t		sl_pending_prim;
73d62bc4baSyz147064 	boolean_t		sl_pending_ioctl;
74d62bc4baSyz147064 	mblk_t			*sl_ack_mp;
75d62bc4baSyz147064 } softmac_lower_t;
76d62bc4baSyz147064 
77da14cebeSEric Cheng typedef enum {
78da14cebeSEric Cheng 	SOFTMAC_UNINIT,
79da14cebeSEric Cheng 	SOFTMAC_ATTACH_INPROG,
80da14cebeSEric Cheng 	SOFTMAC_ATTACH_DONE,
81da14cebeSEric Cheng 	SOFTMAC_DETACH_INPROG,
82da14cebeSEric Cheng } softmac_state_t;
83d62bc4baSyz147064 
84d62bc4baSyz147064 typedef struct softmac_dev_s {
85d62bc4baSyz147064 	dev_t	sd_dev;
86d62bc4baSyz147064 } softmac_dev_t;
87d62bc4baSyz147064 
88d62bc4baSyz147064 /*
89d62bc4baSyz147064  * smac_flag values.
90d62bc4baSyz147064  */
91d62bc4baSyz147064 #define	SOFTMAC_GLDV3		0x01
92d62bc4baSyz147064 #define	SOFTMAC_NOSUPP		0x02
93da14cebeSEric Cheng #define	SOFTMAC_NEED_RECREATE	0x04
94da14cebeSEric Cheng #define	SOFTMAC_NOTIFY_QUIT	0x08
95da14cebeSEric Cheng 
96da14cebeSEric Cheng #define	SMAC_NONZERO_NODECNT(softmac)		\
97da14cebeSEric Cheng 	((softmac->smac_softmac[0] != NULL) +	\
98da14cebeSEric Cheng 	(softmac->smac_softmac[1] != NULL))
99d62bc4baSyz147064 
100d62bc4baSyz147064 /*
101d62bc4baSyz147064  * The softmac structure allows all minor nodes (at most two, style-1 and
102d62bc4baSyz147064  * style-2) for the same device to be processed.  A softmac_dev_t will be
103d62bc4baSyz147064  * created for each minor node.
104d62bc4baSyz147064  *
105d62bc4baSyz147064  * We try to "register" the mac after all the softmac_dev_t's are processed so
106d62bc4baSyz147064  * that even if DLPI operations fail (because of driver bugs) for one minor
107d62bc4baSyz147064  * node, the other minor node can still be used to register the mac.
108d62bc4baSyz147064  * (Specifically, an incorrect xxx_getinfo() implementation will cause style-2
109d62bc4baSyz147064  * minor node mac registration to fail.)
1105d460eafSCathy Zhou  *
1115d460eafSCathy Zhou  * Locking description:
1125d460eafSCathy Zhou  *	WO: write once, valid the life time.
113d62bc4baSyz147064  */
114d62bc4baSyz147064 typedef struct softmac {
1155d460eafSCathy Zhou 	char		smac_devname[MAXNAMELEN];	/* WO */
1165d460eafSCathy Zhou 	major_t		smac_umajor;			/* WO */
1175d460eafSCathy Zhou 	int		smac_uppa;			/* WO */
1185d460eafSCathy Zhou 	uint32_t	smac_cnt;	/* WO, # of minor nodes */
119d62bc4baSyz147064 
1205d460eafSCathy Zhou 	kmutex_t	smac_mutex;
1215d460eafSCathy Zhou 	kcondvar_t	smac_cv;
1225d460eafSCathy Zhou 	softmac_state_t	smac_state;		/* smac_mutex */
123d62bc4baSyz147064 	/*
124d62bc4baSyz147064 	 * The smac_hold_cnt field increases when softmac_hold_device() is
125d62bc4baSyz147064 	 * called to force the dls_vlan_t of the device to be created.  The
126d62bc4baSyz147064 	 * device pre-detach fails if this counter is not 0.
127d62bc4baSyz147064 	 */
1285d460eafSCathy Zhou 	uint32_t	smac_hold_cnt;		/* smac_mutex */
1295d460eafSCathy Zhou 	uint32_t	smac_flags;		/* smac_mutex */
1305d460eafSCathy Zhou 	int		smac_attacherr;		/* smac_mutex */
131d62bc4baSyz147064 	mac_handle_t	smac_mh;
1325d460eafSCathy Zhou 	softmac_dev_t	*smac_softmac[2];	/* smac_mutex */
1335d460eafSCathy Zhou 
134d62bc4baSyz147064 	/*
135d62bc4baSyz147064 	 * Number of minor nodes whose post-attach routine has succeeded.
136d62bc4baSyz147064 	 * This should be the same as the numbers of softmac_dev_t.
137d62bc4baSyz147064 	 * Note that it does not imply SOFTMAC_ATTACH_DONE as the taskq might
138d62bc4baSyz147064 	 * be still ongoing.
139d62bc4baSyz147064 	 */
1405d460eafSCathy Zhou 	uint32_t	smac_attachok_cnt;	/* smac_mutex */
141d62bc4baSyz147064 	/*
142d62bc4baSyz147064 	 * Number of softmac_dev_t left when pre-detach fails. This is used
143d62bc4baSyz147064 	 * to indicate whether postattach is called because of a failed
144d62bc4baSyz147064 	 * pre-detach.
145d62bc4baSyz147064 	 */
1465d460eafSCathy Zhou 	uint32_t	smac_attached_left;	/* smac_mutex */
147d62bc4baSyz147064 
148d62bc4baSyz147064 	/*
149da14cebeSEric Cheng 	 * Thread handles the DL_NOTIFY_IND message from the lower stream.
150da14cebeSEric Cheng 	 */
1515d460eafSCathy Zhou 	kthread_t	*smac_notify_thread;	/* smac_mutex */
152da14cebeSEric Cheng 	/*
153da14cebeSEric Cheng 	 * Head and tail of the DL_NOTIFY_IND messsages.
154da14cebeSEric Cheng 	 */
1555d460eafSCathy Zhou 	mblk_t		*smac_notify_head;	/* smac_mutex */
1565d460eafSCathy Zhou 	mblk_t		*smac_notify_tail;	/* smac_mutex */
157da14cebeSEric Cheng 
158da14cebeSEric Cheng 	/*
159d62bc4baSyz147064 	 * The remaining fields are used to register the MAC for a legacy
160d62bc4baSyz147064 	 * device.  They are set in softmac_mac_register() and do not change.
161d62bc4baSyz147064 	 * One can access them when mac_register() is done without locks.
162d62bc4baSyz147064 	 */
163d62bc4baSyz147064 
164d62bc4baSyz147064 	/*
165d62bc4baSyz147064 	 * media type is needed for create <link name, linkid> mapping, so
166d62bc4baSyz147064 	 * it is set for GLDv3 device as well
167d62bc4baSyz147064 	 */
168d62bc4baSyz147064 	uint_t		smac_media;
169d62bc4baSyz147064 	/* DLPI style of the underlying device */
170d62bc4baSyz147064 	int		smac_style;
171d62bc4baSyz147064 	dev_t		smac_dev;
172d62bc4baSyz147064 	size_t		smac_saplen;
173d62bc4baSyz147064 	size_t		smac_addrlen;
174d62bc4baSyz147064 	uchar_t		smac_unicst_addr[MAXMACADDRLEN];
175d62bc4baSyz147064 	uint_t		smac_min_sdu;
176d62bc4baSyz147064 	uint_t		smac_max_sdu;
177d62bc4baSyz147064 	uint32_t	smac_margin;
178d62bc4baSyz147064 
179d62bc4baSyz147064 	/* Notifications the underlying driver can support. */
180d62bc4baSyz147064 	uint32_t	smac_notifications;
181d62bc4baSyz147064 
182d62bc4baSyz147064 	/*
183d62bc4baSyz147064 	 * Capabilities of the underlying driver.
184d62bc4baSyz147064 	 */
185d62bc4baSyz147064 	uint32_t	smac_capab_flags;
186d62bc4baSyz147064 	uint32_t	smac_hcksum_txflags;
187d62bc4baSyz147064 	boolean_t	smac_no_capability_req;
188d62bc4baSyz147064 
1895d460eafSCathy Zhou 	/*
1905d460eafSCathy Zhou 	 * Lower stream structure, accessed by the MAC provider API. The GLDv3
1915d460eafSCathy Zhou 	 * framework assures it's validity.
1925d460eafSCathy Zhou 	 */
193d62bc4baSyz147064 	softmac_lower_t	*smac_lower;
1945d460eafSCathy Zhou 
1955d460eafSCathy Zhou 	kmutex_t	smac_active_mutex;
1965d460eafSCathy Zhou 	/*
1975d460eafSCathy Zhou 	 * Set by xxx_active_set() when aggregation is created.
1985d460eafSCathy Zhou 	 */
1995d460eafSCathy Zhou 	boolean_t	smac_active;	/* smac_active_mutex */
2005d460eafSCathy Zhou 	/*
2015d460eafSCathy Zhou 	 * Numbers of the bounded streams in the fast-path mode.
2025d460eafSCathy Zhou 	 */
2035d460eafSCathy Zhou 	uint32_t	smac_nactive;	/* smac_active_mutex */
2045d460eafSCathy Zhou 
2055d460eafSCathy Zhou 	kmutex_t	smac_fp_mutex;
2065d460eafSCathy Zhou 	kcondvar_t	smac_fp_cv;
2075d460eafSCathy Zhou 	/*
2085d460eafSCathy Zhou 	 * numbers of clients that request to disable fastpath.
2095d460eafSCathy Zhou 	 */
2105d460eafSCathy Zhou 	uint32_t	smac_fp_disable_clients;	/* smac_fp_mutex */
2115d460eafSCathy Zhou 	boolean_t	smac_fastpath_admin_disabled;	/* smac_fp_mutex */
2125d460eafSCathy Zhou 
2135d460eafSCathy Zhou 	/*
2145d460eafSCathy Zhou 	 * stream list over this softmac.
2155d460eafSCathy Zhou 	 */
2165d460eafSCathy Zhou 	list_t			smac_sup_list;		/* smac_fp_mutex */
217d62bc4baSyz147064 } softmac_t;
218d62bc4baSyz147064 
219d62bc4baSyz147064 typedef struct smac_ioc_start_s {
220d62bc4baSyz147064 	softmac_lower_t	*si_slp;
221d62bc4baSyz147064 } smac_ioc_start_t;
222d62bc4baSyz147064 
223d62bc4baSyz147064 #define	SMAC_IOC	('S' << 24 | 'M' << 16 | 'C' << 8)
224d62bc4baSyz147064 #define	SMAC_IOC_START	(SMAC_IOC | 0x01)
225d62bc4baSyz147064 
2265d460eafSCathy Zhou /*
2275d460eafSCathy Zhou  * The su_mode of a non-IP/ARP stream is UNKNOWN, and the su_mode of an IP/ARP
2285d460eafSCathy Zhou  * stream is either SLOWPATH or FASTPATH.
2295d460eafSCathy Zhou  */
2305d460eafSCathy Zhou #define	SOFTMAC_UNKNOWN		0x00
2315d460eafSCathy Zhou #define	SOFTMAC_SLOWPATH	0x01
2325d460eafSCathy Zhou #define	SOFTMAC_FASTPATH	0x02
2335d460eafSCathy Zhou 
2345d460eafSCathy Zhou typedef struct softmac_switch_req_s {
2355d460eafSCathy Zhou 	list_node_t	ssq_req_list_node;
2365d460eafSCathy Zhou 	uint32_t	ssq_expected_mode;
2375d460eafSCathy Zhou } softmac_switch_req_t;
2385d460eafSCathy Zhou 
2395d460eafSCathy Zhou #define	DATAPATH_MODE(softmac)						\
2405d460eafSCathy Zhou 	((((softmac)->smac_fp_disable_clients != 0) ||			\
2415d460eafSCathy Zhou 	(softmac)->smac_fastpath_admin_disabled) ? SOFTMAC_SLOWPATH :	\
2425d460eafSCathy Zhou 	SOFTMAC_FASTPATH)
2435d460eafSCathy Zhou 
2445d460eafSCathy Zhou 
2455d460eafSCathy Zhou /*
2465d460eafSCathy Zhou  * Locking description:
2475d460eafSCathy Zhou  *
2485d460eafSCathy Zhou  *	WO: Set once and valid for life;
2495d460eafSCathy Zhou  *	SL: Serialized by the control path (softmac_wput_nondata_task())
2505d460eafSCathy Zhou  */
2515d460eafSCathy Zhou typedef struct softmac_upper_s {
2525d460eafSCathy Zhou 	softmac_t		*su_softmac;	/* WO */
2535d460eafSCathy Zhou 	queue_t			*su_rq;		/* WO */
2545d460eafSCathy Zhou 	queue_t			*su_wq;		/* WO */
2555d460eafSCathy Zhou 
2565d460eafSCathy Zhou 	/*
2575d460eafSCathy Zhou 	 * List of upper streams that has pending DLPI messages to be processed.
2585d460eafSCathy Zhou 	 */
2595d460eafSCathy Zhou 	list_node_t		su_taskq_list_node; /* softmac_taskq_lock */
2605d460eafSCathy Zhou 
2615d460eafSCathy Zhou 	/*
2625d460eafSCathy Zhou 	 * non-NULL for IP/ARP streams in the fast-path mode
2635d460eafSCathy Zhou 	 */
2645d460eafSCathy Zhou 	softmac_lower_t		*su_slp;	/* SL & su_mutex */
2655d460eafSCathy Zhou 
2665d460eafSCathy Zhou 	/*
2675d460eafSCathy Zhou 	 * List of all IP/ARP upperstreams on the same softmac (including
2685d460eafSCathy Zhou 	 * the ones in both data-path modes).
2695d460eafSCathy Zhou 	 */
2705d460eafSCathy Zhou 	list_node_t		su_list_node;	/* smac_fp_mutex */
2715d460eafSCathy Zhou 
2725d460eafSCathy Zhou 	/*
2735d460eafSCathy Zhou 	 * List of datapath switch requests.
2745d460eafSCathy Zhou 	 */
2755d460eafSCathy Zhou 	list_t			su_req_list;	/* smac_fp_mutex */
2765d460eafSCathy Zhou 
2775d460eafSCathy Zhou 	/*
2785d460eafSCathy Zhou 	 * Place holder of RX callbacks used to handles data messages comes
2795d460eafSCathy Zhou 	 * from the dedicated-lower-stream associated with the IP/ARP stream.
2805d460eafSCathy Zhou 	 * Another RX callback is softmac_drop_rxinfo, which is a global
2815d460eafSCathy Zhou 	 * variable.
2825d460eafSCathy Zhou 	 */
2835d460eafSCathy Zhou 	softmac_lower_rxinfo_t	su_rxinfo;		/* WO */
2845d460eafSCathy Zhou 	softmac_lower_rxinfo_t	su_direct_rxinfo;	/* WO */
2855d460eafSCathy Zhou 
2865d460eafSCathy Zhou 	/*
2875d460eafSCathy Zhou 	 * Used to serialize the DLPI operation and fastpath<->slowpath
2885d460eafSCathy Zhou 	 * switching over operation.
2895d460eafSCathy Zhou 	 */
2905d460eafSCathy Zhou 	kmutex_t		su_disp_mutex;
2915d460eafSCathy Zhou 	kcondvar_t		su_disp_cv;
2925d460eafSCathy Zhou 	mblk_t			*su_pending_head;	/* su_disp_mutex */
2935d460eafSCathy Zhou 	mblk_t			*su_pending_tail;	/* su_disp_mutex */
2945d460eafSCathy Zhou 	boolean_t		su_dlpi_pending;	/* su_disp_mutex */
2955d460eafSCathy Zhou 	boolean_t		su_closing;		/* su_disp_mutex */
2965d460eafSCathy Zhou 
2975d460eafSCathy Zhou 	uint32_t		su_bound : 1,		/* SL */
2985d460eafSCathy Zhou 				su_active : 1,		/* SL */
299bd670b35SErik Nordmark 				su_direct : 1,		/* SL */
300bd670b35SErik Nordmark 				su_is_arp : 1,
301bd670b35SErik Nordmark 				su_pad_to_32:28;
3025d460eafSCathy Zhou 
3035d460eafSCathy Zhou 	/*
3045d460eafSCathy Zhou 	 * Used for fastpath data path.
3055d460eafSCathy Zhou 	 */
3065d460eafSCathy Zhou 	kmutex_t		su_mutex;
3075d460eafSCathy Zhou 	kcondvar_t		su_cv;
3085d460eafSCathy Zhou 	mblk_t			*su_tx_flow_mp;		/* su_mutex */
3095d460eafSCathy Zhou 	boolean_t		su_tx_busy;		/* su_mutex */
3105d460eafSCathy Zhou 	/*
3115d460eafSCathy Zhou 	 * Number of softmac_srv() operation in fastpath processing.
3125d460eafSCathy Zhou 	 */
3135d460eafSCathy Zhou 	uint32_t		su_tx_inprocess;	/* su_mutex */
3145d460eafSCathy Zhou 	/*
3155d460eafSCathy Zhou 	 * SOFTMAC_SLOWPATH or SOFTMAC_FASTPATH
3165d460eafSCathy Zhou 	 */
3175d460eafSCathy Zhou 	uint32_t		su_mode;		/* SL & su_mutex */
3185d460eafSCathy Zhou 
3195d460eafSCathy Zhou 	/*
3205d460eafSCathy Zhou 	 * Whether this stream is already scheduled in softmac_taskq_list.
3215d460eafSCathy Zhou 	 */
3225d460eafSCathy Zhou 	boolean_t		su_taskq_scheduled;	/* softmac_taskq_lock */
32379eeb645SCathy Zhou 
32479eeb645SCathy Zhou 	/*
32579eeb645SCathy Zhou 	 * The DLD_CAPAB_DIRECT related notify callback.
32679eeb645SCathy Zhou 	 */
32779eeb645SCathy Zhou 	mac_tx_notify_t		su_tx_notify_func;	/* su_mutex */
32879eeb645SCathy Zhou 	void			*su_tx_notify_arg;	/* su_mutex */
3295d460eafSCathy Zhou } softmac_upper_t;
3305d460eafSCathy Zhou 
3315d460eafSCathy Zhou #define	SOFTMAC_EQ_PENDING(sup, mp) {					\
3325d460eafSCathy Zhou 	if ((sup)->su_pending_head == NULL) {				\
3335d460eafSCathy Zhou 		(sup)->su_pending_head = (sup)->su_pending_tail = (mp);	\
3345d460eafSCathy Zhou 	} else {							\
3355d460eafSCathy Zhou 		(sup)->su_pending_tail->b_next = (mp);			\
3365d460eafSCathy Zhou 		(sup)->su_pending_tail = (mp);				\
3375d460eafSCathy Zhou 	}								\
3385d460eafSCathy Zhou }
3395d460eafSCathy Zhou 
3405d460eafSCathy Zhou #define	SOFTMAC_DQ_PENDING(sup, mpp) {					\
3415d460eafSCathy Zhou 	if ((sup)->su_pending_head == NULL) {				\
3425d460eafSCathy Zhou 		*(mpp) = NULL;						\
3435d460eafSCathy Zhou 	} else {							\
3445d460eafSCathy Zhou 		*(mpp) = (sup)->su_pending_head;			\
3455d460eafSCathy Zhou 		if (((sup)->su_pending_head = (*(mpp))->b_next) == NULL)\
3465d460eafSCathy Zhou 			(sup)->su_pending_tail = NULL;			\
3475d460eafSCathy Zhou 		(*(mpp))->b_next = NULL;				\
3485d460eafSCathy Zhou 	}								\
3495d460eafSCathy Zhou }
3505d460eafSCathy Zhou 
3515d460eafSCathy Zhou /*
3525d460eafSCathy Zhou  * A macro to check whether the write-queue of the lower stream is full
3535d460eafSCathy Zhou  * and packets need to be enqueued.
3545d460eafSCathy Zhou  *
3555d460eafSCathy Zhou  * Because softmac is pushed right above the underlying device and
3565d460eafSCathy Zhou  * _I_INSERT/_I_REMOVE is not processed in the lower stream, it is
3575d460eafSCathy Zhou  * safe to directly access the q_next pointer.
3585d460eafSCathy Zhou  */
3595d460eafSCathy Zhou #define	SOFTMAC_CANPUTNEXT(q)	\
3605d460eafSCathy Zhou 	(!((q)->q_next->q_nfsrv->q_flag & QFULL) || canput((q)->q_next))
3615d460eafSCathy Zhou 
3625d460eafSCathy Zhou 
363d62bc4baSyz147064 extern dev_info_t		*softmac_dip;
364d62bc4baSyz147064 #define	SOFTMAC_DEV_NAME	"softmac"
365d62bc4baSyz147064 
366d62bc4baSyz147064 extern int	softmac_send_bind_req(softmac_lower_t *, uint_t);
3675d460eafSCathy Zhou extern int	softmac_send_unbind_req(softmac_lower_t *);
368d62bc4baSyz147064 extern int	softmac_send_notify_req(softmac_lower_t *, uint32_t);
369d62bc4baSyz147064 extern int	softmac_send_promisc_req(softmac_lower_t *, t_uscalar_t,
370d62bc4baSyz147064     boolean_t);
3715d460eafSCathy Zhou extern void	softmac_init();
3725d460eafSCathy Zhou extern void	softmac_fini();
3735d460eafSCathy Zhou extern void	softmac_fp_init();
3745d460eafSCathy Zhou extern void	softmac_fp_fini();
3755d460eafSCathy Zhou extern boolean_t softmac_busy();
376d62bc4baSyz147064 extern int	softmac_fill_capab(ldi_handle_t, softmac_t *);
377d62bc4baSyz147064 extern int	softmac_capab_enable(softmac_lower_t *);
3785d460eafSCathy Zhou extern void	softmac_rput_process_notdata(queue_t *, softmac_upper_t *,
3795d460eafSCathy Zhou     mblk_t *);
380d62bc4baSyz147064 extern void	softmac_rput_process_data(softmac_lower_t *, mblk_t *);
3815d460eafSCathy Zhou extern int	softmac_output(softmac_lower_t *, mblk_t *, t_uscalar_t,
3825d460eafSCathy Zhou     t_uscalar_t, mblk_t **);
3835d460eafSCathy Zhou extern int	softmac_mexchange_error_ack(mblk_t **, t_uscalar_t,
3845d460eafSCathy Zhou     t_uscalar_t, t_uscalar_t);
385d62bc4baSyz147064 
386d62bc4baSyz147064 extern int	softmac_m_promisc(void *, boolean_t);
387d62bc4baSyz147064 extern int	softmac_m_multicst(void *, boolean_t, const uint8_t *);
388d62bc4baSyz147064 extern int	softmac_m_unicst(void *, const uint8_t *);
389d62bc4baSyz147064 extern void	softmac_m_ioctl(void *, queue_t *, mblk_t *);
390d62bc4baSyz147064 extern int	softmac_m_stat(void *, uint_t, uint64_t *);
391d62bc4baSyz147064 extern mblk_t	*softmac_m_tx(void *, mblk_t *);
392d62bc4baSyz147064 extern int	softmac_proto_tx(softmac_lower_t *, mblk_t *, mblk_t **);
393d62bc4baSyz147064 extern void	softmac_ioctl_tx(softmac_lower_t *, mblk_t *, mblk_t **);
394da14cebeSEric Cheng extern void	softmac_notify_thread(void *);
395d62bc4baSyz147064 
3965d460eafSCathy Zhou extern int	softmac_hold(dev_t, softmac_t **);
3975d460eafSCathy Zhou extern void	softmac_rele(softmac_t *);
3985d460eafSCathy Zhou extern int	softmac_lower_setup(softmac_t *, softmac_upper_t *,
3995d460eafSCathy Zhou     softmac_lower_t **);
4005d460eafSCathy Zhou extern boolean_t	softmac_active_set(void *);
4015d460eafSCathy Zhou extern void	softmac_active_clear(void *);
4025d460eafSCathy Zhou extern int	softmac_fastpath_disable(void *);
4035d460eafSCathy Zhou extern void	softmac_fastpath_enable(void *);
4045d460eafSCathy Zhou extern int	softmac_datapath_switch(softmac_t *, boolean_t, boolean_t);
4055d460eafSCathy Zhou 
4065d460eafSCathy Zhou extern void	softmac_wput_data(softmac_upper_t *, mblk_t *);
4075d460eafSCathy Zhou extern void	softmac_wput_nondata(softmac_upper_t *, mblk_t *);
4085d460eafSCathy Zhou extern void	softmac_upperstream_close(softmac_upper_t *);
4095d460eafSCathy Zhou 
410d62bc4baSyz147064 #ifdef	__cplusplus
411d62bc4baSyz147064 }
412d62bc4baSyz147064 #endif
413d62bc4baSyz147064 
414d62bc4baSyz147064 #endif	/* _SYS_SOFTMAC_IMPL_H */
415