Example #1
0
/*
 * Explicity disable radar reporting.
 *
 * Return 0 if it was disabled, < 0 on error.
 */
int
ath_dfs_radar_disable(struct ath_softc *sc)
{
#if 0
    HAL_PHYERR_PARAM pe;

    (void) ath_hal_getdfsthresh(sc->sc_ah, &pe);
    pe.pe_enabled = 0;
    (void) ath_hal_enabledfs(sc->sc_ah, &pe);
    return (0);
#else
    return (0);
#endif
}
Example #2
0
/*
 * Get the current DFS thresholds from the HAL
 */
int
ath_dfs_get_thresholds(struct ath_softc *sc, HAL_PHYERR_PARAM *param)
{
    ath_hal_getdfsthresh(sc->sc_ah, param);
    return (1);
}
Example #3
0
/*
 * Handle ioctl requests from the diagnostic interface.
 *
 * The initial part of this code resembles ath_ioctl_diag();
 * it's likely a good idea to reduce duplication between
 * these two routines.
 */
int
ath_ioctl_phyerr(struct ath_softc *sc, struct ath_diag *ad)
{
    unsigned int id = ad->ad_id & ATH_DIAG_ID;
    void *indata = NULL;
    void *outdata = NULL;
    u_int32_t insize = ad->ad_in_size;
    u_int32_t outsize = ad->ad_out_size;
    int error = 0;
    HAL_PHYERR_PARAM peout;
    HAL_PHYERR_PARAM *pe;

    if (ad->ad_id & ATH_DIAG_IN) {
        /*
         * Copy in data.
         */
        indata = malloc(insize, M_TEMP, M_NOWAIT);
        if (indata == NULL) {
            error = ENOMEM;
            goto bad;
        }
        error = copyin(ad->ad_in_data, indata, insize);
        if (error)
            goto bad;
    }
    if (ad->ad_id & ATH_DIAG_DYN) {
        /*
         * Allocate a buffer for the results (otherwise the HAL
         * returns a pointer to a buffer where we can read the
         * results).  Note that we depend on the HAL leaving this
         * pointer for us to use below in reclaiming the buffer;
         * may want to be more defensive.
         */
        outdata = malloc(outsize, M_TEMP, M_NOWAIT);
        if (outdata == NULL) {
            error = ENOMEM;
            goto bad;
        }
    }
    switch (id) {
    case DFS_SET_THRESH:
        if (insize < sizeof(HAL_PHYERR_PARAM)) {
            error = EINVAL;
            break;
        }
        pe = (HAL_PHYERR_PARAM *) indata;
        ath_hal_enabledfs(sc->sc_ah, pe);
        break;
    case DFS_GET_THRESH:
        memset(&peout, 0, sizeof(peout));
        outsize = sizeof(HAL_PHYERR_PARAM);
        ath_hal_getdfsthresh(sc->sc_ah, &peout);
        pe = (HAL_PHYERR_PARAM *) outdata;
        memcpy(pe, &peout, sizeof(*pe));
        break;
    default:
        error = EINVAL;
    }
    if (outsize < ad->ad_out_size)
        ad->ad_out_size = outsize;
    if (outdata && copyout(outdata, ad->ad_out_data, ad->ad_out_size))
        error = EFAULT;
bad:
    if ((ad->ad_id & ATH_DIAG_IN) && indata != NULL)
        free(indata, M_TEMP);
    if ((ad->ad_id & ATH_DIAG_DYN) && outdata != NULL)
        free(outdata, M_TEMP);
    return (error);
}
Example #4
0
File: dfs.c Project: jorneytu/wlan
int
dfs_control(ath_dev_t dev, u_int id,
                void *indata, u_int32_t insize,
                void *outdata, u_int32_t *outsize)
{
	struct ath_softc *sc = ATH_DEV_TO_SC(dev);
	int error = 0;
	u_int32_t *data = NULL;
	HAL_PHYERR_PARAM peout;
	struct dfsreq_nolinfo *nol;
	struct ath_dfs *dfs = sc->sc_dfs;
	struct dfs_ioctl_params *dfsparams;
        u_int32_t val=0;

	if (dfs == NULL) {
		error = -EINVAL;
                DFS_DPRINTK(sc, ATH_DEBUG_DFS, "%s DFS is null\n", __func__);
		goto bad;
	}

	switch (id) {
	case DFS_MUTE_TIME:
		if (insize < sizeof(u_int32_t) || !indata) {
			error = -EINVAL;
			break;
		}
		data = (u_int32_t *) indata;
		sc->sc_dfs->sc_dfstesttime = *data;
		sc->sc_dfs->sc_dfstesttime *= (1000); //convert sec into ms
		break;
	case DFS_SET_THRESH:
		if (insize < sizeof(HAL_PHYERR_PARAM) || !indata) {
			error = -EINVAL;
			break;
		}
		dfsparams = (struct dfs_ioctl_params *) indata;
		if (!dfs_set_thresholds(sc, DFS_PARAM_FIRPWR, dfsparams->dfs_firpwr))
			error = -EINVAL;
		if (!dfs_set_thresholds(sc, DFS_PARAM_RRSSI, dfsparams->dfs_rrssi))
			error = -EINVAL;
		if (!dfs_set_thresholds(sc, DFS_PARAM_HEIGHT, dfsparams->dfs_height))
			error = -EINVAL;
		if (!dfs_set_thresholds(sc, DFS_PARAM_PRSSI, dfsparams->dfs_prssi))
			error = -EINVAL;
		if (!dfs_set_thresholds(sc, DFS_PARAM_INBAND, dfsparams->dfs_inband))
			error = -EINVAL;
		/* 5413 speicfic */
		if (!dfs_set_thresholds(sc, DFS_PARAM_RELPWR, dfsparams->dfs_relpwr))
			error = -EINVAL;
		if (!dfs_set_thresholds(sc, DFS_PARAM_RELSTEP, dfsparams->dfs_relstep))
			error = -EINVAL;
		if (!dfs_set_thresholds(sc, DFS_PARAM_MAXLEN, dfsparams->dfs_maxlen))
			error = -EINVAL;
		break;
	case DFS_GET_THRESH:
		if (!outdata || !outsize || *outsize <sizeof(struct dfs_ioctl_params)) {
			error = -EINVAL;
			break;
		}
		*outsize = sizeof(struct dfs_ioctl_params);
		ath_hal_getdfsthresh(sc->sc_ah, &peout);
		dfsparams = (struct dfs_ioctl_params *) outdata;
		dfsparams->dfs_firpwr = peout.pe_firpwr;
		dfsparams->dfs_rrssi = peout.pe_rrssi;
		dfsparams->dfs_height = peout.pe_height;
		dfsparams->dfs_prssi = peout.pe_prssi;
		dfsparams->dfs_inband = peout.pe_inband;
		/* 5413 specific */
		dfsparams->dfs_relpwr = peout.pe_relpwr;
		dfsparams->dfs_relstep = peout.pe_relstep;
		dfsparams->dfs_maxlen = peout.pe_maxlen;
                break;
	case DFS_GET_USENOL:
		if (!outdata || !outsize || *outsize < sizeof(u_int32_t)) {
			error = -EINVAL;
			break;
		}
		*outsize = sizeof(u_int32_t);
		*((u_int32_t *)outdata) = dfs->dfs_rinfo.rn_use_nol;
		break;
	case DFS_SET_USENOL:
		if (insize < sizeof(u_int32_t) || !indata) {
			error = -EINVAL;
			break;
		}
		dfs->dfs_rinfo.rn_use_nol = *(u_int32_t *)indata;
		/* iwpriv markdfs in linux can do the same thing... */
		break;
        case DFS_SHOW_NOL:
                dfs_print_nol(sc);
                break;
	case DFS_BANGRADAR:
                if(sc->sc_nostabeacons)
                {
                        printk("No radar detection Enabled \n");
                        break;
                }
		dfs->dfs_bangradar = 1;     
                sc->sc_rtasksched = 1;
                OS_SET_TIMER(&sc->sc_dfs->sc_dfs_task_timer, 0);
		break;
	case DFS_RADARDETECTS:
		if (!outdata || !outsize || *outsize < sizeof(u_int32_t)) {
			error = -EINVAL;
			break;
		}
		*outsize = sizeof (u_int32_t);
		*((u_int32_t *)outdata) = dfs->ath_dfs_stats.num_radar_detects;
		break;
        case DFS_DISABLE_DETECT:
				/*zhaoyang1 transplant from 717*/
                /*zhaoyang modfiy for disable DFS PCAPVXN-85*/
				dfs->sc_dfs_isdfsregdomain = 0;
				/*zhaoyang modify end*/
                dfs->dfs_proc_phyerr &= ~DFS_RADAR_EN;
				printk("%s disable detects\n", __func__);
                break;
        case DFS_ENABLE_DETECT:
				/*zhaoyang modfiy for disable DFS PCAPVXN-85*/
				dfs->sc_dfs_isdfsregdomain = 1;
				/*zhaoyang modify end*/
				/*zhaoyang1 transplant end*/
				dfs->dfs_proc_phyerr |= DFS_RADAR_EN;
                printk("%s enable detects\n", __func__);
                break;
        case DFS_DISABLE_FFT:
#define AR_PHY_RADAR_0      0x9954      /* radar detection settings */
#define AR_PHY_RADAR_DISABLE_FFT 0x7FFFFFFF
                val = OS_REG_READ(sc->sc_ah, AR_PHY_RADAR_0);
                val &= AR_PHY_RADAR_DISABLE_FFT;
                OS_REG_WRITE(sc->sc_ah, AR_PHY_RADAR_0, val);
                val = OS_REG_READ(sc->sc_ah, AR_PHY_RADAR_0);
#undef AR_PHY_RADAR_0
#undef AR_PHY_RADAR_DISABLE_FFT
                printk("%s disable FFT val=0x%x \n", __func__, val);
                break;
        case DFS_ENABLE_FFT:
#define AR_PHY_RADAR_0      0x9954      /* radar detection settings */
#define AR_PHY_RADAR_ENABLE_FFT 0x80000000
                val = OS_REG_READ(sc->sc_ah, AR_PHY_RADAR_0);
                val |= AR_PHY_RADAR_ENABLE_FFT;
                OS_REG_WRITE(sc->sc_ah, AR_PHY_RADAR_0, val);
                val = OS_REG_READ(sc->sc_ah, AR_PHY_RADAR_0);
#undef AR_PHY_RADAR_ENABLE_FFT
#undef AR_PHY_RADAR_0            /* radar detection settings */
                printk("%s enable FFT val=0x%x \n", __func__, val);
                break;
        case DFS_SET_DEBUG_LEVEL:
		if (insize < sizeof(u_int32_t) || !indata) {
                        error = -EINVAL;
			break;
		}
		dfs_debug_level = *(u_int32_t *)indata;
		dfs_debug_level = (ATH_DEBUG_DFS << dfs_debug_level);
                printk("%s debug level now = 0x%x \n", __func__, dfs_debug_level);
                break;
	case DFS_GET_NOL:
		if (!outdata || !outsize || *outsize < sizeof(struct dfsreq_nolinfo)) {
			error = -EINVAL;
			break;
		}
		*outsize = sizeof(struct dfsreq_nolinfo);
		nol = (struct dfsreq_nolinfo *)outdata;
		dfs_get_nol(sc, (struct dfsreq_nolelem *)nol->dfs_nol, &nol->ic_nchans);
		break;
	case DFS_SET_NOL:
		if (insize < sizeof(struct dfsreq_nolinfo) || !indata) {
                        error = -EINVAL;
                        break;
                }
                nol = (struct dfsreq_nolinfo *) indata;
		dfs_set_nol(sc, (struct dfsreq_nolelem *)nol->dfs_nol, nol->ic_nchans);
		break;
	default:
		error = -EINVAL;
	}
bad:
	return error;
}