/* ======================================================================== Routine Description: Open raxx interface. Arguments: *net_dev the raxx interface pointer Return Value: 0 Open OK otherwise Open Fail Note: ======================================================================== */ int rt28xx_open(IN PNET_DEV dev) { struct net_device * net_dev = (struct net_device *)dev; PRTMP_ADAPTER pAd = NULL; int retval = 0; //POS_COOKIE pObj; GET_PAD_FROM_NET_DEV(pAd, net_dev); // Sanity check for pAd if (pAd == NULL) { /* if 1st open fail, pAd will be free; So the net_dev->priv will be NULL in 2rd open */ 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; } #endif // CONFIG_APSTA_MIXED_SUPPORT // #if WIRELESS_EXT >= 12 if (RT_DEV_PRIV_FLAGS_GET(net_dev) == INT_MAIN) { #ifdef CONFIG_APSTA_MIXED_SUPPORT if (pAd->OpMode == OPMODE_AP) net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def; #endif // CONFIG_APSTA_MIXED_SUPPORT // } #endif // WIRELESS_EXT >= 12 // // Request interrupt service routine for PCI device // register the interrupt routine with the os /* AP Channel auto-selection will be run in rt28xx_init(), so we must reqister IRQ hander here. */ RtmpOSIRQRequest(net_dev); // Init IRQ parameters stored in pAd RTMP_IRQ_INIT(pAd); // Chip & other init if (rt28xx_init(pAd, mac, hostname) == FALSE) goto err; #ifdef LINUX #ifdef RT_CFG80211_SUPPORT RT_CFG80211_REINIT(pAd); RT_CFG80211_CRDA_REG_RULE_APPLY(pAd); #endif // RT_CFG80211_SUPPORT // #endif // LINUX // // Enable Interrupt RTMP_IRQ_ENABLE(pAd); // Now Enable RxTx RTMPEnableRxTx(pAd); RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP); { UINT32 reg = 0; RTMP_IO_READ32(pAd, 0x1300, ®); // clear garbage interrupts if (reg); DBGPRINT(RT_DEBUG_TRACE, ("0x1300 = %08x\n", reg)); } { // u32 reg; // UINT8 byte; // u16 tmp; // RTMP_IO_READ32(pAd, XIFS_TIME_CFG, ®); // tmp = 0x0805; // reg = (reg & 0xffff0000) | tmp; // RTMP_IO_WRITE32(pAd, XIFS_TIME_CFG, reg); } #ifdef CONFIG_AP_SUPPORT #ifdef BG_FT_SUPPORT BG_FTPH_Init(); #endif // BG_FT_SUPPORT // #endif // CONFIG_AP_SUPPORT // #ifdef VENDOR_FEATURE2_SUPPORT printk("Number of Packet Allocated in open = %d\n", pAd->NumOfPktAlloc); printk("Number of Packet Freed in open = %d\n", pAd->NumOfPktFree); #endif // VENDOR_FEATURE2_SUPPORT // return (retval); err: //+++Add by shiang, move from rt28xx_init() to here. RtmpOSIRQRelease(net_dev); //---Add by shiang, move from rt28xx_init() to here. return (-1); } /* End of rt28xx_open */
/* ======================================================================== Routine Description: Close raxx interface. Arguments: *net_dev the raxx interface pointer Return Value: 0 Open OK otherwise Open Fail Note: 1. if open fail, kernel will not call the close function. 2. Free memory for (1) Mlme Memory Handler: MlmeHalt() (2) TX & RX: RTMPFreeTxRxRingMemory() (3) BA Reordering: ba_reordering_resource_release() ======================================================================== */ int rt28xx_close(IN PNET_DEV dev) { struct net_device * net_dev = (struct net_device *)dev; RTMP_ADAPTER *pAd = NULL; BOOLEAN Cancelled; UINT32 i = 0; GET_PAD_FROM_NET_DEV(pAd, net_dev); DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n")); #ifdef CONFIG_AP_SUPPORT #ifdef BG_FT_SUPPORT BG_FTPH_Remove(); #endif // BG_FT_SUPPORT // #endif // CONFIG_AP_SUPPORT // Cancelled = FALSE; // Sanity check for pAd if (pAd == NULL) return 0; // close ok RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); #ifdef WMM_ACM_SUPPORT /* must call first */ ACMP_Release(pAd); #endif // WMM_ACM_SUPPORT // #ifdef WDS_SUPPORT WdsDown(pAd); #endif // WDS_SUPPORT // mdelay(20); /* wait for disconnect requests transmitted */ for (i = 0 ; i < NUM_OF_TX_RING; i++) { while (pAd->DeQueueRunning[i] == TRUE) { DBGPRINT(RT_DEBUG_TRACE, ("Waiting for TxQueue[%d] done..........\n", i)); RTMPusecDelay(1000); } } #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { #ifdef DOT11N_DRAFT3 if (pAd->CommonCfg.Bss2040CoexistFlag & BSS_2040_COEXIST_TIMER_FIRED) { RTMPCancelTimer(&pAd->CommonCfg.Bss2040CoexistTimer, &Cancelled); pAd->CommonCfg.Bss2040CoexistFlag = 0; } #endif // DOT11N_DRAFT3 // // PeriodicTimer already been canceled by MlmeHalt() API. //RTMPCancelTimer(&pAd->PeriodicTimer, &Cancelled); } #endif // CONFIG_AP_SUPPORT // // Stop Mlme state machine MlmeHalt(pAd); // Close net tasklets RtmpNetTaskExit(pAd); #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { #ifdef MAT_SUPPORT MATEngineExit(pAd); #endif // MAT_SUPPORT // #ifdef CLIENT_WDS CliWds_ProxyTabDestory(pAd); #endif // CLIENT_WDS // // Shutdown Access Point function, release all related resources APShutdown(pAd); #ifdef AUTO_CH_SELECT_ENHANCE // Free BssTab & ChannelInfo tabbles. AutoChBssTableDestroy(pAd); ChannelInfoDestroy(pAd); #endif // AUTO_CH_SELECT_ENHANCE // } #endif // CONFIG_AP_SUPPORT // MeasureReqTabExit(pAd); TpcReqTabExit(pAd); #ifdef WSC_INCLUDED #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { INT ap_idx; for (ap_idx = 0; ap_idx < pAd->ApCfg.BssidNum; ap_idx++) { PWSC_CTRL pWpsCtrl = &pAd->ApCfg.MBSSID[ap_idx].WscControl; WscStop(pAd, FALSE, pWpsCtrl); } #ifdef APCLI_SUPPORT WscStop(pAd, TRUE, &pAd->ApCfg.ApCliTab[BSS0].WscControl); #endif // APCLI_SUPPORT // } #endif // CONFIG_AP_SUPPORT // #ifdef OLD_DH_KEY #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) WSC_VFREE_KEY_MEM(pAd->ApCfg.MBSSID[0].WscControl.pPubKeyMem, pAd->ApCfg.MBSSID[0].WscControl.pSecKeyMem); #endif // CONFIG_AP_SUPPORT // #endif // OLD_DH_KEY // /* WSC hardware push button function 0811 */ WSC_HDR_BTN_Stop(pAd); #endif // WSC_INCLUDED // // Close kernel threads RtmpMgmtTaskExit(pAd); #ifdef RTMP_MAC_PCI { BOOLEAN brc; // ULONG Value; if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) { RTMP_ASIC_INTERRUPT_DISABLE(pAd); } // Receive packets to clear DMA index after disable interrupt. //RTMPHandleRxDoneInterrupt(pAd); // put to radio off to save power when driver unload. After radiooff, can't write /read register. So need to finish all // register access before Radio off. brc=RT28xxPciAsicRadioOff(pAd, RTMP_HALT, 0); //In solution 3 of 3090F, the bPCIclkOff will be set to TRUE after calling RT28xxPciAsicRadioOff #ifdef PCIE_PS_SUPPORT pAd->bPCIclkOff = FALSE; #endif // PCIE_PS_SUPPORT // if (brc==FALSE) { DBGPRINT(RT_DEBUG_ERROR,("%s call RT28xxPciAsicRadioOff fail !!\n", __FUNCTION__)); } } /* if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) { RTMP_ASIC_INTERRUPT_DISABLE(pAd); } // Disable Rx, register value supposed will remain after reset NICIssueReset(pAd); */ #endif // RTMP_MAC_PCI // // Free IRQ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { #ifdef RTMP_MAC_PCI // Deregister interrupt function RtmpOSIRQRelease(net_dev); #endif // RTMP_MAC_PCI // RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE); } #ifdef RESOURCE_PRE_ALLOC RTMPResetTxRxRingMemory(pAd); #else // Free Ring or USB buffers RTMPFreeTxRxRingMemory(pAd); #endif // RESOURCE_PRE_ALLOC // 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); /*+++Modify by woody to solve the bulk fail+++*/ #ifdef VENDOR_FEATURE2_SUPPORT printk("Number of Packet Allocated = %d\n", pAd->NumOfPktAlloc); printk("Number of Packet Freed = %d\n", pAd->NumOfPktFree); #endif // VENDOR_FEATURE2_SUPPORT // /* clear MAC table */ /* TODO: do not clear spin lock, such as fLastChangeAccordingMfbLock */ NdisZeroMemory(&pAd->MacTab, sizeof(MAC_TABLE)); /* release all timers */ RTMPusecDelay(2000); RTMP_TimerListRelease(pAd); DBGPRINT(RT_DEBUG_TRACE, ("<=== rt28xx_close\n")); return 0; // close ok } /* End of rt28xx_close */
/* ======================================================================== Routine Description: Close raxx interface. Arguments: *net_dev the raxx interface pointer Return Value: 0 Open OK otherwise Open Fail Note: 1. if open fail, kernel will not call the close function. 2. Free memory for (1) Mlme Memory Handler: MlmeHalt() (2) TX & RX: RTMPFreeTxRxRingMemory() (3) BA Reordering: ba_reordering_resource_release() ======================================================================== */ int rt28xx_close(IN PNET_DEV dev) { struct net_device * net_dev = (struct net_device *)dev; RTMP_ADAPTER *pAd = NULL; BOOLEAN Cancelled; UINT32 i = 0; GET_PAD_FROM_NET_DEV(pAd, net_dev); DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n")); Cancelled = FALSE; // Sanity check for pAd if (pAd == NULL) return 0; // close ok #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { #ifdef PCIE_PS_SUPPORT RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_CLOSE); #endif // PCIE_PS_SUPPORT // // If dirver doesn't wake up firmware here, // NICLoadFirmware will hang forever when interface is up again. if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) { AsicForceWakeup(pAd, TRUE); } #ifdef RTMP_MAC_PCI pAd->bPCIclkOff = FALSE; #endif // RTMP_MAC_PCI // } #endif // CONFIG_STA_SUPPORT // RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); #ifdef WDS_SUPPORT WdsDown(pAd); #endif // WDS_SUPPORT // for (i = 0 ; i < NUM_OF_TX_RING; i++) { while (pAd->DeQueueRunning[i] == TRUE) { DBGPRINT(RT_DEBUG_TRACE, ("Waiting for TxQueue[%d] done..........\n", i)); RTMPusecDelay(1000); } } // Stop Mlme state machine MlmeHalt(pAd); // Close net tasklets RtmpNetTaskExit(pAd); #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { MacTableReset(pAd); #ifdef LED_CONTROL_SUPPORT RTMPSetLED(pAd, LED_LINK_DOWN); #endif // LED_CONTROL_SUPPORT // MlmeRadioOff(pAd); } #endif // CONFIG_STA_SUPPORT // MeasureReqTabExit(pAd); TpcReqTabExit(pAd); // Close kernel threads RtmpMgmtTaskExit(pAd); #ifdef RTMP_MAC_PCI { BOOLEAN brc; // ULONG Value; if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) { RTMP_ASIC_INTERRUPT_DISABLE(pAd); } // Receive packets to clear DMA index after disable interrupt. //RTMPHandleRxDoneInterrupt(pAd); // put to radio off to save power when driver unload. After radiooff, can't write /read register. So need to finish all // register access before Radio off. brc=RT28xxPciAsicRadioOff(pAd, RTMP_HALT, 0); //In solution 3 of 3090F, the bPCIclkOff will be set to TRUE after calling RT28xxPciAsicRadioOff #ifdef PCIE_PS_SUPPORT pAd->bPCIclkOff = FALSE; #endif // PCIE_PS_SUPPORT // if (brc==FALSE) { DBGPRINT(RT_DEBUG_ERROR,("%s call RT28xxPciAsicRadioOff fail !!\n", __FUNCTION__)); } } /* if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) { RTMP_ASIC_INTERRUPT_DISABLE(pAd); } // Disable Rx, register value supposed will remain after reset NICIssueReset(pAd); */ #endif // RTMP_MAC_PCI // // Free IRQ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { #ifdef RTMP_MAC_PCI // Deregister interrupt function RtmpOSIRQRelease(net_dev); #endif // RTMP_MAC_PCI // RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE); } #ifdef RESOURCE_PRE_ALLOC RTMPResetTxRxRingMemory(pAd); #else // Free Ring or USB buffers RTMPFreeTxRxRingMemory(pAd); #endif // RESOURCE_PRE_ALLOC // 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 // #ifdef CONFIG_STA_SUPPORT #endif // CONFIG_STA_SUPPORT // RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP); /*+++Modify by woody to solve the bulk fail+++*/ #ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { } #endif // CONFIG_STA_SUPPORT // #ifdef VENDOR_FEATURE2_SUPPORT printk("Number of Packet Allocated = %d\n", pAd->NumOfPktAlloc); printk("Number of Packet Freed = %d\n", pAd->NumOfPktFree); #endif // VENDOR_FEATURE2_SUPPORT // DBGPRINT(RT_DEBUG_TRACE, ("<=== rt28xx_close\n")); return 0; // close ok } /* End of rt28xx_close */
/* ======================================================================== Routine Description: Open raxx interface. Arguments: *net_dev the raxx interface pointer Return Value: 0 Open OK otherwise Open Fail Note: ======================================================================== */ int rt28xx_open(struct net_device *dev) { struct net_device *net_dev = (struct net_device *)dev; struct rt_rtmp_adapter *pAd = NULL; int retval = 0; /*struct os_cookie *pObj; */ GET_PAD_FROM_NET_DEV(pAd, net_dev); /* Sanity check for pAd */ if (pAd == NULL) { /* if 1st open fail, pAd will be free; So the net_dev->ml_priv will be NULL in 2rd open */ return -1; } if (net_dev->priv_flags == INT_MAIN) { if (pAd->OpMode == OPMODE_STA) net_dev->wireless_handlers = (struct iw_handler_def *)&rt28xx_iw_handler_def; } /* Request interrupt service routine for PCI device */ /* register the interrupt routine with the os */ RtmpOSIRQRequest(net_dev); /* Init IRQ parameters stored in pAd */ RTMP_IRQ_INIT(pAd); /* Chip & other init */ if (rt28xx_init(pAd, mac, hostname) == FALSE) goto err; /* Enable Interrupt */ RTMP_IRQ_ENABLE(pAd); /* Now Enable RxTx */ RTMPEnableRxTx(pAd); RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP); { u32 reg = 0; RTMP_IO_READ32(pAd, 0x1300, ®); /* clear garbage interrupts */ printk("0x1300 = %08x\n", reg); } { /* u32 reg; */ /* u8 byte; */ /* u16 tmp; */ /* RTMP_IO_READ32(pAd, XIFS_TIME_CFG, ®); */ /* tmp = 0x0805; */ /* reg = (reg & 0xffff0000) | tmp; */ /* RTMP_IO_WRITE32(pAd, XIFS_TIME_CFG, reg); */ } #ifdef RTMP_MAC_PCI RTMPInitPCIeLinkCtrlValue(pAd); #endif /* RTMP_MAC_PCI // */ return (retval); err: /*+++Add by shiang, move from rt28xx_init() to here. */ RtmpOSIRQRelease(net_dev); /*---Add by shiang, move from rt28xx_init() to here. */ return (-1); } /* End of rt28xx_open */
/* ======================================================================== Routine Description: Close raxx interface. Arguments: *net_dev the raxx interface pointer Return Value: 0 Open OK otherwise Open Fail Note: 1. if open fail, kernel will not call the close function. 2. Free memory for (1) Mlme Memory Handler: MlmeHalt() (2) TX & RX: RTMPFreeTxRxRingMemory() (3) BA Reordering: ba_reordering_resource_release() ======================================================================== */ int rt28xx_close(struct net_device *dev) { struct net_device *net_dev = (struct net_device *)dev; struct rt_rtmp_adapter *pAd = NULL; BOOLEAN Cancelled; u32 i = 0; #ifdef RTMP_MAC_USB DECLARE_WAIT_QUEUE_HEAD(unlink_wakeup); DECLARE_WAITQUEUE(wait, current); #endif /* RTMP_MAC_USB // */ GET_PAD_FROM_NET_DEV(pAd, net_dev); DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n")); Cancelled = FALSE; /* Sanity check for pAd */ if (pAd == NULL) return 0; /* close ok */ { #ifdef RTMP_MAC_PCI RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_CLOSE); #endif /* RTMP_MAC_PCI // */ /* If dirver doesn't wake up firmware here, */ /* NICLoadFirmware will hang forever when interface is up again. */ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) { AsicForceWakeup(pAd, TRUE); } #ifdef RTMP_MAC_USB RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS); #endif /* RTMP_MAC_USB // */ MlmeRadioOff(pAd); #ifdef RTMP_MAC_PCI pAd->bPCIclkOff = FALSE; #endif /* RTMP_MAC_PCI // */ } RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); for (i = 0; i < NUM_OF_TX_RING; i++) { while (pAd->DeQueueRunning[i] == TRUE) { DBGPRINT(RT_DEBUG_TRACE, ("Waiting for TxQueue[%d] done..........\n", i)); RTMPusecDelay(1000); } } #ifdef RTMP_MAC_USB /* 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 /* RTMP_MAC_USB // */ /* Stop Mlme state machine */ MlmeHalt(pAd); /* Close net tasklets */ RtmpNetTaskExit(pAd); { MacTableReset(pAd); } MeasureReqTabExit(pAd); TpcReqTabExit(pAd); /* Close kernel threads */ RtmpMgmtTaskExit(pAd); #ifdef RTMP_MAC_PCI { BOOLEAN brc; /* unsigned long Value; */ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) { RTMP_ASIC_INTERRUPT_DISABLE(pAd); } /* Receive packets to clear DMA index after disable interrupt. */ /*RTMPHandleRxDoneInterrupt(pAd); */ /* put to radio off to save power when driver unload. After radiooff, can't write /read register. So need to finish all */ /* register access before Radio off. */ brc = RT28xxPciAsicRadioOff(pAd, RTMP_HALT, 0); /*In solution 3 of 3090F, the bPCIclkOff will be set to TRUE after calling RT28xxPciAsicRadioOff */ pAd->bPCIclkOff = FALSE; if (brc == FALSE) { DBGPRINT(RT_DEBUG_ERROR, ("%s call RT28xxPciAsicRadioOff fail!\n", __func__)); } } /* if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) { RTMP_ASIC_INTERRUPT_DISABLE(pAd); } // Disable Rx, register value supposed will remain after reset NICIssueReset(pAd); */ #endif /* RTMP_MAC_PCI // */ /* Free IRQ */ if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { #ifdef RTMP_MAC_PCI /* Deregister interrupt function */ RtmpOSIRQRelease(net_dev); #endif /* RTMP_MAC_PCI // */ RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE); } /* Free Ring or USB buffers */ RTMPFreeTxRxRingMemory(pAd); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); /* Free BA reorder resource */ ba_reordering_resource_release(pAd); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP); /*+++Modify by woody to solve the bulk fail+++*/ { } DBGPRINT(RT_DEBUG_TRACE, ("<=== rt28xx_close\n")); return 0; /* close ok */ } /* End of rt28xx_close */
int rt28xx_open(IN PNET_DEV dev) { struct net_device * net_dev = (struct net_device *)dev; PRTMP_ADAPTER pAd = NULL; int retval = 0; //POS_COOKIE pObj; GET_PAD_FROM_NET_DEV(pAd, net_dev); // Sanity check for pAd if (pAd == NULL) { /* if 1st open fail, pAd will be free; So the net_dev->priv will be NULL in 2rd open */ 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; } #endif // CONFIG_APSTA_MIXED_SUPPORT // #if WIRELESS_EXT >= 12 if (net_dev->priv_flags == INT_MAIN) { #ifdef CONFIG_APSTA_MIXED_SUPPORT if (pAd->OpMode == OPMODE_AP) net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def; #endif // CONFIG_APSTA_MIXED_SUPPORT // #ifdef CONFIG_STA_SUPPORT if (pAd->OpMode == OPMODE_STA) net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_iw_handler_def; #endif // CONFIG_STA_SUPPORT // } #endif // WIRELESS_EXT >= 12 // // Request interrupt service routine for PCI device // register the interrupt routine with the os /* AP Channel auto-selection will be run in rt28xx_init(), so we must reqister IRQ hander here. */ RtmpOSIRQRequest(net_dev); // Init IRQ parameters stored in pAd RTMP_IRQ_INIT(pAd); // Chip & other init if (rt28xx_init(pAd, mac, hostname) == FALSE) goto err; #ifdef LINUX #ifdef RT_CFG80211_SUPPORT RT_CFG80211_REINIT(pAd); RT_CFG80211_CRDA_REG_RULE_APPLY(pAd); #endif // RT_CFG80211_SUPPORT // #endif // LINUX // #ifdef CONFIG_STA_SUPPORT #endif // CONFIG_STA_SUPPORT // // Enable Interrupt RTMP_IRQ_ENABLE(pAd); // Now Enable RxTx RTMPEnableRxTx(pAd); RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP); { UINT32 reg = 0; RTMP_IO_READ32(pAd, 0x1300, ®); // clear garbage interrupts //printk("0x1300 = %08x\n", reg); } #ifdef CONFIG_STA_SUPPORT #ifdef PCIE_PS_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) RTMPInitPCIeLinkCtrlValue(pAd); #endif // PCIE_PS_SUPPORT // #endif // CONFIG_STA_SUPPORT // #ifdef CONFIG_AP_SUPPORT #ifdef BG_FT_SUPPORT BG_FTPH_Init(); #endif // BG_FT_SUPPORT // #endif // CONFIG_AP_SUPPORT // #ifdef CONFIG_STA_SUPPORT /* To reduce connection time, do auto reconnect here instead of waiting STAMlmePeriodicExec to do auto reconnect. */ if (pAd->OpMode == OPMODE_STA) MlmeAutoReconnectLastSSID(pAd); #endif // CONFIG_STA_SUPPORT // #ifdef VENDOR_FEATURE2_SUPPORT printk("Number of Packet Allocated in open = %d\n", pAd->NumOfPktAlloc); printk("Number of Packet Freed in open = %d\n", pAd->NumOfPktFree); #endif // VENDOR_FEATURE2_SUPPORT // return (retval); err: //+++Add by shiang, move from rt28xx_init() to here. RtmpOSIRQRelease(net_dev); //---Add by shiang, move from rt28xx_init() to here. return (-1); } /* End of rt28xx_open */