software/drivers/sd8887/src/wlan/mlan/mlan_11h.c
/**
 *  @brief Setup the Supported Channel IE sent in association requests
 *
 *  The Supported Channels IE is required to be sent when the spectrum
 *    management capability (11h) is enabled.  The element contains a
 *    starting channel and number of channels tuple for each sub-band
 *    the STA supports.  This information is based on the operating region.
 *
 *  @param priv      Private driver information structure
 *  @param band      Band in use
 *  @param psup_chan Output parameter: Pointer to the Supported Chan element
 *                   setup by this function.
 *
 *  @return
 *    - Length of the returned element in psup_chan output parameter
 *    - 0 if returned element is not setup
 */
@brief Setup the Supported Channel IE sent in association requests
The Supported Channels IE is required to be sent when the spectrum
management capability (11h) is enabled.  The element contains a
starting channel and number of channels tuple for each sub-band
the STA supports.  This information is based on the operating region.

@param priv      Private driver information structure
@param band      Band in use
@param psup_chan Output parameter: Pointer to the Supported Chan element
setup by this function.

@return
- Length of the returned element in psup_chan output parameter
- 0 if returned element is not setup
@brief Setup the Supported Channel IE sent in association requests The Supported Channels IE is required to be sent when the spectrum management capability ( 11h ) is enabled . The element contains a starting channel and number of channels tuple for each sub - band the STA supports . This information is based on the operating region . @param priv Private driver information structure @param band Band in use @param psup_chan Output parameter : Pointer to the Supported Chan element setup by this function . @return - Length of the returned element in psup_chan output parameter - 0 if returned element is not setup
static
	t_u16
wlan_11h_set_supp_channels_ie(mlan_private *priv,
			      t_u8 band,
			      IEEEtypes_SupportedChannels_t *psup_chan)
{
	t_u16 num_subbands = 0;
	t_u16 ret_len = 0;
	t_u8 cfp_bg, cfp_a;
	ENTER();
	memset(priv->adapter, psup_chan, 0x00,
	       sizeof(IEEEtypes_SupportedChannels_t));
	cfp_bg = cfp_a = priv->adapter->region_code;
	if (!priv->adapter->region_code) {
		cfp_bg = priv->adapter->cfp_code_bg;
		cfp_a = priv->adapter->cfp_code_a;
	}
	if ((band & BAND_B) || (band & BAND_G)) {
		switch (cfp_bg) {
		case 0x10:	
		case 0x20:	
		default:
			psup_chan->subband[num_subbands++] =
				wlan_11h_2_4G_region_FCC;
			break;
		case 0x30:	
		case 0x41:	
		case 0x50:	
			psup_chan->subband[num_subbands++] =
				wlan_11h_2_4G_region_EU;
			break;
		case 0x40:	
			psup_chan->subband[num_subbands++] =
				wlan_11h_2_4G_region_JPN40;
			break;
		case 0xff:	
			psup_chan->subband[num_subbands++] =
				wlan_11h_2_4G_region_EU;
			psup_chan->subband[num_subbands++] =
				wlan_11h_2_4G_region_JPN40;
			break;
		}
	} else if (band & BAND_A) {
		switch (cfp_a) {
		case 0x10:	
		case 0x20:	
		case 0x30:	
		default:
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_lower_band;
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_middle_band;
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_mid_upper_band;
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_upper_band;
			break;
		case 0x50:	
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_lower_band;
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_middle_band;
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_upper_band;
			break;
		case 0x40:	
		case 0x41:	
		case 0xff:	
			psup_chan->subband[num_subbands++] =
				wlan_11h_JPN_bottom_band;
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_lower_band;
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_middle_band;
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_mid_upper_band;
			break;
		case 0x1:	
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_lower_band;
			break;
		case 0x2:	
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_middle_band;
			break;
		case 0x3:	
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_mid_upper_band;
			break;
		case 0x4:	
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_upper_band;
			break;
		case 0x5:	
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_lower_band;
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_upper_band;
			break;
		case 0x6:	
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_lower_band;
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_middle_band;
			psup_chan->subband[num_subbands++] =
				wlan_11h_unii_upper_band;
			break;
		}
	}
	if (num_subbands) {
		psup_chan->element_id = SUPPORTED_CHANNELS;
		psup_chan->len =
			num_subbands * sizeof(IEEEtypes_SupportChan_Subband_t);
		ret_len = (t_u16)(psup_chan->len
				  + sizeof(psup_chan->len) +
				  sizeof(psup_chan->element_id));
		HEXDUMP("11h: SupChan", (t_u8 *)psup_chan, ret_len);
	}
	LEAVE();
	return ret_len;
}
static t_u16 wlan_11h_set_supp_channels_ie ( mlan_private * priv , t_u8 band , IEEEtypes_SupportedChannels_t * psup_chan ) { t_u16 num_subbands = 0 ; t_u16 ret_len = 0 ; t_u8 cfp_bg , cfp_a ; ENTER ( ) ; memset ( priv -> adapter , psup_chan , 0x00 , sizeof ( IEEEtypes_SupportedChannels_t ) ) ; cfp_bg = cfp_a = priv -> adapter -> region_code ; if ( ! priv -> adapter -> region_code ) { cfp_bg = priv -> adapter -> cfp_code_bg ; cfp_a = priv -> adapter -> cfp_code_a ; } if ( ( band & BAND_B ) || ( band & BAND_G ) ) { switch ( cfp_bg ) { case 0x10 : case 0x20 : default : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_2_4G_region_FCC ; break ; case 0x30 : case 0x41 : case 0x50 : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_2_4G_region_EU ; break ; case 0x40 : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_2_4G_region_JPN40 ; break ; case 0xff : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_2_4G_region_EU ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_2_4G_region_JPN40 ; break ; } } else if ( band & BAND_A ) { switch ( cfp_a ) { case 0x10 : case 0x20 : case 0x30 : default : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_lower_band ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_middle_band ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_mid_upper_band ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_upper_band ; break ; case 0x50 : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_lower_band ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_middle_band ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_upper_band ; break ; case 0x40 : case 0x41 : case 0xff : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_JPN_bottom_band ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_lower_band ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_middle_band ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_mid_upper_band ; break ; case 0x1 : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_lower_band ; break ; case 0x2 : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_middle_band ; break ; case 0x3 : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_mid_upper_band ; break ; case 0x4 : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_upper_band ; break ; case 0x5 : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_lower_band ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_upper_band ; break ; case 0x6 : psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_lower_band ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_middle_band ; psup_chan -> subband [ num_subbands ++ ] = wlan_11h_unii_upper_band ; break ; } } if ( num_subbands ) { psup_chan -> element_id = SUPPORTED_CHANNELS ; psup_chan -> len = num_subbands * sizeof ( IEEEtypes_SupportChan_Subband_t ) ; ret_len = ( t_u16 ) ( psup_chan -> len + sizeof ( psup_chan -> len ) + sizeof ( psup_chan -> element_id ) ) ; HEXDUMP ( " " , ( t_u8 * ) psup_chan , ret_len ) ; } LEAVE ( ) ; return ret_len ; }
@brief Setup the Supported Channel IE sent in association requests
  The Supported Channels IE is required to be sent when the spectrum
    management capability (11h) is enabled.
@brief Setup the Supported Channel IE sent in association requests The Supported Channels IE is required to be sent when the spectrum management capability ( 11h ) is enabled .
/* Invalid region code, use CFP code */ /*
		 * Channels are contiguous in 2.4GHz, usually only one subband.
		 */ /* USA FCC   */ /* Canada IC */ /* Europe ETSI */ /* Japan  */ /* China  */ /* Japan  */ /* Japan special */ /*
		 * Set the supported channel elements based on the region code,
		 * incrementing num_subbands for each sub-band we append to the
		 * element.
		 */ /* USA FCC   */ /* Canada IC */ /* Europe ETSI */ /* China */ /* Japan */ /* Japan */ /* Japan special */ /* Low band (5150-5250 MHz) channels */ /* Lower middle band (5250-5350 MHz) channels */ /* Upper middle band (5470-5725 MHz) channels */ /* High band (5725-5850 MHz) channels */ /* Low band (5150-5250 MHz) and High band (5725-5850 MHz) channels */ /* Low band (5150-5250 MHz) and Lower middle band (5250-5350 MHz) and High band (5725-5850 MHz) channels */ /*
	 * If we have setup any supported subbands in the element, return a
	 *    valid IE along with its size, else return 0.
	 */