software/drivers/sd8887/src/wlan/mlan/mlan_11h.c
/**
 *  @brief Retrieve a randomly selected starting channel if needed for 11h
 *
 *  If 11h is enabled and an A-Band channel start band preference
 *    configured in the driver, the start channel must be random in order
 *    to meet with
 *
 *  @param priv  Private driver information structure
 *
 *  @return      Starting channel
 */
@brief Retrieve a randomly selected starting channel if needed for 11h
If 11h is enabled and an A-Band channel start band preference
configured in the driver, the start channel must be random in order
to meet with

@param priv  Private driver information structure

@return      Starting channel
@brief Retrieve a randomly selected starting channel if needed for 11h If 11h is enabled and an A - Band channel start band preference configured in the driver the start channel must be random in order to meet with @param priv Private driver information structure @return Starting channel
t_u8
wlan_11h_get_adhoc_start_channel(mlan_private *priv)
{
	t_u8 start_chn;
	mlan_adapter *adapter = priv->adapter;
	t_u32 region;
	t_u32 rand_entry;
	region_chan_t *chn_tbl;
	t_u8 rand_tries = 0;
	ENTER();
	start_chn = DEFAULT_AD_HOC_CHANNEL;
	if ((adapter->adhoc_start_band & BAND_A)
		) {
		start_chn = DEFAULT_AD_HOC_CHANNEL_A;
		if (wlan_11h_is_enabled(priv)) {
			for (region = 0; (region < MAX_REGION_CHANNEL_NUM);
			     region++) {
				chn_tbl = &adapter->region_channel[region];
				if (chn_tbl->valid
				    && chn_tbl->region == adapter->region_code
				    && chn_tbl->band & BAND_A) {
					do {
						rand_entry =
							wlan_11h_get_random_num
							(adapter) %
							chn_tbl->num_cfp;
						start_chn =
							(t_u8)chn_tbl->
							pcfp[rand_entry].
							channel;
					} while (((chn_tbl->pcfp[rand_entry].
						   dynamic.
						   flags & NXP_CHANNEL_DISABLED)
						  ||
						  wlan_11h_is_channel_under_nop
						  (adapter, start_chn) ||
						  ((adapter->state_rdh.stage ==
						    RDH_GET_INFO_CHANNEL) &&
						   wlan_11h_radar_detect_required
						   (priv, start_chn)))
						 && (++rand_tries <
						     MAX_RANDOM_CHANNEL_RETRIES));
				}
			}
		}
	}
	PRINTM(MINFO, "11h: %s: AdHoc Channel set to %u\n",
	       wlan_11h_is_enabled(priv) ? "Enabled" : "Disabled", start_chn);
	LEAVE();
	return start_chn;
}
t_u8 wlan_11h_get_adhoc_start_channel ( mlan_private * priv ) { t_u8 start_chn ; mlan_adapter * adapter = priv -> adapter ; t_u32 region ; t_u32 rand_entry ; region_chan_t * chn_tbl ; t_u8 rand_tries = 0 ; ENTER ( ) ; start_chn = DEFAULT_AD_HOC_CHANNEL ; if ( ( adapter -> adhoc_start_band & BAND_A ) ) { start_chn = DEFAULT_AD_HOC_CHANNEL_A ; if ( wlan_11h_is_enabled ( priv ) ) { for ( region = 0 ; ( region < MAX_REGION_CHANNEL_NUM ) ; region ++ ) { chn_tbl = & adapter -> region_channel [ region ] ; if ( chn_tbl -> valid && chn_tbl -> region == adapter -> region_code && chn_tbl -> band & BAND_A ) { do { rand_entry = wlan_11h_get_random_num ( adapter ) % chn_tbl -> num_cfp ; start_chn = ( t_u8 ) chn_tbl -> pcfp [ rand_entry ] . channel ; } while ( ( ( chn_tbl -> pcfp [ rand_entry ] . dynamic . flags & NXP_CHANNEL_DISABLED ) || wlan_11h_is_channel_under_nop ( adapter , start_chn ) || ( ( adapter -> state_rdh . stage == RDH_GET_INFO_CHANNEL ) && wlan_11h_radar_detect_required ( priv , start_chn ) ) ) && ( ++ rand_tries < MAX_RANDOM_CHANNEL_RETRIES ) ) ; } } } } PRINTM ( MINFO , " \n " , wlan_11h_is_enabled ( priv ) ? " " : " " , start_chn ) ; LEAVE ( ) ; return start_chn ; }
@brief Retrieve a randomly selected starting channel if needed for 11h
  If 11h is enabled and an A-Band channel start band preference
    configured in the driver, the start channel must be random in order
    to meet with
@brief Retrieve a randomly selected starting channel if needed for 11h If 11h is enabled and an A - Band channel start band preference configured in the driver the start channel must be random in order to meet with
/*
	 * Set start_chn to the Default.  Used if 11h is disabled or the band
	 *   does not require 11h support.
	 */ /*
	 * Check that we are looking for a channel in the A Band
	 */ /*
		 * Set default to the A Band default.
		 * Used if random selection fails
		 * or if 11h is not enabled
		 */ /*
		 * Check that 11h is enabled in the driver
		 */ /*
			 * Search the region_channel tables for a channel table
			 *   that is marked for the A Band.
			 */ /* Check if table is valid and marked for A Band */ /*
					 * Set the start channel.  Get a random
					 * number and use it to pick an entry
					 * in the table between 0 and the number
					 * of channels in the table (NumCFP).
					 */