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>
25 static u32 rtl8192_rates[] = {
26 1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000,
27 18000000, 24000000, 36000000, 48000000, 54000000
34 static int r8192_wx_get_freq(struct net_device *dev,
35 struct iw_request_info *a,
36 union iwreq_data *wrqu, char *b)
38 struct r8192_priv *priv = rtllib_priv(dev);
40 return rtllib_wx_get_freq(priv->rtllib, a, wrqu, b);
44 static int r8192_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
45 union iwreq_data *wrqu, char *b)
47 struct r8192_priv *priv = rtllib_priv(dev);
49 return rtllib_wx_get_mode(priv->rtllib, a, wrqu, b);
52 static int r8192_wx_get_rate(struct net_device *dev,
53 struct iw_request_info *info,
54 union iwreq_data *wrqu, char *extra)
56 struct r8192_priv *priv = rtllib_priv(dev);
58 return rtllib_wx_get_rate(priv->rtllib, info, wrqu, extra);
63 static int r8192_wx_set_rate(struct net_device *dev,
64 struct iw_request_info *info,
65 union iwreq_data *wrqu, char *extra)
68 struct r8192_priv *priv = rtllib_priv(dev);
70 if (priv->bHwRadioOff == true)
75 ret = rtllib_wx_set_rate(priv->rtllib, info, wrqu, extra);
83 static int r8192_wx_set_rts(struct net_device *dev,
84 struct iw_request_info *info,
85 union iwreq_data *wrqu, char *extra)
88 struct r8192_priv *priv = rtllib_priv(dev);
90 if (priv->bHwRadioOff == true)
95 ret = rtllib_wx_set_rts(priv->rtllib, info, wrqu, extra);
102 static int r8192_wx_get_rts(struct net_device *dev,
103 struct iw_request_info *info,
104 union iwreq_data *wrqu, char *extra)
106 struct r8192_priv *priv = rtllib_priv(dev);
108 return rtllib_wx_get_rts(priv->rtllib, info, wrqu, extra);
111 static int r8192_wx_set_power(struct net_device *dev,
112 struct iw_request_info *info,
113 union iwreq_data *wrqu, char *extra)
116 struct r8192_priv *priv = rtllib_priv(dev);
118 if (priv->bHwRadioOff == true) {
119 RT_TRACE(COMP_ERR, "%s():Hw is Radio Off, we can't set "
120 "Power,return\n", __func__);
125 ret = rtllib_wx_set_power(priv->rtllib, info, wrqu, extra);
132 static int r8192_wx_get_power(struct net_device *dev,
133 struct iw_request_info *info,
134 union iwreq_data *wrqu, char *extra)
136 struct r8192_priv *priv = rtllib_priv(dev);
138 return rtllib_wx_get_power(priv->rtllib, info, wrqu, extra);
141 static int r8192_wx_set_rawtx(struct net_device *dev,
142 struct iw_request_info *info,
143 union iwreq_data *wrqu, char *extra)
145 struct r8192_priv *priv = rtllib_priv(dev);
148 if (priv->bHwRadioOff == true)
153 ret = rtllib_wx_set_rawtx(priv->rtllib, info, wrqu, extra);
161 static int r8192_wx_force_reset(struct net_device *dev,
162 struct iw_request_info *info,
163 union iwreq_data *wrqu, char *extra)
165 struct r8192_priv *priv = rtllib_priv(dev);
169 RT_TRACE(COMP_DBG, "%s(): force reset ! extra is %d\n",
171 priv->force_reset = *extra;
177 static int r8192_wx_force_mic_error(struct net_device *dev,
178 struct iw_request_info *info,
179 union iwreq_data *wrqu, char *extra)
181 struct r8192_priv *priv = rtllib_priv(dev);
182 struct rtllib_device *ieee = priv->rtllib;
186 RT_TRACE(COMP_DBG, "%s(): force mic error !\n", __func__);
187 ieee->force_mic_error = true;
193 #define MAX_ADHOC_PEER_NUM 64
194 struct adhoc_peer_entry {
195 unsigned char MacAddr[ETH_ALEN];
196 unsigned char WirelessMode;
197 unsigned char bCurTxBW40MHz;
199 struct adhoc_peers_info {
200 struct adhoc_peer_entry Entry[MAX_ADHOC_PEER_NUM];
204 static int r8192_wx_get_adhoc_peers(struct net_device *dev,
205 struct iw_request_info *info,
206 union iwreq_data *wrqu, char *extra)
212 static int r8191se_wx_get_firm_version(struct net_device *dev,
213 struct iw_request_info *info,
214 struct iw_param *wrqu, char *extra)
219 static int r8192_wx_adapter_power_status(struct net_device *dev,
220 struct iw_request_info *info,
221 union iwreq_data *wrqu, char *extra)
223 struct r8192_priv *priv = rtllib_priv(dev);
224 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
225 (&(priv->rtllib->PowerSaveControl));
226 struct rtllib_device *ieee = priv->rtllib;
230 RT_TRACE(COMP_POWER, "%s(): %s\n", __func__, (*extra == 6) ?
231 "DC power" : "AC power");
232 if (*extra || priv->force_lps) {
233 priv->ps_force = false;
234 pPSC->bLeisurePs = true;
236 if (priv->rtllib->state == RTLLIB_LINKED)
239 priv->ps_force = true;
240 pPSC->bLeisurePs = false;
249 static int r8192se_wx_set_radio(struct net_device *dev,
250 struct iw_request_info *info,
251 union iwreq_data *wrqu, char *extra)
253 struct r8192_priv *priv = rtllib_priv(dev);
257 printk(KERN_INFO "%s(): set radio ! extra is %d\n", __func__, *extra);
258 if ((*extra != 0) && (*extra != 1)) {
259 RT_TRACE(COMP_ERR, "%s(): set radio an err value,must 0(radio "
260 "off) or 1(radio on)\n", __func__);
264 priv->sw_radio_on = *extra;
270 static int r8192se_wx_set_lps_awake_interval(struct net_device *dev,
271 struct iw_request_info *info,
272 union iwreq_data *wrqu, char *extra)
274 struct r8192_priv *priv = rtllib_priv(dev);
275 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
276 (&(priv->rtllib->PowerSaveControl));
280 printk(KERN_INFO "%s(): set lps awake interval ! extra is %d\n",
283 pPSC->RegMaxLPSAwakeIntvl = *extra;
288 static int r8192se_wx_set_force_lps(struct net_device *dev,
289 struct iw_request_info *info,
290 union iwreq_data *wrqu, char *extra)
292 struct r8192_priv *priv = rtllib_priv(dev);
296 printk(KERN_INFO "%s(): force LPS ! extra is %d (1 is open 0 is "
297 "close)\n", __func__, *extra);
298 priv->force_lps = *extra;
304 static int r8192_wx_set_debugflag(struct net_device *dev,
305 struct iw_request_info *info,
306 union iwreq_data *wrqu, char *extra)
308 struct r8192_priv *priv = rtllib_priv(dev);
311 if (priv->bHwRadioOff == true)
314 printk(KERN_INFO "=====>%s(), *extra:%x, debugflag:%x\n", __func__,
315 *extra, rt_global_debug_component);
317 rt_global_debug_component |= (1<<c);
319 rt_global_debug_component &= BIT31;
323 static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
324 union iwreq_data *wrqu, char *b)
326 struct r8192_priv *priv = rtllib_priv(dev);
327 struct rtllib_device *ieee = netdev_priv_rsl(dev);
329 enum rt_rf_power_state rtState;
332 if (priv->bHwRadioOff == true)
334 rtState = priv->rtllib->eRFPowerState;
336 if (wrqu->mode == IW_MODE_ADHOC || wrqu->mode == IW_MODE_MONITOR ||
337 ieee->bNetPromiscuousMode) {
338 if (priv->rtllib->PowerSaveControl.bInactivePs) {
339 if (rtState == eRfOff) {
340 if (priv->rtllib->RfOffReason >
342 RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",
347 printk(KERN_INFO "=========>%s(): "
348 "IPSLeave\n", __func__);
349 down(&priv->rtllib->ips_sem);
351 up(&priv->rtllib->ips_sem);
356 ret = rtllib_wx_set_mode(priv->rtllib, a, wrqu, b);
362 struct iw_range_with_scan_capa {
363 /* Informative stuff (to choose between different interface) */
364 __u32 throughput; /* To give an idea... */
365 /* In theory this value should be the maximum benchmarked
366 * TCP/IP throughput, because with most of these devices the
367 * bit rate is meaningless (overhead an co) to estimate how
368 * fast the connection will go and pick the fastest one.
369 * I suggest people to play with Netperf or any benchmark...
372 /* NWID (or domain id) */
373 __u32 min_nwid; /* Minimal NWID we are able to set */
374 __u32 max_nwid; /* Maximal NWID we are able to set */
376 /* Old Frequency (backward compat - moved lower ) */
377 __u16 old_num_channels;
378 __u8 old_num_frequency;
380 /* Scan capabilities */
384 static int rtl8192_wx_get_range(struct net_device *dev,
385 struct iw_request_info *info,
386 union iwreq_data *wrqu, char *extra)
388 struct iw_range *range = (struct iw_range *)extra;
389 struct r8192_priv *priv = rtllib_priv(dev);
393 wrqu->data.length = sizeof(*range);
394 memset(range, 0, sizeof(*range));
396 /* ~130 Mb/s real (802.11n) */
397 range->throughput = 130 * 1000 * 1000;
399 if (priv->rf_set_sens != NULL) {
400 /* signal level threshold range */
401 range->sensitivity = priv->max_sens;
404 range->max_qual.qual = 100;
405 range->max_qual.level = 0;
406 range->max_qual.noise = 0;
407 range->max_qual.updated = 7; /* Updated all three */
409 range->avg_qual.qual = 70; /* > 8% missed beacons is 'bad' */
410 range->avg_qual.level = 0;
411 range->avg_qual.noise = 0;
412 range->avg_qual.updated = 7; /* Updated all three */
414 range->num_bitrates = min(RATE_COUNT, IW_MAX_BITRATES);
416 for (i = 0; i < range->num_bitrates; i++)
417 range->bitrate[i] = rtl8192_rates[i];
419 range->max_rts = DEFAULT_RTS_THRESHOLD;
420 range->min_frag = MIN_FRAG_THRESHOLD;
421 range->max_frag = MAX_FRAG_THRESHOLD;
424 range->max_pmp = 5000000;
426 range->max_pmt = 65535*1000;
427 range->pmp_flags = IW_POWER_PERIOD;
428 range->pmt_flags = IW_POWER_TIMEOUT;
429 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
430 range->we_version_compiled = WIRELESS_EXT;
431 range->we_version_source = 18;
433 for (i = 0, val = 0; i < 14; i++) {
434 if ((priv->rtllib->active_channel_map)[i+1]) {
435 range->freq[val].i = i + 1;
436 range->freq[val].m = rtllib_wlan_frequencies[i] *
438 range->freq[val].e = 1;
442 if (val == IW_MAX_FREQUENCIES)
445 range->num_frequency = val;
446 range->num_channels = val;
447 range->enc_capa = IW_ENC_CAPA_WPA|IW_ENC_CAPA_WPA2|
448 IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP;
449 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE;
451 /* Event capability (kernel + driver) */
456 static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
457 union iwreq_data *wrqu, char *b)
459 struct r8192_priv *priv = rtllib_priv(dev);
460 struct rtllib_device *ieee = priv->rtllib;
461 enum rt_rf_power_state rtState;
464 if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) {
465 if ((ieee->state >= RTLLIB_ASSOCIATING) &&
466 (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED))
468 if ((priv->rtllib->state == RTLLIB_LINKED) &&
469 (priv->rtllib->CntAfterLink < 2))
473 if (priv->bHwRadioOff == true) {
474 printk(KERN_INFO "================>%s(): hwradio off\n",
478 rtState = priv->rtllib->eRFPowerState;
481 if (priv->rtllib->LinkDetectInfo.bBusyTraffic == true)
484 if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
485 struct iw_scan_req *req = (struct iw_scan_req *)b;
487 if (req->essid_len) {
488 ieee->current_network.ssid_len = req->essid_len;
489 memcpy(ieee->current_network.ssid, req->essid,
496 priv->rtllib->FirstIe_InScan = true;
498 if (priv->rtllib->state != RTLLIB_LINKED) {
499 if (priv->rtllib->PowerSaveControl.bInactivePs) {
500 if (rtState == eRfOff) {
501 if (priv->rtllib->RfOffReason >
503 RT_TRACE(COMP_ERR, "%s(): RF is "
508 RT_TRACE(COMP_PS, "=========>%s(): "
509 "IPSLeave\n", __func__);
510 down(&priv->rtllib->ips_sem);
512 up(&priv->rtllib->ips_sem);
516 rtllib_stop_scan(priv->rtllib);
517 if (priv->rtllib->LedControlHandler)
518 priv->rtllib->LedControlHandler(dev,
519 LED_CTL_SITE_SURVEY);
521 if (priv->rtllib->eRFPowerState != eRfOff) {
522 priv->rtllib->actscanning = true;
524 if (ieee->ScanOperationBackupHandler)
525 ieee->ScanOperationBackupHandler(ieee->dev,
528 rtllib_start_scan_syncro(priv->rtllib, 0);
530 if (ieee->ScanOperationBackupHandler)
531 ieee->ScanOperationBackupHandler(ieee->dev,
536 priv->rtllib->actscanning = true;
537 ret = rtllib_wx_set_scan(priv->rtllib, a, wrqu, b);
545 static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
546 union iwreq_data *wrqu, char *b)
550 struct r8192_priv *priv = rtllib_priv(dev);
555 if (priv->bHwRadioOff == true)
561 ret = rtllib_wx_get_scan(priv->rtllib, a, wrqu, b);
568 static int r8192_wx_set_essid(struct net_device *dev,
569 struct iw_request_info *a,
570 union iwreq_data *wrqu, char *b)
572 struct r8192_priv *priv = rtllib_priv(dev);
575 if ((rtllib_act_scanning(priv->rtllib, false)) &&
576 !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) {
577 ; /* TODO - get rid of if */
579 if (priv->bHwRadioOff == true) {
580 printk(KERN_INFO "=========>%s():hw radio off,or Rf state is "
581 "eRfOff, return\n", __func__);
585 ret = rtllib_wx_set_essid(priv->rtllib, a, wrqu, b);
592 static int r8192_wx_get_essid(struct net_device *dev,
593 struct iw_request_info *a,
594 union iwreq_data *wrqu, char *b)
597 struct r8192_priv *priv = rtllib_priv(dev);
601 ret = rtllib_wx_get_essid(priv->rtllib, a, wrqu, b);
608 static int r8192_wx_set_nick(struct net_device *dev,
609 struct iw_request_info *info,
610 union iwreq_data *wrqu, char *extra)
612 struct r8192_priv *priv = rtllib_priv(dev);
614 if (wrqu->data.length > IW_ESSID_MAX_SIZE)
617 wrqu->data.length = min_t(size_t, wrqu->data.length, sizeof(priv->nick));
618 memset(priv->nick, 0, sizeof(priv->nick));
619 memcpy(priv->nick, extra, wrqu->data.length);
625 static int r8192_wx_get_nick(struct net_device *dev,
626 struct iw_request_info *info,
627 union iwreq_data *wrqu, char *extra)
629 struct r8192_priv *priv = rtllib_priv(dev);
632 wrqu->data.length = strlen(priv->nick);
633 memcpy(extra, priv->nick, wrqu->data.length);
634 wrqu->data.flags = 1; /* active */
639 static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a,
640 union iwreq_data *wrqu, char *b)
643 struct r8192_priv *priv = rtllib_priv(dev);
645 if (priv->bHwRadioOff == true)
650 ret = rtllib_wx_set_freq(priv->rtllib, a, wrqu, b);
656 static int r8192_wx_get_name(struct net_device *dev,
657 struct iw_request_info *info,
658 union iwreq_data *wrqu, char *extra)
660 struct r8192_priv *priv = rtllib_priv(dev);
662 return rtllib_wx_get_name(priv->rtllib, info, wrqu, extra);
666 static int r8192_wx_set_frag(struct net_device *dev,
667 struct iw_request_info *info,
668 union iwreq_data *wrqu, char *extra)
670 struct r8192_priv *priv = rtllib_priv(dev);
672 if (priv->bHwRadioOff == true)
675 if (wrqu->frag.disabled)
676 priv->rtllib->fts = DEFAULT_FRAG_THRESHOLD;
678 if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
679 wrqu->frag.value > MAX_FRAG_THRESHOLD)
682 priv->rtllib->fts = wrqu->frag.value & ~0x1;
689 static int r8192_wx_get_frag(struct net_device *dev,
690 struct iw_request_info *info,
691 union iwreq_data *wrqu, char *extra)
693 struct r8192_priv *priv = rtllib_priv(dev);
695 wrqu->frag.value = priv->rtllib->fts;
696 wrqu->frag.fixed = 0; /* no auto select */
697 wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD);
703 static int r8192_wx_set_wap(struct net_device *dev,
704 struct iw_request_info *info,
705 union iwreq_data *awrq,
709 struct r8192_priv *priv = rtllib_priv(dev);
711 if ((rtllib_act_scanning(priv->rtllib, false)) &&
712 !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) {
713 ; /* TODO - get rid of if */
716 if (priv->bHwRadioOff == true)
721 ret = rtllib_wx_set_wap(priv->rtllib, info, awrq, extra);
730 static int r8192_wx_get_wap(struct net_device *dev,
731 struct iw_request_info *info,
732 union iwreq_data *wrqu, char *extra)
734 struct r8192_priv *priv = rtllib_priv(dev);
736 return rtllib_wx_get_wap(priv->rtllib, info, wrqu, extra);
740 static int r8192_wx_get_enc(struct net_device *dev,
741 struct iw_request_info *info,
742 union iwreq_data *wrqu, char *key)
744 struct r8192_priv *priv = rtllib_priv(dev);
746 return rtllib_wx_get_encode(priv->rtllib, info, wrqu, key);
749 static int r8192_wx_set_enc(struct net_device *dev,
750 struct iw_request_info *info,
751 union iwreq_data *wrqu, char *key)
753 struct r8192_priv *priv = rtllib_priv(dev);
756 struct rtllib_device *ieee = priv->rtllib;
757 u32 hwkey[4] = {0, 0, 0, 0};
760 u8 zero_addr[4][6] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
761 {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
762 {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
763 {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} };
766 if ((rtllib_act_scanning(priv->rtllib, false)) &&
767 !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN))
768 ; /* TODO - get rid of if */
769 if (priv->bHwRadioOff == true)
775 priv->rtllib->wx_set_enc = 1;
776 down(&priv->rtllib->ips_sem);
778 up(&priv->rtllib->ips_sem);
781 RT_TRACE(COMP_SEC, "Setting SW wep key");
782 ret = rtllib_wx_set_encode(priv->rtllib, info, wrqu, key);
786 if (wrqu->encoding.flags & IW_ENCODE_DISABLED) {
787 ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA;
788 CamResetAllEntry(dev);
789 memset(priv->rtllib->swcamtable, 0,
790 sizeof(struct sw_cam_table) * 32);
793 if (wrqu->encoding.length != 0) {
795 for (i = 0; i < 4; i++) {
796 hwkey[i] |= key[4*i+0]&mask;
797 if (i == 1 && (4 * i + 1) == wrqu->encoding.length)
799 if (i == 3 && (4 * i + 1) == wrqu->encoding.length)
801 hwkey[i] |= (key[4 * i + 1] & mask) << 8;
802 hwkey[i] |= (key[4 * i + 2] & mask) << 16;
803 hwkey[i] |= (key[4 * i + 3] & mask) << 24;
806 #define CONF_WEP40 0x4
807 #define CONF_WEP104 0x14
809 switch (wrqu->encoding.flags & IW_ENCODE_INDEX) {
811 key_idx = ieee->crypt_info.tx_keyidx;
828 if (wrqu->encoding.length == 0x5) {
829 ieee->pairwise_key_type = KEY_TYPE_WEP40;
830 EnableHWSecurityConfig8192(dev);
833 else if (wrqu->encoding.length == 0xd) {
834 ieee->pairwise_key_type = KEY_TYPE_WEP104;
835 EnableHWSecurityConfig8192(dev);
836 setKey(dev, key_idx, key_idx, KEY_TYPE_WEP104,
837 zero_addr[key_idx], 0, hwkey);
838 set_swcam(dev, key_idx, key_idx, KEY_TYPE_WEP104,
839 zero_addr[key_idx], 0, hwkey, 0);
841 printk(KERN_INFO "wrong type in WEP, not WEP40 and WEP104\n");
846 priv->rtllib->wx_set_enc = 0;
850 static int r8192_wx_set_scan_type(struct net_device *dev,
851 struct iw_request_info *aa,
852 union iwreq_data *wrqu, char *p)
854 struct r8192_priv *priv = rtllib_priv(dev);
855 int *parms = (int *)p;
858 if (priv->bHwRadioOff == true)
861 priv->rtllib->active_scan = mode;
868 #define R8192_MAX_RETRY 255
869 static int r8192_wx_set_retry(struct net_device *dev,
870 struct iw_request_info *info,
871 union iwreq_data *wrqu, char *extra)
873 struct r8192_priv *priv = rtllib_priv(dev);
876 if (priv->bHwRadioOff == true)
881 if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
882 wrqu->retry.disabled) {
886 if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) {
891 if (wrqu->retry.value > R8192_MAX_RETRY) {
895 if (wrqu->retry.flags & IW_RETRY_MAX) {
896 priv->retry_rts = wrqu->retry.value;
897 DMESG("Setting retry for RTS/CTS data to %d",
901 priv->retry_data = wrqu->retry.value;
902 DMESG("Setting retry for non RTS/CTS data to %d",
914 static int r8192_wx_get_retry(struct net_device *dev,
915 struct iw_request_info *info,
916 union iwreq_data *wrqu, char *extra)
918 struct r8192_priv *priv = rtllib_priv(dev);
921 wrqu->retry.disabled = 0; /* can't be disabled */
923 if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
927 if (wrqu->retry.flags & IW_RETRY_MAX) {
928 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
929 wrqu->retry.value = priv->retry_rts;
931 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
932 wrqu->retry.value = priv->retry_data;
937 static int r8192_wx_get_sens(struct net_device *dev,
938 struct iw_request_info *info,
939 union iwreq_data *wrqu, char *extra)
941 struct r8192_priv *priv = rtllib_priv(dev);
943 if (priv->rf_set_sens == NULL)
944 return -1; /* we have not this support for this radio */
945 wrqu->sens.value = priv->sens;
950 static int r8192_wx_set_sens(struct net_device *dev,
951 struct iw_request_info *info,
952 union iwreq_data *wrqu, char *extra)
955 struct r8192_priv *priv = rtllib_priv(dev);
959 if (priv->bHwRadioOff == true)
963 if (priv->rf_set_sens == NULL) {
964 err = -1; /* we have not this support for this radio */
967 if (priv->rf_set_sens(dev, wrqu->sens.value) == 0)
968 priv->sens = wrqu->sens.value;
978 static int r8192_wx_set_enc_ext(struct net_device *dev,
979 struct iw_request_info *info,
980 union iwreq_data *wrqu, char *extra)
983 struct r8192_priv *priv = rtllib_priv(dev);
984 struct rtllib_device *ieee = priv->rtllib;
986 if (priv->bHwRadioOff == true)
991 priv->rtllib->wx_set_enc = 1;
992 down(&priv->rtllib->ips_sem);
994 up(&priv->rtllib->ips_sem);
996 ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra);
998 u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1001 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1002 struct iw_point *encoding = &wrqu->encoding;
1003 u8 idx = 0, alg = 0, group = 0;
1005 if ((encoding->flags & IW_ENCODE_DISABLED) ||
1006 ext->alg == IW_ENCODE_ALG_NONE) {
1007 ieee->pairwise_key_type = ieee->group_key_type
1009 CamResetAllEntry(dev);
1010 memset(priv->rtllib->swcamtable, 0,
1011 sizeof(struct sw_cam_table) * 32);
1014 alg = (ext->alg == IW_ENCODE_ALG_CCMP) ? KEY_TYPE_CCMP :
1016 idx = encoding->flags & IW_ENCODE_INDEX;
1019 group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY;
1021 if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) ||
1022 (alg == KEY_TYPE_WEP40)) {
1023 if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40))
1024 alg = KEY_TYPE_WEP104;
1025 ieee->pairwise_key_type = alg;
1026 EnableHWSecurityConfig8192(dev);
1028 memcpy((u8 *)key, ext->key, 16);
1030 if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode != 2)) {
1031 if (ext->key_len == 13)
1032 ieee->pairwise_key_type = alg = KEY_TYPE_WEP104;
1033 setKey(dev, idx, idx, alg, zero, 0, key);
1034 set_swcam(dev, idx, idx, alg, zero, 0, key, 0);
1036 ieee->group_key_type = alg;
1037 setKey(dev, idx, idx, alg, broadcast_addr, 0, key);
1038 set_swcam(dev, idx, idx, alg, broadcast_addr, 0,
1041 if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) &&
1042 ieee->pHTInfo->bCurrentHTSupport)
1043 write_nic_byte(dev, 0x173, 1);
1044 setKey(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr,
1046 set_swcam(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr,
1054 priv->rtllib->wx_set_enc = 0;
1059 static int r8192_wx_set_auth(struct net_device *dev,
1060 struct iw_request_info *info,
1061 union iwreq_data *data, char *extra)
1065 struct r8192_priv *priv = rtllib_priv(dev);
1067 if (priv->bHwRadioOff == true)
1070 down(&priv->wx_sem);
1071 ret = rtllib_wx_set_auth(priv->rtllib, info, &(data->param), extra);
1076 static int r8192_wx_set_mlme(struct net_device *dev,
1077 struct iw_request_info *info,
1078 union iwreq_data *wrqu, char *extra)
1083 struct r8192_priv *priv = rtllib_priv(dev);
1085 if (priv->bHwRadioOff == true)
1088 down(&priv->wx_sem);
1089 ret = rtllib_wx_set_mlme(priv->rtllib, info, wrqu, extra);
1094 static int r8192_wx_set_gen_ie(struct net_device *dev,
1095 struct iw_request_info *info,
1096 union iwreq_data *data, char *extra)
1100 struct r8192_priv *priv = rtllib_priv(dev);
1102 if (priv->bHwRadioOff == true)
1105 down(&priv->wx_sem);
1106 ret = rtllib_wx_set_gen_ie(priv->rtllib, extra, data->data.length);
1111 static int r8192_wx_get_gen_ie(struct net_device *dev,
1112 struct iw_request_info *info,
1113 union iwreq_data *data, char *extra)
1116 struct r8192_priv *priv = rtllib_priv(dev);
1117 struct rtllib_device *ieee = priv->rtllib;
1119 if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) {
1120 data->data.length = 0;
1124 if (data->data.length < ieee->wpa_ie_len)
1127 data->data.length = ieee->wpa_ie_len;
1128 memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len);
1132 #define OID_RT_INTEL_PROMISCUOUS_MODE 0xFF0101F6
1134 static int r8192_wx_set_PromiscuousMode(struct net_device *dev,
1135 struct iw_request_info *info,
1136 union iwreq_data *wrqu, char *extra)
1138 struct r8192_priv *priv = rtllib_priv(dev);
1139 struct rtllib_device *ieee = priv->rtllib;
1145 u32 bFilterSourceStationFrame;
1147 if (copy_from_user(info_buf, wrqu->data.pointer, sizeof(info_buf)))
1151 bPromiscuousOn = info_buf[1];
1152 bFilterSourceStationFrame = info_buf[2];
1154 if (OID_RT_INTEL_PROMISCUOUS_MODE == oid) {
1155 ieee->IntelPromiscuousModeInfo.bPromiscuousOn =
1156 (bPromiscuousOn) ? (true) : (false);
1157 ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame =
1158 (bFilterSourceStationFrame) ? (true) : (false);
1160 (rtllib_EnableIntelPromiscuousMode(dev, false)) :
1161 (rtllib_DisableIntelPromiscuousMode(dev, false));
1163 printk(KERN_INFO "=======>%s(), on = %d, filter src sta = %d\n",
1164 __func__, bPromiscuousOn, bFilterSourceStationFrame);
1173 static int r8192_wx_get_PromiscuousMode(struct net_device *dev,
1174 struct iw_request_info *info,
1175 union iwreq_data *wrqu, char *extra)
1177 struct r8192_priv *priv = rtllib_priv(dev);
1178 struct rtllib_device *ieee = priv->rtllib;
1180 down(&priv->wx_sem);
1182 snprintf(extra, 45, "PromiscuousMode:%d, FilterSrcSTAFrame:%d",
1183 ieee->IntelPromiscuousModeInfo.bPromiscuousOn,
1184 ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame);
1185 wrqu->data.length = strlen(extra) + 1;
1193 #define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT]
1194 static iw_handler r8192_wx_handlers[] = {
1195 IW_IOCTL(SIOCGIWNAME) = r8192_wx_get_name,
1196 IW_IOCTL(SIOCSIWFREQ) = r8192_wx_set_freq,
1197 IW_IOCTL(SIOCGIWFREQ) = r8192_wx_get_freq,
1198 IW_IOCTL(SIOCSIWMODE) = r8192_wx_set_mode,
1199 IW_IOCTL(SIOCGIWMODE) = r8192_wx_get_mode,
1200 IW_IOCTL(SIOCSIWSENS) = r8192_wx_set_sens,
1201 IW_IOCTL(SIOCGIWSENS) = r8192_wx_get_sens,
1202 IW_IOCTL(SIOCGIWRANGE) = rtl8192_wx_get_range,
1203 IW_IOCTL(SIOCSIWAP) = r8192_wx_set_wap,
1204 IW_IOCTL(SIOCGIWAP) = r8192_wx_get_wap,
1205 IW_IOCTL(SIOCSIWSCAN) = r8192_wx_set_scan,
1206 IW_IOCTL(SIOCGIWSCAN) = r8192_wx_get_scan,
1207 IW_IOCTL(SIOCSIWESSID) = r8192_wx_set_essid,
1208 IW_IOCTL(SIOCGIWESSID) = r8192_wx_get_essid,
1209 IW_IOCTL(SIOCSIWNICKN) = r8192_wx_set_nick,
1210 IW_IOCTL(SIOCGIWNICKN) = r8192_wx_get_nick,
1211 IW_IOCTL(SIOCSIWRATE) = r8192_wx_set_rate,
1212 IW_IOCTL(SIOCGIWRATE) = r8192_wx_get_rate,
1213 IW_IOCTL(SIOCSIWRTS) = r8192_wx_set_rts,
1214 IW_IOCTL(SIOCGIWRTS) = r8192_wx_get_rts,
1215 IW_IOCTL(SIOCSIWFRAG) = r8192_wx_set_frag,
1216 IW_IOCTL(SIOCGIWFRAG) = r8192_wx_get_frag,
1217 IW_IOCTL(SIOCSIWRETRY) = r8192_wx_set_retry,
1218 IW_IOCTL(SIOCGIWRETRY) = r8192_wx_get_retry,
1219 IW_IOCTL(SIOCSIWENCODE) = r8192_wx_set_enc,
1220 IW_IOCTL(SIOCGIWENCODE) = r8192_wx_get_enc,
1221 IW_IOCTL(SIOCSIWPOWER) = r8192_wx_set_power,
1222 IW_IOCTL(SIOCGIWPOWER) = r8192_wx_get_power,
1223 IW_IOCTL(SIOCSIWGENIE) = r8192_wx_set_gen_ie,
1224 IW_IOCTL(SIOCGIWGENIE) = r8192_wx_get_gen_ie,
1225 IW_IOCTL(SIOCSIWMLME) = r8192_wx_set_mlme,
1226 IW_IOCTL(SIOCSIWAUTH) = r8192_wx_set_auth,
1227 IW_IOCTL(SIOCSIWENCODEEXT) = r8192_wx_set_enc_ext,
1231 * the following rule need to be following,
1232 * Odd : get (world access),
1233 * even : set (root access)
1235 static const struct iw_priv_args r8192_private_args[] = {
1237 SIOCIWFIRSTPRIV + 0x0,
1238 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_debugflag"
1240 SIOCIWFIRSTPRIV + 0x1,
1241 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
1243 SIOCIWFIRSTPRIV + 0x2,
1244 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx"
1246 SIOCIWFIRSTPRIV + 0x3,
1247 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset"
1249 SIOCIWFIRSTPRIV + 0x4,
1250 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "force_mic_error"
1252 SIOCIWFIRSTPRIV + 0x5,
1253 IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1,
1256 SIOCIWFIRSTPRIV + 0x6,
1257 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
1260 SIOCIWFIRSTPRIV + 0x9,
1261 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
1264 SIOCIWFIRSTPRIV + 0xa,
1265 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
1268 SIOCIWFIRSTPRIV + 0xb,
1269 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
1272 SIOCIWFIRSTPRIV + 0xc,
1273 0, IW_PRIV_TYPE_CHAR|2047, "adhoc_peer_list"
1275 SIOCIWFIRSTPRIV + 0x16,
1276 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc"
1278 SIOCIWFIRSTPRIV + 0x17,
1279 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 45, "getpromisc"
1284 static iw_handler r8192_private_handler[] = {
1285 (iw_handler)r8192_wx_set_debugflag, /*SIOCIWSECONDPRIV*/
1286 (iw_handler)r8192_wx_set_scan_type,
1287 (iw_handler)r8192_wx_set_rawtx,
1288 (iw_handler)r8192_wx_force_reset,
1289 (iw_handler)r8192_wx_force_mic_error,
1290 (iw_handler)r8191se_wx_get_firm_version,
1291 (iw_handler)r8192_wx_adapter_power_status,
1294 (iw_handler)r8192se_wx_set_radio,
1295 (iw_handler)r8192se_wx_set_lps_awake_interval,
1296 (iw_handler)r8192se_wx_set_force_lps,
1297 (iw_handler)r8192_wx_get_adhoc_peers,
1307 (iw_handler)r8192_wx_set_PromiscuousMode,
1308 (iw_handler)r8192_wx_get_PromiscuousMode,
1311 static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
1313 struct r8192_priv *priv = rtllib_priv(dev);
1314 struct rtllib_device *ieee = priv->rtllib;
1315 struct iw_statistics *wstats = &priv->wstats;
1320 if (ieee->state < RTLLIB_LINKED) {
1321 wstats->qual.qual = 10;
1322 wstats->qual.level = 0;
1323 wstats->qual.noise = -100;
1324 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1328 tmp_level = (&ieee->current_network)->stats.rssi;
1329 tmp_qual = (&ieee->current_network)->stats.signal;
1330 tmp_noise = (&ieee->current_network)->stats.noise;
1332 wstats->qual.level = tmp_level;
1333 wstats->qual.qual = tmp_qual;
1334 wstats->qual.noise = tmp_noise;
1335 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1339 const struct iw_handler_def r8192_wx_handlers_def = {
1340 .standard = r8192_wx_handlers,
1341 .num_standard = ARRAY_SIZE(r8192_wx_handlers),
1342 .private = r8192_private_handler,
1343 .num_private = ARRAY_SIZE(r8192_private_handler),
1344 .num_private_args = sizeof(r8192_private_args) /
1345 sizeof(struct iw_priv_args),
1346 .get_wireless_stats = r8192_get_wireless_stats,
1347 .private_args = (struct iw_priv_args *)r8192_private_args,