Пример #1
0
int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg)
{
    unifi_cfg_get_t get_cmd;
    char inst_name[IFNAMSIZ];
    int rc;

    if (get_user(get_cmd, (unifi_cfg_get_t*)(((unifi_cfg_command_t*)arg) + 1))) {
        unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
        return -EFAULT;
    }

    switch (get_cmd) {
        case UNIFI_CFG_GET_COEX:
            {
                CsrWifiSmeCoexInfo coexInfo;
                /* Get the coex info from the SME */
                rc = sme_mgt_coex_info_get(priv, &coexInfo);
                if (rc) {
                    unifi_error(priv, "UNIFI_CFG: Get unifi_CoexInfoValue failed.\n");
                    return rc;
                }

                /* Copy the info to the out buffer */
                if (copy_to_user((void*)arg,
                            &coexInfo,
                            sizeof(CsrWifiSmeCoexInfo))) {
                    unifi_error(priv, "UNIFI_CFG: Failed to copy the coex info\n");
                    return -EFAULT;
                }
                break;
            }
        case UNIFI_CFG_GET_POWER_MODE:
            {
                CsrWifiSmePowerConfig powerConfig;
                rc = sme_mgt_power_config_get(priv, &powerConfig);
                if (rc) {
                    unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n");
                    return rc;
                }

                /* Copy the info to the out buffer */
                if (copy_to_user((void*)arg,
                            &powerConfig.powerSaveLevel,
                            sizeof(CsrWifiSmePowerSaveLevel))) {
                    unifi_error(priv, "UNIFI_CFG: Failed to copy the power save info\n");
                    return -EFAULT;
                }
                break;
            }
        case UNIFI_CFG_GET_POWER_SUPPLY:
            {
                CsrWifiSmeHostConfig hostConfig;
                rc = sme_mgt_host_config_get(priv, &hostConfig);
                if (rc) {
                    unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n");
                    return rc;
                }

                /* Copy the info to the out buffer */
                if (copy_to_user((void*)arg,
                            &hostConfig.powerMode,
                            sizeof(CsrWifiSmeHostPowerMode))) {
                    unifi_error(priv, "UNIFI_CFG: Failed to copy the host power mode\n");
                    return -EFAULT;
                }
                break;
            }
        case UNIFI_CFG_GET_VERSIONS:
            break;
        case UNIFI_CFG_GET_INSTANCE:
            {
                u16 InterfaceId=0;
                uf_net_get_name(priv->netdev[InterfaceId], &inst_name[0], sizeof(inst_name));

                /* Copy the info to the out buffer */
                if (copy_to_user((void*)arg,
                            &inst_name[0],
                            sizeof(inst_name))) {
                    unifi_error(priv, "UNIFI_CFG: Failed to copy the instance name\n");
                    return -EFAULT;
                }
            }
            break;

        case UNIFI_CFG_GET_AP_CONFIG:
            {
#ifdef CSR_SUPPORT_WEXT_AP
                uf_cfg_ap_config_t cfg_ap_config;

		memset(&cfg_ap_config, 0, sizeof(cfg_ap_config));
                cfg_ap_config.channel = priv->ap_config.channel;
                cfg_ap_config.beaconInterval = priv->ap_mac_config.beaconInterval;
                cfg_ap_config.wmmEnabled = priv->ap_mac_config.wmmEnabled;
                cfg_ap_config.dtimPeriod = priv->ap_mac_config.dtimPeriod;
                cfg_ap_config.phySupportedBitmap = priv->ap_mac_config.phySupportedBitmap;
                if (copy_to_user((void*)arg,
                            &cfg_ap_config,
                            sizeof(uf_cfg_ap_config_t))) {
                    unifi_error(priv, "UNIFI_CFG: Failed to copy the AP configuration\n");
                    return -EFAULT;
                }
#else
                   return -EPERM;
#endif
            }
            break;


        default:
            unifi_error(priv, "unifi_cfg_get_info: Unknown value.\n");
            return -EINVAL;
    }

    return 0;
}
Пример #2
0
int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg)
{
    unifi_AppValue sme_app_value;
    unifi_cfg_get_t get_cmd;
    char inst_name[IFNAMSIZ];
    int rc;

    if (get_user(get_cmd, (unifi_cfg_get_t*)(((unifi_cfg_command_t*)arg) + 1))) {
        unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
        return -EFAULT;
    }

    switch (get_cmd) {
      case UNIFI_CFG_GET_COEX:
        /* Get the coex info from the SME */
        sme_app_value.id = unifi_CoexInfoValue;
        rc = sme_mgt_get_value(priv, &sme_app_value);
        if (rc) {
            unifi_error(priv, "UNIFI_CFG: Get unifi_CoexInfoValue failed.\n");
            return rc;
        }

        /* Copy the info to the out buffer */
        if (copy_to_user((void*)arg,
                        &sme_app_value.unifi_Value_union.coexInfo,
                        sizeof(unifi_CoexInfo))) {
            unifi_error(priv, "UNIFI_CFG: Failed to copy the coex info\n");
            return -EFAULT;
        }
        break;
      case UNIFI_CFG_GET_POWER_MODE:
        sme_app_value.id = unifi_PowerConfigValue;
        rc = sme_mgt_get_value(priv, &sme_app_value);
        if (rc) {
            unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n");
            return rc;
        }

        /* Copy the info to the out buffer */
        if (copy_to_user((void*)arg,
                        &sme_app_value.unifi_Value_union.powerConfig.powerSaveLevel,
                        sizeof(unifi_PowerSaveLevel))) {
            unifi_error(priv, "UNIFI_CFG: Failed to copy the power save info\n");
            return -EFAULT;
        }
        break;
      case UNIFI_CFG_GET_POWER_SUPPLY:
        sme_app_value.id = unifi_HostConfigValue;
        rc = sme_mgt_get_value(priv, &sme_app_value);
        if (rc) {
            unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n");
            return rc;
        }

        /* Copy the info to the out buffer */
        if (copy_to_user((void*)arg,
                        &sme_app_value.unifi_Value_union.hostConfig.powerMode,
                        sizeof(unifi_HostPowerMode))) {
            unifi_error(priv, "UNIFI_CFG: Failed to copy the host power mode\n");
            return -EFAULT;
        }
        break;
      case UNIFI_CFG_GET_VERSIONS:
        break;
      case UNIFI_CFG_GET_INSTANCE:
        uf_net_get_name(priv->netdev, &inst_name[0], sizeof(inst_name));

        /* Copy the info to the out buffer */
        if (copy_to_user((void*)arg,
                         &inst_name[0],
                         sizeof(inst_name))) {
            unifi_error(priv, "UNIFI_CFG: Failed to copy the instance name\n");
            return -EFAULT;
        }
        break;        
      default:
        unifi_error(priv, "unifi_cfg_get_info: Unknown value.\n");
        return -EINVAL;
    }

    return 0;
}