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
220 #endif // WDS_SUPPORT //
222 #ifdef CONFIG_STA_SUPPORT
223 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
225 // If dirver doesn't wake up firmware here,
226 // NICLoadFirmware will hang forever when interface is up again.
227 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) ||
228 RTMP_SET_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND) ||
229 RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))
231 AsicForceWakeup(pAd, RTMP_HALT);
234 #ifdef QOS_DLS_SUPPORT
235 // send DLS-TEAR_DOWN message,
236 if (pAd->CommonCfg.bDLSCapable)
240 // tear down local dls table entry
241 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
243 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
245 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
246 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
247 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
251 // tear down peer dls table entry
252 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
254 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
256 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
257 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
258 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
261 RT28XX_MLME_HANDLER(pAd);
263 #endif // QOS_DLS_SUPPORT //
266 (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
268 MLME_DISASSOC_REQ_STRUCT DisReq;
269 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
271 COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid);
272 DisReq.Reason = REASON_DEAUTH_STA_LEAVING;
274 MsgElem->Machine = ASSOC_STATE_MACHINE;
275 MsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
276 MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
277 NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
279 // Prevent to connect AP again in STAMlmePeriodicExec
280 pAd->MlmeAux.AutoReconnectSsidLen= 32;
281 NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
283 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
284 MlmeDisassocReqAction(pAd, MsgElem);
292 RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &Cancelled);
295 RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled);
296 RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled);
298 #ifdef WPA_SUPPLICANT_SUPPORT
299 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
301 union iwreq_data wrqu;
302 // send wireless event to wpa_supplicant for infroming interface down.
303 memset(&wrqu, 0, sizeof(wrqu));
304 wrqu.data.flags = RT_INTERFACE_DOWN;
305 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
307 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
308 #endif // WPA_SUPPLICANT_SUPPORT //
311 pAd->bPCIclkOff = FALSE;
313 #endif // CONFIG_STA_SUPPORT //
315 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
317 for (i = 0 ; i < NUM_OF_TX_RING; i++)
319 while (pAd->DeQueueRunning[i] == TRUE)
321 printk("Waiting for TxQueue[%d] done..........\n", i);
326 // Stop Mlme state machine
329 // Close kernel threads or tasklets
330 kill_thread_task(pAd);
333 #ifdef CONFIG_STA_SUPPORT
334 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
338 #endif // CONFIG_STA_SUPPORT //
341 MeasureReqTabExit(pAd);
345 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
347 NICDisableInterrupt(pAd);
350 // Disable Rx, register value supposed will remain after reset
354 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
356 // Deregister interrupt function
357 RT28XX_IRQ_RELEASE(net_dev)
358 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
362 // Free Ring or USB buffers
363 RTMPFreeTxRxRingMemory(pAd);
365 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
367 #ifdef DOT11_N_SUPPORT
368 // Free BA reorder resource
369 ba_reordering_resource_release(pAd);
370 #endif // DOT11_N_SUPPORT //
373 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
375 return 0; // close ok
376 } /* End of rt28xx_close */
378 static int rt28xx_init(IN struct net_device *net_dev)
380 PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)net_dev->ml_priv;
387 #ifdef DOT11_N_SUPPORT
388 // Allocate BA Reordering memory
389 ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM);
390 #endif // DOT11_N_SUPPORT //
392 // Make sure MAC gets ready.
396 RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
397 pAd->MACVersion = MacCsr0;
399 if ((pAd->MACVersion != 0x00) && (pAd->MACVersion != 0xFFFFFFFF))
403 } while (index++ < 100);
405 DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
408 RT28XXDMADisable(pAd);
411 // Load 8051 firmware
412 Status = NICLoadFirmware(pAd);
413 if (Status != NDIS_STATUS_SUCCESS)
415 DBGPRINT_ERR(("NICLoadFirmware failed, Status[=0x%08x]\n", Status));
419 NICLoadRateSwitchingParams(pAd);
421 // Disable interrupts here which is as soon as possible
422 // This statement should never be true. We might consider to remove it later
423 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
425 NICDisableInterrupt(pAd);
428 Status = RTMPAllocTxRxRingMemory(pAd);
429 if (Status != NDIS_STATUS_SUCCESS)
431 DBGPRINT_ERR(("RTMPAllocDMAMemory failed, Status[=0x%08x]\n", Status));
435 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
440 Status = MlmeInit(pAd);
441 if (Status != NDIS_STATUS_SUCCESS)
443 DBGPRINT_ERR(("MlmeInit failed, Status[=0x%08x]\n", Status));
447 // Initialize pAd->StaCfg, pAd->ApCfg, pAd->CommonCfg to manufacture default
452 RT28XX_TASK_THREAD_INIT(pAd, Status);
453 if (Status != NDIS_STATUS_SUCCESS)
460 initblockQueueTab(pAd);
461 #endif // BLOCK_NET_IF //
463 #ifdef CONFIG_STA_SUPPORT
464 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
465 NdisAllocateSpinLock(&pAd->MacTabLock);
466 #endif // CONFIG_STA_SUPPORT //
468 MeasureReqTabInit(pAd);
472 // Init the hardware, we need to init asic before read registry, otherwise mac register will be reset
474 Status = NICInitializeAdapter(pAd, TRUE);
475 if (Status != NDIS_STATUS_SUCCESS)
477 DBGPRINT_ERR(("NICInitializeAdapter failed, Status[=0x%08x]\n", Status));
478 if (Status != NDIS_STATUS_SUCCESS)
482 // Read parameters from Config File
483 Status = RTMPReadParametersHook(pAd);
485 printk("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
486 if (Status != NDIS_STATUS_SUCCESS)
488 DBGPRINT_ERR(("NICReadRegParameters failed, Status[=0x%08x]\n",Status));
494 //Init Ba Capability parameters.
495 #ifdef DOT11_N_SUPPORT
496 pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
497 pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
498 pAd->CommonCfg.DesiredHtPhy.AmsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
499 pAd->CommonCfg.DesiredHtPhy.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
501 pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
502 pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
503 pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
504 #endif // DOT11_N_SUPPORT //
506 printk("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
508 // We should read EEPROM for all cases. rt2860b
509 NICReadEEPROMParameters(pAd, mac);
511 printk("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
513 NICInitAsicFromEEPROM(pAd); //rt2860b
515 // Set PHY to appropriate mode
516 TmpPhy = pAd->CommonCfg.PhyMode;
517 pAd->CommonCfg.PhyMode = 0xff;
518 RTMPSetPhyMode(pAd, TmpPhy);
519 #ifdef DOT11_N_SUPPORT
521 #endif // DOT11_N_SUPPORT //
523 // No valid channels.
524 if (pAd->ChannelListNum == 0)
526 printk("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n");
530 #ifdef DOT11_N_SUPPORT
531 printk("MCS Set = %02x %02x %02x %02x %02x\n", pAd->CommonCfg.HtCapability.MCSSet[0],
532 pAd->CommonCfg.HtCapability.MCSSet[1], pAd->CommonCfg.HtCapability.MCSSet[2],
533 pAd->CommonCfg.HtCapability.MCSSet[3], pAd->CommonCfg.HtCapability.MCSSet[4]);
534 #endif // DOT11_N_SUPPORT //
537 VR_IKANOS_FP_Init(pAd->ApCfg.BssidNum, pAd->PermanentAddress);
538 #endif // IKANOS_VX_1X0 //
541 // Initialize RF register to default value
543 AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
544 AsicLockChannel(pAd, pAd->CommonCfg.Channel);
546 // 8051 firmware require the signal during booting time.
547 AsicSendCommandToMcu(pAd, 0x72, 0xFF, 0x00, 0x00);
549 if (pAd && (Status != NDIS_STATUS_SUCCESS))
552 // Undo everything if it failed
554 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
556 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
561 // Microsoft HCT require driver send a disconnect event after driver initialization.
562 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
563 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
564 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n"));
570 DBGPRINT_S(Status, ("<==== RTMPInitialize, Status=%x\n", Status));
579 RTMPFreeTxRxRingMemory(pAd);
582 #ifdef DOT11_N_SUPPORT
583 os_free_mem(pAd, pAd->mpdu_blk_pool.mem); // free BA pool
584 #endif // DOT11_N_SUPPORT //
585 RT28XX_IRQ_RELEASE(net_dev);
587 // shall not set ml_priv to NULL here because the ml_priv didn't been free yet.
588 //net_dev->ml_priv = 0;
591 #endif // INF_AMAZON_SE //
592 printk("!!! %s Initialized fail !!!\n", RT28xx_CHIP_NAME);
594 } /* End of rt28xx_init */
598 ========================================================================
603 *net_dev the raxx interface pointer
610 ========================================================================
612 int rt28xx_open(IN PNET_DEV dev)
614 struct net_device * net_dev = (struct net_device *)dev;
615 PRTMP_ADAPTER pAd = net_dev->ml_priv;
620 // Sanity check for pAd
623 /* if 1st open fail, pAd will be free;
624 So the net_dev->ml_priv will be NULL in 2rd open */
628 #ifdef CONFIG_APSTA_MIXED_SUPPORT
629 if (pAd->OpMode == OPMODE_AP)
633 else if (pAd->OpMode == OPMODE_STA)
638 #if WIRELESS_EXT >= 12
639 if (net_dev->priv_flags == INT_MAIN)
641 if (pAd->OpMode == OPMODE_AP)
642 net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def;
643 else if (pAd->OpMode == OPMODE_STA)
644 net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_iw_handler_def;
646 #endif // WIRELESS_EXT >= 12 //
647 #endif // CONFIG_APSTA_MIXED_SUPPORT //
650 pObj = (POS_COOKIE)pAd->OS_Cookie;
652 // reset Adapter flags
653 RTMP_CLEAR_FLAGS(pAd);
655 // Request interrupt service routine for PCI device
656 // register the interrupt routine with the os
657 RT28XX_IRQ_REQUEST(net_dev);
660 // Init BssTab & ChannelInfo tabbles for auto channel select.
664 if (rt28xx_init(net_dev) == FALSE)
667 #ifdef CONFIG_STA_SUPPORT
668 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
670 NdisZeroMemory(pAd->StaCfg.dev_name, 16);
671 NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name));
673 #endif // CONFIG_STA_SUPPORT //
675 // Set up the Mac address
676 NdisMoveMemory(net_dev->dev_addr, (void *) pAd->CurrentAddress, 6);
678 // Init IRQ parameters
679 RT28XX_IRQ_INIT(pAd);
681 // Various AP function init
683 #ifdef CONFIG_STA_SUPPORT
684 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
686 #ifdef WPA_SUPPLICANT_SUPPORT
687 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
689 union iwreq_data wrqu;
690 // send wireless event to wpa_supplicant for infroming interface down.
691 memset(&wrqu, 0, sizeof(wrqu));
692 wrqu.data.flags = RT_INTERFACE_UP;
693 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
695 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
696 #endif // WPA_SUPPLICANT_SUPPORT //
699 #endif // CONFIG_STA_SUPPORT //
702 RT28XX_IRQ_ENABLE(pAd);
706 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP);
710 RTMP_IO_READ32(pAd, 0x1300, ®); // clear garbage interrupts
711 printk("0x1300 = %08x\n", reg);
714 #ifdef CONFIG_STA_SUPPORT
715 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
716 RTMPInitPCIeLinkCtrlValue(pAd);
717 #endif // CONFIG_STA_SUPPORT //
723 } /* End of rt28xx_open */
725 static const struct net_device_ops rt2860_netdev_ops = {
726 .ndo_open = MainVirtualIF_open,
727 .ndo_stop = MainVirtualIF_close,
728 .ndo_do_ioctl = rt28xx_ioctl,
729 .ndo_get_stats = RT28xx_get_ether_stats,
730 .ndo_validate_addr = NULL,
731 .ndo_set_mac_address = eth_mac_addr,
732 .ndo_change_mtu = eth_change_mtu,
734 .ndo_start_xmit = IKANOS_DataFramesTx,
736 .ndo_start_xmit = rt28xx_send_packets,
740 /* Must not be called for mdev and apdev */
741 static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER pAd)
745 CHAR slot_name[IFNAMSIZ];
746 struct net_device *device;
751 #ifdef CONFIG_STA_SUPPORT
752 #if WIRELESS_EXT >= 12
753 if (pAd->OpMode == OPMODE_STA)
755 dev->wireless_handlers = &rt28xx_iw_handler_def;
757 #endif //WIRELESS_EXT >= 12
758 #endif // CONFIG_STA_SUPPORT //
760 #ifdef CONFIG_APSTA_MIXED_SUPPORT
761 #if WIRELESS_EXT >= 12
762 if (pAd->OpMode == OPMODE_AP)
764 dev->wireless_handlers = &rt28xx_ap_iw_handler_def;
766 #endif //WIRELESS_EXT >= 12
767 #endif // CONFIG_APSTA_MIXED_SUPPORT //
769 #if WIRELESS_EXT < 21
770 dev->get_wireless_stats = rt28xx_get_wireless_stats;
772 dev->priv_flags = INT_MAIN;
773 dev->netdev_ops = &rt2860_netdev_ops;
774 // find available device name
775 for (i = 0; i < 8; i++)
777 #ifdef MULTIPLE_CARD_SUPPORT
778 if (pAd->MC_RowID >= 0)
779 sprintf(slot_name, "ra%02d_%d", pAd->MC_RowID, i);
781 #endif // MULTIPLE_CARD_SUPPORT //
782 sprintf(slot_name, "ra%d", i);
784 device = dev_get_by_name(dev_net(dev), slot_name);
794 DBGPRINT(RT_DEBUG_ERROR, ("No available slot name\n"));
795 Status = NDIS_STATUS_FAILURE;
799 #ifdef MULTIPLE_CARD_SUPPORT
800 if (pAd->MC_RowID >= 0)
801 sprintf(dev->name, "ra%02d_%d", pAd->MC_RowID, i);
803 #endif // MULTIPLE_CARD_SUPPORT //
804 sprintf(dev->name, "ra%d", i);
805 Status = NDIS_STATUS_SUCCESS;
813 #ifdef MULTIPLE_CARD_SUPPORT
815 ========================================================================
817 Get card profile path.
823 TRUE - Find a card profile
824 FALSE - use default profile
827 ========================================================================
829 extern INT RTMPGetKeyParameter(
835 BOOLEAN RTMP_CardInfoRead(
836 IN PRTMP_ADAPTER pAd)
838 #define MC_SELECT_CARDID 0 /* use CARD ID (0 ~ 31) to identify different cards */
839 #define MC_SELECT_MAC 1 /* use CARD MAC to identify different cards */
840 #define MC_SELECT_CARDTYPE 2 /* use CARD type (abgn or bgn) to identify different cards */
842 #define LETTER_CASE_TRANSLATE(txt_p, card_id) \
843 { UINT32 _len; char _char; \
844 for(_len=0; _len<strlen(card_id); _len++) { \
845 _char = *(txt_p + _len); \
846 if (('A' <= _char) && (_char <= 'Z')) \
847 *(txt_p+_len) = 'a'+(_char-'A'); \
851 INT retval, orgfsuid, orgfsgid;
853 CHAR *buffer, *tmpbuf, card_id_buf[30], RFIC_word[30];
854 BOOLEAN flg_match_ok = FALSE;
855 INT32 card_select_method;
856 INT32 card_free_id, card_nouse_id, card_same_mac_id, card_match_id;
857 EEPROM_ANTENNA_STRUC antenna;
858 USHORT addr01, addr23, addr45;
860 UINT32 data, card_index;
865 buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
869 tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
873 return NDIS_STATUS_FAILURE;
876 orgfsuid = current->fsuid;
877 orgfsgid = current->fsgid;
878 current->fsuid = current->fsgid = 0;
883 RTMP_IO_READ32(pAd, E2PROM_CSR, &data);
885 if ((data & 0x30) == 0)
886 pAd->EEPROMAddressNum = 6; // 93C46
887 else if ((data & 0x30) == 0x10)
888 pAd->EEPROMAddressNum = 8; // 93C66
890 pAd->EEPROMAddressNum = 8; // 93C86
892 RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, antenna.word);
894 if ((antenna.field.RfIcType == RFIC_2850) ||
895 (antenna.field.RfIcType == RFIC_2750))
898 strcpy(RFIC_word, "abgn");
903 strcpy(RFIC_word, "bgn");
907 RT28xx_EEPROM_READ16(pAd, 0x04, addr01);
908 RT28xx_EEPROM_READ16(pAd, 0x06, addr23);
909 RT28xx_EEPROM_READ16(pAd, 0x08, addr45);
911 mac[0] = (UCHAR)(addr01 & 0xff);
912 mac[1] = (UCHAR)(addr01 >> 8);
913 mac[2] = (UCHAR)(addr23 & 0xff);
914 mac[3] = (UCHAR)(addr23 >> 8);
915 mac[4] = (UCHAR)(addr45 & 0xff);
916 mac[5] = (UCHAR)(addr45 >> 8);
918 // open card information file
919 srcf = filp_open(CARD_INFO_PATH, O_RDONLY, 0);
922 /* card information file does not exist */
923 DBGPRINT(RT_DEBUG_TRACE,
924 ("--> Error %ld opening %s\n", -PTR_ERR(srcf), CARD_INFO_PATH));
928 if (srcf->f_op && srcf->f_op->read)
930 /* card information file exists so reading the card information */
931 memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
932 retval = srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
936 DBGPRINT(RT_DEBUG_TRACE,
937 ("--> Read %s error %d\n", CARD_INFO_PATH, -retval));
941 /* get card selection method */
942 memset(tmpbuf, 0x00, MAX_PARAM_BUFFER_SIZE);
943 card_select_method = MC_SELECT_CARDTYPE; // default
945 if (RTMPGetKeyParameter("SELECT", tmpbuf, 256, buffer))
947 if (strcmp(tmpbuf, "CARDID") == 0)
948 card_select_method = MC_SELECT_CARDID;
949 else if (strcmp(tmpbuf, "MAC") == 0)
950 card_select_method = MC_SELECT_MAC;
951 else if (strcmp(tmpbuf, "CARDTYPE") == 0)
952 card_select_method = MC_SELECT_CARDTYPE;
955 DBGPRINT(RT_DEBUG_TRACE,
956 ("MC> Card Selection = %d\n", card_select_method));
961 card_same_mac_id = -1;
964 // search current card information records
966 card_index<MAX_NUM_OF_MULTIPLE_CARD;
969 if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
970 (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
972 // MAC is all-0 so the entry is available
973 MC_CardUsed[card_index] = 0;
975 if (card_free_id < 0)
976 card_free_id = card_index; // 1st free entry
980 if (memcmp(MC_CardMac[card_index], mac, 6) == 0)
982 // we find the entry with same MAC
983 if (card_same_mac_id < 0)
984 card_same_mac_id = card_index; // 1st same entry
988 // MAC is not all-0 but used flag == 0
989 if ((MC_CardUsed[card_index] == 0) &&
992 card_nouse_id = card_index; // 1st available entry
998 DBGPRINT(RT_DEBUG_TRACE,
999 ("MC> Free = %d, Same = %d, NOUSE = %d\n",
1000 card_free_id, card_same_mac_id, card_nouse_id));
1002 if ((card_same_mac_id >= 0) &&
1003 ((card_select_method == MC_SELECT_CARDID) ||
1004 (card_select_method == MC_SELECT_CARDTYPE)))
1006 // same MAC entry is found
1007 card_match_id = card_same_mac_id;
1009 if (card_select_method == MC_SELECT_CARDTYPE)
1012 sprintf(card_id_buf, "%02dCARDTYPE%s",
1013 card_match_id, RFIC_word);
1015 if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
1017 // we found the card ID
1018 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
1024 // the card is 1st plug-in, try to find the match card profile
1025 switch(card_select_method)
1027 case MC_SELECT_CARDID: // CARDID
1029 if (card_free_id >= 0)
1030 card_match_id = card_free_id;
1032 card_match_id = card_nouse_id;
1035 case MC_SELECT_MAC: // MAC
1036 sprintf(card_id_buf, "MAC%02x:%02x:%02x:%02x:%02x:%02x",
1037 mac[0], mac[1], mac[2],
1038 mac[3], mac[4], mac[5]);
1040 /* try to find the key word in the card file */
1041 if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
1043 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
1045 /* get the row ID (2 ASCII characters) */
1047 card_id_buf[0] = *(start_ptr);
1048 card_id_buf[1] = *(start_ptr+1);
1049 card_id_buf[2] = 0x00;
1051 card_match_id = simple_strtol(card_id_buf, 0, 10);
1055 case MC_SELECT_CARDTYPE: // CARDTYPE
1059 card_index<MAX_NUM_OF_MULTIPLE_CARD;
1062 sprintf(card_id_buf, "%02dCARDTYPE%s",
1063 card_index, RFIC_word);
1065 if ((start_ptr=rtstrstruncasecmp(buffer,
1066 card_id_buf)) != NULL)
1068 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
1070 if (MC_CardUsed[card_index] == 0)
1072 /* current the card profile is not used */
1073 if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
1074 (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
1076 // find it and no previous card use it
1077 card_match_id = card_index;
1082 // ever a card use it
1083 if (card_nouse_id < 0)
1084 card_nouse_id = card_index;
1090 // if not find a free one, use the available one
1091 if (card_match_id < 0)
1092 card_match_id = card_nouse_id;
1097 if (card_match_id >= 0)
1099 // make up search keyword
1100 switch(card_select_method)
1102 case MC_SELECT_CARDID: // CARDID
1103 sprintf(card_id_buf, "%02dCARDID", card_match_id);
1106 case MC_SELECT_MAC: // MAC
1107 sprintf(card_id_buf,
1108 "%02dmac%02x:%02x:%02x:%02x:%02x:%02x",
1110 mac[0], mac[1], mac[2],
1111 mac[3], mac[4], mac[5]);
1114 case MC_SELECT_CARDTYPE: // CARDTYPE
1116 sprintf(card_id_buf, "%02dcardtype%s",
1117 card_match_id, RFIC_word);
1121 DBGPRINT(RT_DEBUG_TRACE, ("Search Keyword = %s\n", card_id_buf));
1123 // read card file path
1124 if (RTMPGetKeyParameter(card_id_buf, tmpbuf, 256, buffer))
1126 if (strlen(tmpbuf) < sizeof(pAd->MC_FileName))
1128 // backup card information
1129 pAd->MC_RowID = card_match_id; /* base 0 */
1130 MC_CardUsed[card_match_id] = 1;
1131 memcpy(MC_CardMac[card_match_id], mac, sizeof(mac));
1133 // backup card file path
1134 NdisMoveMemory(pAd->MC_FileName, tmpbuf , strlen(tmpbuf));
1135 pAd->MC_FileName[strlen(tmpbuf)] = '\0';
1136 flg_match_ok = TRUE;
1138 DBGPRINT(RT_DEBUG_TRACE,
1139 ("Card Profile Name = %s\n", pAd->MC_FileName));
1143 DBGPRINT(RT_DEBUG_ERROR,
1144 ("Card Profile Name length too large!\n"));
1149 DBGPRINT(RT_DEBUG_ERROR,
1150 ("Can not find search key word in card.dat!\n"));
1153 if ((flg_match_ok != TRUE) &&
1154 (card_match_id < MAX_NUM_OF_MULTIPLE_CARD))
1156 MC_CardUsed[card_match_id] = 0;
1157 memset(MC_CardMac[card_match_id], 0, sizeof(mac));
1159 } // if (card_match_id >= 0)
1164 retval = filp_close(srcf, NULL);
1166 current->fsuid = orgfsuid;
1167 current->fsgid = orgfsgid;
1170 return flg_match_ok;
1172 #endif // MULTIPLE_CARD_SUPPORT //
1176 ========================================================================
1177 Routine Description:
1178 Probe RT28XX chipset.
1181 _dev_p Point to the PCI or USB device
1182 _dev_id_p Point to the PCI or USB device ID
1189 ========================================================================
1191 INT __devinit rt28xx_probe(
1195 OUT PRTMP_ADAPTER *ppAd)
1197 struct net_device *net_dev;
1198 PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) NULL;
1201 struct pci_dev *dev_p = (struct pci_dev *)_dev_p;
1204 #ifdef CONFIG_STA_SUPPORT
1205 DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION));
1206 #endif // CONFIG_STA_SUPPORT //
1208 net_dev = alloc_etherdev(sizeof(PRTMP_ADAPTER));
1209 if (net_dev == NULL)
1211 printk("alloc_netdev failed\n");
1216 netif_stop_queue(net_dev);
1217 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
1218 /* for supporting Network Manager */
1219 /* Set the sysfs physical device reference for the network logical device
1220 * if set prior to registration will cause a symlink during initialization.
1222 SET_NETDEV_DEV(net_dev, &(dev_p->dev));
1223 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
1225 // Allocate RTMP_ADAPTER miniport adapter structure
1226 handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
1227 RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p);
1229 status = RTMPAllocAdapterBlock(handle, &pAd);
1230 if (status != NDIS_STATUS_SUCCESS)
1231 goto err_out_free_netdev;
1233 net_dev->ml_priv = (PVOID)pAd;
1234 pAd->net_dev = net_dev; // must be before RT28XXNetDevInit()
1236 RT28XXNetDevInit(_dev_p, net_dev, pAd);
1238 #ifdef CONFIG_STA_SUPPORT
1239 pAd->StaCfg.OriDevType = net_dev->type;
1240 #endif // CONFIG_STA_SUPPORT //
1243 if (RT28XXProbePostConfig(_dev_p, pAd, 0) == FALSE)
1246 #ifdef CONFIG_STA_SUPPORT
1247 pAd->OpMode = OPMODE_STA;
1248 #endif // CONFIG_STA_SUPPORT //
1251 #ifdef MULTIPLE_CARD_SUPPORT
1252 // find its profile path
1253 pAd->MC_RowID = -1; // use default profile path
1254 RTMP_CardInfoRead(pAd);
1256 if (pAd->MC_RowID == -1)
1257 #ifdef CONFIG_STA_SUPPORT
1258 strcpy(pAd->MC_FileName, STA_PROFILE_PATH);
1259 #endif // CONFIG_STA_SUPPORT //
1261 DBGPRINT(RT_DEBUG_TRACE,
1262 ("MC> ROW = %d, PATH = %s\n", pAd->MC_RowID, pAd->MC_FileName));
1263 #endif // MULTIPLE_CARD_SUPPORT //
1266 if (rt_ieee80211_if_setup(net_dev, pAd) != NDIS_STATUS_SUCCESS)
1269 // Register this device
1270 status = register_netdev(net_dev);
1275 RT28XX_DRVDATA_SET(_dev_p);
1278 return 0; // probe ok
1281 /* --------------------------- ERROR HANDLE --------------------------- */
1283 RTMPFreeAdapter(pAd);
1286 err_out_free_netdev:
1287 free_netdev(net_dev);
1290 RT28XX_PUT_DEVICE(dev_p);
1292 return -ENODEV; /* probe fail */
1293 } /* End of rt28xx_probe */
1297 ========================================================================
1298 Routine Description:
1299 The entry point for Linux kernel sent packet to our driver.
1302 sk_buff *skb the pointer refer to a sk_buffer.
1308 This function is the entry point of Tx Path for Os delivery packet to
1309 our driver. You only can put OS-depened & STA/AP common handle procedures
1311 ========================================================================
1313 int rt28xx_packet_xmit(struct sk_buff *skb)
1315 struct net_device *net_dev = skb->dev;
1316 PRTMP_ADAPTER pAd = net_dev->ml_priv;
1318 PNDIS_PACKET pPacket = (PNDIS_PACKET) skb;
1320 /* RT2870STA does this in RTMPSendPackets() */
1324 RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_RESOURCES);
1327 #endif // RALINK_ATE //
1329 #ifdef CONFIG_STA_SUPPORT
1330 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1332 // Drop send request since we are in monitor mode
1333 if (MONITOR_ON(pAd))
1335 RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
1339 #endif // CONFIG_STA_SUPPORT //
1341 // EapolStart size is 18
1344 //printk("bad packet size: %d\n", pkt->len);
1345 hex_dump("bad packet", skb->data, skb->len);
1346 RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
1350 RTMP_SET_PACKET_5VT(pPacket, 0);
1351 #ifdef CONFIG_5VT_ENHANCE
1352 if (*(int*)(skb->cb) == BRIDGE_TAG) {
1353 RTMP_SET_PACKET_5VT(pPacket, 1);
1359 #ifdef CONFIG_STA_SUPPORT
1360 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1363 STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1);
1366 #endif // CONFIG_STA_SUPPORT //
1376 ========================================================================
1377 Routine Description:
1378 Send a packet to WLAN.
1381 skb_p points to our adapter
1382 dev_p which WLAN network interface
1385 0: transmit successfully
1386 otherwise: transmit fail
1389 ========================================================================
1391 INT rt28xx_send_packets(
1392 IN struct sk_buff *skb_p,
1393 IN struct net_device *net_dev)
1395 RTMP_ADAPTER *pAd = net_dev->ml_priv;
1396 if (!(net_dev->flags & IFF_UP))
1398 RELEASE_NDIS_PACKET(pAd, (PNDIS_PACKET)skb_p, NDIS_STATUS_FAILURE);
1402 NdisZeroMemory((PUCHAR)&skb_p->cb[CB_OFF], 15);
1403 RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID);
1405 return rt28xx_packet_xmit(skb_p);
1407 } /* End of MBSS_VirtualIF_PacketSend */
1412 void CfgInitHook(PRTMP_ADAPTER pAd)
1414 pAd->bBroadComHT = TRUE;
1415 } /* End of CfgInitHook */
1418 #if WIRELESS_EXT >= 12
1419 // This function will be called when query /proc
1420 struct iw_statistics *rt28xx_get_wireless_stats(
1421 IN struct net_device *net_dev)
1423 PRTMP_ADAPTER pAd = net_dev->ml_priv;
1426 DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
1428 pAd->iw_stats.status = 0; // Status - device dependent for now
1431 pAd->iw_stats.qual.qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10);
1432 if(pAd->iw_stats.qual.qual > 100)
1433 pAd->iw_stats.qual.qual = 100;
1435 #ifdef CONFIG_STA_SUPPORT
1436 if (pAd->OpMode == OPMODE_STA)
1437 pAd->iw_stats.qual.level = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
1438 #endif // CONFIG_STA_SUPPORT //
1440 pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; // noise level (dBm)
1442 pAd->iw_stats.qual.noise += 256 - 143;
1443 pAd->iw_stats.qual.updated = 1; // Flags to know if updated
1445 pAd->iw_stats.qual.updated |= IW_QUAL_DBM; // Level + Noise are dBm
1446 #endif // IW_QUAL_DBM //
1448 pAd->iw_stats.discard.nwid = 0; // Rx : Wrong nwid/essid
1449 pAd->iw_stats.miss.beacon = 0; // Missed beacons/superframe
1451 DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
1452 return &pAd->iw_stats;
1453 } /* End of rt28xx_get_wireless_stats */
1454 #endif // WIRELESS_EXT //
1458 void tbtt_tasklet(unsigned long data)
1460 #define MAX_TX_IN_TBTT (16)
1465 IN struct net_device *net_dev,
1466 IN OUT struct ifreq *rq,
1469 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1470 RTMP_ADAPTER *pAd = NULL;
1473 if (net_dev->priv_flags == INT_MAIN)
1475 pAd = net_dev->ml_priv;
1479 pVirtualAd = net_dev->ml_priv;
1480 pAd = pVirtualAd->RtmpDev->ml_priv;
1485 /* if 1st open fail, pAd will be free;
1486 So the net_dev->ml_priv will be NULL in 2rd open */
1491 #ifdef CONFIG_STA_SUPPORT
1492 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1494 ret = rt28xx_sta_ioctl(net_dev, rq, cmd);
1496 #endif // CONFIG_STA_SUPPORT //
1502 ========================================================================
1504 Routine Description:
1505 return ethernet statistics counter
1508 net_dev Pointer to net_device
1515 ========================================================================
1517 struct net_device_stats *RT28xx_get_ether_stats(
1518 IN struct net_device *net_dev)
1520 RTMP_ADAPTER *pAd = NULL;
1523 pAd = net_dev->ml_priv;
1528 pAd->stats.rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
1529 pAd->stats.tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
1531 pAd->stats.rx_bytes = pAd->RalinkCounters.ReceivedByteCount;
1532 pAd->stats.tx_bytes = pAd->RalinkCounters.TransmittedByteCount;
1534 pAd->stats.rx_errors = pAd->Counters8023.RxErrors;
1535 pAd->stats.tx_errors = pAd->Counters8023.TxErrors;
1537 pAd->stats.rx_dropped = 0;
1538 pAd->stats.tx_dropped = 0;
1540 pAd->stats.multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; // multicast packets received
1541 pAd->stats.collisions = pAd->Counters8023.OneCollision + pAd->Counters8023.MoreCollisions; // Collision packets
1543 pAd->stats.rx_length_errors = 0;
1544 pAd->stats.rx_over_errors = pAd->Counters8023.RxNoBuffer; // receiver ring buff overflow
1545 pAd->stats.rx_crc_errors = 0;//pAd->WlanCounters.FCSErrorCount; // recved pkt with crc error
1546 pAd->stats.rx_frame_errors = pAd->Counters8023.RcvAlignmentErrors; // recv'd frame alignment error
1547 pAd->stats.rx_fifo_errors = pAd->Counters8023.RxNoBuffer; // recv'r fifo overrun
1548 pAd->stats.rx_missed_errors = 0; // receiver missed packet
1550 // detailed tx_errors
1551 pAd->stats.tx_aborted_errors = 0;
1552 pAd->stats.tx_carrier_errors = 0;
1553 pAd->stats.tx_fifo_errors = 0;
1554 pAd->stats.tx_heartbeat_errors = 0;
1555 pAd->stats.tx_window_errors = 0;
1558 pAd->stats.rx_compressed = 0;
1559 pAd->stats.tx_compressed = 0;