OAL_STATIC oal_bool_enum_uint8 hmac_roam_alg_find_in_bsslist(hmac_roam_bss_list_stru *pst_roam_bss_list, oal_uint8 *puc_bssid)
{
    hmac_roam_bss_info_stru    *pst_cur_bss;
    oal_uint32                  ul_current_index;
    oal_uint32                  ul_now;
    oal_uint32                  ul_timeout;
    oal_uint32                  ul_delta_time;
    oal_uint16                  us_count_limit;

    ul_now         = (oal_uint32)OAL_TIME_GET_STAMP_MS();

    for (ul_current_index = 0; ul_current_index < ROAM_LIST_MAX; ul_current_index++)
    {
        pst_cur_bss = &pst_roam_bss_list->ast_bss[ul_current_index];
        ul_timeout     = (oal_uint32)pst_cur_bss->ul_timeout;
        us_count_limit =  pst_cur_bss->us_count_limit;

        if (0 == oal_compare_mac_addr(pst_cur_bss->auc_bssid, puc_bssid))
        {
            /* 如果在超时时间内出现count_limit次以上记录 */
            ul_delta_time = OAL_TIME_GET_RUNTIME(pst_cur_bss->ul_time_stamp, ul_now);
            if ((ul_delta_time <= ul_timeout) &&
                (pst_cur_bss->us_count >= us_count_limit))
            {
                OAM_WARNING_LOG4(0, OAM_SF_ROAM,"{hmac_roam_alg_find_in_bsslist::  time_left = [%d], [%02X:XX:XX:XX:%02X:%02X]}",
                                ul_timeout - ul_delta_time,pst_cur_bss->auc_bssid[0],pst_cur_bss->auc_bssid[4],pst_cur_bss->auc_bssid[5]);
                return OAL_TRUE;
            }
            return OAL_FALSE;
        }
    }

    return OAL_FALSE;
}
Esempio n. 2
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;
}
OAL_STATIC oal_uint32 hmac_roam_alg_add_bsslist(hmac_roam_bss_list_stru *pst_roam_bss_list, oal_uint8 *puc_bssid, roam_blacklist_type_enum_uint8 list_type)
{
    hmac_roam_bss_info_stru    *pst_cur_bss;
    hmac_roam_bss_info_stru    *pst_oldest_bss;
    hmac_roam_bss_info_stru    *pst_zero_bss;
    oal_uint8                   auc_mac_zero[WLAN_MAC_ADDR_LEN] = {0};
    oal_uint32                  ul_current_index;
    oal_uint32                  ul_now;
    oal_uint32                  ul_timeout;

    pst_oldest_bss = OAL_PTR_NULL;
    pst_zero_bss   = OAL_PTR_NULL;
    ul_now = (oal_uint32)OAL_TIME_GET_STAMP_MS();

    for (ul_current_index = 0; ul_current_index < ROAM_LIST_MAX; ul_current_index++)
    {
        pst_cur_bss = &pst_roam_bss_list->ast_bss[ul_current_index];
        ul_timeout = (oal_uint32)pst_cur_bss->ul_timeout;
        if (0 == oal_compare_mac_addr(pst_cur_bss->auc_bssid, puc_bssid))
        {
            /* 优先查找已存在的记录,如果名单超时更新时间戳,否则更新count */

            if (OAL_TIME_GET_RUNTIME(pst_cur_bss->ul_time_stamp, ul_now) > ul_timeout)
            {
                pst_cur_bss->ul_time_stamp = ul_now;
                pst_cur_bss->us_count      = 1;
                /*漫游黑名单,以后有用*/
                if(ROAM_BLACKLIST_TYPE_REJECT_AP == list_type)
                {
                    pst_cur_bss->ul_timeout = ROAM_BLACKLIST_REJECT_AP_TIME_OUT;
                }
            }
            else
            {
                pst_cur_bss->us_count++;
                if(pst_cur_bss->us_count == pst_cur_bss->us_count_limit)
                {
                    pst_cur_bss->ul_time_stamp = ul_now;
                    OAM_WARNING_LOG4(0, OAM_SF_ROAM,"{hmac_roam_alg_add_bsslist::  add new, [%02X:XX:XX:%02X:%02X:%02X]}",
                                                 pst_cur_bss->auc_bssid[0],pst_cur_bss->auc_bssid[3],pst_cur_bss->auc_bssid[4],pst_cur_bss->auc_bssid[5]);
                }
            }
            return OAL_SUCC;
        }

        /* 记录第一个空记录 */
        if (OAL_PTR_NULL != pst_zero_bss)
        {
            continue;
        }

        if (0 == oal_compare_mac_addr(pst_cur_bss->auc_bssid, auc_mac_zero))
        {
            pst_zero_bss = pst_cur_bss;
            continue;
        }

        /* 记录一个非空最老记录 */
        if (OAL_PTR_NULL == pst_oldest_bss)
        {
            pst_oldest_bss = pst_cur_bss;
        }
        else
        {
            if (OAL_TIME_GET_RUNTIME(pst_cur_bss->ul_time_stamp, ul_now) >
                OAL_TIME_GET_RUNTIME(pst_oldest_bss->ul_time_stamp, ul_now))
            {
                pst_oldest_bss = pst_cur_bss;
            }
        }
    }

    if (OAL_PTR_NULL == pst_zero_bss)
    {
        pst_zero_bss = pst_oldest_bss;
    }

    if (OAL_PTR_NULL != pst_zero_bss)
    {
        oal_set_mac_addr(pst_zero_bss->auc_bssid, puc_bssid);
        pst_zero_bss->ul_time_stamp = ul_now;
        pst_zero_bss->us_count      = 1;
        return OAL_SUCC;
    }
    return OAL_FAIL;
}