2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
31 Create and register network interface.
35 -------- ---------- ----------------------------------------------
36 Sample Mar/21/07 Merge RT2870 and RT2860 drivers.
39 #include "rt_config.h"
41 #define FORTY_MHZ_INTOLERANT_INTERVAL (60*1000) // 1 min
43 #ifdef MULTIPLE_CARD_SUPPORT
44 // record whether the card in the card list is used in the card file
45 UINT8 MC_CardUsed[MAX_NUM_OF_MULTIPLE_CARD];
46 // record used card mac address in the card list
47 static UINT8 MC_CardMac[MAX_NUM_OF_MULTIPLE_CARD][6];
48 #endif // MULTIPLE_CARD_SUPPORT //
50 #ifdef CONFIG_APSTA_MIXED_SUPPORT
51 UINT32 CW_MAX_IN_BITS;
52 #endif // CONFIG_APSTA_MIXED_SUPPORT //
54 /*---------------------------------------------------------------------*/
55 /* Private Variables Used */
56 /*---------------------------------------------------------------------*/
57 //static RALINK_TIMER_STRUCT PeriodicTimer;
59 char *mac = ""; // default 00:00:00:00:00:00
60 char *hostname = ""; // default CMPC
61 module_param (mac, charp, 0);
62 MODULE_PARM_DESC (mac, "rt28xx: wireless mac addr");
65 /*---------------------------------------------------------------------*/
66 /* Prototypes of Functions Used */
67 /*---------------------------------------------------------------------*/
68 #ifdef DOT11_N_SUPPORT
69 extern BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num);
70 extern void ba_reordering_resource_release(PRTMP_ADAPTER pAd);
71 #endif // DOT11_N_SUPPORT //
72 extern NDIS_STATUS NICLoadRateSwitchingParams(IN PRTMP_ADAPTER pAd);
74 extern void init_thread_task(PRTMP_ADAPTER pAd);
76 // public function prototype
77 INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
78 IN UINT argc, OUT PRTMP_ADAPTER *ppAd);
80 // private function prototype
81 static int rt28xx_init(IN struct net_device *net_dev);
82 INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev);
84 static void CfgInitHook(PRTMP_ADAPTER pAd);
86 #ifdef CONFIG_STA_SUPPORT
87 extern const struct iw_handler_def rt28xx_iw_handler_def;
88 #endif // CONFIG_STA_SUPPORT //
90 #ifdef CONFIG_APSTA_MIXED_SUPPORT
91 extern const struct iw_handler_def rt28xx_ap_iw_handler_def;
92 #endif // CONFIG_APSTA_MIXED_SUPPORT //
94 #if WIRELESS_EXT >= 12
95 // This function will be called when query /proc
96 struct iw_statistics *rt28xx_get_wireless_stats(
97 IN struct net_device *net_dev);
100 struct net_device_stats *RT28xx_get_ether_stats(
101 IN struct net_device *net_dev);
104 ========================================================================
106 Close raxx interface.
109 *net_dev the raxx interface pointer
116 1. if open fail, kernel will not call the close function.
118 (1) Mlme Memory Handler: MlmeHalt()
119 (2) TX & RX: RTMPFreeTxRxRingMemory()
120 (3) BA Reordering: ba_reordering_resource_release()
121 ========================================================================
123 int MainVirtualIF_close(IN struct net_device *net_dev)
125 RTMP_ADAPTER *pAd = net_dev->ml_priv;
127 // Sanity check for pAd
129 return 0; // close ok
131 netif_carrier_off(pAd->net_dev);
132 netif_stop_queue(pAd->net_dev);
135 VIRTUAL_IF_DOWN(pAd);
137 RT_MOD_DEC_USE_COUNT();
139 return 0; // close ok
143 ========================================================================
148 *net_dev the raxx interface pointer
155 1. if open fail, kernel will not call the close function.
157 (1) Mlme Memory Handler: MlmeHalt()
158 (2) TX & RX: RTMPFreeTxRxRingMemory()
159 (3) BA Reordering: ba_reordering_resource_release()
160 ========================================================================
162 int MainVirtualIF_open(IN struct net_device *net_dev)
164 RTMP_ADAPTER *pAd = net_dev->ml_priv;
166 // Sanity check for pAd
168 return 0; // close ok
170 if (VIRTUAL_IF_UP(pAd) != 0)
173 // increase MODULE use count
174 RT_MOD_INC_USE_COUNT();
176 netif_start_queue(net_dev);
177 netif_carrier_on(net_dev);
178 netif_wake_queue(net_dev);
184 ========================================================================
186 Close raxx interface.
189 *net_dev the raxx interface pointer
196 1. if open fail, kernel will not call the close function.
198 (1) Mlme Memory Handler: MlmeHalt()
199 (2) TX & RX: RTMPFreeTxRxRingMemory()
200 (3) BA Reordering: ba_reordering_resource_release()
201 ========================================================================
203 int rt28xx_close(IN PNET_DEV dev)
205 struct net_device * net_dev = (struct net_device *)dev;
206 RTMP_ADAPTER *pAd = net_dev->ml_priv;
207 BOOLEAN Cancelled = FALSE;
211 DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
213 // Sanity check for pAd
215 return 0; // close ok
217 #ifdef CONFIG_STA_SUPPORT
218 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
220 // If dirver doesn't wake up firmware here,
221 // NICLoadFirmware will hang forever when interface is up again.
222 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) ||
223 RTMP_SET_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND) ||
224 RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))
226 AsicForceWakeup(pAd, RTMP_HALT);
229 #ifdef QOS_DLS_SUPPORT
230 // send DLS-TEAR_DOWN message,
231 if (pAd->CommonCfg.bDLSCapable)
235 // tear down local dls table entry
236 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
238 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
240 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
241 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
242 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
246 // tear down peer dls table entry
247 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
249 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
251 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
252 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
253 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
256 RT28XX_MLME_HANDLER(pAd);
258 #endif // QOS_DLS_SUPPORT //
261 (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
263 MLME_DISASSOC_REQ_STRUCT DisReq;
264 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
266 COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid);
267 DisReq.Reason = REASON_DEAUTH_STA_LEAVING;
269 MsgElem->Machine = ASSOC_STATE_MACHINE;
270 MsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
271 MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
272 NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
274 // Prevent to connect AP again in STAMlmePeriodicExec
275 pAd->MlmeAux.AutoReconnectSsidLen= 32;
276 NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
278 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
279 MlmeDisassocReqAction(pAd, MsgElem);
287 RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &Cancelled);
290 RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled);
291 RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled);
293 #ifdef WPA_SUPPLICANT_SUPPORT
294 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
296 union iwreq_data wrqu;
297 // send wireless event to wpa_supplicant for infroming interface down.
298 memset(&wrqu, 0, sizeof(wrqu));
299 wrqu.data.flags = RT_INTERFACE_DOWN;
300 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
302 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
303 #endif // WPA_SUPPLICANT_SUPPORT //
306 pAd->bPCIclkOff = FALSE;
308 #endif // CONFIG_STA_SUPPORT //
310 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
312 for (i = 0 ; i < NUM_OF_TX_RING; i++)
314 while (pAd->DeQueueRunning[i] == TRUE)
316 printk("Waiting for TxQueue[%d] done..........\n", i);
321 // Stop Mlme state machine
324 // Close kernel threads or tasklets
325 kill_thread_task(pAd);
328 #ifdef CONFIG_STA_SUPPORT
329 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
333 #endif // CONFIG_STA_SUPPORT //
336 MeasureReqTabExit(pAd);
340 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
342 NICDisableInterrupt(pAd);
345 // Disable Rx, register value supposed will remain after reset
349 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
351 // Deregister interrupt function
352 RT28XX_IRQ_RELEASE(net_dev)
353 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
357 // Free Ring or USB buffers
358 RTMPFreeTxRxRingMemory(pAd);
360 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
362 #ifdef DOT11_N_SUPPORT
363 // Free BA reorder resource
364 ba_reordering_resource_release(pAd);
365 #endif // DOT11_N_SUPPORT //
368 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
370 return 0; // close ok
371 } /* End of rt28xx_close */
373 static int rt28xx_init(IN struct net_device *net_dev)
375 PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)net_dev->ml_priv;
382 #ifdef DOT11_N_SUPPORT
383 // Allocate BA Reordering memory
384 ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM);
385 #endif // DOT11_N_SUPPORT //
387 // Make sure MAC gets ready.
391 RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
392 pAd->MACVersion = MacCsr0;
394 if ((pAd->MACVersion != 0x00) && (pAd->MACVersion != 0xFFFFFFFF))
398 } while (index++ < 100);
400 DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
403 RT28XXDMADisable(pAd);
406 // Load 8051 firmware
407 Status = NICLoadFirmware(pAd);
408 if (Status != NDIS_STATUS_SUCCESS)
410 DBGPRINT_ERR(("NICLoadFirmware failed, Status[=0x%08x]\n", Status));
414 NICLoadRateSwitchingParams(pAd);
416 // Disable interrupts here which is as soon as possible
417 // This statement should never be true. We might consider to remove it later
418 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
420 NICDisableInterrupt(pAd);
423 Status = RTMPAllocTxRxRingMemory(pAd);
424 if (Status != NDIS_STATUS_SUCCESS)
426 DBGPRINT_ERR(("RTMPAllocDMAMemory failed, Status[=0x%08x]\n", Status));
430 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
435 Status = MlmeInit(pAd);
436 if (Status != NDIS_STATUS_SUCCESS)
438 DBGPRINT_ERR(("MlmeInit failed, Status[=0x%08x]\n", Status));
442 // Initialize pAd->StaCfg, pAd->ApCfg, pAd->CommonCfg to manufacture default
447 RT28XX_TASK_THREAD_INIT(pAd, Status);
448 if (Status != NDIS_STATUS_SUCCESS)
455 initblockQueueTab(pAd);
456 #endif // BLOCK_NET_IF //
458 #ifdef CONFIG_STA_SUPPORT
459 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
460 NdisAllocateSpinLock(&pAd->MacTabLock);
461 #endif // CONFIG_STA_SUPPORT //
463 MeasureReqTabInit(pAd);
467 // Init the hardware, we need to init asic before read registry, otherwise mac register will be reset
469 Status = NICInitializeAdapter(pAd, TRUE);
470 if (Status != NDIS_STATUS_SUCCESS)
472 DBGPRINT_ERR(("NICInitializeAdapter failed, Status[=0x%08x]\n", Status));
473 if (Status != NDIS_STATUS_SUCCESS)
477 // Read parameters from Config File
478 Status = RTMPReadParametersHook(pAd);
480 printk("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
481 if (Status != NDIS_STATUS_SUCCESS)
483 DBGPRINT_ERR(("NICReadRegParameters failed, Status[=0x%08x]\n",Status));
489 //Init Ba Capability parameters.
490 #ifdef DOT11_N_SUPPORT
491 pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
492 pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
493 pAd->CommonCfg.DesiredHtPhy.AmsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
494 pAd->CommonCfg.DesiredHtPhy.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
496 pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
497 pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
498 pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
499 #endif // DOT11_N_SUPPORT //
501 printk("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
503 // We should read EEPROM for all cases. rt2860b
504 NICReadEEPROMParameters(pAd, mac);
506 printk("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
508 NICInitAsicFromEEPROM(pAd); //rt2860b
510 // Set PHY to appropriate mode
511 TmpPhy = pAd->CommonCfg.PhyMode;
512 pAd->CommonCfg.PhyMode = 0xff;
513 RTMPSetPhyMode(pAd, TmpPhy);
514 #ifdef DOT11_N_SUPPORT
516 #endif // DOT11_N_SUPPORT //
518 // No valid channels.
519 if (pAd->ChannelListNum == 0)
521 printk("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n");
525 #ifdef DOT11_N_SUPPORT
526 printk("MCS Set = %02x %02x %02x %02x %02x\n", pAd->CommonCfg.HtCapability.MCSSet[0],
527 pAd->CommonCfg.HtCapability.MCSSet[1], pAd->CommonCfg.HtCapability.MCSSet[2],
528 pAd->CommonCfg.HtCapability.MCSSet[3], pAd->CommonCfg.HtCapability.MCSSet[4]);
529 #endif // DOT11_N_SUPPORT //
532 VR_IKANOS_FP_Init(pAd->ApCfg.BssidNum, pAd->PermanentAddress);
533 #endif // IKANOS_VX_1X0 //
536 // Initialize RF register to default value
538 AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
539 AsicLockChannel(pAd, pAd->CommonCfg.Channel);
541 // 8051 firmware require the signal during booting time.
542 AsicSendCommandToMcu(pAd, 0x72, 0xFF, 0x00, 0x00);
544 if (pAd && (Status != NDIS_STATUS_SUCCESS))
547 // Undo everything if it failed
549 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
551 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
556 // Microsoft HCT require driver send a disconnect event after driver initialization.
557 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
558 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
559 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n"));
565 DBGPRINT_S(Status, ("<==== RTMPInitialize, Status=%x\n", Status));
574 RTMPFreeTxRxRingMemory(pAd);
577 #ifdef DOT11_N_SUPPORT
578 os_free_mem(pAd, pAd->mpdu_blk_pool.mem); // free BA pool
579 #endif // DOT11_N_SUPPORT //
580 RT28XX_IRQ_RELEASE(net_dev);
582 // shall not set ml_priv to NULL here because the ml_priv didn't been free yet.
583 //net_dev->ml_priv = 0;
586 #endif // INF_AMAZON_SE //
587 printk("!!! %s Initialized fail !!!\n", RT28xx_CHIP_NAME);
589 } /* End of rt28xx_init */
593 ========================================================================
598 *net_dev the raxx interface pointer
605 ========================================================================
607 int rt28xx_open(IN PNET_DEV dev)
609 struct net_device * net_dev = (struct net_device *)dev;
610 PRTMP_ADAPTER pAd = net_dev->ml_priv;
615 // Sanity check for pAd
618 /* if 1st open fail, pAd will be free;
619 So the net_dev->ml_priv will be NULL in 2rd open */
623 #ifdef CONFIG_APSTA_MIXED_SUPPORT
624 if (pAd->OpMode == OPMODE_AP)
628 else if (pAd->OpMode == OPMODE_STA)
633 #if WIRELESS_EXT >= 12
634 if (net_dev->priv_flags == INT_MAIN)
636 if (pAd->OpMode == OPMODE_AP)
637 net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def;
638 else if (pAd->OpMode == OPMODE_STA)
639 net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_iw_handler_def;
641 #endif // WIRELESS_EXT >= 12 //
642 #endif // CONFIG_APSTA_MIXED_SUPPORT //
645 pObj = (POS_COOKIE)pAd->OS_Cookie;
647 // reset Adapter flags
648 RTMP_CLEAR_FLAGS(pAd);
650 // Request interrupt service routine for PCI device
651 // register the interrupt routine with the os
652 RT28XX_IRQ_REQUEST(net_dev);
655 // Init BssTab & ChannelInfo tabbles for auto channel select.
659 if (rt28xx_init(net_dev) == FALSE)
662 #ifdef CONFIG_STA_SUPPORT
663 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
665 NdisZeroMemory(pAd->StaCfg.dev_name, 16);
666 NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name));
668 #endif // CONFIG_STA_SUPPORT //
670 // Set up the Mac address
671 NdisMoveMemory(net_dev->dev_addr, (void *) pAd->CurrentAddress, 6);
673 // Init IRQ parameters
674 RT28XX_IRQ_INIT(pAd);
676 // Various AP function init
678 #ifdef CONFIG_STA_SUPPORT
679 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
681 #ifdef WPA_SUPPLICANT_SUPPORT
682 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
684 union iwreq_data wrqu;
685 // send wireless event to wpa_supplicant for infroming interface down.
686 memset(&wrqu, 0, sizeof(wrqu));
687 wrqu.data.flags = RT_INTERFACE_UP;
688 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
690 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
691 #endif // WPA_SUPPLICANT_SUPPORT //
694 #endif // CONFIG_STA_SUPPORT //
697 RT28XX_IRQ_ENABLE(pAd);
701 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP);
705 RTMP_IO_READ32(pAd, 0x1300, ®); // clear garbage interrupts
706 printk("0x1300 = %08x\n", reg);
709 #ifdef CONFIG_STA_SUPPORT
710 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
711 RTMPInitPCIeLinkCtrlValue(pAd);
712 #endif // CONFIG_STA_SUPPORT //
718 } /* End of rt28xx_open */
720 static const struct net_device_ops rt2860_netdev_ops = {
721 .ndo_open = MainVirtualIF_open,
722 .ndo_stop = MainVirtualIF_close,
723 .ndo_do_ioctl = rt28xx_ioctl,
724 .ndo_get_stats = RT28xx_get_ether_stats,
725 .ndo_validate_addr = NULL,
726 .ndo_set_mac_address = eth_mac_addr,
727 .ndo_change_mtu = eth_change_mtu,
729 .ndo_start_xmit = IKANOS_DataFramesTx,
731 .ndo_start_xmit = rt28xx_send_packets,
735 /* Must not be called for mdev and apdev */
736 static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER pAd)
740 CHAR slot_name[IFNAMSIZ];
741 struct net_device *device;
746 #ifdef CONFIG_STA_SUPPORT
747 #if WIRELESS_EXT >= 12
748 if (pAd->OpMode == OPMODE_STA)
750 dev->wireless_handlers = &rt28xx_iw_handler_def;
752 #endif //WIRELESS_EXT >= 12
753 #endif // CONFIG_STA_SUPPORT //
755 #ifdef CONFIG_APSTA_MIXED_SUPPORT
756 #if WIRELESS_EXT >= 12
757 if (pAd->OpMode == OPMODE_AP)
759 dev->wireless_handlers = &rt28xx_ap_iw_handler_def;
761 #endif //WIRELESS_EXT >= 12
762 #endif // CONFIG_APSTA_MIXED_SUPPORT //
764 #if WIRELESS_EXT < 21
765 dev->get_wireless_stats = rt28xx_get_wireless_stats;
767 dev->priv_flags = INT_MAIN;
768 dev->netdev_ops = &rt2860_netdev_ops;
769 // find available device name
770 for (i = 0; i < 8; i++)
772 #ifdef MULTIPLE_CARD_SUPPORT
773 if (pAd->MC_RowID >= 0)
774 sprintf(slot_name, "ra%02d_%d", pAd->MC_RowID, i);
776 #endif // MULTIPLE_CARD_SUPPORT //
777 sprintf(slot_name, "ra%d", i);
779 device = dev_get_by_name(dev_net(dev), slot_name);
789 DBGPRINT(RT_DEBUG_ERROR, ("No available slot name\n"));
790 Status = NDIS_STATUS_FAILURE;
794 #ifdef MULTIPLE_CARD_SUPPORT
795 if (pAd->MC_RowID >= 0)
796 sprintf(dev->name, "ra%02d_%d", pAd->MC_RowID, i);
798 #endif // MULTIPLE_CARD_SUPPORT //
799 sprintf(dev->name, "ra%d", i);
800 Status = NDIS_STATUS_SUCCESS;
808 #ifdef MULTIPLE_CARD_SUPPORT
810 ========================================================================
812 Get card profile path.
818 TRUE - Find a card profile
819 FALSE - use default profile
822 ========================================================================
824 extern INT RTMPGetKeyParameter(
830 BOOLEAN RTMP_CardInfoRead(
831 IN PRTMP_ADAPTER pAd)
833 #define MC_SELECT_CARDID 0 /* use CARD ID (0 ~ 31) to identify different cards */
834 #define MC_SELECT_MAC 1 /* use CARD MAC to identify different cards */
835 #define MC_SELECT_CARDTYPE 2 /* use CARD type (abgn or bgn) to identify different cards */
837 #define LETTER_CASE_TRANSLATE(txt_p, card_id) \
838 { UINT32 _len; char _char; \
839 for(_len=0; _len<strlen(card_id); _len++) { \
840 _char = *(txt_p + _len); \
841 if (('A' <= _char) && (_char <= 'Z')) \
842 *(txt_p+_len) = 'a'+(_char-'A'); \
846 INT retval, orgfsuid, orgfsgid;
848 CHAR *buffer, *tmpbuf, card_id_buf[30], RFIC_word[30];
849 BOOLEAN flg_match_ok = FALSE;
850 INT32 card_select_method;
851 INT32 card_free_id, card_nouse_id, card_same_mac_id, card_match_id;
852 EEPROM_ANTENNA_STRUC antenna;
853 USHORT addr01, addr23, addr45;
855 UINT32 data, card_index;
860 buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
864 tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
868 return NDIS_STATUS_FAILURE;
871 orgfsuid = current->fsuid;
872 orgfsgid = current->fsgid;
873 current->fsuid = current->fsgid = 0;
878 RTMP_IO_READ32(pAd, E2PROM_CSR, &data);
880 if ((data & 0x30) == 0)
881 pAd->EEPROMAddressNum = 6; // 93C46
882 else if ((data & 0x30) == 0x10)
883 pAd->EEPROMAddressNum = 8; // 93C66
885 pAd->EEPROMAddressNum = 8; // 93C86
887 RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, antenna.word);
889 if ((antenna.field.RfIcType == RFIC_2850) ||
890 (antenna.field.RfIcType == RFIC_2750))
893 strcpy(RFIC_word, "abgn");
898 strcpy(RFIC_word, "bgn");
902 RT28xx_EEPROM_READ16(pAd, 0x04, addr01);
903 RT28xx_EEPROM_READ16(pAd, 0x06, addr23);
904 RT28xx_EEPROM_READ16(pAd, 0x08, addr45);
906 mac[0] = (UCHAR)(addr01 & 0xff);
907 mac[1] = (UCHAR)(addr01 >> 8);
908 mac[2] = (UCHAR)(addr23 & 0xff);
909 mac[3] = (UCHAR)(addr23 >> 8);
910 mac[4] = (UCHAR)(addr45 & 0xff);
911 mac[5] = (UCHAR)(addr45 >> 8);
913 // open card information file
914 srcf = filp_open(CARD_INFO_PATH, O_RDONLY, 0);
917 /* card information file does not exist */
918 DBGPRINT(RT_DEBUG_TRACE,
919 ("--> Error %ld opening %s\n", -PTR_ERR(srcf), CARD_INFO_PATH));
923 if (srcf->f_op && srcf->f_op->read)
925 /* card information file exists so reading the card information */
926 memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
927 retval = srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
931 DBGPRINT(RT_DEBUG_TRACE,
932 ("--> Read %s error %d\n", CARD_INFO_PATH, -retval));
936 /* get card selection method */
937 memset(tmpbuf, 0x00, MAX_PARAM_BUFFER_SIZE);
938 card_select_method = MC_SELECT_CARDTYPE; // default
940 if (RTMPGetKeyParameter("SELECT", tmpbuf, 256, buffer))
942 if (strcmp(tmpbuf, "CARDID") == 0)
943 card_select_method = MC_SELECT_CARDID;
944 else if (strcmp(tmpbuf, "MAC") == 0)
945 card_select_method = MC_SELECT_MAC;
946 else if (strcmp(tmpbuf, "CARDTYPE") == 0)
947 card_select_method = MC_SELECT_CARDTYPE;
950 DBGPRINT(RT_DEBUG_TRACE,
951 ("MC> Card Selection = %d\n", card_select_method));
956 card_same_mac_id = -1;
959 // search current card information records
961 card_index<MAX_NUM_OF_MULTIPLE_CARD;
964 if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
965 (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
967 // MAC is all-0 so the entry is available
968 MC_CardUsed[card_index] = 0;
970 if (card_free_id < 0)
971 card_free_id = card_index; // 1st free entry
975 if (memcmp(MC_CardMac[card_index], mac, 6) == 0)
977 // we find the entry with same MAC
978 if (card_same_mac_id < 0)
979 card_same_mac_id = card_index; // 1st same entry
983 // MAC is not all-0 but used flag == 0
984 if ((MC_CardUsed[card_index] == 0) &&
987 card_nouse_id = card_index; // 1st available entry
993 DBGPRINT(RT_DEBUG_TRACE,
994 ("MC> Free = %d, Same = %d, NOUSE = %d\n",
995 card_free_id, card_same_mac_id, card_nouse_id));
997 if ((card_same_mac_id >= 0) &&
998 ((card_select_method == MC_SELECT_CARDID) ||
999 (card_select_method == MC_SELECT_CARDTYPE)))
1001 // same MAC entry is found
1002 card_match_id = card_same_mac_id;
1004 if (card_select_method == MC_SELECT_CARDTYPE)
1007 sprintf(card_id_buf, "%02dCARDTYPE%s",
1008 card_match_id, RFIC_word);
1010 if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
1012 // we found the card ID
1013 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
1019 // the card is 1st plug-in, try to find the match card profile
1020 switch(card_select_method)
1022 case MC_SELECT_CARDID: // CARDID
1024 if (card_free_id >= 0)
1025 card_match_id = card_free_id;
1027 card_match_id = card_nouse_id;
1030 case MC_SELECT_MAC: // MAC
1031 sprintf(card_id_buf, "MAC%02x:%02x:%02x:%02x:%02x:%02x",
1032 mac[0], mac[1], mac[2],
1033 mac[3], mac[4], mac[5]);
1035 /* try to find the key word in the card file */
1036 if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
1038 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
1040 /* get the row ID (2 ASCII characters) */
1042 card_id_buf[0] = *(start_ptr);
1043 card_id_buf[1] = *(start_ptr+1);
1044 card_id_buf[2] = 0x00;
1046 card_match_id = simple_strtol(card_id_buf, 0, 10);
1050 case MC_SELECT_CARDTYPE: // CARDTYPE
1054 card_index<MAX_NUM_OF_MULTIPLE_CARD;
1057 sprintf(card_id_buf, "%02dCARDTYPE%s",
1058 card_index, RFIC_word);
1060 if ((start_ptr=rtstrstruncasecmp(buffer,
1061 card_id_buf)) != NULL)
1063 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
1065 if (MC_CardUsed[card_index] == 0)
1067 /* current the card profile is not used */
1068 if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
1069 (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
1071 // find it and no previous card use it
1072 card_match_id = card_index;
1077 // ever a card use it
1078 if (card_nouse_id < 0)
1079 card_nouse_id = card_index;
1085 // if not find a free one, use the available one
1086 if (card_match_id < 0)
1087 card_match_id = card_nouse_id;
1092 if (card_match_id >= 0)
1094 // make up search keyword
1095 switch(card_select_method)
1097 case MC_SELECT_CARDID: // CARDID
1098 sprintf(card_id_buf, "%02dCARDID", card_match_id);
1101 case MC_SELECT_MAC: // MAC
1102 sprintf(card_id_buf,
1103 "%02dmac%02x:%02x:%02x:%02x:%02x:%02x",
1105 mac[0], mac[1], mac[2],
1106 mac[3], mac[4], mac[5]);
1109 case MC_SELECT_CARDTYPE: // CARDTYPE
1111 sprintf(card_id_buf, "%02dcardtype%s",
1112 card_match_id, RFIC_word);
1116 DBGPRINT(RT_DEBUG_TRACE, ("Search Keyword = %s\n", card_id_buf));
1118 // read card file path
1119 if (RTMPGetKeyParameter(card_id_buf, tmpbuf, 256, buffer))
1121 if (strlen(tmpbuf) < sizeof(pAd->MC_FileName))
1123 // backup card information
1124 pAd->MC_RowID = card_match_id; /* base 0 */
1125 MC_CardUsed[card_match_id] = 1;
1126 memcpy(MC_CardMac[card_match_id], mac, sizeof(mac));
1128 // backup card file path
1129 NdisMoveMemory(pAd->MC_FileName, tmpbuf , strlen(tmpbuf));
1130 pAd->MC_FileName[strlen(tmpbuf)] = '\0';
1131 flg_match_ok = TRUE;
1133 DBGPRINT(RT_DEBUG_TRACE,
1134 ("Card Profile Name = %s\n", pAd->MC_FileName));
1138 DBGPRINT(RT_DEBUG_ERROR,
1139 ("Card Profile Name length too large!\n"));
1144 DBGPRINT(RT_DEBUG_ERROR,
1145 ("Can not find search key word in card.dat!\n"));
1148 if ((flg_match_ok != TRUE) &&
1149 (card_match_id < MAX_NUM_OF_MULTIPLE_CARD))
1151 MC_CardUsed[card_match_id] = 0;
1152 memset(MC_CardMac[card_match_id], 0, sizeof(mac));
1154 } // if (card_match_id >= 0)
1159 retval = filp_close(srcf, NULL);
1161 current->fsuid = orgfsuid;
1162 current->fsgid = orgfsgid;
1165 return flg_match_ok;
1167 #endif // MULTIPLE_CARD_SUPPORT //
1171 ========================================================================
1172 Routine Description:
1173 Probe RT28XX chipset.
1176 _dev_p Point to the PCI or USB device
1177 _dev_id_p Point to the PCI or USB device ID
1184 ========================================================================
1186 INT __devinit rt28xx_probe(
1190 OUT PRTMP_ADAPTER *ppAd)
1192 struct net_device *net_dev;
1193 PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) NULL;
1196 struct pci_dev *dev_p = (struct pci_dev *)_dev_p;
1199 #ifdef CONFIG_STA_SUPPORT
1200 DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION));
1201 #endif // CONFIG_STA_SUPPORT //
1203 net_dev = alloc_etherdev(sizeof(PRTMP_ADAPTER));
1204 if (net_dev == NULL)
1206 printk("alloc_netdev failed\n");
1211 netif_stop_queue(net_dev);
1212 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
1213 /* for supporting Network Manager */
1214 /* Set the sysfs physical device reference for the network logical device
1215 * if set prior to registration will cause a symlink during initialization.
1217 SET_NETDEV_DEV(net_dev, &(dev_p->dev));
1218 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
1220 // Allocate RTMP_ADAPTER miniport adapter structure
1221 handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
1222 RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p);
1224 status = RTMPAllocAdapterBlock(handle, &pAd);
1225 if (status != NDIS_STATUS_SUCCESS)
1226 goto err_out_free_netdev;
1228 net_dev->ml_priv = (PVOID)pAd;
1229 pAd->net_dev = net_dev; // must be before RT28XXNetDevInit()
1231 RT28XXNetDevInit(_dev_p, net_dev, pAd);
1233 #ifdef CONFIG_STA_SUPPORT
1234 pAd->StaCfg.OriDevType = net_dev->type;
1235 #endif // CONFIG_STA_SUPPORT //
1238 if (RT28XXProbePostConfig(_dev_p, pAd, 0) == FALSE)
1241 #ifdef CONFIG_STA_SUPPORT
1242 pAd->OpMode = OPMODE_STA;
1243 #endif // CONFIG_STA_SUPPORT //
1246 #ifdef MULTIPLE_CARD_SUPPORT
1247 // find its profile path
1248 pAd->MC_RowID = -1; // use default profile path
1249 RTMP_CardInfoRead(pAd);
1251 if (pAd->MC_RowID == -1)
1252 #ifdef CONFIG_STA_SUPPORT
1253 strcpy(pAd->MC_FileName, STA_PROFILE_PATH);
1254 #endif // CONFIG_STA_SUPPORT //
1256 DBGPRINT(RT_DEBUG_TRACE,
1257 ("MC> ROW = %d, PATH = %s\n", pAd->MC_RowID, pAd->MC_FileName));
1258 #endif // MULTIPLE_CARD_SUPPORT //
1261 if (rt_ieee80211_if_setup(net_dev, pAd) != NDIS_STATUS_SUCCESS)
1264 // Register this device
1265 status = register_netdev(net_dev);
1270 RT28XX_DRVDATA_SET(_dev_p);
1273 return 0; // probe ok
1276 /* --------------------------- ERROR HANDLE --------------------------- */
1278 RTMPFreeAdapter(pAd);
1281 err_out_free_netdev:
1282 free_netdev(net_dev);
1285 RT28XX_PUT_DEVICE(dev_p);
1287 return -ENODEV; /* probe fail */
1288 } /* End of rt28xx_probe */
1292 ========================================================================
1293 Routine Description:
1294 The entry point for Linux kernel sent packet to our driver.
1297 sk_buff *skb the pointer refer to a sk_buffer.
1303 This function is the entry point of Tx Path for Os delivery packet to
1304 our driver. You only can put OS-depened & STA/AP common handle procedures
1306 ========================================================================
1308 int rt28xx_packet_xmit(struct sk_buff *skb)
1310 struct net_device *net_dev = skb->dev;
1311 PRTMP_ADAPTER pAd = net_dev->ml_priv;
1313 PNDIS_PACKET pPacket = (PNDIS_PACKET) skb;
1315 /* RT2870STA does this in RTMPSendPackets() */
1319 RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_RESOURCES);
1322 #endif // RALINK_ATE //
1324 #ifdef CONFIG_STA_SUPPORT
1325 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1327 // Drop send request since we are in monitor mode
1328 if (MONITOR_ON(pAd))
1330 RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
1334 #endif // CONFIG_STA_SUPPORT //
1336 // EapolStart size is 18
1339 //printk("bad packet size: %d\n", pkt->len);
1340 hex_dump("bad packet", skb->data, skb->len);
1341 RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
1345 RTMP_SET_PACKET_5VT(pPacket, 0);
1346 #ifdef CONFIG_5VT_ENHANCE
1347 if (*(int*)(skb->cb) == BRIDGE_TAG) {
1348 RTMP_SET_PACKET_5VT(pPacket, 1);
1354 #ifdef CONFIG_STA_SUPPORT
1355 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1358 STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1);
1361 #endif // CONFIG_STA_SUPPORT //
1371 ========================================================================
1372 Routine Description:
1373 Send a packet to WLAN.
1376 skb_p points to our adapter
1377 dev_p which WLAN network interface
1380 0: transmit successfully
1381 otherwise: transmit fail
1384 ========================================================================
1386 INT rt28xx_send_packets(
1387 IN struct sk_buff *skb_p,
1388 IN struct net_device *net_dev)
1390 RTMP_ADAPTER *pAd = net_dev->ml_priv;
1391 if (!(net_dev->flags & IFF_UP))
1393 RELEASE_NDIS_PACKET(pAd, (PNDIS_PACKET)skb_p, NDIS_STATUS_FAILURE);
1397 NdisZeroMemory((PUCHAR)&skb_p->cb[CB_OFF], 15);
1398 RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID);
1400 return rt28xx_packet_xmit(skb_p);
1402 } /* End of MBSS_VirtualIF_PacketSend */
1407 void CfgInitHook(PRTMP_ADAPTER pAd)
1409 pAd->bBroadComHT = TRUE;
1410 } /* End of CfgInitHook */
1413 #if WIRELESS_EXT >= 12
1414 // This function will be called when query /proc
1415 struct iw_statistics *rt28xx_get_wireless_stats(
1416 IN struct net_device *net_dev)
1418 PRTMP_ADAPTER pAd = net_dev->ml_priv;
1421 DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
1423 pAd->iw_stats.status = 0; // Status - device dependent for now
1426 pAd->iw_stats.qual.qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10);
1427 if(pAd->iw_stats.qual.qual > 100)
1428 pAd->iw_stats.qual.qual = 100;
1430 #ifdef CONFIG_STA_SUPPORT
1431 if (pAd->OpMode == OPMODE_STA)
1432 pAd->iw_stats.qual.level = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
1433 #endif // CONFIG_STA_SUPPORT //
1435 pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; // noise level (dBm)
1437 pAd->iw_stats.qual.noise += 256 - 143;
1438 pAd->iw_stats.qual.updated = 1; // Flags to know if updated
1440 pAd->iw_stats.qual.updated |= IW_QUAL_DBM; // Level + Noise are dBm
1441 #endif // IW_QUAL_DBM //
1443 pAd->iw_stats.discard.nwid = 0; // Rx : Wrong nwid/essid
1444 pAd->iw_stats.miss.beacon = 0; // Missed beacons/superframe
1446 DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
1447 return &pAd->iw_stats;
1448 } /* End of rt28xx_get_wireless_stats */
1449 #endif // WIRELESS_EXT //
1453 void tbtt_tasklet(unsigned long data)
1455 #define MAX_TX_IN_TBTT (16)
1460 IN struct net_device *net_dev,
1461 IN OUT struct ifreq *rq,
1464 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1465 RTMP_ADAPTER *pAd = NULL;
1468 if (net_dev->priv_flags == INT_MAIN)
1470 pAd = net_dev->ml_priv;
1474 pVirtualAd = net_dev->ml_priv;
1475 pAd = pVirtualAd->RtmpDev->ml_priv;
1480 /* if 1st open fail, pAd will be free;
1481 So the net_dev->ml_priv will be NULL in 2rd open */
1486 #ifdef CONFIG_STA_SUPPORT
1487 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1489 ret = rt28xx_sta_ioctl(net_dev, rq, cmd);
1491 #endif // CONFIG_STA_SUPPORT //
1497 ========================================================================
1499 Routine Description:
1500 return ethernet statistics counter
1503 net_dev Pointer to net_device
1510 ========================================================================
1512 struct net_device_stats *RT28xx_get_ether_stats(
1513 IN struct net_device *net_dev)
1515 RTMP_ADAPTER *pAd = NULL;
1518 pAd = net_dev->ml_priv;
1523 pAd->stats.rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
1524 pAd->stats.tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
1526 pAd->stats.rx_bytes = pAd->RalinkCounters.ReceivedByteCount;
1527 pAd->stats.tx_bytes = pAd->RalinkCounters.TransmittedByteCount;
1529 pAd->stats.rx_errors = pAd->Counters8023.RxErrors;
1530 pAd->stats.tx_errors = pAd->Counters8023.TxErrors;
1532 pAd->stats.rx_dropped = 0;
1533 pAd->stats.tx_dropped = 0;
1535 pAd->stats.multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; // multicast packets received
1536 pAd->stats.collisions = pAd->Counters8023.OneCollision + pAd->Counters8023.MoreCollisions; // Collision packets
1538 pAd->stats.rx_length_errors = 0;
1539 pAd->stats.rx_over_errors = pAd->Counters8023.RxNoBuffer; // receiver ring buff overflow
1540 pAd->stats.rx_crc_errors = 0;//pAd->WlanCounters.FCSErrorCount; // recved pkt with crc error
1541 pAd->stats.rx_frame_errors = pAd->Counters8023.RcvAlignmentErrors; // recv'd frame alignment error
1542 pAd->stats.rx_fifo_errors = pAd->Counters8023.RxNoBuffer; // recv'r fifo overrun
1543 pAd->stats.rx_missed_errors = 0; // receiver missed packet
1545 // detailed tx_errors
1546 pAd->stats.tx_aborted_errors = 0;
1547 pAd->stats.tx_carrier_errors = 0;
1548 pAd->stats.tx_fifo_errors = 0;
1549 pAd->stats.tx_heartbeat_errors = 0;
1550 pAd->stats.tx_window_errors = 0;
1553 pAd->stats.rx_compressed = 0;
1554 pAd->stats.tx_compressed = 0;