1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
4 * This program is distributed in the hope that it will be useful, but WITHOUT
5 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
9 * You should have received a copy of the GNU General Public License along with
10 * this program; if not, write to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
13 * The full GNU General Public License is included in this distribution in the
14 * file called LICENSE.
16 * Contact Information:
17 * wlanfae <wlanfae@realtek.com>
18 ******************************************************************************/
20 #include <linux/string.h>
24 static u32 rtl8192_rates[] = {
25 1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000,
26 18000000, 24000000, 36000000, 48000000, 54000000
33 static int r8192_wx_get_freq(struct net_device *dev,
34 struct iw_request_info *a,
35 union iwreq_data *wrqu, char *b)
37 struct r8192_priv *priv = rtllib_priv(dev);
39 return rtllib_wx_get_freq(priv->rtllib, a, wrqu, b);
43 static int r8192_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
44 union iwreq_data *wrqu, char *b)
46 struct r8192_priv *priv = rtllib_priv(dev);
48 return rtllib_wx_get_mode(priv->rtllib, a, wrqu, b);
51 static int r8192_wx_get_rate(struct net_device *dev,
52 struct iw_request_info *info,
53 union iwreq_data *wrqu, char *extra)
55 struct r8192_priv *priv = rtllib_priv(dev);
56 return rtllib_wx_get_rate(priv->rtllib, info, wrqu, extra);
61 static int r8192_wx_set_rate(struct net_device *dev,
62 struct iw_request_info *info,
63 union iwreq_data *wrqu, char *extra)
66 struct r8192_priv *priv = rtllib_priv(dev);
68 if (priv->bHwRadioOff == true)
73 ret = rtllib_wx_set_rate(priv->rtllib, info, wrqu, extra);
81 static int r8192_wx_set_rts(struct net_device *dev,
82 struct iw_request_info *info,
83 union iwreq_data *wrqu, char *extra)
86 struct r8192_priv *priv = rtllib_priv(dev);
88 if (priv->bHwRadioOff == true)
93 ret = rtllib_wx_set_rts(priv->rtllib, info, wrqu, extra);
100 static int r8192_wx_get_rts(struct net_device *dev,
101 struct iw_request_info *info,
102 union iwreq_data *wrqu, char *extra)
104 struct r8192_priv *priv = rtllib_priv(dev);
105 return rtllib_wx_get_rts(priv->rtllib, info, wrqu, extra);
108 static int r8192_wx_set_power(struct net_device *dev,
109 struct iw_request_info *info,
110 union iwreq_data *wrqu, char *extra)
113 struct r8192_priv *priv = rtllib_priv(dev);
115 if (priv->bHwRadioOff == true) {
116 RT_TRACE(COMP_ERR, "%s():Hw is Radio Off, we can't set "
117 "Power,return\n", __func__);
122 ret = rtllib_wx_set_power(priv->rtllib, info, wrqu, extra);
129 static int r8192_wx_get_power(struct net_device *dev,
130 struct iw_request_info *info,
131 union iwreq_data *wrqu, char *extra)
133 struct r8192_priv *priv = rtllib_priv(dev);
134 return rtllib_wx_get_power(priv->rtllib, info, wrqu, extra);
137 static int r8192_wx_set_rawtx(struct net_device *dev,
138 struct iw_request_info *info,
139 union iwreq_data *wrqu, char *extra)
141 struct r8192_priv *priv = rtllib_priv(dev);
144 if (priv->bHwRadioOff == true)
149 ret = rtllib_wx_set_rawtx(priv->rtllib, info, wrqu, extra);
157 static int r8192_wx_force_reset(struct net_device *dev,
158 struct iw_request_info *info,
159 union iwreq_data *wrqu, char *extra)
161 struct r8192_priv *priv = rtllib_priv(dev);
165 RT_TRACE(COMP_DBG, "%s(): force reset ! extra is %d\n",
167 priv->force_reset = *extra;
173 static int r8192_wx_force_mic_error(struct net_device *dev,
174 struct iw_request_info *info,
175 union iwreq_data *wrqu, char *extra)
177 struct r8192_priv *priv = rtllib_priv(dev);
178 struct rtllib_device *ieee = priv->rtllib;
182 RT_TRACE(COMP_DBG, "%s(): force mic error !\n", __func__);
183 ieee->force_mic_error = true;
189 #define MAX_ADHOC_PEER_NUM 64
190 struct adhoc_peer_entry {
191 unsigned char MacAddr[ETH_ALEN];
192 unsigned char WirelessMode;
193 unsigned char bCurTxBW40MHz;
195 struct adhoc_peers_info {
196 struct adhoc_peer_entry Entry[MAX_ADHOC_PEER_NUM];
200 static int r8192_wx_get_adhoc_peers(struct net_device *dev,
201 struct iw_request_info *info,
202 union iwreq_data *wrqu, char *extra)
208 static int r8191se_wx_get_firm_version(struct net_device *dev,
209 struct iw_request_info *info,
210 struct iw_param *wrqu, char *extra)
215 static int r8192_wx_adapter_power_status(struct net_device *dev,
216 struct iw_request_info *info,
217 union iwreq_data *wrqu, char *extra)
219 struct r8192_priv *priv = rtllib_priv(dev);
220 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
221 (&(priv->rtllib->PowerSaveControl));
222 struct rtllib_device *ieee = priv->rtllib;
226 RT_TRACE(COMP_POWER, "%s(): %s\n", __func__, (*extra == 6) ?
227 "DC power" : "AC power");
228 if (*extra || priv->force_lps) {
229 priv->ps_force = false;
230 pPSC->bLeisurePs = true;
232 if (priv->rtllib->state == RTLLIB_LINKED)
235 priv->ps_force = true;
236 pPSC->bLeisurePs = false;
245 static int r8192se_wx_set_radio(struct net_device *dev,
246 struct iw_request_info *info,
247 union iwreq_data *wrqu, char *extra)
249 struct r8192_priv *priv = rtllib_priv(dev);
253 printk(KERN_INFO "%s(): set radio ! extra is %d\n", __func__, *extra);
254 if ((*extra != 0) && (*extra != 1)) {
255 RT_TRACE(COMP_ERR, "%s(): set radio an err value,must 0(radio "
256 "off) or 1(radio on)\n", __func__);
260 priv->sw_radio_on = *extra;
266 static int r8192se_wx_set_lps_awake_interval(struct net_device *dev,
267 struct iw_request_info *info,
268 union iwreq_data *wrqu, char *extra)
270 struct r8192_priv *priv = rtllib_priv(dev);
271 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
272 (&(priv->rtllib->PowerSaveControl));
276 printk(KERN_INFO "%s(): set lps awake interval ! extra is %d\n",
279 pPSC->RegMaxLPSAwakeIntvl = *extra;
284 static int r8192se_wx_set_force_lps(struct net_device *dev,
285 struct iw_request_info *info,
286 union iwreq_data *wrqu, char *extra)
288 struct r8192_priv *priv = rtllib_priv(dev);
292 printk(KERN_INFO "%s(): force LPS ! extra is %d (1 is open 0 is "
293 "close)\n", __func__, *extra);
294 priv->force_lps = *extra;
300 static int r8192_wx_set_debugflag(struct net_device *dev,
301 struct iw_request_info *info,
302 union iwreq_data *wrqu, char *extra)
304 struct r8192_priv *priv = rtllib_priv(dev);
307 if (priv->bHwRadioOff == true)
310 printk(KERN_INFO "=====>%s(), *extra:%x, debugflag:%x\n", __func__,
311 *extra, rt_global_debug_component);
313 rt_global_debug_component |= (1<<c);
315 rt_global_debug_component &= BIT31;
319 static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
320 union iwreq_data *wrqu, char *b)
322 struct r8192_priv *priv = rtllib_priv(dev);
323 struct rtllib_device *ieee = netdev_priv_rsl(dev);
325 enum rt_rf_power_state rtState;
328 if (priv->bHwRadioOff == true)
330 rtState = priv->rtllib->eRFPowerState;
332 if (wrqu->mode == IW_MODE_ADHOC || wrqu->mode == IW_MODE_MONITOR ||
333 ieee->bNetPromiscuousMode) {
334 if (priv->rtllib->PowerSaveControl.bInactivePs) {
335 if (rtState == eRfOff) {
336 if (priv->rtllib->RfOffReason >
338 RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",
343 printk(KERN_INFO "=========>%s(): "
344 "IPSLeave\n", __func__);
345 down(&priv->rtllib->ips_sem);
347 up(&priv->rtllib->ips_sem);
352 ret = rtllib_wx_set_mode(priv->rtllib, a, wrqu, b);
358 struct iw_range_with_scan_capa {
359 /* Informative stuff (to choose between different interface) */
360 __u32 throughput; /* To give an idea... */
361 /* In theory this value should be the maximum benchmarked
362 * TCP/IP throughput, because with most of these devices the
363 * bit rate is meaningless (overhead an co) to estimate how
364 * fast the connection will go and pick the fastest one.
365 * I suggest people to play with Netperf or any benchmark...
368 /* NWID (or domain id) */
369 __u32 min_nwid; /* Minimal NWID we are able to set */
370 __u32 max_nwid; /* Maximal NWID we are able to set */
372 /* Old Frequency (backward compat - moved lower ) */
373 __u16 old_num_channels;
374 __u8 old_num_frequency;
376 /* Scan capabilities */
380 static int rtl8192_wx_get_range(struct net_device *dev,
381 struct iw_request_info *info,
382 union iwreq_data *wrqu, char *extra)
384 struct iw_range *range = (struct iw_range *)extra;
385 struct r8192_priv *priv = rtllib_priv(dev);
389 wrqu->data.length = sizeof(*range);
390 memset(range, 0, sizeof(*range));
392 /* ~130 Mb/s real (802.11n) */
393 range->throughput = 130 * 1000 * 1000;
395 if (priv->rf_set_sens != NULL) {
396 /* signal level threshold range */
397 range->sensitivity = priv->max_sens;
400 range->max_qual.qual = 100;
401 range->max_qual.level = 0;
402 range->max_qual.noise = 0;
403 range->max_qual.updated = 7; /* Updated all three */
405 range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */
406 range->avg_qual.level = 0;
407 range->avg_qual.noise = 0;
408 range->avg_qual.updated = 7; /* Updated all three */
410 range->num_bitrates = min(RATE_COUNT, IW_MAX_BITRATES);
412 for (i = 0; i < range->num_bitrates; i++)
413 range->bitrate[i] = rtl8192_rates[i];
415 range->max_rts = DEFAULT_RTS_THRESHOLD;
416 range->min_frag = MIN_FRAG_THRESHOLD;
417 range->max_frag = MAX_FRAG_THRESHOLD;
420 range->max_pmp = 5000000;
422 range->max_pmt = 65535*1000;
423 range->pmp_flags = IW_POWER_PERIOD;
424 range->pmt_flags = IW_POWER_TIMEOUT;
425 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
426 range->we_version_compiled = WIRELESS_EXT;
427 range->we_version_source = 18;
429 for (i = 0, val = 0; i < 14; i++) {
430 if ((priv->rtllib->active_channel_map)[i+1]) {
431 range->freq[val].i = i + 1;
432 range->freq[val].m = rtllib_wlan_frequencies[i] *
434 range->freq[val].e = 1;
438 if (val == IW_MAX_FREQUENCIES)
441 range->num_frequency = val;
442 range->num_channels = val;
443 range->enc_capa = IW_ENC_CAPA_WPA|IW_ENC_CAPA_WPA2|
444 IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP;
445 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE;
447 /* Event capability (kernel + driver) */
452 static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
453 union iwreq_data *wrqu, char *b)
455 struct r8192_priv *priv = rtllib_priv(dev);
456 struct rtllib_device *ieee = priv->rtllib;
457 enum rt_rf_power_state rtState;
460 if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) {
461 if ((ieee->state >= RTLLIB_ASSOCIATING) &&
462 (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED))
464 if ((priv->rtllib->state == RTLLIB_LINKED) &&
465 (priv->rtllib->CntAfterLink < 2))
469 if (priv->bHwRadioOff == true) {
470 printk(KERN_INFO "================>%s(): hwradio off\n",
474 rtState = priv->rtllib->eRFPowerState;
477 if (priv->rtllib->LinkDetectInfo.bBusyTraffic == true)
480 if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
481 struct iw_scan_req *req = (struct iw_scan_req *)b;
482 if (req->essid_len) {
483 ieee->current_network.ssid_len = req->essid_len;
484 memcpy(ieee->current_network.ssid, req->essid,
491 priv->rtllib->FirstIe_InScan = true;
493 if (priv->rtllib->state != RTLLIB_LINKED) {
494 if (priv->rtllib->PowerSaveControl.bInactivePs) {
495 if (rtState == eRfOff) {
496 if (priv->rtllib->RfOffReason >
498 RT_TRACE(COMP_ERR, "%s(): RF is "
503 RT_TRACE(COMP_PS, "=========>%s(): "
504 "IPSLeave\n", __func__);
505 down(&priv->rtllib->ips_sem);
507 up(&priv->rtllib->ips_sem);
511 rtllib_stop_scan(priv->rtllib);
512 if (priv->rtllib->LedControlHandler)
513 priv->rtllib->LedControlHandler(dev,
514 LED_CTL_SITE_SURVEY);
516 if (priv->rtllib->eRFPowerState != eRfOff) {
517 priv->rtllib->actscanning = true;
519 if (ieee->ScanOperationBackupHandler)
520 ieee->ScanOperationBackupHandler(ieee->dev,
523 rtllib_start_scan_syncro(priv->rtllib, 0);
525 if (ieee->ScanOperationBackupHandler)
526 ieee->ScanOperationBackupHandler(ieee->dev,
531 priv->rtllib->actscanning = true;
532 ret = rtllib_wx_set_scan(priv->rtllib, a, wrqu, b);
540 static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
541 union iwreq_data *wrqu, char *b)
545 struct r8192_priv *priv = rtllib_priv(dev);
550 if (priv->bHwRadioOff == true)
556 ret = rtllib_wx_get_scan(priv->rtllib, a, wrqu, b);
563 static int r8192_wx_set_essid(struct net_device *dev,
564 struct iw_request_info *a,
565 union iwreq_data *wrqu, char *b)
567 struct r8192_priv *priv = rtllib_priv(dev);
570 if ((rtllib_act_scanning(priv->rtllib, false)) &&
571 !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) {
572 ; /* TODO - get rid of if */
574 if (priv->bHwRadioOff == true) {
575 printk(KERN_INFO "=========>%s():hw radio off,or Rf state is "
576 "eRfOff, return\n", __func__);
580 ret = rtllib_wx_set_essid(priv->rtllib, a, wrqu, b);
587 static int r8192_wx_get_essid(struct net_device *dev,
588 struct iw_request_info *a,
589 union iwreq_data *wrqu, char *b)
592 struct r8192_priv *priv = rtllib_priv(dev);
596 ret = rtllib_wx_get_essid(priv->rtllib, a, wrqu, b);
603 static int r8192_wx_set_nick(struct net_device *dev,
604 struct iw_request_info *info,
605 union iwreq_data *wrqu, char *extra)
607 struct r8192_priv *priv = rtllib_priv(dev);
609 if (wrqu->data.length > IW_ESSID_MAX_SIZE)
612 wrqu->data.length = min((size_t) wrqu->data.length, sizeof(priv->nick));
613 memset(priv->nick, 0, sizeof(priv->nick));
614 memcpy(priv->nick, extra, wrqu->data.length);
620 static int r8192_wx_get_nick(struct net_device *dev,
621 struct iw_request_info *info,
622 union iwreq_data *wrqu, char *extra)
624 struct r8192_priv *priv = rtllib_priv(dev);
627 wrqu->data.length = strlen(priv->nick);
628 memcpy(extra, priv->nick, wrqu->data.length);
629 wrqu->data.flags = 1; /* active */
634 static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a,
635 union iwreq_data *wrqu, char *b)
638 struct r8192_priv *priv = rtllib_priv(dev);
640 if (priv->bHwRadioOff == true)
645 ret = rtllib_wx_set_freq(priv->rtllib, a, wrqu, b);
651 static int r8192_wx_get_name(struct net_device *dev,
652 struct iw_request_info *info,
653 union iwreq_data *wrqu, char *extra)
655 struct r8192_priv *priv = rtllib_priv(dev);
656 return rtllib_wx_get_name(priv->rtllib, info, wrqu, extra);
660 static int r8192_wx_set_frag(struct net_device *dev,
661 struct iw_request_info *info,
662 union iwreq_data *wrqu, char *extra)
664 struct r8192_priv *priv = rtllib_priv(dev);
666 if (priv->bHwRadioOff == true)
669 if (wrqu->frag.disabled)
670 priv->rtllib->fts = DEFAULT_FRAG_THRESHOLD;
672 if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
673 wrqu->frag.value > MAX_FRAG_THRESHOLD)
676 priv->rtllib->fts = wrqu->frag.value & ~0x1;
683 static int r8192_wx_get_frag(struct net_device *dev,
684 struct iw_request_info *info,
685 union iwreq_data *wrqu, char *extra)
687 struct r8192_priv *priv = rtllib_priv(dev);
689 wrqu->frag.value = priv->rtllib->fts;
690 wrqu->frag.fixed = 0; /* no auto select */
691 wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD);
697 static int r8192_wx_set_wap(struct net_device *dev,
698 struct iw_request_info *info,
699 union iwreq_data *awrq,
703 struct r8192_priv *priv = rtllib_priv(dev);
705 if ((rtllib_act_scanning(priv->rtllib, false)) &&
706 !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) {
707 ; /* TODO - get rid of if */
710 if (priv->bHwRadioOff == true)
715 ret = rtllib_wx_set_wap(priv->rtllib, info, awrq, extra);
724 static int r8192_wx_get_wap(struct net_device *dev,
725 struct iw_request_info *info,
726 union iwreq_data *wrqu, char *extra)
728 struct r8192_priv *priv = rtllib_priv(dev);
730 return rtllib_wx_get_wap(priv->rtllib, info, wrqu, extra);
734 static int r8192_wx_get_enc(struct net_device *dev,
735 struct iw_request_info *info,
736 union iwreq_data *wrqu, char *key)
738 struct r8192_priv *priv = rtllib_priv(dev);
740 return rtllib_wx_get_encode(priv->rtllib, info, wrqu, key);
743 static int r8192_wx_set_enc(struct net_device *dev,
744 struct iw_request_info *info,
745 union iwreq_data *wrqu, char *key)
747 struct r8192_priv *priv = rtllib_priv(dev);
750 struct rtllib_device *ieee = priv->rtllib;
751 u32 hwkey[4] = {0, 0, 0, 0};
754 u8 zero_addr[4][6] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
755 {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
756 {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
757 {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} };
760 if ((rtllib_act_scanning(priv->rtllib, false)) &&
761 !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN))
762 ; /* TODO - get rid of if */
763 if (priv->bHwRadioOff == true)
769 priv->rtllib->wx_set_enc = 1;
770 down(&priv->rtllib->ips_sem);
772 up(&priv->rtllib->ips_sem);
775 RT_TRACE(COMP_SEC, "Setting SW wep key");
776 ret = rtllib_wx_set_encode(priv->rtllib, info, wrqu, key);
780 if (wrqu->encoding.flags & IW_ENCODE_DISABLED) {
781 ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA;
782 CamResetAllEntry(dev);
783 memset(priv->rtllib->swcamtable, 0,
784 sizeof(struct sw_cam_table) * 32);
787 if (wrqu->encoding.length != 0) {
789 for (i = 0; i < 4; i++) {
790 hwkey[i] |= key[4*i+0]&mask;
791 if (i == 1 && (4 * i + 1) == wrqu->encoding.length)
793 if (i == 3 && (4 * i + 1) == wrqu->encoding.length)
795 hwkey[i] |= (key[4 * i + 1] & mask) << 8;
796 hwkey[i] |= (key[4 * i + 2] & mask) << 16;
797 hwkey[i] |= (key[4 * i + 3] & mask) << 24;
800 #define CONF_WEP40 0x4
801 #define CONF_WEP104 0x14
803 switch (wrqu->encoding.flags & IW_ENCODE_INDEX) {
805 key_idx = ieee->crypt_info.tx_keyidx;
822 if (wrqu->encoding.length == 0x5) {
823 ieee->pairwise_key_type = KEY_TYPE_WEP40;
824 EnableHWSecurityConfig8192(dev);
827 else if (wrqu->encoding.length == 0xd) {
828 ieee->pairwise_key_type = KEY_TYPE_WEP104;
829 EnableHWSecurityConfig8192(dev);
830 setKey(dev, key_idx, key_idx, KEY_TYPE_WEP104,
831 zero_addr[key_idx], 0, hwkey);
832 set_swcam(dev, key_idx, key_idx, KEY_TYPE_WEP104,
833 zero_addr[key_idx], 0, hwkey, 0);
835 printk(KERN_INFO "wrong type in WEP, not WEP40 and WEP104\n");
840 priv->rtllib->wx_set_enc = 0;
844 static int r8192_wx_set_scan_type(struct net_device *dev,
845 struct iw_request_info *aa,
846 union iwreq_data *wrqu, char *p)
848 struct r8192_priv *priv = rtllib_priv(dev);
849 int *parms = (int *)p;
852 if (priv->bHwRadioOff == true)
855 priv->rtllib->active_scan = mode;
862 #define R8192_MAX_RETRY 255
863 static int r8192_wx_set_retry(struct net_device *dev,
864 struct iw_request_info *info,
865 union iwreq_data *wrqu, char *extra)
867 struct r8192_priv *priv = rtllib_priv(dev);
870 if (priv->bHwRadioOff == true)
875 if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
876 wrqu->retry.disabled) {
880 if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) {
885 if (wrqu->retry.value > R8192_MAX_RETRY) {
889 if (wrqu->retry.flags & IW_RETRY_MAX) {
890 priv->retry_rts = wrqu->retry.value;
891 DMESG("Setting retry for RTS/CTS data to %d",
895 priv->retry_data = wrqu->retry.value;
896 DMESG("Setting retry for non RTS/CTS data to %d",
908 static int r8192_wx_get_retry(struct net_device *dev,
909 struct iw_request_info *info,
910 union iwreq_data *wrqu, char *extra)
912 struct r8192_priv *priv = rtllib_priv(dev);
915 wrqu->retry.disabled = 0; /* can't be disabled */
917 if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
921 if (wrqu->retry.flags & IW_RETRY_MAX) {
922 wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX;
923 wrqu->retry.value = priv->retry_rts;
925 wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MIN;
926 wrqu->retry.value = priv->retry_data;
931 static int r8192_wx_get_sens(struct net_device *dev,
932 struct iw_request_info *info,
933 union iwreq_data *wrqu, char *extra)
935 struct r8192_priv *priv = rtllib_priv(dev);
936 if (priv->rf_set_sens == NULL)
937 return -1; /* we have not this support for this radio */
938 wrqu->sens.value = priv->sens;
943 static int r8192_wx_set_sens(struct net_device *dev,
944 struct iw_request_info *info,
945 union iwreq_data *wrqu, char *extra)
948 struct r8192_priv *priv = rtllib_priv(dev);
952 if (priv->bHwRadioOff == true)
956 if (priv->rf_set_sens == NULL) {
957 err = -1; /* we have not this support for this radio */
960 if (priv->rf_set_sens(dev, wrqu->sens.value) == 0)
961 priv->sens = wrqu->sens.value;
971 static int r8192_wx_set_enc_ext(struct net_device *dev,
972 struct iw_request_info *info,
973 union iwreq_data *wrqu, char *extra)
976 struct r8192_priv *priv = rtllib_priv(dev);
977 struct rtllib_device *ieee = priv->rtllib;
979 if (priv->bHwRadioOff == true)
984 priv->rtllib->wx_set_enc = 1;
985 down(&priv->rtllib->ips_sem);
987 up(&priv->rtllib->ips_sem);
989 ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra);
991 u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
994 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
995 struct iw_point *encoding = &wrqu->encoding;
996 u8 idx = 0, alg = 0, group = 0;
997 if ((encoding->flags & IW_ENCODE_DISABLED) ||
998 ext->alg == IW_ENCODE_ALG_NONE) {
999 ieee->pairwise_key_type = ieee->group_key_type
1001 CamResetAllEntry(dev);
1002 memset(priv->rtllib->swcamtable, 0,
1003 sizeof(struct sw_cam_table) * 32);
1006 alg = (ext->alg == IW_ENCODE_ALG_CCMP) ? KEY_TYPE_CCMP :
1008 idx = encoding->flags & IW_ENCODE_INDEX;
1011 group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY;
1013 if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) ||
1014 (alg == KEY_TYPE_WEP40)) {
1015 if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40))
1016 alg = KEY_TYPE_WEP104;
1017 ieee->pairwise_key_type = alg;
1018 EnableHWSecurityConfig8192(dev);
1020 memcpy((u8 *)key, ext->key, 16);
1022 if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode != 2)) {
1023 if (ext->key_len == 13)
1024 ieee->pairwise_key_type = alg = KEY_TYPE_WEP104;
1025 setKey(dev, idx, idx, alg, zero, 0, key);
1026 set_swcam(dev, idx, idx, alg, zero, 0, key, 0);
1028 ieee->group_key_type = alg;
1029 setKey(dev, idx, idx, alg, broadcast_addr, 0, key);
1030 set_swcam(dev, idx, idx, alg, broadcast_addr, 0,
1033 if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) &&
1034 ieee->pHTInfo->bCurrentHTSupport)
1035 write_nic_byte(dev, 0x173, 1);
1036 setKey(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr,
1038 set_swcam(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr,
1046 priv->rtllib->wx_set_enc = 0;
1051 static int r8192_wx_set_auth(struct net_device *dev,
1052 struct iw_request_info *info,
1053 union iwreq_data *data, char *extra)
1057 struct r8192_priv *priv = rtllib_priv(dev);
1059 if (priv->bHwRadioOff == true)
1062 down(&priv->wx_sem);
1063 ret = rtllib_wx_set_auth(priv->rtllib, info, &(data->param), extra);
1068 static int r8192_wx_set_mlme(struct net_device *dev,
1069 struct iw_request_info *info,
1070 union iwreq_data *wrqu, char *extra)
1075 struct r8192_priv *priv = rtllib_priv(dev);
1077 if (priv->bHwRadioOff == true)
1080 down(&priv->wx_sem);
1081 ret = rtllib_wx_set_mlme(priv->rtllib, info, wrqu, extra);
1086 static int r8192_wx_set_gen_ie(struct net_device *dev,
1087 struct iw_request_info *info,
1088 union iwreq_data *data, char *extra)
1092 struct r8192_priv *priv = rtllib_priv(dev);
1094 if (priv->bHwRadioOff == true)
1097 down(&priv->wx_sem);
1098 ret = rtllib_wx_set_gen_ie(priv->rtllib, extra, data->data.length);
1103 static int r8192_wx_get_gen_ie(struct net_device *dev,
1104 struct iw_request_info *info,
1105 union iwreq_data *data, char *extra)
1108 struct r8192_priv *priv = rtllib_priv(dev);
1109 struct rtllib_device *ieee = priv->rtllib;
1111 if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) {
1112 data->data.length = 0;
1116 if (data->data.length < ieee->wpa_ie_len)
1119 data->data.length = ieee->wpa_ie_len;
1120 memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len);
1124 #define OID_RT_INTEL_PROMISCUOUS_MODE 0xFF0101F6
1126 static int r8192_wx_set_PromiscuousMode(struct net_device *dev,
1127 struct iw_request_info *info,
1128 union iwreq_data *wrqu, char *extra)
1130 struct r8192_priv *priv = rtllib_priv(dev);
1131 struct rtllib_device *ieee = priv->rtllib;
1133 u32 *info_buf = (u32 *)(wrqu->data.pointer);
1135 u32 oid = info_buf[0];
1136 u32 bPromiscuousOn = info_buf[1];
1137 u32 bFilterSourceStationFrame = info_buf[2];
1139 if (OID_RT_INTEL_PROMISCUOUS_MODE == oid) {
1140 ieee->IntelPromiscuousModeInfo.bPromiscuousOn =
1141 (bPromiscuousOn) ? (true) : (false);
1142 ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame =
1143 (bFilterSourceStationFrame) ? (true) : (false);
1145 (rtllib_EnableIntelPromiscuousMode(dev, false)) :
1146 (rtllib_DisableIntelPromiscuousMode(dev, false));
1148 printk(KERN_INFO "=======>%s(), on = %d, filter src sta = %d\n",
1149 __func__, bPromiscuousOn, bFilterSourceStationFrame);
1158 static int r8192_wx_get_PromiscuousMode(struct net_device *dev,
1159 struct iw_request_info *info,
1160 union iwreq_data *wrqu, char *extra)
1162 struct r8192_priv *priv = rtllib_priv(dev);
1163 struct rtllib_device *ieee = priv->rtllib;
1165 down(&priv->wx_sem);
1167 snprintf(extra, 45, "PromiscuousMode:%d, FilterSrcSTAFrame:%d",
1168 ieee->IntelPromiscuousModeInfo.bPromiscuousOn,
1169 ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame);
1170 wrqu->data.length = strlen(extra) + 1;
1178 #define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT]
1179 static iw_handler r8192_wx_handlers[] = {
1180 IW_IOCTL(SIOCGIWNAME) = r8192_wx_get_name,
1181 IW_IOCTL(SIOCSIWFREQ) = r8192_wx_set_freq,
1182 IW_IOCTL(SIOCGIWFREQ) = r8192_wx_get_freq,
1183 IW_IOCTL(SIOCSIWMODE) = r8192_wx_set_mode,
1184 IW_IOCTL(SIOCGIWMODE) = r8192_wx_get_mode,
1185 IW_IOCTL(SIOCSIWSENS) = r8192_wx_set_sens,
1186 IW_IOCTL(SIOCGIWSENS) = r8192_wx_get_sens,
1187 IW_IOCTL(SIOCGIWRANGE) = rtl8192_wx_get_range,
1188 IW_IOCTL(SIOCSIWAP) = r8192_wx_set_wap,
1189 IW_IOCTL(SIOCGIWAP) = r8192_wx_get_wap,
1190 IW_IOCTL(SIOCSIWSCAN) = r8192_wx_set_scan,
1191 IW_IOCTL(SIOCGIWSCAN) = r8192_wx_get_scan,
1192 IW_IOCTL(SIOCSIWESSID) = r8192_wx_set_essid,
1193 IW_IOCTL(SIOCGIWESSID) = r8192_wx_get_essid,
1194 IW_IOCTL(SIOCSIWNICKN) = r8192_wx_set_nick,
1195 IW_IOCTL(SIOCGIWNICKN) = r8192_wx_get_nick,
1196 IW_IOCTL(SIOCSIWRATE) = r8192_wx_set_rate,
1197 IW_IOCTL(SIOCGIWRATE) = r8192_wx_get_rate,
1198 IW_IOCTL(SIOCSIWRTS) = r8192_wx_set_rts,
1199 IW_IOCTL(SIOCGIWRTS) = r8192_wx_get_rts,
1200 IW_IOCTL(SIOCSIWFRAG) = r8192_wx_set_frag,
1201 IW_IOCTL(SIOCGIWFRAG) = r8192_wx_get_frag,
1202 IW_IOCTL(SIOCSIWRETRY) = r8192_wx_set_retry,
1203 IW_IOCTL(SIOCGIWRETRY) = r8192_wx_get_retry,
1204 IW_IOCTL(SIOCSIWENCODE) = r8192_wx_set_enc,
1205 IW_IOCTL(SIOCGIWENCODE) = r8192_wx_get_enc,
1206 IW_IOCTL(SIOCSIWPOWER) = r8192_wx_set_power,
1207 IW_IOCTL(SIOCGIWPOWER) = r8192_wx_get_power,
1208 IW_IOCTL(SIOCSIWGENIE) = r8192_wx_set_gen_ie,
1209 IW_IOCTL(SIOCGIWGENIE) = r8192_wx_get_gen_ie,
1210 IW_IOCTL(SIOCSIWMLME) = r8192_wx_set_mlme,
1211 IW_IOCTL(SIOCSIWAUTH) = r8192_wx_set_auth,
1212 IW_IOCTL(SIOCSIWENCODEEXT) = r8192_wx_set_enc_ext,
1216 * the following rule need to be follwing,
1217 * Odd : get (world access),
1218 * even : set (root access)
1220 static const struct iw_priv_args r8192_private_args[] = {
1222 SIOCIWFIRSTPRIV + 0x0,
1223 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_debugflag"
1225 SIOCIWFIRSTPRIV + 0x1,
1226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
1228 SIOCIWFIRSTPRIV + 0x2,
1229 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx"
1231 SIOCIWFIRSTPRIV + 0x3,
1232 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset"
1234 SIOCIWFIRSTPRIV + 0x4,
1235 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "force_mic_error"
1237 SIOCIWFIRSTPRIV + 0x5,
1238 IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1,
1241 SIOCIWFIRSTPRIV + 0x6,
1242 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
1245 SIOCIWFIRSTPRIV + 0x9,
1246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
1249 SIOCIWFIRSTPRIV + 0xa,
1250 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
1253 SIOCIWFIRSTPRIV + 0xb,
1254 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
1257 SIOCIWFIRSTPRIV + 0xc,
1258 0, IW_PRIV_TYPE_CHAR|2047, "adhoc_peer_list"
1260 SIOCIWFIRSTPRIV + 0x16,
1261 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc"
1263 SIOCIWFIRSTPRIV + 0x17,
1264 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 45, "getpromisc"
1269 static iw_handler r8192_private_handler[] = {
1270 (iw_handler)r8192_wx_set_debugflag, /*SIOCIWSECONDPRIV*/
1271 (iw_handler)r8192_wx_set_scan_type,
1272 (iw_handler)r8192_wx_set_rawtx,
1273 (iw_handler)r8192_wx_force_reset,
1274 (iw_handler)r8192_wx_force_mic_error,
1275 (iw_handler)r8191se_wx_get_firm_version,
1276 (iw_handler)r8192_wx_adapter_power_status,
1279 (iw_handler)r8192se_wx_set_radio,
1280 (iw_handler)r8192se_wx_set_lps_awake_interval,
1281 (iw_handler)r8192se_wx_set_force_lps,
1282 (iw_handler)r8192_wx_get_adhoc_peers,
1292 (iw_handler)r8192_wx_set_PromiscuousMode,
1293 (iw_handler)r8192_wx_get_PromiscuousMode,
1296 static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
1298 struct r8192_priv *priv = rtllib_priv(dev);
1299 struct rtllib_device *ieee = priv->rtllib;
1300 struct iw_statistics *wstats = &priv->wstats;
1304 if (ieee->state < RTLLIB_LINKED) {
1305 wstats->qual.qual = 10;
1306 wstats->qual.level = 0;
1307 wstats->qual.noise = -100;
1308 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1312 tmp_level = (&ieee->current_network)->stats.rssi;
1313 tmp_qual = (&ieee->current_network)->stats.signal;
1314 tmp_noise = (&ieee->current_network)->stats.noise;
1316 wstats->qual.level = tmp_level;
1317 wstats->qual.qual = tmp_qual;
1318 wstats->qual.noise = tmp_noise;
1319 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1323 struct iw_handler_def r8192_wx_handlers_def = {
1324 .standard = r8192_wx_handlers,
1325 .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler),
1326 .private = r8192_private_handler,
1327 .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler),
1328 .num_private_args = sizeof(r8192_private_args) /
1329 sizeof(struct iw_priv_args),
1330 .get_wireless_stats = r8192_get_wireless_stats,
1331 .private_args = (struct iw_priv_args *)r8192_private_args,