/*----------------------------------------------------------------------------*/ BOOLEAN rlmDomainIsLegalChannel ( P_ADAPTER_T prAdapter, ENUM_BAND_T eBand, UINT_8 ucChannel ) { UINT_8 i, j; P_DOMAIN_SUBBAND_INFO prSubband; P_DOMAIN_INFO_ENTRY prDomainInfo; prDomainInfo = rlmDomainGetDomainInfo(prAdapter); ASSERT(prDomainInfo); for (i = 0; i < MAX_SUBBAND_NUM; i++) { prSubband = &prDomainInfo->rSubBand[i]; if (prSubband->ucBand == BAND_5G && !prAdapter->fgEnable5GBand) { continue; } if (prSubband->ucBand == eBand) { for (j = 0; j < prSubband->ucNumChannels; j++) { if ((prSubband->ucFirstChannelNum + j*prSubband->ucChannelSpan) == ucChannel) { return TRUE; } } } } return FALSE; }
/*----------------------------------------------------------------------------*/ VOID rlmDomainSendCmd(P_ADAPTER_T prAdapter, BOOLEAN fgIsOid) { P_DOMAIN_INFO_ENTRY prDomainInfo; P_CMD_SET_DOMAIN_INFO_T prCmd; WLAN_STATUS rStatus; UINT_8 i; P_DOMAIN_SUBBAND_INFO prSubBand; prDomainInfo = rlmDomainGetDomainInfo(prAdapter); ASSERT(prDomainInfo); prCmd = cnmMemAlloc(prAdapter, RAM_TYPE_BUF, sizeof(CMD_SET_DOMAIN_INFO_T)); ASSERT(prCmd); /* To do: exception handle */ if (!prCmd) { DBGLOG(RLM, ERROR, ("Domain: no buf to send cmd\n")); return; } kalMemZero(prCmd, sizeof(CMD_SET_DOMAIN_INFO_T)); prCmd->u2CountryCode = prAdapter->rWifiVar.rConnSettings.u2CountryCode; prCmd->u2Reserved = 0; prCmd->uc2G4Bandwidth = prAdapter->rWifiVar.rConnSettings.uc2G4BandwidthMode; prCmd->uc5GBandwidth = prAdapter->rWifiVar.rConnSettings.uc5GBandwidthMode; for (i = 0; i < 6; i++) { prSubBand = &prDomainInfo->rSubBand[i]; prCmd->rSubBand[i].ucRegClass = prSubBand->ucRegClass; prCmd->rSubBand[i].ucBand = prSubBand->ucBand; if (prSubBand->ucBand != BAND_NULL && prSubBand->ucBand < BAND_NUM) { prCmd->rSubBand[i].ucChannelSpan = prSubBand->ucChannelSpan; prCmd->rSubBand[i].ucFirstChannelNum = prSubBand->ucFirstChannelNum; prCmd->rSubBand[i].ucNumChannels = prSubBand->ucNumChannels; } } /* Update domain info to chip */ rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */ CMD_ID_SET_DOMAIN_INFO, /* ucCID */ TRUE, /* fgSetQuery */ FALSE, /* fgNeedResp */ fgIsOid, /* fgIsOid */ NULL, /* pfCmdDoneHandler */ NULL, /* pfCmdTimeoutHandler */ sizeof(CMD_SET_DOMAIN_INFO_T), /* u4SetQueryInfoLen */ (PUINT_8) prCmd, /* pucInfoBuffer */ NULL, /* pvSetQueryBuffer */ 0 /* u4SetQueryBufferLen */ ); ASSERT(rStatus == WLAN_STATUS_PENDING); cnmMemFree(prAdapter, prCmd); }
/*----------------------------------------------------------------------------*/ ENUM_CHNL_EXT_T rlmDecideScoForAP ( P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo ) { P_DOMAIN_SUBBAND_INFO prSubband; P_DOMAIN_INFO_ENTRY prDomainInfo; UINT_8 ucSecondChannel, i, j; ENUM_CHNL_EXT_T eSCO; eSCO = CHNL_EXT_SCN; if (prBssInfo->eBand == BAND_2G4) { if (prBssInfo->ucPrimaryChannel != 14) { eSCO = (prBssInfo->ucPrimaryChannel > 7) ? CHNL_EXT_SCB : CHNL_EXT_SCA; } } else { prDomainInfo = rlmDomainGetDomainInfo(prAdapter); ASSERT(prDomainInfo); for (i = 0; i < MAX_SUBBAND_NUM; i++) { prSubband = &prDomainInfo->rSubBand[i]; if (prSubband->ucBand == prBssInfo->eBand) { for (j = 0; j < prSubband->ucNumChannels; j++) { if ((prSubband->ucFirstChannelNum + j*prSubband->ucChannelSpan) == prBssInfo->ucPrimaryChannel) { eSCO = (j & 1) ? CHNL_EXT_SCB : CHNL_EXT_SCA; break; } } if (j < prSubband->ucNumChannels) { break; /* Found */ } } } } /* Check if it is boundary channel and 40MHz BW is permitted */ if (eSCO != CHNL_EXT_SCN) { ucSecondChannel = (eSCO == CHNL_EXT_SCA) ? (prBssInfo->ucPrimaryChannel+ 4) : (prBssInfo->ucPrimaryChannel- 4); if (!rlmDomainIsLegalChannel(prAdapter, prBssInfo->eBand, ucSecondChannel)){ eSCO = CHNL_EXT_SCN; } } return eSCO; }
/*----------------------------------------------------------------------------*/ VOID rlmDomainGetChnlList(P_ADAPTER_T prAdapter, ENUM_BAND_T eSpecificBand, UINT_8 ucMaxChannelNum, PUINT_8 pucNumOfChannel, P_RF_CHANNEL_INFO_T paucChannelList) { UINT_8 i, j, ucNum; P_DOMAIN_SUBBAND_INFO prSubband; P_DOMAIN_INFO_ENTRY prDomainInfo; ASSERT(prAdapter); ASSERT(paucChannelList); ASSERT(pucNumOfChannel); /* If no matched country code, the final one will be used */ prDomainInfo = rlmDomainGetDomainInfo(prAdapter); ASSERT(prDomainInfo); ucNum = 0; for (i = 0; i < MAX_SUBBAND_NUM; i++) { prSubband = &prDomainInfo->rSubBand[i]; if (prSubband->ucBand == BAND_NULL || prSubband->ucBand >= BAND_NUM || (prSubband->ucBand == BAND_5G && !prAdapter->fgEnable5GBand)) { continue; } if (eSpecificBand == BAND_NULL || prSubband->ucBand == eSpecificBand) { for (j = 0; j < prSubband->ucNumChannels; j++) { if (ucNum >= ucMaxChannelNum) { break; } paucChannelList[ucNum].eBand = prSubband->ucBand; paucChannelList[ucNum].ucChannelNum = prSubband->ucFirstChannelNum + j * prSubband->ucChannelSpan; ucNum++; } } } *pucNumOfChannel = ucNum; }
/*----------------------------------------------------------------------------*/ VOID rlmFuncInitialChannelList(IN P_ADAPTER_T prAdapter) { P_P2P_CONNECTION_SETTINGS_T prP2pConnSetting = (P_P2P_CONNECTION_SETTINGS_T) NULL; P_DOMAIN_INFO_ENTRY prDomainInfoEntry = (P_DOMAIN_INFO_ENTRY) NULL; P_DOMAIN_SUBBAND_INFO prDomainSubBand = (P_DOMAIN_SUBBAND_INFO) NULL; P_CHANNEL_ENTRY_FIELD_T prChannelEntryField = (P_CHANNEL_ENTRY_FIELD_T) NULL; UINT_32 u4Idx = 0, u4IdxII = 0; UINT_8 ucBufferSize = P2P_MAX_SUPPORTED_CHANNEL_LIST_SIZE; #if 0 UINT_8 ucSocialChnlSupport = 0, ucAutoChnl = 0; #endif do { ASSERT_BREAK(prAdapter != NULL); prP2pConnSetting = prAdapter->rWifiVar.prP2PConnSettings; #if 0 ucAutoChnl = prP2pConnSetting->ucOperatingChnl; #endif prDomainInfoEntry = rlmDomainGetDomainInfo(prAdapter); ASSERT_BREAK((prDomainInfoEntry != NULL) && (prP2pConnSetting != NULL)); prChannelEntryField = (P_CHANNEL_ENTRY_FIELD_T) prP2pConnSetting->aucChannelEntriesField; for (u4Idx = 0; u4Idx < MAX_SUBBAND_NUM; u4Idx++) { prDomainSubBand = &prDomainInfoEntry->rSubBand[u4Idx]; if (((prDomainSubBand->ucBand == BAND_5G) && (!prAdapter->fgEnable5GBand)) || (prDomainSubBand->ucBand == BAND_NULL)) { continue; } if (ucBufferSize < (P2P_ATTRI_LEN_CHANNEL_ENTRY + prDomainSubBand->ucNumChannels)) { /* Buffer is not enough to include all supported channels. */ break; /* for */ } prChannelEntryField->ucRegulatoryClass = prDomainSubBand->ucRegClass; prChannelEntryField->ucNumberOfChannels = prDomainSubBand->ucNumChannels; for (u4IdxII = 0; u4IdxII < prDomainSubBand->ucNumChannels; u4IdxII++) { prChannelEntryField->aucChannelList[u4IdxII] = prDomainSubBand->ucFirstChannelNum + (u4IdxII * prDomainSubBand->ucChannelSpan); #if 0 switch (prChannelEntryField->aucChannelList[u4IdxII]) { case 1: ucSocialChnlSupport = 1; break; case 6: ucSocialChnlSupport = 6; break; case 11: ucSocialChnlSupport = 11; break; default: break; } #endif } if (ucBufferSize >= (P2P_ATTRI_LEN_CHANNEL_ENTRY + prChannelEntryField->ucNumberOfChannels)) { ucBufferSize -= (P2P_ATTRI_LEN_CHANNEL_ENTRY + prChannelEntryField->ucNumberOfChannels); } else { break; } prChannelEntryField = (P_CHANNEL_ENTRY_FIELD_T) ((UINT_32) prChannelEntryField + P2P_ATTRI_LEN_CHANNEL_ENTRY + (UINT_32) prChannelEntryField-> ucNumberOfChannels); } #if 0 if (prP2pConnSetting->ucListenChnl == 0) { prP2pConnSetting->ucListenChnl = P2P_DEFAULT_LISTEN_CHANNEL; if (ucSocialChnlSupport != 0) { /* 1. User Not Set LISTEN channel. * 2. Social channel is not empty. */ prP2pConnSetting->ucListenChnl = ucSocialChnlSupport; } } #endif /* TODO: 20110921 frog - */ /* If LISTEN channel is not set, * a random supported channel would be set. * If no social channel is supported, DEFAULT channel would be set. */ prP2pConnSetting->ucRfChannelListSize = P2P_MAX_SUPPORTED_CHANNEL_LIST_SIZE - ucBufferSize; #if 0 if (prP2pConnSetting->ucOperatingChnl == 0) { /* User not set OPERATE channel. */ if (scnQuerySparseChannel(prAdapter, NULL, &ucAutoChnl)) { break; /* while */ } ucBufferSize = prP2pConnSetting->ucRfChannelListSize; prChannelEntryField = (P_CHANNEL_ENTRY_FIELD_T) prP2pConnSetting->aucChannelEntriesField; while (ucBufferSize != 0) { if (prChannelEntryField->ucNumberOfChannels != 0) { ucAutoChnl = prChannelEntryField->aucChannelList[0]; break; /* while */ } else { prChannelEntryField = (P_CHANNEL_ENTRY_FIELD_T) ((UINT_32) prChannelEntryField + P2P_ATTRI_LEN_CHANNEL_ENTRY + (UINT_32) prChannelEntryField-> ucNumberOfChannels); ucBufferSize -= (P2P_ATTRI_LEN_CHANNEL_ENTRY + prChannelEntryField->ucNumberOfChannels); } } } #endif /* We assume user would not set a channel not in the channel list. * If so, the operating channel still depends on target deivce supporting capability. */ /* TODO: 20110921 frog - */ /* If the Operating channel is not set, a channel from supported channel list is set automatically. * If there is no supported channel in channel list, a DEFAULT channel is set. */ } while (FALSE); #if 0 prP2pConnSetting->ucOperatingChnl = ucAutoChnl; #endif return; } /* rlmFuncInitialChannelList */
/*----------------------------------------------------------------------------*/ VOID rlmDomainSendCmd ( P_ADAPTER_T prAdapter, BOOLEAN fgIsOid ) { P_DOMAIN_INFO_ENTRY prDomainInfo; P_CMD_SET_DOMAIN_INFO_T prCmd; WLAN_STATUS rStatus; P_DOMAIN_SUBBAND_INFO prSubBand; UINT_8 i; prDomainInfo = rlmDomainGetDomainInfo(prAdapter); ASSERT(prDomainInfo); prCmd = cnmMemAlloc(prAdapter, RAM_TYPE_BUF, sizeof(CMD_SET_DOMAIN_INFO_T)); ASSERT(prCmd); /* To do: exception handle */ if (!prCmd) { DBGLOG(RLM, ERROR, ("Domain: no buf to send cmd\n")); return; } kalMemZero(prCmd, sizeof(CMD_SET_DOMAIN_INFO_T)); /* previous country code == FF : ignore country code, current country code == FE : resume */ if(prAdapter->rWifiVar.rConnSettings.u2CountryCodeBakup == COUNTRY_CODE_FF){ if (prAdapter->rWifiVar.rConnSettings.u2CountryCode != COUNTRY_CODE_FE){ DBGLOG(RLM, INFO, ("Domain: skip country code cmd (0x%x)\n",prAdapter->rWifiVar.rConnSettings.u2CountryCode)); return; }else{ DBGLOG(RLM, INFO, ("Domain: disable skip country code cmd (0x%x)\n",prAdapter->rWifiVar.rConnSettings.u2CountryCode)); } } prAdapter->rWifiVar.rConnSettings.u2CountryCodeBakup = prAdapter->rWifiVar.rConnSettings.u2CountryCode; DBGLOG(RLM, INFO, ("Domain: country code backup %x \n",prAdapter->rWifiVar.rConnSettings.u2CountryCodeBakup)); prCmd->u2CountryCode = prAdapter->rWifiVar.rConnSettings.u2CountryCode; prCmd->u2IsSetPassiveScan = 0; prCmd->uc2G4Bandwidth = prAdapter->rWifiVar.rConnSettings.uc2G4BandwidthMode; prCmd->uc5GBandwidth = prAdapter->rWifiVar.rConnSettings.uc5GBandwidthMode; prCmd->aucReserved[0] = 0; prCmd->aucReserved[1] = 0; for (i = 0; i < 6; i++) { prSubBand = &prDomainInfo->rSubBand[i]; prCmd->rSubBand[i].ucRegClass = prSubBand->ucRegClass; prCmd->rSubBand[i].ucBand = prSubBand->ucBand; if (prSubBand->ucBand != BAND_NULL && prSubBand->ucBand < BAND_NUM) { prCmd->rSubBand[i].ucChannelSpan = prSubBand->ucChannelSpan; prCmd->rSubBand[i].ucFirstChannelNum = prSubBand->ucFirstChannelNum; prCmd->rSubBand[i].ucNumChannels = prSubBand->ucNumChannels; } } DBGLOG(RLM, INFO, ("rlmDomainSendCmd(), SetQueryCmd\n")); /* Update domain info to chip */ rStatus = wlanSendSetQueryCmd ( prAdapter, /* prAdapter */ CMD_ID_SET_DOMAIN_INFO, /* ucCID */ TRUE, /* fgSetQuery */ FALSE, /* fgNeedResp */ fgIsOid, /* fgIsOid */ NULL, /* pfCmdDoneHandler*/ NULL, /* pfCmdTimeoutHandler */ sizeof(CMD_SET_DOMAIN_INFO_T), /* u4SetQueryInfoLen */ (PUINT_8) prCmd, /* pucInfoBuffer */ NULL, /* pvSetQueryBuffer */ 0 /* u4SetQueryBufferLen */ ); ASSERT(rStatus == WLAN_STATUS_PENDING); cnmMemFree(prAdapter, prCmd); rlmDomainPassiveScanSendCmd(prAdapter, fgIsOid); }
/*----------------------------------------------------------------------------*/ ENUM_CHNL_EXT_T rlmDecideScoForAP(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo) { P_DOMAIN_SUBBAND_INFO prSubband; P_DOMAIN_INFO_ENTRY prDomainInfo; UINT_8 ucSecondChannel, i, j; ENUM_CHNL_EXT_T eSCO; ENUM_CHNL_EXT_T eTempSCO; eSCO = CHNL_EXT_SCN; eTempSCO = CHNL_EXT_SCN; if (prBssInfo->eBand == BAND_2G4) { if (prBssInfo->ucPrimaryChannel != 14) { eSCO = (prBssInfo->ucPrimaryChannel > 7) ? CHNL_EXT_SCB : CHNL_EXT_SCA; } } else { prDomainInfo = rlmDomainGetDomainInfo(prAdapter); ASSERT(prDomainInfo); for (i = 0; i < MAX_SUBBAND_NUM; i++) { prSubband = &prDomainInfo->rSubBand[i]; if (prSubband->ucBand == prBssInfo->eBand) { for (j = 0; j < prSubband->ucNumChannels; j++) { if ((prSubband->ucFirstChannelNum + j * prSubband->ucChannelSpan) == prBssInfo->ucPrimaryChannel) { eSCO = (j & 1) ? CHNL_EXT_SCB : CHNL_EXT_SCA; break; } } if (j < prSubband->ucNumChannels) { break; /* Found */ } } } } /* Check if it is boundary channel and 40MHz BW is permitted */ if (eSCO != CHNL_EXT_SCN) { ucSecondChannel = (eSCO == CHNL_EXT_SCA) ? (prBssInfo->ucPrimaryChannel + 4) : (prBssInfo->ucPrimaryChannel - 4); if (!rlmDomainIsLegalChannel(prAdapter, prBssInfo->eBand, ucSecondChannel)) { eSCO = CHNL_EXT_SCN; } } /* Overwrite SCO settings by wifi cfg */ if(IS_BSS_P2P(prBssInfo)) { /* AP mode */ if(p2pFuncIsAPMode(prAdapter->rWifiVar.prP2PConnSettings)) { if(prAdapter->rWifiVar.ucApSco == CHNL_EXT_SCA || prAdapter->rWifiVar.ucApSco == CHNL_EXT_SCB) { eTempSCO = (ENUM_CHNL_EXT_T)prAdapter->rWifiVar.ucApSco; } } /* P2P mode */ else { if(prAdapter->rWifiVar.ucP2pGoSco == CHNL_EXT_SCA || prAdapter->rWifiVar.ucP2pGoSco == CHNL_EXT_SCB) { eTempSCO = (ENUM_CHNL_EXT_T)prAdapter->rWifiVar.ucP2pGoSco; } } /* Check again if it is boundary channel and 40MHz BW is permitted */ if(eTempSCO != CHNL_EXT_SCN) { ucSecondChannel = (eTempSCO == CHNL_EXT_SCA) ? (prBssInfo->ucPrimaryChannel+ 4) : (prBssInfo->ucPrimaryChannel- 4); if(rlmDomainIsLegalChannel(prAdapter, prBssInfo->eBand, ucSecondChannel)) { eSCO = eTempSCO; } } } return eSCO; }