xref: /OK3568_Linux_fs/external/rkwifibt/drivers/bcmdhd/wl_iw.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Linux Wireless Extensions support
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (C) 1999-2017, Broadcom Corporation
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  *      Unless you and Broadcom execute a separate written software license
7*4882a593Smuzhiyun  * agreement governing use of this software, this software is licensed to you
8*4882a593Smuzhiyun  * under the terms of the GNU General Public License version 2 (the "GPL"),
9*4882a593Smuzhiyun  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10*4882a593Smuzhiyun  * following added to such license:
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  *      As a special exception, the copyright holders of this software give you
13*4882a593Smuzhiyun  * permission to link this software with independent modules, and to copy and
14*4882a593Smuzhiyun  * distribute the resulting executable under terms of your choice, provided that
15*4882a593Smuzhiyun  * you also meet, for each linked independent module, the terms and conditions of
16*4882a593Smuzhiyun  * the license of that module.  An independent module is a module which is not
17*4882a593Smuzhiyun  * derived from this software.  The special exception does not apply to any
18*4882a593Smuzhiyun  * modifications of the software.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  *      Notwithstanding the above, under no circumstances may you combine this
21*4882a593Smuzhiyun  * software in any way with any other Broadcom software provided under a license
22*4882a593Smuzhiyun  * other than the GPL, without Broadcom's express prior written consent.
23*4882a593Smuzhiyun  *
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  * <<Broadcom-WL-IPTag/Open:>>
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  * $Id: wl_iw.h 514727 2014-11-12 03:02:48Z $
28*4882a593Smuzhiyun  */
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #ifndef _wl_iw_h_
31*4882a593Smuzhiyun #define _wl_iw_h_
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #include <linux/wireless.h>
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #include <typedefs.h>
36*4882a593Smuzhiyun #include <ethernet.h>
37*4882a593Smuzhiyun #include <wlioctl.h>
38*4882a593Smuzhiyun #include <dngl_stats.h>
39*4882a593Smuzhiyun #include <dhd.h>
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
42*4882a593Smuzhiyun #define get_ds()    (KERNEL_DS)
43*4882a593Smuzhiyun #endif
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #define WL_SCAN_PARAMS_SSID_MAX 	10
46*4882a593Smuzhiyun #define GET_SSID			"SSID="
47*4882a593Smuzhiyun #define GET_CHANNEL			"CH="
48*4882a593Smuzhiyun #define GET_NPROBE 			"NPROBE="
49*4882a593Smuzhiyun #define GET_ACTIVE_ASSOC_DWELL  	"ACTIVE="
50*4882a593Smuzhiyun #define GET_PASSIVE_ASSOC_DWELL  	"PASSIVE="
51*4882a593Smuzhiyun #define GET_HOME_DWELL  		"HOME="
52*4882a593Smuzhiyun #define GET_SCAN_TYPE			"TYPE="
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun #define BAND_GET_CMD				"GETBAND"
55*4882a593Smuzhiyun #define BAND_SET_CMD				"SETBAND"
56*4882a593Smuzhiyun #define DTIM_SKIP_GET_CMD			"DTIMSKIPGET"
57*4882a593Smuzhiyun #define DTIM_SKIP_SET_CMD			"DTIMSKIPSET"
58*4882a593Smuzhiyun #define SETSUSPEND_CMD				"SETSUSPENDOPT"
59*4882a593Smuzhiyun #define PNOSSIDCLR_SET_CMD			"PNOSSIDCLR"
60*4882a593Smuzhiyun /* Lin - Is the extra space needed? */
61*4882a593Smuzhiyun #define PNOSETUP_SET_CMD			"PNOSETUP " /* TLV command has extra end space */
62*4882a593Smuzhiyun #define PNOENABLE_SET_CMD			"PNOFORCE"
63*4882a593Smuzhiyun #define PNODEBUG_SET_CMD			"PNODEBUG"
64*4882a593Smuzhiyun #define TXPOWER_SET_CMD			"TXPOWER"
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
67*4882a593Smuzhiyun #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun /* Structure to keep global parameters */
70*4882a593Smuzhiyun typedef struct wl_iw_extra_params {
71*4882a593Smuzhiyun 	int 	target_channel; /* target channel */
72*4882a593Smuzhiyun } wl_iw_extra_params_t;
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun /* ============================================== */
75*4882a593Smuzhiyun /* Defines from wlc_pub.h */
76*4882a593Smuzhiyun #define	WL_IW_RSSI_MINVAL		-200	/* Low value, e.g. for forcing roam */
77*4882a593Smuzhiyun #define	WL_IW_RSSI_NO_SIGNAL	-91	/* NDIS RSSI link quality cutoffs */
78*4882a593Smuzhiyun #define	WL_IW_RSSI_VERY_LOW	-80	/* Very low quality cutoffs */
79*4882a593Smuzhiyun #define	WL_IW_RSSI_LOW		-70	/* Low quality cutoffs */
80*4882a593Smuzhiyun #define	WL_IW_RSSI_GOOD		-68	/* Good quality cutoffs */
81*4882a593Smuzhiyun #define	WL_IW_RSSI_VERY_GOOD	-58	/* Very good quality cutoffs */
82*4882a593Smuzhiyun #define	WL_IW_RSSI_EXCELLENT	-57	/* Excellent quality cutoffs */
83*4882a593Smuzhiyun #define	WL_IW_RSSI_INVALID	 0	/* invalid RSSI value */
84*4882a593Smuzhiyun #define MAX_WX_STRING 80
85*4882a593Smuzhiyun #define SSID_FMT_BUF_LEN	((4 * 32) + 1)
86*4882a593Smuzhiyun #define isprint(c) bcm_isprint(c)
87*4882a593Smuzhiyun #define WL_IW_SET_ACTIVE_SCAN	(SIOCIWFIRSTPRIV+1)
88*4882a593Smuzhiyun #define WL_IW_GET_RSSI			(SIOCIWFIRSTPRIV+3)
89*4882a593Smuzhiyun #define WL_IW_SET_PASSIVE_SCAN	(SIOCIWFIRSTPRIV+5)
90*4882a593Smuzhiyun #define WL_IW_GET_LINK_SPEED	(SIOCIWFIRSTPRIV+7)
91*4882a593Smuzhiyun #define WL_IW_GET_CURR_MACADDR	(SIOCIWFIRSTPRIV+9)
92*4882a593Smuzhiyun #define WL_IW_SET_STOP				(SIOCIWFIRSTPRIV+11)
93*4882a593Smuzhiyun #define WL_IW_SET_START			(SIOCIWFIRSTPRIV+13)
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun #define 		G_SCAN_RESULTS 8*1024
96*4882a593Smuzhiyun #define 		WE_ADD_EVENT_FIX	0x80
97*4882a593Smuzhiyun #define          G_WLAN_SET_ON	0
98*4882a593Smuzhiyun #define          G_WLAN_SET_OFF	1
99*4882a593Smuzhiyun 
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun typedef struct wl_iw {
102*4882a593Smuzhiyun 	char nickname[IW_ESSID_MAX_SIZE];
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun 	struct iw_statistics wstats;
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun 	int spy_num;
107*4882a593Smuzhiyun 	uint32 pwsec;			/* pairwise wsec setting */
108*4882a593Smuzhiyun 	uint32 gwsec;			/* group wsec setting  */
109*4882a593Smuzhiyun 	bool privacy_invoked; 		/* IW_AUTH_PRIVACY_INVOKED setting */
110*4882a593Smuzhiyun 	struct ether_addr spy_addr[IW_MAX_SPY];
111*4882a593Smuzhiyun 	struct iw_quality spy_qual[IW_MAX_SPY];
112*4882a593Smuzhiyun 	void  *wlinfo;
113*4882a593Smuzhiyun } wl_iw_t;
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun struct wl_ctrl {
116*4882a593Smuzhiyun 	timer_list_compat_t *timer;
117*4882a593Smuzhiyun 	struct net_device *dev;
118*4882a593Smuzhiyun 	long sysioc_pid;
119*4882a593Smuzhiyun 	struct semaphore sysioc_sem;
120*4882a593Smuzhiyun 	struct completion sysioc_exited;
121*4882a593Smuzhiyun };
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun #if WIRELESS_EXT > 12
125*4882a593Smuzhiyun #include <net/iw_handler.h>
126*4882a593Smuzhiyun extern const struct iw_handler_def wl_iw_handler_def;
127*4882a593Smuzhiyun #endif /* WIRELESS_EXT > 12 */
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun extern int wl_iw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
130*4882a593Smuzhiyun extern int wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats);
131*4882a593Smuzhiyun int wl_iw_send_priv_event(struct net_device *dev, char *flag);
132*4882a593Smuzhiyun int wl_iw_attach(struct net_device *dev);
133*4882a593Smuzhiyun void wl_iw_detach(struct net_device *dev);
134*4882a593Smuzhiyun s32 wl_iw_autochannel(struct net_device *dev, char* command, int total_len);
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun /* message levels */
137*4882a593Smuzhiyun #define WL_ERROR_LEVEL	(1 << 0)
138*4882a593Smuzhiyun #define WL_TRACE_LEVEL	(1 << 1)
139*4882a593Smuzhiyun #define WL_INFO_LEVEL	(1 << 2)
140*4882a593Smuzhiyun #define WL_SCAN_LEVEL	(1 << 3)
141*4882a593Smuzhiyun #define WL_WSEC_LEVEL	(1 << 4)
142*4882a593Smuzhiyun 
143*4882a593Smuzhiyun #define CSCAN_COMMAND				"CSCAN "
144*4882a593Smuzhiyun #define CSCAN_TLV_PREFIX 			'S'
145*4882a593Smuzhiyun #define CSCAN_TLV_VERSION			1
146*4882a593Smuzhiyun #define CSCAN_TLV_SUBVERSION			0
147*4882a593Smuzhiyun #define CSCAN_TLV_TYPE_SSID_IE          'S'
148*4882a593Smuzhiyun #define CSCAN_TLV_TYPE_CHANNEL_IE   'C'
149*4882a593Smuzhiyun #define CSCAN_TLV_TYPE_NPROBE_IE     'N'
150*4882a593Smuzhiyun #define CSCAN_TLV_TYPE_ACTIVE_IE      'A'
151*4882a593Smuzhiyun #define CSCAN_TLV_TYPE_PASSIVE_IE    'P'
152*4882a593Smuzhiyun #define CSCAN_TLV_TYPE_HOME_IE         'H'
153*4882a593Smuzhiyun #define CSCAN_TLV_TYPE_STYPE_IE        'T'
154*4882a593Smuzhiyun 
155*4882a593Smuzhiyun #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
156*4882a593Smuzhiyun #define IWE_STREAM_ADD_EVENT(info, stream, ends, iwe, extra) \
157*4882a593Smuzhiyun 	iwe_stream_add_event(info, stream, ends, iwe, extra)
158*4882a593Smuzhiyun #define IWE_STREAM_ADD_VALUE(info, event, value, ends, iwe, event_len) \
159*4882a593Smuzhiyun 	iwe_stream_add_value(info, event, value, ends, iwe, event_len)
160*4882a593Smuzhiyun #define IWE_STREAM_ADD_POINT(info, stream, ends, iwe, extra) \
161*4882a593Smuzhiyun 	iwe_stream_add_point(info, stream, ends, iwe, extra)
162*4882a593Smuzhiyun #else
163*4882a593Smuzhiyun #define IWE_STREAM_ADD_EVENT(info, stream, ends, iwe, extra) \
164*4882a593Smuzhiyun 	iwe_stream_add_event(stream, ends, iwe, extra)
165*4882a593Smuzhiyun #define IWE_STREAM_ADD_VALUE(info, event, value, ends, iwe, event_len) \
166*4882a593Smuzhiyun 	iwe_stream_add_value(event, value, ends, iwe, event_len)
167*4882a593Smuzhiyun #define IWE_STREAM_ADD_POINT(info, stream, ends, iwe, extra) \
168*4882a593Smuzhiyun 	iwe_stream_add_point(stream, ends, iwe, extra)
169*4882a593Smuzhiyun #endif
170*4882a593Smuzhiyun 
171*4882a593Smuzhiyun #endif /* _wl_iw_h_ */
172