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