blob: dab787542c45d6d9efc2c67ea2e1dfc16443cc20 [file] [log] [blame]
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001/*
Tracey Dentde171bd2010-09-20 21:19:41 -04002 This file contains wireless extension handlers.
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08003
Tracey Dentde171bd2010-09-20 21:19:41 -04004 This is part of rtl8180 OpenSource driver.
Andrea Merello559a4c32013-08-26 13:53:30 +02005 Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com>
Tracey Dentde171bd2010-09-20 21:19:41 -04006 Released under the terms of GPL (General Public Licence)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08007
Tracey Dentde171bd2010-09-20 21:19:41 -04008 Parts of this driver are based on the GPL part
9 of the official realtek driver.
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080010
Tracey Dentde171bd2010-09-20 21:19:41 -040011 Parts of this driver are based on the rtl8180 driver skeleton
12 from Patric Schenke & Andres Salomon.
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080013
Tracey Dentde171bd2010-09-20 21:19:41 -040014 Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080015
Justin P. Mattocked2cb4f2012-04-17 06:56:43 -070016 We want to thanks the Authors of those projects and the Ndiswrapper
Tracey Dentde171bd2010-09-20 21:19:41 -040017 project Authors.
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080018*/
19
20
21#include "r8180.h"
22#include "r8180_hw.h"
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080023
Bartlomiej Zolnierkiewiczfd9b8d62009-06-12 18:28:35 +020024#include "ieee80211/dot11d.h"
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080025
Tracey Dentde171bd2010-09-20 21:19:41 -040026u32 rtl8180_rates[] = {1000000, 2000000, 5500000, 11000000,
27 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000};
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080028
Stoyan Gaydarovb6ac1612009-07-21 22:02:27 -050029#define RATE_COUNT ARRAY_SIZE(rtl8180_rates)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080030
31static CHANNEL_LIST DefaultChannelPlan[] = {
Andrew Miller40ec6c52012-03-15 19:32:08 -040032 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64}, 19}, /* FCC */
33 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11}, /* IC */
34 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, /* ETSI */
35 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, /* Spain. Change to ETSI. */
36 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, /* France. Change to ETSI. */
37 {{14, 36, 40, 44, 48, 52, 56, 60, 64}, 9}, /* MKK */
38 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22}, /* MKK1 */
39 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, /* Israel */
40 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 34, 38, 42, 46}, 17}, /* For 11a , TELEC */
41 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14} /* For Global Domain. 1-11:active scan, 12-14 passive scan.*/ /* +YJ, 080626 */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080042};
43static int r8180_wx_get_freq(struct net_device *dev,
44 struct iw_request_info *a,
45 union iwreq_data *wrqu, char *b)
46{
47 struct r8180_priv *priv = ieee80211_priv(dev);
48
49 return ieee80211_wx_get_freq(priv->ieee80211, a, wrqu, b);
50}
51
52
53int r8180_wx_set_key(struct net_device *dev, struct iw_request_info *info,
54 union iwreq_data *wrqu, char *key)
55{
56 struct r8180_priv *priv = ieee80211_priv(dev);
57 struct iw_point *erq = &(wrqu->encoding);
58
Tracey Dentde171bd2010-09-20 21:19:41 -040059 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080060 return 0;
61
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080062 if (erq->length > 0) {
Tracey Dentde171bd2010-09-20 21:19:41 -040063 u32* tkey = (u32*) key;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080064 priv->key0[0] = tkey[0];
65 priv->key0[1] = tkey[1];
66 priv->key0[2] = tkey[2];
Tracey Dentde171bd2010-09-20 21:19:41 -040067 priv->key0[3] = tkey[3] & 0xff;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080068 DMESG("Setting wep key to %x %x %x %x",
Tracey Dentde171bd2010-09-20 21:19:41 -040069 tkey[0], tkey[1], tkey[2], tkey[3]);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080070 rtl8180_set_hw_wep(dev);
71 }
72 return 0;
73}
74
75
76static int r8180_wx_set_beaconinterval(struct net_device *dev, struct iw_request_info *aa,
77 union iwreq_data *wrqu, char *b)
78{
79 int *parms = (int *)b;
80 int bi = parms[0];
81
82 struct r8180_priv *priv = ieee80211_priv(dev);
83
Tracey Dentde171bd2010-09-20 21:19:41 -040084 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080085 return 0;
86
87 down(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -040088 DMESG("setting beacon interval to %x", bi);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080089
Tracey Dentde171bd2010-09-20 21:19:41 -040090 priv->ieee80211->current_network.beacon_interval = bi;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -080091 rtl8180_commit(dev);
92 up(&priv->wx_sem);
93
94 return 0;
95}
96
97
98
99static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
100 union iwreq_data *wrqu, char *b)
101{
102 struct r8180_priv *priv = ieee80211_priv(dev);
Tracey Dentde171bd2010-09-20 21:19:41 -0400103 return ieee80211_wx_get_mode(priv->ieee80211, a, wrqu, b);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800104}
105
106
107
108static int r8180_wx_get_rate(struct net_device *dev,
109 struct iw_request_info *info,
110 union iwreq_data *wrqu, char *extra)
111{
112 struct r8180_priv *priv = ieee80211_priv(dev);
Tracey Dentde171bd2010-09-20 21:19:41 -0400113 return ieee80211_wx_get_rate(priv->ieee80211, info, wrqu, extra);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800114}
115
116
117
118static int r8180_wx_set_rate(struct net_device *dev,
119 struct iw_request_info *info,
120 union iwreq_data *wrqu, char *extra)
121{
122 int ret;
123 struct r8180_priv *priv = ieee80211_priv(dev);
124
125
Tracey Dentde171bd2010-09-20 21:19:41 -0400126 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800127 return 0;
128
129 down(&priv->wx_sem);
130
Tracey Dentde171bd2010-09-20 21:19:41 -0400131 ret = ieee80211_wx_set_rate(priv->ieee80211, info, wrqu, extra);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800132
133 up(&priv->wx_sem);
134
135 return ret;
136}
137
138
139static int r8180_wx_set_crcmon(struct net_device *dev,
140 struct iw_request_info *info,
141 union iwreq_data *wrqu, char *extra)
142{
143 struct r8180_priv *priv = ieee80211_priv(dev);
144 int *parms = (int *)extra;
145 int enable = (parms[0] > 0);
146 short prev = priv->crcmon;
147
148
Tracey Dentde171bd2010-09-20 21:19:41 -0400149 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800150 return 0;
151
152 down(&priv->wx_sem);
153
Tracey Dentde171bd2010-09-20 21:19:41 -0400154 if (enable)
155 priv->crcmon = 1;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800156 else
Tracey Dentde171bd2010-09-20 21:19:41 -0400157 priv->crcmon = 0;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800158
159 DMESG("bad CRC in monitor mode are %s",
160 priv->crcmon ? "accepted" : "rejected");
161
Tracey Dentde171bd2010-09-20 21:19:41 -0400162 if (prev != priv->crcmon && priv->up) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800163 rtl8180_down(dev);
164 rtl8180_up(dev);
165 }
166
167 up(&priv->wx_sem);
168
169 return 0;
170}
171
172
173static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
174 union iwreq_data *wrqu, char *b)
175{
176 struct r8180_priv *priv = ieee80211_priv(dev);
177 int ret;
178
179
Tracey Dentde171bd2010-09-20 21:19:41 -0400180 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800181 return 0;
182
183 down(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -0400184 if (priv->bInactivePs) {
185 if (wrqu->mode == IW_MODE_ADHOC)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800186 IPSLeave(dev);
187 }
Tracey Dentde171bd2010-09-20 21:19:41 -0400188 ret = ieee80211_wx_set_mode(priv->ieee80211, a, wrqu, b);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800189
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800190 up(&priv->wx_sem);
191 return ret;
192}
193
Tracey Dentde171bd2010-09-20 21:19:41 -0400194/* YJ,add,080819,for hidden ap */
195struct iw_range_with_scan_capa {
Andrew Miller40ec6c52012-03-15 19:32:08 -0400196 /* Informative stuff (to choose between different interface) */
197
198 __u32 throughput; /* To give an idea... */
199
Tracey Dentde171bd2010-09-20 21:19:41 -0400200 /* In theory this value should be the maximum benchmarked
Andrew Miller40ec6c52012-03-15 19:32:08 -0400201 * TCP/IP throughput, because with most of these devices the
202 * bit rate is meaningless (overhead an co) to estimate how
203 * fast the connection will go and pick the fastest one.
204 * I suggest people to play with Netperf or any benchmark...
205 */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800206
Tracey Dentde171bd2010-09-20 21:19:41 -0400207 /* NWID (or domain id) */
Andrew Miller40ec6c52012-03-15 19:32:08 -0400208 __u32 min_nwid; /* Minimal NWID we are able to set */
209 __u32 max_nwid; /* Maximal NWID we are able to set */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800210
Tracey Dentde171bd2010-09-20 21:19:41 -0400211 /* Old Frequency (backward compat - moved lower ) */
212 __u16 old_num_channels;
213 __u8 old_num_frequency;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800214
Tracey Dentde171bd2010-09-20 21:19:41 -0400215 /* Scan capabilities */
216 __u8 scan_capa;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800217};
Tracey Dentde171bd2010-09-20 21:19:41 -0400218/* YJ,add,080819,for hidden ap */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800219
220
221static int rtl8180_wx_get_range(struct net_device *dev,
222 struct iw_request_info *info,
223 union iwreq_data *wrqu, char *extra)
224{
225 struct iw_range *range = (struct iw_range *)extra;
226 struct r8180_priv *priv = ieee80211_priv(dev);
227 u16 val;
228 int i;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800229
230 wrqu->data.length = sizeof(*range);
231 memset(range, 0, sizeof(*range));
232
233 /* Let's try to keep this struct in the same order as in
234 * linux/include/wireless.h
235 */
236
237 /* TODO: See what values we can set, and remove the ones we can't
238 * set, or fill them with some default data.
239 */
240
241 /* ~5 Mb/s real (802.11b) */
242 range->throughput = 5 * 1000 * 1000;
243
Tracey Dentde171bd2010-09-20 21:19:41 -0400244 /* TODO: Not used in 802.11b? */
245/* range->min_nwid; */ /* Minimal NWID we are able to set */
246 /* TODO: Not used in 802.11b? */
247/* range->max_nwid; */ /* Maximal NWID we are able to set */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800248
Tracey Dentde171bd2010-09-20 21:19:41 -0400249 /* Old Frequency (backward compat - moved lower ) */
250/* range->old_num_channels; */
251/* range->old_num_frequency; */
252/* range->old_freq[6]; */ /* Filler to keep "version" at the same offset */
253 if (priv->rf_set_sens != NULL)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800254 range->sensitivity = priv->max_sens; /* signal level threshold range */
255
256 range->max_qual.qual = 100;
257 /* TODO: Find real max RSSI and stick here */
258 range->max_qual.level = 0;
259 range->max_qual.noise = -98;
260 range->max_qual.updated = 7; /* Updated all three */
261
262 range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */
André Goddard Rosabbc9a992009-11-14 13:09:06 -0200263 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800264 range->avg_qual.level = 20 + -98;
265 range->avg_qual.noise = 0;
266 range->avg_qual.updated = 7; /* Updated all three */
267
268 range->num_bitrates = RATE_COUNT;
269
Tracey Dentde171bd2010-09-20 21:19:41 -0400270 for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800271 range->bitrate[i] = rtl8180_rates[i];
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800272
273 range->min_frag = MIN_FRAG_THRESHOLD;
274 range->max_frag = MAX_FRAG_THRESHOLD;
275
276 range->pm_capa = 0;
277
278 range->we_version_compiled = WIRELESS_EXT;
279 range->we_version_source = 16;
280
Tracey Dentde171bd2010-09-20 21:19:41 -0400281 range->num_channels = 14;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800282
283 for (i = 0, val = 0; i < 14; i++) {
284
Tracey Dentde171bd2010-09-20 21:19:41 -0400285 /* Include only legal frequencies for some countries */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800286 if ((GET_DOT11D_INFO(priv->ieee80211)->channel_map)[i+1]) {
Tracey Dentde171bd2010-09-20 21:19:41 -0400287 range->freq[val].i = i + 1;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800288 range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000;
289 range->freq[val].e = 1;
290 val++;
291 } else {
Andrew Miller40ec6c52012-03-15 19:32:08 -0400292 /* FIXME: do we need to set anything for channels */
293 /* we don't use ? */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800294 }
295
296 if (val == IW_MAX_FREQUENCIES)
297 break;
298 }
299
300 range->num_frequency = val;
301 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
Tracey Dentde171bd2010-09-20 21:19:41 -0400302 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800303
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800304 return 0;
305}
306
307
308static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
309 union iwreq_data *wrqu, char *b)
310{
311 struct r8180_priv *priv = ieee80211_priv(dev);
312 int ret;
313 struct ieee80211_device* ieee = priv->ieee80211;
314
315
Tracey Dentde171bd2010-09-20 21:19:41 -0400316 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800317 return 0;
318
Tracey Dentde171bd2010-09-20 21:19:41 -0400319 if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800320 struct iw_scan_req* req = (struct iw_scan_req*)b;
Tracey Dentde171bd2010-09-20 21:19:41 -0400321 if (req->essid_len) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800322 ieee->current_network.ssid_len = req->essid_len;
323 memcpy(ieee->current_network.ssid, req->essid, req->essid_len);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800324 }
325 }
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800326
327 down(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -0400328 if (priv->up) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800329 priv->ieee80211->actscanning = true;
Tracey Dentde171bd2010-09-20 21:19:41 -0400330 if (priv->bInactivePs && (priv->ieee80211->state != IEEE80211_LINKED)) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800331 IPSLeave(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800332 ieee80211_softmac_ips_scan_syncro(priv->ieee80211);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800333 ret = 0;
Tracey Dentde171bd2010-09-20 21:19:41 -0400334 } else {
Andrew Millere7e298e2012-03-15 19:32:07 -0400335 /* prevent scan in BusyTraffic */
Tracey Dentde171bd2010-09-20 21:19:41 -0400336 /* FIXME: Need to consider last scan time */
337 if ((priv->link_detect.bBusyTraffic) && (true)) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800338 ret = 0;
339 printk("Now traffic is busy, please try later!\n");
Tracey Dentde171bd2010-09-20 21:19:41 -0400340 } else
Andrew Millere7e298e2012-03-15 19:32:07 -0400341 /* prevent scan in BusyTraffic,end */
Tracey Dentde171bd2010-09-20 21:19:41 -0400342 ret = ieee80211_wx_set_scan(priv->ieee80211, a, wrqu, b);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800343 }
Tracey Dentde171bd2010-09-20 21:19:41 -0400344 } else
345 ret = -1;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800346
347 up(&priv->wx_sem);
348
349 return ret;
350}
351
352
353static int r8180_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
354 union iwreq_data *wrqu, char *b)
355{
356
357 int ret;
358 struct r8180_priv *priv = ieee80211_priv(dev);
359
360 down(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -0400361 if (priv->up)
362 ret = ieee80211_wx_get_scan(priv->ieee80211, a, wrqu, b);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800363 else
364 ret = -1;
365
366 up(&priv->wx_sem);
367 return ret;
368}
369
370
371static int r8180_wx_set_essid(struct net_device *dev,
372 struct iw_request_info *a,
373 union iwreq_data *wrqu, char *b)
374{
375 struct r8180_priv *priv = ieee80211_priv(dev);
376
377 int ret;
378
Tracey Dentde171bd2010-09-20 21:19:41 -0400379 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800380 return 0;
381
382 down(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -0400383 if (priv->bInactivePs)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800384 IPSLeave(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800385
Tracey Dentde171bd2010-09-20 21:19:41 -0400386 ret = ieee80211_wx_set_essid(priv->ieee80211, a, wrqu, b);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800387
388 up(&priv->wx_sem);
389 return ret;
390}
391
392
393static int r8180_wx_get_essid(struct net_device *dev,
394 struct iw_request_info *a,
395 union iwreq_data *wrqu, char *b)
396{
397 int ret;
398 struct r8180_priv *priv = ieee80211_priv(dev);
399
400 down(&priv->wx_sem);
401
402 ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b);
403
404 up(&priv->wx_sem);
405
406 return ret;
407}
408
409
410static int r8180_wx_set_freq(struct net_device *dev, struct iw_request_info *a,
411 union iwreq_data *wrqu, char *b)
412{
413 int ret;
414 struct r8180_priv *priv = ieee80211_priv(dev);
415
416
Tracey Dentde171bd2010-09-20 21:19:41 -0400417 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800418 return 0;
419
420 down(&priv->wx_sem);
421
422 ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b);
423
424 up(&priv->wx_sem);
425 return ret;
426}
427
428
429static int r8180_wx_get_name(struct net_device *dev,
430 struct iw_request_info *info,
431 union iwreq_data *wrqu, char *extra)
432{
433 struct r8180_priv *priv = ieee80211_priv(dev);
434 return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra);
435}
436
437static int r8180_wx_set_frag(struct net_device *dev,
438 struct iw_request_info *info,
439 union iwreq_data *wrqu, char *extra)
440{
441 struct r8180_priv *priv = ieee80211_priv(dev);
442
Tracey Dentde171bd2010-09-20 21:19:41 -0400443 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800444 return 0;
445
446 if (wrqu->frag.disabled)
447 priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
448 else {
449 if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
450 wrqu->frag.value > MAX_FRAG_THRESHOLD)
451 return -EINVAL;
452
453 priv->ieee80211->fts = wrqu->frag.value & ~0x1;
454 }
455
456 return 0;
457}
458
459
460static int r8180_wx_get_frag(struct net_device *dev,
461 struct iw_request_info *info,
462 union iwreq_data *wrqu, char *extra)
463{
464 struct r8180_priv *priv = ieee80211_priv(dev);
465
466 wrqu->frag.value = priv->ieee80211->fts;
467 wrqu->frag.fixed = 0; /* no auto select */
468 wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD);
469
470 return 0;
471}
472
473
474static int r8180_wx_set_wap(struct net_device *dev,
475 struct iw_request_info *info,
476 union iwreq_data *awrq,
477 char *extra)
478{
479 int ret;
480 struct r8180_priv *priv = ieee80211_priv(dev);
481
Tracey Dentde171bd2010-09-20 21:19:41 -0400482 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800483 return 0;
484
485 down(&priv->wx_sem);
486
Tracey Dentde171bd2010-09-20 21:19:41 -0400487 ret = ieee80211_wx_set_wap(priv->ieee80211, info, awrq, extra);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800488
489 up(&priv->wx_sem);
490 return ret;
491
492}
493
494
495static int r8180_wx_get_wap(struct net_device *dev,
496 struct iw_request_info *info,
497 union iwreq_data *wrqu, char *extra)
498{
499 struct r8180_priv *priv = ieee80211_priv(dev);
500
Tracey Dentde171bd2010-09-20 21:19:41 -0400501 return ieee80211_wx_get_wap(priv->ieee80211, info, wrqu, extra);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800502}
503
504
505static int r8180_wx_set_enc(struct net_device *dev,
506 struct iw_request_info *info,
507 union iwreq_data *wrqu, char *key)
508{
509 struct r8180_priv *priv = ieee80211_priv(dev);
510 int ret;
511
Tracey Dentde171bd2010-09-20 21:19:41 -0400512 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800513 return 0;
514
515
516 down(&priv->wx_sem);
517
Tracey Dentde171bd2010-09-20 21:19:41 -0400518 if (priv->hw_wep) ret = r8180_wx_set_key(dev, info, wrqu, key);
519 else {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800520 DMESG("Setting SW wep key");
Tracey Dentde171bd2010-09-20 21:19:41 -0400521 ret = ieee80211_wx_set_encode(priv->ieee80211, info, wrqu, key);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800522 }
523
524 up(&priv->wx_sem);
525 return ret;
526}
527
528
529static int r8180_wx_get_enc(struct net_device *dev,
530 struct iw_request_info *info,
531 union iwreq_data *wrqu, char *key)
532{
533 struct r8180_priv *priv = ieee80211_priv(dev);
534
535 return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key);
536}
537
538
539static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union
Tracey Dentde171bd2010-09-20 21:19:41 -0400540 iwreq_data *wrqu, char *p) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800541
Tracey Dentde171bd2010-09-20 21:19:41 -0400542 struct r8180_priv *priv = ieee80211_priv(dev);
543 int *parms = (int*)p;
544 int mode = parms[0];
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800545
Tracey Dentde171bd2010-09-20 21:19:41 -0400546 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800547 return 0;
548
549 priv->ieee80211->active_scan = mode;
550
551 return 1;
552}
553
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800554static int r8180_wx_set_retry(struct net_device *dev,
555 struct iw_request_info *info,
556 union iwreq_data *wrqu, char *extra)
557{
558 struct r8180_priv *priv = ieee80211_priv(dev);
559 int err = 0;
560
Tracey Dentde171bd2010-09-20 21:19:41 -0400561 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800562 return 0;
563
564 down(&priv->wx_sem);
565
566 if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
Tracey Dentde171bd2010-09-20 21:19:41 -0400567 wrqu->retry.disabled) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800568 err = -EINVAL;
569 goto exit;
570 }
Tracey Dentde171bd2010-09-20 21:19:41 -0400571 if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800572 err = -EINVAL;
573 goto exit;
574 }
575
Tracey Dentde171bd2010-09-20 21:19:41 -0400576 if (wrqu->retry.value > R8180_MAX_RETRY) {
577 err = -EINVAL;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800578 goto exit;
579 }
580 if (wrqu->retry.flags & IW_RETRY_MAX) {
581 priv->retry_rts = wrqu->retry.value;
582 DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value);
583
Tracey Dentde171bd2010-09-20 21:19:41 -0400584 } else {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800585 priv->retry_data = wrqu->retry.value;
586 DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value);
587 }
588
589 /* FIXME !
590 * We might try to write directly the TX config register
591 * or to restart just the (R)TX process.
592 * I'm unsure if whole reset is really needed
593 */
594
Tracey Dentde171bd2010-09-20 21:19:41 -0400595 rtl8180_commit(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800596exit:
597 up(&priv->wx_sem);
598
599 return err;
600}
601
602static int r8180_wx_get_retry(struct net_device *dev,
603 struct iw_request_info *info,
604 union iwreq_data *wrqu, char *extra)
605{
606 struct r8180_priv *priv = ieee80211_priv(dev);
607
608
609 wrqu->retry.disabled = 0; /* can't be disabled */
610
611 if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
612 IW_RETRY_LIFETIME)
613 return -EINVAL;
614
615 if (wrqu->retry.flags & IW_RETRY_MAX) {
Dan Carpenter6fe86442012-06-09 20:05:16 +0300616 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800617 wrqu->retry.value = priv->retry_rts;
618 } else {
Dan Carpenter6fe86442012-06-09 20:05:16 +0300619 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800620 wrqu->retry.value = priv->retry_data;
621 }
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800622
623 return 0;
624}
625
626static int r8180_wx_get_sens(struct net_device *dev,
627 struct iw_request_info *info,
628 union iwreq_data *wrqu, char *extra)
629{
630 struct r8180_priv *priv = ieee80211_priv(dev);
Tracey Dentde171bd2010-09-20 21:19:41 -0400631 if (priv->rf_set_sens == NULL)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800632 return -1; /* we have not this support for this radio */
633 wrqu->sens.value = priv->sens;
634 return 0;
635}
636
637
638static int r8180_wx_set_sens(struct net_device *dev,
639 struct iw_request_info *info,
640 union iwreq_data *wrqu, char *extra)
641{
642
643 struct r8180_priv *priv = ieee80211_priv(dev);
644
645 short err = 0;
646
Tracey Dentde171bd2010-09-20 21:19:41 -0400647 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800648 return 0;
649
650 down(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -0400651 if (priv->rf_set_sens == NULL) {
652 err = -1; /* we have not this support for this radio */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800653 goto exit;
654 }
Tracey Dentde171bd2010-09-20 21:19:41 -0400655 if (priv->rf_set_sens(dev, wrqu->sens.value) == 0)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800656 priv->sens = wrqu->sens.value;
657 else
Tracey Dentde171bd2010-09-20 21:19:41 -0400658 err = -EINVAL;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800659
660exit:
661 up(&priv->wx_sem);
662
663 return err;
664}
665
666
667static int r8180_wx_set_rawtx(struct net_device *dev,
668 struct iw_request_info *info,
669 union iwreq_data *wrqu, char *extra)
670{
671 struct r8180_priv *priv = ieee80211_priv(dev);
672 int ret;
673
Tracey Dentde171bd2010-09-20 21:19:41 -0400674 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800675 return 0;
676
677 down(&priv->wx_sem);
678
679 ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra);
680
681 up(&priv->wx_sem);
682
683 return ret;
684
685}
686
687static int r8180_wx_get_power(struct net_device *dev,
688 struct iw_request_info *info,
689 union iwreq_data *wrqu, char *extra)
690{
691 int ret;
692 struct r8180_priv *priv = ieee80211_priv(dev);
693
694 down(&priv->wx_sem);
695
696 ret = ieee80211_wx_get_power(priv->ieee80211, info, wrqu, extra);
697
698 up(&priv->wx_sem);
699
700 return ret;
701}
702
703static int r8180_wx_set_power(struct net_device *dev,
704 struct iw_request_info *info,
705 union iwreq_data *wrqu, char *extra)
706{
707 int ret;
708 struct r8180_priv *priv = ieee80211_priv(dev);
709
710
Tracey Dentde171bd2010-09-20 21:19:41 -0400711 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800712 return 0;
713
714 down(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -0400715 printk("=>>>>>>>>>>=============================>set power:%d, %d!\n", wrqu->power.disabled, wrqu->power.flags);
716 if (wrqu->power.disabled == 0) {
717 wrqu->power.flags |= IW_POWER_ALL_R;
718 wrqu->power.flags |= IW_POWER_TIMEOUT;
719 wrqu->power.value = 1000;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800720 }
721
722 ret = ieee80211_wx_set_power(priv->ieee80211, info, wrqu, extra);
723
724 up(&priv->wx_sem);
725
726 return ret;
727}
728
729static int r8180_wx_set_rts(struct net_device *dev,
730 struct iw_request_info *info,
731 union iwreq_data *wrqu, char *extra)
732{
733 struct r8180_priv *priv = ieee80211_priv(dev);
734
735
Tracey Dentde171bd2010-09-20 21:19:41 -0400736 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800737 return 0;
738
739 if (wrqu->rts.disabled)
740 priv->rts = DEFAULT_RTS_THRESHOLD;
741 else {
742 if (wrqu->rts.value < MIN_RTS_THRESHOLD ||
743 wrqu->rts.value > MAX_RTS_THRESHOLD)
744 return -EINVAL;
745
746 priv->rts = wrqu->rts.value;
747 }
748
749 return 0;
750}
751static int r8180_wx_get_rts(struct net_device *dev,
752 struct iw_request_info *info,
753 union iwreq_data *wrqu, char *extra)
754{
755 struct r8180_priv *priv = ieee80211_priv(dev);
756
757
758
759 wrqu->rts.value = priv->rts;
760 wrqu->rts.fixed = 0; /* no auto select */
761 wrqu->rts.disabled = (wrqu->rts.value == 0);
762
763 return 0;
764}
765static int dummy(struct net_device *dev, struct iw_request_info *a,
Tracey Dentde171bd2010-09-20 21:19:41 -0400766 union iwreq_data *wrqu, char *b)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800767{
768 return -1;
769}
770
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800771static int r8180_wx_get_iwmode(struct net_device *dev,
772 struct iw_request_info *info,
773 union iwreq_data *wrqu, char *extra)
774{
775 struct r8180_priv *priv = ieee80211_priv(dev);
776 struct ieee80211_device *ieee;
777 int ret = 0;
778
779
780
781 down(&priv->wx_sem);
782
783 ieee = priv->ieee80211;
784
785 strcpy(extra, "802.11");
Tracey Dentde171bd2010-09-20 21:19:41 -0400786 if (ieee->modulation & IEEE80211_CCK_MODULATION) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800787 strcat(extra, "b");
Tracey Dentde171bd2010-09-20 21:19:41 -0400788 if (ieee->modulation & IEEE80211_OFDM_MODULATION)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800789 strcat(extra, "/g");
Tracey Dentde171bd2010-09-20 21:19:41 -0400790 } else if (ieee->modulation & IEEE80211_OFDM_MODULATION)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800791 strcat(extra, "g");
792
793 up(&priv->wx_sem);
794
795 return ret;
796}
797static int r8180_wx_set_iwmode(struct net_device *dev,
798 struct iw_request_info *info,
799 union iwreq_data *wrqu, char *extra)
800{
801 struct r8180_priv *priv = ieee80211_priv(dev);
802 struct ieee80211_device *ieee = priv->ieee80211;
803 int *param = (int *)extra;
804 int ret = 0;
805 int modulation = 0, mode = 0;
806
807
Tracey Dentde171bd2010-09-20 21:19:41 -0400808 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800809 return 0;
810
811 down(&priv->wx_sem);
812
813 if (*param == 1) {
814 modulation |= IEEE80211_CCK_MODULATION;
815 mode = IEEE_B;
816 printk(KERN_INFO "B mode!\n");
817 } else if (*param == 2) {
818 modulation |= IEEE80211_OFDM_MODULATION;
819 mode = IEEE_G;
820 printk(KERN_INFO "G mode!\n");
821 } else if (*param == 3) {
822 modulation |= IEEE80211_CCK_MODULATION;
823 modulation |= IEEE80211_OFDM_MODULATION;
824 mode = IEEE_B|IEEE_G;
825 printk(KERN_INFO "B/G mode!\n");
826 }
827
Tracey Dentde171bd2010-09-20 21:19:41 -0400828 if (ieee->proto_started) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800829 ieee80211_stop_protocol(ieee);
830 ieee->mode = mode;
831 ieee->modulation = modulation;
832 ieee80211_start_protocol(ieee);
833 } else {
834 ieee->mode = mode;
835 ieee->modulation = modulation;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800836 }
837
838 up(&priv->wx_sem);
839
840 return ret;
841}
842static int r8180_wx_get_preamble(struct net_device *dev,
843 struct iw_request_info *info,
844 union iwreq_data *wrqu, char *extra)
845{
846 struct r8180_priv *priv = ieee80211_priv(dev);
847
848
849
850 down(&priv->wx_sem);
851
852
853
Tracey Dentde171bd2010-09-20 21:19:41 -0400854 *extra = (char) priv->plcp_preamble_mode; /* 0:auto 1:short 2:long */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800855 up(&priv->wx_sem);
856
857 return 0;
858}
859static int r8180_wx_set_preamble(struct net_device *dev,
860 struct iw_request_info *info,
861 union iwreq_data *wrqu, char *extra)
862{
863 struct r8180_priv *priv = ieee80211_priv(dev);
864 int ret = 0;
865
866
Tracey Dentde171bd2010-09-20 21:19:41 -0400867 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800868 return 0;
869
870 down(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -0400871 if (*extra < 0 || *extra > 2)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800872 ret = -1;
873 else
874 priv->plcp_preamble_mode = *((short *)extra) ;
875
876
877
878 up(&priv->wx_sem);
879
880 return ret;
881}
882static int r8180_wx_get_siglevel(struct net_device *dev,
883 struct iw_request_info *info,
884 union iwreq_data *wrqu, char *extra)
885{
886 struct r8180_priv *priv = ieee80211_priv(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800887 int ret = 0;
888
889
890
891 down(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -0400892 /* Modify by hikaru 6.5 */
893 *((int *)extra) = priv->wstats.qual.level;/*for interface test ,it should be the priv->wstats.qual.level; */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800894
895
896
897 up(&priv->wx_sem);
898
899 return ret;
900}
901static int r8180_wx_get_sigqual(struct net_device *dev,
902 struct iw_request_info *info,
903 union iwreq_data *wrqu, char *extra)
904{
905 struct r8180_priv *priv = ieee80211_priv(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800906 int ret = 0;
907
908
909
910 down(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -0400911 /* Modify by hikaru 6.5 */
912 *((int *)extra) = priv->wstats.qual.qual;/* for interface test ,it should be the priv->wstats.qual.qual; */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800913
914
915
916 up(&priv->wx_sem);
917
918 return ret;
919}
920static int r8180_wx_reset_stats(struct net_device *dev,
921 struct iw_request_info *info,
922 union iwreq_data *wrqu, char *extra)
923{
Tracey Dentde171bd2010-09-20 21:19:41 -0400924 struct r8180_priv *priv = ieee80211_priv(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800925 down(&priv->wx_sem);
926
927 priv->stats.txrdu = 0;
928 priv->stats.rxrdu = 0;
929 priv->stats.rxnolast = 0;
930 priv->stats.rxnodata = 0;
931 priv->stats.rxnopointer = 0;
932 priv->stats.txnperr = 0;
933 priv->stats.txresumed = 0;
934 priv->stats.rxerr = 0;
935 priv->stats.rxoverflow = 0;
936 priv->stats.rxint = 0;
937
938 priv->stats.txnpokint = 0;
939 priv->stats.txhpokint = 0;
940 priv->stats.txhperr = 0;
941 priv->stats.ints = 0;
942 priv->stats.shints = 0;
943 priv->stats.txoverflow = 0;
944 priv->stats.rxdmafail = 0;
945 priv->stats.txbeacon = 0;
946 priv->stats.txbeaconerr = 0;
947 priv->stats.txlpokint = 0;
948 priv->stats.txlperr = 0;
Tracey Dentde171bd2010-09-20 21:19:41 -0400949 priv->stats.txretry = 0;/* 20060601 */
950 priv->stats.rxcrcerrmin = 0 ;
951 priv->stats.rxcrcerrmid = 0;
952 priv->stats.rxcrcerrmax = 0;
953 priv->stats.rxicverr = 0;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800954
955 up(&priv->wx_sem);
956
957 return 0;
958
959}
960static int r8180_wx_radio_on(struct net_device *dev,
961 struct iw_request_info *info,
962 union iwreq_data *wrqu, char *extra)
963{
Tracey Dentde171bd2010-09-20 21:19:41 -0400964 struct r8180_priv *priv = ieee80211_priv(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800965
Tracey Dentde171bd2010-09-20 21:19:41 -0400966 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800967 return 0;
968
969
970 down(&priv->wx_sem);
971 priv->rf_wakeup(dev);
972
973 up(&priv->wx_sem);
974
975 return 0;
976
977}
978
979static int r8180_wx_radio_off(struct net_device *dev,
980 struct iw_request_info *info,
981 union iwreq_data *wrqu, char *extra)
982{
Tracey Dentde171bd2010-09-20 21:19:41 -0400983 struct r8180_priv *priv = ieee80211_priv(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800984
Tracey Dentde171bd2010-09-20 21:19:41 -0400985 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -0800986 return 0;
987
988
989 down(&priv->wx_sem);
990 priv->rf_sleep(dev);
991
992 up(&priv->wx_sem);
993
994 return 0;
995
996}
997static int r8180_wx_get_channelplan(struct net_device *dev,
998 struct iw_request_info *info,
999 union iwreq_data *wrqu, char *extra)
1000{
1001 struct r8180_priv *priv = ieee80211_priv(dev);
1002
1003
1004
1005 down(&priv->wx_sem);
1006 *extra = priv->channel_plan;
1007
1008
1009
1010 up(&priv->wx_sem);
1011
1012 return 0;
1013}
1014static int r8180_wx_set_channelplan(struct net_device *dev,
1015 struct iw_request_info *info,
1016 union iwreq_data *wrqu, char *extra)
1017{
1018 struct r8180_priv *priv = ieee80211_priv(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001019 int *val = (int *)extra;
1020 int i;
Harvey Harrisond599edc2009-01-07 14:31:57 -08001021 printk("-----in fun %s\n", __func__);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001022
Tracey Dentde171bd2010-09-20 21:19:41 -04001023 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001024 return 0;
1025
Tracey Dentde171bd2010-09-20 21:19:41 -04001026 /* unsigned long flags; */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001027 down(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -04001028 if (DefaultChannelPlan[*val].Len != 0) {
1029 priv->channel_plan = *val;
1030 /* Clear old channel map 8 */
1031 for (i = 1; i <= MAX_CHANNEL_NUMBER; i++)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001032 GET_DOT11D_INFO(priv->ieee80211)->channel_map[i] = 0;
Tracey Dentde171bd2010-09-20 21:19:41 -04001033
1034 /* Set new channel map */
1035 for (i = 1; i <= DefaultChannelPlan[*val].Len; i++)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001036 GET_DOT11D_INFO(priv->ieee80211)->channel_map[DefaultChannelPlan[*val].Channel[i-1]] = 1;
Tracey Dentde171bd2010-09-20 21:19:41 -04001037
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001038 }
1039 up(&priv->wx_sem);
1040
1041 return 0;
1042}
1043
1044static int r8180_wx_get_version(struct net_device *dev,
1045 struct iw_request_info *info,
1046 union iwreq_data *wrqu, char *extra)
1047{
1048 struct r8180_priv *priv = ieee80211_priv(dev);
Tracey Dentde171bd2010-09-20 21:19:41 -04001049 /* struct ieee80211_device *ieee; */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001050
1051 down(&priv->wx_sem);
1052 strcpy(extra, "1020.0808");
1053 up(&priv->wx_sem);
1054
1055 return 0;
1056}
1057
Tracey Dentde171bd2010-09-20 21:19:41 -04001058/* added by amy 080818 */
1059/*receive datarate from user typing valid rate is from 2 to 108 (1 - 54M), if input 0, return to normal rate adaptive. */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001060static int r8180_wx_set_forcerate(struct net_device *dev,
1061 struct iw_request_info *info,
1062 union iwreq_data *wrqu, char *extra)
1063{
1064 struct r8180_priv *priv = ieee80211_priv(dev);
1065 u8 forcerate = *extra;
1066
1067 down(&priv->wx_sem);
1068
Tracey Dentde171bd2010-09-20 21:19:41 -04001069 printk("==============>%s(): forcerate is %d\n", __func__, forcerate);
1070 if ((forcerate == 2) || (forcerate == 4) || (forcerate == 11) || (forcerate == 22) || (forcerate == 12) ||
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001071 (forcerate == 18) || (forcerate == 24) || (forcerate == 36) || (forcerate == 48) || (forcerate == 72) ||
1072 (forcerate == 96) || (forcerate == 108))
1073 {
1074 priv->ForcedDataRate = 1;
1075 priv->ieee80211->rate = forcerate * 5;
Tracey Dentde171bd2010-09-20 21:19:41 -04001076 } else if (forcerate == 0) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001077 priv->ForcedDataRate = 0;
1078 printk("OK! return rate adaptive\n");
Tracey Dentde171bd2010-09-20 21:19:41 -04001079 } else
1080 printk("ERR: wrong rate\n");
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001081 up(&priv->wx_sem);
1082 return 0;
1083}
1084
1085static int r8180_wx_set_enc_ext(struct net_device *dev,
Tracey Dentde171bd2010-09-20 21:19:41 -04001086 struct iw_request_info *info,
1087 union iwreq_data *wrqu, char *extra)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001088{
1089
1090 struct r8180_priv *priv = ieee80211_priv(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001091
Tracey Dentde171bd2010-09-20 21:19:41 -04001092 int ret = 0;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001093
Tracey Dentde171bd2010-09-20 21:19:41 -04001094 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001095 return 0;
1096
1097 down(&priv->wx_sem);
1098 ret = ieee80211_wx_set_encode_ext(priv->ieee80211, info, wrqu, extra);
1099 up(&priv->wx_sem);
1100 return ret;
1101
1102}
1103static int r8180_wx_set_auth(struct net_device *dev,
Herton Ronaldo Krzesinskib318a3a2009-02-13 08:35:13 -05001104 struct iw_request_info *info,
1105 union iwreq_data *wrqu, char *extra)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001106{
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001107 struct r8180_priv *priv = ieee80211_priv(dev);
Tracey Dentde171bd2010-09-20 21:19:41 -04001108 int ret = 0;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001109
Tracey Dentde171bd2010-09-20 21:19:41 -04001110 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001111 return 0;
1112
1113 down(&priv->wx_sem);
Herton Ronaldo Krzesinskib318a3a2009-02-13 08:35:13 -05001114 ret = ieee80211_wx_set_auth(priv->ieee80211, info, &wrqu->param, extra);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001115 up(&priv->wx_sem);
1116 return ret;
1117}
1118
1119static int r8180_wx_set_mlme(struct net_device *dev,
Tracey Dentde171bd2010-09-20 21:19:41 -04001120 struct iw_request_info *info,
1121 union iwreq_data *wrqu, char *extra)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001122{
Tracey Dentde171bd2010-09-20 21:19:41 -04001123 int ret = 0;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001124 struct r8180_priv *priv = ieee80211_priv(dev);
1125
1126
Tracey Dentde171bd2010-09-20 21:19:41 -04001127 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001128 return 0;
1129
1130
1131 down(&priv->wx_sem);
1132#if 1
1133 ret = ieee80211_wx_set_mlme(priv->ieee80211, info, wrqu, extra);
1134#endif
1135 up(&priv->wx_sem);
1136 return ret;
1137}
1138static int r8180_wx_set_gen_ie(struct net_device *dev,
Herton Ronaldo Krzesinskib318a3a2009-02-13 08:35:13 -05001139 struct iw_request_info *info,
1140 union iwreq_data *wrqu, char *extra)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001141{
Tracey Dentde171bd2010-09-20 21:19:41 -04001142 int ret = 0;
1143 struct r8180_priv *priv = ieee80211_priv(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001144
1145
Tracey Dentde171bd2010-09-20 21:19:41 -04001146 if (priv->ieee80211->bHwRadioOff)
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001147 return 0;
1148
Tracey Dentde171bd2010-09-20 21:19:41 -04001149 down(&priv->wx_sem);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001150#if 1
Tracey Dentde171bd2010-09-20 21:19:41 -04001151 ret = ieee80211_wx_set_gen_ie(priv->ieee80211, extra, wrqu->data.length);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001152#endif
Tracey Dentde171bd2010-09-20 21:19:41 -04001153 up(&priv->wx_sem);
Tracey Dentde171bd2010-09-20 21:19:41 -04001154 return ret;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001155
1156
1157}
Tracey Dentde171bd2010-09-20 21:19:41 -04001158static iw_handler r8180_wx_handlers[] = {
Andrew Miller40ec6c52012-03-15 19:32:08 -04001159 NULL, /* SIOCSIWCOMMIT */
Tracey Dentde171bd2010-09-20 21:19:41 -04001160 r8180_wx_get_name, /* SIOCGIWNAME */
Andrew Miller40ec6c52012-03-15 19:32:08 -04001161 dummy, /* SIOCSIWNWID */
1162 dummy, /* SIOCGIWNWID */
Tracey Dentde171bd2010-09-20 21:19:41 -04001163 r8180_wx_set_freq, /* SIOCSIWFREQ */
1164 r8180_wx_get_freq, /* SIOCGIWFREQ */
1165 r8180_wx_set_mode, /* SIOCSIWMODE */
1166 r8180_wx_get_mode, /* SIOCGIWMODE */
1167 r8180_wx_set_sens, /* SIOCSIWSENS */
1168 r8180_wx_get_sens, /* SIOCGIWSENS */
Andrew Miller40ec6c52012-03-15 19:32:08 -04001169 NULL, /* SIOCSIWRANGE */
1170 rtl8180_wx_get_range, /* SIOCGIWRANGE */
1171 NULL, /* SIOCSIWPRIV */
1172 NULL, /* SIOCGIWPRIV */
1173 NULL, /* SIOCSIWSTATS */
1174 NULL, /* SIOCGIWSTATS */
1175 dummy, /* SIOCSIWSPY */
1176 dummy, /* SIOCGIWSPY */
1177 NULL, /* SIOCGIWTHRSPY */
1178 NULL, /* SIOCWIWTHRSPY */
Tracey Dentde171bd2010-09-20 21:19:41 -04001179 r8180_wx_set_wap, /* SIOCSIWAP */
1180 r8180_wx_get_wap, /* SIOCGIWAP */
1181 r8180_wx_set_mlme, /* SIOCSIWMLME*/
Justin P. Mattocked2cb4f2012-04-17 06:56:43 -07001182 dummy, /* SIOCGIWAPLIST -- deprecated */
Tracey Dentde171bd2010-09-20 21:19:41 -04001183 r8180_wx_set_scan, /* SIOCSIWSCAN */
1184 r8180_wx_get_scan, /* SIOCGIWSCAN */
1185 r8180_wx_set_essid, /* SIOCSIWESSID */
1186 r8180_wx_get_essid, /* SIOCGIWESSID */
Andrew Miller40ec6c52012-03-15 19:32:08 -04001187 dummy, /* SIOCSIWNICKN */
1188 dummy, /* SIOCGIWNICKN */
1189 NULL, /* -- hole -- */
1190 NULL, /* -- hole -- */
Tracey Dentde171bd2010-09-20 21:19:41 -04001191 r8180_wx_set_rate, /* SIOCSIWRATE */
1192 r8180_wx_get_rate, /* SIOCGIWRATE */
1193 r8180_wx_set_rts, /* SIOCSIWRTS */
1194 r8180_wx_get_rts, /* SIOCGIWRTS */
1195 r8180_wx_set_frag, /* SIOCSIWFRAG */
1196 r8180_wx_get_frag, /* SIOCGIWFRAG */
Andrew Miller40ec6c52012-03-15 19:32:08 -04001197 dummy, /* SIOCSIWTXPOW */
1198 dummy, /* SIOCGIWTXPOW */
Tracey Dentde171bd2010-09-20 21:19:41 -04001199 r8180_wx_set_retry, /* SIOCSIWRETRY */
1200 r8180_wx_get_retry, /* SIOCGIWRETRY */
1201 r8180_wx_set_enc, /* SIOCSIWENCODE */
1202 r8180_wx_get_enc, /* SIOCGIWENCODE */
1203 r8180_wx_set_power, /* SIOCSIWPOWER */
1204 r8180_wx_get_power, /* SIOCGIWPOWER */
Andrew Miller40ec6c52012-03-15 19:32:08 -04001205 NULL, /*---hole---*/
1206 NULL, /*---hole---*/
1207 r8180_wx_set_gen_ie, /* SIOCSIWGENIE */
1208 NULL, /* SIOCSIWGENIE */
Tracey Dentde171bd2010-09-20 21:19:41 -04001209 r8180_wx_set_auth, /* SIOCSIWAUTH */
Andrew Miller40ec6c52012-03-15 19:32:08 -04001210 NULL, /* SIOCSIWAUTH */
1211 r8180_wx_set_enc_ext, /* SIOCSIWENCODEEXT */
1212 NULL, /* SIOCSIWENCODEEXT */
1213 NULL, /* SIOCSIWPMKSA */
1214 NULL, /*---hole---*/
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001215};
1216
1217
1218static const struct iw_priv_args r8180_private_args[] = {
1219 {
1220 SIOCIWFIRSTPRIV + 0x0,
1221 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
1222 },
1223 { SIOCIWFIRSTPRIV + 0x1,
1224 0, 0, "dummy"
1225
1226 },
1227 {
1228 SIOCIWFIRSTPRIV + 0x2,
1229 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "beaconint"
1230 },
1231 { SIOCIWFIRSTPRIV + 0x3,
1232 0, 0, "dummy"
1233
1234 },
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001235 {
1236 SIOCIWFIRSTPRIV + 0x4,
1237 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
1238
1239 },
1240 { SIOCIWFIRSTPRIV + 0x5,
1241 0, 0, "dummy"
1242
1243 },
1244 {
1245 SIOCIWFIRSTPRIV + 0x6,
1246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx"
1247
1248 },
1249 { SIOCIWFIRSTPRIV + 0x7,
1250 0, 0, "dummy"
1251
1252 },
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001253 {
1254 SIOCIWFIRSTPRIV + 0x8,
1255 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setiwmode"
1256 },
1257 {
1258 SIOCIWFIRSTPRIV + 0x9,
1259 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 32, "getiwmode"
1260 },
1261 {
1262 SIOCIWFIRSTPRIV + 0xA,
1263 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setpreamble"
1264 },
1265 {
1266 SIOCIWFIRSTPRIV + 0xB,
1267 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getpreamble"
1268 },
1269 { SIOCIWFIRSTPRIV + 0xC,
1270 0, 0, "dummy"
1271 },
1272 {
1273 SIOCIWFIRSTPRIV + 0xD,
1274 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getrssi"
1275 },
1276 { SIOCIWFIRSTPRIV + 0xE,
1277 0, 0, "dummy"
1278 },
1279 {
1280 SIOCIWFIRSTPRIV + 0xF,
1281 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getlinkqual"
Tracey Dentde171bd2010-09-20 21:19:41 -04001282 },
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001283 {
1284 SIOCIWFIRSTPRIV + 0x10,
1285 0, 0, "resetstats"
Tracey Dentde171bd2010-09-20 21:19:41 -04001286 },
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001287 {
1288 SIOCIWFIRSTPRIV + 0x11,
Tracey Dentde171bd2010-09-20 21:19:41 -04001289 0, 0, "dummy"
1290 },
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001291 {
1292 SIOCIWFIRSTPRIV + 0x12,
1293 0, 0, "radioon"
Tracey Dentde171bd2010-09-20 21:19:41 -04001294 },
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001295 {
1296 SIOCIWFIRSTPRIV + 0x13,
1297 0, 0, "radiooff"
Tracey Dentde171bd2010-09-20 21:19:41 -04001298 },
1299 {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001300 SIOCIWFIRSTPRIV + 0x14,
1301 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setchannel"
Tracey Dentde171bd2010-09-20 21:19:41 -04001302 },
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001303 {
1304 SIOCIWFIRSTPRIV + 0x15,
1305 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel"
Tracey Dentde171bd2010-09-20 21:19:41 -04001306 },
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001307 {
1308 SIOCIWFIRSTPRIV + 0x16,
Tracey Dentde171bd2010-09-20 21:19:41 -04001309 0, 0, "dummy"
1310 },
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001311 {
1312 SIOCIWFIRSTPRIV + 0x17,
Tracey Dentde171bd2010-09-20 21:19:41 -04001313 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 32, "getversion"
1314 },
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001315 {
1316 SIOCIWFIRSTPRIV + 0x18,
1317 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setrate"
1318 },
1319};
1320
1321
1322static iw_handler r8180_private_handler[] = {
Andrew Miller40ec6c52012-03-15 19:32:08 -04001323 r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001324 dummy,
1325 r8180_wx_set_beaconinterval,
1326 dummy,
Tracey Dentde171bd2010-09-20 21:19:41 -04001327 /* r8180_wx_set_monitor_type, */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001328 r8180_wx_set_scan_type,
1329 dummy,
1330 r8180_wx_set_rawtx,
1331 dummy,
1332 r8180_wx_set_iwmode,
1333 r8180_wx_get_iwmode,
1334 r8180_wx_set_preamble,
1335 r8180_wx_get_preamble,
1336 dummy,
1337 r8180_wx_get_siglevel,
1338 dummy,
1339 r8180_wx_get_sigqual,
1340 r8180_wx_reset_stats,
Tracey Dentde171bd2010-09-20 21:19:41 -04001341 dummy,/* r8180_wx_get_stats */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001342 r8180_wx_radio_on,
1343 r8180_wx_radio_off,
1344 r8180_wx_set_channelplan,
1345 r8180_wx_get_channelplan,
1346 dummy,
1347 r8180_wx_get_version,
1348 r8180_wx_set_forcerate,
1349};
1350
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001351static inline int is_same_network(struct ieee80211_network *src,
Tracey Dentde171bd2010-09-20 21:19:41 -04001352 struct ieee80211_network *dst,
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001353 struct ieee80211_device *ieee)
1354{
Andrew Miller40ec6c52012-03-15 19:32:08 -04001355 /* A network is only a duplicate if the channel, BSSID, ESSID
1356 * and the capability field (in particular IBSS and BSS) all match.
1357 * We treat all <hidden> with the same BSSID and channel
1358 * as one network
1359 */
1360 return (((src->ssid_len == dst->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) && /* YJ,mod, 080819,for hidden ap */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001361 (src->channel == dst->channel) &&
1362 !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
Tracey Dentde171bd2010-09-20 21:19:41 -04001363 (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) && /* YJ,mod, 080819,for hidden ap */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001364 ((src->capability & WLAN_CAPABILITY_IBSS) ==
1365 (dst->capability & WLAN_CAPABILITY_IBSS)) &&
1366 ((src->capability & WLAN_CAPABILITY_BSS) ==
1367 (dst->capability & WLAN_CAPABILITY_BSS)));
1368}
1369
Justin P. Mattocked2cb4f2012-04-17 06:56:43 -07001370/* WB modified to show signal to GUI on 18-01-2008 */
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001371static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
1372{
Tracey Dentde171bd2010-09-20 21:19:41 -04001373 struct r8180_priv *priv = ieee80211_priv(dev);
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001374 struct ieee80211_device* ieee = priv->ieee80211;
1375 struct iw_statistics* wstats = &priv->wstats;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001376 int tmp_level = 0;
1377 int tmp_qual = 0;
1378 int tmp_noise = 0;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001379
Tracey Dentde171bd2010-09-20 21:19:41 -04001380 if (ieee->state < IEEE80211_LINKED) {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001381 wstats->qual.qual = 0;
1382 wstats->qual.level = 0;
1383 wstats->qual.noise = 0;
1384 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1385 return wstats;
1386 }
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001387
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001388 tmp_level = (&ieee->current_network)->stats.signal;
1389 tmp_qual = (&ieee->current_network)->stats.signalstrength;
1390 tmp_noise = (&ieee->current_network)->stats.noise;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001391
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001392 wstats->qual.level = tmp_level;
1393 wstats->qual.qual = tmp_qual;
1394 wstats->qual.noise = tmp_noise;
Tracey Dentde171bd2010-09-20 21:19:41 -04001395 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001396 return wstats;
1397}
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001398
Tracey Dentde171bd2010-09-20 21:19:41 -04001399struct iw_handler_def r8180_wx_handlers_def = {
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001400 .standard = r8180_wx_handlers,
Stoyan Gaydarovb6ac1612009-07-21 22:02:27 -05001401 .num_standard = ARRAY_SIZE(r8180_wx_handlers),
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001402 .private = r8180_private_handler,
Stoyan Gaydarovb6ac1612009-07-21 22:02:27 -05001403 .num_private = ARRAY_SIZE(r8180_private_handler),
Tracey Dentde171bd2010-09-20 21:19:41 -04001404 .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args),
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001405 .get_wireless_stats = r8180_get_wireless_stats,
Greg Kroah-Hartmanc8d86be2008-12-04 20:01:41 -08001406 .private_args = (struct iw_priv_args *)r8180_private_args,
1407};
1408
1409