1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
4 * Based on the r8180 driver, which is:
5 * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * The full GNU General Public License is included in this distribution in the
16 * file called LICENSE.
18 * Contact Information:
19 * wlanfae <wlanfae@realtek.com>
20 ******************************************************************************/
21 #include <linux/uaccess.h>
22 #include <linux/pci.h>
23 #include <linux/vmalloc.h>
24 #include <linux/ieee80211.h>
26 #include "r8192E_phy.h"
27 #include "r8192E_phyreg.h"
28 #include "r8190P_rtl8256.h"
29 #include "r8192E_cmdpkt.h"
37 static int channels = 0x3fff;
38 static char *ifname = "wlan%d";
41 static struct rtl819x_ops rtl819xp_ops = {
42 .nic_type = NIC_8192E,
43 .get_eeprom_size = rtl92e_get_eeprom_size,
44 .init_adapter_variable = rtl92e_init_variables,
45 .initialize_adapter = rtl92e_start_adapter,
46 .link_change = rtl92e_link_change,
47 .tx_fill_descriptor = rtl92e_fill_tx_desc,
48 .tx_fill_cmd_descriptor = rtl92e_fill_tx_cmd_desc,
49 .rx_query_status_descriptor = rtl92e_get_rx_stats,
50 .rx_command_packet_handler = NULL,
51 .stop_adapter = rtl92e_stop_adapter,
52 .update_ratr_table = rtl92e_update_ratr_table,
53 .irq_enable = rtl92e_enable_irq,
54 .irq_disable = rtl92e_disable_irq,
55 .irq_clear = rtl92e_clear_irq,
56 .rx_enable = rtl92e_enable_rx,
57 .tx_enable = rtl92e_enable_tx,
58 .interrupt_recognized = rtl92e_ack_irq,
59 .TxCheckStuckHandler = rtl92e_is_tx_stuck,
60 .RxCheckStuckHandler = rtl92e_is_rx_stuck,
63 static struct pci_device_id rtl8192_pci_id_tbl[] = {
64 {RTL_PCI_DEVICE(0x10ec, 0x8192, rtl819xp_ops)},
65 {RTL_PCI_DEVICE(0x07aa, 0x0044, rtl819xp_ops)},
66 {RTL_PCI_DEVICE(0x07aa, 0x0047, rtl819xp_ops)},
70 MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl);
72 static int _rtl92e_pci_probe(struct pci_dev *pdev,
73 const struct pci_device_id *id);
74 static void _rtl92e_pci_disconnect(struct pci_dev *pdev);
75 static irqreturn_t _rtl92e_irq(int irq, void *netdev);
77 static struct pci_driver rtl8192_pci_driver = {
78 .name = DRV_NAME, /* Driver name */
79 .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */
80 .probe = _rtl92e_pci_probe, /* probe fn */
81 .remove = _rtl92e_pci_disconnect, /* remove fn */
82 .suspend = rtl92e_suspend, /* PM suspend fn */
83 .resume = rtl92e_resume, /* PM resume fn */
86 static short _rtl92e_is_tx_queue_empty(struct net_device *dev);
87 static void _rtl92e_watchdog_wq_cb(void *data);
88 static void _rtl92e_watchdog_timer_cb(unsigned long data);
89 static void _rtl92e_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
91 static int _rtl92e_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
92 static void _rtl92e_tx_cmd(struct net_device *dev, struct sk_buff *skb);
93 static short _rtl92e_tx(struct net_device *dev, struct sk_buff *skb);
94 static short _rtl92e_pci_initdescring(struct net_device *dev);
95 static void _rtl92e_irq_tx_tasklet(struct r8192_priv *priv);
96 static void _rtl92e_irq_rx_tasklet(struct r8192_priv *priv);
97 static void _rtl92e_cancel_deferred_work(struct r8192_priv *priv);
98 static int _rtl92e_up(struct net_device *dev, bool is_silent_reset);
99 static int _rtl92e_try_up(struct net_device *dev);
100 static int _rtl92e_down(struct net_device *dev, bool shutdownrf);
101 static void _rtl92e_restart(void *data);
103 /****************************************************************************
104 -----------------------------IO STUFF-------------------------
105 *****************************************************************************/
107 u8 rtl92e_readb(struct net_device *dev, int x)
109 return 0xff & readb((u8 __iomem *)dev->mem_start + x);
112 u32 rtl92e_readl(struct net_device *dev, int x)
114 return readl((u8 __iomem *)dev->mem_start + x);
117 u16 rtl92e_readw(struct net_device *dev, int x)
119 return readw((u8 __iomem *)dev->mem_start + x);
122 void rtl92e_writeb(struct net_device *dev, int x, u8 y)
124 writeb(y, (u8 __iomem *)dev->mem_start + x);
129 void rtl92e_writel(struct net_device *dev, int x, u32 y)
131 writel(y, (u8 __iomem *)dev->mem_start + x);
136 void rtl92e_writew(struct net_device *dev, int x, u16 y)
138 writew(y, (u8 __iomem *)dev->mem_start + x);
143 /****************************************************************************
144 -----------------------------GENERAL FUNCTION-------------------------
145 *****************************************************************************/
146 bool rtl92e_set_rf_state(struct net_device *dev,
147 enum rt_rf_power_state StateToSet,
148 RT_RF_CHANGE_SOURCE ChangeSource)
150 struct r8192_priv *priv = rtllib_priv(dev);
151 struct rtllib_device *ieee = priv->rtllib;
152 bool bActionAllowed = false;
153 bool bConnectBySSID = false;
154 enum rt_rf_power_state rtState;
155 u16 RFWaitCounter = 0;
158 RT_TRACE((COMP_PS | COMP_RF),
159 "===>rtl92e_set_rf_state(): StateToSet(%d)\n", StateToSet);
162 spin_lock_irqsave(&priv->rf_ps_lock, flag);
163 if (priv->RFChangeInProgress) {
164 spin_unlock_irqrestore(&priv->rf_ps_lock, flag);
165 RT_TRACE((COMP_PS | COMP_RF),
166 "rtl92e_set_rf_state(): RF Change in progress! Wait to set..StateToSet(%d).\n",
169 while (priv->RFChangeInProgress) {
171 RT_TRACE((COMP_PS | COMP_RF),
172 "rtl92e_set_rf_state(): Wait 1 ms (%d times)...\n",
176 if (RFWaitCounter > 100) {
178 "%s(): Timeout waiting for RF change.\n",
184 priv->RFChangeInProgress = true;
185 spin_unlock_irqrestore(&priv->rf_ps_lock, flag);
190 rtState = priv->rtllib->eRFPowerState;
192 switch (StateToSet) {
194 priv->rtllib->RfOffReason &= (~ChangeSource);
196 if ((ChangeSource == RF_CHANGE_BY_HW) && priv->bHwRadioOff)
197 priv->bHwRadioOff = false;
199 if (!priv->rtllib->RfOffReason) {
200 priv->rtllib->RfOffReason = 0;
201 bActionAllowed = true;
204 if (rtState == eRfOff &&
205 ChangeSource >= RF_CHANGE_BY_HW)
206 bConnectBySSID = true;
208 RT_TRACE((COMP_PS | COMP_RF),
209 "rtl92e_set_rf_state - eRfon reject pMgntInfo->RfOffReason= 0x%x, ChangeSource=0x%X\n",
210 priv->rtllib->RfOffReason, ChangeSource);
217 if ((priv->rtllib->iw_mode == IW_MODE_INFRA) ||
218 (priv->rtllib->iw_mode == IW_MODE_ADHOC)) {
219 if ((priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) ||
220 (ChangeSource > RF_CHANGE_BY_IPS)) {
221 if (ieee->state == RTLLIB_LINKED)
222 priv->blinked_ingpio = true;
224 priv->blinked_ingpio = false;
225 rtllib_MgntDisconnect(priv->rtllib,
226 WLAN_REASON_DISASSOC_STA_HAS_LEFT);
229 if ((ChangeSource == RF_CHANGE_BY_HW) && !priv->bHwRadioOff)
230 priv->bHwRadioOff = true;
231 priv->rtllib->RfOffReason |= ChangeSource;
232 bActionAllowed = true;
236 priv->rtllib->RfOffReason |= ChangeSource;
237 bActionAllowed = true;
244 if (bActionAllowed) {
245 RT_TRACE((COMP_PS | COMP_RF),
246 "rtl92e_set_rf_state(): Action is allowed.... StateToSet(%d), RfOffReason(%#X)\n",
247 StateToSet, priv->rtllib->RfOffReason);
248 PHY_SetRFPowerState(dev, StateToSet);
249 if (StateToSet == eRfOn) {
251 if (bConnectBySSID && priv->blinked_ingpio) {
252 queue_delayed_work_rsl(ieee->wq,
253 &ieee->associate_procedure_wq, 0);
254 priv->blinked_ingpio = false;
258 RT_TRACE((COMP_PS | COMP_RF),
259 "rtl92e_set_rf_state(): Action is rejected.... StateToSet(%d), ChangeSource(%#X), RfOffReason(%#X)\n",
260 StateToSet, ChangeSource, priv->rtllib->RfOffReason);
263 spin_lock_irqsave(&priv->rf_ps_lock, flag);
264 priv->RFChangeInProgress = false;
265 spin_unlock_irqrestore(&priv->rf_ps_lock, flag);
267 RT_TRACE((COMP_PS | COMP_RF), "<===rtl92e_set_rf_state()\n");
268 return bActionAllowed;
271 static short _rtl92e_check_nic_enough_desc(struct net_device *dev, int prio)
273 struct r8192_priv *priv = rtllib_priv(dev);
274 struct rtl8192_tx_ring *ring = &priv->tx_ring[prio];
276 if (ring->entries - skb_queue_len(&ring->queue) >= 2)
281 static void _rtl92e_tx_timeout(struct net_device *dev)
283 struct r8192_priv *priv = rtllib_priv(dev);
285 schedule_work(&priv->reset_wq);
286 netdev_info(dev, "TXTIMEOUT");
289 void rtl92e_irq_enable(struct net_device *dev)
291 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
293 priv->irq_enabled = 1;
295 priv->ops->irq_enable(dev);
298 void rtl92e_irq_disable(struct net_device *dev)
300 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
302 priv->ops->irq_disable(dev);
304 priv->irq_enabled = 0;
307 static void _rtl92e_set_chan(struct net_device *dev, short ch)
309 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
311 RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __func__, ch);
312 if (priv->chan_forced)
317 if (priv->rf_set_chan)
318 priv->rf_set_chan(dev, priv->chan);
321 static void _rtl92e_update_cap(struct net_device *dev, u16 cap)
323 struct r8192_priv *priv = rtllib_priv(dev);
324 struct rtllib_network *net = &priv->rtllib->current_network;
327 if (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) {
328 if (priv->dot11CurrentPreambleMode != PREAMBLE_SHORT) {
329 ShortPreamble = true;
330 priv->dot11CurrentPreambleMode = PREAMBLE_SHORT;
332 "%s(): WLAN_CAPABILITY_SHORT_PREAMBLE\n",
334 priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE,
335 (unsigned char *)&ShortPreamble);
338 if (priv->dot11CurrentPreambleMode != PREAMBLE_LONG) {
339 ShortPreamble = false;
340 priv->dot11CurrentPreambleMode = PREAMBLE_LONG;
342 "%s(): WLAN_CAPABILITY_LONG_PREAMBLE\n",
344 priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE,
345 (unsigned char *)&ShortPreamble);
349 if (net->mode & (IEEE_G|IEEE_N_24G)) {
351 u8 CurSlotTime = priv->slot_time;
353 if ((cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) &&
354 (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) {
355 if (CurSlotTime != SHORT_SLOT_TIME) {
356 slot_time_val = SHORT_SLOT_TIME;
357 priv->rtllib->SetHwRegHandler(dev,
358 HW_VAR_SLOT_TIME, &slot_time_val);
361 if (CurSlotTime != NON_SHORT_SLOT_TIME) {
362 slot_time_val = NON_SHORT_SLOT_TIME;
363 priv->rtllib->SetHwRegHandler(dev,
364 HW_VAR_SLOT_TIME, &slot_time_val);
370 static struct rtllib_qos_parameters def_qos_parameters = {
371 {cpu_to_le16(3), cpu_to_le16(3), cpu_to_le16(3), cpu_to_le16(3)},
372 {cpu_to_le16(7), cpu_to_le16(7), cpu_to_le16(7), cpu_to_le16(7)},
378 static void _rtl92e_update_beacon(void *data)
380 struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv,
381 update_beacon_wq.work);
382 struct net_device *dev = priv->rtllib->dev;
383 struct rtllib_device *ieee = priv->rtllib;
384 struct rtllib_network *net = &ieee->current_network;
386 if (ieee->pHTInfo->bCurrentHTSupport)
387 HT_update_self_and_peer_setting(ieee, net);
388 ieee->pHTInfo->bCurrentRT2RTLongSlotTime =
389 net->bssht.bdRT2RTLongSlotTime;
390 ieee->pHTInfo->RT2RT_HT_Mode = net->bssht.RT2RT_HT_Mode;
391 _rtl92e_update_cap(dev, net->capability);
394 static void _rtl92e_qos_activate(void *data)
396 struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv,
398 struct net_device *dev = priv->rtllib->dev;
401 mutex_lock(&priv->mutex);
402 if (priv->rtllib->state != RTLLIB_LINKED)
405 "qos active process with associate response received\n");
407 for (i = 0; i < QOS_QUEUE_NUM; i++)
408 priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&i));
412 mutex_unlock(&priv->mutex);
415 static int _rtl92e_qos_handle_probe_response(struct r8192_priv *priv,
417 struct rtllib_network *network)
420 u32 size = sizeof(struct rtllib_qos_parameters);
422 if (priv->rtllib->state != RTLLIB_LINKED)
425 if (priv->rtllib->iw_mode != IW_MODE_INFRA)
428 if (network->flags & NETWORK_HAS_QOS_MASK) {
429 if (active_network &&
430 (network->flags & NETWORK_HAS_QOS_PARAMETERS))
431 network->qos_data.active = network->qos_data.supported;
433 if ((network->qos_data.active == 1) && (active_network == 1) &&
434 (network->flags & NETWORK_HAS_QOS_PARAMETERS) &&
435 (network->qos_data.old_param_count !=
436 network->qos_data.param_count)) {
437 network->qos_data.old_param_count =
438 network->qos_data.param_count;
439 priv->rtllib->wmm_acm = network->qos_data.wmm_acm;
440 queue_work_rsl(priv->priv_wq, &priv->qos_activate);
442 "QoS parameters change call qos_activate\n");
445 memcpy(&priv->rtllib->current_network.qos_data.parameters,
446 &def_qos_parameters, size);
448 if ((network->qos_data.active == 1) && (active_network == 1)) {
449 queue_work_rsl(priv->priv_wq, &priv->qos_activate);
451 "QoS was disabled call qos_activate\n");
453 network->qos_data.active = 0;
454 network->qos_data.supported = 0;
460 static int _rtl92e_handle_beacon(struct net_device *dev,
461 struct rtllib_beacon *beacon,
462 struct rtllib_network *network)
464 struct r8192_priv *priv = rtllib_priv(dev);
466 _rtl92e_qos_handle_probe_response(priv, 1, network);
468 queue_delayed_work_rsl(priv->priv_wq, &priv->update_beacon_wq, 0);
473 static int _rtl92e_qos_assoc_resp(struct r8192_priv *priv,
474 struct rtllib_network *network)
477 u32 size = sizeof(struct rtllib_qos_parameters);
478 int set_qos_param = 0;
480 if ((priv == NULL) || (network == NULL))
483 if (priv->rtllib->state != RTLLIB_LINKED)
486 if (priv->rtllib->iw_mode != IW_MODE_INFRA)
489 spin_lock_irqsave(&priv->rtllib->lock, flags);
490 if (network->flags & NETWORK_HAS_QOS_PARAMETERS) {
491 memcpy(&priv->rtllib->current_network.qos_data.parameters,
492 &network->qos_data.parameters,
493 sizeof(struct rtllib_qos_parameters));
494 priv->rtllib->current_network.qos_data.active = 1;
495 priv->rtllib->wmm_acm = network->qos_data.wmm_acm;
497 priv->rtllib->current_network.qos_data.old_param_count =
498 priv->rtllib->current_network.qos_data.param_count;
499 priv->rtllib->current_network.qos_data.param_count =
500 network->qos_data.param_count;
502 memcpy(&priv->rtllib->current_network.qos_data.parameters,
503 &def_qos_parameters, size);
504 priv->rtllib->current_network.qos_data.active = 0;
505 priv->rtllib->current_network.qos_data.supported = 0;
509 spin_unlock_irqrestore(&priv->rtllib->lock, flags);
511 RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__,
512 network->flags, priv->rtllib->current_network.qos_data.active);
513 if (set_qos_param == 1) {
514 rtl92e_dm_init_edca_turbo(priv->rtllib->dev);
515 queue_work_rsl(priv->priv_wq, &priv->qos_activate);
520 static int _rtl92e_handle_assoc_response(struct net_device *dev,
521 struct rtllib_assoc_response_frame *resp,
522 struct rtllib_network *network)
524 struct r8192_priv *priv = rtllib_priv(dev);
526 _rtl92e_qos_assoc_resp(priv, network);
530 static void _rtl92e_prepare_beacon(struct r8192_priv *priv)
532 struct net_device *dev = priv->rtllib->dev;
533 struct sk_buff *pskb = NULL, *pnewskb = NULL;
534 struct cb_desc *tcb_desc = NULL;
535 struct rtl8192_tx_ring *ring = NULL;
536 struct tx_desc *pdesc = NULL;
538 ring = &priv->tx_ring[BEACON_QUEUE];
539 pskb = __skb_dequeue(&ring->queue);
542 pnewskb = rtllib_get_beacon(priv->rtllib);
546 tcb_desc = (struct cb_desc *)(pnewskb->cb + 8);
547 tcb_desc->queue_index = BEACON_QUEUE;
548 tcb_desc->data_rate = 2;
549 tcb_desc->RATRIndex = 7;
550 tcb_desc->bTxDisableRateFallBack = 1;
551 tcb_desc->bTxUseDriverAssingedRate = 1;
552 skb_push(pnewskb, priv->rtllib->tx_headroom);
554 pdesc = &ring->desc[0];
555 priv->ops->tx_fill_descriptor(dev, pdesc, tcb_desc, pnewskb);
556 __skb_queue_tail(&ring->queue, pnewskb);
560 static void _rtl92e_stop_beacon(struct net_device *dev)
564 void rtl92e_config_rate(struct net_device *dev, u16 *rate_config)
566 struct r8192_priv *priv = rtllib_priv(dev);
567 struct rtllib_network *net;
568 u8 i = 0, basic_rate = 0;
570 net = &priv->rtllib->current_network;
572 for (i = 0; i < net->rates_len; i++) {
573 basic_rate = net->rates[i] & 0x7f;
574 switch (basic_rate) {
576 *rate_config |= RRSR_1M;
579 *rate_config |= RRSR_2M;
582 *rate_config |= RRSR_5_5M;
585 *rate_config |= RRSR_11M;
588 *rate_config |= RRSR_6M;
591 *rate_config |= RRSR_9M;
594 *rate_config |= RRSR_12M;
597 *rate_config |= RRSR_18M;
600 *rate_config |= RRSR_24M;
603 *rate_config |= RRSR_36M;
606 *rate_config |= RRSR_48M;
609 *rate_config |= RRSR_54M;
614 for (i = 0; i < net->rates_ex_len; i++) {
615 basic_rate = net->rates_ex[i] & 0x7f;
616 switch (basic_rate) {
618 *rate_config |= RRSR_1M;
621 *rate_config |= RRSR_2M;
624 *rate_config |= RRSR_5_5M;
627 *rate_config |= RRSR_11M;
630 *rate_config |= RRSR_6M;
633 *rate_config |= RRSR_9M;
636 *rate_config |= RRSR_12M;
639 *rate_config |= RRSR_18M;
642 *rate_config |= RRSR_24M;
645 *rate_config |= RRSR_36M;
648 *rate_config |= RRSR_48M;
651 *rate_config |= RRSR_54M;
657 static void _rtl92e_refresh_support_rate(struct r8192_priv *priv)
659 struct rtllib_device *ieee = priv->rtllib;
661 if (ieee->mode == WIRELESS_MODE_N_24G ||
662 ieee->mode == WIRELESS_MODE_N_5G) {
663 memcpy(ieee->Regdot11HTOperationalRateSet,
664 ieee->RegHTSuppRateSet, 16);
665 memcpy(ieee->Regdot11TxHTOperationalRateSet,
666 ieee->RegHTSuppRateSet, 16);
669 memset(ieee->Regdot11HTOperationalRateSet, 0, 16);
673 static u8 _rtl92e_get_supported_wireless_mode(struct net_device *dev)
675 struct r8192_priv *priv = rtllib_priv(dev);
678 switch (priv->rf_chip) {
683 ret = (WIRELESS_MODE_N_24G|WIRELESS_MODE_G | WIRELESS_MODE_B);
686 ret = (WIRELESS_MODE_A | WIRELESS_MODE_N_5G);
689 ret = WIRELESS_MODE_B;
695 void rtl92e_set_wireless_mode(struct net_device *dev, u8 wireless_mode)
697 struct r8192_priv *priv = rtllib_priv(dev);
698 u8 bSupportMode = _rtl92e_get_supported_wireless_mode(dev);
700 if ((wireless_mode == WIRELESS_MODE_AUTO) ||
701 ((wireless_mode & bSupportMode) == 0)) {
702 if (bSupportMode & WIRELESS_MODE_N_24G) {
703 wireless_mode = WIRELESS_MODE_N_24G;
704 } else if (bSupportMode & WIRELESS_MODE_N_5G) {
705 wireless_mode = WIRELESS_MODE_N_5G;
706 } else if ((bSupportMode & WIRELESS_MODE_A)) {
707 wireless_mode = WIRELESS_MODE_A;
708 } else if ((bSupportMode & WIRELESS_MODE_G)) {
709 wireless_mode = WIRELESS_MODE_G;
710 } else if ((bSupportMode & WIRELESS_MODE_B)) {
711 wireless_mode = WIRELESS_MODE_B;
714 "%s(): Unsupported mode requested. Fallback to 802.11b\n",
716 wireless_mode = WIRELESS_MODE_B;
720 if ((wireless_mode & (WIRELESS_MODE_B | WIRELESS_MODE_G)) ==
721 (WIRELESS_MODE_G | WIRELESS_MODE_B))
722 wireless_mode = WIRELESS_MODE_G;
724 priv->rtllib->mode = wireless_mode;
726 if ((wireless_mode == WIRELESS_MODE_N_24G) ||
727 (wireless_mode == WIRELESS_MODE_N_5G)) {
728 priv->rtllib->pHTInfo->bEnableHT = 1;
729 RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 1\n",
730 __func__, wireless_mode);
732 priv->rtllib->pHTInfo->bEnableHT = 0;
733 RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 0\n",
734 __func__, wireless_mode);
737 RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode);
738 _rtl92e_refresh_support_rate(priv);
741 static int _rtl92e_sta_up(struct net_device *dev, bool is_silent_reset)
743 struct r8192_priv *priv = rtllib_priv(dev);
744 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
745 (&(priv->rtllib->PowerSaveControl));
746 bool init_status = true;
748 priv->bDriverIsGoingToUnload = false;
749 priv->bdisable_nic = false;
752 priv->rtllib->ieee_up = 1;
754 priv->up_first_time = 0;
755 RT_TRACE(COMP_INIT, "Bringing up iface");
756 priv->bfirst_init = true;
757 init_status = priv->ops->initialize_adapter(dev);
759 netdev_err(dev, "%s(): Initialization failed!\n", __func__);
760 priv->bfirst_init = false;
764 RT_TRACE(COMP_INIT, "start adapter finished\n");
765 RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC);
766 priv->bfirst_init = false;
768 if (priv->polling_timer_on == 0)
769 rtl92e_check_rfctrl_gpio_timer((unsigned long)dev);
771 if (priv->rtllib->state != RTLLIB_LINKED)
772 rtllib_softmac_start_protocol(priv->rtllib, 0);
773 rtllib_reset_queue(priv->rtllib);
774 _rtl92e_watchdog_timer_cb((unsigned long)dev);
776 if (!netif_queue_stopped(dev))
777 netif_start_queue(dev);
779 netif_wake_queue(dev);
784 static int _rtl92e_sta_down(struct net_device *dev, bool shutdownrf)
786 struct r8192_priv *priv = rtllib_priv(dev);
787 unsigned long flags = 0;
788 u8 RFInProgressTimeOut = 0;
793 if (priv->rtllib->rtllib_ips_leave != NULL)
794 priv->rtllib->rtllib_ips_leave(dev);
796 if (priv->rtllib->state == RTLLIB_LINKED)
797 rtl92e_leisure_ps_leave(dev);
799 priv->bDriverIsGoingToUnload = true;
801 priv->rtllib->ieee_up = 0;
802 priv->bfirst_after_down = true;
803 RT_TRACE(COMP_DOWN, "==========>%s()\n", __func__);
804 if (!netif_queue_stopped(dev))
805 netif_stop_queue(dev);
807 priv->rtllib->wpa_ie_len = 0;
808 kfree(priv->rtllib->wpa_ie);
809 priv->rtllib->wpa_ie = NULL;
810 rtl92e_cam_reset(dev);
811 memset(priv->rtllib->swcamtable, 0, sizeof(struct sw_cam_table) * 32);
812 rtl92e_irq_disable(dev);
814 del_timer_sync(&priv->watch_dog_timer);
815 _rtl92e_cancel_deferred_work(priv);
816 cancel_delayed_work(&priv->rtllib->hw_wakeup_wq);
818 rtllib_softmac_stop_protocol(priv->rtllib, 0, true);
819 spin_lock_irqsave(&priv->rf_ps_lock, flags);
820 while (priv->RFChangeInProgress) {
821 spin_unlock_irqrestore(&priv->rf_ps_lock, flags);
822 if (RFInProgressTimeOut > 100) {
823 spin_lock_irqsave(&priv->rf_ps_lock, flags);
827 "===>%s():RF is in progress, need to wait until rf change is done.\n",
830 RFInProgressTimeOut++;
831 spin_lock_irqsave(&priv->rf_ps_lock, flags);
833 priv->RFChangeInProgress = true;
834 spin_unlock_irqrestore(&priv->rf_ps_lock, flags);
835 priv->ops->stop_adapter(dev, false);
836 spin_lock_irqsave(&priv->rf_ps_lock, flags);
837 priv->RFChangeInProgress = false;
838 spin_unlock_irqrestore(&priv->rf_ps_lock, flags);
840 memset(&priv->rtllib->current_network, 0,
841 offsetof(struct rtllib_network, list));
842 RT_TRACE(COMP_DOWN, "<==========%s()\n", __func__);
847 static void _rtl92e_init_priv_handler(struct net_device *dev)
849 struct r8192_priv *priv = rtllib_priv(dev);
851 priv->rtllib->softmac_hard_start_xmit = _rtl92e_hard_start_xmit;
852 priv->rtllib->set_chan = _rtl92e_set_chan;
853 priv->rtllib->link_change = priv->ops->link_change;
854 priv->rtllib->softmac_data_hard_start_xmit = _rtl92e_hard_data_xmit;
855 priv->rtllib->check_nic_enough_desc = _rtl92e_check_nic_enough_desc;
856 priv->rtllib->handle_assoc_response = _rtl92e_handle_assoc_response;
857 priv->rtllib->handle_beacon = _rtl92e_handle_beacon;
858 priv->rtllib->SetWirelessMode = rtl92e_set_wireless_mode;
859 priv->rtllib->LeisurePSLeave = rtl92e_leisure_ps_leave;
860 priv->rtllib->SetBWModeHandler = rtl92e_set_bw_mode;
861 priv->rf_set_chan = rtl92e_set_channel;
863 priv->rtllib->start_send_beacons = rtl92e_start_beacon;
864 priv->rtllib->stop_send_beacons = _rtl92e_stop_beacon;
866 priv->rtllib->sta_wake_up = rtl92e_hw_wakeup;
867 priv->rtllib->enter_sleep_state = rtl92e_enter_sleep;
868 priv->rtllib->ps_is_queue_empty = _rtl92e_is_tx_queue_empty;
870 priv->rtllib->GetNmodeSupportBySecCfg = rtl92e_get_nmode_support_by_sec;
871 priv->rtllib->GetHalfNmodeSupportByAPsHandler =
872 rtl92e_is_halfn_supported_by_ap;
874 priv->rtllib->SetHwRegHandler = rtl92e_set_reg;
875 priv->rtllib->AllowAllDestAddrHandler = rtl92e_set_monitor_mode;
876 priv->rtllib->SetFwCmdHandler = NULL;
877 priv->rtllib->InitialGainHandler = rtl92e_init_gain;
878 priv->rtllib->rtllib_ips_leave_wq = rtl92e_rtllib_ips_leave_wq;
879 priv->rtllib->rtllib_ips_leave = rtl92e_rtllib_ips_leave;
881 priv->rtllib->LedControlHandler = NULL;
882 priv->rtllib->UpdateBeaconInterruptHandler = NULL;
884 priv->rtllib->ScanOperationBackupHandler = rtl92e_scan_op_backup;
887 static void _rtl92e_init_priv_constant(struct net_device *dev)
889 struct r8192_priv *priv = rtllib_priv(dev);
890 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
891 &(priv->rtllib->PowerSaveControl);
893 pPSC->RegMaxLPSAwakeIntvl = 5;
897 static void _rtl92e_init_priv_variable(struct net_device *dev)
899 struct r8192_priv *priv = rtllib_priv(dev);
902 priv->AcmMethod = eAcmWay2_SW;
903 priv->dot11CurrentPreambleMode = PREAMBLE_AUTO;
904 priv->rtllib->status = 0;
905 priv->polling_timer_on = 0;
906 priv->up_first_time = 1;
907 priv->blinked_ingpio = false;
908 priv->bDriverIsGoingToUnload = false;
909 priv->being_init_adapter = false;
910 priv->initialized_at_probe = false;
911 priv->bdisable_nic = false;
912 priv->bfirst_init = false;
913 priv->txringcount = 64;
914 priv->rxbuffersize = 9100;
915 priv->rxringcount = MAX_RX_COUNT;
916 priv->irq_enabled = 0;
918 priv->RegChannelPlan = 0xf;
919 priv->rtllib->mode = WIRELESS_MODE_AUTO;
920 priv->rtllib->iw_mode = IW_MODE_INFRA;
921 priv->rtllib->bNetPromiscuousMode = false;
922 priv->rtllib->IntelPromiscuousModeInfo.bPromiscuousOn = false;
923 priv->rtllib->IntelPromiscuousModeInfo.bFilterSourceStationFrame =
925 priv->rtllib->ieee_up = 0;
926 priv->retry_rts = DEFAULT_RETRY_RTS;
927 priv->retry_data = DEFAULT_RETRY_DATA;
928 priv->rtllib->rts = DEFAULT_RTS_THRESHOLD;
929 priv->rtllib->rate = 110;
930 priv->rtllib->short_slot = 1;
931 priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0;
932 priv->bcck_in_ch14 = false;
933 priv->bfsync_processing = false;
934 priv->CCKPresentAttentuation = 0;
935 priv->rfa_txpowertrackingindex = 0;
936 priv->rfc_txpowertrackingindex = 0;
938 priv->ScanDelay = 50;
939 priv->ResetProgress = RESET_TYPE_NORESET;
940 priv->bForcedSilentReset = false;
941 priv->bDisableNormalResetCheck = false;
942 priv->force_reset = false;
943 memset(priv->rtllib->swcamtable, 0, sizeof(struct sw_cam_table) * 32);
945 memset(&priv->InterruptLog, 0, sizeof(struct log_int_8190));
947 priv->rtllib->wx_set_enc = 0;
948 priv->bHwRadioOff = false;
949 priv->RegRfOff = false;
950 priv->isRFOff = false;
951 priv->bInPowerSaveMode = false;
952 priv->rtllib->RfOffReason = 0;
953 priv->RFChangeInProgress = false;
954 priv->bHwRfOffAction = 0;
955 priv->SetRFPowerStateInProgress = false;
956 priv->rtllib->PowerSaveControl.bInactivePs = true;
957 priv->rtllib->PowerSaveControl.bIPSModeBackup = false;
958 priv->rtllib->PowerSaveControl.bLeisurePs = true;
959 priv->rtllib->PowerSaveControl.bFwCtrlLPS = false;
960 priv->rtllib->LPSDelayCnt = 0;
961 priv->rtllib->sta_sleep = LPS_IS_WAKE;
962 priv->rtllib->eRFPowerState = eRfOn;
964 priv->rtllib->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
965 priv->rtllib->iw_mode = IW_MODE_INFRA;
966 priv->rtllib->active_scan = 1;
967 priv->rtllib->be_scan_inprogress = false;
968 priv->rtllib->modulation = RTLLIB_CCK_MODULATION |
969 RTLLIB_OFDM_MODULATION;
970 priv->rtllib->host_encrypt = 1;
971 priv->rtllib->host_decrypt = 1;
973 priv->rtllib->fts = DEFAULT_FRAG_THRESHOLD;
975 priv->card_type = PCI;
977 priv->pFirmware = vzalloc(sizeof(struct rt_firmware));
978 if (!priv->pFirmware)
980 "rtl8192e: Unable to allocate space for firmware\n");
982 skb_queue_head_init(&priv->skb_queue);
984 for (i = 0; i < MAX_QUEUE_SIZE; i++)
985 skb_queue_head_init(&priv->rtllib->skb_waitQ[i]);
986 for (i = 0; i < MAX_QUEUE_SIZE; i++)
987 skb_queue_head_init(&priv->rtllib->skb_aggQ[i]);
990 static void _rtl92e_init_priv_lock(struct r8192_priv *priv)
992 spin_lock_init(&priv->tx_lock);
993 spin_lock_init(&priv->irq_th_lock);
994 spin_lock_init(&priv->rf_ps_lock);
995 spin_lock_init(&priv->ps_lock);
996 sema_init(&priv->wx_sem, 1);
997 sema_init(&priv->rf_sem, 1);
998 mutex_init(&priv->mutex);
1001 static void _rtl92e_init_priv_task(struct net_device *dev)
1003 struct r8192_priv *priv = rtllib_priv(dev);
1005 priv->priv_wq = create_workqueue(DRV_NAME);
1006 INIT_WORK_RSL(&priv->reset_wq, (void *)_rtl92e_restart, dev);
1007 INIT_WORK_RSL(&priv->rtllib->ips_leave_wq, (void *)rtl92e_ips_leave_wq,
1009 INIT_DELAYED_WORK_RSL(&priv->watch_dog_wq,
1010 (void *)_rtl92e_watchdog_wq_cb, dev);
1011 INIT_DELAYED_WORK_RSL(&priv->txpower_tracking_wq,
1012 (void *)rtl92e_dm_txpower_tracking_wq, dev);
1013 INIT_DELAYED_WORK_RSL(&priv->rfpath_check_wq,
1014 (void *)rtl92e_dm_rf_pathcheck_wq, dev);
1015 INIT_DELAYED_WORK_RSL(&priv->update_beacon_wq,
1016 (void *)_rtl92e_update_beacon, dev);
1017 INIT_WORK_RSL(&priv->qos_activate, (void *)_rtl92e_qos_activate, dev);
1018 INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_wakeup_wq,
1019 (void *) rtl92e_hw_wakeup_wq, dev);
1020 INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_sleep_wq,
1021 (void *) rtl92e_hw_sleep_wq, dev);
1022 tasklet_init(&priv->irq_rx_tasklet,
1023 (void(*)(unsigned long))_rtl92e_irq_rx_tasklet,
1024 (unsigned long)priv);
1025 tasklet_init(&priv->irq_tx_tasklet,
1026 (void(*)(unsigned long))_rtl92e_irq_tx_tasklet,
1027 (unsigned long)priv);
1028 tasklet_init(&priv->irq_prepare_beacon_tasklet,
1029 (void(*)(unsigned long))_rtl92e_prepare_beacon,
1030 (unsigned long)priv);
1033 static short _rtl92e_get_channel_map(struct net_device *dev)
1037 struct r8192_priv *priv = rtllib_priv(dev);
1039 if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256)
1040 && (priv->rf_chip != RF_6052)) {
1041 netdev_err(dev, "%s: unknown rf chip, can't set channel map\n",
1046 if (priv->ChannelPlan >= COUNTRY_CODE_MAX) {
1048 "rtl819x_init:Error channel plan! Set to default.\n");
1049 priv->ChannelPlan = COUNTRY_CODE_FCC;
1051 RT_TRACE(COMP_INIT, "Channel plan is %d\n", priv->ChannelPlan);
1052 dot11d_init(priv->rtllib);
1053 Dot11d_Channelmap(priv->ChannelPlan, priv->rtllib);
1054 for (i = 1; i <= 11; i++)
1055 (priv->rtllib->active_channel_map)[i] = 1;
1056 (priv->rtllib->active_channel_map)[12] = 2;
1057 (priv->rtllib->active_channel_map)[13] = 2;
1062 static short _rtl92e_init(struct net_device *dev)
1064 struct r8192_priv *priv = rtllib_priv(dev);
1066 memset(&(priv->stats), 0, sizeof(struct rt_stats));
1068 _rtl92e_init_priv_handler(dev);
1069 _rtl92e_init_priv_constant(dev);
1070 _rtl92e_init_priv_variable(dev);
1071 _rtl92e_init_priv_lock(priv);
1072 _rtl92e_init_priv_task(dev);
1073 priv->ops->get_eeprom_size(dev);
1074 priv->ops->init_adapter_variable(dev);
1075 _rtl92e_get_channel_map(dev);
1077 rtl92e_dm_init(dev);
1079 setup_timer(&priv->watch_dog_timer,
1080 _rtl92e_watchdog_timer_cb,
1081 (unsigned long) dev);
1083 setup_timer(&priv->gpio_polling_timer,
1084 rtl92e_check_rfctrl_gpio_timer,
1085 (unsigned long)dev);
1087 rtl92e_irq_disable(dev);
1088 if (request_irq(dev->irq, _rtl92e_irq, IRQF_SHARED, dev->name, dev)) {
1089 netdev_err(dev, "Error allocating IRQ %d", dev->irq);
1093 priv->irq = dev->irq;
1094 RT_TRACE(COMP_INIT, "IRQ %d\n", dev->irq);
1096 if (_rtl92e_pci_initdescring(dev) != 0) {
1097 netdev_err(dev, "Endopoints initialization failed");
1098 free_irq(dev->irq, dev);
1105 /***************************************************************************
1106 -------------------------------WATCHDOG STUFF---------------------------
1107 ***************************************************************************/
1108 static short _rtl92e_is_tx_queue_empty(struct net_device *dev)
1111 struct r8192_priv *priv = rtllib_priv(dev);
1113 for (i = 0; i <= MGNT_QUEUE; i++) {
1114 if ((i == TXCMD_QUEUE) || (i == HCCA_QUEUE))
1116 if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0) {
1117 netdev_info(dev, "===>tx queue is not empty:%d, %d\n",
1118 i, skb_queue_len(&(&priv->tx_ring[i])->queue));
1125 static enum reset_type _rtl92e_tx_check_stuck(struct net_device *dev)
1127 struct r8192_priv *priv = rtllib_priv(dev);
1129 bool bCheckFwTxCnt = false;
1130 struct rtl8192_tx_ring *ring = NULL;
1131 struct sk_buff *skb = NULL;
1132 struct cb_desc *tcb_desc = NULL;
1133 unsigned long flags = 0;
1135 switch (priv->rtllib->ps) {
1136 case RTLLIB_PS_DISABLED:
1138 case (RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST):
1143 spin_lock_irqsave(&priv->irq_th_lock, flags);
1144 for (QueueID = 0; QueueID < MAX_TX_QUEUE; QueueID++) {
1145 if (QueueID == TXCMD_QUEUE)
1148 if (QueueID == BEACON_QUEUE)
1151 ring = &priv->tx_ring[QueueID];
1153 if (skb_queue_len(&ring->queue) == 0) {
1156 skb = (&ring->queue)->next;
1157 tcb_desc = (struct cb_desc *)(skb->cb +
1159 tcb_desc->nStuckCount++;
1160 bCheckFwTxCnt = true;
1161 if (tcb_desc->nStuckCount > 1)
1163 "%s: QueueID=%d tcb_desc->nStuckCount=%d\n",
1165 tcb_desc->nStuckCount);
1168 spin_unlock_irqrestore(&priv->irq_th_lock, flags);
1170 if (bCheckFwTxCnt) {
1171 if (priv->ops->TxCheckStuckHandler(dev)) {
1172 RT_TRACE(COMP_RESET,
1173 "TxCheckStuck(): Fw indicates no Tx condition!\n");
1174 return RESET_TYPE_SILENT;
1178 return RESET_TYPE_NORESET;
1181 static enum reset_type _rtl92e_rx_check_stuck(struct net_device *dev)
1183 struct r8192_priv *priv = rtllib_priv(dev);
1185 if (priv->ops->RxCheckStuckHandler(dev)) {
1186 RT_TRACE(COMP_RESET, "RxStuck Condition\n");
1187 return RESET_TYPE_SILENT;
1190 return RESET_TYPE_NORESET;
1193 static enum reset_type _rtl92e_if_check_reset(struct net_device *dev)
1195 struct r8192_priv *priv = rtllib_priv(dev);
1196 enum reset_type TxResetType = RESET_TYPE_NORESET;
1197 enum reset_type RxResetType = RESET_TYPE_NORESET;
1198 enum rt_rf_power_state rfState;
1200 rfState = priv->rtllib->eRFPowerState;
1202 if (rfState == eRfOn)
1203 TxResetType = _rtl92e_tx_check_stuck(dev);
1205 if (rfState == eRfOn &&
1206 (priv->rtllib->iw_mode == IW_MODE_INFRA) &&
1207 (priv->rtllib->state == RTLLIB_LINKED))
1208 RxResetType = _rtl92e_rx_check_stuck(dev);
1210 if (TxResetType == RESET_TYPE_NORMAL ||
1211 RxResetType == RESET_TYPE_NORMAL) {
1212 netdev_info(dev, "%s(): TxResetType is %d, RxResetType is %d\n",
1213 __func__, TxResetType, RxResetType);
1214 return RESET_TYPE_NORMAL;
1215 } else if (TxResetType == RESET_TYPE_SILENT ||
1216 RxResetType == RESET_TYPE_SILENT) {
1217 netdev_info(dev, "%s(): TxResetType is %d, RxResetType is %d\n",
1218 __func__, TxResetType, RxResetType);
1219 return RESET_TYPE_SILENT;
1221 return RESET_TYPE_NORESET;
1226 static void _rtl92e_if_silent_reset(struct net_device *dev)
1228 struct r8192_priv *priv = rtllib_priv(dev);
1230 int reset_status = 0;
1231 struct rtllib_device *ieee = priv->rtllib;
1234 if (priv->ResetProgress == RESET_TYPE_NORESET) {
1236 RT_TRACE(COMP_RESET, "=========>Reset progress!!\n");
1238 priv->ResetProgress = RESET_TYPE_SILENT;
1240 spin_lock_irqsave(&priv->rf_ps_lock, flag);
1241 if (priv->RFChangeInProgress) {
1242 spin_unlock_irqrestore(&priv->rf_ps_lock, flag);
1245 priv->RFChangeInProgress = true;
1246 priv->bResetInProgress = true;
1247 spin_unlock_irqrestore(&priv->rf_ps_lock, flag);
1251 down(&priv->wx_sem);
1253 if (priv->rtllib->state == RTLLIB_LINKED)
1254 rtl92e_leisure_ps_leave(dev);
1257 netdev_info(dev, "%s():the driver is not up.\n",
1264 RT_TRACE(COMP_RESET, "%s():======>start to down the driver\n",
1267 RT_TRACE(COMP_RESET,
1268 "%s():111111111111111111111111======>start to down the driver\n",
1271 if (!netif_queue_stopped(dev))
1272 netif_stop_queue(dev);
1274 rtl92e_irq_disable(dev);
1275 del_timer_sync(&priv->watch_dog_timer);
1276 _rtl92e_cancel_deferred_work(priv);
1277 rtl92e_dm_deinit(dev);
1278 rtllib_stop_scan_syncro(ieee);
1280 if (ieee->state == RTLLIB_LINKED) {
1281 SEM_DOWN_IEEE_WX(&ieee->wx_sem);
1282 netdev_info(dev, "ieee->state is RTLLIB_LINKED\n");
1283 rtllib_stop_send_beacons(priv->rtllib);
1284 del_timer_sync(&ieee->associate_timer);
1285 cancel_delayed_work(&ieee->associate_retry_wq);
1286 rtllib_stop_scan(ieee);
1287 netif_carrier_off(dev);
1288 SEM_UP_IEEE_WX(&ieee->wx_sem);
1290 netdev_info(dev, "ieee->state is NOT LINKED\n");
1291 rtllib_softmac_stop_protocol(priv->rtllib, 0, true);
1294 rtl92e_dm_backup_state(dev);
1297 RT_TRACE(COMP_RESET,
1298 "%s():<==========down process is finished\n",
1301 RT_TRACE(COMP_RESET, "%s():<===========up process start\n",
1303 reset_status = _rtl92e_up(dev, true);
1305 RT_TRACE(COMP_RESET,
1306 "%s():<===========up process is finished\n", __func__);
1307 if (reset_status == -1) {
1308 if (reset_times < 3) {
1312 netdev_warn(dev, "%s(): Reset Failed\n",
1317 ieee->is_silent_reset = 1;
1319 spin_lock_irqsave(&priv->rf_ps_lock, flag);
1320 priv->RFChangeInProgress = false;
1321 spin_unlock_irqrestore(&priv->rf_ps_lock, flag);
1323 rtl92e_enable_hw_security_config(dev);
1325 if (ieee->state == RTLLIB_LINKED && ieee->iw_mode ==
1327 ieee->set_chan(ieee->dev,
1328 ieee->current_network.channel);
1330 queue_work_rsl(ieee->wq, &ieee->associate_complete_wq);
1332 } else if (ieee->state == RTLLIB_LINKED && ieee->iw_mode ==
1334 ieee->set_chan(ieee->dev,
1335 ieee->current_network.channel);
1336 ieee->link_change(ieee->dev);
1338 notify_wx_assoc_event(ieee);
1340 rtllib_start_send_beacons(ieee);
1342 netif_carrier_on(ieee->dev);
1345 rtl92e_cam_restore(dev);
1346 rtl92e_dm_restore_state(dev);
1348 priv->ResetProgress = RESET_TYPE_NORESET;
1349 priv->reset_count++;
1351 priv->bForcedSilentReset = false;
1352 priv->bResetInProgress = false;
1354 rtl92e_writeb(dev, UFWP, 1);
1355 RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n",
1360 static void _rtl92e_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum,
1361 u32 *TotalRxDataNum)
1367 *TotalRxDataNum = 0;
1369 SlotIndex = (priv->rtllib->LinkDetectInfo.SlotIndex++) %
1370 (priv->rtllib->LinkDetectInfo.SlotNum);
1371 priv->rtllib->LinkDetectInfo.RxBcnNum[SlotIndex] =
1372 priv->rtllib->LinkDetectInfo.NumRecvBcnInPeriod;
1373 priv->rtllib->LinkDetectInfo.RxDataNum[SlotIndex] =
1374 priv->rtllib->LinkDetectInfo.NumRecvDataInPeriod;
1375 for (i = 0; i < priv->rtllib->LinkDetectInfo.SlotNum; i++) {
1376 *TotalRxBcnNum += priv->rtllib->LinkDetectInfo.RxBcnNum[i];
1377 *TotalRxDataNum += priv->rtllib->LinkDetectInfo.RxDataNum[i];
1381 static void _rtl92e_watchdog_wq_cb(void *data)
1383 struct r8192_priv *priv = container_of_dwork_rsl(data,
1384 struct r8192_priv, watch_dog_wq);
1385 struct net_device *dev = priv->rtllib->dev;
1386 struct rtllib_device *ieee = priv->rtllib;
1387 enum reset_type ResetType = RESET_TYPE_NORESET;
1388 static u8 check_reset_cnt;
1389 unsigned long flags;
1390 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
1391 (&(priv->rtllib->PowerSaveControl));
1392 bool bBusyTraffic = false;
1393 bool bHigherBusyTraffic = false;
1394 bool bHigherBusyRxTraffic = false;
1395 bool bEnterPS = false;
1397 if (!priv->up || priv->bHwRadioOff)
1400 if (priv->rtllib->state >= RTLLIB_LINKED) {
1401 if (priv->rtllib->CntAfterLink < 2)
1402 priv->rtllib->CntAfterLink++;
1404 priv->rtllib->CntAfterLink = 0;
1407 rtl92e_dm_watchdog(dev);
1409 if (rtllib_act_scanning(priv->rtllib, false) == false) {
1410 if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state ==
1412 (ieee->eRFPowerState == eRfOn) && !ieee->is_set_key &&
1413 (!ieee->proto_stoppping) && !ieee->wx_set_enc) {
1414 if ((ieee->PowerSaveControl.ReturnPoint ==
1415 IPS_CALLBACK_NONE) &&
1416 (!ieee->bNetPromiscuousMode)) {
1418 "====================>haha: rtl92e_ips_enter()\n");
1419 rtl92e_ips_enter(dev);
1423 if ((ieee->state == RTLLIB_LINKED) && (ieee->iw_mode ==
1424 IW_MODE_INFRA) && (!ieee->bNetPromiscuousMode)) {
1425 if (ieee->LinkDetectInfo.NumRxOkInPeriod > 100 ||
1426 ieee->LinkDetectInfo.NumTxOkInPeriod > 100)
1427 bBusyTraffic = true;
1430 if (ieee->LinkDetectInfo.NumRxOkInPeriod > 4000 ||
1431 ieee->LinkDetectInfo.NumTxOkInPeriod > 4000) {
1432 bHigherBusyTraffic = true;
1433 if (ieee->LinkDetectInfo.NumRxOkInPeriod > 5000)
1434 bHigherBusyRxTraffic = true;
1436 bHigherBusyRxTraffic = false;
1439 if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +
1440 ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
1441 (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2))
1446 if (ieee->current_network.beacon_interval < 95)
1450 rtl92e_leisure_ps_enter(dev);
1452 rtl92e_leisure_ps_leave(dev);
1455 RT_TRACE(COMP_LPS, "====>no link LPS leave\n");
1456 rtl92e_leisure_ps_leave(dev);
1459 ieee->LinkDetectInfo.NumRxOkInPeriod = 0;
1460 ieee->LinkDetectInfo.NumTxOkInPeriod = 0;
1461 ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0;
1462 ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic;
1464 ieee->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic;
1465 ieee->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic;
1467 if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) {
1468 u32 TotalRxBcnNum = 0;
1469 u32 TotalRxDataNum = 0;
1471 _rtl92e_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum);
1473 if ((TotalRxBcnNum+TotalRxDataNum) == 0)
1474 priv->check_roaming_cnt++;
1476 priv->check_roaming_cnt = 0;
1479 if (priv->check_roaming_cnt > 0) {
1480 if (ieee->eRFPowerState == eRfOff)
1481 netdev_info(dev, "%s(): RF is off\n", __func__);
1484 "===>%s(): AP is power off, chan:%d, connect another one\n",
1485 __func__, priv->chan);
1487 ieee->state = RTLLIB_ASSOCIATING;
1489 RemovePeerTS(priv->rtllib,
1490 priv->rtllib->current_network.bssid);
1491 ieee->is_roaming = true;
1492 ieee->is_set_key = false;
1493 ieee->link_change(dev);
1494 if (ieee->LedControlHandler)
1495 ieee->LedControlHandler(ieee->dev,
1496 LED_CTL_START_TO_LINK);
1498 notify_wx_assoc_event(ieee);
1500 if (!(ieee->rtllib_ap_sec_type(ieee) &
1501 (SEC_ALG_CCMP|SEC_ALG_TKIP)))
1502 queue_delayed_work_rsl(ieee->wq,
1503 &ieee->associate_procedure_wq, 0);
1505 priv->check_roaming_cnt = 0;
1507 ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0;
1508 ieee->LinkDetectInfo.NumRecvDataInPeriod = 0;
1512 spin_lock_irqsave(&priv->tx_lock, flags);
1513 if ((check_reset_cnt++ >= 3) && (!ieee->is_roaming) &&
1514 (!priv->RFChangeInProgress) && (!pPSC->bSwRfProcessing)) {
1515 ResetType = _rtl92e_if_check_reset(dev);
1516 check_reset_cnt = 3;
1518 spin_unlock_irqrestore(&priv->tx_lock, flags);
1520 if (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) {
1521 priv->ResetProgress = RESET_TYPE_NORMAL;
1522 RT_TRACE(COMP_RESET, "%s(): NOMAL RESET\n", __func__);
1526 if (((priv->force_reset) || (!priv->bDisableNormalResetCheck &&
1527 ResetType == RESET_TYPE_SILENT)))
1528 _rtl92e_if_silent_reset(dev);
1529 priv->force_reset = false;
1530 priv->bForcedSilentReset = false;
1531 priv->bResetInProgress = false;
1532 RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n");
1535 static void _rtl92e_watchdog_timer_cb(unsigned long data)
1537 struct r8192_priv *priv = rtllib_priv((struct net_device *)data);
1539 queue_delayed_work_rsl(priv->priv_wq, &priv->watch_dog_wq, 0);
1540 mod_timer(&priv->watch_dog_timer, jiffies +
1541 msecs_to_jiffies(RTLLIB_WATCH_DOG_TIME));
1544 /****************************************************************************
1545 ---------------------------- NIC TX/RX STUFF---------------------------
1546 *****************************************************************************/
1547 void rtl92e_rx_enable(struct net_device *dev)
1549 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
1551 priv->ops->rx_enable(dev);
1554 void rtl92e_tx_enable(struct net_device *dev)
1556 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
1558 priv->ops->tx_enable(dev);
1560 rtllib_reset_queue(priv->rtllib);
1564 static void _rtl92e_free_rx_ring(struct net_device *dev)
1566 struct r8192_priv *priv = rtllib_priv(dev);
1567 int i, rx_queue_idx;
1569 for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE;
1571 for (i = 0; i < priv->rxringcount; i++) {
1572 struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i];
1577 pci_unmap_single(priv->pdev,
1578 *((dma_addr_t *)skb->cb),
1579 priv->rxbuffersize, PCI_DMA_FROMDEVICE);
1583 pci_free_consistent(priv->pdev,
1584 sizeof(*priv->rx_ring[rx_queue_idx]) *
1586 priv->rx_ring[rx_queue_idx],
1587 priv->rx_ring_dma[rx_queue_idx]);
1588 priv->rx_ring[rx_queue_idx] = NULL;
1592 static void _rtl92e_free_tx_ring(struct net_device *dev, unsigned int prio)
1594 struct r8192_priv *priv = rtllib_priv(dev);
1595 struct rtl8192_tx_ring *ring = &priv->tx_ring[prio];
1597 while (skb_queue_len(&ring->queue)) {
1598 struct tx_desc *entry = &ring->desc[ring->idx];
1599 struct sk_buff *skb = __skb_dequeue(&ring->queue);
1601 pci_unmap_single(priv->pdev, entry->TxBuffAddr,
1602 skb->len, PCI_DMA_TODEVICE);
1604 ring->idx = (ring->idx + 1) % ring->entries;
1607 pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries,
1608 ring->desc, ring->dma);
1612 static void _rtl92e_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
1615 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
1617 struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb +
1619 u8 queue_index = tcb_desc->queue_index;
1621 if ((priv->rtllib->eRFPowerState == eRfOff) || !priv->up ||
1622 priv->bResetInProgress) {
1627 if (queue_index == TXCMD_QUEUE)
1628 netdev_warn(dev, "%s(): queue index == TXCMD_QUEUE\n",
1631 memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
1632 skb_push(skb, priv->rtllib->tx_headroom);
1633 ret = _rtl92e_tx(dev, skb);
1637 if (queue_index != MGNT_QUEUE) {
1638 priv->rtllib->stats.tx_bytes += (skb->len -
1639 priv->rtllib->tx_headroom);
1640 priv->rtllib->stats.tx_packets++;
1644 static int _rtl92e_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
1646 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
1648 struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb +
1650 u8 queue_index = tcb_desc->queue_index;
1652 if (queue_index != TXCMD_QUEUE) {
1653 if ((priv->rtllib->eRFPowerState == eRfOff) ||
1654 !priv->up || priv->bResetInProgress) {
1660 memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
1661 if (queue_index == TXCMD_QUEUE) {
1662 _rtl92e_tx_cmd(dev, skb);
1666 tcb_desc->RATRIndex = 7;
1667 tcb_desc->bTxDisableRateFallBack = 1;
1668 tcb_desc->bTxUseDriverAssingedRate = 1;
1669 tcb_desc->bTxEnableFwCalcDur = 1;
1670 skb_push(skb, priv->rtllib->tx_headroom);
1671 ret = _rtl92e_tx(dev, skb);
1677 static void _rtl92e_tx_isr(struct net_device *dev, int prio)
1679 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
1681 struct rtl8192_tx_ring *ring = &priv->tx_ring[prio];
1683 while (skb_queue_len(&ring->queue)) {
1684 struct tx_desc *entry = &ring->desc[ring->idx];
1685 struct sk_buff *skb;
1687 if (prio != BEACON_QUEUE) {
1690 ring->idx = (ring->idx + 1) % ring->entries;
1693 skb = __skb_dequeue(&ring->queue);
1694 pci_unmap_single(priv->pdev, entry->TxBuffAddr,
1695 skb->len, PCI_DMA_TODEVICE);
1699 if (prio != BEACON_QUEUE)
1700 tasklet_schedule(&priv->irq_tx_tasklet);
1703 static void _rtl92e_tx_cmd(struct net_device *dev, struct sk_buff *skb)
1705 struct r8192_priv *priv = rtllib_priv(dev);
1706 struct rtl8192_tx_ring *ring;
1707 struct tx_desc_cmd *entry;
1709 struct cb_desc *tcb_desc;
1710 unsigned long flags;
1712 spin_lock_irqsave(&priv->irq_th_lock, flags);
1713 ring = &priv->tx_ring[TXCMD_QUEUE];
1715 idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries;
1716 entry = (struct tx_desc_cmd *) &ring->desc[idx];
1718 tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
1720 priv->ops->tx_fill_cmd_descriptor(dev, entry, tcb_desc, skb);
1722 __skb_queue_tail(&ring->queue, skb);
1723 spin_unlock_irqrestore(&priv->irq_th_lock, flags);
1726 static short _rtl92e_tx(struct net_device *dev, struct sk_buff *skb)
1728 struct r8192_priv *priv = rtllib_priv(dev);
1729 struct rtl8192_tx_ring *ring;
1730 unsigned long flags;
1731 struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb +
1733 struct tx_desc *pdesc = NULL;
1734 struct rtllib_hdr_1addr *header = NULL;
1735 u16 fc = 0, type = 0, stype = 0;
1736 bool multi_addr = false, broad_addr = false, uni_addr = false;
1737 u8 *pda_addr = NULL;
1739 u32 fwinfo_size = 0;
1741 if (priv->bdisable_nic) {
1742 netdev_warn(dev, "%s: Nic is disabled! Can't tx packet.\n",
1747 priv->rtllib->bAwakePktSent = true;
1749 fwinfo_size = sizeof(struct tx_fwinfo_8190pci);
1751 header = (struct rtllib_hdr_1addr *)(((u8 *)skb->data) + fwinfo_size);
1752 fc = le16_to_cpu(header->frame_ctl);
1753 type = WLAN_FC_GET_TYPE(fc);
1754 stype = WLAN_FC_GET_STYPE(fc);
1755 pda_addr = header->addr1;
1757 if (is_broadcast_ether_addr(pda_addr))
1759 else if (is_multicast_ether_addr(pda_addr))
1765 priv->stats.txbytesunicast += skb->len - fwinfo_size;
1766 else if (multi_addr)
1767 priv->stats.txbytesmulticast += skb->len - fwinfo_size;
1769 priv->stats.txbytesbroadcast += skb->len - fwinfo_size;
1771 spin_lock_irqsave(&priv->irq_th_lock, flags);
1772 ring = &priv->tx_ring[tcb_desc->queue_index];
1773 if (tcb_desc->queue_index != BEACON_QUEUE)
1774 idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries;
1778 pdesc = &ring->desc[idx];
1779 if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) {
1781 "No more TX desc@%d, ring->idx = %d, idx = %d, skblen = 0x%x queuelen=%d",
1782 tcb_desc->queue_index, ring->idx, idx, skb->len,
1783 skb_queue_len(&ring->queue));
1784 spin_unlock_irqrestore(&priv->irq_th_lock, flags);
1788 if (type == RTLLIB_FTYPE_DATA) {
1789 if (priv->rtllib->LedControlHandler)
1790 priv->rtllib->LedControlHandler(dev, LED_CTL_TX);
1792 priv->ops->tx_fill_descriptor(dev, pdesc, tcb_desc, skb);
1793 __skb_queue_tail(&ring->queue, skb);
1795 spin_unlock_irqrestore(&priv->irq_th_lock, flags);
1796 dev->trans_start = jiffies;
1798 rtl92e_writew(dev, TPPoll, 0x01 << tcb_desc->queue_index);
1802 static short _rtl92e_alloc_rx_ring(struct net_device *dev)
1804 struct r8192_priv *priv = rtllib_priv(dev);
1805 struct rx_desc *entry = NULL;
1806 int i, rx_queue_idx;
1808 for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) {
1809 priv->rx_ring[rx_queue_idx] = pci_zalloc_consistent(priv->pdev,
1810 sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
1811 &priv->rx_ring_dma[rx_queue_idx]);
1812 if (!priv->rx_ring[rx_queue_idx] ||
1813 (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) {
1814 netdev_warn(dev, "Cannot allocate RX ring\n");
1818 priv->rx_idx[rx_queue_idx] = 0;
1820 for (i = 0; i < priv->rxringcount; i++) {
1821 struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize);
1822 dma_addr_t *mapping;
1824 entry = &priv->rx_ring[rx_queue_idx][i];
1828 priv->rx_buf[rx_queue_idx][i] = skb;
1829 mapping = (dma_addr_t *)skb->cb;
1830 *mapping = pci_map_single(priv->pdev,
1831 skb_tail_pointer_rsl(skb),
1833 PCI_DMA_FROMDEVICE);
1834 if (pci_dma_mapping_error(priv->pdev, *mapping)) {
1835 dev_kfree_skb_any(skb);
1838 entry->BufferAddress = *mapping;
1840 entry->Length = priv->rxbuffersize;
1850 static int _rtl92e_alloc_tx_ring(struct net_device *dev, unsigned int prio,
1851 unsigned int entries)
1853 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
1854 struct tx_desc *ring;
1858 ring = pci_zalloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma);
1859 if (!ring || (unsigned long)ring & 0xFF) {
1860 netdev_warn(dev, "Cannot allocate TX ring (prio = %d)\n", prio);
1864 priv->tx_ring[prio].desc = ring;
1865 priv->tx_ring[prio].dma = dma;
1866 priv->tx_ring[prio].idx = 0;
1867 priv->tx_ring[prio].entries = entries;
1868 skb_queue_head_init(&priv->tx_ring[prio].queue);
1870 for (i = 0; i < entries; i++)
1871 ring[i].NextDescAddress =
1872 (u32)dma + ((i + 1) % entries) *
1878 static short _rtl92e_pci_initdescring(struct net_device *dev)
1882 struct r8192_priv *priv = rtllib_priv(dev);
1884 ret = _rtl92e_alloc_rx_ring(dev);
1888 for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) {
1889 ret = _rtl92e_alloc_tx_ring(dev, i, priv->txringcount);
1891 goto err_free_rings;
1897 _rtl92e_free_rx_ring(dev);
1898 for (i = 0; i < MAX_TX_QUEUE_COUNT; i++)
1899 if (priv->tx_ring[i].desc)
1900 _rtl92e_free_tx_ring(dev, i);
1904 void rtl92e_reset_desc_ring(struct net_device *dev)
1906 struct r8192_priv *priv = rtllib_priv(dev);
1907 int i, rx_queue_idx;
1908 unsigned long flags = 0;
1910 for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) {
1911 if (priv->rx_ring[rx_queue_idx]) {
1912 struct rx_desc *entry = NULL;
1914 for (i = 0; i < priv->rxringcount; i++) {
1915 entry = &priv->rx_ring[rx_queue_idx][i];
1918 priv->rx_idx[rx_queue_idx] = 0;
1922 spin_lock_irqsave(&priv->irq_th_lock, flags);
1923 for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) {
1924 if (priv->tx_ring[i].desc) {
1925 struct rtl8192_tx_ring *ring = &priv->tx_ring[i];
1927 while (skb_queue_len(&ring->queue)) {
1928 struct tx_desc *entry = &ring->desc[ring->idx];
1929 struct sk_buff *skb =
1930 __skb_dequeue(&ring->queue);
1932 pci_unmap_single(priv->pdev,
1934 skb->len, PCI_DMA_TODEVICE);
1936 ring->idx = (ring->idx + 1) % ring->entries;
1941 spin_unlock_irqrestore(&priv->irq_th_lock, flags);
1944 void rtl92e_update_rx_pkt_timestamp(struct net_device *dev,
1945 struct rtllib_rx_stats *stats)
1947 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
1949 if (stats->bIsAMPDU && !stats->bFirstMPDU)
1950 stats->mac_time = priv->LastRxDescTSF;
1952 priv->LastRxDescTSF = stats->mac_time;
1955 long rtl92e_translate_to_dbm(struct r8192_priv *priv, u8 signal_strength_index)
1959 signal_power = (long)((signal_strength_index + 1) >> 1);
1962 return signal_power;
1966 void rtl92e_update_rx_statistics(struct r8192_priv *priv,
1967 struct rtllib_rx_stats *pprevious_stats)
1972 if (priv->stats.recv_signal_power == 0)
1973 priv->stats.recv_signal_power =
1974 pprevious_stats->RecvSignalPower;
1976 if (pprevious_stats->RecvSignalPower > priv->stats.recv_signal_power)
1978 else if (pprevious_stats->RecvSignalPower <
1979 priv->stats.recv_signal_power)
1981 priv->stats.recv_signal_power = (priv->stats.recv_signal_power * 5 +
1982 pprevious_stats->RecvSignalPower +
1986 u8 rtl92e_rx_db_to_percent(char antpower)
1988 if ((antpower <= -100) || (antpower >= 20))
1990 else if (antpower >= 0)
1993 return 100 + antpower;
1995 } /* QueryRxPwrPercentage */
1997 u8 rtl92e_evm_db_to_percent(char value)
2007 ret_val = 0 - ret_val;
2014 void rtl92e_copy_mpdu_stats(struct rtllib_rx_stats *psrc_stats,
2015 struct rtllib_rx_stats *ptarget_stats)
2017 ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU;
2018 ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU;
2023 static void _rtl92e_rx_normal(struct net_device *dev)
2025 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
2026 struct rtllib_hdr_1addr *rtllib_hdr = NULL;
2027 bool unicast_packet = false;
2028 bool bLedBlinking = true;
2029 u16 fc = 0, type = 0;
2031 int rx_queue_idx = RX_MPDU_QUEUE;
2033 struct rtllib_rx_stats stats = {
2037 .freq = RTLLIB_24GHZ_BAND,
2039 unsigned int count = priv->rxringcount;
2041 stats.nic_type = NIC_8192E;
2044 struct rx_desc *pdesc = &priv->rx_ring[rx_queue_idx]
2045 [priv->rx_idx[rx_queue_idx]];
2046 struct sk_buff *skb = priv->rx_buf[rx_queue_idx]
2047 [priv->rx_idx[rx_queue_idx]];
2048 struct sk_buff *new_skb;
2052 if (!priv->ops->rx_query_status_descriptor(dev, &stats,
2055 new_skb = dev_alloc_skb(priv->rxbuffersize);
2056 /* if allocation of new skb failed - drop current packet
2059 if (unlikely(!new_skb))
2062 pci_unmap_single(priv->pdev,
2063 *((dma_addr_t *)skb->cb),
2065 PCI_DMA_FROMDEVICE);
2067 skb_put(skb, pdesc->Length);
2068 skb_reserve(skb, stats.RxDrvInfoSize +
2070 skb_trim(skb, skb->len - 4/*sCrcLng*/);
2071 rtllib_hdr = (struct rtllib_hdr_1addr *)skb->data;
2072 if (!is_multicast_ether_addr(rtllib_hdr->addr1)) {
2073 /* unicast packet */
2074 unicast_packet = true;
2076 fc = le16_to_cpu(rtllib_hdr->frame_ctl);
2077 type = WLAN_FC_GET_TYPE(fc);
2078 if (type == RTLLIB_FTYPE_MGMT)
2079 bLedBlinking = false;
2082 if (priv->rtllib->LedControlHandler)
2083 priv->rtllib->LedControlHandler(dev,
2087 if (type != RTLLIB_FTYPE_MGMT)
2088 priv->stats.rxdatacrcerr++;
2090 priv->stats.rxmgmtcrcerr++;
2095 if (!rtllib_rx(priv->rtllib, skb, &stats)) {
2096 dev_kfree_skb_any(skb);
2100 priv->stats.rxbytesunicast += skb_len;
2106 priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] =
2108 *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev,
2109 skb_tail_pointer_rsl(skb),
2111 PCI_DMA_FROMDEVICE);
2112 if (pci_dma_mapping_error(priv->pdev,
2113 *((dma_addr_t *)skb->cb))) {
2114 dev_kfree_skb_any(skb);
2118 pdesc->BufferAddress = *((dma_addr_t *)skb->cb);
2120 pdesc->Length = priv->rxbuffersize;
2121 if (priv->rx_idx[rx_queue_idx] == priv->rxringcount-1)
2123 priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) %
2129 static void _rtl92e_tx_resume(struct net_device *dev)
2131 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
2132 struct rtllib_device *ieee = priv->rtllib;
2133 struct sk_buff *skb;
2136 for (queue_index = BK_QUEUE;
2137 queue_index < MAX_QUEUE_SIZE; queue_index++) {
2138 while ((!skb_queue_empty(&ieee->skb_waitQ[queue_index])) &&
2139 (priv->rtllib->check_nic_enough_desc(dev, queue_index) > 0)) {
2140 skb = skb_dequeue(&ieee->skb_waitQ[queue_index]);
2141 ieee->softmac_data_hard_start_xmit(skb, dev, 0);
2146 static void _rtl92e_irq_tx_tasklet(struct r8192_priv *priv)
2148 _rtl92e_tx_resume(priv->rtllib->dev);
2151 static void _rtl92e_irq_rx_tasklet(struct r8192_priv *priv)
2153 _rtl92e_rx_normal(priv->rtllib->dev);
2155 rtl92e_writel(priv->rtllib->dev, INTA_MASK,
2156 rtl92e_readl(priv->rtllib->dev, INTA_MASK) | IMR_RDU);
2159 /****************************************************************************
2160 ---------------------------- NIC START/CLOSE STUFF---------------------------
2161 *****************************************************************************/
2162 static void _rtl92e_cancel_deferred_work(struct r8192_priv *priv)
2164 cancel_delayed_work(&priv->watch_dog_wq);
2165 cancel_delayed_work(&priv->update_beacon_wq);
2166 cancel_delayed_work(&priv->rtllib->hw_sleep_wq);
2167 cancel_work_sync(&priv->reset_wq);
2168 cancel_work_sync(&priv->qos_activate);
2171 static int _rtl92e_up(struct net_device *dev, bool is_silent_reset)
2173 if (_rtl92e_sta_up(dev, is_silent_reset) == -1)
2178 static int _rtl92e_open(struct net_device *dev)
2180 struct r8192_priv *priv = rtllib_priv(dev);
2183 down(&priv->wx_sem);
2184 ret = _rtl92e_try_up(dev);
2190 static int _rtl92e_try_up(struct net_device *dev)
2192 struct r8192_priv *priv = rtllib_priv(dev);
2196 return _rtl92e_up(dev, false);
2200 static int _rtl92e_close(struct net_device *dev)
2202 struct r8192_priv *priv = rtllib_priv(dev);
2205 if ((rtllib_act_scanning(priv->rtllib, false)) &&
2206 !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) {
2207 rtllib_stop_scan(priv->rtllib);
2210 down(&priv->wx_sem);
2212 ret = _rtl92e_down(dev, true);
2220 static int _rtl92e_down(struct net_device *dev, bool shutdownrf)
2222 if (_rtl92e_sta_down(dev, shutdownrf) == -1)
2228 void rtl92e_commit(struct net_device *dev)
2230 struct r8192_priv *priv = rtllib_priv(dev);
2234 rtllib_softmac_stop_protocol(priv->rtllib, 0, true);
2235 rtl92e_irq_disable(dev);
2236 priv->ops->stop_adapter(dev, true);
2237 _rtl92e_up(dev, false);
2240 static void _rtl92e_restart(void *data)
2242 struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv,
2244 struct net_device *dev = priv->rtllib->dev;
2246 down(&priv->wx_sem);
2253 static void _rtl92e_set_multicast(struct net_device *dev)
2255 struct r8192_priv *priv = rtllib_priv(dev);
2258 promisc = (dev->flags & IFF_PROMISC) ? 1 : 0;
2259 priv->promisc = promisc;
2264 static int _rtl92e_set_mac_adr(struct net_device *dev, void *mac)
2266 struct r8192_priv *priv = rtllib_priv(dev);
2267 struct sockaddr *addr = mac;
2269 down(&priv->wx_sem);
2271 ether_addr_copy(dev->dev_addr, addr->sa_data);
2273 schedule_work(&priv->reset_wq);
2279 /* based on ipw2200 driver */
2280 static int _rtl92e_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2282 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
2283 struct iwreq *wrq = (struct iwreq *)rq;
2285 struct rtllib_device *ieee = priv->rtllib;
2287 const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2288 struct iw_point *p = &wrq->u.data;
2289 struct ieee_param *ipw = NULL;
2291 down(&priv->wx_sem);
2294 case RTL_IOCTL_WPA_SUPPLICANT:
2295 if (p->length < sizeof(struct ieee_param) || !p->pointer) {
2300 ipw = memdup_user(p->pointer, p->length);
2306 if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) {
2307 if (ipw->u.crypt.set_tx) {
2308 if (strcmp(ipw->u.crypt.alg, "CCMP") == 0)
2309 ieee->pairwise_key_type = KEY_TYPE_CCMP;
2310 else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0)
2311 ieee->pairwise_key_type = KEY_TYPE_TKIP;
2312 else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
2313 if (ipw->u.crypt.key_len == 13)
2314 ieee->pairwise_key_type =
2316 else if (ipw->u.crypt.key_len == 5)
2317 ieee->pairwise_key_type =
2320 ieee->pairwise_key_type = KEY_TYPE_NA;
2323 if (ieee->pairwise_key_type) {
2324 if (is_zero_ether_addr(ieee->ap_mac_addr))
2325 ieee->iw_mode = IW_MODE_ADHOC;
2326 memcpy((u8 *)key, ipw->u.crypt.key, 16);
2327 rtl92e_enable_hw_security_config(dev);
2328 rtl92e_set_swcam(dev, 4,
2330 ieee->pairwise_key_type,
2331 (u8 *)ieee->ap_mac_addr,
2333 rtl92e_set_key(dev, 4, ipw->u.crypt.idx,
2334 ieee->pairwise_key_type,
2335 (u8 *)ieee->ap_mac_addr,
2337 if (ieee->iw_mode == IW_MODE_ADHOC) {
2338 rtl92e_set_swcam(dev,
2341 ieee->pairwise_key_type,
2342 (u8 *)ieee->ap_mac_addr,
2347 ieee->pairwise_key_type,
2348 (u8 *)ieee->ap_mac_addr,
2352 if ((ieee->pairwise_key_type == KEY_TYPE_CCMP)
2353 && ieee->pHTInfo->bCurrentHTSupport) {
2354 rtl92e_writeb(dev, 0x173, 1);
2358 memcpy((u8 *)key, ipw->u.crypt.key, 16);
2359 if (strcmp(ipw->u.crypt.alg, "CCMP") == 0)
2360 ieee->group_key_type = KEY_TYPE_CCMP;
2361 else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0)
2362 ieee->group_key_type = KEY_TYPE_TKIP;
2363 else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) {
2364 if (ipw->u.crypt.key_len == 13)
2365 ieee->group_key_type =
2367 else if (ipw->u.crypt.key_len == 5)
2368 ieee->group_key_type =
2371 ieee->group_key_type = KEY_TYPE_NA;
2373 if (ieee->group_key_type) {
2374 rtl92e_set_swcam(dev, ipw->u.crypt.idx,
2376 ieee->group_key_type,
2377 broadcast_addr, 0, key,
2379 rtl92e_set_key(dev, ipw->u.crypt.idx,
2381 ieee->group_key_type,
2382 broadcast_addr, 0, key);
2387 ret = rtllib_wpa_supplicant_ioctl(priv->rtllib, &wrq->u.data,
2403 static irqreturn_t _rtl92e_irq(int irq, void *netdev)
2405 struct net_device *dev = (struct net_device *) netdev;
2406 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
2407 unsigned long flags;
2413 if (priv->irq_enabled == 0)
2416 spin_lock_irqsave(&priv->irq_th_lock, flags);
2418 priv->ops->interrupt_recognized(dev, &inta, &intb);
2419 priv->stats.shints++;
2422 spin_unlock_irqrestore(&priv->irq_th_lock, flags);
2426 if (inta == 0xffff) {
2427 spin_unlock_irqrestore(&priv->irq_th_lock, flags);
2433 if (!netif_running(dev)) {
2434 spin_unlock_irqrestore(&priv->irq_th_lock, flags);
2438 if (inta & IMR_TBDOK) {
2439 RT_TRACE(COMP_INTR, "beacon ok interrupt!\n");
2440 priv->stats.txbeaconokint++;
2443 if (inta & IMR_TBDER) {
2444 RT_TRACE(COMP_INTR, "beacon ok interrupt!\n");
2445 priv->stats.txbeaconerr++;
2448 if (inta & IMR_BDOK)
2449 RT_TRACE(COMP_INTR, "beacon interrupt!\n");
2451 if (inta & IMR_MGNTDOK) {
2452 RT_TRACE(COMP_INTR, "Manage ok interrupt!\n");
2453 priv->stats.txmanageokint++;
2454 _rtl92e_tx_isr(dev, MGNT_QUEUE);
2455 spin_unlock_irqrestore(&priv->irq_th_lock, flags);
2456 if (priv->rtllib->ack_tx_to_ieee) {
2457 if (_rtl92e_is_tx_queue_empty(dev)) {
2458 priv->rtllib->ack_tx_to_ieee = 0;
2459 rtllib_ps_tx_ack(priv->rtllib, 1);
2462 spin_lock_irqsave(&priv->irq_th_lock, flags);
2465 if (inta & IMR_COMDOK) {
2466 priv->stats.txcmdpktokint++;
2467 _rtl92e_tx_isr(dev, TXCMD_QUEUE);
2470 if (inta & IMR_HIGHDOK)
2471 _rtl92e_tx_isr(dev, HIGH_QUEUE);
2473 if (inta & IMR_ROK) {
2474 priv->stats.rxint++;
2475 priv->InterruptLog.nIMR_ROK++;
2476 tasklet_schedule(&priv->irq_rx_tasklet);
2479 if (inta & IMR_BcnInt) {
2480 RT_TRACE(COMP_INTR, "prepare beacon for interrupt!\n");
2481 tasklet_schedule(&priv->irq_prepare_beacon_tasklet);
2484 if (inta & IMR_RDU) {
2485 RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n");
2486 priv->stats.rxrdu++;
2487 rtl92e_writel(dev, INTA_MASK,
2488 rtl92e_readl(dev, INTA_MASK) & ~IMR_RDU);
2489 tasklet_schedule(&priv->irq_rx_tasklet);
2492 if (inta & IMR_RXFOVW) {
2493 RT_TRACE(COMP_INTR, "rx overflow !\n");
2494 priv->stats.rxoverflow++;
2495 tasklet_schedule(&priv->irq_rx_tasklet);
2498 if (inta & IMR_TXFOVW)
2499 priv->stats.txoverflow++;
2501 if (inta & IMR_BKDOK) {
2502 RT_TRACE(COMP_INTR, "BK Tx OK interrupt!\n");
2503 priv->stats.txbkokint++;
2504 priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++;
2505 _rtl92e_tx_isr(dev, BK_QUEUE);
2508 if (inta & IMR_BEDOK) {
2509 RT_TRACE(COMP_INTR, "BE TX OK interrupt!\n");
2510 priv->stats.txbeokint++;
2511 priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++;
2512 _rtl92e_tx_isr(dev, BE_QUEUE);
2515 if (inta & IMR_VIDOK) {
2516 RT_TRACE(COMP_INTR, "VI TX OK interrupt!\n");
2517 priv->stats.txviokint++;
2518 priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++;
2519 _rtl92e_tx_isr(dev, VI_QUEUE);
2522 if (inta & IMR_VODOK) {
2523 priv->stats.txvookint++;
2524 RT_TRACE(COMP_INTR, "Vo TX OK interrupt!\n");
2525 priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++;
2526 _rtl92e_tx_isr(dev, VO_QUEUE);
2529 spin_unlock_irqrestore(&priv->irq_th_lock, flags);
2538 /****************************************************************************
2539 ---------------------------- PCI_STUFF---------------------------
2540 *****************************************************************************/
2541 static const struct net_device_ops rtl8192_netdev_ops = {
2542 .ndo_open = _rtl92e_open,
2543 .ndo_stop = _rtl92e_close,
2544 .ndo_tx_timeout = _rtl92e_tx_timeout,
2545 .ndo_do_ioctl = _rtl92e_ioctl,
2546 .ndo_set_rx_mode = _rtl92e_set_multicast,
2547 .ndo_set_mac_address = _rtl92e_set_mac_adr,
2548 .ndo_validate_addr = eth_validate_addr,
2549 .ndo_change_mtu = eth_change_mtu,
2550 .ndo_start_xmit = rtllib_xmit,
2553 static int _rtl92e_pci_probe(struct pci_dev *pdev,
2554 const struct pci_device_id *id)
2556 unsigned long ioaddr = 0;
2557 struct net_device *dev = NULL;
2558 struct r8192_priv *priv = NULL;
2559 struct rtl819x_ops *ops = (struct rtl819x_ops *)(id->driver_data);
2560 unsigned long pmem_start, pmem_len, pmem_flags;
2564 RT_TRACE(COMP_INIT, "Configuring chip resources");
2566 if (pci_enable_device(pdev)) {
2567 dev_err(&pdev->dev, "Failed to enable PCI device");
2571 pci_set_master(pdev);
2573 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
2574 if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
2575 dev_info(&pdev->dev,
2576 "Unable to obtain 32bit DMA for consistent allocations\n");
2577 goto err_pci_disable;
2580 dev = alloc_rtllib(sizeof(struct r8192_priv));
2582 goto err_pci_disable;
2586 pci_set_drvdata(pdev, dev);
2587 SET_NETDEV_DEV(dev, &pdev->dev);
2588 priv = rtllib_priv(dev);
2589 priv->rtllib = (struct rtllib_device *)netdev_priv_rsl(dev);
2591 priv->rtllib->pdev = pdev;
2592 if ((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK) &&
2593 (pdev->subsystem_device == 0x3304))
2594 priv->rtllib->bSupportRemoteWakeUp = 1;
2596 priv->rtllib->bSupportRemoteWakeUp = 0;
2598 pmem_start = pci_resource_start(pdev, 1);
2599 pmem_len = pci_resource_len(pdev, 1);
2600 pmem_flags = pci_resource_flags(pdev, 1);
2602 if (!(pmem_flags & IORESOURCE_MEM)) {
2603 netdev_err(dev, "region #1 not a MMIO resource, aborting");
2604 goto err_rel_rtllib;
2607 dev_info(&pdev->dev, "Memory mapped space start: 0x%08lx\n",
2609 if (!request_mem_region(pmem_start, pmem_len, DRV_NAME)) {
2610 netdev_err(dev, "request_mem_region failed!");
2611 goto err_rel_rtllib;
2615 ioaddr = (unsigned long)ioremap_nocache(pmem_start, pmem_len);
2616 if (ioaddr == (unsigned long)NULL) {
2617 netdev_err(dev, "ioremap failed!");
2621 dev->mem_start = ioaddr;
2622 dev->mem_end = ioaddr + pci_resource_len(pdev, 0);
2624 pci_read_config_byte(pdev, 0x08, &revision_id);
2625 /* If the revisionid is 0x10, the device uses rtl8192se. */
2626 if (pdev->device == 0x8192 && revision_id == 0x10)
2631 if (rtl92e_check_adapter(pdev, dev) == false)
2634 dev->irq = pdev->irq;
2637 dev->netdev_ops = &rtl8192_netdev_ops;
2639 dev->wireless_handlers = &r8192_wx_handlers_def;
2640 dev->ethtool_ops = &rtl819x_ethtool_ops;
2642 dev->type = ARPHRD_ETHER;
2643 dev->watchdog_timeo = HZ * 3;
2645 if (dev_alloc_name(dev, ifname) < 0) {
2647 "Oops: devname already taken! Trying wlan%%d...\n");
2648 dev_alloc_name(dev, ifname);
2651 RT_TRACE(COMP_INIT, "Driver probe completed1\n");
2652 if (_rtl92e_init(dev) != 0) {
2653 netdev_warn(dev, "Initialization failed");
2657 netif_carrier_off(dev);
2658 netif_stop_queue(dev);
2660 if (register_netdev(dev))
2662 RT_TRACE(COMP_INIT, "dev name: %s\n", dev->name);
2664 if (priv->polling_timer_on == 0)
2665 rtl92e_check_rfctrl_gpio_timer((unsigned long)dev);
2667 RT_TRACE(COMP_INIT, "Driver probe completed\n");
2671 free_irq(dev->irq, dev);
2674 iounmap((void __iomem *)ioaddr);
2676 release_mem_region(pmem_start, pmem_len);
2680 pci_disable_device(pdev);
2684 static void _rtl92e_pci_disconnect(struct pci_dev *pdev)
2686 struct net_device *dev = pci_get_drvdata(pdev);
2687 struct r8192_priv *priv;
2691 unregister_netdev(dev);
2693 priv = rtllib_priv(dev);
2695 del_timer_sync(&priv->gpio_polling_timer);
2696 cancel_delayed_work(&priv->gpio_change_rf_wq);
2697 priv->polling_timer_on = 0;
2698 _rtl92e_down(dev, true);
2699 rtl92e_dm_deinit(dev);
2700 if (priv->pFirmware) {
2701 vfree(priv->pFirmware);
2702 priv->pFirmware = NULL;
2704 destroy_workqueue(priv->priv_wq);
2705 _rtl92e_free_rx_ring(dev);
2706 for (i = 0; i < MAX_TX_QUEUE_COUNT; i++)
2707 _rtl92e_free_tx_ring(dev, i);
2710 dev_info(&pdev->dev, "Freeing irq %d\n", dev->irq);
2711 free_irq(dev->irq, dev);
2716 if (dev->mem_start != 0) {
2717 iounmap((void __iomem *)dev->mem_start);
2718 release_mem_region(pci_resource_start(pdev, 1),
2719 pci_resource_len(pdev, 1));
2722 priv = rtllib_priv(dev);
2725 pci_disable_device(pdev);
2726 RT_TRACE(COMP_DOWN, "wlan driver removed\n");
2729 bool rtl92e_enable_nic(struct net_device *dev)
2731 bool init_status = true;
2732 struct r8192_priv *priv = rtllib_priv(dev);
2733 struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
2734 (&(priv->rtllib->PowerSaveControl));
2737 netdev_warn(dev, "%s(): Driver is already down!\n", __func__);
2738 priv->bdisable_nic = false;
2742 RT_TRACE(COMP_PS, "===========>%s()\n", __func__);
2743 priv->bfirst_init = true;
2744 init_status = priv->ops->initialize_adapter(dev);
2746 netdev_warn(dev, "%s(): Initialization failed!\n", __func__);
2747 priv->bdisable_nic = false;
2750 RT_TRACE(COMP_INIT, "start adapter finished\n");
2751 RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC);
2752 priv->bfirst_init = false;
2754 rtl92e_irq_enable(dev);
2755 priv->bdisable_nic = false;
2756 RT_TRACE(COMP_PS, "<===========%s()\n", __func__);
2759 bool rtl92e_disable_nic(struct net_device *dev)
2761 struct r8192_priv *priv = rtllib_priv(dev);
2764 RT_TRACE(COMP_PS, "=========>%s()\n", __func__);
2765 priv->bdisable_nic = true;
2766 tmp_state = priv->rtllib->state;
2767 rtllib_softmac_stop_protocol(priv->rtllib, 0, false);
2768 priv->rtllib->state = tmp_state;
2769 _rtl92e_cancel_deferred_work(priv);
2770 rtl92e_irq_disable(dev);
2772 priv->ops->stop_adapter(dev, false);
2773 RT_TRACE(COMP_PS, "<=========%s()\n", __func__);
2778 module_pci_driver(rtl8192_pci_driver);
2780 void rtl92e_check_rfctrl_gpio_timer(unsigned long data)
2782 struct r8192_priv *priv = rtllib_priv((struct net_device *)data);
2784 priv->polling_timer_on = 1;
2786 queue_delayed_work_rsl(priv->priv_wq, &priv->gpio_change_rf_wq, 0);
2788 mod_timer(&priv->gpio_polling_timer, jiffies +
2789 msecs_to_jiffies(RTLLIB_WATCH_DOG_TIME));
2792 /***************************************************************************
2793 ------------------- module init / exit stubs ----------------
2794 ****************************************************************************/
2795 MODULE_DESCRIPTION("Linux driver for Realtek RTL819x WiFi cards");
2796 MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR);
2797 MODULE_VERSION(DRV_VERSION);
2798 MODULE_LICENSE("GPL");
2799 MODULE_FIRMWARE(RTL8192E_BOOT_IMG_FW);
2800 MODULE_FIRMWARE(RTL8192E_MAIN_IMG_FW);
2801 MODULE_FIRMWARE(RTL8192E_DATA_IMG_FW);
2803 module_param(ifname, charp, S_IRUGO|S_IWUSR);
2804 module_param(hwwep, int, S_IRUGO|S_IWUSR);
2805 module_param(channels, int, S_IRUGO|S_IWUSR);
2807 MODULE_PARM_DESC(ifname, " Net interface name, wlan%d=default");
2808 MODULE_PARM_DESC(hwwep, " Try to use hardware WEP support(default use hw. set 0 to use software security)");
2809 MODULE_PARM_DESC(channels, " Channel bitmask for specific locales. NYI");