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);
75 extern void init_thread_task(PRTMP_ADAPTER pAd);
78 // public function prototype
79 INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
80 IN UINT argc, OUT PRTMP_ADAPTER *ppAd);
82 // private function prototype
83 static int rt28xx_init(IN struct net_device *net_dev);
84 INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev);
86 static void CfgInitHook(PRTMP_ADAPTER pAd);
88 #ifdef CONFIG_STA_SUPPORT
89 extern const struct iw_handler_def rt28xx_iw_handler_def;
90 #endif // CONFIG_STA_SUPPORT //
92 #ifdef CONFIG_APSTA_MIXED_SUPPORT
93 extern const struct iw_handler_def rt28xx_ap_iw_handler_def;
94 #endif // CONFIG_APSTA_MIXED_SUPPORT //
96 #if WIRELESS_EXT >= 12
97 // This function will be called when query /proc
98 struct iw_statistics *rt28xx_get_wireless_stats(
99 IN struct net_device *net_dev);
102 struct net_device_stats *RT28xx_get_ether_stats(
103 IN struct net_device *net_dev);
106 ========================================================================
108 Close raxx interface.
111 *net_dev the raxx interface pointer
118 1. if open fail, kernel will not call the close function.
120 (1) Mlme Memory Handler: MlmeHalt()
121 (2) TX & RX: RTMPFreeTxRxRingMemory()
122 (3) BA Reordering: ba_reordering_resource_release()
123 ========================================================================
125 int MainVirtualIF_close(IN struct net_device *net_dev)
127 RTMP_ADAPTER *pAd = net_dev->ml_priv;
129 // Sanity check for pAd
131 return 0; // close ok
133 netif_carrier_off(pAd->net_dev);
134 netif_stop_queue(pAd->net_dev);
137 VIRTUAL_IF_DOWN(pAd);
139 RT_MOD_DEC_USE_COUNT();
141 return 0; // close ok
145 ========================================================================
150 *net_dev the raxx interface pointer
157 1. if open fail, kernel will not call the close function.
159 (1) Mlme Memory Handler: MlmeHalt()
160 (2) TX & RX: RTMPFreeTxRxRingMemory()
161 (3) BA Reordering: ba_reordering_resource_release()
162 ========================================================================
164 int MainVirtualIF_open(IN struct net_device *net_dev)
166 RTMP_ADAPTER *pAd = net_dev->ml_priv;
168 // Sanity check for pAd
170 return 0; // close ok
172 if (VIRTUAL_IF_UP(pAd) != 0)
175 // increase MODULE use count
176 RT_MOD_INC_USE_COUNT();
178 netif_start_queue(net_dev);
179 netif_carrier_on(net_dev);
180 netif_wake_queue(net_dev);
186 ========================================================================
188 Close raxx interface.
191 *net_dev the raxx interface pointer
198 1. if open fail, kernel will not call the close function.
200 (1) Mlme Memory Handler: MlmeHalt()
201 (2) TX & RX: RTMPFreeTxRxRingMemory()
202 (3) BA Reordering: ba_reordering_resource_release()
203 ========================================================================
205 int rt28xx_close(IN PNET_DEV dev)
207 struct net_device * net_dev = (struct net_device *)dev;
208 RTMP_ADAPTER *pAd = net_dev->ml_priv;
209 BOOLEAN Cancelled = FALSE;
213 DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
215 // Sanity check for pAd
217 return 0; // close ok
222 #endif // WDS_SUPPORT //
224 #ifdef CONFIG_STA_SUPPORT
225 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
228 RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_CLOSE);
231 // If dirver doesn't wake up firmware here,
232 // NICLoadFirmware will hang forever when interface is up again.
233 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
235 AsicForceWakeup(pAd, TRUE);
238 #ifdef QOS_DLS_SUPPORT
239 // send DLS-TEAR_DOWN message,
240 if (pAd->CommonCfg.bDLSCapable)
244 // tear down local dls table entry
245 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
247 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
249 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
250 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
251 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
255 // tear down peer dls table entry
256 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
258 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
260 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
261 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
262 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
265 RT28XX_MLME_HANDLER(pAd);
267 #endif // QOS_DLS_SUPPORT //
270 (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
272 MLME_DISASSOC_REQ_STRUCT DisReq;
273 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
275 COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid);
276 DisReq.Reason = REASON_DEAUTH_STA_LEAVING;
278 MsgElem->Machine = ASSOC_STATE_MACHINE;
279 MsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
280 MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
281 NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
283 // Prevent to connect AP again in STAMlmePeriodicExec
284 pAd->MlmeAux.AutoReconnectSsidLen= 32;
285 NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
287 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
288 MlmeDisassocReqAction(pAd, MsgElem);
296 RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &Cancelled);
299 RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled);
300 RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled);
302 #ifdef WPA_SUPPLICANT_SUPPORT
303 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
305 union iwreq_data wrqu;
306 // send wireless event to wpa_supplicant for infroming interface down.
307 memset(&wrqu, 0, sizeof(wrqu));
308 wrqu.data.flags = RT_INTERFACE_DOWN;
309 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
311 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
312 #endif // WPA_SUPPLICANT_SUPPORT //
316 pAd->bPCIclkOff = FALSE;
319 #endif // CONFIG_STA_SUPPORT //
321 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
323 for (i = 0 ; i < NUM_OF_TX_RING; i++)
325 while (pAd->DeQueueRunning[i] == TRUE)
327 printk("Waiting for TxQueue[%d] done..........\n", i);
332 // Stop Mlme state machine
335 // Close kernel threads or tasklets
336 kill_thread_task(pAd);
339 #ifdef CONFIG_STA_SUPPORT
340 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
344 #endif // CONFIG_STA_SUPPORT //
347 MeasureReqTabExit(pAd);
352 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
354 NICDisableInterrupt(pAd);
357 // Disable Rx, register value supposed will remain after reset
361 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
363 // Deregister interrupt function
364 RT28XX_IRQ_RELEASE(net_dev)
365 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
370 // Free Ring or USB buffers
371 RTMPFreeTxRxRingMemory(pAd);
373 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
375 #ifdef DOT11_N_SUPPORT
376 // Free BA reorder resource
377 ba_reordering_resource_release(pAd);
378 #endif // DOT11_N_SUPPORT //
381 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
383 return 0; // close ok
384 } /* End of rt28xx_close */
386 static int rt28xx_init(IN struct net_device *net_dev)
388 PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)net_dev->ml_priv;
395 #ifdef DOT11_N_SUPPORT
396 // Allocate BA Reordering memory
397 ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM);
398 #endif // DOT11_N_SUPPORT //
400 // Make sure MAC gets ready.
404 RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
405 pAd->MACVersion = MacCsr0;
407 if ((pAd->MACVersion != 0x00) && (pAd->MACVersion != 0xFFFFFFFF))
411 } while (index++ < 100);
413 DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
416 RT28XXDMADisable(pAd);
419 // Load 8051 firmware
420 Status = NICLoadFirmware(pAd);
421 if (Status != NDIS_STATUS_SUCCESS)
423 DBGPRINT_ERR(("NICLoadFirmware failed, Status[=0x%08x]\n", Status));
427 NICLoadRateSwitchingParams(pAd);
429 // Disable interrupts here which is as soon as possible
430 // This statement should never be true. We might consider to remove it later
432 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
434 NICDisableInterrupt(pAd);
438 Status = RTMPAllocTxRxRingMemory(pAd);
439 if (Status != NDIS_STATUS_SUCCESS)
441 DBGPRINT_ERR(("RTMPAllocDMAMemory failed, Status[=0x%08x]\n", Status));
445 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
450 Status = MlmeInit(pAd);
451 if (Status != NDIS_STATUS_SUCCESS)
453 DBGPRINT_ERR(("MlmeInit failed, Status[=0x%08x]\n", Status));
457 // Initialize pAd->StaCfg, pAd->ApCfg, pAd->CommonCfg to manufacture default
462 RT28XX_TASK_THREAD_INIT(pAd, Status);
463 if (Status != NDIS_STATUS_SUCCESS)
470 initblockQueueTab(pAd);
471 #endif // BLOCK_NET_IF //
473 #ifdef CONFIG_STA_SUPPORT
474 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
475 NdisAllocateSpinLock(&pAd->MacTabLock);
476 #endif // CONFIG_STA_SUPPORT //
478 MeasureReqTabInit(pAd);
482 // Init the hardware, we need to init asic before read registry, otherwise mac register will be reset
484 Status = NICInitializeAdapter(pAd, TRUE);
485 if (Status != NDIS_STATUS_SUCCESS)
487 DBGPRINT_ERR(("NICInitializeAdapter failed, Status[=0x%08x]\n", Status));
488 if (Status != NDIS_STATUS_SUCCESS)
492 // Read parameters from Config File
493 Status = RTMPReadParametersHook(pAd);
495 printk("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
496 if (Status != NDIS_STATUS_SUCCESS)
498 DBGPRINT_ERR(("NICReadRegParameters failed, Status[=0x%08x]\n",Status));
504 //Init Ba Capability parameters.
505 #ifdef DOT11_N_SUPPORT
506 pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
507 pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
508 pAd->CommonCfg.DesiredHtPhy.AmsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
509 pAd->CommonCfg.DesiredHtPhy.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
511 pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
512 pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
513 pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
514 #endif // DOT11_N_SUPPORT //
516 printk("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
518 // We should read EEPROM for all cases. rt2860b
519 NICReadEEPROMParameters(pAd, mac);
521 printk("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
523 NICInitAsicFromEEPROM(pAd); //rt2860b
525 // Set PHY to appropriate mode
526 TmpPhy = pAd->CommonCfg.PhyMode;
527 pAd->CommonCfg.PhyMode = 0xff;
528 RTMPSetPhyMode(pAd, TmpPhy);
529 #ifdef DOT11_N_SUPPORT
531 #endif // DOT11_N_SUPPORT //
533 // No valid channels.
534 if (pAd->ChannelListNum == 0)
536 printk("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n");
540 #ifdef DOT11_N_SUPPORT
541 printk("MCS Set = %02x %02x %02x %02x %02x\n", pAd->CommonCfg.HtCapability.MCSSet[0],
542 pAd->CommonCfg.HtCapability.MCSSet[1], pAd->CommonCfg.HtCapability.MCSSet[2],
543 pAd->CommonCfg.HtCapability.MCSSet[3], pAd->CommonCfg.HtCapability.MCSSet[4]);
544 #endif // DOT11_N_SUPPORT //
547 VR_IKANOS_FP_Init(pAd->ApCfg.BssidNum, pAd->PermanentAddress);
548 #endif // IKANOS_VX_1X0 //
551 // Initialize RF register to default value
553 AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
554 AsicLockChannel(pAd, pAd->CommonCfg.Channel);
556 // 8051 firmware require the signal during booting time.
557 AsicSendCommandToMcu(pAd, 0x72, 0xFF, 0x00, 0x00);
559 if (pAd && (Status != NDIS_STATUS_SUCCESS))
562 // Undo everything if it failed
564 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
566 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
571 // Microsoft HCT require driver send a disconnect event after driver initialization.
572 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
573 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
574 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n"));
580 DBGPRINT_S(Status, ("<==== RTMPInitialize, Status=%x\n", Status));
589 RTMPFreeTxRxRingMemory(pAd);
592 #ifdef DOT11_N_SUPPORT
593 os_free_mem(pAd, pAd->mpdu_blk_pool.mem); // free BA pool
594 #endif // DOT11_N_SUPPORT //
595 RT28XX_IRQ_RELEASE(net_dev);
597 // shall not set ml_priv to NULL here because the ml_priv didn't been free yet.
598 //net_dev->ml_priv = 0;
601 #endif // INF_AMAZON_SE //
602 printk("!!! %s Initialized fail !!!\n", RT28xx_CHIP_NAME);
604 } /* End of rt28xx_init */
608 ========================================================================
613 *net_dev the raxx interface pointer
620 ========================================================================
622 int rt28xx_open(IN PNET_DEV dev)
624 struct net_device * net_dev = (struct net_device *)dev;
625 PRTMP_ADAPTER pAd = net_dev->ml_priv;
630 // Sanity check for pAd
633 /* if 1st open fail, pAd will be free;
634 So the net_dev->ml_priv will be NULL in 2rd open */
638 #ifdef CONFIG_APSTA_MIXED_SUPPORT
639 if (pAd->OpMode == OPMODE_AP)
643 else if (pAd->OpMode == OPMODE_STA)
648 #if WIRELESS_EXT >= 12
649 if (net_dev->priv_flags == INT_MAIN)
651 if (pAd->OpMode == OPMODE_AP)
652 net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def;
653 else if (pAd->OpMode == OPMODE_STA)
654 net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_iw_handler_def;
656 #endif // WIRELESS_EXT >= 12 //
657 #endif // CONFIG_APSTA_MIXED_SUPPORT //
659 #ifdef CONFIG_STA_SUPPORT
661 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
663 // If dirver doesn't wake up firmware here,
664 // NICLoadFirmware will hang forever when interface is up again.
666 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) &&
667 OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
669 AUTO_WAKEUP_STRUC AutoWakeupCfg;
670 AsicForceWakeup(pAd, TRUE);
671 AutoWakeupCfg.word = 0;
672 RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
673 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
677 #endif // CONFIG_STA_SUPPORT //
680 pObj = (POS_COOKIE)pAd->OS_Cookie;
682 // reset Adapter flags
683 RTMP_CLEAR_FLAGS(pAd);
685 // Request interrupt service routine for PCI device
686 // register the interrupt routine with the os
687 RT28XX_IRQ_REQUEST(net_dev);
690 // Init BssTab & ChannelInfo tabbles for auto channel select.
694 if (rt28xx_init(net_dev) == FALSE)
697 #ifdef CONFIG_STA_SUPPORT
698 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
700 NdisZeroMemory(pAd->StaCfg.dev_name, 16);
701 NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name));
703 #endif // CONFIG_STA_SUPPORT //
705 // Set up the Mac address
706 NdisMoveMemory(net_dev->dev_addr, (void *) pAd->CurrentAddress, 6);
708 // Init IRQ parameters
709 RT28XX_IRQ_INIT(pAd);
711 // Various AP function init
713 #ifdef CONFIG_STA_SUPPORT
714 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
716 #ifdef WPA_SUPPLICANT_SUPPORT
717 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
719 union iwreq_data wrqu;
720 // send wireless event to wpa_supplicant for infroming interface down.
721 memset(&wrqu, 0, sizeof(wrqu));
722 wrqu.data.flags = RT_INTERFACE_UP;
723 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
725 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
726 #endif // WPA_SUPPLICANT_SUPPORT //
729 #endif // CONFIG_STA_SUPPORT //
732 RT28XX_IRQ_ENABLE(pAd);
736 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP);
740 RTMP_IO_READ32(pAd, 0x1300, ®); // clear garbage interrupts
741 printk("0x1300 = %08x\n", reg);
744 #ifdef CONFIG_STA_SUPPORT
746 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
747 RTMPInitPCIeLinkCtrlValue(pAd);
749 #endif // CONFIG_STA_SUPPORT //
755 } /* End of rt28xx_open */
758 /* Must not be called for mdev and apdev */
759 static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER pAd)
763 CHAR slot_name[IFNAMSIZ];
764 struct net_device *device;
768 dev->hard_start_xmit = rt28xx_send_packets;
771 dev->hard_start_xmit = IKANOS_DataFramesTx;
772 #endif // IKANOS_VX_1X0 //
774 #ifdef CONFIG_STA_SUPPORT
775 #if WIRELESS_EXT >= 12
776 if (pAd->OpMode == OPMODE_STA)
778 dev->wireless_handlers = &rt28xx_iw_handler_def;
780 #endif //WIRELESS_EXT >= 12
781 #endif // CONFIG_STA_SUPPORT //
783 #ifdef CONFIG_APSTA_MIXED_SUPPORT
784 #if WIRELESS_EXT >= 12
785 if (pAd->OpMode == OPMODE_AP)
787 dev->wireless_handlers = &rt28xx_ap_iw_handler_def;
789 #endif //WIRELESS_EXT >= 12
790 #endif // CONFIG_APSTA_MIXED_SUPPORT //
792 #if WIRELESS_EXT < 21
793 dev->get_wireless_stats = rt28xx_get_wireless_stats;
795 dev->get_stats = RT28xx_get_ether_stats;
796 dev->open = MainVirtualIF_open; //rt28xx_open;
797 dev->stop = MainVirtualIF_close; //rt28xx_close;
798 dev->priv_flags = INT_MAIN;
799 dev->do_ioctl = rt28xx_ioctl;
800 dev->validate_addr = NULL;
801 // find available device name
802 for (i = 0; i < 8; i++)
804 #ifdef MULTIPLE_CARD_SUPPORT
805 if (pAd->MC_RowID >= 0)
806 sprintf(slot_name, "ra%02d_%d", pAd->MC_RowID, i);
808 #endif // MULTIPLE_CARD_SUPPORT //
809 sprintf(slot_name, "ra%d", i);
811 device = dev_get_by_name(dev_net(dev), slot_name);
821 DBGPRINT(RT_DEBUG_ERROR, ("No available slot name\n"));
822 Status = NDIS_STATUS_FAILURE;
826 #ifdef MULTIPLE_CARD_SUPPORT
827 if (pAd->MC_RowID >= 0)
828 sprintf(dev->name, "ra%02d_%d", pAd->MC_RowID, i);
830 #endif // MULTIPLE_CARD_SUPPORT //
831 sprintf(dev->name, "ra%d", i);
832 Status = NDIS_STATUS_SUCCESS;
840 #ifdef MULTIPLE_CARD_SUPPORT
842 ========================================================================
844 Get card profile path.
850 TRUE - Find a card profile
851 FALSE - use default profile
854 ========================================================================
856 extern INT RTMPGetKeyParameter(
862 BOOLEAN RTMP_CardInfoRead(
863 IN PRTMP_ADAPTER pAd)
865 #define MC_SELECT_CARDID 0 /* use CARD ID (0 ~ 31) to identify different cards */
866 #define MC_SELECT_MAC 1 /* use CARD MAC to identify different cards */
867 #define MC_SELECT_CARDTYPE 2 /* use CARD type (abgn or bgn) to identify different cards */
869 #define LETTER_CASE_TRANSLATE(txt_p, card_id) \
870 { UINT32 _len; char _char; \
871 for(_len=0; _len<strlen(card_id); _len++) { \
872 _char = *(txt_p + _len); \
873 if (('A' <= _char) && (_char <= 'Z')) \
874 *(txt_p+_len) = 'a'+(_char-'A'); \
878 INT retval, orgfsuid, orgfsgid;
880 CHAR *buffer, *tmpbuf, card_id_buf[30], RFIC_word[30];
881 BOOLEAN flg_match_ok = FALSE;
882 INT32 card_select_method;
883 INT32 card_free_id, card_nouse_id, card_same_mac_id, card_match_id;
884 EEPROM_ANTENNA_STRUC antenna;
885 USHORT addr01, addr23, addr45;
887 UINT32 data, card_index;
892 buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
896 tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
900 return NDIS_STATUS_FAILURE;
903 orgfsuid = current->fsuid;
904 orgfsgid = current->fsgid;
905 current->fsuid = current->fsgid = 0;
910 RTMP_IO_READ32(pAd, E2PROM_CSR, &data);
912 if ((data & 0x30) == 0)
913 pAd->EEPROMAddressNum = 6; // 93C46
914 else if ((data & 0x30) == 0x10)
915 pAd->EEPROMAddressNum = 8; // 93C66
917 pAd->EEPROMAddressNum = 8; // 93C86
919 RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, antenna.word);
921 if ((antenna.field.RfIcType == RFIC_2850) ||
922 (antenna.field.RfIcType == RFIC_2750))
925 strcpy(RFIC_word, "abgn");
930 strcpy(RFIC_word, "bgn");
934 RT28xx_EEPROM_READ16(pAd, 0x04, addr01);
935 RT28xx_EEPROM_READ16(pAd, 0x06, addr23);
936 RT28xx_EEPROM_READ16(pAd, 0x08, addr45);
938 mac[0] = (UCHAR)(addr01 & 0xff);
939 mac[1] = (UCHAR)(addr01 >> 8);
940 mac[2] = (UCHAR)(addr23 & 0xff);
941 mac[3] = (UCHAR)(addr23 >> 8);
942 mac[4] = (UCHAR)(addr45 & 0xff);
943 mac[5] = (UCHAR)(addr45 >> 8);
945 // open card information file
946 srcf = filp_open(CARD_INFO_PATH, O_RDONLY, 0);
949 /* card information file does not exist */
950 DBGPRINT(RT_DEBUG_TRACE,
951 ("--> Error %ld opening %s\n", -PTR_ERR(srcf), CARD_INFO_PATH));
955 if (srcf->f_op && srcf->f_op->read)
957 /* card information file exists so reading the card information */
958 memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
959 retval = srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
963 DBGPRINT(RT_DEBUG_TRACE,
964 ("--> Read %s error %d\n", CARD_INFO_PATH, -retval));
968 /* get card selection method */
969 memset(tmpbuf, 0x00, MAX_PARAM_BUFFER_SIZE);
970 card_select_method = MC_SELECT_CARDTYPE; // default
972 if (RTMPGetKeyParameter("SELECT", tmpbuf, 256, buffer))
974 if (strcmp(tmpbuf, "CARDID") == 0)
975 card_select_method = MC_SELECT_CARDID;
976 else if (strcmp(tmpbuf, "MAC") == 0)
977 card_select_method = MC_SELECT_MAC;
978 else if (strcmp(tmpbuf, "CARDTYPE") == 0)
979 card_select_method = MC_SELECT_CARDTYPE;
982 DBGPRINT(RT_DEBUG_TRACE,
983 ("MC> Card Selection = %d\n", card_select_method));
988 card_same_mac_id = -1;
991 // search current card information records
993 card_index<MAX_NUM_OF_MULTIPLE_CARD;
996 if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
997 (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
999 // MAC is all-0 so the entry is available
1000 MC_CardUsed[card_index] = 0;
1002 if (card_free_id < 0)
1003 card_free_id = card_index; // 1st free entry
1007 if (memcmp(MC_CardMac[card_index], mac, 6) == 0)
1009 // we find the entry with same MAC
1010 if (card_same_mac_id < 0)
1011 card_same_mac_id = card_index; // 1st same entry
1015 // MAC is not all-0 but used flag == 0
1016 if ((MC_CardUsed[card_index] == 0) &&
1017 (card_nouse_id < 0))
1019 card_nouse_id = card_index; // 1st available entry
1025 DBGPRINT(RT_DEBUG_TRACE,
1026 ("MC> Free = %d, Same = %d, NOUSE = %d\n",
1027 card_free_id, card_same_mac_id, card_nouse_id));
1029 if ((card_same_mac_id >= 0) &&
1030 ((card_select_method == MC_SELECT_CARDID) ||
1031 (card_select_method == MC_SELECT_CARDTYPE)))
1033 // same MAC entry is found
1034 card_match_id = card_same_mac_id;
1036 if (card_select_method == MC_SELECT_CARDTYPE)
1039 sprintf(card_id_buf, "%02dCARDTYPE%s",
1040 card_match_id, RFIC_word);
1042 if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
1044 // we found the card ID
1045 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
1051 // the card is 1st plug-in, try to find the match card profile
1052 switch(card_select_method)
1054 case MC_SELECT_CARDID: // CARDID
1056 if (card_free_id >= 0)
1057 card_match_id = card_free_id;
1059 card_match_id = card_nouse_id;
1062 case MC_SELECT_MAC: // MAC
1063 sprintf(card_id_buf, "MAC%02x:%02x:%02x:%02x:%02x:%02x",
1064 mac[0], mac[1], mac[2],
1065 mac[3], mac[4], mac[5]);
1067 /* try to find the key word in the card file */
1068 if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL)
1070 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
1072 /* get the row ID (2 ASCII characters) */
1074 card_id_buf[0] = *(start_ptr);
1075 card_id_buf[1] = *(start_ptr+1);
1076 card_id_buf[2] = 0x00;
1078 card_match_id = simple_strtol(card_id_buf, 0, 10);
1082 case MC_SELECT_CARDTYPE: // CARDTYPE
1086 card_index<MAX_NUM_OF_MULTIPLE_CARD;
1089 sprintf(card_id_buf, "%02dCARDTYPE%s",
1090 card_index, RFIC_word);
1092 if ((start_ptr=rtstrstruncasecmp(buffer,
1093 card_id_buf)) != NULL)
1095 LETTER_CASE_TRANSLATE(start_ptr, card_id_buf);
1097 if (MC_CardUsed[card_index] == 0)
1099 /* current the card profile is not used */
1100 if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) &&
1101 (*(UINT16 *)&MC_CardMac[card_index][4] == 0))
1103 // find it and no previous card use it
1104 card_match_id = card_index;
1109 // ever a card use it
1110 if (card_nouse_id < 0)
1111 card_nouse_id = card_index;
1117 // if not find a free one, use the available one
1118 if (card_match_id < 0)
1119 card_match_id = card_nouse_id;
1124 if (card_match_id >= 0)
1126 // make up search keyword
1127 switch(card_select_method)
1129 case MC_SELECT_CARDID: // CARDID
1130 sprintf(card_id_buf, "%02dCARDID", card_match_id);
1133 case MC_SELECT_MAC: // MAC
1134 sprintf(card_id_buf,
1135 "%02dmac%02x:%02x:%02x:%02x:%02x:%02x",
1137 mac[0], mac[1], mac[2],
1138 mac[3], mac[4], mac[5]);
1141 case MC_SELECT_CARDTYPE: // CARDTYPE
1143 sprintf(card_id_buf, "%02dcardtype%s",
1144 card_match_id, RFIC_word);
1148 DBGPRINT(RT_DEBUG_TRACE, ("Search Keyword = %s\n", card_id_buf));
1150 // read card file path
1151 if (RTMPGetKeyParameter(card_id_buf, tmpbuf, 256, buffer))
1153 if (strlen(tmpbuf) < sizeof(pAd->MC_FileName))
1155 // backup card information
1156 pAd->MC_RowID = card_match_id; /* base 0 */
1157 MC_CardUsed[card_match_id] = 1;
1158 memcpy(MC_CardMac[card_match_id], mac, sizeof(mac));
1160 // backup card file path
1161 NdisMoveMemory(pAd->MC_FileName, tmpbuf , strlen(tmpbuf));
1162 pAd->MC_FileName[strlen(tmpbuf)] = '\0';
1163 flg_match_ok = TRUE;
1165 DBGPRINT(RT_DEBUG_TRACE,
1166 ("Card Profile Name = %s\n", pAd->MC_FileName));
1170 DBGPRINT(RT_DEBUG_ERROR,
1171 ("Card Profile Name length too large!\n"));
1176 DBGPRINT(RT_DEBUG_ERROR,
1177 ("Can not find search key word in card.dat!\n"));
1180 if ((flg_match_ok != TRUE) &&
1181 (card_match_id < MAX_NUM_OF_MULTIPLE_CARD))
1183 MC_CardUsed[card_match_id] = 0;
1184 memset(MC_CardMac[card_match_id], 0, sizeof(mac));
1186 } // if (card_match_id >= 0)
1191 retval = filp_close(srcf, NULL);
1193 current->fsuid = orgfsuid;
1194 current->fsgid = orgfsgid;
1197 return flg_match_ok;
1199 #endif // MULTIPLE_CARD_SUPPORT //
1203 ========================================================================
1204 Routine Description:
1205 Probe RT28XX chipset.
1208 _dev_p Point to the PCI or USB device
1209 _dev_id_p Point to the PCI or USB device ID
1216 ========================================================================
1218 INT __devinit rt28xx_probe(
1222 OUT PRTMP_ADAPTER *ppAd)
1224 struct net_device *net_dev;
1225 PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) NULL;
1229 struct pci_dev *dev_p = (struct pci_dev *)_dev_p;
1233 #ifdef CONFIG_STA_SUPPORT
1234 DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION));
1235 #endif // CONFIG_STA_SUPPORT //
1237 net_dev = alloc_etherdev(sizeof(PRTMP_ADAPTER));
1238 if (net_dev == NULL)
1240 printk("alloc_netdev failed\n");
1245 netif_stop_queue(net_dev);
1246 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
1247 /* for supporting Network Manager */
1248 /* Set the sysfs physical device reference for the network logical device
1249 * if set prior to registration will cause a symlink during initialization.
1251 SET_NETDEV_DEV(net_dev, &(dev_p->dev));
1252 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
1254 // Allocate RTMP_ADAPTER miniport adapter structure
1255 handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
1256 RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p);
1258 status = RTMPAllocAdapterBlock(handle, &pAd);
1259 if (status != NDIS_STATUS_SUCCESS)
1260 goto err_out_free_netdev;
1262 net_dev->ml_priv = (PVOID)pAd;
1263 pAd->net_dev = net_dev; // must be before RT28XXNetDevInit()
1265 RT28XXNetDevInit(_dev_p, net_dev, pAd);
1267 #ifdef CONFIG_STA_SUPPORT
1268 pAd->StaCfg.OriDevType = net_dev->type;
1269 #endif // CONFIG_STA_SUPPORT //
1272 if (RT28XXProbePostConfig(_dev_p, pAd, 0) == FALSE)
1275 #ifdef CONFIG_STA_SUPPORT
1276 pAd->OpMode = OPMODE_STA;
1277 #endif // CONFIG_STA_SUPPORT //
1280 #ifdef MULTIPLE_CARD_SUPPORT
1281 // find its profile path
1282 pAd->MC_RowID = -1; // use default profile path
1283 RTMP_CardInfoRead(pAd);
1285 if (pAd->MC_RowID == -1)
1286 #ifdef CONFIG_STA_SUPPORT
1287 strcpy(pAd->MC_FileName, STA_PROFILE_PATH);
1288 #endif // CONFIG_STA_SUPPORT //
1290 DBGPRINT(RT_DEBUG_TRACE,
1291 ("MC> ROW = %d, PATH = %s\n", pAd->MC_RowID, pAd->MC_FileName));
1292 #endif // MULTIPLE_CARD_SUPPORT //
1295 if (rt_ieee80211_if_setup(net_dev, pAd) != NDIS_STATUS_SUCCESS)
1298 // Register this device
1299 status = register_netdev(net_dev);
1304 RT28XX_DRVDATA_SET(_dev_p);
1307 return 0; // probe ok
1310 /* --------------------------- ERROR HANDLE --------------------------- */
1312 RTMPFreeAdapter(pAd);
1315 err_out_free_netdev:
1316 free_netdev(net_dev);
1319 RT28XX_PUT_DEVICE(dev_p);
1321 return -ENODEV; /* probe fail */
1322 } /* End of rt28xx_probe */
1326 ========================================================================
1327 Routine Description:
1328 The entry point for Linux kernel sent packet to our driver.
1331 sk_buff *skb the pointer refer to a sk_buffer.
1337 This function is the entry point of Tx Path for Os delivery packet to
1338 our driver. You only can put OS-depened & STA/AP common handle procedures
1340 ========================================================================
1342 int rt28xx_packet_xmit(struct sk_buff *skb)
1344 struct net_device *net_dev = skb->dev;
1345 PRTMP_ADAPTER pAd = net_dev->ml_priv;
1347 PNDIS_PACKET pPacket = (PNDIS_PACKET) skb;
1349 /* RT2870STA does this in RTMPSendPackets() */
1353 RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_RESOURCES);
1356 #endif // RALINK_ATE //
1358 #ifdef CONFIG_STA_SUPPORT
1359 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1361 // Drop send request since we are in monitor mode
1362 if (MONITOR_ON(pAd))
1364 RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
1368 #endif // CONFIG_STA_SUPPORT //
1370 // EapolStart size is 18
1373 //printk("bad packet size: %d\n", pkt->len);
1374 hex_dump("bad packet", skb->data, skb->len);
1375 RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
1379 RTMP_SET_PACKET_5VT(pPacket, 0);
1380 #ifdef CONFIG_5VT_ENHANCE
1381 if (*(int*)(skb->cb) == BRIDGE_TAG) {
1382 RTMP_SET_PACKET_5VT(pPacket, 1);
1388 #ifdef CONFIG_STA_SUPPORT
1389 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1392 STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1);
1395 #endif // CONFIG_STA_SUPPORT //
1405 ========================================================================
1406 Routine Description:
1407 Send a packet to WLAN.
1410 skb_p points to our adapter
1411 dev_p which WLAN network interface
1414 0: transmit successfully
1415 otherwise: transmit fail
1418 ========================================================================
1420 INT rt28xx_send_packets(
1421 IN struct sk_buff *skb_p,
1422 IN struct net_device *net_dev)
1424 RTMP_ADAPTER *pAd = net_dev->ml_priv;
1425 if (!(net_dev->flags & IFF_UP))
1427 RELEASE_NDIS_PACKET(pAd, (PNDIS_PACKET)skb_p, NDIS_STATUS_FAILURE);
1431 NdisZeroMemory((PUCHAR)&skb_p->cb[CB_OFF], 15);
1432 RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID);
1434 return rt28xx_packet_xmit(skb_p);
1436 } /* End of MBSS_VirtualIF_PacketSend */
1441 void CfgInitHook(PRTMP_ADAPTER pAd)
1443 pAd->bBroadComHT = TRUE;
1444 } /* End of CfgInitHook */
1447 #if WIRELESS_EXT >= 12
1448 // This function will be called when query /proc
1449 struct iw_statistics *rt28xx_get_wireless_stats(
1450 IN struct net_device *net_dev)
1452 PRTMP_ADAPTER pAd = net_dev->ml_priv;
1455 DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
1457 pAd->iw_stats.status = 0; // Status - device dependent for now
1460 pAd->iw_stats.qual.qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10);
1461 if(pAd->iw_stats.qual.qual > 100)
1462 pAd->iw_stats.qual.qual = 100;
1464 #ifdef CONFIG_STA_SUPPORT
1465 if (pAd->OpMode == OPMODE_STA)
1466 pAd->iw_stats.qual.level = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
1467 #endif // CONFIG_STA_SUPPORT //
1469 pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; // noise level (dBm)
1471 pAd->iw_stats.qual.noise += 256 - 143;
1472 pAd->iw_stats.qual.updated = 1; // Flags to know if updated
1474 pAd->iw_stats.qual.updated |= IW_QUAL_DBM; // Level + Noise are dBm
1475 #endif // IW_QUAL_DBM //
1477 pAd->iw_stats.discard.nwid = 0; // Rx : Wrong nwid/essid
1478 pAd->iw_stats.miss.beacon = 0; // Missed beacons/superframe
1480 DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
1481 return &pAd->iw_stats;
1482 } /* End of rt28xx_get_wireless_stats */
1483 #endif // WIRELESS_EXT //
1487 void tbtt_tasklet(unsigned long data)
1489 #define MAX_TX_IN_TBTT (16)
1494 IN struct net_device *net_dev,
1495 IN OUT struct ifreq *rq,
1498 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1499 RTMP_ADAPTER *pAd = NULL;
1502 if (net_dev->priv_flags == INT_MAIN)
1504 pAd = net_dev->ml_priv;
1508 pVirtualAd = net_dev->ml_priv;
1509 pAd = pVirtualAd->RtmpDev->ml_priv;
1514 /* if 1st open fail, pAd will be free;
1515 So the net_dev->ml_priv will be NULL in 2rd open */
1520 #ifdef CONFIG_STA_SUPPORT
1521 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
1523 ret = rt28xx_sta_ioctl(net_dev, rq, cmd);
1525 #endif // CONFIG_STA_SUPPORT //
1531 ========================================================================
1533 Routine Description:
1534 return ethernet statistics counter
1537 net_dev Pointer to net_device
1544 ========================================================================
1546 struct net_device_stats *RT28xx_get_ether_stats(
1547 IN struct net_device *net_dev)
1549 RTMP_ADAPTER *pAd = NULL;
1552 pAd = net_dev->ml_priv;
1557 pAd->stats.rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
1558 pAd->stats.tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
1560 pAd->stats.rx_bytes = pAd->RalinkCounters.ReceivedByteCount;
1561 pAd->stats.tx_bytes = pAd->RalinkCounters.TransmittedByteCount;
1563 pAd->stats.rx_errors = pAd->Counters8023.RxErrors;
1564 pAd->stats.tx_errors = pAd->Counters8023.TxErrors;
1566 pAd->stats.rx_dropped = 0;
1567 pAd->stats.tx_dropped = 0;
1569 pAd->stats.multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; // multicast packets received
1570 pAd->stats.collisions = pAd->Counters8023.OneCollision + pAd->Counters8023.MoreCollisions; // Collision packets
1572 pAd->stats.rx_length_errors = 0;
1573 pAd->stats.rx_over_errors = pAd->Counters8023.RxNoBuffer; // receiver ring buff overflow
1574 pAd->stats.rx_crc_errors = 0;//pAd->WlanCounters.FCSErrorCount; // recved pkt with crc error
1575 pAd->stats.rx_frame_errors = pAd->Counters8023.RcvAlignmentErrors; // recv'd frame alignment error
1576 pAd->stats.rx_fifo_errors = pAd->Counters8023.RxNoBuffer; // recv'r fifo overrun
1577 pAd->stats.rx_missed_errors = 0; // receiver missed packet
1579 // detailed tx_errors
1580 pAd->stats.tx_aborted_errors = 0;
1581 pAd->stats.tx_carrier_errors = 0;
1582 pAd->stats.tx_fifo_errors = 0;
1583 pAd->stats.tx_heartbeat_errors = 0;
1584 pAd->stats.tx_window_errors = 0;
1587 pAd->stats.rx_compressed = 0;
1588 pAd->stats.tx_compressed = 0;