oal_uint32  dmac_config_data_acq(mac_vap_stru *pst_mac_vap, oal_uint8 uc_len, oal_uint8 *puc_param)
{
    dmac_data_acq_enum_uint8    en_data_acq = 0;
    oal_uint32                  ul_ret = OAL_SUCC;
    mac_device_stru            *pst_device;
    oal_uint32                  ul_offset = 0;
    oal_int8                    ac_name[DMAC_HIPRIV_CMD_NAME_MAX_LEN];

    pst_device = mac_res_get_dev(pst_mac_vap->uc_device_id);

    /* 设置配置命令参数 */
    if(OAL_PTR_NULL == pst_device)
    {
        return OAL_FAIL;
    }

    OAL_MEMZERO(ac_name, DMAC_HIPRIV_CMD_NAME_MAX_LEN);

    /* 获取数据采集命令标识符 */
    dmac_get_cmd_one_arg((oal_int8*)puc_param, ac_name, &ul_offset);
    en_data_acq = (dmac_data_acq_enum_uint8)oal_atoi(ac_name);
    /* 偏移,取下一个参数 */
    puc_param = puc_param + ul_offset;

    switch(en_data_acq)
    {
        case DMAC_DATA_ACQ_PRE:
             /* 配置MAC寄存器 */
             ul_ret = dmac_data_acq_prepare(pst_mac_vap, puc_param, pst_device);

             break;
        case DMAC_DATA_ACQ_COND:
             /* 配置PHY寄存器 */
             ul_ret = dmac_data_acq_condition(pst_mac_vap, puc_param, pst_device);

             break;
        case DMAC_DATA_ACQ_ENABLE:
            /* 使能数据采集功能 */
             ul_ret = dmac_data_acq_enable(pst_mac_vap, puc_param, pst_device);

             break;
        case DMAC_DATA_ACQ_STATUS:
            /* 获取数据采集状态 */
             ul_ret = dmac_data_acq_get_status(pst_mac_vap, puc_param, pst_device);

             break;
        case DMAC_DATA_ACQ_RECODE:
            /* 获取数据采集数据 */
             ul_ret = dmac_data_acq_get_record();

             break;
        default:
             break;
    }

    return ul_ret;
}
Exemple #2
0
STATIC ssize_t store_wifi_pmdbg(struct device *dev, struct kobj_attribute *attr, const char *buf, size_t count)
{
    struct wlan_pm_s *pst_wlan_pm = wlan_pm_get_drv();
    int input = 0;

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    input = oal_atoi(buf);

    if (NULL == pst_wlan_pm)
    {
        OAL_IO_PRINT("pm_data is NULL!\n");
        return -FAILURE;
    }

    switch(input)
    {
       case 1:
        wlan_pm_dump_host_info();
       break;
       case 2:
        wlan_pm_dump_device_info();
       break;
#ifdef PLATFORM_DEBUG_ENABLE
       case 3:
        wlan_pm_open();
       break;
       case 4:
        wlan_pm_close();
       break;
       case 5:
        wlan_pm_enable();
       break;
       case 6:
        wlan_pm_disable();
       break;
#endif
       case 7:
       frw_timer_sys_start();
       break;
       case 8:
       frw_timer_sys_stop();
       break;
       default:
       break;
    }

    return count;
}
oal_uint32  dmac_data_acq_prepare(mac_vap_stru *pst_mac_vap,oal_uint8 *puc_param, mac_device_stru *pst_device)
{
    oal_uint32                  ul_offset = 0;
    oal_uint16                  us_left = 0;
    oal_int8                    ac_name[DMAC_HIPRIV_CMD_NAME_MAX_LEN];
    oal_uint32                  ul_ret;
    oal_uint32                  ul_unit_num = 0;

    OAL_MEMZERO(ac_name, DMAC_HIPRIV_CMD_NAME_MAX_LEN);

    if (DMAC_DATA_ACQ_STATUS_ENABLE == g_st_data_acq.en_daq_status)
    {
        /* 数据采集正在进行,不允许设置 */

        return OAL_SUCC;
    }

    ul_ret = dmac_data_acq_mem_alloc();
    if (OAL_SUCC != ul_ret)
    {
       /* 返回错误码 */
       OAM_ERROR_LOG0(pst_mac_vap->uc_vap_id, OAM_SF_ANY, "{dmac_data_acq_prepare::g_puc_mem_daq_addr null.}");

       g_st_data_acq.en_daq_status = DMAC_DATA_ACQ_STATUS_INIT;
       return ul_ret;
    }

    /* 1、获取数据采集单元长度 */
    dmac_get_cmd_one_arg((oal_int8*)puc_param, ac_name, &ul_offset);
    g_st_data_acq.st_daq_prep_info.us_len_unit = (oal_uint16)oal_atoi(ac_name);

    puc_param = puc_param + ul_offset;

    /* 如果单元长度大于最大单元长度,则配置为最大单元长度 */
    if (DMAC_DATA_ACQ_MAX_UNITLEN < g_st_data_acq.st_daq_prep_info.us_len_unit )
    {
        g_st_data_acq.st_daq_prep_info.us_len_unit = DMAC_DATA_ACQ_MAX_UNITLEN;
    }

    /* 如果单元长度不是8的倍数,则配置为8的倍数 */
    us_left = g_st_data_acq.st_daq_prep_info.us_len_unit % 8;

    g_st_data_acq.st_daq_prep_info.us_len_unit -= us_left;

    /* 2、获取数据采集单元个数 */
    dmac_get_cmd_one_arg((oal_int8*)puc_param, ac_name, &ul_offset);
    ul_unit_num = (oal_uint32)oal_atoi(ac_name);

    /* 偏移,取下一个参数 */
    puc_param = puc_param + ul_offset;
    g_st_data_acq.st_daq_prep_info.us_num = (oal_uint16)ul_unit_num;

    /* 如果单元个数超过最大个数,则设置为最大个数 */
    if (DMAC_DATA_ACQ_MAX_UNITNUM < ul_unit_num)
    {
        g_st_data_acq.st_daq_prep_info.us_num = DMAC_DATA_ACQ_MAX_UNITNUM;
    }

    /* 3、获取数据采集单元深度 */
    dmac_get_cmd_one_arg((oal_int8*)puc_param, ac_name, &ul_offset);
    g_st_data_acq.st_daq_prep_info.us_depth = (oal_uint16)oal_atoi(ac_name);

    /* 如果深度大于单元个数,则将深度设置为单元个数 */
    if (g_st_data_acq.st_daq_prep_info.us_depth > g_st_data_acq.st_daq_prep_info.us_num)
    {
        g_st_data_acq.st_daq_prep_info.us_depth = g_st_data_acq.st_daq_prep_info.us_num;
    }

    g_st_data_acq.ul_length = ((g_st_data_acq.st_daq_prep_info.us_depth) * (g_st_data_acq.st_daq_prep_info.us_len_unit));

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

    /* 如果长度超过了软件申请的最大长度,则更新深度与实际保存采集数据的长度 */
    if (DMAC_DATA_ACQ_MAX_LEN < g_st_data_acq.ul_length)
    {
        g_st_data_acq.st_daq_prep_info.us_depth = (oal_uint16)(DMAC_DATA_ACQ_MAX_LEN / g_st_data_acq.st_daq_prep_info.us_len_unit);
        g_st_data_acq.ul_length = (oal_uint32)((g_st_data_acq.st_daq_prep_info.us_len_unit) * (g_st_data_acq.st_daq_prep_info.us_depth));
    }

    /* 设置MAC寄存器 */
    hal_set_daq_mac_reg(pst_device->pst_device_stru,
                       (oal_uint32 *)g_st_data_acq.st_daq_prep_info.puc_start_addr,
                       g_st_data_acq.st_daq_prep_info.us_len_unit,
                       g_st_data_acq.st_daq_prep_info.us_num,
                       g_st_data_acq.st_daq_prep_info.us_depth);

    g_st_data_acq.en_daq_status = DMAC_DATA_ACQ_STATUS_MAC_REG;

    return OAL_SUCC;
}
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;
}