Ejemplo n.º 1
0
/** 
 *  @brief This function generates parsed_region_chan from Domain Info
 *           learned from AP/IBSS
 *
 *  @param pmadapter            Pointer to mlan_adapter structure
 *  @param region_chan          Pointer to region_chan_t
 *  @param parsed_region_chan   Pointer to parsed_region_chan_11d_t
 *
 *  @return                     N/A
 */
static t_void
wlan_11d_generate_parsed_region_chan(pmlan_adapter pmadapter,
                                     region_chan_t * region_chan,
                                     parsed_region_chan_11d_t *
                                     parsed_region_chan)
{
    chan_freq_power_t *cfp;
    t_u8 i;

    ENTER();

    /* Region channel must be provided */
    if (!region_chan) {
        PRINTM(MWARN, "11D: region_chan is MNULL\n");
        LEAVE();
        return;
    }

    /* Get channel-frequecy-power trio */
    cfp = region_chan->pcfp;
    if (!cfp) {
        PRINTM(MWARN, "11D: cfp equal MNULL \n");
        LEAVE();
        return;
    }

    /* Set band, region and country code */
    parsed_region_chan->band = region_chan->band;
    parsed_region_chan->region = region_chan->region;
    memcpy(pmadapter, parsed_region_chan->country_code,
           wlan_11d_code_2_region(pmadapter, region_chan->region),
           COUNTRY_CODE_LEN);

    PRINTM(MINFO, "11D: region[0x%x] band[%d]\n", parsed_region_chan->region,
           parsed_region_chan->band);

    /* Set channel and power */
    for (i = 0; i < region_chan->num_cfp; i++, cfp++) {
        parsed_region_chan->chan_pwr[i].chan = (t_u8) cfp->channel;
        parsed_region_chan->chan_pwr[i].pwr = (t_u8) cfp->max_tx_power;
        PRINTM(MINFO, "11D: Chan[%d] Pwr[%d]\n",
               parsed_region_chan->chan_pwr[i].chan,
               parsed_region_chan->chan_pwr[i].pwr);
    }
    parsed_region_chan->no_of_chan = region_chan->num_cfp;

    PRINTM(MINFO, "11D: no_of_chan[%d]\n", parsed_region_chan->no_of_chan);

    LEAVE();
    return;
}
Ejemplo n.º 2
0
/**
 *  @brief This function generates domain_info from parsed_region_chan
 *
 *  @param pmadapter            Pointer to mlan_adapter structure
 *  @param parsed_region_chan   Pointer to parsed_region_chan_11d_t
 *
 *  @return                     MLAN_STATUS_SUCCESS
 */
static mlan_status
wlan_11d_generate_domain_info(pmlan_adapter pmadapter,
                              parsed_region_chan_11d_t * parsed_region_chan)
{
    t_u8 no_of_sub_band = 0;
    t_u8 no_of_chan = parsed_region_chan->no_of_chan;
    t_u8 no_of_parsed_chan = 0;
    t_u8 first_chan = 0, next_chan = 0, max_pwr = 0;
    t_u8 i, flag = MFALSE;
    wlan_802_11d_domain_reg_t *domain_info = &pmadapter->domain_reg;

    ENTER();

    /* Should be only place that clear domain_reg (besides init) */
    memset(pmadapter, domain_info, 0, sizeof(wlan_802_11d_domain_reg_t));

    /* Set country code */
    memcpy(pmadapter, domain_info->country_code,
           wlan_11d_code_2_region(pmadapter, (t_u8) pmadapter->region_code),
           COUNTRY_CODE_LEN);

    PRINTM(MINFO, "11D: Number of channel = %d\n", no_of_chan);
    HEXDUMP("11D: parsed_region_chan", (t_u8 *) parsed_region_chan,
            sizeof(parsed_region_chan_11d_t));

    /* Set channel and power */
    for (i = 0; i < no_of_chan; i++) {
        if (!flag) {
            flag = MTRUE;
            next_chan = first_chan = parsed_region_chan->chan_pwr[i].chan;
            max_pwr = parsed_region_chan->chan_pwr[i].pwr;
            no_of_parsed_chan = 1;
            continue;
        }

        if (parsed_region_chan->chan_pwr[i].chan == next_chan + 1 &&
            parsed_region_chan->chan_pwr[i].pwr == max_pwr) {
            next_chan++;
            no_of_parsed_chan++;
        } else {
            domain_info->sub_band[no_of_sub_band].first_chan = first_chan;
            domain_info->sub_band[no_of_sub_band].no_of_chan =
                no_of_parsed_chan;
            domain_info->sub_band[no_of_sub_band].max_tx_pwr = max_pwr;
            no_of_sub_band++;
            no_of_parsed_chan = 1;
            next_chan = first_chan = parsed_region_chan->chan_pwr[i].chan;
            max_pwr = parsed_region_chan->chan_pwr[i].pwr;
        }
    }

    if (flag) {
        domain_info->sub_band[no_of_sub_band].first_chan = first_chan;
        domain_info->sub_band[no_of_sub_band].no_of_chan = no_of_parsed_chan;
        domain_info->sub_band[no_of_sub_band].max_tx_pwr = max_pwr;
        no_of_sub_band++;
    }
    domain_info->no_of_sub_band = no_of_sub_band;

    PRINTM(MINFO, "11D: Number of sub-band =0x%x\n",
           domain_info->no_of_sub_band);
    HEXDUMP("11D: domain_info", (t_u8 *) domain_info,
            COUNTRY_CODE_LEN + 1 +
            sizeof(IEEEtypes_SubbandSet_t) * no_of_sub_band);
    LEAVE();
    return MLAN_STATUS_SUCCESS;
}