Esempio n. 1
0
File: dfs.c Progetto: 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;
}
Esempio n. 2
0
/*
 * This is called each time a channel change occurs, to (potentially) enable
 * the radar code.
 */
int dfs_radar_enable(struct ieee80211com *ic,
    struct ath_dfs_radar_tab_info *radar_info, int no_cac)
{
    int                                 is_ext_ch=IEEE80211_IS_CHAN_11N_HT40(ic->ic_curchan);
    int                                 is_fastclk = 0;
    //u_int32_t                        rfilt;
    struct ath_dfs                 *dfs=(struct ath_dfs *)ic->ic_dfs;
    struct ieee80211_channel *chan=ic->ic_curchan, *ext_ch = NULL;
  
	if (dfs == NULL) {
		DFS_DPRINTK(dfs, ATH_DEBUG_DFS, "%s: ic_dfs is NULL\n",
			__func__);
		return -EIO;
	}
	ic->ic_dfs_disable(ic, no_cac);

	/*
	 * Setting country code might change the DFS domain
	 * so initialize the DFS Radar filters
	 */
	dfs_init_radar_filters(ic, radar_info);
#if ATH_SUPPORT_DFS && ATH_SUPPORT_STA_DFS
	if ((ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_IBSS ||
                (ic->ic_opmode == IEEE80211_M_STA && ieee80211com_has_cap_ext(dfs->ic,IEEE80211_CEXT_STADFS)))) {
#else
	if ((ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_IBSS)) {
#endif
            	if (IEEE80211_IS_CHAN_DFS(chan)) {
			struct dfs_state *rs_pri=NULL, *rs_ext=NULL;
			u_int8_t index_pri, index_ext;
#ifdef ATH_ENABLE_AR
    dfs->dfs_proc_phyerr |= DFS_AR_EN;
#endif
    dfs->dfs_proc_phyerr |= DFS_RADAR_EN;
    //printk( "%s[%d]: ==== 0x%08x\n", __func__, __LINE__, dfs->dfs_proc_phyerr);


                   if (is_ext_ch) {
                       ext_ch = ieee80211_get_extchan(ic);
                   }
			dfs_reset_alldelaylines(dfs);

			rs_pri = dfs_getchanstate(dfs, &index_pri, 0);
			if (ext_ch) {
                            rs_ext = dfs_getchanstate(dfs, &index_ext, 1);
                   }
    			if (rs_pri != NULL && ((ext_ch==NULL)||(rs_ext != NULL))) {
				struct ath_dfs_phyerr_param pe;

				OS_MEMSET(&pe, '\0', sizeof(pe));

				if (index_pri != dfs->dfs_curchan_radindex)
					dfs_reset_alldelaylines(dfs);

				dfs->dfs_curchan_radindex = (int16_t) index_pri;
                                
                                if (rs_ext)
			            dfs->dfs_extchan_radindex = (int16_t) index_ext;

				ath_dfs_phyerr_param_copy(&pe,
				    &rs_pri->rs_param);
				DFS_DPRINTK(dfs, ATH_DEBUG_DFS3,
				    "%s: firpwr=%d, rssi=%d, height=%d, "
				    "prssi=%d, inband=%d, relpwr=%d, "
				    "relstep=%d, maxlen=%d\n",
				    __func__,
				    pe.pe_firpwr,
				    pe.pe_rrssi,
				    pe.pe_height,
				    pe.pe_prssi,
				    pe.pe_inband,
				    pe.pe_relpwr,
				    pe.pe_relstep,
				    pe.pe_maxlen
				    );

#if 0 //Not needed
				/* Disable strong signal fast antenna diversity */
				ath_hal_setcapability(ah, HAL_CAP_DIVERSITY,
						      HAL_CAP_STRONG_DIV, 1, NULL);
#endif
	                    ic->ic_dfs_enable(ic, &is_fastclk, &pe);
				DFS_DPRINTK(dfs, ATH_DEBUG_DFS, "Enabled radar detection on channel %d\n",
					chan->ic_freq);

                                dfs->dur_multiplier =  is_fastclk ? DFS_FAST_CLOCK_MULTIPLIER : DFS_NO_FAST_CLOCK_MULTIPLIER;
                    	DFS_DPRINTK(dfs, ATH_DEBUG_DFS3,
			"%s: duration multiplier is %d\n", __func__, dfs->dur_multiplier);

			} else
				DFS_DPRINTK(dfs, ATH_DEBUG_DFS, "%s: No more radar states left\n",
					__func__);
		} 
	} 
	return 0;
}

int
dfs_control(struct ieee80211com *ic, u_int id,
                void *indata, u_int32_t insize,
                void *outdata, u_int32_t *outsize)
{
	int error = 0;
	struct ath_dfs_phyerr_param peout;
	struct ath_dfs *dfs = (struct ath_dfs *)ic->ic_dfs;
	struct dfs_ioctl_params *dfsparams;
    u_int32_t val=0;
#ifndef ATH_DFS_RADAR_DETECTION_ONLY
    struct dfsreq_nolinfo *nol;
    u_int32_t *data = NULL;
#endif /* ATH_DFS_RADAR_DETECTION_ONLY */
    int i;

	if (dfs == NULL) {
                DFS_DPRINTK(dfs, ATH_DEBUG_DFS1, "%s DFS is null\n", __func__);
                /* Enable/Disable DFS can be done prior to attach, So handle here */
	switch (id) {
        case DFS_DISABLE_DETECT:
                ic->ic_dfs_state.ignore_dfs = 1;
                DFS_PRINTK("%s enable detects, ignore_dfs %d\n", 
                    __func__,
		   ic->ic_dfs_state.ignore_dfs ? 1:0);
                break;
        case DFS_ENABLE_DETECT:
                ic->ic_dfs_state.ignore_dfs = 0;
                DFS_PRINTK("%s enable detects, ignore_dfs %d\n", 
                    __func__,
		    ic->ic_dfs_state.ignore_dfs ? 1:0);
                break;
        default:
            error = -EINVAL;
            break;
       }
		goto bad;
	}

      //printk("%s[%d] id =%d\n", __func__, __LINE__, id);
	switch (id) {
	case DFS_SET_THRESH:
		if (insize < sizeof(struct dfs_ioctl_params) || !indata) {
			DFS_DPRINTK(dfs, ATH_DEBUG_DFS1,
			    "%s: insize=%d, expected=%d bytes, indata=%p\n",
			    __func__, insize, sizeof(struct dfs_ioctl_params),
			    indata);
			error = -EINVAL;
			break;
		}
		dfsparams = (struct dfs_ioctl_params *) indata;
		if (!dfs_set_thresholds(ic, DFS_PARAM_FIRPWR, dfsparams->dfs_firpwr))
			error = -EINVAL;
		if (!dfs_set_thresholds(ic, DFS_PARAM_RRSSI, dfsparams->dfs_rrssi))
			error = -EINVAL;
		if (!dfs_set_thresholds(ic, DFS_PARAM_HEIGHT, dfsparams->dfs_height))
			error = -EINVAL;
		if (!dfs_set_thresholds(ic, DFS_PARAM_PRSSI, dfsparams->dfs_prssi))
			error = -EINVAL;
		if (!dfs_set_thresholds(ic, DFS_PARAM_INBAND, dfsparams->dfs_inband))
			error = -EINVAL;
		/* 5413 speicfic */
		if (!dfs_set_thresholds(ic, DFS_PARAM_RELPWR, dfsparams->dfs_relpwr))
			error = -EINVAL;
		if (!dfs_set_thresholds(ic, DFS_PARAM_RELSTEP, dfsparams->dfs_relstep))
			error = -EINVAL;
		if (!dfs_set_thresholds(ic, 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);
		dfsparams = (struct dfs_ioctl_params *) outdata;

		/*
		 * Fetch the DFS thresholds using the internal representation.
		 */
		(void) dfs_get_thresholds(ic, &peout);

		/*
		 * Convert them to the dfs IOCTL representation.
		 */
		ath_dfs_dfsparam_to_ioctlparam(&peout, dfsparams);
                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:
                dfs->dfs_proc_phyerr &= ~DFS_RADAR_EN;
                dfs->ic->ic_dfs_state.ignore_dfs = 1;
                DFS_PRINTK("%s enable detects, ignore_dfs %d\n", 
                    __func__,
		    dfs->ic->ic_dfs_state.ignore_dfs ? 1:0);
                break;
        case DFS_ENABLE_DETECT:
		dfs->dfs_proc_phyerr |= DFS_RADAR_EN;
                dfs->ic->ic_dfs_state.ignore_dfs = 0;
                DFS_PRINTK("%s enable detects, ignore_dfs %d\n", 
                    __func__,
		    dfs->ic->ic_dfs_state.ignore_dfs ? 1:0);
                break;
        case DFS_DISABLE_FFT:
                //UMACDFS: TODO: val = ath_hal_dfs_config_fft(sc->sc_ah, false);
                DFS_PRINTK("%s TODO disable FFT val=0x%x \n", __func__, val);
                break;
        case DFS_ENABLE_FFT:
                //UMACDFS TODO: val = ath_hal_dfs_config_fft(sc->sc_ah, true);
                DFS_PRINTK("%s TODO 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->dfs_debug_mask= *(u_int32_t *)indata;
		DFS_PRINTK("%s debug level now = 0x%x \n",
		    __func__,
		    dfs->dfs_debug_mask);
                if (dfs->dfs_debug_mask & ATH_DEBUG_DFS3) {
                    /* Enable debug Radar Event */
                    dfs->dfs_event_log_on = 1;
                } else {
                    dfs->dfs_event_log_on = 0;
                }
                break;
        case DFS_SET_FALSE_RSSI_THRES:
		if (insize < sizeof(u_int32_t) || !indata) {
			error = -EINVAL;
			break;
		}
		dfs->ath_dfs_false_rssi_thres= *(u_int32_t *)indata;
		DFS_PRINTK("%s false RSSI threshold now = 0x%x \n",
		    __func__,
		    dfs->ath_dfs_false_rssi_thres);
                break;
        case DFS_SET_PEAK_MAG:
		if (insize < sizeof(u_int32_t) || !indata) {
			error = -EINVAL;
			break;
		}
		dfs->ath_dfs_peak_mag= *(u_int32_t *)indata;
		DFS_PRINTK("%s peak_mag now = 0x%x \n",
		    __func__,
		    dfs->ath_dfs_peak_mag);
                break;
	case DFS_GET_CAC_VALID_TIME:
		if (!outdata || !outsize || *outsize < sizeof(u_int32_t)) {
			error = -EINVAL;
			break;
		}
		*outsize = sizeof (u_int32_t);
		*((u_int32_t *)outdata) = dfs->ic->ic_dfs_state.cac_valid_time;
		break;
        case DFS_SET_CAC_VALID_TIME:
		if (insize < sizeof(u_int32_t) || !indata) {
			error = -EINVAL;
			break;
		}
		dfs->ic->ic_dfs_state.cac_valid_time = *(u_int32_t *)indata;
		DFS_PRINTK("%s dfs timeout = %d \n",
		    __func__,
		    dfs->ic->ic_dfs_state.cac_valid_time);
                break;
        case DFS_IGNORE_CAC:
		if (insize < sizeof(u_int32_t) || !indata) {
			error = -EINVAL;
			break;
		}
             if (*(u_int32_t *)indata) {
                 dfs->ic->ic_dfs_state.ignore_cac= 1;
             } else {
                 dfs->ic->ic_dfs_state.ignore_cac= 0;
             }
		DFS_PRINTK("%s ignore cac = 0x%x \n",
		    __func__,
		    dfs->ic->ic_dfs_state.ignore_cac);
                break;
        case DFS_SET_NOL_TIMEOUT:
		if (insize < sizeof(u_int32_t) || !indata) {
			error = -EINVAL;
			break;
		}
             if (*(int *)indata) {
                 dfs->ath_dfs_nol_timeout= *(int *)indata;
             } else {
                 dfs->ath_dfs_nol_timeout= DFS_NOL_TIMEOUT_S;
             }
		DFS_PRINTK("%s nol timeout = %d sec \n",
		    __func__,
		    dfs->ath_dfs_nol_timeout);
                break;
#ifndef ATH_DFS_RADAR_DETECTION_ONLY
    case DFS_MUTE_TIME:
        if (insize < sizeof(u_int32_t) || !indata) {
            error = -EINVAL;
            break;
        }
        data = (u_int32_t *) indata;
        dfs->ath_dfstesttime = *data;
        dfs->ath_dfstesttime *= (1000); //convert sec into ms
        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;
                 printk("%s:#Phyerr=%d, #false detect=%d, #queued=%d\n", __func__,dfs->dfs_phyerr_count, dfs->dfs_phyerr_reject_count, dfs->dfs_phyerr_queued_count);
                 printk("%s:dfs_phyerr_freq_min=%d, dfs_phyerr_freq_max=%d\n", __func__,dfs->dfs_phyerr_freq_min, dfs->dfs_phyerr_freq_max);
                 printk("%s:Total radar events detected=%d, entries in the radar queue follows:\n",  __func__,dfs->dfs_event_log_count);
                 for (i = 0; (i < DFS_EVENT_LOG_SIZE) && (i < dfs->dfs_event_log_count); i++) {
                         //DFS_DPRINTK(sc, ATH_DEBUG_DFS,"ts=%llu diff_ts=%u rssi=%u dur=%u\n", dfs->radar_log[i].ts, dfs->radar_log[i].diff_ts, dfs->radar_log[i].rssi, dfs->radar_log[i].dur);
                         printk("ts=%llu diff_ts=%u rssi=%u dur=%u\n", dfs->radar_log[i].ts, dfs->radar_log[i].diff_ts, dfs->radar_log[i].rssi, dfs->radar_log[i].dur);
                 }
                 dfs->dfs_event_log_count     = 0;
                 dfs->dfs_phyerr_count        = 0;
                 dfs->dfs_phyerr_reject_count = 0;
                 dfs->dfs_phyerr_queued_count = 0;
                dfs->dfs_phyerr_freq_min     = 0x7fffffff;
                dfs->dfs_phyerr_freq_max     = 0;
		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_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(dfs, (struct dfsreq_nolelem *)nol->dfs_nol, &nol->ic_nchans);
             dfs_print_nol(dfs);
		break;
	case DFS_SET_NOL:
		if (insize < sizeof(struct dfsreq_nolinfo) || !indata) {
                        error = -EINVAL;
                        break;
                }
                nol = (struct dfsreq_nolinfo *) indata;
		dfs_set_nol(dfs, (struct dfsreq_nolelem *)nol->dfs_nol, nol->ic_nchans);
		break;

    case DFS_SHOW_NOL:
        dfs_print_nol(dfs);
        break;
#if ATH_SUPPORT_DFS && ATH_SUPPORT_STA_DFS
    case DFS_SHOW_NOLHISTORY:
        dfs_print_nolhistory(ic,dfs);
        break;
#endif
    case DFS_BANGRADAR:
 #if 0 //MERGE_TBD       
        if(sc->sc_nostabeacons)
        {
            printk("No radar detection Enabled \n");
            break;
        }
#endif        
        dfs->dfs_bangradar = 1;     
        dfs->ath_radar_tasksched = 1;
        OS_SET_TIMER(&dfs->ath_dfs_task_timer, 0);
        break;
#endif /* ATH_DFS_RADAR_DETECTION_ONLY */
	default:
		error = -EINVAL;
	}
bad:
	return error;
}
Esempio n. 3
0
int
dfs_control(struct ieee80211com *ic, u_int id,
                void *indata, u_int32_t insize,
                void *outdata, u_int32_t *outsize)
{
   int error = 0;
   struct ath_dfs_phyerr_param peout;
   struct ath_dfs *dfs = (struct ath_dfs *)ic->ic_dfs;
   struct dfs_ioctl_params *dfsparams;
    u_int32_t val=0;
#ifndef ATH_DFS_RADAR_DETECTION_ONLY
    struct dfsreq_nolinfo *nol;
    u_int32_t *data = NULL;
#endif /* ATH_DFS_RADAR_DETECTION_ONLY */
    int i;

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


   switch (id) {
   case DFS_SET_THRESH:
      if (insize < sizeof(struct dfs_ioctl_params) || !indata) {
         DFS_DPRINTK(dfs, ATH_DEBUG_DFS1,
             "%s: insize=%d, expected=%zu bytes, indata=%p\n",
             __func__, insize, sizeof(struct dfs_ioctl_params),
             indata);
         error = -EINVAL;
         break;
      }
      dfsparams = (struct dfs_ioctl_params *) indata;
      if (!dfs_set_thresholds(ic, DFS_PARAM_FIRPWR, dfsparams->dfs_firpwr))
         error = -EINVAL;
      if (!dfs_set_thresholds(ic, DFS_PARAM_RRSSI, dfsparams->dfs_rrssi))
         error = -EINVAL;
      if (!dfs_set_thresholds(ic, DFS_PARAM_HEIGHT, dfsparams->dfs_height))
         error = -EINVAL;
      if (!dfs_set_thresholds(ic, DFS_PARAM_PRSSI, dfsparams->dfs_prssi))
         error = -EINVAL;
      if (!dfs_set_thresholds(ic, DFS_PARAM_INBAND, dfsparams->dfs_inband))
         error = -EINVAL;
      /* 5413 speicfic */
      if (!dfs_set_thresholds(ic, DFS_PARAM_RELPWR, dfsparams->dfs_relpwr))
         error = -EINVAL;
      if (!dfs_set_thresholds(ic, DFS_PARAM_RELSTEP, dfsparams->dfs_relstep))
         error = -EINVAL;
      if (!dfs_set_thresholds(ic, 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);
      dfsparams = (struct dfs_ioctl_params *) outdata;

      /*
       * Fetch the DFS thresholds using the internal representation.
       */
      (void) dfs_get_thresholds(ic, &peout);

      /*
       * Convert them to the dfs IOCTL representation.
       */
      ath_dfs_dfsparam_to_ioctlparam(&peout, dfsparams);
                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:
                dfs->dfs_proc_phyerr &= ~DFS_RADAR_EN;
                dfs->ic->ic_dfs_state.ignore_dfs = 1;
                DFS_PRINTK("%s enable detects, ignore_dfs %d\n",
                    __func__,
          dfs->ic->ic_dfs_state.ignore_dfs);
                break;
        case DFS_ENABLE_DETECT:
      dfs->dfs_proc_phyerr |= DFS_RADAR_EN;
                dfs->ic->ic_dfs_state.ignore_dfs = 0;
                DFS_PRINTK("%s enable detects, ignore_dfs %d\n",
                    __func__,
          dfs->ic->ic_dfs_state.ignore_dfs);
                break;
        case DFS_DISABLE_FFT:
                //UMACDFS: TODO: val = ath_hal_dfs_config_fft(sc->sc_ah, false);
                DFS_PRINTK("%s TODO disable FFT val=0x%x \n", __func__, val);
                break;
        case DFS_ENABLE_FFT:
                //UMACDFS TODO: val = ath_hal_dfs_config_fft(sc->sc_ah, true);
                DFS_PRINTK("%s TODO 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->dfs_debug_mask= *(u_int32_t *)indata;
      DFS_PRINTK("%s debug level now = 0x%x \n",
          __func__,
          dfs->dfs_debug_mask);
                if (dfs->dfs_debug_mask & ATH_DEBUG_DFS3) {
                    /* Enable debug Radar Event */
                    dfs->dfs_event_log_on = 1;
                } else {
                    dfs->dfs_event_log_on = 0;
                }
                break;
        case DFS_SET_FALSE_RSSI_THRES:
      if (insize < sizeof(u_int32_t) || !indata) {
         error = -EINVAL;
         break;
      }
      dfs->ath_dfs_false_rssi_thres= *(u_int32_t *)indata;
      DFS_PRINTK("%s false RSSI threshold now = 0x%x \n",
          __func__,
          dfs->ath_dfs_false_rssi_thres);
                break;
        case DFS_SET_PEAK_MAG:
      if (insize < sizeof(u_int32_t) || !indata) {
         error = -EINVAL;
         break;
      }
      dfs->ath_dfs_peak_mag= *(u_int32_t *)indata;
      DFS_PRINTK("%s peak_mag now = 0x%x \n",
          __func__,
          dfs->ath_dfs_peak_mag);
                break;
        case DFS_IGNORE_CAC:
      if (insize < sizeof(u_int32_t) || !indata) {
         error = -EINVAL;
         break;
      }
             if (*(u_int32_t *)indata) {
                 dfs->ic->ic_dfs_state.ignore_cac= 1;
             } else {
                 dfs->ic->ic_dfs_state.ignore_cac= 0;
             }
      DFS_PRINTK("%s ignore cac = 0x%x \n",
          __func__,
          dfs->ic->ic_dfs_state.ignore_cac);
                break;
        case DFS_SET_NOL_TIMEOUT:
      if (insize < sizeof(u_int32_t) || !indata) {
         error = -EINVAL;
         break;
      }
             if (*(int *)indata) {
                 dfs->ath_dfs_nol_timeout= *(int *)indata;
             } else {
                 dfs->ath_dfs_nol_timeout= DFS_NOL_TIMEOUT_S;
             }
      DFS_PRINTK("%s nol timeout = %d sec \n",
          __func__,
          dfs->ath_dfs_nol_timeout);
                break;
#ifndef ATH_DFS_RADAR_DETECTION_ONLY
    case DFS_MUTE_TIME:
        if (insize < sizeof(u_int32_t) || !indata) {
            error = -EINVAL;
            break;
        }
        data = (u_int32_t *) indata;
        dfs->ath_dfstesttime = *data;
        dfs->ath_dfstesttime *= (1000); //convert sec into ms
        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;



                 for (i = 0; (i < DFS_EVENT_LOG_SIZE) && (i < dfs->dfs_event_log_count); i++) {
                         //DFS_DPRINTK(sc, ATH_DEBUG_DFS,"ts=%llu diff_ts=%u rssi=%u dur=%u\n", dfs->radar_log[i].ts, dfs->radar_log[i].diff_ts, dfs->radar_log[i].rssi, dfs->radar_log[i].dur);

                 }
                 dfs->dfs_event_log_count     = 0;
                 dfs->dfs_phyerr_count        = 0;
                 dfs->dfs_phyerr_reject_count = 0;
                 dfs->dfs_phyerr_queued_count = 0;
                dfs->dfs_phyerr_freq_min     = 0x7fffffff;
                dfs->dfs_phyerr_freq_max     = 0;
      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_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(dfs, (struct dfsreq_nolelem *)nol->dfs_nol, &nol->ic_nchans);
             dfs_print_nol(dfs);
      break;
   case DFS_SET_NOL:
      if (insize < sizeof(struct dfsreq_nolinfo) || !indata) {
                        error = -EINVAL;
                        break;
                }
                nol = (struct dfsreq_nolinfo *) indata;
      dfs_set_nol(dfs, (struct dfsreq_nolelem *)nol->dfs_nol, nol->ic_nchans);
      break;

    case DFS_SHOW_NOL:
        dfs_print_nol(dfs);
        break;
    case DFS_BANGRADAR:
 #if 0 //MERGE_TBD
        if(sc->sc_nostabeacons)
        {
            printk("No radar detection Enabled \n");
            break;
        }
#endif
        dfs->dfs_bangradar = 1;
        dfs->ath_radar_tasksched = 1;
        OS_SET_TIMER(&dfs->ath_dfs_task_timer, 0);
        break;
#endif /* ATH_DFS_RADAR_DETECTION_ONLY */
   default:
      error = -EINVAL;
   }
bad:
   return error;
}