Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/upstream-linus
[linux-btrfs-devel.git] / drivers / staging / rtl8187se / r8180_wx.c
blob39ef7e0193fb52e78d9ab5777c13a79ab9e9dab8
1 /*
2 This file contains wireless extension handlers.
4 This is part of rtl8180 OpenSource driver.
5 Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
6 Released under the terms of GPL (General Public Licence)
8 Parts of this driver are based on the GPL part
9 of the official realtek driver.
11 Parts of this driver are based on the rtl8180 driver skeleton
12 from Patric Schenke & Andres Salomon.
14 Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
16 We want to tanks the Authors of those projects and the Ndiswrapper
17 project Authors.
21 #include "r8180.h"
22 #include "r8180_hw.h"
24 #include "ieee80211/dot11d.h"
26 /* #define RATE_COUNT 4 */
27 u32 rtl8180_rates[] = {1000000, 2000000, 5500000, 11000000,
28 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000};
30 #define RATE_COUNT ARRAY_SIZE(rtl8180_rates)
32 static CHANNEL_LIST DefaultChannelPlan[] = {
33 /* {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14}, */ /*Default channel plan */
34 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64}, 19}, /*FCC */
35 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11}, /*IC */
36 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, /*ETSI */
37 {{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. */
38 {{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. */
39 {{14, 36, 40, 44, 48, 52, 56, 60, 64}, 9}, /*MKK */
40 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},/*MKK1 */
41 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, /*Israel. */
42 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 34, 38, 42, 46}, 17}, /*For 11a , TELEC */
43 {{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 */
45 static int r8180_wx_get_freq(struct net_device *dev,
46 struct iw_request_info *a,
47 union iwreq_data *wrqu, char *b)
49 struct r8180_priv *priv = ieee80211_priv(dev);
51 return ieee80211_wx_get_freq(priv->ieee80211, a, wrqu, b);
55 int r8180_wx_set_key(struct net_device *dev, struct iw_request_info *info,
56 union iwreq_data *wrqu, char *key)
58 struct r8180_priv *priv = ieee80211_priv(dev);
59 struct iw_point *erq = &(wrqu->encoding);
61 if (priv->ieee80211->bHwRadioOff)
62 return 0;
64 if (erq->flags & IW_ENCODE_DISABLED)
66 /* i = erq->flags & IW_ENCODE_INDEX;
67 if (i < 1 || i > 4)
70 if (erq->length > 0) {
72 /*int len = erq->length <= 5 ? 5 : 13; */
74 u32* tkey = (u32*) key;
75 priv->key0[0] = tkey[0];
76 priv->key0[1] = tkey[1];
77 priv->key0[2] = tkey[2];
78 priv->key0[3] = tkey[3] & 0xff;
79 DMESG("Setting wep key to %x %x %x %x",
80 tkey[0], tkey[1], tkey[2], tkey[3]);
81 rtl8180_set_hw_wep(dev);
83 return 0;
87 static int r8180_wx_set_beaconinterval(struct net_device *dev, struct iw_request_info *aa,
88 union iwreq_data *wrqu, char *b)
90 int *parms = (int *)b;
91 int bi = parms[0];
93 struct r8180_priv *priv = ieee80211_priv(dev);
95 if (priv->ieee80211->bHwRadioOff)
96 return 0;
98 down(&priv->wx_sem);
99 DMESG("setting beacon interval to %x", bi);
101 priv->ieee80211->current_network.beacon_interval = bi;
102 rtl8180_commit(dev);
103 up(&priv->wx_sem);
105 return 0;
110 static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
111 union iwreq_data *wrqu, char *b)
113 struct r8180_priv *priv = ieee80211_priv(dev);
114 return ieee80211_wx_get_mode(priv->ieee80211, a, wrqu, b);
119 static int r8180_wx_get_rate(struct net_device *dev,
120 struct iw_request_info *info,
121 union iwreq_data *wrqu, char *extra)
123 struct r8180_priv *priv = ieee80211_priv(dev);
124 return ieee80211_wx_get_rate(priv->ieee80211, info, wrqu, extra);
129 static int r8180_wx_set_rate(struct net_device *dev,
130 struct iw_request_info *info,
131 union iwreq_data *wrqu, char *extra)
133 int ret;
134 struct r8180_priv *priv = ieee80211_priv(dev);
137 if (priv->ieee80211->bHwRadioOff)
138 return 0;
140 down(&priv->wx_sem);
142 ret = ieee80211_wx_set_rate(priv->ieee80211, info, wrqu, extra);
144 up(&priv->wx_sem);
146 return ret;
150 static int r8180_wx_set_crcmon(struct net_device *dev,
151 struct iw_request_info *info,
152 union iwreq_data *wrqu, char *extra)
154 struct r8180_priv *priv = ieee80211_priv(dev);
155 int *parms = (int *)extra;
156 int enable = (parms[0] > 0);
157 short prev = priv->crcmon;
160 if (priv->ieee80211->bHwRadioOff)
161 return 0;
163 down(&priv->wx_sem);
165 if (enable)
166 priv->crcmon = 1;
167 else
168 priv->crcmon = 0;
170 DMESG("bad CRC in monitor mode are %s",
171 priv->crcmon ? "accepted" : "rejected");
173 if (prev != priv->crcmon && priv->up) {
174 rtl8180_down(dev);
175 rtl8180_up(dev);
178 up(&priv->wx_sem);
180 return 0;
184 static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
185 union iwreq_data *wrqu, char *b)
187 struct r8180_priv *priv = ieee80211_priv(dev);
188 int ret;
191 if (priv->ieee80211->bHwRadioOff)
192 return 0;
194 down(&priv->wx_sem);
195 /* printk("set mode ENABLE_IPS\n"); */
196 if (priv->bInactivePs) {
197 if (wrqu->mode == IW_MODE_ADHOC)
198 IPSLeave(dev);
200 ret = ieee80211_wx_set_mode(priv->ieee80211, a, wrqu, b);
202 /* rtl8180_commit(dev); */
204 up(&priv->wx_sem);
205 return ret;
208 /* YJ,add,080819,for hidden ap */
209 struct iw_range_with_scan_capa {
210 /* Informative stuff (to choose between different interface) */
211 __u32 throughput; /* To give an idea... */
212 /* In theory this value should be the maximum benchmarked
213 * TCP/IP throughput, because with most of these devices the
214 * bit rate is meaningless (overhead an co) to estimate how
215 * fast the connection will go and pick the fastest one.
216 * I suggest people to play with Netperf or any benchmark...
219 /* NWID (or domain id) */
220 __u32 min_nwid; /* Minimal NWID we are able to set */
221 __u32 max_nwid; /* Maximal NWID we are able to set */
223 /* Old Frequency (backward compat - moved lower ) */
224 __u16 old_num_channels;
225 __u8 old_num_frequency;
227 /* Scan capabilities */
228 __u8 scan_capa;
230 /* YJ,add,080819,for hidden ap */
233 static int rtl8180_wx_get_range(struct net_device *dev,
234 struct iw_request_info *info,
235 union iwreq_data *wrqu, char *extra)
237 struct iw_range *range = (struct iw_range *)extra;
238 struct r8180_priv *priv = ieee80211_priv(dev);
239 u16 val;
240 int i;
241 /*struct iw_range_with_scan_capa* tmp = (struct iw_range_with_scan_capa*)range; */ /*YJ,add,080819,for hidden ap */
243 wrqu->data.length = sizeof(*range);
244 memset(range, 0, sizeof(*range));
246 /* Let's try to keep this struct in the same order as in
247 * linux/include/wireless.h
250 /* TODO: See what values we can set, and remove the ones we can't
251 * set, or fill them with some default data.
254 /* ~5 Mb/s real (802.11b) */
255 range->throughput = 5 * 1000 * 1000;
257 /* TODO: Not used in 802.11b? */
258 /* range->min_nwid; */ /* Minimal NWID we are able to set */
259 /* TODO: Not used in 802.11b? */
260 /* range->max_nwid; */ /* Maximal NWID we are able to set */
262 /* Old Frequency (backward compat - moved lower ) */
263 /* range->old_num_channels; */
264 /* range->old_num_frequency; */
265 /* range->old_freq[6]; */ /* Filler to keep "version" at the same offset */
266 if (priv->rf_set_sens != NULL)
267 range->sensitivity = priv->max_sens; /* signal level threshold range */
269 range->max_qual.qual = 100;
270 /* TODO: Find real max RSSI and stick here */
271 range->max_qual.level = 0;
272 range->max_qual.noise = -98;
273 range->max_qual.updated = 7; /* Updated all three */
275 range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */
276 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
277 range->avg_qual.level = 20 + -98;
278 range->avg_qual.noise = 0;
279 range->avg_qual.updated = 7; /* Updated all three */
281 range->num_bitrates = RATE_COUNT;
283 for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++)
284 range->bitrate[i] = rtl8180_rates[i];
286 range->min_frag = MIN_FRAG_THRESHOLD;
287 range->max_frag = MAX_FRAG_THRESHOLD;
289 range->pm_capa = 0;
291 range->we_version_compiled = WIRELESS_EXT;
292 range->we_version_source = 16;
294 /* range->retry_capa; */ /* What retry options are supported */
295 /* range->retry_flags; */ /* How to decode max/min retry limit */
296 /* range->r_time_flags;*/ /* How to decode max/min retry life */
297 /* range->min_retry; */ /* Minimal number of retries */
298 /* range->max_retry; */ /* Maximal number of retries */
299 /* range->min_r_time; */ /* Minimal retry lifetime */
300 /* range->max_r_time; */ /* Maximal retry lifetime */
302 range->num_channels = 14;
304 for (i = 0, val = 0; i < 14; i++) {
306 /* Include only legal frequencies for some countries */
307 if ((GET_DOT11D_INFO(priv->ieee80211)->channel_map)[i+1]) {
308 range->freq[val].i = i + 1;
309 range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000;
310 range->freq[val].e = 1;
311 val++;
312 } else {
313 /* FIXME: do we need to set anything for channels */
314 /* we don't use ? */
317 if (val == IW_MAX_FREQUENCIES)
318 break;
321 range->num_frequency = val;
322 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
323 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
325 /*tmp->scan_capa = 0x01; */ /*YJ,add,080819,for hidden ap */
327 return 0;
331 static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
332 union iwreq_data *wrqu, char *b)
334 struct r8180_priv *priv = ieee80211_priv(dev);
335 int ret;
336 struct ieee80211_device* ieee = priv->ieee80211;
339 if (priv->ieee80211->bHwRadioOff)
340 return 0;
342 /*YJ,add,080819, for hidden ap */
343 /*printk("==*&*&*&==>%s in\n", __func__); */
344 /*printk("=*&*&*&*===>flag:%x, %x\n", wrqu->data.flags, IW_SCAN_THIS_ESSID); */
345 if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
346 struct iw_scan_req* req = (struct iw_scan_req*)b;
347 if (req->essid_len) {
348 /*printk("==**&*&*&**===>scan set ssid:%s\n", req->essid); */
349 ieee->current_network.ssid_len = req->essid_len;
350 memcpy(ieee->current_network.ssid, req->essid, req->essid_len);
351 /*printk("=====>network ssid:%s\n", ieee->current_network.ssid); */
354 /*YJ,add,080819, for hidden ap, end */
356 down(&priv->wx_sem);
357 if (priv->up) {
358 /* printk("set scan ENABLE_IPS\n"); */
359 priv->ieee80211->actscanning = true;
360 if (priv->bInactivePs && (priv->ieee80211->state != IEEE80211_LINKED)) {
361 IPSLeave(dev);
362 /*down(&priv->ieee80211->wx_sem); */
364 if (priv->ieee80211->iw_mode == IW_MODE_MONITOR || !(priv->ieee80211->proto_started)){
365 ret = -1;
366 up(&priv->ieee80211->wx_sem);
367 up(&priv->wx_sem);
368 return ret;
371 /* queue_work(priv->ieee80211->wq, &priv->ieee80211->wx_sync_scan_wq); */
372 /* printk("start scan============================>\n"); */
373 ieee80211_softmac_ips_scan_syncro(priv->ieee80211);
374 /* ieee80211_rtl_start_scan(priv->ieee80211); */
375 /* intentionally forget to up sem */
376 /* up(&priv->ieee80211->wx_sem); */
377 ret = 0;
378 } else {
379 /* YJ,add,080828, prevent scan in BusyTraffic */
380 /* FIXME: Need to consider last scan time */
381 if ((priv->link_detect.bBusyTraffic) && (true)) {
382 ret = 0;
383 printk("Now traffic is busy, please try later!\n");
384 } else
385 /* YJ,add,080828, prevent scan in BusyTraffic,end */
386 ret = ieee80211_wx_set_scan(priv->ieee80211, a, wrqu, b);
388 } else
389 ret = -1;
391 up(&priv->wx_sem);
393 return ret;
397 static int r8180_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
398 union iwreq_data *wrqu, char *b)
401 int ret;
402 struct r8180_priv *priv = ieee80211_priv(dev);
404 down(&priv->wx_sem);
405 if (priv->up)
406 ret = ieee80211_wx_get_scan(priv->ieee80211, a, wrqu, b);
407 else
408 ret = -1;
410 up(&priv->wx_sem);
411 return ret;
415 static int r8180_wx_set_essid(struct net_device *dev,
416 struct iw_request_info *a,
417 union iwreq_data *wrqu, char *b)
419 struct r8180_priv *priv = ieee80211_priv(dev);
421 int ret;
423 if (priv->ieee80211->bHwRadioOff)
424 return 0;
426 down(&priv->wx_sem);
427 /* printk("set essid ENABLE_IPS\n"); */
428 if (priv->bInactivePs)
429 IPSLeave(dev);
430 /* printk("haha:set essid %s essid_len = %d essid_flgs = %d\n",b, wrqu->essid.length, wrqu->essid.flags); */
432 ret = ieee80211_wx_set_essid(priv->ieee80211, a, wrqu, b);
434 up(&priv->wx_sem);
435 return ret;
439 static int r8180_wx_get_essid(struct net_device *dev,
440 struct iw_request_info *a,
441 union iwreq_data *wrqu, char *b)
443 int ret;
444 struct r8180_priv *priv = ieee80211_priv(dev);
446 down(&priv->wx_sem);
448 ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b);
450 up(&priv->wx_sem);
452 return ret;
456 static int r8180_wx_set_freq(struct net_device *dev, struct iw_request_info *a,
457 union iwreq_data *wrqu, char *b)
459 int ret;
460 struct r8180_priv *priv = ieee80211_priv(dev);
463 if (priv->ieee80211->bHwRadioOff)
464 return 0;
466 down(&priv->wx_sem);
468 ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b);
470 up(&priv->wx_sem);
471 return ret;
475 static int r8180_wx_get_name(struct net_device *dev,
476 struct iw_request_info *info,
477 union iwreq_data *wrqu, char *extra)
479 struct r8180_priv *priv = ieee80211_priv(dev);
480 return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra);
483 static int r8180_wx_set_frag(struct net_device *dev,
484 struct iw_request_info *info,
485 union iwreq_data *wrqu, char *extra)
487 struct r8180_priv *priv = ieee80211_priv(dev);
489 if (priv->ieee80211->bHwRadioOff)
490 return 0;
492 if (wrqu->frag.disabled)
493 priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
494 else {
495 if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
496 wrqu->frag.value > MAX_FRAG_THRESHOLD)
497 return -EINVAL;
499 priv->ieee80211->fts = wrqu->frag.value & ~0x1;
502 return 0;
506 static int r8180_wx_get_frag(struct net_device *dev,
507 struct iw_request_info *info,
508 union iwreq_data *wrqu, char *extra)
510 struct r8180_priv *priv = ieee80211_priv(dev);
512 wrqu->frag.value = priv->ieee80211->fts;
513 wrqu->frag.fixed = 0; /* no auto select */
514 wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD);
516 return 0;
520 static int r8180_wx_set_wap(struct net_device *dev,
521 struct iw_request_info *info,
522 union iwreq_data *awrq,
523 char *extra)
525 int ret;
526 struct r8180_priv *priv = ieee80211_priv(dev);
528 if (priv->ieee80211->bHwRadioOff)
529 return 0;
531 down(&priv->wx_sem);
533 ret = ieee80211_wx_set_wap(priv->ieee80211, info, awrq, extra);
535 up(&priv->wx_sem);
536 return ret;
541 static int r8180_wx_get_wap(struct net_device *dev,
542 struct iw_request_info *info,
543 union iwreq_data *wrqu, char *extra)
545 struct r8180_priv *priv = ieee80211_priv(dev);
547 return ieee80211_wx_get_wap(priv->ieee80211, info, wrqu, extra);
551 static int r8180_wx_set_enc(struct net_device *dev,
552 struct iw_request_info *info,
553 union iwreq_data *wrqu, char *key)
555 struct r8180_priv *priv = ieee80211_priv(dev);
556 int ret;
558 if (priv->ieee80211->bHwRadioOff)
559 return 0;
562 down(&priv->wx_sem);
564 if (priv->hw_wep) ret = r8180_wx_set_key(dev, info, wrqu, key);
565 else {
566 DMESG("Setting SW wep key");
567 ret = ieee80211_wx_set_encode(priv->ieee80211, info, wrqu, key);
570 up(&priv->wx_sem);
571 return ret;
575 static int r8180_wx_get_enc(struct net_device *dev,
576 struct iw_request_info *info,
577 union iwreq_data *wrqu, char *key)
579 struct r8180_priv *priv = ieee80211_priv(dev);
581 return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key);
585 static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union
586 iwreq_data *wrqu, char *p) {
588 struct r8180_priv *priv = ieee80211_priv(dev);
589 int *parms = (int*)p;
590 int mode = parms[0];
592 if (priv->ieee80211->bHwRadioOff)
593 return 0;
595 priv->ieee80211->active_scan = mode;
597 return 1;
601 /* added by christian */
603 static int r8180_wx_set_monitor_type(struct net_device *dev, struct iw_request_info *aa, union
604 iwreq_data *wrqu, char *p){
606 struct r8180_priv *priv = ieee80211_priv(dev);
607 int *parms=(int*)p;
608 int mode=parms[0];
610 if(priv->ieee80211->iw_mode != IW_MODE_MONITOR) return -1;
611 priv->prism_hdr = mode;
612 if(!mode)dev->type=ARPHRD_IEEE80211;
613 else dev->type=ARPHRD_IEEE80211_PRISM;
614 DMESG("using %s RX encap", mode ? "AVS":"80211");
615 return 0;
619 /*of r8180_wx_set_monitor_type */
620 /* end added christian */
622 static int r8180_wx_set_retry(struct net_device *dev,
623 struct iw_request_info *info,
624 union iwreq_data *wrqu, char *extra)
626 struct r8180_priv *priv = ieee80211_priv(dev);
627 int err = 0;
629 if (priv->ieee80211->bHwRadioOff)
630 return 0;
632 down(&priv->wx_sem);
634 if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
635 wrqu->retry.disabled) {
636 err = -EINVAL;
637 goto exit;
639 if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) {
640 err = -EINVAL;
641 goto exit;
644 if (wrqu->retry.value > R8180_MAX_RETRY) {
645 err = -EINVAL;
646 goto exit;
648 if (wrqu->retry.flags & IW_RETRY_MAX) {
649 priv->retry_rts = wrqu->retry.value;
650 DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value);
652 } else {
653 priv->retry_data = wrqu->retry.value;
654 DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value);
657 /* FIXME !
658 * We might try to write directly the TX config register
659 * or to restart just the (R)TX process.
660 * I'm unsure if whole reset is really needed
663 rtl8180_commit(dev);
665 if(priv->up){
666 rtl8180_rtx_disable(dev);
667 rtl8180_rx_enable(dev);
668 rtl8180_tx_enable(dev);
672 exit:
673 up(&priv->wx_sem);
675 return err;
678 static int r8180_wx_get_retry(struct net_device *dev,
679 struct iw_request_info *info,
680 union iwreq_data *wrqu, char *extra)
682 struct r8180_priv *priv = ieee80211_priv(dev);
685 wrqu->retry.disabled = 0; /* can't be disabled */
687 if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
688 IW_RETRY_LIFETIME)
689 return -EINVAL;
691 if (wrqu->retry.flags & IW_RETRY_MAX) {
692 wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX;
693 wrqu->retry.value = priv->retry_rts;
694 } else {
695 wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MIN;
696 wrqu->retry.value = priv->retry_data;
698 /* DMESG("returning %d",wrqu->retry.value); */
701 return 0;
704 static int r8180_wx_get_sens(struct net_device *dev,
705 struct iw_request_info *info,
706 union iwreq_data *wrqu, char *extra)
708 struct r8180_priv *priv = ieee80211_priv(dev);
709 if (priv->rf_set_sens == NULL)
710 return -1; /* we have not this support for this radio */
711 wrqu->sens.value = priv->sens;
712 return 0;
716 static int r8180_wx_set_sens(struct net_device *dev,
717 struct iw_request_info *info,
718 union iwreq_data *wrqu, char *extra)
721 struct r8180_priv *priv = ieee80211_priv(dev);
723 short err = 0;
725 if (priv->ieee80211->bHwRadioOff)
726 return 0;
728 down(&priv->wx_sem);
729 /* DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); */
730 if (priv->rf_set_sens == NULL) {
731 err = -1; /* we have not this support for this radio */
732 goto exit;
734 if (priv->rf_set_sens(dev, wrqu->sens.value) == 0)
735 priv->sens = wrqu->sens.value;
736 else
737 err = -EINVAL;
739 exit:
740 up(&priv->wx_sem);
742 return err;
746 static int r8180_wx_set_rawtx(struct net_device *dev,
747 struct iw_request_info *info,
748 union iwreq_data *wrqu, char *extra)
750 struct r8180_priv *priv = ieee80211_priv(dev);
751 int ret;
753 if (priv->ieee80211->bHwRadioOff)
754 return 0;
756 down(&priv->wx_sem);
758 ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra);
760 up(&priv->wx_sem);
762 return ret;
766 static int r8180_wx_get_power(struct net_device *dev,
767 struct iw_request_info *info,
768 union iwreq_data *wrqu, char *extra)
770 int ret;
771 struct r8180_priv *priv = ieee80211_priv(dev);
773 down(&priv->wx_sem);
775 ret = ieee80211_wx_get_power(priv->ieee80211, info, wrqu, extra);
777 up(&priv->wx_sem);
779 return ret;
782 static int r8180_wx_set_power(struct net_device *dev,
783 struct iw_request_info *info,
784 union iwreq_data *wrqu, char *extra)
786 int ret;
787 struct r8180_priv *priv = ieee80211_priv(dev);
790 if (priv->ieee80211->bHwRadioOff)
791 return 0;
793 down(&priv->wx_sem);
794 printk("=>>>>>>>>>>=============================>set power:%d, %d!\n", wrqu->power.disabled, wrqu->power.flags);
795 if (wrqu->power.disabled == 0) {
796 wrqu->power.flags |= IW_POWER_ALL_R;
797 wrqu->power.flags |= IW_POWER_TIMEOUT;
798 wrqu->power.value = 1000;
801 ret = ieee80211_wx_set_power(priv->ieee80211, info, wrqu, extra);
803 up(&priv->wx_sem);
805 return ret;
808 static int r8180_wx_set_rts(struct net_device *dev,
809 struct iw_request_info *info,
810 union iwreq_data *wrqu, char *extra)
812 struct r8180_priv *priv = ieee80211_priv(dev);
815 if (priv->ieee80211->bHwRadioOff)
816 return 0;
818 if (wrqu->rts.disabled)
819 priv->rts = DEFAULT_RTS_THRESHOLD;
820 else {
821 if (wrqu->rts.value < MIN_RTS_THRESHOLD ||
822 wrqu->rts.value > MAX_RTS_THRESHOLD)
823 return -EINVAL;
825 priv->rts = wrqu->rts.value;
828 return 0;
830 static int r8180_wx_get_rts(struct net_device *dev,
831 struct iw_request_info *info,
832 union iwreq_data *wrqu, char *extra)
834 struct r8180_priv *priv = ieee80211_priv(dev);
838 wrqu->rts.value = priv->rts;
839 wrqu->rts.fixed = 0; /* no auto select */
840 wrqu->rts.disabled = (wrqu->rts.value == 0);
842 return 0;
844 static int dummy(struct net_device *dev, struct iw_request_info *a,
845 union iwreq_data *wrqu, char *b)
847 return -1;
851 static int r8180_wx_get_psmode(struct net_device *dev,
852 struct iw_request_info *info,
853 union iwreq_data *wrqu, char *extra)
855 struct r8180_priv *priv = ieee80211_priv(dev);
856 struct ieee80211_device *ieee;
857 int ret = 0;
861 down(&priv->wx_sem);
863 if(priv) {
864 ieee = priv->ieee80211;
865 if(ieee->ps == IEEE80211_PS_DISABLED) {
866 *((unsigned int *)extra) = IEEE80211_PS_DISABLED;
867 goto exit;
869 *((unsigned int *)extra) = IW_POWER_TIMEOUT;
870 if (ieee->ps & IEEE80211_PS_MBCAST)
871 *((unsigned int *)extra) |= IW_POWER_ALL_R;
872 else
873 *((unsigned int *)extra) |= IW_POWER_UNICAST_R;
874 } else
875 ret = -1;
876 exit:
877 up(&priv->wx_sem);
879 return ret;
881 static int r8180_wx_set_psmode(struct net_device *dev,
882 struct iw_request_info *info,
883 union iwreq_data *wrqu, char *extra)
885 struct r8180_priv *priv = ieee80211_priv(dev);
886 //struct ieee80211_device *ieee;
887 int ret = 0;
891 down(&priv->wx_sem);
893 ret = ieee80211_wx_set_power(priv->ieee80211, info, wrqu, extra);
895 up(&priv->wx_sem);
897 return ret;
902 static int r8180_wx_get_iwmode(struct net_device *dev,
903 struct iw_request_info *info,
904 union iwreq_data *wrqu, char *extra)
906 struct r8180_priv *priv = ieee80211_priv(dev);
907 struct ieee80211_device *ieee;
908 int ret = 0;
912 down(&priv->wx_sem);
914 ieee = priv->ieee80211;
916 strcpy(extra, "802.11");
917 if (ieee->modulation & IEEE80211_CCK_MODULATION) {
918 strcat(extra, "b");
919 if (ieee->modulation & IEEE80211_OFDM_MODULATION)
920 strcat(extra, "/g");
921 } else if (ieee->modulation & IEEE80211_OFDM_MODULATION)
922 strcat(extra, "g");
924 up(&priv->wx_sem);
926 return ret;
928 static int r8180_wx_set_iwmode(struct net_device *dev,
929 struct iw_request_info *info,
930 union iwreq_data *wrqu, char *extra)
932 struct r8180_priv *priv = ieee80211_priv(dev);
933 struct ieee80211_device *ieee = priv->ieee80211;
934 int *param = (int *)extra;
935 int ret = 0;
936 int modulation = 0, mode = 0;
939 if (priv->ieee80211->bHwRadioOff)
940 return 0;
942 down(&priv->wx_sem);
944 if (*param == 1) {
945 modulation |= IEEE80211_CCK_MODULATION;
946 mode = IEEE_B;
947 printk(KERN_INFO "B mode!\n");
948 } else if (*param == 2) {
949 modulation |= IEEE80211_OFDM_MODULATION;
950 mode = IEEE_G;
951 printk(KERN_INFO "G mode!\n");
952 } else if (*param == 3) {
953 modulation |= IEEE80211_CCK_MODULATION;
954 modulation |= IEEE80211_OFDM_MODULATION;
955 mode = IEEE_B|IEEE_G;
956 printk(KERN_INFO "B/G mode!\n");
959 if (ieee->proto_started) {
960 ieee80211_stop_protocol(ieee);
961 ieee->mode = mode;
962 ieee->modulation = modulation;
963 ieee80211_start_protocol(ieee);
964 } else {
965 ieee->mode = mode;
966 ieee->modulation = modulation;
967 /* ieee80211_start_protocol(ieee); */
970 up(&priv->wx_sem);
972 return ret;
974 static int r8180_wx_get_preamble(struct net_device *dev,
975 struct iw_request_info *info,
976 union iwreq_data *wrqu, char *extra)
978 struct r8180_priv *priv = ieee80211_priv(dev);
982 down(&priv->wx_sem);
986 *extra = (char) priv->plcp_preamble_mode; /* 0:auto 1:short 2:long */
987 up(&priv->wx_sem);
989 return 0;
991 static int r8180_wx_set_preamble(struct net_device *dev,
992 struct iw_request_info *info,
993 union iwreq_data *wrqu, char *extra)
995 struct r8180_priv *priv = ieee80211_priv(dev);
996 int ret = 0;
999 if (priv->ieee80211->bHwRadioOff)
1000 return 0;
1002 down(&priv->wx_sem);
1003 if (*extra < 0 || *extra > 2)
1004 ret = -1;
1005 else
1006 priv->plcp_preamble_mode = *((short *)extra) ;
1010 up(&priv->wx_sem);
1012 return ret;
1014 static int r8180_wx_get_siglevel(struct net_device *dev,
1015 struct iw_request_info *info,
1016 union iwreq_data *wrqu, char *extra)
1018 struct r8180_priv *priv = ieee80211_priv(dev);
1019 /* struct ieee80211_network *network = &(priv->ieee80211->current_network); */
1020 int ret = 0;
1024 down(&priv->wx_sem);
1025 /* Modify by hikaru 6.5 */
1026 *((int *)extra) = priv->wstats.qual.level;/*for interface test ,it should be the priv->wstats.qual.level; */
1030 up(&priv->wx_sem);
1032 return ret;
1034 static int r8180_wx_get_sigqual(struct net_device *dev,
1035 struct iw_request_info *info,
1036 union iwreq_data *wrqu, char *extra)
1038 struct r8180_priv *priv = ieee80211_priv(dev);
1039 /* struct ieee80211_network *network = &(priv->ieee80211->current_network); */
1040 int ret = 0;
1044 down(&priv->wx_sem);
1045 /* Modify by hikaru 6.5 */
1046 *((int *)extra) = priv->wstats.qual.qual;/* for interface test ,it should be the priv->wstats.qual.qual; */
1050 up(&priv->wx_sem);
1052 return ret;
1054 static int r8180_wx_reset_stats(struct net_device *dev,
1055 struct iw_request_info *info,
1056 union iwreq_data *wrqu, char *extra)
1058 struct r8180_priv *priv = ieee80211_priv(dev);
1059 down(&priv->wx_sem);
1061 priv->stats.txrdu = 0;
1062 priv->stats.rxrdu = 0;
1063 priv->stats.rxnolast = 0;
1064 priv->stats.rxnodata = 0;
1065 priv->stats.rxnopointer = 0;
1066 priv->stats.txnperr = 0;
1067 priv->stats.txresumed = 0;
1068 priv->stats.rxerr = 0;
1069 priv->stats.rxoverflow = 0;
1070 priv->stats.rxint = 0;
1072 priv->stats.txnpokint = 0;
1073 priv->stats.txhpokint = 0;
1074 priv->stats.txhperr = 0;
1075 priv->stats.ints = 0;
1076 priv->stats.shints = 0;
1077 priv->stats.txoverflow = 0;
1078 priv->stats.rxdmafail = 0;
1079 priv->stats.txbeacon = 0;
1080 priv->stats.txbeaconerr = 0;
1081 priv->stats.txlpokint = 0;
1082 priv->stats.txlperr = 0;
1083 priv->stats.txretry = 0;/* 20060601 */
1084 priv->stats.rxcrcerrmin = 0 ;
1085 priv->stats.rxcrcerrmid = 0;
1086 priv->stats.rxcrcerrmax = 0;
1087 priv->stats.rxicverr = 0;
1089 up(&priv->wx_sem);
1091 return 0;
1094 static int r8180_wx_radio_on(struct net_device *dev,
1095 struct iw_request_info *info,
1096 union iwreq_data *wrqu, char *extra)
1098 struct r8180_priv *priv = ieee80211_priv(dev);
1100 if (priv->ieee80211->bHwRadioOff)
1101 return 0;
1104 down(&priv->wx_sem);
1105 priv->rf_wakeup(dev);
1107 up(&priv->wx_sem);
1109 return 0;
1113 static int r8180_wx_radio_off(struct net_device *dev,
1114 struct iw_request_info *info,
1115 union iwreq_data *wrqu, char *extra)
1117 struct r8180_priv *priv = ieee80211_priv(dev);
1119 if (priv->ieee80211->bHwRadioOff)
1120 return 0;
1123 down(&priv->wx_sem);
1124 priv->rf_sleep(dev);
1126 up(&priv->wx_sem);
1128 return 0;
1131 static int r8180_wx_get_channelplan(struct net_device *dev,
1132 struct iw_request_info *info,
1133 union iwreq_data *wrqu, char *extra)
1135 struct r8180_priv *priv = ieee80211_priv(dev);
1139 down(&priv->wx_sem);
1140 *extra = priv->channel_plan;
1144 up(&priv->wx_sem);
1146 return 0;
1148 static int r8180_wx_set_channelplan(struct net_device *dev,
1149 struct iw_request_info *info,
1150 union iwreq_data *wrqu, char *extra)
1152 struct r8180_priv *priv = ieee80211_priv(dev);
1153 /* struct ieee80211_device *ieee = netdev_priv(dev); */
1154 int *val = (int *)extra;
1155 int i;
1156 printk("-----in fun %s\n", __func__);
1158 if (priv->ieee80211->bHwRadioOff)
1159 return 0;
1161 /* unsigned long flags; */
1162 down(&priv->wx_sem);
1163 if (DefaultChannelPlan[*val].Len != 0) {
1164 priv->channel_plan = *val;
1165 /* Clear old channel map 8 */
1166 for (i = 1; i <= MAX_CHANNEL_NUMBER; i++)
1167 GET_DOT11D_INFO(priv->ieee80211)->channel_map[i] = 0;
1169 /* Set new channel map */
1170 for (i = 1; i <= DefaultChannelPlan[*val].Len; i++)
1171 GET_DOT11D_INFO(priv->ieee80211)->channel_map[DefaultChannelPlan[*val].Channel[i-1]] = 1;
1174 up(&priv->wx_sem);
1176 return 0;
1179 static int r8180_wx_get_version(struct net_device *dev,
1180 struct iw_request_info *info,
1181 union iwreq_data *wrqu, char *extra)
1183 struct r8180_priv *priv = ieee80211_priv(dev);
1184 /* struct ieee80211_device *ieee; */
1186 down(&priv->wx_sem);
1187 strcpy(extra, "1020.0808");
1188 up(&priv->wx_sem);
1190 return 0;
1193 /* added by amy 080818 */
1194 /*receive datarate from user typing valid rate is from 2 to 108 (1 - 54M), if input 0, return to normal rate adaptive. */
1195 static int r8180_wx_set_forcerate(struct net_device *dev,
1196 struct iw_request_info *info,
1197 union iwreq_data *wrqu, char *extra)
1199 struct r8180_priv *priv = ieee80211_priv(dev);
1200 u8 forcerate = *extra;
1202 down(&priv->wx_sem);
1204 printk("==============>%s(): forcerate is %d\n", __func__, forcerate);
1205 if ((forcerate == 2) || (forcerate == 4) || (forcerate == 11) || (forcerate == 22) || (forcerate == 12) ||
1206 (forcerate == 18) || (forcerate == 24) || (forcerate == 36) || (forcerate == 48) || (forcerate == 72) ||
1207 (forcerate == 96) || (forcerate == 108))
1209 priv->ForcedDataRate = 1;
1210 priv->ieee80211->rate = forcerate * 5;
1211 } else if (forcerate == 0) {
1212 priv->ForcedDataRate = 0;
1213 printk("OK! return rate adaptive\n");
1214 } else
1215 printk("ERR: wrong rate\n");
1216 up(&priv->wx_sem);
1217 return 0;
1220 static int r8180_wx_set_enc_ext(struct net_device *dev,
1221 struct iw_request_info *info,
1222 union iwreq_data *wrqu, char *extra)
1225 struct r8180_priv *priv = ieee80211_priv(dev);
1226 /* printk("===>%s()\n", __func__); */
1228 int ret = 0;
1230 if (priv->ieee80211->bHwRadioOff)
1231 return 0;
1233 down(&priv->wx_sem);
1234 ret = ieee80211_wx_set_encode_ext(priv->ieee80211, info, wrqu, extra);
1235 up(&priv->wx_sem);
1236 return ret;
1239 static int r8180_wx_set_auth(struct net_device *dev,
1240 struct iw_request_info *info,
1241 union iwreq_data *wrqu, char *extra)
1243 /* printk("====>%s()\n", __func__); */
1244 struct r8180_priv *priv = ieee80211_priv(dev);
1245 int ret = 0;
1247 if (priv->ieee80211->bHwRadioOff)
1248 return 0;
1250 down(&priv->wx_sem);
1251 ret = ieee80211_wx_set_auth(priv->ieee80211, info, &wrqu->param, extra);
1252 up(&priv->wx_sem);
1253 return ret;
1256 static int r8180_wx_set_mlme(struct net_device *dev,
1257 struct iw_request_info *info,
1258 union iwreq_data *wrqu, char *extra)
1260 /* printk("====>%s()\n", __func__); */
1262 int ret = 0;
1263 struct r8180_priv *priv = ieee80211_priv(dev);
1266 if (priv->ieee80211->bHwRadioOff)
1267 return 0;
1270 down(&priv->wx_sem);
1271 #if 1
1272 ret = ieee80211_wx_set_mlme(priv->ieee80211, info, wrqu, extra);
1273 #endif
1274 up(&priv->wx_sem);
1275 return ret;
1277 static int r8180_wx_set_gen_ie(struct net_device *dev,
1278 struct iw_request_info *info,
1279 union iwreq_data *wrqu, char *extra)
1281 /* printk("====>%s(), len:%d\n", __func__, data->length); */
1282 int ret = 0;
1283 struct r8180_priv *priv = ieee80211_priv(dev);
1286 if (priv->ieee80211->bHwRadioOff)
1287 return 0;
1289 down(&priv->wx_sem);
1290 #if 1
1291 ret = ieee80211_wx_set_gen_ie(priv->ieee80211, extra, wrqu->data.length);
1292 #endif
1293 up(&priv->wx_sem);
1294 /* printk("<======%s(), ret:%d\n", __func__, ret); */
1295 return ret;
1299 static iw_handler r8180_wx_handlers[] = {
1300 NULL, /* SIOCSIWCOMMIT */
1301 r8180_wx_get_name, /* SIOCGIWNAME */
1302 dummy, /* SIOCSIWNWID */
1303 dummy, /* SIOCGIWNWID */
1304 r8180_wx_set_freq, /* SIOCSIWFREQ */
1305 r8180_wx_get_freq, /* SIOCGIWFREQ */
1306 r8180_wx_set_mode, /* SIOCSIWMODE */
1307 r8180_wx_get_mode, /* SIOCGIWMODE */
1308 r8180_wx_set_sens, /* SIOCSIWSENS */
1309 r8180_wx_get_sens, /* SIOCGIWSENS */
1310 NULL, /* SIOCSIWRANGE */
1311 rtl8180_wx_get_range, /* SIOCGIWRANGE */
1312 NULL, /* SIOCSIWPRIV */
1313 NULL, /* SIOCGIWPRIV */
1314 NULL, /* SIOCSIWSTATS */
1315 NULL, /* SIOCGIWSTATS */
1316 dummy, /* SIOCSIWSPY */
1317 dummy, /* SIOCGIWSPY */
1318 NULL, /* SIOCGIWTHRSPY */
1319 NULL, /* SIOCWIWTHRSPY */
1320 r8180_wx_set_wap, /* SIOCSIWAP */
1321 r8180_wx_get_wap, /* SIOCGIWAP */
1322 r8180_wx_set_mlme, /* SIOCSIWMLME*/
1323 dummy, /* SIOCGIWAPLIST -- depricated */
1324 r8180_wx_set_scan, /* SIOCSIWSCAN */
1325 r8180_wx_get_scan, /* SIOCGIWSCAN */
1326 r8180_wx_set_essid, /* SIOCSIWESSID */
1327 r8180_wx_get_essid, /* SIOCGIWESSID */
1328 dummy, /* SIOCSIWNICKN */
1329 dummy, /* SIOCGIWNICKN */
1330 NULL, /* -- hole -- */
1331 NULL, /* -- hole -- */
1332 r8180_wx_set_rate, /* SIOCSIWRATE */
1333 r8180_wx_get_rate, /* SIOCGIWRATE */
1334 r8180_wx_set_rts, /* SIOCSIWRTS */
1335 r8180_wx_get_rts, /* SIOCGIWRTS */
1336 r8180_wx_set_frag, /* SIOCSIWFRAG */
1337 r8180_wx_get_frag, /* SIOCGIWFRAG */
1338 dummy, /* SIOCSIWTXPOW */
1339 dummy, /* SIOCGIWTXPOW */
1340 r8180_wx_set_retry, /* SIOCSIWRETRY */
1341 r8180_wx_get_retry, /* SIOCGIWRETRY */
1342 r8180_wx_set_enc, /* SIOCSIWENCODE */
1343 r8180_wx_get_enc, /* SIOCGIWENCODE */
1344 r8180_wx_set_power, /* SIOCSIWPOWER */
1345 r8180_wx_get_power, /* SIOCGIWPOWER */
1346 NULL, /*---hole---*/
1347 NULL, /*---hole---*/
1348 r8180_wx_set_gen_ie, /* SIOCSIWGENIE */
1349 NULL, /* SIOCSIWGENIE */
1350 r8180_wx_set_auth, /* SIOCSIWAUTH */
1351 NULL, /* SIOCSIWAUTH */
1352 r8180_wx_set_enc_ext, /* SIOCSIWENCODEEXT */
1353 NULL, /* SIOCSIWENCODEEXT */
1354 NULL, /* SIOCSIWPMKSA */
1355 NULL, /*---hole---*/
1359 static const struct iw_priv_args r8180_private_args[] = {
1361 SIOCIWFIRSTPRIV + 0x0,
1362 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
1364 { SIOCIWFIRSTPRIV + 0x1,
1365 0, 0, "dummy"
1369 SIOCIWFIRSTPRIV + 0x2,
1370 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "beaconint"
1372 { SIOCIWFIRSTPRIV + 0x3,
1373 0, 0, "dummy"
1376 /* added by christian */
1379 SIOCIWFIRSTPRIV + 0x2,
1380 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "prismhdr"
1383 /* end added by christian */
1385 SIOCIWFIRSTPRIV + 0x4,
1386 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
1389 { SIOCIWFIRSTPRIV + 0x5,
1390 0, 0, "dummy"
1394 SIOCIWFIRSTPRIV + 0x6,
1395 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx"
1398 { SIOCIWFIRSTPRIV + 0x7,
1399 0, 0, "dummy"
1404 SIOCIWFIRSTPRIV + 0x5,
1405 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getpsmode"
1408 SIOCIWFIRSTPRIV + 0x6,
1409 IW_PRIV_SIZE_FIXED, 0, "setpsmode"
1412 /* set/get mode have been realized in public handlers */
1415 SIOCIWFIRSTPRIV + 0x8,
1416 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setiwmode"
1419 SIOCIWFIRSTPRIV + 0x9,
1420 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 32, "getiwmode"
1423 SIOCIWFIRSTPRIV + 0xA,
1424 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setpreamble"
1427 SIOCIWFIRSTPRIV + 0xB,
1428 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getpreamble"
1430 { SIOCIWFIRSTPRIV + 0xC,
1431 0, 0, "dummy"
1434 SIOCIWFIRSTPRIV + 0xD,
1435 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getrssi"
1437 { SIOCIWFIRSTPRIV + 0xE,
1438 0, 0, "dummy"
1441 SIOCIWFIRSTPRIV + 0xF,
1442 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getlinkqual"
1445 SIOCIWFIRSTPRIV + 0x10,
1446 0, 0, "resetstats"
1449 SIOCIWFIRSTPRIV + 0x11,
1450 0, 0, "dummy"
1453 SIOCIWFIRSTPRIV + 0x12,
1454 0, 0, "radioon"
1457 SIOCIWFIRSTPRIV + 0x13,
1458 0, 0, "radiooff"
1461 SIOCIWFIRSTPRIV + 0x14,
1462 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setchannel"
1465 SIOCIWFIRSTPRIV + 0x15,
1466 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel"
1469 SIOCIWFIRSTPRIV + 0x16,
1470 0, 0, "dummy"
1473 SIOCIWFIRSTPRIV + 0x17,
1474 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 32, "getversion"
1477 SIOCIWFIRSTPRIV + 0x18,
1478 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setrate"
1483 static iw_handler r8180_private_handler[] = {
1484 r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/
1485 dummy,
1486 r8180_wx_set_beaconinterval,
1487 dummy,
1488 /* r8180_wx_set_monitor_type, */
1489 r8180_wx_set_scan_type,
1490 dummy,
1491 r8180_wx_set_rawtx,
1492 dummy,
1493 r8180_wx_set_iwmode,
1494 r8180_wx_get_iwmode,
1495 r8180_wx_set_preamble,
1496 r8180_wx_get_preamble,
1497 dummy,
1498 r8180_wx_get_siglevel,
1499 dummy,
1500 r8180_wx_get_sigqual,
1501 r8180_wx_reset_stats,
1502 dummy,/* r8180_wx_get_stats */
1503 r8180_wx_radio_on,
1504 r8180_wx_radio_off,
1505 r8180_wx_set_channelplan,
1506 r8180_wx_get_channelplan,
1507 dummy,
1508 r8180_wx_get_version,
1509 r8180_wx_set_forcerate,
1512 static inline int is_same_network(struct ieee80211_network *src,
1513 struct ieee80211_network *dst,
1514 struct ieee80211_device *ieee)
1516 /* A network is only a duplicate if the channel, BSSID, ESSID
1517 * and the capability field (in particular IBSS and BSS) all match.
1518 * We treat all <hidden> with the same BSSID and channel
1519 * as one network */
1520 return (((src->ssid_len == dst->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) && /* YJ,mod, 080819,for hidden ap */
1521 /* ((src->ssid_len == dst->ssid_len) && */
1522 (src->channel == dst->channel) &&
1523 !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
1524 (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) && /* YJ,mod, 080819,for hidden ap */
1525 /*!memcmp(src->ssid, dst->ssid, src->ssid_len) && */
1526 ((src->capability & WLAN_CAPABILITY_IBSS) ==
1527 (dst->capability & WLAN_CAPABILITY_IBSS)) &&
1528 ((src->capability & WLAN_CAPABILITY_BSS) ==
1529 (dst->capability & WLAN_CAPABILITY_BSS)));
1532 /* WB modefied to show signal to GUI on 18-01-2008 */
1533 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
1535 struct r8180_priv *priv = ieee80211_priv(dev);
1536 struct ieee80211_device* ieee = priv->ieee80211;
1537 struct iw_statistics* wstats = &priv->wstats;
1538 /* struct ieee80211_network* target = NULL; */
1539 int tmp_level = 0;
1540 int tmp_qual = 0;
1541 int tmp_noise = 0;
1542 /* unsigned long flag; */
1544 if (ieee->state < IEEE80211_LINKED) {
1545 wstats->qual.qual = 0;
1546 wstats->qual.level = 0;
1547 wstats->qual.noise = 0;
1548 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1549 return wstats;
1552 tmp_level = (&ieee->current_network)->stats.signal;
1553 tmp_qual = (&ieee->current_network)->stats.signalstrength;
1554 tmp_noise = (&ieee->current_network)->stats.noise;
1555 /* printk("level:%d, qual:%d, noise:%d\n", tmp_level, tmp_qual, tmp_noise); */
1557 /* printk("level:%d\n", tmp_level); */
1558 wstats->qual.level = tmp_level;
1559 wstats->qual.qual = tmp_qual;
1560 wstats->qual.noise = tmp_noise;
1561 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1562 return wstats;
1565 struct iw_handler_def r8180_wx_handlers_def = {
1566 .standard = r8180_wx_handlers,
1567 .num_standard = ARRAY_SIZE(r8180_wx_handlers),
1568 .private = r8180_private_handler,
1569 .num_private = ARRAY_SIZE(r8180_private_handler),
1570 .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args),
1571 .get_wireless_stats = r8180_get_wireless_stats,
1572 .private_args = (struct iw_priv_args *)r8180_private_args,