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

📄 if_ath_radar.c.svn-base

📁 最新之atheros芯片driver source code, 基于linux操作系统,內含atheros芯片HAL全部代码
💻 SVN-BASE
📖 第 1 页 / 共 4 页
字号:
				break;			/* Skip pulse analysis after we have confirmed radar 			 * presence unless we are debugging and have 			 * disabled short-circuit logic.  In this case,			 * we'll go through ALL the signatures and find 			 * the best match to convince ourselves this code works.			 */			if (AH_FALSE == radar || 			    DFLAG_ISSET(sc, ATH_DEBUG_DOTHFILTNOSC)) {				/* short pulse match status */				u_int32_t index	 	= 0;				u_int32_t pri 		= 0;				u_int32_t matched 	= 0;				u_int32_t missed 	= 0;				u_int32_t noise 	= 0;#ifdef ATH_RADAR_LONG_PULSE				/* long pulse match status */				u_int32_t lp_bc	  	= 0;				u_int32_t lp_matched 	= 0;				u_int32_t lp_missed  	= 0;				u_int32_t lp_noise   	= 0;				u_int32_t lp_pulses  	= 0;#endif /* #ifdef ATH_RADAR_LONG_PULSE */				if (rp_analyze_short_pulse(sc, pulse, &index, 							&pri, &matched, &missed, 							&noise)) {					int compare_result = (!radar || best_index == -1) ? 						CR_NULL : 						compare_radar_matches(							matched, 							missed, 							pri,							noise,							radar_patterns[index].min_evts,							radar_patterns[index].max_evts,							radar_patterns[index].min_rep_int,							radar_patterns[index].max_rep_int,							radar_patterns[index].min_pulse,							radar_patterns[index].max_missing,							radar_patterns[index].match_midpoint,							best_matched,							best_missed,							best_pri,							best_noise,							radar_patterns[best_index].min_evts,							radar_patterns[best_index].max_evts,							radar_patterns[best_index].min_rep_int,							radar_patterns[best_index].max_rep_int,							radar_patterns[best_index].min_pulse,							radar_patterns[best_index].max_missing,							radar_patterns[best_index].match_midpoint						);					if (compare_result > CR_FALLTHROUGH) {						/* Update best match */						best_matched 	= matched;						best_missed 	= missed;						best_index 	= index;						best_pri 	= pri;						best_noise 	= noise;						radar 		= AH_TRUE;						best_cr 	= compare_result;					}					DPRINTF(sc, ATH_DEBUG_DOTHFILT,						"%s: %10s: %-17s [match=%2u "						"{%2u..%2u}, missed=%2u/%2u, "						"dur=%2d {%2u..%2u}, "						"noise=%2u/%2u, cr=%2d] "						"RI=%-9u RF=%-4u\n",						DEV_NAME(sc->sc_dev),						(compare_result > CR_FALLTHROUGH) ? 							"BETTER" : "WORSE",						radar_patterns[index].name,						matched, 						radar_patterns[index].min_pulse, 						radar_patterns[index].max_evts,						missed, 						radar_patterns[index].max_missing,						(matched + missed),						radar_patterns[index].min_evts,						radar_patterns[index].max_evts,						noise, 						(matched + noise), 						compare_result, 						pri, 						interval_to_frequency(pri));				}#ifdef ATH_RADAR_LONG_PULSE				if (rp_analyze_long_pulse(sc, pulse, 								  &lp_bc, 								  &lp_matched, 								  &lp_missed, 								  &lp_noise,								  &lp_pulses)) {					/* XXX: Do we care about best match?? */					radar 		= AH_TRUE;					best_lp_bc 	= lp_bc;					best_lp_matched = lp_matched;					best_lp_missed 	= lp_missed;					best_lp_noise 	= lp_noise;					best_lp_pulses 	= lp_pulses;				}#endif /* #ifdef ATH_RADAR_LONG_PULSE */			}			pulse->rp_analyzed = 1;		}	}	if (AH_TRUE == radar) {#ifdef ATH_RADAR_LONG_PULSE		if (!best_lp_bc) {#endif /* #ifdef ATH_RADAR_LONG_PULSE */			best_pattern = 				&radar_patterns[best_index];			DPRINTF(sc, ATH_DEBUG_DOTHFILT,				"%s: %10s: %-17s [match=%2u {%2u..%2u},missed="				"%2u/%2u,dur=%2d {%2u..%2u},noise=%2u/%2u,cr=%2d] "				"RI=%-9u RF=%-4u\n",				DEV_NAME(sc->sc_dev),				"BEST MATCH",				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));#ifdef ATH_RADAR_LONG_PULSE		}		else {			DPRINTF(sc, ATH_DEBUG_DOTHFILT,				"%s: %10s: %-17s [match=%2u {%2u..%2u},missed="				"%2u/%2u,noise=%2u/%2u]\n",				DEV_NAME(sc->sc_dev),				"BEST MATCH",				get_longpulse_desc(best_lp_bc),				best_lp_bc, 				(best_lp_bc-4),				best_lp_bc,				best_lp_missed,				(best_lp_bc-(best_lp_bc-4)),				best_lp_noise, 				(best_lp_pulses + best_lp_noise)				);		}#endif /* #ifdef ATH_RADAR_LONG_PULSE */		if (DFLAG_ISSET(sc, ATH_DEBUG_DOTHFILT)) {			DPRINTF(sc, ATH_DEBUG_DOTHFILT, 				"%s: ========================================\n",				DEV_NAME(sc->sc_dev));			DPRINTF(sc, ATH_DEBUG_DOTHFILT,				"%s: ==BEGIN RADAR SAMPLE====================\n",				DEV_NAME(sc->sc_dev));			DPRINTF(sc, ATH_DEBUG_DOTHFILT,				"%s: ========================================\n",				DEV_NAME(sc->sc_dev));#ifdef ATH_RADAR_LONG_PULSE			if (!best_lp_bc) {#endif /* #ifdef ATH_RADAR_LONG_PULSE */				best_pattern = 					&radar_patterns[best_index];				DPRINTF(sc, ATH_DEBUG_DOTHPULSES,					"%s: Sample contains data matching %s "					"[match=%2u {%2u..%2u}, "					"missed=%2u/%2u, dur=%2d {%2u..%2u}, "					"noise=%2u/%2u,cr=%d] RI=%-9u RF=%-4u\n",					DEV_NAME(sc->sc_dev),					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_noise + best_matched, 					best_cr,					best_pri, 					interval_to_frequency(best_pri));#ifdef ATH_RADAR_LONG_PULSE			} else {				DPRINTF(sc, ATH_DEBUG_DOTHPULSES,					"%s: Sample contains data matching %s\n",					DEV_NAME(sc->sc_dev),					get_longpulse_desc(best_lp_bc));			}#endif /* #ifdef ATH_RADAR_LONG_PULSE */			ath_rp_print(sc, 0 /* analyzed pulses only */ );			DPRINTF(sc, ATH_DEBUG_DOTHFILT, 				"%s: ========================================\n",				DEV_NAME(sc->sc_dev));			DPRINTF(sc, ATH_DEBUG_DOTHFILT, 				"%s: ==END RADAR SAMPLE======================\n",				DEV_NAME(sc->sc_dev));			DPRINTF(sc, ATH_DEBUG_DOTHFILT, 				"%s: ========================================\n",				DEV_NAME(sc->sc_dev));		}#ifdef ATH_RADAR_LONG_PULSE		if (!best_lp_bc)#endif /* #ifdef ATH_RADAR_LONG_PULSE */			ath_radar_detected(sc, radar_patterns[best_index].name);#ifdef ATH_RADAR_LONG_PULSE		else 			ath_radar_detected(sc, get_longpulse_desc(best_lp_bc));#endif /* #ifdef ATH_RADAR_LONG_PULSE */	}	return radar;}/* initialize ath_softc members so sensible values */static void ath_rp_clear(struct ath_softc *sc){	sc->sc_rp = NULL;	INIT_LIST_HEAD(&sc->sc_rp_list);	sc->sc_rp_num = 0;	sc->sc_rp_analyze = NULL;}static void ath_rp_tasklet(TQUEUE_ARG data){	struct net_device *dev = (struct net_device *)data;	struct ath_softc *sc = netdev_priv(dev);	if (sc->sc_rp_analyze != NULL)		sc->sc_rp_analyze(sc);}void ath_rp_init(struct ath_softc *sc){	struct net_device *dev = sc->sc_dev;	int i;	ath_rp_clear(sc);	sc->sc_rp = (struct ath_rp *)kzalloc(			sizeof(struct ath_rp) *			ATH_RADAR_PULSE_NR, GFP_KERNEL);	if (sc->sc_rp == NULL)		return;	/* initialize the circular list */	INIT_LIST_HEAD(&sc->sc_rp_list);	for (i = 0; i < ATH_RADAR_PULSE_NR; i++) {		sc->sc_rp[i].rp_index = i;		list_add_tail(&sc->sc_rp[i].list, 			      &sc->sc_rp_list);	}	sc->sc_rp_num = 0;	sc->sc_rp_analyze = rp_analyze;	/* compute sc_rp_min */	sc->sc_rp_min = 2;	for (i = 0; i < sizetab(radar_patterns); i++)		sc->sc_rp_min = 			MIN(sc->sc_rp_min,			    radar_patterns[i].min_pulse);	/* default values is properly handle pulses and detected radars */	sc->sc_rp_ignored = 0;	sc->sc_radar_ignored = 0;	ATH_INIT_TQUEUE(&sc->sc_rp_tq, ath_rp_tasklet, dev);}void ath_rp_done(struct ath_softc *sc){	/* free what we allocated in ath_rp_init() */	kfree(sc->sc_rp);	ath_rp_clear(sc);}void ath_rp_record(struct ath_softc *sc, u_int64_t tsf, u_int8_t rssi, 			    u_int8_t width, HAL_BOOL is_simulated){	struct ath_rp *pulse;	DPRINTF(sc, ATH_DEBUG_DOTHPULSES, "%s: ath_rp_record: "		"tsf=%10llu rssi=%3u width=%3u%s\n", 		SC_DEV_NAME(sc), tsf, rssi, width,		sc->sc_rp_ignored ? " (ignored)" : "");	if (sc->sc_rp_ignored) {		return;	}	/* pulses width 255 seems to trigger false detection of radar. we	 * ignored it then. */	if (width == 255) {		/* ignored */		return ;	}	/* check if the new radar pulse is after the last one recorded, or	 * else, we flush the history */	pulse = pulse_tail(sc);	if (tsf < pulse->rp_tsf) {		if (is_simulated == AH_TRUE && 0 == tsf) {			DPRINTF(sc, ATH_DEBUG_DOTHFILTVBSE, 				"%s: %s: ath_rp_flush: simulated tsf "				"reset.  tsf =%10llu, rptsf =%10llu\n", 				SC_DEV_NAME(sc), __func__, tsf, pulse->rp_tsf);			ath_rp_flush(sc);		} else if ((pulse->rp_tsf - tsf) > (1 << 15)) {			DPRINTF(sc, ATH_DEBUG_DOTHFILTVBSE,				"%s: %s: ath_rp_flush: tsf reset.  "				"(rp_tsf - tsf > 0x8000) tsf=%10llu, rptsf="				"%10llu\n", 				SC_DEV_NAME(sc), __func__, tsf, pulse->rp_tsf);			ath_rp_flush(sc);		} else {			DPRINTF(sc, ATH_DEBUG_DOTHFILT,				"%s: %s: tsf jitter/bug detected: tsf =%10llu, "				"rptsf =%10llu, rp_tsf - tsf = %10llu\n", 				SC_DEV_NAME(sc), __func__, tsf, pulse->rp_tsf,				pulse->rp_tsf - tsf);		}	}	/* remove the head of the list */	pulse = pulse_head(sc);	list_del(&pulse->list);	pulse->rp_tsf = tsf;	pulse->rp_rssi = rssi;	pulse->rp_width = width;	pulse->rp_allocated = 1;	pulse->rp_analyzed = 0;	/* add at the tail of the list */	list_add_tail(&pulse->list, &sc->sc_rp_list);	if (ATH_RADAR_PULSE_NR > sc->sc_rp_num)		sc->sc_rp_num++;}void ath_rp_print_mem(struct ath_softc *sc, int analyzed_pulses_only){	struct ath_rp *pulse;	u_int64_t oldest_tsf = ~0;	int i;	IPRINTF(sc, "Pulse dump of %spulses using sc_rp containing "	       "%d allocated pulses.\n", 	       analyzed_pulses_only ? "analyzed " : "", sc->sc_rp_num);	/* Find oldest TSF value so we can print relative times */	for (i = 0; i < ATH_RADAR_PULSE_NR; i++) {		pulse = &sc->sc_rp[i];		if (pulse->rp_allocated && pulse->rp_tsf < oldest_tsf)			oldest_tsf = pulse->rp_tsf;	}	for (i = 0; i < ATH_RADAR_PULSE_NR; i++) {		pulse = &sc->sc_rp[i];		if (!pulse->rp_allocated)			break;		if ((!analyzed_pulses_only) || pulse->rp_analyzed)			IPRINTF(sc, "Pulse [%3d, %p] : relative_tsf=%10llu "			       "tsf=%10llu rssi=%3u width=%3u allocated=%d "			       "analyzed=%d next=%p prev=%p\n",			       pulse->rp_index,			       pulse, 			       pulse->rp_tsf - oldest_tsf, 			       pulse->rp_tsf, 			       pulse->rp_rssi, 			       pulse->rp_width, 			       pulse->rp_allocated, 			       pulse->rp_analyzed, 			       pulse->list.next, 			       pulse->list.prev);	}}void ath_rp_print(struct ath_softc *sc, int analyzed_pulses_only){	struct ath_rp *pulse;	u_int64_t oldest_tsf = ~0;	IPRINTF(sc, "Pulse dump of %spulses from ring buffer containing %d "	       "pulses.\n", 	       analyzed_pulses_only ? "analyzed " : "", 	       sc->sc_rp_num);	/* Find oldest TSF value so we can print relative times */	oldest_tsf = ~0;	list_for_each_entry_reverse(pulse, &sc->sc_rp_list, list)		if (pulse->rp_allocated && pulse->rp_tsf < oldest_tsf)			oldest_tsf = pulse->rp_tsf;	list_for_each_entry_reverse(pulse, &sc->sc_rp_list, list) {		if (!pulse->rp_allocated)			continue;		if ((!analyzed_pulses_only) || pulse->rp_analyzed)			IPRINTF(sc, "Pulse [%3d, %p] : relative_tsf=%10llu "			       "tsf=%10llu rssi=%3u width=%3u allocated=%d "			       "analyzed=%d next=%p prev=%p\n",			       pulse->rp_index,			       pulse, 			       pulse->rp_tsf - oldest_tsf, 			       pulse->rp_tsf, 			       pulse->rp_rssi, 			       pulse->rp_width, 			       pulse->rp_allocated, 			       pulse->rp_analyzed, 			       pulse->list.next, 			       pulse->list.prev);	}}void ath_rp_flush(struct ath_softc *sc){	struct ath_rp *pulse;	list_for_each_entry_reverse(pulse, &sc->sc_rp_list, list)		pulse->rp_allocated = 0;	sc->sc_rp_num = 0;}

⌨️ 快捷键说明

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