1. kernel_modules/connectivity/wlan/gen4m/os/linux/gl_init.c
mtk_wcn_wlan_gen2_init-> initWlan();
initWlan(); ---------------wifi driver start !
#if DBG //defult closed; you can open it when you want to debug wifi log .
kalInitIOBuffer(); ----SDIO buf alloc
procInitFs(); ---dbglevel_ops(debug module and debug level)
--- proc_txdone_ops ("ARP", "DNS", "TCP", "UDP", "EAPOL", "DHCP", "ICMP")
--- auto_per_ops (Performance Configure)
--- country_ops// diff country support diff channel
重点关注一下国家码country_ops,此信息跟选择的工作频段 TX power 等有关。
Two Special country code:
COUNTRY_CODE_FF enable open for all channel for Certification
COUNTRY_CODE_FE disable open for all channel for Certification
static ssize_t procCountryWrite(struct file *file, const char __user *buffer,size_t count, loff_t *data);
wlanoidSetCountryCode WLAN_STATUS wlanoidSetCountryCode(IN P_ADAPTER_T prAdapter,
IN PVOID pvSetBuffer, IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
pucCountry = pvSetBuffer;
prAdapter->rWifiVar.rConnSettings.u2CountryCodeBakup = prAdapter->rWifiVar.rConnSettings.u2CountryCode;
(set country code complete)
* For example: 2.4GHz, 1~13, 20MHz ==> regulation class = 81
* 2.4GHz, 1~13, SCA ==> regulation class = 83
* 2.4GHz, 1~13, SCB ==> regulation class = 84
Force to re-search
rlmDomainSendCmd(prAdapter, TRUE);
1 .rlmDomainSendDomainInfoCmd(prAdapter, fgIsOid);
2. rlmDomainSendPwrLimitCmd(prAdapter);
3. rlmDomainSendPassiveScanInfoCmd(prAdapter, fgIsOid);
rlmDomainSendDomainInfoCmd(prAdapter, fgIsOid);
rlmDomainGetDomainInfo(prAdapter);
//defined three mothed to get country code:
1. by given table idx 2. by customized 3. by country code
rlmDomainSendPwrLimitCmd(prAdapter); //TX power limit
WLAN_GET_FIELD_BE16(&g_rRlmPowerLimitDefault[u2DefaultTableIndex].aucCountryCode[0],&prCmd->u2CountryCode); // Corresponding country TX power limit allocation
MAX_TX_POWER 63
MIN_TX_POWER -64
rlmDomainBuildCmdByDefaultTable(prCmd, u2DefaultTableIndex); //default table information
rlmDomainBuildCmdByConfigTable(prAdapter, prCmd); // configuration table information
rlmDomainSendPassiveScanInfoCmd(prAdapter, fgIsOid); //Set passive scan channel info to chip
createWirelessDevice();
/* <1.1> Create wireless_dev */
prWdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
/* <1.2> Create wiphy */
prWiphy = wiphy_new(&mtk_wlan_ops, sizeof(GLUE_INFO_T));
/* <1.3> configure wireless_dev & wiphy */
...
/* <1.4> wowlan support */
prWiphy->wowlan = &mtk_wlan_wowlan_support;
/* <1.5> Use wireless extension to replace IOCTL */
prWiphy->wext = &wext_handler_def;
/* <2> allocate and register net_device */
prNetDev = alloc_netdev_mq(sizeof(P_GLUE_INFO_T), NIC_INF_NAME, NET_NAME_PREDICTABLE,
ether_setup, CFG_MAX_TXQ_NUM);
prNetDev->netdev_ops = &wlan_netdev_ops;
/* <2.1> co-relate with wireless_dev bi-directionally */
prNetDev->ieee80211_ptr = prWdev;
prWdev->netdev = prNetDev;
/* <2.2> co-relate net device & device tree */
SET_NETDEV_DEV(prNetDev, wiphy_dev(prWiphy));
/* <2.3> register net_device */
register_netdev(prWdev->netdev)
createWirelessDevice -> /* <1.2> Create wiphy */
phy = wiphy_new(&mtk_wlan_ops, sizeof(GLUE_INFO_T)); Start
static struct cfg80211_ops mtk_wlan_ops = {
.suspend = mtk_cfg80211_suspend,
.resume = mtk_cfg80211_resume,
.change_virtual_intf = mtk_cfg80211_change_iface,
//wlanoidSetInfrastructureMode 1. Infrastructure Client (Non-AP STA) = AP + STA 2. Ad-Hoc IBSS = STA+ STA
.add_key = mtk_cfg80211_add_key,
// mtk_cfg80211_add_key -> wlanoidSetAddKey -> _wlanoidSetAddKey (wlan_oid.c)
According to the different prNewKey-> u4KeyLength, select the encryption method.
/* rKey.u4KeyIndex |= BIT(31);//Enable BIT 31 will make tx use bc key id,should use pairwise key id 0 */
.get_key = mtk_cfg80211_get_key,
.del_key = mtk_cfg80211_del_key,
.set_default_key = mtk_cfg80211_set_default_key,
.set_default_mgmt_key = mtk_cfg80211_set_default_mgmt_key,
.get_station = mtk_cfg80211_get_station,
//This routine is responsible for getting station information such as RSSI
/* 1. check BSSID */
UNEQUAL_MAC_ADDR(arBssid, mac)
/* 2. fill TX rate */
wlanoidQueryLinkSpeed
/* 3. fill RSSI */
wlanoidQueryRssi
Contradictory point:
rRssi = (PARAM_RSSI) prAdapter->rLinkQuality.cRssi; /* ranged from (-128 ~ 30) in unit of dBm */
#define PARAM_WHQL_RSSI_MAX_DBM (-10)
#define PARAM_WHQL_RSSI_MIN_DBM (-200)
/* 4. Fill Tx OK and Tx Bad */
wlanoidQueryStatisticsPL
.change_station = mtk_cfg80211_change_station,
.add_station = mtk_cfg80211_add_station,
.del_station = mtk_cfg80211_del_station,
.scan = mtk_cfg80211_scan,
#define CFG_SCAN_SSID_MAX_NUM (4)
#define CFG_SCAN_SSID_MATCH_MAX_NUM (16)
#if CFG_MULTI_SSID_SCAN
wlanoidSetBssidListScanAdv
wlanoidGetChannelInfo(prAdapter, prScanRequest->puPartialScanReq);// get channel list
aisFsmScanRequestAdv(prAdapter, ucSsidNum, rSsid, pucIe, u4IeLength);
{//遍历赋值ssid,此方法多次使用,请以适当的场景赋值为准
for (i = 0; i < ucSsidNum; i++) {
COPY_SSID(prAisFsmInfo->arScanSSID[i].aucSsid,
prAisFsmInfo->arScanSSID[i].u4SsidLen,
prSsid[i].aucSsid, prSsid[i].u4SsidLen);
}
/* start online scan */
wlanClearScanningResult(prAdapter);
aisFsmSteps(prAdapter, AIS_STATE_ONLINE_SCAN);
{
case AIS_STATE_ONLINE_SCAN:
1、//ssid 赋值(各种扫描方式宏控辅助)
COPY_SSID(prAisFsmInfo->rRoamingSSID.aucSsid,prAisFsmInfo->rRoamingSSID.u4SsidLen,prConnSettings->aucSSID,prConnSettings->ucSSIDLen);
2、//channel 获取
}
#else
wlanoidSetBssidListScanExt
// The difference between the two cases is: last case did not achieve aisFsmScanRequestAdv(fun :LIST_SCAN) function.
#endif
.connect = mtk_cfg80211_connect,
1. wlanoidSetInfrastructureMode
{
/* Verify the new infrastructure mode. */基础架构BSS 网络
if (eOpMode >= NET_TYPE_NUM) {
DBGLOG(OID, TRACE, "Invalid mode value %d\n", eOpMode);
return WLAN_STATUS_INVALID_DATA;
}
/* check if possible to switch