diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-19 17:48:32 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-19 17:48:32 -0700 |
commit | fb20871a54961b82d35303b43452928186c1361d (patch) | |
tree | 1beeb39e45eda1c8b5893090904b583fceeb07ef /drivers/staging/rt2860/rt_main_dev.c | |
parent | bee89ab228e6f51c4ddd3481b9bd491859a8ee7b (diff) | |
parent | c7a5d70796379e3d51d0c652fbe1634b81d3bbd5 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6: (342 commits)
Staging: comedi: fix build errors
Staging: udlfb: update to version 0.2.3
Staging: udlfb: fix some sparse warnings.
Staging: udlfb: clean up checkpatch warnings in udlfb.c
Staging: udlfb: clean up checkpatch warnings in udlfb.h
Staging: udlfb: add udlfb driver to build
Staging: add udlfb driver
Staging: pata_rdc: remove pointless comments
Staging: pata_rdc: remove DRIVER macros
Staging: pata_rdc: remove dbgprintf macro
Staging: pata_rdc: remove broken flag
Staging: pata_rdc: fix build warnings
Staging: pata_rdc: use PCI_DEVICE
Staging: pata_rdc: remove function prototypes
Staging: pata_rdc: coding style fixes
Staging: pata_rdc: convert code to work in 2.6.29
Staging: pata_rdc: add driver to the build system
Staging: add pata_rdc driver
Staging: remove obsolete serqt_usb driver
Staging: serqt_usb2 add the driver to the build
...
Diffstat (limited to 'drivers/staging/rt2860/rt_main_dev.c')
-rw-r--r-- | drivers/staging/rt2860/rt_main_dev.c | 717 |
1 files changed, 118 insertions, 599 deletions
diff --git a/drivers/staging/rt2860/rt_main_dev.c b/drivers/staging/rt2860/rt_main_dev.c index 6c4396f0903..f298b9bcec3 100644 --- a/drivers/staging/rt2860/rt_main_dev.c +++ b/drivers/staging/rt2860/rt_main_dev.c @@ -40,17 +40,6 @@ #define FORTY_MHZ_INTOLERANT_INTERVAL (60*1000) // 1 min -#ifdef MULTIPLE_CARD_SUPPORT -// record whether the card in the card list is used in the card file -UINT8 MC_CardUsed[MAX_NUM_OF_MULTIPLE_CARD]; -// record used card mac address in the card list -static UINT8 MC_CardMac[MAX_NUM_OF_MULTIPLE_CARD][6]; -#endif // MULTIPLE_CARD_SUPPORT // - -#ifdef CONFIG_APSTA_MIXED_SUPPORT -UINT32 CW_MAX_IN_BITS; -#endif // CONFIG_APSTA_MIXED_SUPPORT // - /*---------------------------------------------------------------------*/ /* Private Variables Used */ /*---------------------------------------------------------------------*/ @@ -65,13 +54,13 @@ MODULE_PARM_DESC (mac, "rt28xx: wireless mac addr"); /*---------------------------------------------------------------------*/ /* Prototypes of Functions Used */ /*---------------------------------------------------------------------*/ -#ifdef DOT11_N_SUPPORT extern BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num); extern void ba_reordering_resource_release(PRTMP_ADAPTER pAd); -#endif // DOT11_N_SUPPORT // extern NDIS_STATUS NICLoadRateSwitchingParams(IN PRTMP_ADAPTER pAd); +#ifdef RT2860 extern void init_thread_task(PRTMP_ADAPTER pAd); +#endif // public function prototype INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p, @@ -83,13 +72,7 @@ INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev) static void CfgInitHook(PRTMP_ADAPTER pAd); -#ifdef CONFIG_STA_SUPPORT extern const struct iw_handler_def rt28xx_iw_handler_def; -#endif // CONFIG_STA_SUPPORT // - -#ifdef CONFIG_APSTA_MIXED_SUPPORT -extern const struct iw_handler_def rt28xx_ap_iw_handler_def; -#endif // CONFIG_APSTA_MIXED_SUPPORT // #if WIRELESS_EXT >= 12 // This function will be called when query /proc @@ -206,6 +189,12 @@ int rt28xx_close(IN PNET_DEV dev) RTMP_ADAPTER *pAd = net_dev->ml_priv; BOOLEAN Cancelled = FALSE; UINT32 i = 0; +#ifdef RT2870 + DECLARE_WAIT_QUEUE_HEAD(unlink_wakeup); + DECLARE_WAITQUEUE(wait, current); + + //RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS); +#endif // RT2870 // DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n")); @@ -214,54 +203,26 @@ int rt28xx_close(IN PNET_DEV dev) if (pAd == NULL) return 0; // close ok - -#ifdef WDS_SUPPORT - WdsDown(pAd); -#endif // WDS_SUPPORT // - -#ifdef CONFIG_STA_SUPPORT - IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { // If dirver doesn't wake up firmware here, // NICLoadFirmware will hang forever when interface is up again. +#ifdef RT2860 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) || RTMP_SET_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND) || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)) +#endif +#ifdef RT2870 + if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) +#endif { +#ifdef RT2860 AsicForceWakeup(pAd, RTMP_HALT); +#endif +#ifdef RT2870 + AsicForceWakeup(pAd, TRUE); +#endif } -#ifdef QOS_DLS_SUPPORT - // send DLS-TEAR_DOWN message, - if (pAd->CommonCfg.bDLSCapable) - { - UCHAR i; - - // tear down local dls table entry - for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) - { - RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - } - } - - // tear down peer dls table entry - for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) - { - if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) - { - RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); - pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; - pAd->StaCfg.DLSEntry[i].Valid = FALSE; - } - } - RT28XX_MLME_HANDLER(pAd); - } -#endif // QOS_DLS_SUPPORT // - if (INFRA_ON(pAd) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) { @@ -287,6 +248,9 @@ int rt28xx_close(IN PNET_DEV dev) RTMPusecDelay(1000); } +#ifdef RT2870 + RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS); +#endif // RT2870 // #ifdef CCX_SUPPORT RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &Cancelled); @@ -295,22 +259,11 @@ int rt28xx_close(IN PNET_DEV dev) RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled); RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled); -#ifdef WPA_SUPPLICANT_SUPPORT -#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT - { - union iwreq_data wrqu; - // send wireless event to wpa_supplicant for infroming interface down. - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_INTERFACE_DOWN; - wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); - } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // -#endif // WPA_SUPPLICANT_SUPPORT // - MlmeRadioOff(pAd); +#ifdef RT2860 pAd->bPCIclkOff = FALSE; +#endif } -#endif // CONFIG_STA_SUPPORT // RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); @@ -323,25 +276,52 @@ int rt28xx_close(IN PNET_DEV dev) } } +#ifdef RT2870 + // ensure there are no more active urbs. + add_wait_queue (&unlink_wakeup, &wait); + pAd->wait = &unlink_wakeup; + + // maybe wait for deletions to finish. + i = 0; + //while((i < 25) && atomic_read(&pAd->PendingRx) > 0) + while(i < 25) + { + unsigned long IrqFlags; + + RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags); + if (pAd->PendingRx == 0) + { + RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags); + break; + } + RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags); + + msleep(UNLINK_TIMEOUT_MS); //Time in millisecond + i++; + } + pAd->wait = NULL; + remove_wait_queue (&unlink_wakeup, &wait); +#endif // RT2870 // + +#ifdef RT2870 + // We need clear timerQ related structure before exits of the timer thread. + RT2870_TimerQ_Exit(pAd); + // Close kernel threads or tasklets + RT28xxThreadTerminate(pAd); +#endif // RT2870 // + // Stop Mlme state machine MlmeHalt(pAd); // Close kernel threads or tasklets kill_thread_task(pAd); - -#ifdef CONFIG_STA_SUPPORT - IF_DEV_CONFIG_OPMODE_ON_STA(pAd) - { - MacTableReset(pAd); - } -#endif // CONFIG_STA_SUPPORT // - + MacTableReset(pAd); MeasureReqTabExit(pAd); TpcReqTabExit(pAd); - +#ifdef RT2860 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) { NICDisableInterrupt(pAd); @@ -357,18 +337,15 @@ int rt28xx_close(IN PNET_DEV dev) RT28XX_IRQ_RELEASE(net_dev) RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE); } - +#endif // Free Ring or USB buffers RTMPFreeTxRxRingMemory(pAd); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); -#ifdef DOT11_N_SUPPORT // Free BA reorder resource ba_reordering_resource_release(pAd); -#endif // DOT11_N_SUPPORT // - RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP); @@ -377,17 +354,19 @@ int rt28xx_close(IN PNET_DEV dev) static int rt28xx_init(IN struct net_device *net_dev) { +#ifdef RT2860 PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)net_dev->ml_priv; +#endif +#ifdef RT2870 + PRTMP_ADAPTER pAd = net_dev->ml_priv; +#endif UINT index; UCHAR TmpPhy; NDIS_STATUS Status; UINT32 MacCsr0 = 0; - -#ifdef DOT11_N_SUPPORT // Allocate BA Reordering memory ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM); -#endif // DOT11_N_SUPPORT // // Make sure MAC gets ready. index = 0; @@ -403,11 +382,11 @@ static int rt28xx_init(IN struct net_device *net_dev) } while (index++ < 100); DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion)); +/*Iverson patch PCIE L1 issue */ // Disable DMA RT28XXDMADisable(pAd); - // Load 8051 firmware Status = NICLoadFirmware(pAd); if (Status != NDIS_STATUS_SUCCESS) @@ -420,10 +399,12 @@ static int rt28xx_init(IN struct net_device *net_dev) // Disable interrupts here which is as soon as possible // This statement should never be true. We might consider to remove it later +#ifdef RT2860 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) { NICDisableInterrupt(pAd); } +#endif Status = RTMPAllocTxRxRingMemory(pAd); if (Status != NDIS_STATUS_SUCCESS) @@ -448,6 +429,10 @@ static int rt28xx_init(IN struct net_device *net_dev) // UserCfgInit(pAd); +#ifdef RT2870 + // We need init timerQ related structure before create the timer thread. + RT2870_TimerQ_Init(pAd); +#endif // RT2870 // RT28XX_TASK_THREAD_INIT(pAd, Status); if (Status != NDIS_STATUS_SUCCESS) @@ -455,15 +440,7 @@ static int rt28xx_init(IN struct net_device *net_dev) CfgInitHook(pAd); - -#ifdef BLOCK_NET_IF - initblockQueueTab(pAd); -#endif // BLOCK_NET_IF // - -#ifdef CONFIG_STA_SUPPORT - IF_DEV_CONFIG_OPMODE_ON_STA(pAd) - NdisAllocateSpinLock(&pAd->MacTabLock); -#endif // CONFIG_STA_SUPPORT // + NdisAllocateSpinLock(&pAd->MacTabLock); MeasureReqTabInit(pAd); TpcReqTabInit(pAd); @@ -489,10 +466,17 @@ static int rt28xx_init(IN struct net_device *net_dev) goto err4; } +#ifdef RT2870 + pAd->CommonCfg.bMultipleIRP = FALSE; + + if (pAd->CommonCfg.bMultipleIRP) + pAd->CommonCfg.NumOfBulkInIRP = RX_RING_SIZE; + else + pAd->CommonCfg.NumOfBulkInIRP = 1; +#endif // RT2870 // //Init Ba Capability parameters. -#ifdef DOT11_N_SUPPORT pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity; pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable; pAd->CommonCfg.DesiredHtPhy.AmsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize; @@ -501,7 +485,6 @@ static int rt28xx_init(IN struct net_device *net_dev) pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode; pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize; pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity; -#endif // DOT11_N_SUPPORT // printk("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode); @@ -516,9 +499,7 @@ static int rt28xx_init(IN struct net_device *net_dev) TmpPhy = pAd->CommonCfg.PhyMode; pAd->CommonCfg.PhyMode = 0xff; RTMPSetPhyMode(pAd, TmpPhy); -#ifdef DOT11_N_SUPPORT SetCommonHT(pAd); -#endif // DOT11_N_SUPPORT // // No valid channels. if (pAd->ChannelListNum == 0) @@ -527,11 +508,14 @@ static int rt28xx_init(IN struct net_device *net_dev) goto err4; } -#ifdef DOT11_N_SUPPORT printk("MCS Set = %02x %02x %02x %02x %02x\n", pAd->CommonCfg.HtCapability.MCSSet[0], pAd->CommonCfg.HtCapability.MCSSet[1], pAd->CommonCfg.HtCapability.MCSSet[2], pAd->CommonCfg.HtCapability.MCSSet[3], pAd->CommonCfg.HtCapability.MCSSet[4]); -#endif // DOT11_N_SUPPORT // + +#ifdef RT2870 + //Init RT30xx RFRegisters after read RFIC type from EEPROM + NICInitRT30xxRFRegisters(pAd); +#endif // RT2870 // #ifdef IKANOS_VX_1X0 VR_IKANOS_FP_Init(pAd->ApCfg.BssidNum, pAd->PermanentAddress); @@ -543,8 +527,10 @@ static int rt28xx_init(IN struct net_device *net_dev) AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE); AsicLockChannel(pAd, pAd->CommonCfg.Channel); +#ifndef RT30xx // 8051 firmware require the signal during booting time. AsicSendCommandToMcu(pAd, 0x72, 0xFF, 0x00, 0x00); +#endif if (pAd && (Status != NDIS_STATUS_SUCCESS)) { @@ -561,9 +547,24 @@ static int rt28xx_init(IN struct net_device *net_dev) // Microsoft HCT require driver send a disconnect event after driver initialization. OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE); + DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n")); +#ifdef RT2870 + RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS); + RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS); + + // + // Support multiple BulkIn IRP, + // the value on pAd->CommonCfg.NumOfBulkInIRP may be large than 1. + // + for(index=0; index<pAd->CommonCfg.NumOfBulkInIRP; index++) + { + RTUSBBulkReceive(pAd); + DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n" )); + } +#endif // RT2870 // }// end of else @@ -578,17 +579,12 @@ err3: err2: RTMPFreeTxRxRingMemory(pAd); err1: - -#ifdef DOT11_N_SUPPORT os_free_mem(pAd, pAd->mpdu_blk_pool.mem); // free BA pool -#endif // DOT11_N_SUPPORT // RT28XX_IRQ_RELEASE(net_dev); // shall not set ml_priv to NULL here because the ml_priv didn't been free yet. //net_dev->ml_priv = 0; -#ifdef INF_AMAZON_SE -err0: -#endif // INF_AMAZON_SE // + printk("!!! %s Initialized fail !!!\n", RT28xx_CHIP_NAME); return FALSE; } /* End of rt28xx_init */ @@ -625,27 +621,6 @@ int rt28xx_open(IN PNET_DEV dev) return -1; } -#ifdef CONFIG_APSTA_MIXED_SUPPORT - if (pAd->OpMode == OPMODE_AP) - { - CW_MAX_IN_BITS = 6; - } - else if (pAd->OpMode == OPMODE_STA) - { - CW_MAX_IN_BITS = 10; - } - -#if WIRELESS_EXT >= 12 - if (net_dev->priv_flags == INT_MAIN) - { - if (pAd->OpMode == OPMODE_AP) - net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def; - else if (pAd->OpMode == OPMODE_STA) - net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_iw_handler_def; - } -#endif // WIRELESS_EXT >= 12 // -#endif // CONFIG_APSTA_MIXED_SUPPORT // - // Init pObj = (POS_COOKIE)pAd->OS_Cookie; @@ -664,13 +639,8 @@ int rt28xx_open(IN PNET_DEV dev) if (rt28xx_init(net_dev) == FALSE) goto err; -#ifdef CONFIG_STA_SUPPORT - IF_DEV_CONFIG_OPMODE_ON_STA(pAd) - { - NdisZeroMemory(pAd->StaCfg.dev_name, 16); - NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name)); - } -#endif // CONFIG_STA_SUPPORT // + NdisZeroMemory(pAd->StaCfg.dev_name, 16); + NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name)); // Set up the Mac address NdisMoveMemory(net_dev->dev_addr, (void *) pAd->CurrentAddress, 6); @@ -680,24 +650,6 @@ int rt28xx_open(IN PNET_DEV dev) // Various AP function init -#ifdef CONFIG_STA_SUPPORT - IF_DEV_CONFIG_OPMODE_ON_STA(pAd) - { -#ifdef WPA_SUPPLICANT_SUPPORT -#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT - { - union iwreq_data wrqu; - // send wireless event to wpa_supplicant for infroming interface down. - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.flags = RT_INTERFACE_UP; - wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); - } -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // -#endif // WPA_SUPPLICANT_SUPPORT // - - } -#endif // CONFIG_STA_SUPPORT // - // Enable Interrupt RT28XX_IRQ_ENABLE(pAd); @@ -711,11 +663,9 @@ int rt28xx_open(IN PNET_DEV dev) printk("0x1300 = %08x\n", reg); } -#ifdef CONFIG_STA_SUPPORT - IF_DEV_CONFIG_OPMODE_ON_STA(pAd) +#ifdef RT2860 RTMPInitPCIeLinkCtrlValue(pAd); -#endif // CONFIG_STA_SUPPORT // - +#endif return (retval); err: @@ -745,26 +695,12 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p CHAR slot_name[IFNAMSIZ]; struct net_device *device; - - //ether_setup(dev); - -#ifdef CONFIG_STA_SUPPORT #if WIRELESS_EXT >= 12 if (pAd->OpMode == OPMODE_STA) { dev->wireless_handlers = &rt28xx_iw_handler_def; } #endif //WIRELESS_EXT >= 12 -#endif // CONFIG_STA_SUPPORT // - -#ifdef CONFIG_APSTA_MIXED_SUPPORT -#if WIRELESS_EXT >= 12 - if (pAd->OpMode == OPMODE_AP) - { - dev->wireless_handlers = &rt28xx_ap_iw_handler_def; - } -#endif //WIRELESS_EXT >= 12 -#endif // CONFIG_APSTA_MIXED_SUPPORT // #if WIRELESS_EXT < 21 dev->get_wireless_stats = rt28xx_get_wireless_stats; @@ -774,11 +710,6 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p // find available device name for (i = 0; i < 8; i++) { -#ifdef MULTIPLE_CARD_SUPPORT - if (pAd->MC_RowID >= 0) - sprintf(slot_name, "ra%02d_%d", pAd->MC_RowID, i); - else -#endif // MULTIPLE_CARD_SUPPORT // sprintf(slot_name, "ra%d", i); device = dev_get_by_name(dev_net(dev), slot_name); @@ -796,11 +727,6 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p } else { -#ifdef MULTIPLE_CARD_SUPPORT - if (pAd->MC_RowID >= 0) - sprintf(dev->name, "ra%02d_%d", pAd->MC_RowID, i); - else -#endif // MULTIPLE_CARD_SUPPORT // sprintf(dev->name, "ra%d", i); Status = NDIS_STATUS_SUCCESS; } @@ -809,369 +735,6 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p } - -#ifdef MULTIPLE_CARD_SUPPORT -/* -======================================================================== -Routine Description: - Get card profile path. - -Arguments: - pAd - -Return Value: - TRUE - Find a card profile - FALSE - use default profile - -Note: -======================================================================== -*/ -extern INT RTMPGetKeyParameter( - IN PCHAR key, - OUT PCHAR dest, - IN INT destsize, - IN PCHAR buffer); - -BOOLEAN RTMP_CardInfoRead( - IN PRTMP_ADAPTER pAd) -{ -#define MC_SELECT_CARDID 0 /* use CARD ID (0 ~ 31) to identify different cards */ -#define MC_SELECT_MAC 1 /* use CARD MAC to identify different cards */ -#define MC_SELECT_CARDTYPE 2 /* use CARD type (abgn or bgn) to identify different cards */ - -#define LETTER_CASE_TRANSLATE(txt_p, card_id) \ - { UINT32 _len; char _char; \ - for(_len=0; _len<strlen(card_id); _len++) { \ - _char = *(txt_p + _len); \ - if (('A' <= _char) && (_char <= 'Z')) \ - *(txt_p+_len) = 'a'+(_char-'A'); \ - } } - - struct file *srcf; - INT retval, orgfsuid, orgfsgid; - mm_segment_t orgfs; - CHAR *buffer, *tmpbuf, card_id_buf[30], RFIC_word[30]; - BOOLEAN flg_match_ok = FALSE; - INT32 card_select_method; - INT32 card_free_id, card_nouse_id, card_same_mac_id, card_match_id; - EEPROM_ANTENNA_STRUC antenna; - USHORT addr01, addr23, addr45; - UINT8 mac[6]; - UINT32 data, card_index; - UCHAR *start_ptr; - - - // init - buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG); - if (buffer == NULL) - return FALSE; - - tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG); - if(tmpbuf == NULL) - { - kfree(buffer); - return NDIS_STATUS_FAILURE; - } - - orgfsuid = current->fsuid; - orgfsgid = current->fsgid; - current->fsuid = current->fsgid = 0; - orgfs = get_fs(); - set_fs(KERNEL_DS); - - // get RF IC type - RTMP_IO_READ32(pAd, E2PROM_CSR, &data); - - if ((data & 0x30) == 0) - pAd->EEPROMAddressNum = 6; // 93C46 - else if ((data & 0x30) == 0x10) - pAd->EEPROMAddressNum = 8; // 93C66 - else - pAd->EEPROMAddressNum = 8; // 93C86 - - RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, antenna.word); - - if ((antenna.field.RfIcType == RFIC_2850) || - (antenna.field.RfIcType == RFIC_2750)) - { - /* ABGN card */ - strcpy(RFIC_word, "abgn"); - } - else - { - /* BGN card */ - strcpy(RFIC_word, "bgn"); - } - - // get MAC address - RT28xx_EEPROM_READ16(pAd, 0x04, addr01); - RT28xx_EEPROM_READ16(pAd, 0x06, addr23); - RT28xx_EEPROM_READ16(pAd, 0x08, addr45); - - mac[0] = (UCHAR)(addr01 & 0xff); - mac[1] = (UCHAR)(addr01 >> 8); - mac[2] = (UCHAR)(addr23 & 0xff); - mac[3] = (UCHAR)(addr23 >> 8); - mac[4] = (UCHAR)(addr45 & 0xff); - mac[5] = (UCHAR)(addr45 >> 8); - - // open card information file - srcf = filp_open(CARD_INFO_PATH, O_RDONLY, 0); - if (IS_ERR(srcf)) - { - /* card information file does not exist */ - DBGPRINT(RT_DEBUG_TRACE, - ("--> Error %ld opening %s\n", -PTR_ERR(srcf), CARD_INFO_PATH)); - return FALSE; - } - - if (srcf->f_op && srcf->f_op->read) - { - /* card information file exists so reading the card information */ - memset(buffer, 0x00, MAX_INI_BUFFER_SIZE); - retval = srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos); - if (retval < 0) - { - /* read fail */ - DBGPRINT(RT_DEBUG_TRACE, - ("--> Read %s error %d\n", CARD_INFO_PATH, -retval)); - } - else - { - /* get card selection method */ - memset(tmpbuf, 0x00, MAX_PARAM_BUFFER_SIZE); - card_select_method = MC_SELECT_CARDTYPE; // default - - if (RTMPGetKeyParameter("SELECT", tmpbuf, 256, buffer)) - { - if (strcmp(tmpbuf, "CARDID") == 0) - card_select_method = MC_SELECT_CARDID; - else if (strcmp(tmpbuf, "MAC") == 0) - card_select_method = MC_SELECT_MAC; - else if (strcmp(tmpbuf, "CARDTYPE") == 0) - card_select_method = MC_SELECT_CARDTYPE; - } - - DBGPRINT(RT_DEBUG_TRACE, - ("MC> Card Selection = %d\n", card_select_method)); - - // init - card_free_id = -1; - card_nouse_id = -1; - card_same_mac_id = -1; - card_match_id = -1; - - // search current card information records - for(card_index=0; - card_index<MAX_NUM_OF_MULTIPLE_CARD; - card_index++) - { - if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) && - (*(UINT16 *)&MC_CardMac[card_index][4] == 0)) - { - // MAC is all-0 so the entry is available - MC_CardUsed[card_index] = 0; - - if (card_free_id < 0) - card_free_id = card_index; // 1st free entry - } - else - { - if (memcmp(MC_CardMac[card_index], mac, 6) == 0) - { - // we find the entry with same MAC - if (card_same_mac_id < 0) - card_same_mac_id = card_index; // 1st same entry - } - else - { - // MAC is not all-0 but used flag == 0 - if ((MC_CardUsed[card_index] == 0) && - (card_nouse_id < 0)) - { - card_nouse_id = card_index; // 1st available entry - } - } - } - } - - DBGPRINT(RT_DEBUG_TRACE, - ("MC> Free = %d, Same = %d, NOUSE = %d\n", - card_free_id, card_same_mac_id, card_nouse_id)); - - if ((card_same_mac_id >= 0) && - ((card_select_method == MC_SELECT_CARDID) || - (card_select_method == MC_SELECT_CARDTYPE))) - { - // same MAC entry is found - card_match_id = card_same_mac_id; - - if (card_select_method == MC_SELECT_CARDTYPE) - { - // for CARDTYPE - sprintf(card_id_buf, "%02dCARDTYPE%s", - card_match_id, RFIC_word); - - if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL) - { - // we found the card ID - LETTER_CASE_TRANSLATE(start_ptr, card_id_buf); - } - } - } - else - { - // the card is 1st plug-in, try to find the match card profile - switch(card_select_method) - { - case MC_SELECT_CARDID: // CARDID - default: - if (card_free_id >= 0) - card_match_id = card_free_id; - else - card_match_id = card_nouse_id; - break; - - case MC_SELECT_MAC: // MAC - sprintf(card_id_buf, "MAC%02x:%02x:%02x:%02x:%02x:%02x", - mac[0], mac[1], mac[2], - mac[3], mac[4], mac[5]); - - /* try to find the key word in the card file */ - if ((start_ptr=rtstrstruncasecmp(buffer, card_id_buf)) != NULL) - { - LETTER_CASE_TRANSLATE(start_ptr, card_id_buf); - - /* get the row ID (2 ASCII characters) */ - start_ptr -= 2; - card_id_buf[0] = *(start_ptr); - card_id_buf[1] = *(start_ptr+1); - card_id_buf[2] = 0x00; - - card_match_id = simple_strtol(card_id_buf, 0, 10); - } - break; - - case MC_SELECT_CARDTYPE: // CARDTYPE - card_nouse_id = -1; - - for(card_index=0; - card_index<MAX_NUM_OF_MULTIPLE_CARD; - card_index++) - { - sprintf(card_id_buf, "%02dCARDTYPE%s", - card_index, RFIC_word); - - if ((start_ptr=rtstrstruncasecmp(buffer, - card_id_buf)) != NULL) - { - LETTER_CASE_TRANSLATE(start_ptr, card_id_buf); - - if (MC_CardUsed[card_index] == 0) - { - /* current the card profile is not used */ - if ((*(UINT32 *)&MC_CardMac[card_index][0] == 0) && - (*(UINT16 *)&MC_CardMac[card_index][4] == 0)) - { - // find it and no previous card use it - card_match_id = card_index; - break; - } - else - { - // ever a card use it - if (card_nouse_id < 0) - card_nouse_id = card_index; - } - } - } - } - - // if not find a free one, use the available one - if (card_match_id < 0) - card_match_id = card_nouse_id; - break; - } - } - - if (card_match_id >= 0) - { - // make up search keyword - switch(card_select_method) - { - case MC_SELECT_CARDID: // CARDID - sprintf(card_id_buf, "%02dCARDID", card_match_id); - break; - - case MC_SELECT_MAC: // MAC - sprintf(card_id_buf, - "%02dmac%02x:%02x:%02x:%02x:%02x:%02x", - card_match_id, - mac[0], mac[1], mac[2], - mac[3], mac[4], mac[5]); - break; - - case MC_SELECT_CARDTYPE: // CARDTYPE - default: - sprintf(card_id_buf, "%02dcardtype%s", - card_match_id, RFIC_word); - break; - } - - DBGPRINT(RT_DEBUG_TRACE, ("Search Keyword = %s\n", card_id_buf)); - - // read card file path - if (RTMPGetKeyParameter(card_id_buf, tmpbuf, 256, buffer)) - { - if (strlen(tmpbuf) < sizeof(pAd->MC_FileName)) - { - // backup card information - pAd->MC_RowID = card_match_id; /* base 0 */ - MC_CardUsed[card_match_id] = 1; - memcpy(MC_CardMac[card_match_id], mac, sizeof(mac)); - - // backup card file path - NdisMoveMemory(pAd->MC_FileName, tmpbuf , strlen(tmpbuf)); - pAd->MC_FileName[strlen(tmpbuf)] = '\0'; - flg_match_ok = TRUE; - - DBGPRINT(RT_DEBUG_TRACE, - ("Card Profile Name = %s\n", pAd->MC_FileName)); - } - else - { - DBGPRINT(RT_DEBUG_ERROR, - ("Card Profile Name length too large!\n")); - } - } - else - { - DBGPRINT(RT_DEBUG_ERROR, - ("Can not find search key word in card.dat!\n")); - } - - if ((flg_match_ok != TRUE) && - (card_match_id < MAX_NUM_OF_MULTIPLE_CARD)) - { - MC_CardUsed[card_match_id] = 0; - memset(MC_CardMac[card_match_id], 0, sizeof(mac)); - } - } // if (card_match_id >= 0) - } - } - - // close file - retval = filp_close(srcf, NULL); - set_fs(orgfs); - current->fsuid = orgfsuid; - current->fsgid = orgfsgid; - kfree(buffer); - kfree(tmpbuf); - return flg_match_ok; -} -#endif // MULTIPLE_CARD_SUPPORT // - - /* ======================================================================== Routine Description: @@ -1198,12 +761,17 @@ INT __devinit rt28xx_probe( PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) NULL; INT status; PVOID handle; +#ifdef RT2860 struct pci_dev *dev_p = (struct pci_dev *)_dev_p; +#endif +#ifdef RT2870 + struct usb_interface *intf = (struct usb_interface *)_dev_p; + struct usb_device *dev_p = interface_to_usbdev(intf); + dev_p = usb_get_dev(dev_p); +#endif // RT2870 // -#ifdef CONFIG_STA_SUPPORT DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION)); -#endif // CONFIG_STA_SUPPORT // net_dev = alloc_etherdev(sizeof(PRTMP_ADAPTER)); if (net_dev == NULL) @@ -1214,13 +782,12 @@ INT __devinit rt28xx_probe( } netif_stop_queue(net_dev); -#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT + /* for supporting Network Manager */ /* Set the sysfs physical device reference for the network logical device * if set prior to registration will cause a symlink during initialization. */ SET_NETDEV_DEV(net_dev, &(dev_p->dev)); -#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // // Allocate RTMP_ADAPTER miniport adapter structure handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL); @@ -1235,32 +802,13 @@ INT __devinit rt28xx_probe( RT28XXNetDevInit(_dev_p, net_dev, pAd); -#ifdef CONFIG_STA_SUPPORT pAd->StaCfg.OriDevType = net_dev->type; -#endif // CONFIG_STA_SUPPORT // // Post config if (RT28XXProbePostConfig(_dev_p, pAd, 0) == FALSE) goto err_out_unmap; -#ifdef CONFIG_STA_SUPPORT pAd->OpMode = OPMODE_STA; -#endif // CONFIG_STA_SUPPORT // - - -#ifdef MULTIPLE_CARD_SUPPORT - // find its profile path - pAd->MC_RowID = -1; // use default profile path - RTMP_CardInfoRead(pAd); - - if (pAd->MC_RowID == -1) -#ifdef CONFIG_STA_SUPPORT - strcpy(pAd->MC_FileName, STA_PROFILE_PATH); -#endif // CONFIG_STA_SUPPORT // - - DBGPRINT(RT_DEBUG_TRACE, - ("MC> ROW = %d, PATH = %s\n", pAd->MC_RowID, pAd->MC_FileName)); -#endif // MULTIPLE_CARD_SUPPORT // // sample move if (rt_ieee80211_if_setup(net_dev, pAd) != NDIS_STATUS_SUCCESS) @@ -1317,17 +865,6 @@ int rt28xx_packet_xmit(struct sk_buff *skb) int status = 0; PNDIS_PACKET pPacket = (PNDIS_PACKET) skb; - /* RT2870STA does this in RTMPSendPackets() */ -#ifdef RALINK_ATE - if (ATE_ON(pAd)) - { - RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_RESOURCES); - return 0; - } -#endif // RALINK_ATE // - -#ifdef CONFIG_STA_SUPPORT - IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { // Drop send request since we are in monitor mode if (MONITOR_ON(pAd)) @@ -1336,7 +873,6 @@ int rt28xx_packet_xmit(struct sk_buff *skb) goto done; } } -#endif // CONFIG_STA_SUPPORT // // EapolStart size is 18 if (skb->len < 14) @@ -1354,16 +890,7 @@ int rt28xx_packet_xmit(struct sk_buff *skb) } #endif - - -#ifdef CONFIG_STA_SUPPORT - IF_DEV_CONFIG_OPMODE_ON_STA(pAd) - { - - STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1); - } - -#endif // CONFIG_STA_SUPPORT // + STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1); status = 0; done: @@ -1432,10 +959,8 @@ struct iw_statistics *rt28xx_get_wireless_stats( if(pAd->iw_stats.qual.qual > 100) pAd->iw_stats.qual.qual = 100; -#ifdef CONFIG_STA_SUPPORT if (pAd->OpMode == OPMODE_STA) pAd->iw_stats.qual.level = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2); -#endif // CONFIG_STA_SUPPORT // pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; // noise level (dBm) @@ -1487,13 +1012,7 @@ INT rt28xx_ioctl( return -ENETDOWN; } - -#ifdef CONFIG_STA_SUPPORT - IF_DEV_CONFIG_OPMODE_ON_STA(pAd) - { - ret = rt28xx_sta_ioctl(net_dev, rq, cmd); - } -#endif // CONFIG_STA_SUPPORT // + ret = rt28xx_sta_ioctl(net_dev, rq, cmd); return ret; } |