1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
5 * Contact Information: wlanfae <wlanfae@realtek.com>
7 #include <linux/string.h>
12 static u32 rtl8192_rates[] = {
13 1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000,
14 18000000, 24000000, 36000000, 48000000, 54000000
21 static int _rtl92e_wx_get_freq(struct net_device *dev,
22 struct iw_request_info *a,
23 union iwreq_data *wrqu, char *b)
25 struct r8192_priv *priv = rtllib_priv(dev);
27 return rtllib_wx_get_freq(priv->rtllib, a, wrqu, b);
30 static int _rtl92e_wx_get_mode(struct net_device *dev,
31 struct iw_request_info *a,
32 union iwreq_data *wrqu, char *b)
34 struct r8192_priv *priv = rtllib_priv(dev);
36 return rtllib_wx_get_mode(priv->rtllib, a, wrqu, b);
39 static int _rtl92e_wx_get_rate(struct net_device *dev,
40 struct iw_request_info *info,
41 union iwreq_data *wrqu, char *extra)
43 struct r8192_priv *priv = rtllib_priv(dev);
45 return rtllib_wx_get_rate(priv->rtllib, info, wrqu, extra);
48 static int _rtl92e_wx_set_rate(struct net_device *dev,
49 struct iw_request_info *info,
50 union iwreq_data *wrqu, char *extra)
53 struct r8192_priv *priv = rtllib_priv(dev);
55 if (priv->hw_radio_off)
58 mutex_lock(&priv->wx_mutex);
60 ret = rtllib_wx_set_rate(priv->rtllib, info, wrqu, extra);
62 mutex_unlock(&priv->wx_mutex);
67 static int _rtl92e_wx_set_rts(struct net_device *dev,
68 struct iw_request_info *info,
69 union iwreq_data *wrqu, char *extra)
72 struct r8192_priv *priv = rtllib_priv(dev);
74 if (priv->hw_radio_off)
77 mutex_lock(&priv->wx_mutex);
79 ret = rtllib_wx_set_rts(priv->rtllib, info, wrqu, extra);
81 mutex_unlock(&priv->wx_mutex);
86 static int _rtl92e_wx_get_rts(struct net_device *dev,
87 struct iw_request_info *info,
88 union iwreq_data *wrqu, char *extra)
90 struct r8192_priv *priv = rtllib_priv(dev);
92 return rtllib_wx_get_rts(priv->rtllib, info, wrqu, extra);
95 static int _rtl92e_wx_set_power(struct net_device *dev,
96 struct iw_request_info *info,
97 union iwreq_data *wrqu, char *extra)
100 struct r8192_priv *priv = rtllib_priv(dev);
102 if (priv->hw_radio_off) {
103 netdev_warn(dev, "%s(): Can't set Power: Radio is Off.\n",
107 mutex_lock(&priv->wx_mutex);
109 ret = rtllib_wx_set_power(priv->rtllib, info, wrqu, extra);
111 mutex_unlock(&priv->wx_mutex);
116 static int _rtl92e_wx_get_power(struct net_device *dev,
117 struct iw_request_info *info,
118 union iwreq_data *wrqu, char *extra)
120 struct r8192_priv *priv = rtllib_priv(dev);
122 return rtllib_wx_get_power(priv->rtllib, info, wrqu, extra);
125 static int _rtl92e_wx_set_mode(struct net_device *dev,
126 struct iw_request_info *a,
127 union iwreq_data *wrqu, char *b)
129 struct r8192_priv *priv = rtllib_priv(dev);
131 enum rt_rf_power_state rt_state;
134 if (priv->hw_radio_off)
136 rt_state = priv->rtllib->rf_power_state;
137 mutex_lock(&priv->wx_mutex);
138 if (wrqu->mode == IW_MODE_MONITOR) {
139 if (rt_state == rf_off) {
140 if (priv->rtllib->rf_off_reason >
142 netdev_warn(dev, "%s(): RF is OFF.\n",
144 mutex_unlock(&priv->wx_mutex);
148 "=========>%s(): rtl92e_ips_leave\n",
150 mutex_lock(&priv->rtllib->ips_mutex);
151 rtl92e_ips_leave(dev);
152 mutex_unlock(&priv->rtllib->ips_mutex);
155 ret = rtllib_wx_set_mode(priv->rtllib, a, wrqu, b);
157 mutex_unlock(&priv->wx_mutex);
161 struct iw_range_with_scan_capa {
162 /* Informative stuff (to choose between different interface) */
163 __u32 throughput; /* To give an idea... */
164 /* In theory this value should be the maximum benchmarked
165 * TCP/IP throughput, because with most of these devices the
166 * bit rate is meaningless (overhead an co) to estimate how
167 * fast the connection will go and pick the fastest one.
168 * I suggest people to play with Netperf or any benchmark...
171 /* NWID (or domain id) */
172 __u32 min_nwid; /* Minimal NWID we are able to set */
173 __u32 max_nwid; /* Maximal NWID we are able to set */
175 /* Old Frequency (backward compat - moved lower ) */
176 __u16 old_num_channels;
177 __u8 old_num_frequency;
179 /* Scan capabilities */
183 static int _rtl92e_wx_get_range(struct net_device *dev,
184 struct iw_request_info *info,
185 union iwreq_data *wrqu, char *extra)
187 struct iw_range *range = (struct iw_range *)extra;
188 struct r8192_priv *priv = rtllib_priv(dev);
192 wrqu->data.length = sizeof(*range);
193 memset(range, 0, sizeof(*range));
195 /* ~130 Mb/s real (802.11n) */
196 range->throughput = 130 * 1000 * 1000;
198 range->max_qual.qual = 100;
199 range->max_qual.level = 0;
200 range->max_qual.noise = 0;
201 range->max_qual.updated = 7; /* Updated all three */
203 range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */
204 range->avg_qual.level = 0;
205 range->avg_qual.noise = 0;
206 range->avg_qual.updated = 7; /* Updated all three */
208 range->num_bitrates = min(RATE_COUNT, IW_MAX_BITRATES);
210 for (i = 0; i < range->num_bitrates; i++)
211 range->bitrate[i] = rtl8192_rates[i];
213 range->max_rts = DEFAULT_RTS_THRESHOLD;
214 range->min_frag = MIN_FRAG_THRESHOLD;
215 range->max_frag = MAX_FRAG_THRESHOLD;
218 range->max_pmp = 5000000;
220 range->max_pmt = 65535 * 1000;
221 range->pmp_flags = IW_POWER_PERIOD;
222 range->pmt_flags = IW_POWER_TIMEOUT;
223 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
224 range->we_version_compiled = WIRELESS_EXT;
225 range->we_version_source = 18;
227 for (i = 0, val = 0; i < 14; i++) {
228 if ((priv->rtllib->active_channel_map)[i + 1]) {
231 range->freq[val].i = i + 1;
232 freq_khz = ieee80211_channel_to_freq_khz(i + 1, NL80211_BAND_2GHZ);
233 range->freq[val].m = freq_khz * 100;
234 range->freq[val].e = 1;
238 if (val == IW_MAX_FREQUENCIES)
241 range->num_frequency = val;
242 range->num_channels = val;
243 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
244 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
245 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE;
247 /* Event capability (kernel + driver) */
252 static int _rtl92e_wx_set_scan(struct net_device *dev,
253 struct iw_request_info *a,
254 union iwreq_data *wrqu, char *b)
256 struct r8192_priv *priv = rtllib_priv(dev);
257 struct rtllib_device *ieee = priv->rtllib;
258 enum rt_rf_power_state rt_state;
261 if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) {
262 if ((ieee->link_state >= RTLLIB_ASSOCIATING) &&
263 (ieee->link_state <= RTLLIB_ASSOCIATING_AUTHENTICATED))
265 if ((priv->rtllib->link_state == MAC80211_LINKED) &&
266 (priv->rtllib->CntAfterLink < 2))
270 if (priv->hw_radio_off) {
271 netdev_info(dev, "================>%s(): hwradio off\n",
275 rt_state = priv->rtllib->rf_power_state;
278 if (priv->rtllib->link_detect_info.bBusyTraffic)
281 if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
282 struct iw_scan_req *req = (struct iw_scan_req *)b;
284 if (req->essid_len) {
285 int len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE);
287 ieee->current_network.ssid_len = len;
288 memcpy(ieee->current_network.ssid, req->essid, len);
292 mutex_lock(&priv->wx_mutex);
294 priv->rtllib->FirstIe_InScan = true;
296 if (priv->rtllib->link_state != MAC80211_LINKED) {
297 if (rt_state == rf_off) {
298 if (priv->rtllib->rf_off_reason >
300 netdev_warn(dev, "%s(): RF is OFF.\n",
302 mutex_unlock(&priv->wx_mutex);
305 mutex_lock(&priv->rtllib->ips_mutex);
306 rtl92e_ips_leave(dev);
307 mutex_unlock(&priv->rtllib->ips_mutex);
309 rtllib_stop_scan(priv->rtllib);
310 if (priv->rtllib->rf_power_state != rf_off) {
311 priv->rtllib->actscanning = true;
313 ieee->ScanOperationBackupHandler(ieee->dev, SCAN_OPT_BACKUP);
315 rtllib_start_scan_syncro(priv->rtllib);
317 ieee->ScanOperationBackupHandler(ieee->dev, SCAN_OPT_RESTORE);
321 priv->rtllib->actscanning = true;
322 ret = rtllib_wx_set_scan(priv->rtllib, a, wrqu, b);
325 mutex_unlock(&priv->wx_mutex);
329 static int _rtl92e_wx_get_scan(struct net_device *dev,
330 struct iw_request_info *a,
331 union iwreq_data *wrqu, char *b)
334 struct r8192_priv *priv = rtllib_priv(dev);
339 if (priv->hw_radio_off)
342 mutex_lock(&priv->wx_mutex);
344 ret = rtllib_wx_get_scan(priv->rtllib, a, wrqu, b);
346 mutex_unlock(&priv->wx_mutex);
351 static int _rtl92e_wx_set_essid(struct net_device *dev,
352 struct iw_request_info *a,
353 union iwreq_data *wrqu, char *b)
355 struct r8192_priv *priv = rtllib_priv(dev);
358 if (priv->hw_radio_off) {
360 "=========>%s():hw radio off,or Rf state is rf_off, return\n",
364 mutex_lock(&priv->wx_mutex);
365 ret = rtllib_wx_set_essid(priv->rtllib, a, wrqu, b);
367 mutex_unlock(&priv->wx_mutex);
372 static int _rtl92e_wx_get_essid(struct net_device *dev,
373 struct iw_request_info *a,
374 union iwreq_data *wrqu, char *b)
377 struct r8192_priv *priv = rtllib_priv(dev);
379 mutex_lock(&priv->wx_mutex);
381 ret = rtllib_wx_get_essid(priv->rtllib, a, wrqu, b);
383 mutex_unlock(&priv->wx_mutex);
388 static int _rtl92e_wx_set_nick(struct net_device *dev,
389 struct iw_request_info *info,
390 union iwreq_data *wrqu, char *extra)
392 struct r8192_priv *priv = rtllib_priv(dev);
394 if (wrqu->data.length > IW_ESSID_MAX_SIZE)
396 mutex_lock(&priv->wx_mutex);
397 wrqu->data.length = min_t(size_t, wrqu->data.length,
399 memset(priv->nick, 0, sizeof(priv->nick));
400 memcpy(priv->nick, extra, wrqu->data.length);
401 mutex_unlock(&priv->wx_mutex);
405 static int _rtl92e_wx_get_nick(struct net_device *dev,
406 struct iw_request_info *info,
407 union iwreq_data *wrqu, char *extra)
409 struct r8192_priv *priv = rtllib_priv(dev);
411 mutex_lock(&priv->wx_mutex);
412 wrqu->data.length = strlen(priv->nick);
413 memcpy(extra, priv->nick, wrqu->data.length);
414 wrqu->data.flags = 1; /* active */
415 mutex_unlock(&priv->wx_mutex);
419 static int _rtl92e_wx_set_freq(struct net_device *dev,
420 struct iw_request_info *a,
421 union iwreq_data *wrqu, char *b)
424 struct r8192_priv *priv = rtllib_priv(dev);
426 if (priv->hw_radio_off)
429 mutex_lock(&priv->wx_mutex);
431 ret = rtllib_wx_set_freq(priv->rtllib, a, wrqu, b);
433 mutex_unlock(&priv->wx_mutex);
437 static int _rtl92e_wx_get_name(struct net_device *dev,
438 struct iw_request_info *info,
439 union iwreq_data *wrqu, char *extra)
441 struct r8192_priv *priv = rtllib_priv(dev);
443 return rtllib_wx_get_name(priv->rtllib, info, wrqu, extra);
446 static int _rtl92e_wx_set_frag(struct net_device *dev,
447 struct iw_request_info *info,
448 union iwreq_data *wrqu, char *extra)
450 struct r8192_priv *priv = rtllib_priv(dev);
452 if (priv->hw_radio_off)
455 if (wrqu->frag.disabled) {
456 priv->rtllib->fts = DEFAULT_FRAG_THRESHOLD;
458 if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
459 wrqu->frag.value > MAX_FRAG_THRESHOLD)
462 priv->rtllib->fts = wrqu->frag.value & ~0x1;
468 static int _rtl92e_wx_get_frag(struct net_device *dev,
469 struct iw_request_info *info,
470 union iwreq_data *wrqu, char *extra)
472 struct r8192_priv *priv = rtllib_priv(dev);
474 wrqu->frag.value = priv->rtllib->fts;
475 wrqu->frag.fixed = 0; /* no auto select */
476 wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD);
481 static int _rtl92e_wx_set_wap(struct net_device *dev,
482 struct iw_request_info *info,
483 union iwreq_data *awrq, char *extra)
486 struct r8192_priv *priv = rtllib_priv(dev);
488 if (priv->hw_radio_off)
491 mutex_lock(&priv->wx_mutex);
493 ret = rtllib_wx_set_wap(priv->rtllib, info, awrq, extra);
495 mutex_unlock(&priv->wx_mutex);
500 static int _rtl92e_wx_get_wap(struct net_device *dev,
501 struct iw_request_info *info,
502 union iwreq_data *wrqu, char *extra)
504 struct r8192_priv *priv = rtllib_priv(dev);
506 return rtllib_wx_get_wap(priv->rtllib, info, wrqu, extra);
509 static int _rtl92e_wx_get_enc(struct net_device *dev,
510 struct iw_request_info *info,
511 union iwreq_data *wrqu, char *key)
513 struct r8192_priv *priv = rtllib_priv(dev);
515 return rtllib_wx_get_encode(priv->rtllib, info, wrqu, key);
518 static int _rtl92e_wx_set_enc(struct net_device *dev,
519 struct iw_request_info *info,
520 union iwreq_data *wrqu, char *key)
522 struct r8192_priv *priv = rtllib_priv(dev);
525 struct rtllib_device *ieee = priv->rtllib;
526 u32 hwkey[4] = {0, 0, 0, 0};
529 u8 zero_addr[4][6] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
530 {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
531 {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
532 {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} };
535 if (priv->hw_radio_off)
541 priv->rtllib->wx_set_enc = 1;
542 mutex_lock(&priv->rtllib->ips_mutex);
543 rtl92e_ips_leave(dev);
544 mutex_unlock(&priv->rtllib->ips_mutex);
545 mutex_lock(&priv->wx_mutex);
547 ret = rtllib_wx_set_encode(priv->rtllib, info, wrqu, key);
548 mutex_unlock(&priv->wx_mutex);
550 if (wrqu->encoding.flags & IW_ENCODE_DISABLED) {
551 ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA;
552 rtl92e_cam_reset(dev);
553 memset(priv->rtllib->swcamtable, 0,
554 sizeof(struct sw_cam_table) * 32);
557 if (wrqu->encoding.length != 0) {
558 for (i = 0; i < 4; i++) {
559 hwkey[i] |= key[4 * i + 0] & mask;
560 if (i == 1 && (4 * i + 1) == wrqu->encoding.length)
562 if (i == 3 && (4 * i + 1) == wrqu->encoding.length)
564 hwkey[i] |= (key[4 * i + 1] & mask) << 8;
565 hwkey[i] |= (key[4 * i + 2] & mask) << 16;
566 hwkey[i] |= (key[4 * i + 3] & mask) << 24;
569 switch (wrqu->encoding.flags & IW_ENCODE_INDEX) {
571 key_idx = ieee->crypt_info.tx_keyidx;
588 if (wrqu->encoding.length == 0x5) {
589 ieee->pairwise_key_type = KEY_TYPE_WEP40;
590 rtl92e_enable_hw_security_config(dev);
593 else if (wrqu->encoding.length == 0xd) {
594 ieee->pairwise_key_type = KEY_TYPE_WEP104;
595 rtl92e_enable_hw_security_config(dev);
596 rtl92e_set_key(dev, key_idx, key_idx, KEY_TYPE_WEP104,
597 zero_addr[key_idx], 0, hwkey);
598 rtl92e_set_swcam(dev, key_idx, key_idx, KEY_TYPE_WEP104,
599 zero_addr[key_idx], hwkey);
602 "wrong type in WEP, not WEP40 and WEP104\n");
607 priv->rtllib->wx_set_enc = 0;
611 #define R8192_MAX_RETRY 255
612 static int _rtl92e_wx_set_retry(struct net_device *dev,
613 struct iw_request_info *info,
614 union iwreq_data *wrqu, char *extra)
616 struct r8192_priv *priv = rtllib_priv(dev);
619 if (priv->hw_radio_off)
622 mutex_lock(&priv->wx_mutex);
624 if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
625 wrqu->retry.disabled) {
629 if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) {
634 if (wrqu->retry.value > R8192_MAX_RETRY) {
638 if (wrqu->retry.flags & IW_RETRY_MAX)
639 priv->retry_rts = wrqu->retry.value;
641 priv->retry_data = wrqu->retry.value;
645 mutex_unlock(&priv->wx_mutex);
650 static int _rtl92e_wx_get_retry(struct net_device *dev,
651 struct iw_request_info *info,
652 union iwreq_data *wrqu, char *extra)
654 struct r8192_priv *priv = rtllib_priv(dev);
656 wrqu->retry.disabled = 0; /* can't be disabled */
658 if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
662 if (wrqu->retry.flags & IW_RETRY_MAX) {
663 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
664 wrqu->retry.value = priv->retry_rts;
666 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
667 wrqu->retry.value = priv->retry_data;
672 static int _rtl92e_wx_set_encode_ext(struct net_device *dev,
673 struct iw_request_info *info,
674 union iwreq_data *wrqu, char *extra)
677 struct r8192_priv *priv = rtllib_priv(dev);
678 struct rtllib_device *ieee = priv->rtllib;
680 if (priv->hw_radio_off)
683 mutex_lock(&priv->wx_mutex);
685 priv->rtllib->wx_set_enc = 1;
686 mutex_lock(&priv->rtllib->ips_mutex);
687 rtl92e_ips_leave(dev);
688 mutex_unlock(&priv->rtllib->ips_mutex);
690 ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra);
692 const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
693 const u8 zero[ETH_ALEN] = {0};
695 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
696 struct iw_point *encoding = &wrqu->encoding;
697 u8 idx = 0, alg = 0, group = 0;
699 if ((encoding->flags & IW_ENCODE_DISABLED) ||
700 ext->alg == IW_ENCODE_ALG_NONE) {
701 ieee->pairwise_key_type = ieee->group_key_type
703 rtl92e_cam_reset(dev);
704 memset(priv->rtllib->swcamtable, 0,
705 sizeof(struct sw_cam_table) * 32);
708 alg = (ext->alg == IW_ENCODE_ALG_CCMP) ? KEY_TYPE_CCMP :
710 idx = encoding->flags & IW_ENCODE_INDEX;
713 group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY;
715 if ((!group) || (alg == KEY_TYPE_WEP40)) {
716 if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40))
717 alg = KEY_TYPE_WEP104;
718 ieee->pairwise_key_type = alg;
719 rtl92e_enable_hw_security_config(dev);
721 memcpy((u8 *)key, ext->key, 16);
723 if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode != 2)) {
724 if (ext->key_len == 13)
725 ieee->pairwise_key_type = alg = KEY_TYPE_WEP104;
726 rtl92e_set_key(dev, idx, idx, alg, zero, 0, key);
727 rtl92e_set_swcam(dev, idx, idx, alg, zero, key);
729 ieee->group_key_type = alg;
730 rtl92e_set_key(dev, idx, idx, alg, broadcast_addr, 0,
732 rtl92e_set_swcam(dev, idx, idx, alg, broadcast_addr, key);
734 if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) &&
735 ieee->ht_info->current_ht_support)
736 rtl92e_writeb(dev, 0x173, 1);
737 rtl92e_set_key(dev, 4, idx, alg,
738 (u8 *)ieee->ap_mac_addr, 0, key);
739 rtl92e_set_swcam(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr, key);
744 priv->rtllib->wx_set_enc = 0;
745 mutex_unlock(&priv->wx_mutex);
749 static int _rtl92e_wx_set_auth(struct net_device *dev,
750 struct iw_request_info *info,
751 union iwreq_data *data, char *extra)
755 struct r8192_priv *priv = rtllib_priv(dev);
757 if (priv->hw_radio_off)
760 mutex_lock(&priv->wx_mutex);
761 ret = rtllib_wx_set_auth(priv->rtllib, info, &data->param, extra);
762 mutex_unlock(&priv->wx_mutex);
766 static int _rtl92e_wx_set_mlme(struct net_device *dev,
767 struct iw_request_info *info,
768 union iwreq_data *wrqu, char *extra)
772 struct r8192_priv *priv = rtllib_priv(dev);
774 if (priv->hw_radio_off)
777 mutex_lock(&priv->wx_mutex);
778 ret = rtllib_wx_set_mlme(priv->rtllib, info, wrqu, extra);
779 mutex_unlock(&priv->wx_mutex);
783 static int _rtl92e_wx_set_gen_ie(struct net_device *dev,
784 struct iw_request_info *info,
785 union iwreq_data *data, char *extra)
789 struct r8192_priv *priv = rtllib_priv(dev);
791 if (priv->hw_radio_off)
794 mutex_lock(&priv->wx_mutex);
795 ret = rtllib_wx_set_gen_ie(priv->rtllib, extra, data->data.length);
796 mutex_unlock(&priv->wx_mutex);
800 static int _rtl92e_wx_get_gen_ie(struct net_device *dev,
801 struct iw_request_info *info,
802 union iwreq_data *data, char *extra)
805 struct r8192_priv *priv = rtllib_priv(dev);
806 struct rtllib_device *ieee = priv->rtllib;
808 if (ieee->wpa_ie_len == 0 || !ieee->wpa_ie) {
809 data->data.length = 0;
813 if (data->data.length < ieee->wpa_ie_len)
816 data->data.length = ieee->wpa_ie_len;
817 memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len);
821 #define IW_IOCTL(x) ((x) - SIOCSIWCOMMIT)
822 static iw_handler r8192_wx_handlers[] = {
823 [IW_IOCTL(SIOCGIWNAME)] = _rtl92e_wx_get_name,
824 [IW_IOCTL(SIOCSIWFREQ)] = _rtl92e_wx_set_freq,
825 [IW_IOCTL(SIOCGIWFREQ)] = _rtl92e_wx_get_freq,
826 [IW_IOCTL(SIOCSIWMODE)] = _rtl92e_wx_set_mode,
827 [IW_IOCTL(SIOCGIWMODE)] = _rtl92e_wx_get_mode,
828 [IW_IOCTL(SIOCGIWRANGE)] = _rtl92e_wx_get_range,
829 [IW_IOCTL(SIOCSIWAP)] = _rtl92e_wx_set_wap,
830 [IW_IOCTL(SIOCGIWAP)] = _rtl92e_wx_get_wap,
831 [IW_IOCTL(SIOCSIWSCAN)] = _rtl92e_wx_set_scan,
832 [IW_IOCTL(SIOCGIWSCAN)] = _rtl92e_wx_get_scan,
833 [IW_IOCTL(SIOCSIWESSID)] = _rtl92e_wx_set_essid,
834 [IW_IOCTL(SIOCGIWESSID)] = _rtl92e_wx_get_essid,
835 [IW_IOCTL(SIOCSIWNICKN)] = _rtl92e_wx_set_nick,
836 [IW_IOCTL(SIOCGIWNICKN)] = _rtl92e_wx_get_nick,
837 [IW_IOCTL(SIOCSIWRATE)] = _rtl92e_wx_set_rate,
838 [IW_IOCTL(SIOCGIWRATE)] = _rtl92e_wx_get_rate,
839 [IW_IOCTL(SIOCSIWRTS)] = _rtl92e_wx_set_rts,
840 [IW_IOCTL(SIOCGIWRTS)] = _rtl92e_wx_get_rts,
841 [IW_IOCTL(SIOCSIWFRAG)] = _rtl92e_wx_set_frag,
842 [IW_IOCTL(SIOCGIWFRAG)] = _rtl92e_wx_get_frag,
843 [IW_IOCTL(SIOCSIWRETRY)] = _rtl92e_wx_set_retry,
844 [IW_IOCTL(SIOCGIWRETRY)] = _rtl92e_wx_get_retry,
845 [IW_IOCTL(SIOCSIWENCODE)] = _rtl92e_wx_set_enc,
846 [IW_IOCTL(SIOCGIWENCODE)] = _rtl92e_wx_get_enc,
847 [IW_IOCTL(SIOCSIWPOWER)] = _rtl92e_wx_set_power,
848 [IW_IOCTL(SIOCGIWPOWER)] = _rtl92e_wx_get_power,
849 [IW_IOCTL(SIOCSIWGENIE)] = _rtl92e_wx_set_gen_ie,
850 [IW_IOCTL(SIOCGIWGENIE)] = _rtl92e_wx_get_gen_ie,
851 [IW_IOCTL(SIOCSIWMLME)] = _rtl92e_wx_set_mlme,
852 [IW_IOCTL(SIOCSIWAUTH)] = _rtl92e_wx_set_auth,
853 [IW_IOCTL(SIOCSIWENCODEEXT)] = _rtl92e_wx_set_encode_ext,
856 static struct iw_statistics *_rtl92e_get_wireless_stats(struct net_device *dev)
858 struct r8192_priv *priv = rtllib_priv(dev);
859 struct rtllib_device *ieee = priv->rtllib;
860 struct iw_statistics *wstats = &priv->wstats;
865 if (ieee->link_state < MAC80211_LINKED) {
866 wstats->qual.qual = 10;
867 wstats->qual.level = 0;
868 wstats->qual.noise = 0x100 - 100; /* -100 dBm */
869 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
873 tmp_level = (&ieee->current_network)->stats.rssi;
874 tmp_qual = (&ieee->current_network)->stats.signal;
875 tmp_noise = (&ieee->current_network)->stats.noise;
877 wstats->qual.level = tmp_level;
878 wstats->qual.qual = tmp_qual;
879 wstats->qual.noise = tmp_noise;
880 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
884 const struct iw_handler_def r8192_wx_handlers_def = {
885 .standard = r8192_wx_handlers,
886 .num_standard = ARRAY_SIZE(r8192_wx_handlers),
887 .get_wireless_stats = _rtl92e_get_wireless_stats,