⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 if_ath_radar.c.svn-base

📁 最新之atheros芯片driver source code, 基于linux操作系统,內含atheros芯片HAL全部代码
💻 SVN-BASE
📖 第 1 页 / 共 4 页
字号:
		t0_min = (pattern->min_rep_int * 			  pattern->min_evts) < t1 ?		    t1 - (pattern->min_rep_int * 			  pattern->min_evts) : 0;		/* this max formula is to stop when we exceed maximum time		 * period for the pattern.  It's the oldest possible TSF that		 * could match. */		t0_max = (pattern->max_rep_int * 			  pattern->max_evts) < t1 ?		    t1 - (pattern->max_rep_int * 			  pattern->max_evts) : 0;		/* we directly start with the timestamp before t1 */		pulse = pulse_prev(last_pulse);		/* initial values for t_min, t_max */		t_min = pattern->max_rep_int < t1 ? 			t1 - pattern->max_rep_int : 0;		t_max = pattern->min_rep_int < t1 ? 			t1 - pattern->min_rep_int : 0;		last_tsf = t1;		last_seen_period = 0;		sum_periods = 0;		matched = 0;		noise = 0;		missed = 0;		partial_miss = 0;		mean_period = 0;		adjusted_max_rep_int = 			pattern->max_rep_int;		adjusted_min_rep_int = 			pattern->min_rep_int;		for (;;) {			if (mean_period && pattern->dyn_ints) {				u_int32_t fuzz_pct = pattern->fuzz_pct;				adjusted_max_rep_int = 					MIN(nofloat_pct(mean_period, fuzz_pct), 					    pattern->max_rep_int);				adjusted_min_rep_int = 					MAX(nofloat_pct(mean_period, -fuzz_pct),					    pattern->min_rep_int);			}			else {				adjusted_max_rep_int = pattern->max_rep_int;				adjusted_min_rep_int = pattern->min_rep_int;			}			/* check if we are at the end of the list */			if (&pulse->list == &sc->sc_rp_list) 				break;			if (!pulse->rp_allocated)				break;			/* Do not go too far... this is an optimization to not			 * keep checking after we hit maximum time span for the			 * pattern. */			if (pulse->rp_tsf < t0_max) {				DPRINTF(sc, ATH_DEBUG_DOTHFILTVBSE,					"%s: %s matching stopped (pulse->rp_tsf"					" < t0_max).  t1=%10llu t0_max=%10llu "					"t_min=%10llu t_max=%10llu matched=%u "					"missed=%u\n", SC_DEV_NAME(sc),					pattern->name, t1, t0_max, 					t_min, t_max, matched, missed);				break;			}			/* if we missed more than specified number of pulses,			 * we stop searching */			if (partial_miss > 			    pattern->max_consecutive_missing) {				DPRINTF(sc, ATH_DEBUG_DOTHFILTVBSE, 					"%s: %s matching stopped (too many "					"consecutive pulses missing). %d>%d "					"matched=%u. missed=%u.\n",					SC_DEV_NAME(sc), pattern->name,					partial_miss, 					pattern->max_consecutive_missing, 					matched, missed);				break;			}			new_period = (u_int64_t) 				(last_tsf && last_tsf > pulse->rp_tsf) ? 					last_tsf - pulse->rp_tsf : 0;			if (pulse->rp_tsf > t_max) {				DPRINTF(sc, ATH_DEBUG_DOTHFILTVBSE, 					"%s: %-17s [%2d] %5s [**:**] tsf: "					"%10llu [range: %5llu-%5llu].  width: "					"%3d. period: %4llu. last_period: %4llu"					". mean_period: %4llu. last_tsf: %10llu"					".\n",					SC_DEV_NAME(sc),					pattern->name,					pulse->rp_index,					"noise",					(u_int64_t)pulse->rp_tsf,					(u_int64_t)t_min,					(u_int64_t)t_max, 					(u_int8_t)pulse->rp_width, 					(u_int64_t)new_period, 					(u_int64_t)last_seen_period, 					(u_int64_t)mean_period, 					(u_int64_t)last_tsf);				/* this event is noise, ignore it */				pulse = pulse_prev(pulse);				noise++;			} else if (pulse->rp_tsf >= t_min) {				/* we found a match */				matched++;				if (partial_miss)					new_period /= (partial_miss + 1);				missed += partial_miss;				partial_miss = 0;				sum_periods += new_period;				mean_period = matched ? 						(sum_periods / matched) : 						0;				if (mean_period && 				    pattern->dyn_ints &&				    (mean_period > 				     pattern->max_rep_int || 				     mean_period < 				     pattern->min_rep_int)) {					DPRINTF(sc, ATH_DEBUG_DOTHFILTVBSE,						"%s: %s mean period deviated "						"from original range [period: "						"%4u, range: %4u-%4u]\n",						SC_DEV_NAME(sc),						pattern->name, 						mean_period, 						pattern->min_rep_int, 						pattern->max_rep_int);					break;				}				/* Remember we are scanning backwards... */				DPRINTF(sc, ATH_DEBUG_DOTHFILTVBSE,					"%s: %-17s [%2d] %5s [%2d:%-2d] tsf: "					"%10llu [range: %5llu-%5llu].  width: "					"%3d. period: %4llu. last_period: %4llu"					". mean_period: %4llu. last_tsf: %10llu"					".\n",					SC_DEV_NAME(sc),					pattern->name,					pulse->rp_index,					"match",					MAX(matched + missed + partial_miss - 1,					    0),					(matched + missed + partial_miss),					(u_int64_t)pulse->rp_tsf,					(u_int64_t)t_min,					(u_int64_t)t_max, 					(u_int8_t)pulse->rp_width, 					(u_int64_t)new_period, 					(u_int64_t)last_seen_period, 					(u_int64_t)mean_period, 					(u_int64_t)last_tsf);				/* record tsf and period */				last_seen_period = new_period;				last_tsf = pulse->rp_tsf;				/* advance to next pulse */				pulse = pulse_prev(pulse);				/* update bounds */				t_min = adjusted_max_rep_int < last_tsf ? 					last_tsf - adjusted_max_rep_int : 					0;				t_max = adjusted_min_rep_int < last_tsf ? 					last_tsf - adjusted_min_rep_int : 					0;			} else {				partial_miss++;				/* if we missed more than specified number of 				 * pulses, we stop searching */				if ((missed + partial_miss) > 				    pattern->max_missing) {					DPRINTF(sc, ATH_DEBUG_DOTHFILTVBSE,						"%s: %s matching stopped (too "						"many total pulses missing). "						"%d>%d  matched=%u. missed=%u."						"\n",						SC_DEV_NAME(sc),						pattern->name, 						missed, 						pattern->max_missing, 						matched, 						missed);					break;				}				/* Default mean period to approximate center 				 * of range.  Remember we are scanning 				 * backwards... */				DPRINTF(sc, ATH_DEBUG_DOTHFILTVBSE,					"%s: %-17s [**] %5s [%2d:%-2d] tsf: "					"(missing) [range: %5llu-%5llu].  "					"width: ***. period: ****. last_period:"					" %4llu. mean_period: %4llu. last_tsf: "					"%10llu.\n",					SC_DEV_NAME(sc),					pattern->name,					"missed",					MAX(matched + missed + partial_miss - 1, 					    0),					(matched + missed + partial_miss), 					(u_int64_t)t_min, 					(u_int64_t)t_max, 					(u_int64_t)last_seen_period, 					(u_int64_t)mean_period, 					(u_int64_t)last_tsf);				/* update bounds */				t_min = adjusted_max_rep_int < t_min ? 					t_min - adjusted_max_rep_int : 					0;				t_max = adjusted_min_rep_int < t_max ? 					t_max - adjusted_min_rep_int : 					0;			}		}		/* print counters for this PRF */		if (matched > 1) {			int compare_result = CR_FALLTHROUGH;			int match_result = MR_MATCH;			/* we add one to the matched since we counted only the 			 * time differences */			/* matched++; not sure... */			/* check if PRF counters match a known radar, if we are			 * confident enought */			if (MR_MATCH == (match_result = match_radar(					matched,					missed,					mean_period,					noise,					pattern->min_evts,					pattern->max_evts,					pattern->min_rep_int,					pattern->max_rep_int,					pattern->min_pulse,					pattern->max_missing))) {				compare_result = (NULL == best_pattern) ? CR_NULL : 					compare_radar_matches(						matched,						missed, 						mean_period, 						noise,						pattern->min_evts,						pattern->max_evts,						pattern->min_rep_int,						pattern->max_rep_int,						pattern->min_pulse,						pattern->max_missing,						pattern->match_midpoint,						best_matched, 						best_missed, 						best_pri, 						best_noise,						best_pattern->min_evts,						best_pattern->max_evts,						best_pattern->min_rep_int,						best_pattern->max_rep_int,						best_pattern->min_pulse,						best_pattern->max_missing,						best_pattern->match_midpoint);			}			if (DFLAG_ISSET(sc, ATH_DEBUG_DOTHFILT)) {				DPRINTF(sc, ATH_DEBUG_DOTHFILT,					"%s: [%02d] %13s: %-17s [match=%2u {%2u"					"..%2u},missed=%2u/%2u,dur=%2d {%2u.."					"%2u},noise=%2u/%2u,cr:%d]\n",					SC_DEV_NAME(sc),					last_pulse->rp_index,					compare_result > CR_FALLTHROUGH ? 						"NEW-BEST" : 						get_match_result_desc(match_result),					pattern->name,					matched, 					pattern->min_pulse, 					pattern->max_evts,					missed, 					pattern->max_missing,					matched + missed, 					pattern->min_evts, 					pattern->max_evts, 					noise, 					matched + noise,					compare_result);			}			if (compare_result > CR_FALLTHROUGH) {				best_matched = matched;				best_missed = missed;				best_index = i;				best_pattern = pattern;				best_pri = mean_period;				best_noise = noise;				best_cr = compare_result;			}			else if (compare_result <= CR_FALLTHROUGH) {				DPRINTF(sc, ATH_DEBUG_DOTHFILTVBSE,					"%s: %s match not better than best so "					"far.  cr: %d matched: %d  missed: "					"%d min_evts: %d\n",					SC_DEV_NAME(sc),					pattern->name, 					compare_result,					matched, 					missed, 					pattern->min_evts);			}		}	}	if (-1 != best_index) {		DPRINTF(sc, ATH_DEBUG_DOTHFILTVBSE,			"%s: [%02d] %10s: %-17s [match=%2u {%2u..%2u},missed="			"%2u/%2u,dur=%2d {%2u..%2u},noise=%2u/%2u,cr=%2d] "			"RI=%-9u RF=%-4u\n",			SC_DEV_NAME(sc),			last_pulse->rp_index,			"BEST/PULSE",			best_pattern->name,			best_matched, 			best_pattern->min_pulse, 			best_pattern->max_evts,			best_missed, 			best_pattern->max_missing,			(best_matched + best_missed),			best_pattern->min_evts,			best_pattern->max_evts, 			best_noise, 			(best_matched + best_noise), 			best_cr, 			best_pri, 			interval_to_frequency(best_pri));		if (index)			*index = best_index;		if (pri)			*pri = best_pri;		if (matching_pulses)			*matching_pulses = best_matched;		if (noise_pulses)			*noise_pulses = best_noise;		if (missed_pulses)			*missed_pulses = best_missed;	}	return (-1 != best_index) ? AH_TRUE : AH_FALSE;}#ifdef AR_DEBUGstatic u_int32_t interval_to_frequency(u_int32_t interval){	/* Calculate BRI from PRI */	u_int32_t frequency = interval ? (1000000 / interval) : 0;	/* Round to nearest multiple of 50 */	return frequency + ((frequency % 50) >= 25 ? 50 : 0) - (frequency % 50);}#endif /* AR_DEBUG */#ifdef ATH_RADAR_LONG_PULSEstatic const char *get_longpulse_desc(int lp){	switch (lp) {	case  8:  return "FCC [5,  8 pulses]";	case  9:  return "FCC [5,  9 pulses]";	case 10:  return "FCC [5, 10 pulses]";	case 11:  return "FCC [5, 11 pulses]";	case 12:  return "FCC [5, 12 pulses]";	case 13:  return "FCC [5, 13 pulses]";	case 14:  return "FCC [5, 14 pulses]";	case 15:  return "FCC [5, 15 pulses]";	case 16:  return "FCC [5, 16 pulses]";	case 17:  return "FCC [5, 17 pulses]";	case 18:  return "FCC [5, 18 pulses]";	case 19:  return "FCC [5, 19 pulses]";	case 20:  return "FCC [5, 20 pulses]";	default:  return "FCC [5, invalid pulses]";	}}#endif /* #ifdef ATH_RADAR_LONG_PULSE */static HAL_BOOL rp_analyze(struct ath_softc *sc){	HAL_BOOL radar = 0;	struct ath_rp *pulse;	/* Best short pulse match */	int32_t best_index = -1;	u_int32_t best_pri = 0;	u_int32_t best_matched = 0;	u_int32_t best_missed = 0;	u_int32_t best_noise = 0;	int32_t best_cr = 0;#ifdef ATH_RADAR_LONG_PULSE	/* Best long pulse match */	u_int32_t best_lp_bc	  = 0;	u_int32_t best_lp_matched = 0;	u_int32_t best_lp_missed  = 0;	u_int32_t best_lp_noise   = 0;	u_int32_t best_lp_pulses  = 0;#endif /* #ifdef ATH_RADAR_LONG_PULSE */	u_int32_t pass = 0;	struct radar_pattern_specification *best_pattern = NULL;	/* start the analysis by the last pulse since it might speed up	 * things and then move backward for all non-analyzed pulses.	 * For debugging ONLY - we continue to run this scan after radar is 	 * detected, processing all pulses... even when they come in after an 	 * iteration of all pulses that were present when this function was 	 * invoked.  This can happen at some radar waveforms where we will 	 * match the first few pulses and then the rest of the burst will come 	 * in, but never be analyzed.	 */	while (pulse_tail(sc)->rp_allocated && 	       !pulse_tail(sc)->rp_analyzed && 	       (AH_FALSE == radar || 		(DFLAG_ISSET(sc, ATH_DEBUG_DOTHFILT) && ++pass <= 3))) {		list_for_each_entry_reverse(pulse, &sc->sc_rp_list, list) {			if (!pulse->rp_allocated) 				break;			if (pulse->rp_analyzed)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -