/* ======================================================================== Routine Description: Re-Initialize wireless channel/PHY in 2.4GHZ and 5GHZ. Arguments: pCB - CFG80211 control block pointer pBandInfo - Band information Return Value: true - re-init successfully false - re-init fail Note: CFG80211_SupBandInit() is called in xx_probe(). But we do not have complete chip information in xx_probe() so we need to re-init bands in xx_open(). ======================================================================== */ bool CFG80211OS_SupBandReInit( IN VOID *pCB, IN CFG80211_BAND *pBandInfo) { struct mt7612u_cfg80211_cb *pCfg80211_CB = (struct mt7612u_cfg80211_cb *)pCB; struct wiphy *pWiphy; if ((pCfg80211_CB == NULL) || (pCfg80211_CB->pCfg80211_Wdev == NULL)) return false; pWiphy = pCfg80211_CB->pCfg80211_Wdev->wiphy; if (pWiphy != NULL) { CFG80211DBG(RT_DEBUG_ERROR, ("80211> re-init bands...\n")); /* re-init bands */ CFG80211_SupBandInit(pCfg80211_CB, pBandInfo, pWiphy, pCfg80211_CB->pCfg80211_Channels, pCfg80211_CB->pCfg80211_Rates); /* re-init PHY */ pWiphy->rts_threshold = pBandInfo->RtsThreshold; pWiphy->frag_threshold = pBandInfo->FragmentThreshold; pWiphy->retry_short = pBandInfo->RetryMaxCnt & 0xff; pWiphy->retry_long = (pBandInfo->RetryMaxCnt & 0xff00)>>8; return true; }
/* ======================================================================== Routine Description: Re-Initialize wireless channel/PHY in 2.4GHZ and 5GHZ. Arguments: pCB - CFG80211 control block pointer pBandInfo - Band information Return Value: TRUE - re-init successfully FALSE - re-init fail Note: CFG80211_SupBandInit() is called in xx_probe(). But we do not have complete chip information in xx_probe() so we need to re-init bands in xx_open(). ======================================================================== */ BOOLEAN CFG80211OS_SupBandReInit(void *pCB, CFG80211_BAND *pBandInfo) { CFG80211_CB *pCfg80211_CB = (CFG80211_CB *)pCB; struct wiphy *pWiphy; if ((pCfg80211_CB == NULL) || (pCfg80211_CB->pCfg80211_Wdev == NULL)) return FALSE; pWiphy = pCfg80211_CB->pCfg80211_Wdev->wiphy; if (pWiphy != NULL) { CFG80211DBG(RT_DEBUG_ERROR, ("80211> re-init bands...\n")); /* re-init bands */ CFG80211_SupBandInit(pCfg80211_CB, pBandInfo, pWiphy, pCfg80211_CB->pCfg80211_Channels, pCfg80211_CB->pCfg80211_Rates); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) /* re-init PHY */ pWiphy->rts_threshold = pBandInfo->RtsThreshold; pWiphy->frag_threshold = pBandInfo->FragmentThreshold; pWiphy->retry_short = pBandInfo->RetryMaxCnt & 0xff; pWiphy->retry_long = (pBandInfo->RetryMaxCnt & 0xff00)>>8; #endif /* LINUX_VERSION_CODE */ return TRUE; }
/* ======================================================================== Routine Description: Allocate a wireless device. Arguments: pAd - WLAN control block pointer pDev - Generic device interface Return Value: wireless device Note: ======================================================================== */ static struct wireless_dev *CFG80211_WdevAlloc( IN CFG80211_CB *pCfg80211_CB, IN CFG80211_BAND *pBandInfo, IN void *pAd, IN struct device *pDev) { struct wireless_dev *pWdev; ULONG *pPriv; /* * We're trying to have the following memory layout: * * +------------------------+ * | struct wiphy | * +------------------------+ * | pAd pointer | * +------------------------+ */ pWdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); if (pWdev == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("80211> Wireless device allocation fail!\n")); return NULL; } /* End of if */ pWdev->wiphy = wiphy_new(&CFG80211_Ops, sizeof(ULONG *)); if (pWdev->wiphy == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("80211> Wiphy device allocation fail!\n")); goto LabelErrWiphyNew; } /* End of if */ /* keep pAd pointer */ pPriv = (ULONG *)(wiphy_priv(pWdev->wiphy)); *pPriv = (ULONG)pAd; set_wiphy_dev(pWdev->wiphy, pDev); pWdev->wiphy->max_scan_ssids = pBandInfo->MaxBssTable; #ifdef CONFIG_STA_SUPPORT pWdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_MONITOR); #endif /* CONFIG_STA_SUPPORT */ pWdev->wiphy->reg_notifier = CFG80211_RegNotifier; /* init channel information */ CFG80211_SupBandInit(pCfg80211_CB, pBandInfo, pWdev->wiphy, NULL, NULL); /* CFG80211_SIGNAL_TYPE_MBM: signal strength in mBm (100*dBm) */ pWdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; pWdev->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; pWdev->wiphy->cipher_suites = CipherSuites; pWdev->wiphy->n_cipher_suites = ARRAY_SIZE(CipherSuites); if (wiphy_register(pWdev->wiphy) < 0) { DBGPRINT(RT_DEBUG_ERROR, ("80211> Register wiphy device fail!\n")); goto LabelErrReg; } /* End of if */ return pWdev; LabelErrReg: wiphy_free(pWdev->wiphy); LabelErrWiphyNew: kfree(pWdev); return NULL; } /* End of CFG80211_WdevAlloc */