qcacld-3.0: Re-indent function sap_select_channel

Fix indentation for function sap_select_channel

Change-Id: I079648a7f553689b14b7bf940fc835aa60e944b7
CRs-Fixed: 972906
This commit is contained in:
Naveen Rawat
2016-02-05 12:10:43 -08:00
committed by Gerrit - the friendly Code Review server
parent c43ee5b756
commit 365d1cb2dc

View File

@@ -1890,299 +1890,271 @@ bool sap_filter_over_lap_ch(ptSapContext pSapCtx, uint16_t chNum)
return eSAP_FALSE; return eSAP_FALSE;
} }
/*========================================================================== /**
FUNCTION sap_select_channel * sap_select_channel_no_scan_result() - select SAP channel when no scan results
* are available.
* @sap_ctx: Sap context
*
* Returns: channel number if success, 0 otherwise
*/
static uint8_t sap_select_channel_no_scan_result(ptSapContext sap_ctx)
{
enum channel_state ch_type;
uint32_t start_ch_num, end_ch_num;
#ifdef FEATURE_WLAN_CH_AVOID
uint8_t i, first_safe_ch_in_range = SAP_CHANNEL_NOT_SELECTED;
#endif
start_ch_num = sap_ctx->acs_cfg->start_ch;
end_ch_num = sap_ctx->acs_cfg->end_ch;
DESCRIPTION QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
Runs a algorithm to select the best channel to operate in based on BSS FL("start - end: %d - %d"), start_ch_num, end_ch_num);
rssi and bss count on each channel
DEPENDENCIES #ifndef FEATURE_WLAN_CH_AVOID
NA. sap_ctx->acs_cfg->pri_ch = start_ch_num;
sap_ctx->acs_cfg->ht_sec_ch = 0;
/* pick the first channel in configured range */
return start_ch_num;
#else
PARAMETERS /* get a channel in PCL and within the range */
for (i = 0; i < sap_ctx->acs_cfg->pcl_ch_count; i++) {
if ((sap_ctx->acs_cfg->pcl_channels[i] < start_ch_num) ||
(sap_ctx->acs_cfg->pcl_channels[i] > end_ch_num))
continue;
IN first_safe_ch_in_range = sap_ctx->acs_cfg->pcl_channels[i];
halHandle : Pointer to HAL handle break;
pResult : Pointer to tScanResultHandle }
RETURN VALUE if (SAP_CHANNEL_NOT_SELECTED != first_safe_ch_in_range)
uint8_t : Success - channel number, Fail - zero return first_safe_ch_in_range;
SIDE EFFECTS for (i = 0; i < NUM_CHANNELS; i++) {
============================================================================*/ if ((safe_channels[i].channelNumber < start_ch_num) ||
uint8_t sap_select_channel(tHalHandle halHandle, ptSapContext pSapCtx, (safe_channels[i].channelNumber > end_ch_num))
tScanResultHandle pScanResult) continue;
ch_type = cds_get_channel_state(safe_channels[i].channelNumber);
if ((ch_type == CHANNEL_STATE_DISABLE) ||
(ch_type == CHANNEL_STATE_INVALID))
continue;
if (safe_channels[i].isSafe == true) {
QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
FL("channel %d in the configuration is safe"),
safe_channels[i].channelNumber);
first_safe_ch_in_range = safe_channels[i].channelNumber;
break;
}
QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
FL("channel %d in the configuration is unsafe"),
safe_channels[i].channelNumber);
}
/* if no channel selected return SAP_CHANNEL_NOT_SELECTED */
return first_safe_ch_in_range;
#endif /* !FEATURE_WLAN_CH_AVOID */
}
/**
* sap_select_channel() - select SAP channel
* @hal: Pointer to HAL handle
* @sap_ctx: Sap context
* @scan_result: Pointer to tScanResultHandle
*
* Runs a algorithm to select the best channel to operate in based on BSS
* rssi and bss count on each channel
*
* Returns: channel number if success, 0 otherwise
*/
uint8_t sap_select_channel(tHalHandle hal, ptSapContext sap_ctx,
tScanResultHandle scan_result)
{ {
/* DFS param object holding all the data req by the algo */ /* DFS param object holding all the data req by the algo */
tSapChSelSpectInfo oSpectInfoParams = { NULL, 0 }; tSapChSelSpectInfo spect_info_obj = { NULL, 0 };
tSapChSelSpectInfo *pSpectInfoParams = &oSpectInfoParams; /* Memory? NB */ tSapChSelSpectInfo *spect_info = &spect_info_obj;
uint8_t bestChNum = SAP_CHANNEL_NOT_SELECTED; uint8_t best_ch_num = SAP_CHANNEL_NOT_SELECTED;
#ifdef FEATURE_WLAN_CH_AVOID
uint8_t i;
uint8_t firstSafeChannelInRange = SAP_CHANNEL_NOT_SELECTED;
#endif
#ifdef SOFTAP_CHANNEL_RANGE #ifdef SOFTAP_CHANNEL_RANGE
uint32_t startChannelNum;
uint32_t endChannelNum;
uint32_t operatingBand = 0;
uint32_t tmpChNum;
uint8_t count; uint8_t count;
uint32_t start_ch_num, end_ch_num, tmp_ch_num, operating_band = 0;
#endif #endif
QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
"In %s, Running SAP Ch Select", __func__); "In %s, Running SAP Ch Select", __func__);
#ifdef FEATURE_WLAN_CH_AVOID #ifdef FEATURE_WLAN_CH_AVOID
sap_update_unsafe_channel_list(pSapCtx); sap_update_unsafe_channel_list(sap_ctx);
#endif #endif
if (NULL == pScanResult) { if (NULL == scan_result) {
QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
"%s: No external AP present\n", __func__); FL("No external AP present"));
#ifndef SOFTAP_CHANNEL_RANGE #ifndef SOFTAP_CHANNEL_RANGE
return bestChNum; return SAP_CHANNEL_NOT_SELECTED;
#else #else
startChannelNum = pSapCtx->acs_cfg->start_ch; return sap_select_channel_no_scan_result(sap_ctx);
endChannelNum = pSapCtx->acs_cfg->end_ch; #endif
QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
"%s: start - end: %d - %d\n", __func__,
startChannelNum, endChannelNum);
#ifndef FEATURE_WLAN_CH_AVOID /* FEATURE_WLAN_CH_AVOID NOT defined case */
pSapCtx->acs_cfg->pri_ch = startChannelNum;
pSapCtx->acs_cfg->ht_sec_ch = 0;
/* pick the first channel in configured range */
return startChannelNum;
#else /* FEATURE_WLAN_CH_AVOID defined */
/* get a channel in PCL and within the range */
for (i = 0; i < pSapCtx->acs_cfg->pcl_ch_count; i++) {
if ((pSapCtx->acs_cfg->pcl_channels[i] >=
startChannelNum)
&& (pSapCtx->acs_cfg->pcl_channels[i] <=
endChannelNum)) {
firstSafeChannelInRange =
pSapCtx->acs_cfg->pcl_channels[i];
break;
}
}
if (SAP_CHANNEL_NOT_SELECTED != firstSafeChannelInRange)
return firstSafeChannelInRange;
for (i = 0; i < NUM_CHANNELS; i++) {
if ((safe_channels[i].channelNumber >= startChannelNum)
&& (safe_channels[i].channelNumber <=
endChannelNum)) {
enum channel_state channel_type =
cds_get_channel_state(safe_channels[i].
channelNumber);
if ((channel_type == CHANNEL_STATE_DISABLE) ||
(channel_type == CHANNEL_STATE_INVALID))
continue;
if (safe_channels[i].isSafe == true) {
QDF_TRACE(QDF_MODULE_ID_SAP,
QDF_TRACE_LEVEL_INFO_HIGH,
"%s: channel %d in the configuration is safe\n",
__func__,
safe_channels[i].
channelNumber);
firstSafeChannelInRange =
safe_channels[i].channelNumber;
break;
}
QDF_TRACE(QDF_MODULE_ID_SAP,
QDF_TRACE_LEVEL_INFO_HIGH,
"%s: channel %d in the configuration is unsafe\n",
__func__,
safe_channels[i].channelNumber);
}
}
/* if no channel selected return SAP_CHANNEL_NOT_SELECTED */
return firstSafeChannelInRange;
#endif /* !FEATURE_WLAN_CH_AVOID */
#endif /* SOFTAP_CHANNEL_RANGE */
} }
/* Initialize the structure pointed by pSpectInfoParams */ /* Initialize the structure pointed by spect_info */
if (sap_chan_sel_init(halHandle, pSpectInfoParams, pSapCtx) != eSAP_TRUE) { if (sap_chan_sel_init(hal, spect_info, sap_ctx) != eSAP_TRUE) {
QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
"In %s, Ch Select initialization failed", __func__); FL("Ch Select initialization failed"));
return SAP_CHANNEL_NOT_SELECTED; return SAP_CHANNEL_NOT_SELECTED;
} }
/* Compute the weight of the entire spectrum in the operating band */ /* Compute the weight of the entire spectrum in the operating band */
sap_compute_spect_weight(pSpectInfoParams, halHandle, pScanResult, sap_compute_spect_weight(spect_info, hal, scan_result, sap_ctx);
pSapCtx);
#ifdef FEATURE_AP_MCC_CH_AVOIDANCE #ifdef FEATURE_AP_MCC_CH_AVOIDANCE
/* process avoid channel IE to collect all channels to avoid */ /* process avoid channel IE to collect all channels to avoid */
sap_process_avoid_ie(halHandle, pSapCtx, pScanResult, pSpectInfoParams); sap_process_avoid_ie(hal, sap_ctx, scan_result, spect_info);
#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */ #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
#ifdef SOFTAP_CHANNEL_RANGE #ifdef SOFTAP_CHANNEL_RANGE
startChannelNum = pSapCtx->acs_cfg->start_ch; start_ch_num = sap_ctx->acs_cfg->start_ch;
endChannelNum = pSapCtx->acs_cfg->end_ch; end_ch_num = sap_ctx->acs_cfg->end_ch;
SET_ACS_BAND(operatingBand, pSapCtx); SET_ACS_BAND(operating_band, sap_ctx);
pSapCtx->acsBestChannelInfo.channelNum = 0; sap_ctx->acsBestChannelInfo.channelNum = 0;
pSapCtx->acsBestChannelInfo.weight = SAP_ACS_WEIGHT_MAX; sap_ctx->acsBestChannelInfo.weight = SAP_ACS_WEIGHT_MAX;
/* Sort the channel list as per the computed weights, lesser weight first. */ /* Sort the ch lst as per the computed weights, lesser weight first. */
sap_sort_chl_weight_all(pSapCtx, pSpectInfoParams, operatingBand); sap_sort_chl_weight_all(sap_ctx, spect_info, operating_band);
/*Loop till get the best channel in the given range */ /*Loop till get the best channel in the given range */
for (count = 0; count < pSpectInfoParams->numSpectChans; count++) { for (count = 0; count < spect_info->numSpectChans; count++) {
if ((startChannelNum <= pSpectInfoParams->pSpectCh[count].chNum) if ((start_ch_num > spect_info->pSpectCh[count].chNum) ||
&& (endChannelNum >= (end_ch_num < spect_info->pSpectCh[count].chNum))
pSpectInfoParams->pSpectCh[count].chNum)) { continue;
if (bestChNum == SAP_CHANNEL_NOT_SELECTED) {
bestChNum = if (best_ch_num == SAP_CHANNEL_NOT_SELECTED) {
pSpectInfoParams->pSpectCh[count].chNum; best_ch_num = spect_info->pSpectCh[count].chNum;
/* check if bestChNum is in preferred channel list */ /* check if best_ch_num is in preferred channel list */
bestChNum = best_ch_num =
sap_select_preferred_channel_from_channel_list sap_select_preferred_channel_from_channel_list(
(bestChNum, pSapCtx, pSpectInfoParams); best_ch_num, sap_ctx, spect_info);
if (bestChNum == SAP_CHANNEL_NOT_SELECTED) { /* if not in preferred ch lst, go to nxt best ch */
/* not in preferred channel list, go to next best channel */ if (best_ch_num == SAP_CHANNEL_NOT_SELECTED)
continue; continue;
}
#ifdef FEATURE_AP_MCC_CH_AVOIDANCE #ifdef FEATURE_AP_MCC_CH_AVOIDANCE
/* Weight of the channels(device's AP is /*
* operating) increased to MAX+1 so that they * Weight of the channels(device's AP is operating)
* will be choosen only when there is no other * increased to MAX+1 so that they will be choosen only
* best channel to choose * when there is no other best channel to choose
*/ */
if (sap_check_in_avoid_ch_list(pSapCtx, if (sap_check_in_avoid_ch_list(sap_ctx, best_ch_num)) {
bestChNum)) { best_ch_num = SAP_CHANNEL_NOT_SELECTED;
bestChNum = SAP_CHANNEL_NOT_SELECTED; continue;
continue; }
}
#endif #endif
pSapCtx->acsBestChannelInfo.channelNum = sap_ctx->acsBestChannelInfo.channelNum = best_ch_num;
bestChNum; sap_ctx->acsBestChannelInfo.weight =
pSapCtx->acsBestChannelInfo.weight = spect_info->pSpectCh[count].weight_copy;
pSpectInfoParams->
pSpectCh[count].
weight_copy;
}
if (bestChNum != SAP_CHANNEL_NOT_SELECTED) {
if (operatingBand == eCSR_DOT11_MODE_11g) {
/* Give preference to Non-overlap channels */
if (sap_filter_over_lap_ch(pSapCtx,
pSpectInfoParams->
pSpectCh[count].
chNum)) {
tmpChNum =
pSpectInfoParams->
pSpectCh[count].chNum;
tmpChNum =
sap_select_preferred_channel_from_channel_list
(tmpChNum, pSapCtx,
pSpectInfoParams);
if (tmpChNum !=
SAP_CHANNEL_NOT_SELECTED) {
bestChNum = tmpChNum;
break;
}
}
}
}
} }
if (best_ch_num == SAP_CHANNEL_NOT_SELECTED)
continue;
if (operating_band != eCSR_DOT11_MODE_11g)
continue;
/* Give preference to Non-overlap channels */
if (false == sap_filter_over_lap_ch(sap_ctx,
spect_info->pSpectCh[count].chNum))
continue;
tmp_ch_num = spect_info->pSpectCh[count].chNum;
tmp_ch_num = sap_select_preferred_channel_from_channel_list(
tmp_ch_num, sap_ctx, spect_info);
if (tmp_ch_num == SAP_CHANNEL_NOT_SELECTED)
continue;
best_ch_num = tmp_ch_num;
break;
} }
#else #else
/* Sort the channel list as per the computed weights, lesser weight first. */ /* Sort the ch lst as per the computed weights, lesser weight first. */
sap_sort_chl_weight_all(pSapCtx, halHandle, pSpectInfoParams); sap_sort_chl_weight_all(sap_ctx, hal, spect_info);
/* Get the first channel in sorted array as best 20M Channel */ /* Get the first channel in sorted array as best 20M Channel */
bestChNum = (uint8_t) pSpectInfoParams->pSpectCh[0].chNum; best_ch_num = (uint8_t) spect_info->pSpectCh[0].chNum;
/* Select Best Channel from Channel List if Configured */ /* Select Best Channel from Channel List if Configured */
bestChNum = sap_select_preferred_channel_from_channel_list(bestChNum, best_ch_num = sap_select_preferred_channel_from_channel_list(
pSapCtx, best_ch_num, sap_ctx, spect_info);
pSpectInfoParams);
#endif #endif
/** in case the best channel seleted is not in PCL and there is another /*
* in case the best channel seleted is not in PCL and there is another
* channel which has same weightage and is in PCL, choose the one in * channel which has same weightage and is in PCL, choose the one in
* PCL * PCL
*/ */
for (count = 0; count < pSpectInfoParams->numSpectChans; count++) { for (count = 0; count < spect_info->numSpectChans; count++) {
/** check if a pcl channel has the same weightage if (!ch_in_pcl(sap_ctx, spect_info->pSpectCh[count].chNum) ||
* as the best channel (spect_info->pSpectCh[count].weight !=
*/ sap_ctx->acsBestChannelInfo.weight))
if (ch_in_pcl(pSapCtx, pSpectInfoParams->pSpectCh[count].chNum) continue;
&& (pSpectInfoParams->pSpectCh[count].weight ==
pSapCtx->acsBestChannelInfo.weight)) { if (sap_select_preferred_channel_from_channel_list(
if (sap_select_preferred_channel_from_channel_list( spect_info->pSpectCh[count].chNum, sap_ctx, spect_info)
pSpectInfoParams->pSpectCh[count].chNum, == SAP_CHANNEL_NOT_SELECTED)
pSapCtx, pSpectInfoParams) == continue;
SAP_CHANNEL_NOT_SELECTED)
continue;
#ifdef FEATURE_AP_MCC_CH_AVOIDANCE #ifdef FEATURE_AP_MCC_CH_AVOIDANCE
if (sap_check_in_avoid_ch_list(pSapCtx, bestChNum)) if (sap_check_in_avoid_ch_list(sap_ctx, best_ch_num))
continue; continue;
#endif #endif
bestChNum = pSpectInfoParams->pSpectCh[count].chNum; best_ch_num = spect_info->pSpectCh[count].chNum;
QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
QDF_TRACE_LEVEL_INFO_HIGH, FL("change best channel to %d in PCL"), best_ch_num);
"change best channel to %d in PCL", break;
bestChNum);
break;
}
} }
pSapCtx->acs_cfg->pri_ch = bestChNum; sap_ctx->acs_cfg->pri_ch = best_ch_num;
/* determine secondary channel for 2.4G channel 5, 6, 7 in HT40 */ /* determine secondary channel for 2.4G channel 5, 6, 7 in HT40 */
if ((operatingBand == eCSR_DOT11_MODE_11g) && if ((operating_band != eCSR_DOT11_MODE_11g) ||
(pSapCtx->acs_cfg->ch_width == CH_WIDTH_40MHZ)) { (sap_ctx->acs_cfg->ch_width != CH_WIDTH_40MHZ))
if ((bestChNum >= 5) && (bestChNum <= 7)) { goto sap_ch_sel_end;
int weight_below, weight_above, i;
tSapSpectChInfo *pspect_info;
weight_below = weight_above = SAP_ACS_WEIGHT_MAX; if ((best_ch_num >= 5) && (best_ch_num <= 7)) {
pspect_info = pSpectInfoParams->pSpectCh; int weight_below, weight_above, i;
for (i = 0; i < pSpectInfoParams->numSpectChans; tSapSpectChInfo *pspect_info;
i++) {
if (pspect_info[i].chNum == (bestChNum - 4))
weight_below = pspect_info[i].weight;
if (pspect_info[i].chNum == (bestChNum + 4)) weight_below = weight_above = SAP_ACS_WEIGHT_MAX;
weight_above = pspect_info[i].weight; pspect_info = spect_info->pSpectCh;
} for (i = 0; i < spect_info->numSpectChans; i++) {
if (pspect_info[i].chNum == (best_ch_num - 4))
if (weight_below < weight_above) weight_below = pspect_info[i].weight;
pSapCtx->acs_cfg->ht_sec_ch = if (pspect_info[i].chNum == (best_ch_num + 4))
pSapCtx->acs_cfg->pri_ch - 4; weight_above = pspect_info[i].weight;
else
pSapCtx->acs_cfg->ht_sec_ch =
pSapCtx->acs_cfg->pri_ch + 4;
} else if (bestChNum >= 1 && bestChNum <= 4) {
pSapCtx->acs_cfg->ht_sec_ch =
pSapCtx->acs_cfg->pri_ch + 4;
} else if (bestChNum >= 8 && bestChNum <= 13) {
pSapCtx->acs_cfg->ht_sec_ch =
pSapCtx->acs_cfg->pri_ch - 4;
} else if (bestChNum == 14) {
pSapCtx->acs_cfg->ht_sec_ch = 0;
} }
pSapCtx->secondary_ch = pSapCtx->acs_cfg->ht_sec_ch;
if (weight_below < weight_above)
sap_ctx->acs_cfg->ht_sec_ch =
sap_ctx->acs_cfg->pri_ch - 4;
else
sap_ctx->acs_cfg->ht_sec_ch =
sap_ctx->acs_cfg->pri_ch + 4;
} else if (best_ch_num >= 1 && best_ch_num <= 4) {
sap_ctx->acs_cfg->ht_sec_ch = sap_ctx->acs_cfg->pri_ch + 4;
} else if (best_ch_num >= 8 && best_ch_num <= 13) {
sap_ctx->acs_cfg->ht_sec_ch = sap_ctx->acs_cfg->pri_ch - 4;
} else if (best_ch_num == 14) {
sap_ctx->acs_cfg->ht_sec_ch = 0;
} }
sap_ctx->secondary_ch = sap_ctx->acs_cfg->ht_sec_ch;
sap_ch_sel_end:
/* Free all the allocated memory */ /* Free all the allocated memory */
sap_chan_sel_exit(pSpectInfoParams); sap_chan_sel_exit(spect_info);
QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
"In %s, Running SAP Ch select Completed, Ch=%d", __func__, FL("Running SAP Ch select Completed, Ch=%d"), best_ch_num);
bestChNum); if (best_ch_num > 0 && best_ch_num <= 252)
if (bestChNum > 0 && bestChNum <= 252) return best_ch_num;
return bestChNum;
else else
return SAP_CHANNEL_NOT_SELECTED; return SAP_CHANNEL_NOT_SELECTED;
} }