int32 hwifi_get_init_value(int32 cus_tag, int32 cfg_id)
{
    int32*              pgal_params = OAL_PTR_NULL;
    int32               l_wlan_cfg_butt;

    if (CUS_TAG_INI == cus_tag)
    {
        pgal_params = &g_al_host_init_params[0];
        l_wlan_cfg_butt = WLAN_CFG_INIT_BUTT;
    }
    else if (CUS_TAG_DTS == cus_tag)
    {
        pgal_params = &g_al_dts_params[0];
        l_wlan_cfg_butt = WLAN_CFG_DTS_BUTT;
    }
    else
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "hisi_customize_wifi tag number[0x%2x] not correct!", cus_tag);
        return INI_FAILED;
    }

    if (0 > cfg_id || l_wlan_cfg_butt <= cfg_id)
    {
        OAM_ERROR_LOG2(0, OAM_SF_ANY, "hisi_customize_wifi cfg id[%d] out of range, max cfg id is:%d", cfg_id, l_wlan_cfg_butt-1);
        return INI_FAILED;
    }
    return pgal_params[cfg_id];
}
oal_uint32 dmac_data_acq_report_data_unit(oal_uint8 *puc_daq_addr, oal_uint32 ul_len, oal_netbuf_stru *pst_netbuf)
{
    dmac_data_acq_data_head_stru   *pst_daq_data_head;
    oal_int32                       l_bytes = 0;

    pst_daq_data_head = (dmac_data_acq_data_head_stru *)oal_netbuf_data(pst_netbuf);

    /* 填写消息头 */
    pst_daq_data_head->en_send_type    = DMAC_DATA_ACQ_SEND_TYPE_UNIT;
    pst_daq_data_head->ul_msg_sn       = g_st_data_acq.ul_daq_sn;
    pst_daq_data_head->ul_data_len     = ul_len;

    oal_memcopy((oal_uint8 *)pst_daq_data_head + DMAC_DATA_ACQ_DATA_HEAD_LEN, puc_daq_addr, ul_len);

    l_bytes = oam_netlink_kernel_send(oal_netbuf_data(pst_netbuf), OAL_SIZEOF(dmac_data_acq_info_stru) + ul_len, OAM_NL_CMD_DAQ);

    if (l_bytes <= 0)
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_data_acq_report_data_unit::invalid l_bytes[%d].}", l_bytes);

        return OAL_FAIL;
    }

    g_st_data_acq.ul_daq_sn++;

    /* 等待APP侧接收完成 */
    if (0 == g_st_data_acq.ul_daq_sn % DMAC_DATA_ACQ_PER_MAX_NUM)
    {
        dmac_data_acq_set_send_flag(OAL_FALSE);
    }

    return OAL_SUCC;
}
Пример #3
0
/*****************************************************************************
 函 数 名  : dmac_txopps_set_en
 功能描述  : 设置11ac模式vap的txop ps使能,如果是ap模式只要设置mib和能力;如
             果是sta模式还要设置相应的mac寄存器
 输入参数  : pst_mac_vap: mac_vap结构
             en_switch  : 开关
 输出参数  : 无
 返 回 值  :
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2014年7月16日
    作    者   : z00237171
    修改内容   : 新生成函数

*****************************************************************************/
oal_uint32  dmac_txopps_set_en(mac_vap_stru *pst_mac_vap, oal_switch_enum_uint8 en_switch)
{
    if (OAL_UNLIKELY(OAL_PTR_NULL == pst_mac_vap))
    {
        OAM_ERROR_LOG0(0, OAM_SF_TXOP, "{dmac_txopps_set_en:: vap is null!}.");
        return OAL_ERR_CODE_PTR_NULL;
    }

    if (en_switch >= OAL_SWITCH_BUTT)
    {
        OAM_ERROR_LOG1(pst_mac_vap->uc_vap_id, OAM_SF_TXOP, "{dmac_txopps_set_en:: en_switch=[%d]}.", en_switch);
        return OAL_ERR_CODE_INVALID_CONFIG;
    }

    /* ap和sta都需要配置mib和vap的能力 */
    //pst_mac_vap->st_cap_flag.bit_txop_ps = en_switch;
    pst_mac_vap->pst_mib_info->st_wlan_mib_vht_sta_config.en_dot11VHTTXOPPowerSaveOptionImplemented = en_switch;

    /* sta模式还需要配置mac寄存器 */
    if (WLAN_VAP_MODE_BSS_STA == pst_mac_vap->en_vap_mode)
    {
        dmac_txopps_set_machw(pst_mac_vap);
    }

    return OAL_SUCC;
}
OAL_STATIC oal_uint32 dmac_bip_decrypto(dmac_vap_stru  *pst_dmac_vap, oal_netbuf_stru *pst_netbuf)
{
   wlan_priv_key_param_stru          *pst_pmf_igtk;
   mac_user_stru                     *pst_multi_user;
   oal_uint8                          uc_pmf_igtk_keyid = 0xff;
   wlan_mib_Dot11RSNAStatsEntry_stru *pst_mib_rsna_status;
   dmac_rx_ctl_stru                  *pst_rx_ctl;
   oal_uint32                         ul_relt;
   wlan_pmf_cap_status_uint8          en_pmf_cap;

   if (OAL_TRUE != dmac_11w_check_multicast_mgmt(pst_netbuf))
   {
       return OAL_SUCC;
   }

   /* 获取帧头信息 */
   pst_rx_ctl    = (dmac_rx_ctl_stru *)oal_netbuf_cb(pst_netbuf);


   /* 获取包含 重放 & CMAC解密失败 的统计mib指针 */
   pst_mib_rsna_status = (pst_dmac_vap->st_vap_base_info.pst_mib_info->ast_wlan_mib_rsna_status) + (pst_rx_ctl->st_rx_info.us_ta_user_idx);


   /* 判断vap的pmf能力 */
   ul_relt = dmac_11w_get_pmf_cap(&pst_dmac_vap->st_vap_base_info,&en_pmf_cap);
   if (OAL_SUCC != ul_relt)
   {
        return OAL_FAIL;
   }

   pst_multi_user = mac_res_get_mac_user(pst_dmac_vap->st_vap_base_info.us_multi_user_idx);
   if (OAL_PTR_NULL == pst_multi_user)
   {
       return OAL_PTR_NULL;
   }

   /* 强健组播管理帧解密 */
   if ((WLAN_VAP_MODE_BSS_STA == pst_dmac_vap->st_vap_base_info.en_vap_mode) &&
       (OAL_TRUE == dmac_11w_check_vap_pmf_cap(pst_dmac_vap,en_pmf_cap)))
    {
        /* 获取igtk信息 */
        uc_pmf_igtk_keyid = pst_multi_user->st_key_info.uc_igtk_key_index;
        pst_pmf_igtk      = &(pst_multi_user->st_key_info.ast_key[uc_pmf_igtk_keyid]);
        /* 管理帧解密 */
        ul_relt = oal_crypto_bip_demic(uc_pmf_igtk_keyid,
                                       pst_pmf_igtk->auc_key,
                                       pst_pmf_igtk->auc_seq,
                                       pst_netbuf,
                                      &pst_mib_rsna_status->ul_dot11RSNAStatsCMACReplays,
                                      &pst_mib_rsna_status->ul_dot11RSNAStatsCMACICVErrors);
        if(OAL_SUCC != ul_relt)
        {
            OAM_ERROR_LOG1(pst_dmac_vap->st_vap_base_info.uc_vap_id, OAM_SF_PMF, "{dmac_bip_decrypto::oal_crypto_bip_demic failed[%d].}", ul_relt);
            return OAL_ERR_CODE_PMF_BIP_DECRIPTO_FAIL;
        }
    }

   return OAL_SUCC;
}
/*****************************************************************************
 函 数 名  : dmac_get_device_freq_value
 功能描述  : 获取device的调频类型
 输入参数  : 无
 输出参数  : oal_device_freq_type_enum_uint8 uc_device_freq_type,device的调频类型,
             wlan_auto_freq_bw_enum_uint8 uc_auto_freq_bw_type,调频频宽类型
             oal_uint16* pusdevice_freq_value,device主频值
 返 回 值  : oal_uint32
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2015年11月16日
    作    者   : z00185449
    修改内容   : 新生成函数

*****************************************************************************/
oal_uint32 dmac_get_device_freq_value(oal_device_freq_type_enum_uint8 uc_device_freq_type,wlan_auto_freq_bw_enum_uint8 uc_auto_freq_bw_type,oal_uint16* pusdevice_freq_value)
{
    if (uc_device_freq_type > FREQ_HIGHEST)
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_get_device_freq_value:para error,uc_device_freq_type = %d.}",uc_device_freq_type);
        return OAL_FAIL;
    }
    if (uc_auto_freq_bw_type >= WLAN_BW_BUTT)
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_get_device_freq_value:para error,uc_auto_freq_bw_type = %d.}",uc_auto_freq_bw_type);
        return OAL_FAIL;
    }
    *pusdevice_freq_value = g_device_speed_freq[uc_auto_freq_bw_type][uc_device_freq_type];
//    OAM_WARNING_LOG3(0, OAM_SF_ANY, "{dmac_get_device_freq_value uc_auto_freq_bw_type = %d,uc_auto_freq_bw_type = %d,device_freq_value = %d.}",uc_auto_freq_bw_type,uc_device_freq_type,*pusdevice_freq_value);

    return OAL_SUCC;
}
oal_uint32 dmac_bip_crypto(dmac_vap_stru *pst_dmac_vap,
                                 oal_netbuf_stru *pst_netbuf_mgmt,
                                 wlan_security_txop_params_stru  *pst_security,
                                 oal_uint16 *pus_len)
{
#if(_PRE_WLAN_FEATURE_PMF == _PRE_PMF_HW_CCMP_SW_BIP)

    wlan_priv_key_param_stru    *pst_pmf_igtk;
#endif
    mac_user_stru               *pst_multi_user;
    oal_uint8                    uc_pmf_igtk_keyid;
    oal_uint32                   ul_relt;
    wlan_pmf_cap_status_uint8    en_pmf_cap;

    /* 判断vap的pmf能力 */
    ul_relt = dmac_11w_get_pmf_cap(&pst_dmac_vap->st_vap_base_info,&en_pmf_cap);
    if (OAL_SUCC != ul_relt)
    {
         return OAL_ERR_CODE_PMF_VAP_CAP_FAIL;
    }

    pst_multi_user = mac_res_get_mac_user(pst_dmac_vap->st_vap_base_info.us_multi_user_idx);
    if (OAL_PTR_NULL == pst_multi_user)
    {
        return OAL_PTR_NULL;
    }

    /* 判断是否需要加密的组播/广播 强健管理帧 */
    if ((OAL_TRUE == dmac_11w_check_multicast_mgmt(pst_netbuf_mgmt)) &&
        (OAL_TRUE == dmac_11w_check_vap_pmf_cap(pst_dmac_vap,en_pmf_cap)))
    {
        uc_pmf_igtk_keyid = pst_multi_user->st_key_info.uc_igtk_key_index;
        oal_netbuf_set_len(pst_netbuf_mgmt, *pus_len);

#if(_PRE_WLAN_FEATURE_PMF == _PRE_PMF_HW_CCMP_BIP)

        pst_security->en_cipher_protocol_type = WLAN_80211_CIPHER_SUITE_BIP;
        pst_security->uc_cipher_key_id        = uc_pmf_igtk_keyid;
#else
        pst_pmf_igtk      = &pst_multi_user->st_key_info.ast_key[uc_pmf_igtk_keyid];
        pst_security->en_cipher_protocol_type = WLAN_80211_CIPHER_SUITE_NO_ENCRYP;
        /* 11w组播管理帧加密 */
        ul_relt = oal_crypto_bip_enmic(uc_pmf_igtk_keyid,
                                       pst_pmf_igtk->auc_key,
                                       pst_pmf_igtk->auc_seq,
                                       pst_netbuf_mgmt,
                                       pus_len);
        if(OAL_SUCC != ul_relt)
        {
            OAM_ERROR_LOG1(pst_dmac_vap->st_vap_base_info.uc_vap_id, OAM_SF_PMF, "{dmac_bip_crypto::oal_crypto_bip_enmic failed[%d].}", ul_relt);
            return OAL_ERR_CODE_PMF_BIP_CRIPTO_FAIL;
        }
#endif

     }

    return OAL_SUCC;
}
Пример #7
0
/*****************************************************************************
 函 数 名  : dmac_res_get_mac_dev
 功能描述  : 获取对应HMAC DEV索引的内存
 输入参数  : 对应HMAC DEV内存索引
 输出参数  : 无
 返 回 值  : 对应内存地址
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2015年1月31日
    作    者   : l00279018
    修改内容   : 新生成函数

*****************************************************************************/
dmac_device_stru  *dmac_res_get_mac_dev(oal_uint32 ul_dev_idx)
{
    if (OAL_UNLIKELY(ul_dev_idx >= MAC_RES_MAX_DEV_NUM))
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_res_get_dmac_dev::invalid ul_dev_idx[%d].}", ul_dev_idx);

        return OAL_PTR_NULL;
    }

    return &(g_st_dmac_res.st_dmac_dev_res.ast_dmac_dev_info[ul_dev_idx]);
}
Пример #8
0
/*****************************************************************************
 函 数 名  : dmac_device_exception_report_timeout_fn
 功能描述  : 异常维测信息上报,定期读取寄存器,出现错误直接上报
 输入参数  : 无
 输出参数  : 无
 返 回 值  :
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2014年8月4日
    作    者   : huxiaotong
    修改内容   : 新生成函数
  2.日    期   : 2015年1月4日
    作    者   : daihu
    修改内容   : 增加双芯片时,pcie0和pcie1的读写

*****************************************************************************/
oal_uint32  dmac_device_exception_report_timeout_fn(oal_void *p_arg)
{
#if ((_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) && (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC != _PRE_MULTI_CORE_MODE))
    oal_uint8                   uc_pci_device_id = 0;
    oal_uint32                  ul_reg_pci_rpt_val  = 0;
    oal_uint32                  ul_pci_warn_clear_cfg_val = 0xFFFFFFFF;             /* 写1清 */
    oal_uint32                  ul_reg_pci_rpt_addr_offset = 0x110;                 /* PCIE 0x110寄存器 */
    oal_bus_chip_stru           *pst_bus_chip = OAL_PTR_NULL;
    hal_to_dmac_device_stru     *pst_hal_device = OAL_PTR_NULL;
    mac_device_stru             *pst_mac_device = OAL_PTR_NULL;

    pst_hal_device = (hal_to_dmac_device_stru *)p_arg;

    /* 获取chip id值 */
    uc_pci_device_id = pst_hal_device->uc_chip_id;

    oal_bus_get_chip_instance(&pst_bus_chip, uc_pci_device_id);

    /* 然后读取1151侧的 PCIE */
    ul_reg_pci_rpt_val   = 0;
    oal_pci_read_config_dword(pst_bus_chip->pst_pci_device, ul_reg_pci_rpt_addr_offset, &ul_reg_pci_rpt_val);

    pst_mac_device = mac_res_get_dev(pst_hal_device->uc_mac_device_id);
    if (OAL_UNLIKELY(OAL_PTR_NULL == pst_mac_device))
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_device_exception_report_timeout_fn::pst_mac_device[%d] is NULL!}", pst_hal_device->uc_mac_device_id);
        return OAL_ERR_CODE_PTR_NULL;
    }

    pst_mac_device->ul_pcie_read_counter++;

    /* Bit[12]: Timer Timeout Status, 判断是否发生 timeout异常 */
    if(0 != (ul_reg_pci_rpt_val & 0x1000))
    {
        pst_mac_device->ul_pcie_reg110_timeout_counter++;

        OAM_WARNING_LOG4(0, OAM_SF_ANY,
         "{dmac_device_exception_report_timeout_fn:: read 1151 pcie reg0x110 timeout, chip id = %d, device id = %d, reg0x110 = [0x%08x]}, timeout counter: %d.",
            pst_hal_device->uc_chip_id, pst_hal_device->uc_mac_device_id, ul_reg_pci_rpt_val, pst_mac_device->ul_pcie_reg110_timeout_counter);

        oal_pci_write_config_dword(pst_bus_chip->pst_pci_device, ul_reg_pci_rpt_addr_offset, ul_pci_warn_clear_cfg_val);
    }
    /* 为防止出现 timeout异常后,长时间再未出现异常,每隔 10 * 64秒打印一次 timeout异常统计 */
    else if(0 == (pst_mac_device->ul_pcie_read_counter & 0x3F))
    {
        OAM_WARNING_LOG3(0, OAM_SF_ANY,
             "{dmac_device_exception_report_timeout_fn:: chip id = %d, device id = %d, reg0x110 read timeout counter: %d.",
                pst_hal_device->uc_chip_id, pst_hal_device->uc_mac_device_id, pst_mac_device->ul_pcie_reg110_timeout_counter);
    }
#endif

    return OAL_SUCC;
}
Пример #9
0
/*****************************************************************************
 函 数 名  : dmac_res_alloc_mac_dev
 功能描述  : 获取一个HMAC DEV资源
 输入参数  : 无
 输出参数  : HMAC DEV内存索引值
 返 回 值  : OAL_SUCC/OAL_FAIL
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2013年5月8日
    作    者   : l00279018
    修改内容   : 新生成函数

*****************************************************************************/
oal_uint32  dmac_res_alloc_mac_dev(oal_uint32    ul_dev_idx)
{
    if (OAL_UNLIKELY(ul_dev_idx >= MAC_RES_MAX_DEV_NUM))
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_res_alloc_dmac_dev::invalid ul_dev_idx[%d].}", ul_dev_idx);

        return OAL_FAIL;
    }

    (g_st_dmac_res.st_dmac_dev_res.auc_user_cnt[ul_dev_idx])++;

    return OAL_SUCC;
}
oal_uint32 dmac_data_acq_report_data_info(oal_uint8 *puc_daq_addr, oal_uint32 ul_len, oal_netbuf_stru *pst_netbuf)
{
    dmac_data_acq_info_stru        *pst_daq_data_info           = OAL_PTR_NULL;
    dmac_data_acq_data_head_stru   *pst_daq_data_head           = OAL_PTR_NULL;
    oal_int32                       l_bytes = 0;
    oal_uint32                      ul_time = 0;

    /***** 发送数采基本信息给app 填写消息头 *****/
    pst_daq_data_head = (dmac_data_acq_data_head_stru *)oal_netbuf_data(pst_netbuf);

    pst_daq_data_head->en_send_type = DMAC_DATA_ACQ_SEND_TYPE_INFO;
    pst_daq_data_head->ul_msg_sn    = 0;
    pst_daq_data_head->ul_data_len  = OAL_SIZEOF(dmac_data_acq_info_stru);

    /***** 发送数采基本信息给app 填写消息内容 *****/
    pst_daq_data_info = (dmac_data_acq_info_stru *)(oal_netbuf_data(pst_netbuf) + DMAC_DATA_ACQ_DATA_HEAD_LEN);

    pst_daq_data_info->ul_daq_addr    = (oal_uint32)puc_daq_addr;
    pst_daq_data_info->ul_data_len    = ul_len;
    pst_daq_data_info->ul_unit_len    = DMAC_DATA_ACQ_UNIT_DATA_LEN;


    /***** 将daq info通知app侧 *****/
    l_bytes = oam_netlink_kernel_send(oal_netbuf_data(pst_netbuf), OAL_SIZEOF(dmac_data_acq_info_stru) + DMAC_DATA_ACQ_DATA_HEAD_LEN, OAM_NL_CMD_DAQ);

    if (l_bytes <= 0)
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_data_acq_report_data_info::invalid l_bytes[%d].}", l_bytes);

        return OAL_FAIL;
    }

    g_st_data_acq.uc_ack_flag = OAL_FALSE;

    while(!g_st_data_acq.uc_ack_flag)
    {

        oal_msleep(1000);

        if (DMAC_DATA_ACQ_MAX_WAIT_TIME <= ul_time)
        {
            OAM_ERROR_LOG0(0, OAM_SF_ANY, "{dmac_data_acq_report_data_info::wait app ack timeout. Try again.}");

            return OAL_FAIL;
        }

        ul_time++;
    }

    return OAL_SUCC;
}
Пример #11
0
/*****************************************************************************
 函 数 名  : hmac_roam_alg_add_blacklist
 功能描述  : 将bssid添加到黑名单列表中
 输入参数  :
 输出参数  : 无
 返 回 值  : OAL_SUCC 或 失败错误码
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2015年7月8日
    作    者   : g00260350
    修改内容   : 新生成函数

*****************************************************************************/
oal_uint32 hmac_roam_alg_add_blacklist(hmac_roam_info_stru *pst_roam_info, oal_uint8 *puc_bssid, roam_blacklist_type_enum_uint8 list_type)
{
    oal_uint32      ul_ret;
    if ((pst_roam_info == OAL_PTR_NULL) || (puc_bssid == OAL_PTR_NULL))
    {
        return OAL_ERR_CODE_PTR_NULL;
    }

    ul_ret = hmac_roam_alg_add_bsslist(&pst_roam_info->st_alg.st_blacklist, puc_bssid, list_type);
    if (OAL_SUCC != ul_ret)
    {
        OAM_ERROR_LOG1(0, OAM_SF_ROAM, "{hmac_roam_alg_add_blacklist::hmac_roam_alg_add_list failed[%d].}", ul_ret);
        return ul_ret;
    }

    return OAL_SUCC;
}
Пример #12
0
/*****************************************************************************
 函 数 名  : hmac_roam_add_bss_history
 功能描述  : 将bssid添加到历史优选AP列表中
 输入参数  :
 输出参数  : 无
 返 回 值  : OAL_SUCC 或 失败错误码
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2015年7月8日
    作    者   : g00260350
    修改内容   : 新生成函数

*****************************************************************************/
oal_uint32 hmac_roam_alg_add_history(hmac_roam_info_stru *pst_roam_info, oal_uint8 *puc_bssid)
{
    oal_uint32      ul_ret;

    if ((pst_roam_info == OAL_PTR_NULL) || (puc_bssid == OAL_PTR_NULL))
    {
        return OAL_ERR_CODE_PTR_NULL;
    }

    ul_ret = hmac_roam_alg_add_bsslist(&pst_roam_info->st_alg.st_history, puc_bssid, ROAM_BLACKLIST_TYPE_NORMAL_AP);
    if (OAL_SUCC != ul_ret)
    {
        OAM_ERROR_LOG1(0, OAM_SF_ROAM, "{hmac_roam_alg_add_history::hmac_roam_alg_add_list failed[%d].}", ul_ret);
        return ul_ret;
    }

    return OAL_SUCC;
}
OAL_STATIC int32 hwifi_config_init_nvram(void)
{
    int32 l_ret = INI_FAILED;
    int32 l_cfg_id;
    int32 aul_nvram_params[NVRAM_PARAMS_INDEX_BUTT]={0};

    oal_memset(g_auc_nv_params, 0x00, sizeof(g_auc_nv_params));
    l_ret = get_cust_conf_string(CUST_MODU_NVRAM, OAL_PTR_NULL, g_auc_nv_params, sizeof(g_auc_nv_params));

    /* nv读取失败或者返回的参数值为零,尝试读取ini */
    if(INI_FAILED == l_ret || !g_auc_nv_params[0])
    {
        OAM_WARNING_LOG3(0, OAM_SF_ANY, "hwifi_config_init_nvram read nvram failed[ret:%d] or wrong values[first eight values:0x%x %x], read dts instead!", l_ret, *((oal_uint32*)g_auc_nv_params),*((oal_uint32*)(g_auc_nv_params+4)));
        /* 先尝试从ini文件中读取,读不到的话再从dts中读取 */
        for (l_cfg_id = NVRAM_PARAMS_INDEX_0; l_cfg_id < NVRAM_PARAMS_INDEX_BUTT; l_cfg_id++)
        {
            l_ret = get_cust_conf_int32(INI_MODU_WIFI, g_ast_nvram_config_ini[l_cfg_id].name, &aul_nvram_params[l_cfg_id]);
            if(INI_FAILED == l_ret)
            {
                OAM_ERROR_LOG1(0, OAM_SF_ANY, "hwifi_config_init_nvram read %d from ini failed!", l_cfg_id);
                break;
            }
        }

        if (NVRAM_PARAMS_INDEX_BUTT == l_cfg_id)
        {
            OAM_INFO_LOG0(0, OAM_SF_ANY, "hwifi_config_init_nvram read from ini success!");
            oal_memcopy(g_auc_nv_params, aul_nvram_params, sizeof(g_auc_nv_params));
            return INI_SUCC;
        }

        l_ret = get_cust_conf_string(CUST_MODU_DTS, NVRAM_PARAMS_ARRAY, g_auc_nv_params, sizeof(g_auc_nv_params));
        if(INI_FAILED == l_ret)
        {
            OAM_WARNING_LOG0(0, OAM_SF_ANY, "hwifi_config_init_nvram read dts failed!");
            /* 读取dts也失败时将数组置零,防止下发至device */
            oal_memset(g_auc_nv_params, 0x00, sizeof(g_auc_nv_params));
            return INI_FAILED;
        }
    }

    return INI_SUCC;
}
Пример #14
0
/*****************************************************************************
 函 数 名  : hmac_protection_del_user_stat_legacy_ap
 功能描述  : 删除保护模式相关user统计(legacy)
 输入参数  : pst_mac_vap  : mac vap结构体指针
             pst_mac_user : mac user结构体指针
 输出参数  : 无
 返 回 值  : oal_uint32
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2014年1月22日
    作    者   : c00260463
    修改内容   : 新生成函数

*****************************************************************************/
OAL_STATIC oal_uint32  hmac_protection_del_user_stat_legacy_ap(mac_vap_stru *pst_mac_vap, mac_user_stru *pst_mac_user)
{
    mac_protection_stru    *pst_protection = &(pst_mac_vap->st_protection);
    hmac_user_stru         *pst_hmac_user;

    pst_hmac_user = (hmac_user_stru *)mac_res_get_hmac_user(pst_mac_user->us_assoc_id);
    if (OAL_PTR_NULL == pst_hmac_user)
    {
        OAM_ERROR_LOG1(pst_mac_vap->uc_vap_id, OAM_SF_ANY,
                        "hmac_protection_del_user_stat_legacy_ap::Get Hmac_user(idx=%d) NULL POINT!", pst_mac_user->us_assoc_id);
        return OAL_ERR_CODE_PTR_NULL;
    }

    /*如果去关联的站点不支持ERP*/
    if ((OAL_FALSE == pst_hmac_user->st_hmac_cap_info.bit_erp)
        && (OAL_TRUE == pst_hmac_user->st_user_stats_flag.bit_no_erp_stats_flag)
        && (0 != pst_protection->uc_sta_non_erp_num))
    {
        pst_protection->uc_sta_non_erp_num--;
    }

    /*如果去关联的站点不支持short preamble*/
    if ((OAL_FALSE == pst_hmac_user->st_hmac_cap_info.bit_short_preamble)
        && (OAL_TRUE == pst_hmac_user->st_user_stats_flag.bit_no_short_preamble_stats_flag)
        && (0 != pst_protection->uc_sta_no_short_preamble_num))
    {
        pst_protection->uc_sta_no_short_preamble_num--;
    }

    /*如果去关联的站点不支持short slot*/
    if ((OAL_FALSE == pst_hmac_user->st_hmac_cap_info.bit_short_slot_time)
        && (OAL_TRUE == pst_hmac_user->st_user_stats_flag.bit_no_short_slot_stats_flag)
        && (0 != pst_protection->uc_sta_no_short_slot_num))
    {
        pst_protection->uc_sta_no_short_slot_num--;
    }

    pst_hmac_user->st_user_stats_flag.bit_no_short_slot_stats_flag     = OAL_FALSE;
    pst_hmac_user->st_user_stats_flag.bit_no_short_preamble_stats_flag = OAL_FALSE;
    pst_hmac_user->st_user_stats_flag.bit_no_erp_stats_flag            = OAL_FALSE;

    return OAL_SUCC;
}
int32 hwifi_fetch_ori_caldata(uint8* auc_caldata, int32 l_nvm_len)
{
    int32 l_ret = INI_FAILED;
    int32 l_cfg_id;
    int32 aul_nvram_params[NVRAM_PARAMS_INDEX_BUTT]={0};

    if (l_nvm_len != HISI_CUST_NVRAM_LEN)
    {
        OAM_ERROR_LOG2(0, OAM_SF_ANY, "hwifi_fetch_ori_caldata atcmd[nv_len:%d] and plat_ini[nv_len:%d] model have different nvm lenth!!",
                        l_nvm_len, HISI_CUST_NVRAM_LEN);
        return INI_FAILED;
    }

    oal_memset(auc_caldata, 0x00, HISI_CUST_NVRAM_LEN);

    for (l_cfg_id = NVRAM_PARAMS_INDEX_0; l_cfg_id < NVRAM_PARAMS_INDEX_BUTT; l_cfg_id++)
    {
        l_ret = get_cust_conf_int32(INI_MODU_WIFI, g_ast_nvram_config_ini[l_cfg_id].name, &aul_nvram_params[l_cfg_id]);
        if(INI_FAILED == l_ret)
        {
            OAM_ERROR_LOG1(0, OAM_SF_ANY, "hwifi_fetch_ori_caldata read ori caldata %d from ini failed!", l_cfg_id);
            break;
        }
    }

    if (NVRAM_PARAMS_INDEX_BUTT == l_cfg_id)
    {
        OAM_INFO_LOG0(0, OAM_SF_ANY, "hwifi_fetch_ori_caldata read ori caldata from ini success!");
        oal_memcopy(auc_caldata, aul_nvram_params, HISI_CUST_NVRAM_LEN);
        return INI_SUCC;
    }

    l_ret = get_cust_conf_string(CUST_MODU_DTS, NVRAM_PARAMS_ARRAY, auc_caldata, HISI_CUST_NVRAM_LEN);
    if(INI_FAILED == l_ret)
    {
        OAM_ERROR_LOG0(0, OAM_SF_ANY, "hwifi_fetch_ori_caldata read ori caldata from dts failed!");
        return INI_FAILED;
    }

    return INI_SUCC;
}
oal_uint32  dmac_data_acq_enable(mac_vap_stru *pst_mac_vap,oal_uint8 *puc_param, mac_device_stru *pst_device)
{
    if ((DMAC_DATA_ACQ_STATUS_PHY_REG != g_st_data_acq.en_daq_status) && (DMAC_DATA_ACQ_STATUS_COMPLETE != g_st_data_acq.en_daq_status))
    {
        /* 数据采集条件当前有误,不允许配置 */
        OAM_ERROR_LOG1(pst_mac_vap->uc_vap_id, OAM_SF_ANY, "{dmac_data_acq_enable::invalid en_daq_status[%d].}", g_st_data_acq.en_daq_status);

        return OAL_FAIL;
    }

    g_st_data_acq.st_daq_prep_info.en_daq_enable = OAL_TRUE;
    g_st_data_acq.st_daq_cond.bit_cfg_real_sample_en = OAL_TRUE;

    /* 开始采集数据 */
    g_st_data_acq.en_daq_status = DMAC_DATA_ACQ_STATUS_ENABLE;

    /* 设置MAC与PHY寄存器 */
    hal_set_daq_en(pst_device->pst_device_stru, (oal_uint8)(g_st_data_acq.st_daq_prep_info.en_daq_enable));

    return OAL_SUCC;
}
Пример #17
0
/*****************************************************************************
 函 数 名  : dmac_res_free_mac_dev
 功能描述  : 释放对应HMAC DEV的内存
 输入参数  : 对应HMAC DEV内存索引
 输出参数  : 无
 返 回 值  : OAL_SUCC/OAL_FAIL
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2015年1月31日
    作    者   : l00279018
    修改内容   : 新生成函数

*****************************************************************************/
oal_uint32  dmac_res_free_mac_dev(oal_uint32 ul_dev_idx)
{
    if (OAL_UNLIKELY(ul_dev_idx >= MAC_RES_MAX_DEV_NUM))
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "{mac_res_free_dev::invalid ul_dev_idx[%d].}", ul_dev_idx);

        return OAL_FAIL;
    }

    (g_st_dmac_res.st_dmac_dev_res.auc_user_cnt[ul_dev_idx])--;

    if (0 != g_st_dmac_res.st_dmac_dev_res.auc_user_cnt[ul_dev_idx])
    {
        return OAL_SUCC;
    }

    /* 入队索引值需要加1操作 */
    oal_queue_enqueue(&(g_st_dmac_res.st_dmac_dev_res.st_queue), (oal_void *)((oal_uint)ul_dev_idx + 1));

    return OAL_SUCC;
}
oal_uint32  hmac_frag_process_proc(hmac_vap_stru *pst_hmac_vap, hmac_user_stru *pst_hmac_user, oal_netbuf_stru *pst_netbuf, mac_tx_ctl_stru *pst_tx_ctl)
{
    oal_uint32          ul_threshold    = 0;
    oal_uint8           uc_ic_header    = 0;
    oal_uint32          ul_ret          = OAL_SUCC;
#if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC != _PRE_MULTI_CORE_MODE)
    oal_uint32          uc_last_frag    = 0;
#endif

    /* 获取分片门限 */
    ul_threshold = pst_hmac_vap->st_vap_base_info.pst_mib_info->st_wlan_mib_operation.ul_dot11FragmentationThreshold;

    /* TBD调用加密接口在使用TKIP时对MSDU进行加密后在进行分片 */
    ul_ret = hmac_en_mic(pst_hmac_vap, pst_hmac_user, pst_netbuf, &uc_ic_header);
    if (OAL_SUCC != ul_ret)
    {
        OAM_ERROR_LOG1(pst_hmac_vap->st_vap_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_frag_process::hmac_en_mic failed[%d].}", ul_ret);
        return ul_ret;
    }
    ul_threshold = (ul_threshold & (~(BIT0|BIT1))) + 2;

    /* 规避1151硬件bug,调整分片门限:TKIP加密时,当最后一个分片的payload长度小于等于8时,无法进行加密 */
#if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC != _PRE_MULTI_CORE_MODE)
    if (WLAN_80211_CIPHER_SUITE_TKIP == pst_hmac_user->st_user_base_info.st_key_info.en_cipher_type)
    {
        uc_last_frag = OAL_NETBUF_LEN(pst_netbuf) % (ul_threshold - (oal_uint32)uc_ic_header - pst_tx_ctl->uc_frame_header_length);
        if ((uc_last_frag > 0) && (uc_last_frag <= 8))
        {
            ul_threshold = ul_threshold + 8;
            OAM_INFO_LOG1(pst_hmac_vap->st_vap_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_frag_process_proc::adjust the frag threshold to %d.}", ul_threshold);
        }
    }
#endif
    /* 进行分片处理 */
    ul_ret = hmac_frag_process(pst_hmac_vap, pst_netbuf, pst_tx_ctl, (oal_uint32)uc_ic_header, ul_threshold);

    return ul_ret;

}
oal_uint32  dmac_data_acq_condition(mac_vap_stru *pst_mac_vap,oal_uint8 *puc_param, mac_device_stru *pst_device)
{
    oal_uint32                  ul_offset = 0;
    oal_int8                    ac_name[DMAC_HIPRIV_CMD_NAME_MAX_LEN];
    oal_uint8                   uc_value;
    oal_uint32                  ul_val;

    OAL_MEMZERO(ac_name, DMAC_HIPRIV_CMD_NAME_MAX_LEN);

    if ((DMAC_DATA_ACQ_STATUS_BUTT > g_st_data_acq.en_daq_status) && ((DMAC_DATA_ACQ_STATUS_INIT == g_st_data_acq.en_daq_status) || (DMAC_DATA_ACQ_STATUS_ENABLE == g_st_data_acq.en_daq_status)))
    {
        /* 数据采集正在进行,不允许设置 */
        return OAL_SUCC;
    }

    OAL_MEMZERO(&(g_st_data_acq.st_daq_cond), OAL_SIZEOF(dmac_data_acq_cond_stru));

    /* 1、获取通道配置 */
    dmac_get_cmd_one_arg((oal_int8*)puc_param, ac_name, &ul_offset);
    uc_value = (oal_uint8)oal_atoi(ac_name);

    if (WITP_RF_CHANNEL_NUMS < uc_value)
    {
        OAM_ERROR_LOG1(pst_mac_vap->uc_vap_id, OAM_SF_ANY, "{dmac_data_acq_condition::invalid uc_value[%d].}", uc_value);

        g_st_data_acq.en_daq_status = DMAC_DATA_ACQ_STATUS_MAC_REG;
        return OAL_FAIL;
    }

    g_st_data_acq.st_daq_cond.bit_cfg_real_sample_ch_sel = uc_value;

    /* 偏移,取下一个参数 */
    puc_param = puc_param + ul_offset;

    /* 2、获取数据采集条件 */
    dmac_get_cmd_one_arg((oal_int8*)puc_param, ac_name, &ul_offset);
    uc_value = (oal_uint8)oal_atoi(ac_name);

    if ((DMAC_DATA_ACQ_COND_BUTT <= (dmac_data_acq_cond_enum_uint8)uc_value)
       || (DMAC_DATA_ACQ_COND_ADC_TH > (dmac_data_acq_cond_enum_uint8)uc_value))
    {
        OAM_ERROR_LOG1(pst_mac_vap->uc_vap_id, OAM_SF_ANY, "{dmac_data_acq_condition::invalid uc_value[%d].}", uc_value);

        g_st_data_acq.en_daq_status = DMAC_DATA_ACQ_STATUS_MAC_REG;
        return OAL_FAIL;
    }

    g_st_data_acq.st_daq_cond.bit_cfg_real_sample_cond_ctrl = uc_value;
    /* 偏移,取下一个参数 */
    puc_param = puc_param + ul_offset;

    /* 3、获取数据采集限制门限 */
    dmac_get_cmd_one_arg((oal_int8*)puc_param, ac_name, &ul_offset);
    uc_value = (oal_uint8)oal_atoi(ac_name);
    /* 偏移,取下一个参数 */
    puc_param = puc_param + ul_offset;

    if (DMAC_DATA_ACQ_COND_ADC_TH == (g_st_data_acq.st_daq_cond.bit_cfg_real_sample_cond_ctrl & DMAC_DATA_ACQ_COND_ADC_TH))
    {
        if (0 == uc_value)
        {
            OAM_ERROR_LOG0(pst_mac_vap->uc_vap_id, OAM_SF_ANY, "{dmac_data_acq_prepare::uc_value=0.}");

            g_st_data_acq.en_daq_status = DMAC_DATA_ACQ_STATUS_MAC_REG;
            return OAL_FAIL;
        }

        g_st_data_acq.st_daq_cond.bit_cfg_real_sample_data_th = uc_value;
    }

    /* 4、获取数据采集bit位选 */
    dmac_get_cmd_one_arg((oal_int8*)puc_param, ac_name, &ul_offset);
    uc_value = (oal_uint8)oal_atoi(ac_name);
    /* 偏移,取下一个参数 */
    puc_param = puc_param + ul_offset;

    if (DMAC_DATA_ACQ_BIT_BUTT <= (dmac_data_acq_bit_enum_uint8)uc_value)
    {
        OAM_ERROR_LOG1(pst_mac_vap->uc_vap_id, OAM_SF_ANY, "{dmac_data_acq_prepare::invalid uc_value[%d].}", uc_value);

        g_st_data_acq.en_daq_status = DMAC_DATA_ACQ_STATUS_MAC_REG;
        return OAL_FAIL;
    }

    g_st_data_acq.st_daq_cond.bit_cfg_real_sample_bits_sel = uc_value;

    ul_val = *((oal_uint32 *)(&g_st_data_acq.st_daq_cond));

    /* 设置PHY寄存器 */
    hal_set_daq_phy_reg(pst_device->pst_device_stru, ul_val);

    /* 条件完全符合,配置允许采集标志 */
    g_st_data_acq.en_daq_status = DMAC_DATA_ACQ_STATUS_PHY_REG;

    return OAL_SUCC;
}
oal_uint32 dmac_data_acq_report_data(oal_uint8 *puc_daq_addr, oal_uint32 ul_len, oal_netbuf_stru *pst_netbuf)
{
    oal_uint8                      *puc_data_offset             = OAL_PTR_NULL;
    oal_uint32                      ul_trans_remainder_len      = 0;
    oal_uint32                      ul_unit_len;
    oal_uint32                      ul_ret;
    oal_uint32                      ul_time = 0;

    ul_trans_remainder_len  = ul_len;
    ul_unit_len             = DMAC_DATA_ACQ_UNIT_DATA_LEN;
    puc_data_offset         = puc_daq_addr;

    g_st_data_acq.ul_daq_sn  = 0;

    dmac_data_acq_set_send_flag(OAL_TRUE);

    /* 发送daq 数据信息 */
    while (ul_trans_remainder_len >= ul_unit_len)
    {
        if (OAL_FALSE == g_st_data_acq.en_daq_app_error)
        {
            if (OAL_TRUE == dmac_data_acq_get_send_flag())
            {
                ul_ret = dmac_data_acq_report_data_unit(puc_data_offset, ul_unit_len, pst_netbuf);
                if (ul_ret != OAL_SUCC)
                {
                    /* 释放内存 */
                    OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_data_acq_report_data::dmac_data_acq_report_data_unit failed[%d].}", ul_ret);

                    return ul_ret;
                }

                ul_trans_remainder_len  -= ul_unit_len;
                puc_data_offset         += ul_unit_len;
            }
            else
            {
                oal_msleep(1000);

                if (DMAC_DATA_ACQ_MAX_WAIT_TIME <= ul_time)
                {
                    OAM_ERROR_LOG0(0, OAM_SF_ANY, "{dmac_report_data_acq_record::send data uint failed. Try again.}");

                    return OAL_FAIL;
                }

                ul_time++;
            }
        }
        else
        {
            OAM_ERROR_LOG0(0, OAM_SF_ANY, "{dmac_report_data_acq_record::send data uint failed. app error, Try again.}");

            return OAL_FAIL;
        }
    }

    /* 最后一片数据采集长度 */
    if ((ul_trans_remainder_len != 0) && (OAL_FALSE == g_st_data_acq.en_daq_app_error))
    {

        ul_ret = dmac_data_acq_report_data_unit(puc_data_offset, ul_trans_remainder_len,pst_netbuf);
        if (ul_ret != OAL_SUCC)
        {
            OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_report_data_acq_record::dmac_data_acq_report_data_unit failed[%d].}", ul_ret);

            return ul_ret;
        }
    }

    g_st_data_acq.uc_ack_flag = OAL_FALSE;

    while(!g_st_data_acq.uc_ack_flag)
    {

        oal_msleep(1000);

        if ((OAL_TRUE == g_st_data_acq.en_daq_app_error) || (DMAC_DATA_ACQ_MAX_WAIT_TIME <= ul_time))
        {
            OAM_ERROR_LOG0(0, OAM_SF_ANY, "{dmac_data_acq_report_data::wait app ack timeout or app error. Try again.}");

            return OAL_FAIL;
        }

        ul_time++;
    }

    return OAL_SUCC;
}
Пример #21
0
/*****************************************************************************
 函 数 名  : dmac_wep_add_entry
 功能描述  : 将一个关联station的密钥写进硬件寄存器
 输入参数  : 无
 输出参数  : 无
 返 回 值  :
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2013年7月24日
    作    者   : t00231215
    修改内容   : 新生成函数
  2.日    期   : 2013年10月17日
    作    者   : l00218984
    修改内容   : 新生成函数

*****************************************************************************/
oal_uint32  dmac_config_wep_add_entry(mac_vap_stru *pst_mac_vap, oal_uint8 uc_len, oal_uint8 *puc_param)
{
    hal_security_key_stru             st_wep_key         = {0};
    dmac_vap_stru                    *pst_dmac_vap       = OAL_PTR_NULL;
    mac_user_stru                    *pst_mac_user       = OAL_PTR_NULL;
    oal_uint8                        *puc_addr           = OAL_PTR_NULL;
    oal_uint32                        ul_ret;
#ifdef _PRE_WLAN_FEATURE_PROXYSTA
    mac_device_stru                    *pst_mac_device;
#endif

    puc_addr = puc_param;

    pst_dmac_vap = mac_res_get_dmac_vap(pst_mac_vap->uc_vap_id);
    if (OAL_PTR_NULL == pst_dmac_vap)
    {
        OAM_ERROR_LOG0(pst_mac_vap->uc_vap_id, OAM_SF_WEP, "{dmac_config_wep_add_entry::pst_dmac_vap null.}");
        return OAL_ERR_CODE_PTR_NULL;
    }

    pst_mac_user =  (mac_user_stru *)mac_vap_get_user_by_addr(pst_mac_vap, puc_addr);
    if (OAL_PTR_NULL == pst_mac_user)
    {
        OAM_ERROR_LOG0(pst_mac_vap->uc_vap_id, OAM_SF_WEP, "{dmac_config_wep_add_entry::mac_user null.}");
        return OAL_ERR_CODE_PTR_NULL;
    }

    /* 设置用户的发送加密套件*/
    ul_ret = mac_user_update_wep_key(pst_mac_user, pst_mac_vap->us_multi_user_idx);
    if (OAL_SUCC != ul_ret)
    {
        OAM_ERROR_LOG1(pst_mac_vap->uc_vap_id, OAM_SF_WEP, "{dmac_config_wep_add_entry::mac_wep_add_usr_key FAIL[%d].}", ul_ret);
        return OAL_ERR_CODE_PTR_NULL;
    }

    st_wep_key.uc_key_id       = pst_mac_user->st_key_info.uc_default_index;
    st_wep_key.en_cipher_type  = pst_mac_user->st_key_info.en_cipher_type;
    st_wep_key.en_key_type     = WLAN_KEY_TYPE_PTK;
    st_wep_key.uc_lut_idx      = ((dmac_user_stru *)pst_mac_user)->uc_lut_index;
    st_wep_key.en_update_key   = OAL_TRUE;
    st_wep_key.en_key_origin   = WLAN_AUTH_KEY;

    /*密钥已经添加过,不需要重复添加,只需要激活用户即可*/
    st_wep_key.puc_cipher_key  = pst_mac_user->st_key_info.ast_key[st_wep_key.uc_key_id].auc_key;
    st_wep_key.puc_mic_key     = OAL_PTR_NULL;

#ifdef _PRE_WLAN_FEATURE_PROXYSTA
    pst_mac_device = mac_res_get_dev(pst_mac_vap->uc_device_id);
    if (OAL_PTR_NULL == pst_mac_device)
    {
        OAM_ERROR_LOG0(pst_mac_vap->uc_vap_id, OAM_SF_PROXYSTA, "{dmac_config_wep_add_entry::mac_res_get_dev is null.}");
        return OAL_ERR_CODE_PTR_NULL;
    }

    if (OAL_TRUE == pst_mac_device->st_cap_flag.bit_proxysta)
    {
        if ((OAL_TRUE == pst_mac_vap->st_vap_proxysta.en_is_proxysta) && (OAL_FALSE == pst_mac_vap->st_vap_proxysta.en_is_main_proxysta))
        {
            /* 写硬件寄存器 */
            /* 对于proxysta来讲,peer_macaddr需要配置为自身mac地址,创建时已经配置过 */
            hal_ce_add_key(pst_dmac_vap->pst_hal_device, &st_wep_key, OAL_PTR_NULL);
        }
        else
        {
            /* 写硬件寄存器 */
            hal_ce_add_key(pst_dmac_vap->pst_hal_device, &st_wep_key, puc_addr);
        }
    }
    else
    {
        /* 写硬件寄存器   */
        hal_ce_add_key(pst_dmac_vap->pst_hal_device, &st_wep_key, puc_addr);
    }
#else
    /* 写硬件寄存器   */
    hal_ce_add_key(pst_dmac_vap->pst_hal_device, &st_wep_key, puc_addr);
#endif

    return OAL_SUCC;
}
Пример #22
0
/*****************************************************************************
 函 数 名  : hmac_protection_del_user_stat_ht_ap
 功能描述  : 删除保护模式相关user统计(ht)
 输入参数  : pst_mac_vap  : mac vap结构体指针
             pst_mac_user : mac user结构体指针
 输出参数  : 无
 返 回 值  : oal_uint32
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2014年1月22日
    作    者   : c00260463
    修改内容   : 新生成函数

*****************************************************************************/
OAL_STATIC oal_uint32  hmac_protection_del_user_stat_ht_ap(mac_vap_stru *pst_mac_vap, mac_user_stru *pst_mac_user)
{
    mac_user_ht_hdl_stru   *pst_ht_hdl     = &(pst_mac_user->st_ht_hdl);
    mac_protection_stru    *pst_protection = &(pst_mac_vap->st_protection);
    hmac_user_stru         *pst_hmac_user;

    pst_hmac_user = (hmac_user_stru *)mac_res_get_hmac_user(pst_mac_user->us_assoc_id);
    if (OAL_PTR_NULL == pst_hmac_user)
    {
        OAM_ERROR_LOG1(pst_mac_vap->uc_vap_id, OAM_SF_ANY,
                        "hmac_protection_del_user_stat_ht_ap::Get Hmac_user(idx=%d) NULL POINT!", pst_mac_user->us_assoc_id);
        return OAL_ERR_CODE_PTR_NULL;
    }

    /*如果去关联的站点不支持HT*/
    if ((OAL_FALSE == pst_ht_hdl->en_ht_capable)
        && (OAL_TRUE == pst_hmac_user->st_user_stats_flag.bit_no_ht_stats_flag)
        && (0 != pst_protection->uc_sta_non_ht_num))
    {
        pst_protection->uc_sta_non_ht_num--;
    }
    else /*支持HT*/
    {
        /*如果去关联的站点不支持20/40Mhz频宽*/
        if ((OAL_FALSE == pst_ht_hdl->bit_supported_channel_width)
            && (OAL_TRUE == pst_hmac_user->st_user_stats_flag.bit_20M_only_stats_flag)
            && (0 != pst_protection->uc_sta_20M_only_num))
        {
            pst_protection->uc_sta_20M_only_num--;
        }

        /*如果去关联的站点不支持GF*/
        if ((OAL_FALSE == pst_ht_hdl->bit_ht_green_field)
            && (OAL_TRUE == pst_hmac_user->st_user_stats_flag.bit_no_gf_stats_flag)
            && (0 != pst_protection->uc_sta_non_gf_num))
        {
            pst_protection->uc_sta_non_gf_num--;
        }

        /*如果去关联的站点不支持L-SIG TXOP Protection*/
        if ((OAL_FALSE == pst_ht_hdl->bit_lsig_txop_protection)
            && (OAL_TRUE == pst_hmac_user->st_user_stats_flag.bit_no_lsig_txop_stats_flag)
            && (0 != pst_protection->uc_sta_no_lsig_txop_num))
        {
            pst_protection->uc_sta_no_lsig_txop_num--;
        }

        /*如果去关联的站点不支持40Mhz cck*/
        if ((OAL_FALSE == pst_ht_hdl->bit_dsss_cck_mode_40mhz)
             && (OAL_TRUE == pst_ht_hdl->bit_supported_channel_width)
             && (OAL_TRUE == pst_hmac_user->st_user_stats_flag.bit_no_40dsss_stats_flag)
             && (0 != pst_protection->uc_sta_no_40dsss_cck_num))
        {
            pst_protection->uc_sta_no_40dsss_cck_num--;
        }
    }

    pst_hmac_user->st_user_stats_flag.bit_no_ht_stats_flag             = OAL_FALSE;
    pst_hmac_user->st_user_stats_flag.bit_no_gf_stats_flag             = OAL_FALSE;
    pst_hmac_user->st_user_stats_flag.bit_20M_only_stats_flag          = OAL_FALSE;
    pst_hmac_user->st_user_stats_flag.bit_no_40dsss_stats_flag         = OAL_FALSE;
    pst_hmac_user->st_user_stats_flag.bit_no_lsig_txop_stats_flag      = OAL_FALSE;

    return OAL_SUCC;
}
int32 hwifi_config_init(int32 cus_tag)
{
    int32               l_cfg_id;
    int32               l_ret = INI_FAILED;
    int32               l_ori_val;
    wlan_cfg_cmd*       pgast_wifi_config;
    int32*              pgal_params;
    int32               l_cfg_value = 0;
    int32               l_wlan_cfg_butt;

    switch (cus_tag)
    {
        case CUS_TAG_NV:
            return hwifi_config_init_nvram();
        case CUS_TAG_INI:
            host_params_init_first();
            pgast_wifi_config = g_ast_wifi_config_cmds;
            pgal_params = g_al_host_init_params;
            l_wlan_cfg_butt = WLAN_CFG_INIT_BUTT;
            break;
        case CUS_TAG_DTS:
            original_value_for_dts_params();
            pgast_wifi_config = g_ast_wifi_config_dts;
            pgal_params = g_al_dts_params;
            l_wlan_cfg_butt = WLAN_CFG_DTS_BUTT;
            break;
        default:
            OAM_ERROR_LOG1(0, OAM_SF_ANY, "hisi_customize_wifi tag number[0x%x] not correct!", cus_tag);
            return INI_FAILED;
    }

    for(l_cfg_id=0; l_cfg_id<l_wlan_cfg_butt; ++l_cfg_id)
    {
        if(CUS_TAG_INI == cus_tag && WLAN_CFG_INIT_COUNTRY_CODE == l_cfg_id)
        {
            /* 获取ini中的国家码 */
            l_ret = get_cust_conf_string(INI_MODU_WIFI, pgast_wifi_config[l_cfg_id].name, g_ac_country_code, sizeof(g_ac_country_code));
            if(INI_FAILED == l_ret)
            {
                OAM_WARNING_LOG0(0, OAM_SF_ANY, "hisi_customize_wifi read country code failed, check if it exists!");
                strncpy(g_ac_country_code, "99", 2);
            }
            g_ac_country_code[2] = '\0';
            continue;
        }

        /* 获取ini或dts中的配置值 */
        l_ret = get_cust_conf_int32(INI_MODU_WIFI, pgast_wifi_config[l_cfg_id].name, &l_cfg_value);
        if (INI_FAILED == l_ret)
        {
            l_ret = get_cust_conf_int32(CUST_MODU_DTS, pgast_wifi_config[l_cfg_id].name, &l_cfg_value);
            if(INI_FAILED == l_ret)
            {
                OAM_WARNING_LOG1(0, OAM_SF_ANY, "hisi_customize_wifi read ini or dts file failed, check if cfg_id[%d] exists!", l_cfg_id);
                continue;
            }
        }

        l_ori_val = pgal_params[l_cfg_id];
        pgal_params[l_cfg_id] = l_cfg_value;
        OAM_WARNING_LOG3(0, OAM_SF_ANY, "hisi_customize_wifi [cfg_id:%d]value changed from [init:%d] to [config:%d]. \n", l_cfg_id, l_ori_val, pgal_params[l_cfg_id]);
    }

    return INI_SUCC;
}
Пример #24
0
/*****************************************************************************
 函 数 名  : dmac_device_init
 功能描述  : device的初始化函数
 输入参数  : 指向要进行初始化的device指针
 输出参数  : 无
 返 回 值  : 成功或者失败原因
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2012年10月19日
    作    者   : huxiaotong
    修改内容   : 新生成函数

*****************************************************************************/
OAL_STATIC oal_uint32  dmac_device_init(oal_uint8 *puc_device_id, oal_uint8 uc_chip_id, oal_uint8 uc_device_id, oal_uint32 ul_chip_ver)
{
    oal_uint32                 ul_ret;
    oal_uint8                  uc_dev_id;
    mac_device_stru           *pst_device;
    mac_data_rate_stru        *pst_data_rate;
    oal_uint32                 ul_rate_num = 0;
    oal_uint32                 ul_idx;
    oal_uint32                 ul_loop = 0;
    dmac_device_stru          *pst_dmac_device;
    hal_cfg_rts_tx_param_stru  st_hal_rts_tx_param;

#ifdef _PRE_WLAN_DFT_STAT
    oam_stats_phy_node_idx_stru st_phy_node_idx = {{OAM_STATS_PHY_NODE_TX_CNT,
                                                    OAM_STATS_PHY_NODE_RX_OK_CNT,
                                                    OAM_STATS_PHY_NODE_11B_HDR_ERR_CNT,
                                                    OAM_STATS_PHY_NODE_OFDM_HDR_ERR_CNT}};
#endif

    /*申请公共mac device结构体,修改下 名称*/
    ul_ret = mac_res_alloc_dmac_dev(&uc_dev_id);
    if(OAL_UNLIKELY(ul_ret != OAL_SUCC))
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_device_init::mac_res_alloc_dmac_dev failed[%d].}", ul_ret);

        return OAL_FAIL;
    }

    pst_device = mac_res_get_dev(uc_dev_id);

    if (OAL_PTR_NULL == pst_device)
    {
       OAM_ERROR_LOG0(0, OAM_SF_ANY, "{dmac_device_init::pst_device null.}");

       return OAL_ERR_CODE_PTR_NULL;
    }

#if 0
    pst_device->uc_chip_id   = uc_chip_id;
    pst_device->uc_device_id = uc_dev_id;
#endif

    /* 申请dmac device资源 */
    if(OAL_UNLIKELY(dmac_res_alloc_mac_dev(uc_dev_id) != OAL_SUCC))
    {
        OAM_ERROR_LOG0(0, OAM_SF_ANY, "{dmac_device_init::dmac_res_alloc_mac_dev failed.}");
        return OAL_FAIL;
    }

#if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
    /* 初始化device级别的一些参数 */
    ul_ret = mac_device_init(pst_device, ul_chip_ver, uc_chip_id, uc_dev_id);
    if (OAL_SUCC != ul_ret)
    {
        OAM_ERROR_LOG2(0, OAM_SF_ANY, "{dmac_device_init::mac_device_init failed[%d], chip_ver[0x%x].}", ul_ret, ul_chip_ver);
        dmac_res_free_mac_dev(uc_dev_id);
        mac_res_free_dev(uc_dev_id);
        return ul_ret;
    }
#endif

    /* 获取hmac device,并进行相关参数赋值 */
    pst_dmac_device = dmac_res_get_mac_dev(uc_dev_id);
    if (OAL_PTR_NULL == pst_dmac_device)
    {
       OAM_ERROR_LOG0(0, OAM_SF_ANY, "{dmac_device_init::pst_dmac_device null.}");
       mac_res_free_dev(uc_dev_id);
       return OAL_ERR_CODE_PTR_NULL;
    }

    /* 结构体初始化 */
    OAL_MEMZERO(pst_dmac_device, OAL_SIZEOF(*pst_dmac_device));
    pst_dmac_device->pst_device_base_info = pst_device;

#ifdef _PRE_WLAN_FEATURE_DFR
    pst_dmac_device->en_dfr_hw_reset_enable = OAL_FALSE;
#endif //#ifdef _PRE_WLAN_FEATURE_DFR


    /* 硬mac结构指针只存在于DMAC中,需要针对device对象中私有部分
       的内容进行初始化,用于逻辑和物理device的对应 */
    ul_ret = hal_chip_get_device(uc_chip_id, uc_device_id, &pst_device->pst_device_stru);

    pst_device->ul_core_id = pst_device->pst_device_stru->ul_core_id;

    if (OAL_SUCC != ul_ret)
    {
        OAM_WARNING_LOG1(0, OAM_SF_ANY, "{dmac_device_init::hal_chip_get_device failed[%d].}", ul_ret);

        dmac_res_free_mac_dev(uc_dev_id);
        mac_res_free_dev(uc_dev_id);
        return ul_ret;
    }

    /* 保存mac层的device id */
    pst_device->pst_device_stru->uc_mac_device_id = uc_dev_id;

    if(OAL_SUCC != mac_fcs_init(&pst_device->st_fcs_mgr, pst_device->uc_chip_id, pst_device->uc_device_id))
    {
        OAM_WARNING_LOG0(0, OAM_SF_ANY, "{dmac_device_init::mac_fcs_init failed.}");
        dmac_res_free_mac_dev(uc_dev_id);
        mac_res_free_dev(uc_dev_id);
        return OAL_FAIL;
    }

    /* 算法框架初始化 */
    ul_ret = dmac_alg_init(pst_device);
    if (OAL_SUCC != ul_ret)
    {
        OAM_WARNING_LOG1(0, OAM_SF_ANY, "{dmac_device_init::dmac_alg_init failed[%d].}", ul_ret);
        dmac_res_free_mac_dev(uc_dev_id);
        mac_res_free_dev(uc_dev_id);
        return ul_ret;
    }

    /* 算法距离、干扰等状态初始化 */
    dmac_alg_stat_init(pst_dmac_device);

    pst_device->us_total_mpdu_num = 0;
    /* 错误计数初始化 */
    OAL_MEMZERO(pst_device->aul_mac_err_cnt, OAL_SIZEOF(pst_device->aul_mac_err_cnt));

    /*初始化记录性能统计第一次时间戳*/
    pst_device->ul_first_timestamp = 0;

    pst_device->ul_rx_buf_too_small_show_counter = 0;
#if (_PRE_PRODUCT_ID == _PRE_PRODUCT_ID_HI1151)
    pst_device->ul_rx_fsm_st_timeout_show_counter = 0;
    pst_device->ul_tx_fsm_st_timeout_show_counter = 0;
    pst_device->ul_beacon_miss_show_counter = 0;
    pst_device->us_user_nums_max = WLAN_ASSOC_USER_MAX_NUM_SPEC;
    pst_device->ul_pcie_reg110_timeout_counter = 0;
    pst_device->ul_pcie_read_counter = 0;

    /* DTS2015100700205,特殊网卡兼容性问题规避方案: 会发生DataFlow Break时候会影响性能 */
    pst_device->st_dataflow_brk_bypass.en_brk_limit_aggr_enable = OAL_FALSE;
    pst_device->st_dataflow_brk_bypass.ul_tx_dataflow_brk_cnt = 0;
    pst_device->st_dataflow_brk_bypass.ul_last_tx_complete_isr_cnt = 0;
#endif
    for (ul_loop = 0; ul_loop < WLAN_WME_AC_BUTT; ul_loop++)
    {
        pst_device->aus_ac_mpdu_num[ul_loop] = 0;
    }

    for (ul_loop = 0; ul_loop < WLAN_VAP_SUPPORT_MAX_NUM_LIMIT; ul_loop++)
    {
        pst_device->aus_vap_mpdu_num[ul_loop] = 0;
    }

    for (ul_loop = WLAN_WME_AC_BE; ul_loop < WLAN_WME_AC_BUTT; ul_loop++)
    {
        pst_device->aus_ac_mpdu_num[ul_loop] = 0;
    }

#ifdef _PRE_WLAN_DFT_STAT
    /* 初始化维测参数,空口环境类参数 */
    OAL_MEMZERO(&(pst_device->st_dbb_env_param_ctx), OAL_SIZEOF(mac_device_dbb_env_param_ctx_stru));
#endif


    #ifdef _PRE_WLAN_FEATURE_PM
    pst_device->en_pm_enable   = OAL_FALSE;
    mac_pm_arbiter_init(pst_device);
    #endif

    /* 初始化TXOP特性相关值 */
    pst_device->en_txop_enable       = OAL_FALSE;
    pst_device->uc_tx_ba_num = 0;

    /* 从eeprom或flash获得MAC地址 */
    hal_get_hw_addr(pst_device->pst_device_stru, pst_device->auc_hw_addr);

    /* 初始化DEVICE下的速率集 */
    hal_get_rate_80211g_table(pst_device->pst_device_stru, (oal_void *)&pst_data_rate);
    hal_get_rate_80211g_num(pst_device->pst_device_stru, &ul_rate_num);

    for (ul_idx = 0; ul_idx < ul_rate_num; ul_idx++)
    {
        oal_memcopy(&(pst_device->st_mac_rates_11g[ul_idx]),&pst_data_rate[ul_idx],OAL_SIZEOF(mac_data_rate_stru));
    }

    /* 初始化2.4G和5G的RTS速率, RTS[0~2]设为24Mbps,  RTS[3]在2.4G设为1Mbps、5G设为24Mbps*/
    st_hal_rts_tx_param.auc_protocol_mode[0]    = WLAN_LEGACY_OFDM_PHY_PROTOCOL_MODE;
    st_hal_rts_tx_param.auc_rate[0]             = WLAN_LEGACY_OFDM_24M_BPS;
    st_hal_rts_tx_param.auc_protocol_mode[1]    = WLAN_LEGACY_OFDM_PHY_PROTOCOL_MODE;
    st_hal_rts_tx_param.auc_rate[1]             = WLAN_LEGACY_OFDM_24M_BPS;
    st_hal_rts_tx_param.auc_protocol_mode[2]    = WLAN_LEGACY_OFDM_PHY_PROTOCOL_MODE;
    st_hal_rts_tx_param.auc_rate[2]             = WLAN_LEGACY_OFDM_24M_BPS;

    st_hal_rts_tx_param.en_band                 = WLAN_BAND_2G;
    st_hal_rts_tx_param.auc_protocol_mode[3]    = WLAN_11B_PHY_PROTOCOL_MODE;
    st_hal_rts_tx_param.auc_rate[3]             = WLAN_LONG_11b_1_M_BPS;
    hal_set_rts_rate_params(pst_device->pst_device_stru, &st_hal_rts_tx_param);

    st_hal_rts_tx_param.en_band                 = WLAN_BAND_5G;
    st_hal_rts_tx_param.auc_protocol_mode[3]    = WLAN_LEGACY_OFDM_PHY_PROTOCOL_MODE;
    st_hal_rts_tx_param.auc_rate[3]             = WLAN_LEGACY_OFDM_24M_BPS;
    hal_set_rts_rate_params(pst_device->pst_device_stru, &st_hal_rts_tx_param);

#if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)||(_PRE_OS_VERSION_RAW == _PRE_OS_VERSION)
    /* TBD  */
    /* hal_enable_radar_det(pst_device->pst_device_stru, OAL_TRUE); */
    pst_device->us_dfs_timeout = 0;
#endif

    /* 初始化DMAC SCANNER */
    dmac_scan_init(pst_device);

#ifdef _PRE_SUPPORT_ACS
    /* 初始化ACS结构体 */
    dmac_acs_init(pst_device);
#endif

#ifdef _PRE_WLAN_DFT_REG
    /* 初始化寄存器读取定时器 */
    FRW_TIMER_CREATE_TIMER(&pst_device->st_reg_prd_timer,
                               dmac_reg_timeout,
                               OAM_REGSTER_REFRESH_TIME_MS,
                               pst_device->pst_device_stru,
                               OAL_TRUE,
                               OAM_MODULE_ID_DMAC,
                               pst_device->ul_core_id);
#endif


    /* 出参赋值,CHIP中需要保存该device id */
    *puc_device_id = uc_dev_id;

#ifdef _PRE_WLAN_FEATURE_AMPDU
#ifdef _PRE_DEBUG_MODE
//#if ((_PRE_TARGET_PRODUCT_TYPE_5610DMB != _PRE_CONFIG_TARGET_PRODUCT) )
    //OAL_MEMZERO(g_ast_tx_ba_track[pst_device->uc_device_id], OAL_SIZEOF(dmac_tx_ba_track_stru) * HAL_MAX_AMPDU_LUT_SIZE);
//#endif
#endif
#endif

#ifdef _PRE_DEBUG_MODE
    OAL_MEMZERO(&(pst_device->st_exception_report_timer), OAL_SIZEOF(frw_timeout_stru));

    FRW_TIMER_CREATE_TIMER(&(pst_device->st_exception_report_timer),
                            dmac_device_exception_report_timeout_fn,
                            MAC_EXCEPTION_TIME_OUT,
                            pst_device->pst_device_stru,
                            OAL_TRUE,
                            OAM_MODULE_ID_MAC,
                            pst_device->ul_core_id);

#endif

#ifdef _PRE_WLAN_DFT_STAT
        /* 初始化phy统计节点 */
        dmac_dft_set_phy_stat_node(pst_device, &st_phy_node_idx);
#endif

    ul_ret = dmac_cfg_vap_init(pst_device);
    if(OAL_UNLIKELY(ul_ret != OAL_SUCC))
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "{hmac_chip_init::hmac_cfg_vap_init failed[%d].}", ul_ret);
        return OAL_FAIL;
    }

    return OAL_SUCC;
}
Пример #25
0
/*****************************************************************************
 函 数 名  : dmac_vap_init
 功能描述  : 初始化要添加的dmac vap的一些特性信息
 输入参数  : 指向要添加的vap的指针
 输出参数  : 无
 返 回 值  : 成功或者失败原因
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2012年10月24日
    作    者   : 康国昌
    修改内容   : 新生成函数

*****************************************************************************/
oal_uint32  dmac_vap_init(
                dmac_vap_stru              *pst_dmac_vap,
                oal_uint8                   uc_chip_id,
                oal_uint8                   uc_device_id,
                oal_uint8                   uc_vap_id,
                mac_cfg_add_vap_param_stru *pst_param)
{
#if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
    oal_uint32  ul_ret;
#endif
    mac_device_stru               *pst_mac_device = mac_res_get_dev(uc_device_id);
    if (OAL_UNLIKELY(OAL_PTR_NULL == pst_mac_device))
    {
        OAM_ERROR_LOG1(0, OAM_SF_ANY, "{dmac_vap_init::pst_mac_device[%d] null!}", uc_device_id);
        return OAL_ERR_CODE_PTR_NULL;
    }

    /* DMAC VAP 部分初始清零 */
    OAL_MEMZERO(((oal_uint8 *)pst_dmac_vap) + OAL_SIZEOF(mac_vap_stru), OAL_SIZEOF(dmac_vap_stru) - OAL_SIZEOF(mac_vap_stru));
#if (_PRE_PRODUCT_ID == _PRE_PRODUCT_ID_HI1151)

    /* 统计信息清零 */
    oam_stats_clear_vap_stat_info(uc_vap_id);
#endif

#if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
    /* 在非OFFLOAD情况下,这些操作HMAC都已经做过了 */
    /* 初始化mac vap */
    ul_ret = mac_vap_init(&pst_dmac_vap->st_vap_base_info,
                           uc_chip_id,
                           uc_device_id,
                           uc_vap_id,
                           pst_param);
    if (OAL_SUCC != ul_ret)
    {
        OAM_WARNING_LOG1(uc_vap_id, OAM_SF_CFG,
                         "{dmac_vap_init::dmac_vap_init failed[%d].", ul_ret);
        return ul_ret;
    }
    pst_dmac_vap->bit_beacon_timeout_times = 0;
#endif

    pst_dmac_vap->en_bfer_actived       = pst_mac_device->bit_su_bfmer;
    pst_dmac_vap->en_bfee_actived       = pst_mac_device->bit_su_bfmee;
    pst_dmac_vap->en_mu_bfee_actived    = pst_mac_device->bit_mu_bfmee;
    pst_dmac_vap->en_txstbc_actived     = pst_mac_device->bit_tx_stbc;
    pst_dmac_vap->en_multi_user_multi_ac_flag = OAL_FALSE;
    pst_dmac_vap->uc_traffic_type    = OAL_TRAFFIC_NORMAL;

    /* 初始化特性标识中BEACON帧不轮流发送 */
    pst_dmac_vap->en_beacon_chain_active = OAL_FALSE;

    /* VAP发送通道默认值赋值,按照device下能力赋值 */
    pst_dmac_vap->uc_vap_tx_chain = pst_mac_device->uc_tx_chain;

    /* 速率结构体赋初值 */
    /* 按照PHY给出的初始值 ul_value = 0x00800211 */
    pst_dmac_vap->st_tx_alg.ast_per_rate[0].rate_bit_stru.bit_tx_count = 1;
#if (_PRE_PRODUCT_ID == _PRE_PRODUCT_ID_HI1151)
    pst_dmac_vap->st_tx_alg.ast_per_rate[0].rate_bit_stru.bit_stbc_mode = 0;
#endif
    pst_dmac_vap->st_tx_alg.ast_per_rate[0].rate_bit_stru.bit_tx_chain_selection = 1;
    pst_dmac_vap->st_tx_alg.ast_per_rate[0].rate_bit_stru.uc_tx_data_antenna = 2;


    /* FPGA zhangyu Debug 11n */
    pst_dmac_vap->st_tx_alg.ast_per_rate[0].rate_bit_stru.un_nss_rate.st_ht_rate.bit_ht_mcs = 0;
    pst_dmac_vap->st_tx_alg.ast_per_rate[0].rate_bit_stru.un_nss_rate.st_ht_rate.bit_protocol_mode = WLAN_HT_PHY_PROTOCOL_MODE;

    /* 默认是HOST VAP */
    pst_dmac_vap->en_is_host_vap = OAL_TRUE;

    /* 默认天线组合 */
    pst_dmac_vap->uc_default_ant_bitmap = 0xFF;

    /* 初始化节能相关参数 */
    pst_dmac_vap->uc_ps_user_num = 0;
    pst_dmac_vap->uc_dtim_count  = WLAN_DTIM_DEFAULT;
#ifdef _PRE_WLAN_CHIP_TEST
    pst_dmac_vap->pst_wow_probe_resp = OAL_PTR_NULL;
    pst_dmac_vap->pst_wow_null_data  = OAL_PTR_NULL;
#endif
    pst_dmac_vap->uc_sw_retry_limit  = DMAC_MAX_SW_RETRIES;

    if (WLAN_VAP_MODE_BSS_AP == pst_dmac_vap->st_vap_base_info.en_vap_mode)
    {
        /* DTS2015050301014,双芯片实现时bitmap_len计算要乘以device(也即是chip)个数  */
        pst_dmac_vap->uc_tim_bitmap_len = (oal_uint8)(2 + (((g_us_max_asoc_user + WLAN_SERVICE_VAP_MAX_NUM_PER_DEVICE)* MAC_RES_MAX_DEV_NUM + 7 ) >> 3));
        pst_dmac_vap->puc_tim_bitmap = OAL_MEM_ALLOC(OAL_MEM_POOL_ID_LOCAL, pst_dmac_vap->uc_tim_bitmap_len, OAL_TRUE);
        if (OAL_PTR_NULL == pst_dmac_vap->puc_tim_bitmap)
        {
            OAM_ERROR_LOG0(uc_vap_id, OAM_SF_ANY, "{dmac_vap_init::puc_tim_bitmap null.}");

            return OAL_ERR_CODE_ALLOC_MEM_FAIL;
        }

        OAL_MEMZERO(pst_dmac_vap->puc_tim_bitmap, pst_dmac_vap->uc_tim_bitmap_len);
        /* TIM bitmap len is default 1*/
        pst_dmac_vap->puc_tim_bitmap[0] = 1;
    }
oal_netbuf_stru* hmac_defrag_process(hmac_user_stru *pst_hmac_user, oal_netbuf_stru *pst_netbuf, oal_uint32 ul_hrdsize)
{
    mac_ieee80211_frame_stru *pst_mac_hdr   = OAL_PTR_NULL;
    mac_ieee80211_frame_stru *pst_last_hdr  = OAL_PTR_NULL;
    oal_uint16                us_rx_seq     = 0;
    oal_uint16                us_last_seq   = 0;
    oal_uint8                 uc_frag_num   = 0;
    oal_uint8                 uc_last_frag_num  = 0;
    oal_bool_enum_uint8       en_more_frag      = OAL_FALSE;
    oal_netbuf_stru          *pst_new_buf       = OAL_PTR_NULL;
    mac_rx_ctl_stru          *pst_rx_ctl;
    oal_uint32                ul_ret;
    oal_uint8                 uc_device_id;
    mac_device_stru          *pst_mac_device;
    oal_uint32                ul_core_id;


    pst_mac_hdr = (mac_ieee80211_frame_stru *)oal_netbuf_data(pst_netbuf);
    us_rx_seq   = pst_mac_hdr->bit_seq_num;
    uc_frag_num = (oal_uint8)pst_mac_hdr->bit_frag_num;

    en_more_frag = (oal_bool_enum_uint8)pst_mac_hdr->st_frame_control.bit_more_frag;

    /* 如果没有什么可以去分片的则直接返回 */
    if (!en_more_frag && 0 == uc_frag_num && OAL_PTR_NULL == pst_hmac_user->pst_defrag_netbuf)
    {
        return pst_netbuf;
    }

    OAL_MEM_NETBUF_TRACE(pst_netbuf, OAL_FALSE);

    /* 首先检查到来的分片报文是不是属于正在重组的分片报文 */
    if (pst_hmac_user->pst_defrag_netbuf)
    {
        frw_timer_restart_timer(&pst_hmac_user->st_defrag_timer, HMAC_FRAG_TIMEOUT, OAL_FALSE);

        pst_last_hdr = (mac_ieee80211_frame_stru *)oal_netbuf_data(pst_hmac_user->pst_defrag_netbuf);

        us_last_seq  = pst_last_hdr->bit_seq_num;
        uc_last_frag_num = (oal_uint8)pst_last_hdr->bit_frag_num;

        /* 如果地址不匹配,序列号不匹配,分片号不匹配则释放现在正在重组的报文 */
        if (us_rx_seq != us_last_seq ||
            uc_frag_num != (uc_last_frag_num + 1) ||
            oal_compare_mac_addr(pst_last_hdr->auc_address1, pst_mac_hdr->auc_address1) ||
            oal_compare_mac_addr(pst_last_hdr->auc_address2, pst_mac_hdr->auc_address2))
        {
            oal_netbuf_free(pst_hmac_user->pst_defrag_netbuf);
            FRW_TIMER_IMMEDIATE_DESTROY_TIMER(&pst_hmac_user->st_defrag_timer);

            pst_hmac_user->pst_defrag_netbuf = OAL_PTR_NULL;
        }
    }

    /* 判断到来的分片报文是否是第一个分片 */
    if (OAL_PTR_NULL == pst_hmac_user->pst_defrag_netbuf)
    {
        /* 首片分片的分片号不为0则释放 */
        if (uc_frag_num != 0)
        {
            oal_netbuf_free(pst_netbuf);
            OAM_STAT_VAP_INCR(pst_hmac_user->st_user_base_info.uc_vap_id, rx_defrag_process_dropped, 1);
            OAM_INFO_LOG3(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY,
                        "{hmac_defrag_process::The first frag_num is not Zero(%d), seq_num[%d], mor_frag[%d].}",
                           uc_frag_num, us_rx_seq, en_more_frag);

            return OAL_PTR_NULL;
        }

        /* 没有分片,直接返回 */
        if (0 == en_more_frag && 0 == uc_frag_num)
        {
            return pst_netbuf;
        }

        uc_device_id   = pst_hmac_user->st_user_base_info.uc_device_id;
        pst_mac_device = mac_res_get_dev((oal_uint32)uc_device_id);
        if (OAL_PTR_NULL == pst_mac_device)
        {
            OAM_ERROR_LOG4(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY,
                        "{hmac_defrag_process::user index[%d] user mac:XX:XX:XX:%02X:%02X:%02X}",
                        pst_hmac_user->st_user_base_info.us_assoc_id,
                        pst_hmac_user->st_user_base_info.auc_user_mac_addr[3],
                        pst_hmac_user->st_user_base_info.auc_user_mac_addr[4],
                        pst_hmac_user->st_user_base_info.auc_user_mac_addr[5]);
            /* user异常,丢弃报文 */
            oal_netbuf_free(pst_netbuf);
            OAM_STAT_VAP_INCR(pst_hmac_user->st_user_base_info.uc_vap_id, rx_defrag_process_dropped, 1);
            return OAL_PTR_NULL;
        }
        ul_core_id     = pst_mac_device->ul_core_id;

        /* 启动超时定时器,超时释放重组报文 */
        FRW_TIMER_CREATE_TIMER(&pst_hmac_user->st_defrag_timer,
                                hmac_defrag_timeout_fn,
                                HMAC_FRAG_TIMEOUT,
                                pst_hmac_user,
                                OAL_FALSE,
                                OAM_MODULE_ID_HMAC,
                                ul_core_id);

        /* 内存池netbuf只有1600 可能不够,参照A公司申请2500操作系统原生态报文 */
        pst_new_buf = OAL_MEM_NETBUF_ALLOC(OAL_NORMAL_NETBUF, HMAC_MAX_FRAG_SIZE, OAL_NETBUF_PRIORITY_MID);
        if (OAL_PTR_NULL == pst_new_buf)
        {
            OAM_ERROR_LOG1(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_defrag_process::Alloc new_buf null,size[%d].}", HMAC_MAX_FRAG_SIZE);
            return OAL_PTR_NULL;
        }
        OAL_MEM_NETBUF_TRACE(pst_new_buf, OAL_FALSE);

        /* 将分片报文拷贝到新申请的报文中并挂接到用户结构体下,释放原有的报文 */
        oal_netbuf_init(pst_new_buf, OAL_NETBUF_LEN(pst_netbuf));
        oal_netbuf_copydata(pst_netbuf, 0, oal_netbuf_data(pst_new_buf), OAL_NETBUF_LEN(pst_netbuf));
        oal_memcopy(OAL_NETBUF_CB(pst_new_buf), OAL_NETBUF_CB(pst_netbuf), MAC_TX_CTL_SIZE);
        pst_rx_ctl = (mac_rx_ctl_stru *)OAL_NETBUF_CB(pst_new_buf);
        pst_rx_ctl->pul_mac_hdr_start_addr = (oal_uint32 *)OAL_NETBUF_HEADER(pst_new_buf);
        pst_hmac_user->pst_defrag_netbuf = pst_new_buf;

        oal_netbuf_free(pst_netbuf);

        pst_netbuf = pst_new_buf;
    }
    else
    {
        if (OAL_UNLIKELY(OAL_PTR_NULL == pst_last_hdr))
        {
            OAM_ERROR_LOG0(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_defrag_process::pst_last_hdr is NULL.}");
            return OAL_PTR_NULL;
        }

        /* 此分片是期望的到来的分片,重启定时器,并进行重组 */
        frw_timer_restart_timer(&pst_hmac_user->st_defrag_timer, HMAC_FRAG_TIMEOUT, OAL_FALSE);

        oal_netbuf_pull(pst_netbuf, ul_hrdsize);

        /* 记录最新分片报文的分片号 */
        pst_last_hdr->bit_seq_num   = pst_mac_hdr->bit_seq_num;
        pst_last_hdr->bit_frag_num  = pst_mac_hdr->bit_frag_num;

        /*此接口内会调用dev_kfree_skb*/
        oal_netbuf_concat(pst_hmac_user->pst_defrag_netbuf, pst_netbuf);
    }

    /* 判断是否重组完毕,存在更多报文返回空指针,重组完毕返回组好的报文 */
    if (en_more_frag)
    {
        pst_netbuf = OAL_PTR_NULL;
    }
    else
    {
        if (OAL_UNLIKELY(OAL_PTR_NULL == pst_last_hdr))
        {
            OAM_ERROR_LOG0(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_defrag_process::pst_last_hdr is NULL.}");
            oal_netbuf_free(pst_netbuf);
            pst_hmac_user->pst_defrag_netbuf = OAL_PTR_NULL;
            return OAL_PTR_NULL;
        }

        pst_netbuf = pst_hmac_user->pst_defrag_netbuf;
        /* 对重组好的报文进行mic检查 */
        ul_ret = hmac_de_mic(pst_hmac_user, pst_netbuf);
        if (OAL_SUCC != ul_ret)
        {
            oal_netbuf_free(pst_netbuf);

            OAM_STAT_VAP_INCR(pst_hmac_user->st_user_base_info.uc_vap_id, rx_de_mic_fail_dropped, 1);
            pst_netbuf = OAL_PTR_NULL;

            OAM_INFO_LOG1(pst_hmac_user->st_user_base_info.uc_vap_id, OAM_SF_ANY, "{hmac_defrag_process::hmac_de_mic failed[%d].}", ul_ret);
        }

        pst_hmac_user->pst_defrag_netbuf = OAL_PTR_NULL;

        pst_last_hdr->bit_frag_num = 0;

        FRW_TIMER_IMMEDIATE_DESTROY_TIMER(&pst_hmac_user->st_defrag_timer);
    }

    return pst_netbuf;
}