- struct ath_dfs {
-
u_int32_t dfsdomain; /* cur. DFS domain */
-
STAILQ_HEAD(,dfs_event) dfs_eventq; /* Q of free dfs event objects */
-
STAILQ_HEAD(,dfs_event) dfs_radarq; /* Q of radar events */
-
STAILQ_HEAD(,dfs_event) dfs_arq; /* Q of AR events */
-
struct dfs_state dfs_radar[DFS_NUM_RADAR_STATES]; /* Per-Channel Radar detector state */
-
struct dfs_filtertype *dfs_radarf[DFS_MAX_RADAR_TYPES]; /* One filter for each radar pulse type */
-
struct dfs_info dfs_rinfo; /* State variables for radar processing */
-
struct dfs_bin5radars *dfs_b5radars; /* array of bin5 radar events */
-
int8_t **dfs_radartable; /* mapping of radar durations to filter types */
-
struct dfs_nolelem *dfs_nol; /* Non occupancy list for radar */
-
HAL_PHYERR_PARAM dfs_defaultparams; /* Default phy params per radar state */
-
struct dfs_stats ath_dfs_stats; /* DFS related stats */
-
struct dfs_pulseline *pulses; /* pulse history */
-
struct dfs_event *events; /* Events structure */
-
-
u_int8_t sc_dfstest_ieeechan; /* IEEE channel number to return to after a dfs mute test */
-
u_int32_t sc_dfs_cac_time; /* Time to stay off chan during dfs test */
-
u_int32_t sc_dfstesttime; /* Time to stay off chan during dfs test */
-
os_timer_t sc_dfs_task_timer;/* dfs wait timer */
-
os_timer_t sc_dfswaittimer;/* dfs wait timer */
-
os_timer_t sc_dfstesttimer;/* dfs mute test timer */
-
u_int8_t dfs_bangradar;
-
int dur_multiplier;
-
};
-
这个结构体一方面是用来和sc进行关联,从而做到和其它驱动模块进行关联,方便调用。另一方面就是用来保存本身的一些信息;
dfsdomain:用来表示所在国家的区域;
dfs_eventq:空的event queue,用来与dfs_radarq和dfs_arq配套使用;
dfs_radar[DFS_NUM_RADAR_STATES]:用来保存和chan相关的信息;
*dfs_radarf[DFS_MAX_RADAR_TYPES]:用来存储filter type信息;
dfs_radartable:用来根据pulse dur来查找可能的radar filter;
dfs_defaultparams:用来存储和硬件寄存器相关的门限值数据,用来控制网卡的敏感度;
Pulses:用来存储pulse的历史记录,对pattern_type为1的有很大作用;
ath_dfs_stats:用来存储dfs的一些状态信息,最重要的就是检测到的雷达的数目;
- struct dfs_filtertype {
-
struct dfs_filter ft_filters[DFS_MAX_NUM_RADAR_FILTERS]; /* array of filters */
-
u_int32_t ft_filterdur; /* Duration of pulse which specifies filter type */
-
u_int32_t ft_numfilters; /* Num filters of this type */
-
u_int64_t ft_last_ts; /* Last timestamp this filtertype was used (in usecs) */
-
u_int32_t ft_mindur; /* min pulse duration to be considered
-
for this filter type */
-
u_int32_t ft_maxdur; /* max pulse duration to be consdiered
-
for this filter type */
-
u_int32_t ft_rssithresh; /* min rssi to be considered for this filter type */
-
u_int32_t ft_numpulses; /* Num pulses in each filter of this type */
-
u_int32_t ft_patterntype; /* fixed or variable pattern type */
-
u_int32_t ft_minpri; /* min pri to be considered for this type*/
-
u_int32_t ft_rssimargin; /* rssi threshold margin. In Turbo Mode HW reports rssi 3dB */
-
/* lower than in non TURBO mode. This will offset that diff.*/
-
};
这个结构体用来表示过滤器类型,ft_filters表示该过滤器类型中包含的过滤器, ft_filterdur用来区分过滤器类型, ft_numfilters表示该过滤器类型中包含的过滤器的数目(最大是10), ft_last_ts用来记录该过滤器类型的上次radar的时间, ft_mindur和ft_maxdur分别表示该过滤器类型的脉冲的最小和最大长度, ft_rssithresh表示该过滤器允许的最小接收信号强度, ft_numpulses表示burst中pulse的个数。ft_patterntype表示过滤器是属于固定PRI或者变动PRI. ft_minpri表示该过滤器允许的最小pri, ft_rssimargin表示该过滤器允许rssi误差(变化值)的最大值。
- struct dfs_filter {
-
struct dfs_delayline rf_dl; /* Delay line of pulses for this filter */
-
u_int32_t rf_numpulses; /* Number of pulses in the filter */
-
u_int32_t rf_minpri; /* min pri to be considered for this filter*/
-
u_int32_t rf_maxpri; /* max pri to be considered for this filter*/
-
u_int32_t rf_threshold; /* match filter output threshold for radar detect */
-
u_int32_t rf_filterlen; /* Length (in usecs) of the filter */
-
u_int32_t rf_patterntype; /* fixed or variable pattern type */
-
u_int32_t rf_mindur; /* Min duration for this radar filter */
-
u_int32_t rf_maxdur; /* Max duration for this radar filter */
-
u_int32_t rf_pulseid; /* Unique ID corresponding to the original filter ID */
-
};
该结构体是用来表示具体的过滤器(注意和过滤器类型相区分,过滤器类型中有多个过滤器)。
rf_dl存放该过滤器满足条件的pulse,大小请参考第6,7页的介绍; rf_numpulses表示该过滤器的脉冲串中脉冲数目;
rf_minpri和rf_maxpri分别表示该过滤器最小和做大脉冲间隔周期;
rf_threshold:匹配该过滤器的radar检测数目的门限值;
rf_filterlen:过滤器的长度(等于rf_numpulses* rf_maxpri);
rf_patterntype:固定pri(0)或者变动pri(2),值为1也属于固定但处理很特 殊,我们的6种radar 没有属于1的情况。
rf_mindur和rf_maxdur分别表示该过滤器允许的最小最大脉冲长度;
rf_pulseid:该过滤器的编号
- /* NB: The first element in the circular buffer is the oldest element */
-
-
struct dfs_delayline {
-
struct dfs_delayelem dl_elems[DFS_MAX_DL_SIZE]; /* Array of pulses in delay line */
-
u_int64_t dl_last_ts; /* Last timestamp the delay line was used (in usecs) */
-
u_int32_t dl_firstelem; /* Index of the first element */
-
u_int32_t dl_lastelem; /* Index of the last element */
-
u_int32_t dl_numelems; /* Number of elements in the delay line */
-
};
dfs_delayline用来对应dfs_filter中的rf_dl, dl_elems用来存放具体的pulse信息。其中需要注意的是dl_last_ts的值,它表示该过滤器的最后一个pulse的时间,但不一定是lastelem所对应的时间(有两种情况会更新最后时间但不加入到dl中)。
struct dfs_delayelem {
u_int32_t de_time; /* Current "filter" time for start of pulse in usecs*/
u_int8_t de_dur; /* Duration of pulse in usecs*/
u_int8_t de_rssi; /* rssi of pulse in dB*/
};
dfs_delayelem表示dfs_delayline中具体的元素,用来存放pulse信息;
de_time表示这个pulse和dl_last_ts之间的差值;
de_dur表示脉冲的长度
de_rssi表示该脉冲的接收信号强度。
初始化过程:
ath_dev_attach---àdfs_attach->dfs_init_radar_filters-àath_hal_getdfsradars
dfs_attach:主要完成dfs和sc的关联,eventq,radarq,arq的初始化动作,并为radar filter 和 radar table 分配空间。
dfs_init_radar_filters:当dfs domain没有被初始化或者和hal domain不同时就需要初始化radar filter tables.这个函数主要用来初始化radar filter 表同时初始化dfs_radartable,达到通过pulse dur来找到可能的filter(作用可以参考第5页)。
ath_hal_getdfsradars:这个函数会根据domain去取预先设好的几种pulse参数,并用这些数据区填充radar filter
处理过程:
①ath_rx_tasklet->ath_process_phyerr(struct ath_softc *sc, struct ath_desc *ds, u_int64_t fulltsf)
当产生硬件错误中断时,调用ath_process_phyerr,在这个函数中,fulltsf用来记录硬件中断时的time stamp,
主要的信息都保存在ath_desc中,当确定是radar detect产生的错误时,从ds中算出pulse的rssi, chaninfo 和dur等信息。然后从eventq中取出一个元素并赋值,当chaninfo的信息为(CHANNEL_2GHZ|CHANNEL_OFDM|CHANNEL_TURBO) 将event存放到arq中,但是我们的条件是不可能会出现上述情况,故不考虑。我们的情况是将event添加到radarq中,由后面的dfs_process_radarevent去处理。
②OS_TIMER_FUNC(ath_radar_task)->dfs_process_radarevent
OS_INIT_TIMER(sc->sc_osdev, &sc->sc_dfs->sc_dfs_task_timer, ath_radar_task, sc);
ath_rx_tasklet ->OS_SET_TIMER(&sc->sc_dfs->sc_dfs_task_timer, 0);
③ dfs_process_radarevent:从radarq中取出event,将其中的值赋给re,并立即将空间归还给eventq。