Просмотр исходного кода

qcacmn: Define DFS logging APIs

1) Define logging(alert, err, warn, info, debug) on top of
   QDF abstractions for DFS component.
2) Use dfs_info for important prints such as CAC timeout,
   NOL timeout, enable/disable radar etc.
3) For everything else use dfs_debug macro.

Change-Id: Id1efc12dd00e7b3f2b8d5627c65f58e619438c82
CRs-Fixed: 2116421
Abhijit Pradhan 7 лет назад
Родитель
Сommit
77561584ad

+ 59 - 7
umac/dfs/core/src/dfs.h

@@ -40,18 +40,68 @@
 #include <wlan_objmgr_pdev_obj.h>
 #include <osdep.h>
 
-#define DFS_PRINTK(_fmt, ...) printk((_fmt), __VA_ARGS__)
-#define DFS_DPRINTK(dfs, _m, _fmt, ...) do { \
-	if (((dfs) == NULL) ||                   \
-			((dfs) != NULL &&                \
-	   ((_m) & (dfs)->dfs_debug_mask))) {    \
-		printk(_fmt, __VA_ARGS__);           \
-	}                                        \
+/* File Line and Submodule String */
+#define FLSM(x, str)   #str " : " FL(x)
+/* Cast to dfs type */
+#define DC(x)  ((struct wlan_dfs *)(x))
+
+/**
+ * dfs_log: dfs logging using submodule MASKs and
+ * QDF trace level.
+ * The logging is controlled by two bitmasks:
+ * 1) submodule bitmask: sm
+ * 2) trace level masks: level
+ *
+ * @dfs: The dfs object pointer or NULL if dfs is not defined.
+ * @sm: Submodule BITMASK.
+ * @level: QDF trace level.
+ * @args...: Variable argument list.
+ *
+ * The submodule(sm) cannot be empty even if argument dfs is NULL.
+ * Else the macro will create a  compilation  error.
+ * One may provide WLAN_DEBUG_DFS_ALWAYS when  the argument dfs is NULL.
+ * Example:-
+ * dfs_log(NULL, WLAN_DEBUG_DFS_ALWAYS, QDF_TRACE_LEVEL_INFO,"Error pulse");
+ *
+ * Why DC(x) is required?
+ * Since NULL is defined as ((void *)(0)), if the argument "dfs"
+ * in a call to the macro "dfs_log" is NULL
+ * then during compilation (NULL)->dfs_debug_mask will dereference
+ * a (void *) type, which is illegal. Therefore, we need
+ * the cast: (DC(dfs))->dfs_debug_mask.
+ * Example:-
+ * dfs_log(NULL, WLAN_DEBUG_DFS, QDF_TRACE_LEVEL_INFO,"dfs is NULL");
+ */
+#define dfs_log(dfs, sm, level, args...)  do {        \
+	if (((dfs) == NULL) ||                            \
+			((sm) == WLAN_DEBUG_DFS_ALWAYS) ||        \
+			((sm) & ((DC(dfs))->dfs_debug_mask))) {   \
+		QDF_TRACE(QDF_MODULE_ID_DFS, level, ## args); \
+	}                                                 \
 } while (0)
 
+#define dfs_logfl(dfs, level, sm, format, args...) \
+	dfs_log(dfs, sm, level, FLSM(format, sm), ## args)
+
+#define dfs_alert(dfs, sm, format, args...) \
+	dfs_logfl(dfs, QDF_TRACE_LEVEL_FATAL, sm, format, ## args)
+
+#define dfs_err(dfs, sm, format, args...) \
+	dfs_logfl(dfs, QDF_TRACE_LEVEL_ERROR, sm, format, ## args)
+
+#define dfs_warn(dfs, sm, format, args...) \
+	dfs_logfl(dfs, QDF_TRACE_LEVEL_WARN, sm, format, ## args)
+
+#define dfs_info(dfs, sm, format, args...) \
+	dfs_logfl(dfs, QDF_TRACE_LEVEL_INFO, sm, format, ## args)
+
+#define dfs_debug(dfs, sm, format, args...) \
+	dfs_logfl(dfs, QDF_TRACE_LEVEL_DEBUG, sm, format, ## args)
+
 #define DFS_MIN(a, b) ((a) < (b)?(a):(b))
 #define DFS_MAX(a, b) ((a) > (b)?(a) : (b))
 #define DFS_DIFF(a, b)(DFS_MAX(a, b) - DFS_MIN(a, b))
+
 /**
  * Maximum number of radar events to be processed in a single iteration.
  * Allows soft watchdog to run.
@@ -851,6 +901,8 @@ enum {
 	WLAN_DEBUG_DFS_BIN5_FFT   = 0x00020000,
 	WLAN_DEBUG_DFS_BIN5_PULSE = 0x00040000,
 	WLAN_DEBUG_DFS_FALSE_DET  = 0x00080000,
+	WLAN_DEBUG_DFS_MAX        = 0x80000000,
+	WLAN_DEBUG_DFS_ALWAYS     = WLAN_DEBUG_DFS_MAX
 };
 
 /**

+ 4 - 4
umac/dfs/core/src/filtering/ar5212_radar.c

@@ -171,7 +171,7 @@ void dfs_get_radars_for_ar5212(struct wlan_dfs *dfs)
 
 	switch (dfsdomain) {
 	case DFS_FCC_DOMAIN:
-		DFS_PRINTK("%s: DFS_FCC_DOMAIN_5212\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "DFS_FCC_DOMAIN_5212");
 		rinfo.dfsdomain = DFS_FCC_DOMAIN;
 		rinfo.dfs_radars = &ar5212_fcc_radars[2];
 		rinfo.numradars = QDF_ARRAY_SIZE(ar5212_fcc_radars)-2;
@@ -179,7 +179,7 @@ void dfs_get_radars_for_ar5212(struct wlan_dfs *dfs)
 		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5212_bin5pulses);
 		break;
 	case DFS_ETSI_DOMAIN:
-		DFS_PRINTK("%s: DFS_ETSI_DOMAIN_5412\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "DFS_ETSI_DOMAIN_5412");
 		rinfo.dfsdomain = DFS_ETSI_DOMAIN;
 		rinfo.dfs_radars = &ar5212_etsi_radars[0];
 		rinfo.numradars = QDF_ARRAY_SIZE(ar5212_etsi_radars);
@@ -187,7 +187,7 @@ void dfs_get_radars_for_ar5212(struct wlan_dfs *dfs)
 		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5212_bin5pulses);
 		break;
 	case DFS_MKK4_DOMAIN:
-		DFS_PRINTK("%s: DFS_MKK4_DOMAIN_5412\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "DFS_MKK4_DOMAIN_5412");
 		rinfo.dfsdomain = DFS_MKK4_DOMAIN;
 		rinfo.dfs_radars = &ar5212_fcc_radars[0];
 		rinfo.numradars = QDF_ARRAY_SIZE(ar5212_fcc_radars);
@@ -195,7 +195,7 @@ void dfs_get_radars_for_ar5212(struct wlan_dfs *dfs)
 		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5212_bin5pulses);
 		break;
 	default:
-		DFS_PRINTK("%s: No domain\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "No domain");
 		return;
 	}
 

+ 4 - 4
umac/dfs/core/src/filtering/ar5416_radar.c

@@ -114,7 +114,7 @@ void dfs_get_radars_for_ar5416(struct wlan_dfs *dfs)
 
 	switch (dfsdomain) {
 	case DFS_FCC_DOMAIN:
-		DFS_PRINTK("%s: DFS_FCC_DOMAIN_5416\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "DFS_FCC_DOMAIN_5416");
 		rinfo.dfsdomain = DFS_FCC_DOMAIN;
 		rinfo.dfs_radars = &ar5416_fcc_radars[3];
 		rinfo.numradars = QDF_ARRAY_SIZE(ar5416_fcc_radars)-3;
@@ -122,7 +122,7 @@ void dfs_get_radars_for_ar5416(struct wlan_dfs *dfs)
 		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5416_bin5pulses);
 		break;
 	case DFS_ETSI_DOMAIN:
-		DFS_PRINTK("%s: DFS_ETSI_DOMAIN_5416\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "DFS_ETSI_DOMAIN_5416");
 		rinfo.dfsdomain = DFS_ETSI_DOMAIN;
 		rinfo.dfs_radars = &ar5416_etsi_radars[0];
 		rinfo.numradars = QDF_ARRAY_SIZE(ar5416_etsi_radars);
@@ -130,7 +130,7 @@ void dfs_get_radars_for_ar5416(struct wlan_dfs *dfs)
 		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5416_bin5pulses);
 		break;
 	case DFS_MKK4_DOMAIN:
-		DFS_PRINTK("%s: DFS_MKK4_DOMAIN_5416\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "DFS_MKK4_DOMAIN_5416");
 		rinfo.dfsdomain = DFS_MKK4_DOMAIN;
 		rinfo.dfs_radars = &ar5416_fcc_radars[0];
 		rinfo.numradars = QDF_ARRAY_SIZE(ar5416_fcc_radars);
@@ -138,7 +138,7 @@ void dfs_get_radars_for_ar5416(struct wlan_dfs *dfs)
 		rinfo.numb5radars = QDF_ARRAY_SIZE(ar5416_bin5pulses);
 		break;
 	default:
-		DFS_PRINTK("%s: no domain\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "no domain");
 		return;
 	}
 

+ 5 - 6
umac/dfs/core/src/filtering/ar9300_radar.c

@@ -168,7 +168,7 @@ void dfs_get_radars_for_ar9300(struct wlan_dfs *dfs)
 
 	switch (dfsdomain) {
 	case DFS_FCC_DOMAIN:
-		DFS_PRINTK("%s: DFS_FCC_DOMAIN_9300\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "DFS_FCC_DOMAIN_9300");
 		rinfo.dfsdomain = DFS_FCC_DOMAIN;
 		rinfo.dfs_radars =
 			&ar9300_fcc_radars[AR9300_FCC_RADARS_FCC_OFFSET];
@@ -179,7 +179,7 @@ void dfs_get_radars_for_ar9300(struct wlan_dfs *dfs)
 		rinfo.numb5radars = QDF_ARRAY_SIZE(ar9300_bin5pulses);
 		break;
 	case DFS_ETSI_DOMAIN:
-		DFS_PRINTK("%s: DFS_ETSI_DOMAIN_9300\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "DFS_ETSI_DOMAIN_9300");
 		rinfo.dfsdomain = DFS_ETSI_DOMAIN;
 		rinfo.dfs_radars = &ar9300_etsi_radars[0];
 		rinfo.numradars = QDF_ARRAY_SIZE(ar9300_etsi_radars);
@@ -187,14 +187,13 @@ void dfs_get_radars_for_ar9300(struct wlan_dfs *dfs)
 		rinfo.numb5radars = QDF_ARRAY_SIZE(ar9300_bin5pulses);
 
 		if (lmac_is_countryCode_KOREA_ROC3(dfs->dfs_pdev_obj)) {
-			DFS_PRINTK("%s: DFS_ETSI_DOMAIN_9300_Country_Korea\n",
-				__func__);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "DFS_ETSI_DOMAIN_9300_Country_Korea");
 			rinfo.dfs_radars = &ar9300_korea_radars[0];
 			rinfo.numradars = QDF_ARRAY_SIZE(ar9300_korea_radars);
 		}
 		break;
 	case DFS_MKK4_DOMAIN:
-		DFS_PRINTK("%s: DFS_MKK4_DOMAIN_9300\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "DFS_MKK4_DOMAIN_9300");
 		rinfo.dfsdomain = DFS_MKK4_DOMAIN;
 		rinfo.dfs_radars = &ar9300_fcc_radars[0];
 		rinfo.numradars = QDF_ARRAY_SIZE(ar9300_fcc_radars);
@@ -202,7 +201,7 @@ void dfs_get_radars_for_ar9300(struct wlan_dfs *dfs)
 		rinfo.numb5radars = QDF_ARRAY_SIZE(ar9300_bin5pulses);
 		break;
 	default:
-		DFS_PRINTK("%s: no domain\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "no domain");
 		return;
 	}
 

+ 7 - 10
umac/dfs/core/src/filtering/dfs_ar.c

@@ -54,9 +54,8 @@ void dfs_process_ar_event(struct wlan_dfs *dfs,
 	uint16_t thistimestamp;
 	int empty;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"%s: dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -70,7 +69,7 @@ void dfs_process_ar_event(struct wlan_dfs *dfs,
 		if (re != NULL)
 			STAILQ_REMOVE_HEAD(&(dfs->dfs_arq), re_list);
 		WLAN_ARQ_UNLOCK(dfs);
-		if (re == NULL)
+		if (!re)
 			return;
 
 		thistimestamp = re->re_ts;
@@ -285,9 +284,8 @@ void dfs_process_ar_event(struct wlan_dfs *dfs,
 
 void dfs_reset_ar(struct wlan_dfs *dfs)
 {
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s: sc_dfs is NULL\n",
-			__func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -300,9 +298,8 @@ void dfs_reset_arq(struct wlan_dfs *dfs)
 {
 	struct dfs_event *event;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s: sc_dfs is NULL\n",
-			__func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 

+ 21 - 21
umac/dfs/core/src/filtering/dfs_bindetects.c

@@ -77,7 +77,7 @@ static inline bool dfs_ts_within_window(
 	if ((pl->pl_elems[*index].p_dur == 1) ||
 			((dur != 1) && (deltadur <= 2))) {
 		(*numpulses)++;
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2, "numpulses %u\n", *numpulses);
+		dfs_debug(dfs, WLAN_DEBUG_DFS2, "numpulses %u", *numpulses);
 		return 1;
 	}
 
@@ -114,8 +114,8 @@ static inline bool dfs_ts_eq_prevts(
 				((pl->pl_elems[*index].p_dur != 1) &&
 				 (deltadur <= 2))) {
 			(*numpulses)++;
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-					"zero PRI: numpulses %u\n", *numpulses);
+			dfs_debug(dfs, WLAN_DEBUG_DFS2,
+					"zero PRI: numpulses %u", *numpulses);
 			return 1;
 		}
 	}
@@ -154,7 +154,7 @@ static inline int dfs_pulses_within_window(
 		event_ts = pl->pl_elems[*index].p_time;
 		next_index = (*index+1) & DFS_MAX_PULSE_BUFFER_MASK;
 		next_event_ts = pl->pl_elems[next_index].p_time;
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2, "ts %u\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2, "ts %u",
 				(uint32_t)event_ts);
 
 		if ((event_ts <= window_end) && (event_ts >= window_start)) {
@@ -204,8 +204,8 @@ static inline int dfs_count_pulses(
 	for (n = 0; n <= rf->rf_numpulses; n++) {
 		window_start = (start_ts + (refpri*n))-(primargin+n);
 		window_end = window_start + 2*(primargin+n);
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"window_start %u window_end %u\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"window_start %u window_end %u",
 				(uint32_t)window_start, (uint32_t)window_end);
 		numpulses += dfs_pulses_within_window(dfs, window_start,
 				window_end, &index, dur, refpri);
@@ -238,8 +238,8 @@ static int  dfs_bin_fixedpattern_check(
 	end_ts = pl->pl_elems[last_index].p_time;
 	start_ts = end_ts - (refpri*rf->rf_numpulses);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS3,
-		"lastelem ts=%llu start_ts=%llu, end_ts=%llu\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS3,
+		"lastelem ts=%llu start_ts=%llu, end_ts=%llu",
 		(unsigned long long)pl->pl_elems[last_index].p_time,
 		(unsigned long long)start_ts,
 		(unsigned long long) end_ts);
@@ -257,9 +257,9 @@ static int  dfs_bin_fixedpattern_check(
 	fil_thresh = dfs_get_filter_threshold(dfs, rf, ext_chan_flag);
 
 	if (numpulses >= fil_thresh) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"%s FOUND filterID=%u numpulses=%d unadj thresh=%d\n",
-			__func__, rf->rf_pulseid, numpulses, rf->rf_threshold);
+		dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"FOUND filterID=%u numpulses=%d unadj thresh=%d",
+			 rf->rf_pulseid, numpulses, rf->rf_threshold);
 		return 1;
 	} else {
 		return 0;
@@ -290,9 +290,9 @@ void dfs_add_pulse(
 	dl->dl_elems[index].de_dur = re->re_dur;
 	dl->dl_elems[index].de_rssi = re->re_rssi;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-		"%s: adding: filter id %d, dur=%d, rssi=%d, ts=%llu\n",
-		__func__, rf->rf_pulseid, re->re_dur,
+	dfs_debug(dfs, WLAN_DEBUG_DFS2,
+		"adding: filter id %d, dur=%d, rssi=%d, ts=%llu",
+		 rf->rf_pulseid, re->re_dur,
 		re->re_rssi, (unsigned long long int)this_ts);
 
 	for (n = 0; n < dl->dl_numelems-1; n++) {
@@ -308,7 +308,7 @@ void dfs_add_pulse(
 			dl->dl_numelems = n+1;
 		}
 	}
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2, "dl firstElem = %d  lastElem = %d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS2, "dl firstElem = %d  lastElem = %d",
 			dl->dl_firstelem, dl->dl_lastelem);
 }
 
@@ -602,8 +602,8 @@ static inline void dfs_bin_success_print(
 		uint32_t refdur,
 		uint32_t primargin)
 {
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"ext_flag=%d MATCH filter=%u numpulses=%u thresh=%u refdur=%d refpri=%d primargin=%d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"ext_flag=%d MATCH filter=%u numpulses=%u thresh=%u refdur=%d refpri=%d primargin=%d",
 			ext_chan_flag, rf->rf_pulseid, numpulses,
 			rf->rf_threshold, refdur, refpri, primargin);
 	dfs_print_delayline(dfs, &rf->rf_dl);
@@ -784,8 +784,8 @@ static void dfs_count_the_other_delay_elements(
 		}
 		*prev_good_timestamp = dl->dl_elems[delayindex].de_ts;
 
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-			"rf->minpri=%d rf->maxpri=%d searchpri = %d index = %d numpulses = %d deltapri=%d j=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+			"rf->minpri=%d rf->maxpri=%d searchpri = %d index = %d numpulses = %d deltapri=%d j=%d",
 			rf->rf_minpri, rf->rf_maxpri, searchpri,
 			i, *numpulses, deltapri, j);
 	}
@@ -862,8 +862,8 @@ int dfs_bin_pri_check(
 	 * are left as it is for readability hoping the complier
 	 * will use left/right shifts wherever possible.
 	 */
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-		"refpri = %d high score = %d index = %d numpulses = %d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS2,
+		"refpri = %d high score = %d index = %d numpulses = %d",
 		refpri, highscore, highscoreindex, numpulses);
 	/*
 	 * Count the other delay elements that have pri and dur with

+ 10 - 11
umac/dfs/core/src/filtering/dfs_debug.c

@@ -28,8 +28,8 @@ void dfs_print_delayline(struct wlan_dfs *dfs, struct dfs_delayline *dl)
 	index = dl->dl_lastelem;
 	for (i = 0; i < dl->dl_numelems; i++) {
 		de = &dl->dl_elems[index];
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-			"Elem %d: ts = %u (0x%x) dur=%u\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+			"Elem %d: ts = %u (0x%x) dur=%u",
 			i, de->de_time, de->de_time, de->de_dur);
 		index = (index - 1) & DFS_MAX_DL_MASK;
 	}
@@ -37,8 +37,8 @@ void dfs_print_delayline(struct wlan_dfs *dfs, struct dfs_delayline *dl)
 
 void dfs_print_filter(struct wlan_dfs *dfs, struct dfs_filter *rf)
 {
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-		"filterID[%d] rf_numpulses=%u; rf->rf_minpri=%u; rf->rf_maxpri=%u; rf->rf_threshold=%u; rf->rf_filterlen=%u; rf->rf_mindur=%u; rf->rf_maxdur=%u\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS1,
+		"filterID[%d] rf_numpulses=%u; rf->rf_minpri=%u; rf->rf_maxpri=%u; rf->rf_threshold=%u; rf->rf_filterlen=%u; rf->rf_mindur=%u; rf->rf_maxdur=%u",
 		rf->rf_pulseid, rf->rf_numpulses, rf->rf_minpri, rf->rf_maxpri,
 		rf->rf_threshold, rf->rf_filterlen, rf->rf_mindur,
 		rf->rf_maxdur);
@@ -58,8 +58,8 @@ static void dfs_print_filtertype(
 
 	for (j = 0; j < ft->ft_numfilters; j++) {
 		rf = &(ft->ft_filters[j]);
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"filter[%d] filterID = %d rf_numpulses=%u; rf->rf_minpri=%u; rf->rf_maxpri=%u; rf->rf_threshold=%u; rf->rf_filterlen=%u; rf->rf_mindur=%u; rf->rf_maxdur=%u\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"filter[%d] filterID = %d rf_numpulses=%u; rf->rf_minpri=%u; rf->rf_maxpri=%u; rf->rf_threshold=%u; rf->rf_filterlen=%u; rf->rf_mindur=%u; rf->rf_maxdur=%u",
 				j, rf->rf_pulseid, rf->rf_numpulses,
 				rf->rf_minpri, rf->rf_maxpri,
 				rf->rf_threshold, rf->rf_filterlen,
@@ -72,9 +72,8 @@ void dfs_print_filters(struct wlan_dfs *dfs)
 	struct dfs_filtertype *ft = NULL;
 	uint8_t i;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			"%s: sc_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -85,8 +84,8 @@ void dfs_print_filters(struct wlan_dfs *dfs)
 					(!ft->ft_numfilters)) {
 				continue;
 			}
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-					"===========ft->ft_numfilters = %u===========\n",
+			dfs_debug(dfs, WLAN_DEBUG_DFS2,
+					"===========ft->ft_numfilters = %u===========",
 					ft->ft_numfilters);
 			dfs_print_filtertype(dfs, ft);
 		}

+ 69 - 73
umac/dfs/core/src/filtering/dfs_fcc_bin5.c

@@ -32,18 +32,18 @@ int dfs_bin5_check_pulse(struct wlan_dfs *dfs, struct dfs_event *re,
 {
 	int b5_rssithresh = br->br_pulse.b5_rssithresh;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_PULSE,
-		"%s: re_dur=%d, rssi=%d, check_chirp=%d, hw_chirp=%d, sw_chirp=%d\n",
-		__func__, (int)re->re_dur, (int)re->re_rssi,
+	dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_PULSE,
+		"re_dur=%d, rssi=%d, check_chirp=%d, hw_chirp=%d, sw_chirp=%d",
+		 (int)re->re_dur, (int)re->re_rssi,
 		!!(re->re_flags & DFS_EVENT_CHECKCHIRP),
 		!!(re->re_flags & DFS_EVENT_HW_CHIRP),
 		!!(re->re_flags & DFS_EVENT_SW_CHIRP));
 
 	/* If the SW/HW chirp detection says to fail the pulse,do so. */
 	if (DFS_EVENT_NOTCHIRP(re)) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5,
-			"%s: rejecting chirp: ts=%llu, dur=%d, rssi=%d checkchirp=%d, hwchirp=%d, swchirp=%d\n",
-			__func__, (unsigned long long)re->re_full_ts,
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5,
+			"rejecting chirp: ts=%llu, dur=%d, rssi=%d checkchirp=%d, hwchirp=%d, swchirp=%d",
+			 (unsigned long long)re->re_full_ts,
 			(int)re->re_dur, (int)re->re_rssi,
 			!!(re->re_flags & DFS_EVENT_CHECKCHIRP),
 			!!(re->re_flags & DFS_EVENT_HW_CHIRP),
@@ -61,15 +61,15 @@ int dfs_bin5_check_pulse(struct wlan_dfs *dfs, struct dfs_event *re,
 	if ((re->re_dur >= br->br_pulse.b5_mindur) &&
 			(re->re_dur <= br->br_pulse.b5_maxdur) &&
 			(re->re_rssi >= b5_rssithresh)) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5,
-			"%s: dur=%d, rssi=%d - adding!\n",
-			__func__, (int)re->re_dur, (int)re->re_rssi);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5,
+			"dur=%d, rssi=%d - adding!",
+			 (int)re->re_dur, (int)re->re_rssi);
 		return 1;
 	}
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5,
-		"%s: too low to be Bin5 pulse tsf=%llu, dur=%d, rssi=%d\n",
-		__func__, (unsigned long long)re->re_full_ts,
+	dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5,
+		"too low to be Bin5 pulse tsf=%llu, dur=%d, rssi=%d",
+		 (unsigned long long)re->re_full_ts,
 		(int)re->re_dur, (int)re->re_rssi);
 
 	return 0;
@@ -174,9 +174,8 @@ static inline void dfs_calculate_bursts_for_same_rssi(
 
 		index[(*numevents)++] = this;
 	} else {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5,
-				"%s %d Bin5 rssi_diff=%d\n",
-				__func__, __LINE__, rssi_diff);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5,
+				"Bin5 rssi_diff=%d", rssi_diff);
 	}
 }
 
@@ -199,8 +198,8 @@ void bin5_rules_check_internal(struct wlan_dfs *dfs,
 		/* Roll over case */
 		pri = br->br_elems[this].be_ts;
 	}
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5,
-		" pri=%llu this.ts=%llu this.dur=%d this.rssi=%d prev.ts=%llu\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5,
+		" pri=%llu this.ts=%llu this.dur=%d this.rssi=%d prev.ts=%llu",
 		(uint64_t)pri,
 		(uint64_t) br->br_elems[this].be_ts,
 		(int) br->br_elems[this].be_dur,
@@ -230,17 +229,15 @@ void bin5_rules_check_internal(struct wlan_dfs *dfs,
 			dfs_calculate_bursts_for_same_rssi(dfs, br, bursts,
 					numevents, prev, this, index);
 		 else
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5,
-				"%s %d Bin5 width_diff=%d\n",
-				__func__, __LINE__, width_diff);
+			dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5,
+				"Bin5 width_diff=%d", width_diff);
 	} else if ((pri >= DFS_BIN5_BRI_LOWER_LIMIT) &&
 			(pri <= DFS_BIN5_BRI_UPPER_LIMIT)) {
 		/* Check pulse width to make sure it is in range of bin 5. */
 		(*bursts)++;
 	} else{
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5,
-			"%s %d Bin5 PRI check fail pri=%llu\n",
-			__func__, __LINE__, (uint64_t)pri);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5,
+			"Bin5 PRI check fail pri=%llu", (uint64_t)pri);
 	}
 }
 
@@ -252,14 +249,14 @@ int dfs_bin5_check(struct wlan_dfs *dfs)
 	uint32_t total_width = 0, average_width = 0, numevents = 0;
 	int index[DFS_MAX_B5_SIZE];
 
-	if (dfs == NULL) {
-		DFS_PRINTK("%s: dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return 1;
 	}
 
 	for (n = 0; n < dfs->dfs_rinfo.rn_numbin5radars; n++) {
 		br = &(dfs->dfs_b5radars[n]);
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5, "Num elems = %d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5, "Num elems = %d",
 				br->br_numelems);
 
 		/* Find a valid bin 5 pulse and use it as reference. */
@@ -289,19 +286,22 @@ int dfs_bin5_check(struct wlan_dfs *dfs)
 			prev = this;
 		}
 
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5,
-			"bursts=%u numevents=%u\n", bursts, numevents);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5,
+			"bursts=%u numevents=%u", bursts, numevents);
 		if (bursts >= br->br_pulse.b5_threshold) {
 			if ((br->br_elems[br->br_lastelem].be_ts -
 					br->br_elems[br->br_firstelem].be_ts) <
 					3000000)
 				return 0;
 
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5,
-				"bursts=%u numevents=%u total_width=%d average_width=%d total_diff=%d average_diff=%d\n",
-				bursts, numevents, total_width, average_width,
-				total_diff, average_diff);
-			DFS_PRINTK("bin 5 radar detected, bursts=%d\n", bursts);
+			dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5,
+					"bursts=%u numevents=%u total_width=%d average_width=%d total_diff=%d average_diff=%d",
+					bursts, numevents, total_width,
+					average_width, total_diff,
+					average_diff);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"bin 5 radar detected, bursts=%d",
+					bursts);
 			return 1;
 		}
 	}
@@ -355,17 +355,17 @@ static int dfs_check_chirping_sowl(struct wlan_dfs *dfs,
 
 	/* DEBUG - Print relevant portions of the FFT data. */
 	for (p = 0; p < num_fft_packets; p++) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
 			"fft_data_ptr=0x%pK\t", fft_data_ptr);
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
-			"[66]=%d [69]=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
+			"[66]=%d [69]=%d",
 			*(fft_data_ptr + FFT_LOWER_BIN_MAX_INDEX_BYTE) >> 2,
 			*(fft_data_ptr + FFT_UPPER_BIN_MAX_INDEX_BYTE) >> 2);
 		fft_data_ptr += FFT_LEN;
 	}
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
-		"datalen=%d num_fft_packets=%d\n", datalen, num_fft_packets);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
+		"datalen=%d num_fft_packets=%d", datalen, num_fft_packets);
 
 	/*
 	 * There is not enough FFT data to figure out whether the pulse
@@ -404,8 +404,8 @@ static int dfs_check_chirping_sowl(struct wlan_dfs *dfs,
 		    ((ctl_slope0 > ctl_slope1) ? ctl_slope0 : ctl_slope1);
 		*slope = ctl_slope;
 
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
-			"ctl_slope0=%d ctl_slope1=%d ctl_slope=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
+			"ctl_slope0=%d ctl_slope1=%d ctl_slope=%d",
 			ctl_slope0, ctl_slope1, ctl_slope);
 	} else if (is_ext) {
 		fft_data_ptr = (uint8_t *)buf;
@@ -433,8 +433,8 @@ static int dfs_check_chirping_sowl(struct wlan_dfs *dfs,
 		ext_slope = ((ext_slope0 > ext_slope1) ?
 				ext_slope0 : ext_slope1);
 		*slope = ext_slope;
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT | WLAN_DEBUG_DFS_BIN5,
-			"ext_slope0=%d ext_slope1=%d ext_slope=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT | WLAN_DEBUG_DFS_BIN5,
+			"ext_slope0=%d ext_slope1=%d ext_slope=%d",
 			ext_slope0, ext_slope1, ext_slope);
 	} else
 		return 0;
@@ -442,8 +442,8 @@ static int dfs_check_chirping_sowl(struct wlan_dfs *dfs,
 	if ((ctl_slope >= MIN_CHIRPING_SLOPE) ||
 			(ext_slope >= MIN_CHIRPING_SLOPE)) {
 		is_chirp = 1;
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5 | WLAN_DEBUG_DFS_BIN5_FFT |
-			WLAN_DEBUG_DFS_PHYERR_SUM, "is_chirp=%d is_dc=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5 | WLAN_DEBUG_DFS_BIN5_FFT |
+			WLAN_DEBUG_DFS_PHYERR_SUM, "is_chirp=%d is_dc=%d",
 			is_chirp, *is_dc);
 	}
 
@@ -572,17 +572,16 @@ static int dfs_check_chirping_merlin(struct wlan_dfs *dfs,
 
 	ptr = (uint8_t *)buf;
 	/* Sanity check for FFT buffer. */
-	if ((ptr == NULL) || (datalen == 0)) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
-			"%s: FFT buffer pointer is null or size is 0\n",
-			__func__);
+	if (!ptr || (datalen == 0)) {
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
+			"FFT buffer pointer is null or size is 0");
 		return 0;
 	}
 
 	num_fft_packets = (datalen - 3) / num_fft_bytes;
 	if (num_fft_packets < (NUM_DIFFS + DELTA_STEP)) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
-			"datalen = %d, num_fft_packets = %d, too few packets... (exiting)\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
+			"datalen = %d, num_fft_packets = %d, too few packets... (exiting)",
 			datalen, num_fft_packets);
 		return 0;
 	}
@@ -652,8 +651,8 @@ static int dfs_check_chirping_merlin(struct wlan_dfs *dfs,
 				max_index[i] = max_index_lower[i];
 			}
 		}
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
-			"i=%d, max_index[i]=%d, max_index_lower[i]=%d, max_index_upper[i]=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
+			"i=%d, max_index[i]=%d, max_index_lower[i]=%d, max_index_upper[i]=%d",
 			i, max_index[i], max_index_lower[i],
 			max_index_upper[i]);
 	}
@@ -679,19 +678,17 @@ static int dfs_check_chirping_merlin(struct wlan_dfs *dfs,
 			(ABS(delta_peak[i]) >= min_d[DELTA_STEP - 1]) &&
 			(ABS(delta_peak[i]) <= max_d[DELTA_STEP - 1]) &&
 			same_sign && (ABS(delta_diff) <= MAX_DIFF);
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
-			"i=%d, delta_peak[i]=%d, delta_diff=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
+			"i=%d, delta_peak[i]=%d, delta_diff=%d",
 			i, delta_peak[i], delta_diff);
 	}
 
 	if (chirp_found) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
-			"%s: CHIRPING_BEFORE_STRONGBIN_YES\n",
-			__func__);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
+			"CHIRPING_BEFORE_STRONGBIN_YES");
 	} else {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
-			"%s: CHIRPING_BEFORE_STRONGBIN_NO\n",
-			__func__);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
+			"CHIRPING_BEFORE_STRONGBIN_NO");
 	}
 
 	/*
@@ -721,20 +718,19 @@ static int dfs_check_chirping_merlin(struct wlan_dfs *dfs,
 			bin_count += (ptr[fft_start + j] & 0x88) ? 1 : 0;
 		}
 		chirp_found &= (bin_count > BIN_COUNT_MAX) ? 0 : 1;
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
-			"i=%d, computed bin_count=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT,
+			"i=%d, computed bin_count=%d",
 			i, bin_count);
 	}
 
 	if (chirp_found) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT |
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT |
 			WLAN_DEBUG_DFS_PHYERR_SUM,
-			"%s: CHIRPING_YES\n",
-			__func__);
+			"CHIRPING_YES");
 	} else {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_FFT |
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_FFT |
 			WLAN_DEBUG_DFS_PHYERR_SUM,
-			"%s: CHIRPING_NO\n", __func__);
+			"CHIRPING_NO");
 	}
 
 	return chirp_found;
@@ -794,9 +790,9 @@ uint8_t dfs_retain_bin5_burst_pattern(struct wlan_dfs *dfs,
 	 */
 	/* SPLIT pulses will have a time stamp difference of < 50 */
 	if (diff_ts < 50) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5,
-			"%s SPLIT pulse diffTs=%u dur=%d (old_dur=%d)\n",
-			__func__, diff_ts,
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5,
+			"SPLIT pulse diffTs=%u dur=%d (old_dur=%d)",
+			 diff_ts,
 			dfs->dfs_rinfo.dfs_last_bin5_dur, old_dur);
 	}
 
@@ -810,9 +806,9 @@ uint8_t dfs_retain_bin5_burst_pattern(struct wlan_dfs *dfs,
 		 * This pulse belongs to the same burst as the pulse before,
 		 * so return the same random duration for it.
 		 */
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5,
-			"%s this pulse belongs to the same burst as before, give it same dur=%d (old_dur=%d)\n",
-			__func__, dfs->dfs_rinfo.dfs_last_bin5_dur, old_dur);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5,
+			"this pulse belongs to the same burst as before, give it same dur=%d (old_dur=%d)",
+			 dfs->dfs_rinfo.dfs_last_bin5_dur, old_dur);
 		return dfs->dfs_rinfo.dfs_last_bin5_dur;
 	}
 

+ 31 - 38
umac/dfs/core/src/filtering/dfs_init.c

@@ -50,22 +50,20 @@ void dfs_reset_alldelaylines(struct wlan_dfs *dfs)
 	struct dfs_pulseline *pl;
 	int i;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-				"%s: sc_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 	pl = dfs->pulses;
 
-	if (pl == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s: pl==NULL, dfs=%pK\n",
-				__func__, dfs);
+	if (!pl) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "pl==NULL, dfs=%p", dfs);
 		return;
 	}
 
-	if (dfs->dfs_b5radars == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s: pl==NULL, b5radars=%pK\n",
-				__func__, dfs->dfs_b5radars);
+	if (!(dfs->dfs_b5radars)) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "pl==NULL, b5radars=%p",
+				dfs->dfs_b5radars);
 		return;
 	}
 
@@ -111,9 +109,8 @@ void dfs_reset_radarq(struct wlan_dfs *dfs)
 {
 	struct dfs_event *event;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s: sc_dfs is NULL\n",
-				__func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -153,9 +150,7 @@ static inline bool dfs_fill_ft_index_table(
 		(dfs->dfs_ftindextable[i])[tableindex] =
 			(int8_t)(dfs->dfs_rinfo.rn_ftindex);
 	} else {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-				"%s: Too many overlapping radar filters\n",
-				__func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "Too many overlapping radar filters");
 		return 1;
 	}
 
@@ -185,8 +180,7 @@ static inline bool dfs_fill_filter_type(
 
 	/* No filter of the appropriate dur was found. */
 	if ((dfs->dfs_rinfo.rn_ftindex + 1) > DFS_MAX_RADAR_TYPES) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-				"%s: Too many filter types\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "Too many filter types");
 		return 1;
 	}
 	(*ft) = dfs->dfs_radarf[dfs->dfs_rinfo.rn_ftindex];
@@ -230,14 +224,14 @@ int dfs_init_radar_filters(struct wlan_dfs *dfs,
 	int numradars = 0, numb5radars = 0;
 	int retval;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "dfs is NULL %s", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return 1;
 	}
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			"%s: dfsdomain=%d, numradars=%d, numb5radars=%d\n",
-			__func__, radar_info->dfsdomain,
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+			"dfsdomain=%d, numradars=%d, numb5radars=%d",
+			 radar_info->dfsdomain,
 			radar_info->numradars, radar_info->numb5radars);
 
 	/* Clear up the dfs domain flag first. */
@@ -247,9 +241,9 @@ int dfs_init_radar_filters(struct wlan_dfs *dfs,
 	 * If radar_info is NULL or dfsdomain is NULL, treat the
 	 * rest of the radar configuration as suspect.
 	 */
-	if (radar_info == NULL || radar_info->dfsdomain == 0) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s: Unknown dfs domain %d\n",
-				__func__, dfs->dfsdomain);
+	if (!radar_info || radar_info->dfsdomain == 0) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "Unknown dfs domain %d",
+				 dfs->dfsdomain);
 		/* Disable radar detection since we don't have a radar domain.*/
 		dfs->dfs_proc_phyerr &= ~DFS_RADAR_EN;
 		dfs->dfs_proc_phyerr &= ~DFS_SECOND_SEGMENT_RADAR_EN;
@@ -289,7 +283,7 @@ int dfs_init_radar_filters(struct wlan_dfs *dfs,
 			}
 		}
 
-		if (ft == NULL) {
+		if (!ft) {
 			retval = dfs_fill_filter_type(dfs, &ft, dfs_radars,
 					&min_rssithresh, &max_pulsedur, p);
 			if (retval == 1)
@@ -325,15 +319,15 @@ int dfs_init_radar_filters(struct wlan_dfs *dfs,
 		rf->rf_threshold = dfs_radars[p].rp_threshold;
 		rf->rf_filterlen = rf->rf_maxpri * rf->rf_numpulses;
 
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"minprf = %d maxprf = %d pulsevar = %d thresh=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"minprf = %d maxprf = %d pulsevar = %d thresh=%d",
 				dfs_radars[p].rp_pulsefreq,
 				dfs_radars[p].rp_max_pulsefreq,
 				dfs_radars[p].rp_pulsevar,
 				rf->rf_threshold);
 
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"minpri = %d maxpri = %d filterlen = %d filterID = %d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"minpri = %d maxpri = %d filterlen = %d filterID = %d",
 				rf->rf_minpri, rf->rf_maxpri,
 				rf->rf_filterlen, rf->rf_pulseid);
 	}
@@ -341,15 +335,14 @@ int dfs_init_radar_filters(struct wlan_dfs *dfs,
 	dfs_print_filters(dfs);
 
 	dfs->dfs_rinfo.rn_numbin5radars  = numb5radars;
-	if (dfs->dfs_b5radars != NULL)
+	if (!(dfs->dfs_b5radars))
 		qdf_mem_free(dfs->dfs_b5radars);
 
 	dfs->dfs_b5radars = (struct dfs_bin5radars *)qdf_mem_malloc(
 			numb5radars * sizeof(struct dfs_bin5radars));
-	if (dfs->dfs_b5radars == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-				"%s: cannot allocate memory for bin5 radars\n",
-				__func__);
+	if (!(dfs->dfs_b5radars)) {
+		dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"cannot allocate memory for bin5 radars");
 		goto bad4;
 	}
 	for (n = 0; n < numb5radars; n++) {
@@ -378,10 +371,10 @@ int dfs_init_radar_filters(struct wlan_dfs *dfs,
 	 */
 	dfs->dfs_rinfo.rn_maxpulsedur = dfs->dfs_rinfo.rn_maxpulsedur + 20;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "DFS min filter rssiThresh = %d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS, "DFS min filter rssiThresh = %d",
 			min_rssithresh);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "DFS max pulse dur = %d ticks\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS, "DFS max pulse dur = %d ticks",
 			dfs->dfs_rinfo.rn_maxpulsedur);
 
 	return 0;
@@ -392,7 +385,7 @@ bad4:
 
 void dfs_clear_stats(struct wlan_dfs *dfs)
 {
-	if (dfs == NULL)
+	if (!dfs)
 		return;
 
 	qdf_mem_zero(&dfs->wlan_dfs_stats, sizeof(struct dfs_stats));

+ 4 - 4
umac/dfs/core/src/filtering/dfs_misc.c

@@ -87,8 +87,8 @@ static inline void dfs_get_cached_ext_chan_busy(
 			(dfs->dfs_rinfo.rn_lastfull_ts <
 			 dfs->dfs_rinfo.ext_chan_busy_ts)) {
 		*ext_chan_busy = dfs->dfs_rinfo.dfs_ext_chan_busy;
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"Use cached copy of ext_chan_busy extchanbusy=%d rn_lastfull_ts=%llu ext_chan_busy_ts=%llu\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"Use cached copy of ext_chan_busy extchanbusy=%d rn_lastfull_ts=%llu ext_chan_busy_ts=%llu",
 				*ext_chan_busy,
 				(uint64_t)dfs->dfs_rinfo.rn_lastfull_ts,
 				(uint64_t)dfs->dfs_rinfo.ext_chan_busy_ts);
@@ -145,8 +145,8 @@ int dfs_get_filter_threshold(struct wlan_dfs *dfs,
 
 		adjust_thresh =
 			dfs_adjust_thresh_per_chan_busy(ext_chan_busy, thresh);
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-			" filterID=%d extchanbusy=%d adjust_thresh=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+			" filterID=%d extchanbusy=%d adjust_thresh=%d",
 			rf->rf_pulseid, ext_chan_busy, adjust_thresh);
 
 		thresh += adjust_thresh;

+ 73 - 95
umac/dfs/core/src/filtering/dfs_phyerr_tlv.c

@@ -81,29 +81,29 @@ static void dfs_radar_summary_print(struct wlan_dfs *dfs,
 		struct rx_radar_status *rsu)
 {
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"    pulsedur=%d\n", rsu->pulse_duration);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"    rssi=%d\n", rsu->rssi);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"    ischirp=%d\n", rsu->is_chirp);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"    sidx=%d\n", rsu->sidx);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"    raw tsf=%d\n", rsu->raw_tsf);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"    tsf_offset=%d\n", rsu->tsf_offset);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"    cooked tsf=%d\n", rsu->raw_tsf - rsu->tsf_offset);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"    frequency offset=%d.%d MHz (oversampling=%d)\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"    pulsedur=%d", rsu->pulse_duration);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"    rssi=%d", rsu->rssi);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"    ischirp=%d", rsu->is_chirp);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"    sidx=%d", rsu->sidx);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"    raw tsf=%d", rsu->raw_tsf);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"    tsf_offset=%d", rsu->tsf_offset);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"    cooked tsf=%d", rsu->raw_tsf - rsu->tsf_offset);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"    frequency offset=%d.%d MHz (oversampling=%d)",
 		(int)(rsu->freq_offset / 1000),
 		(int)abs(rsu->freq_offset % 1000),
 		PERE_IS_OVERSAMPLING(dfs));
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"    agc_total_gain=%d\n", rsu->agc_total_gain);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"    agc_mb_gain=%d\n", rsu->agc_mb_gain);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"    agc_total_gain=%d", rsu->agc_total_gain);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"    agc_mb_gain=%d", rsu->agc_mb_gain);
 }
 
 /**
@@ -124,10 +124,9 @@ static void dfs_radar_summary_parse(struct wlan_dfs *dfs,
 
 	/* Drop out if we have < 2 DWORDs available. */
 	if (len < sizeof(rs)) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR |
+		dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR |
 			WLAN_DEBUG_DFS_PHYERR_SUM,
-			"%s: len (%zu) < expected (%zu)!\n",
-			__func__, len, sizeof(rs));
+			"len (%zu) < expected (%zu)!", len, sizeof(rs));
 	}
 
 	/*
@@ -138,9 +137,8 @@ static void dfs_radar_summary_parse(struct wlan_dfs *dfs,
 	 */
 	qdf_mem_copy(rs, buf, sizeof(rs));
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"%s: two 32 bit values are: %08x %08x\n",
-		__func__, rs[0], rs[1]);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"two 32 bit values are: %08x %08x", rs[0], rs[1]);
 
 	/* Populate the fields from the summary report. */
 	rsu->tsf_offset =
@@ -182,10 +180,9 @@ static void dfs_radar_fft_search_report_parse(struct wlan_dfs *dfs,
 
 	/* Drop out if we have < 2 DWORDs available. */
 	if (len < sizeof(rs)) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR |
+		dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR |
 			WLAN_DEBUG_DFS_PHYERR_SUM,
-			"%s: len (%zu) < expected (%zu)!\n",
-			__func__, len, sizeof(rs));
+			"len (%zu) < expected (%zu)!", len, sizeof(rs));
 	}
 
 	/*
@@ -219,39 +216,30 @@ static void dfs_radar_fft_search_report_parse(struct wlan_dfs *dfs,
 	rsfr->num_str_bins_ib =
 	    MS(rs[SEARCH_FFT_REPORT_REG_2], SEARCH_FFT_REPORT_NUM_STR_BINS_IB);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"%s: two 32 bit values are: %08x %08x\n",
-		__func__, rs[0], rs[1]);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"%s: rsfr->total_gain_db = %d\n",
-		__func__, rsfr->total_gain_db);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"%s: rsfr->base_pwr_db = %d\n",
-		__func__, rsfr->base_pwr_db);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"%s: rsfr->fft_chn_idx = %d\n",
-		__func__, rsfr->fft_chn_idx);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"%s: rsfr->peak_sidx = %d\n",
-		__func__, rsfr->peak_sidx);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"%s: rsfr->relpwr_db = %d\n",
-		__func__, rsfr->relpwr_db);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"%s: rsfr->avgpwr_db = %d\n",
-		__func__, rsfr->avgpwr_db);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"%s: rsfr->peak_mag = %d\n",
-		__func__, rsfr->peak_mag);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-		"%s: rsfr->num_str_bins_ib = %d\n",
-		__func__, rsfr->num_str_bins_ib);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"two 32 bit values are: %08x %08x", rs[0], rs[1]);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"rsfr->total_gain_db = %d", rsfr->total_gain_db);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"rsfr->base_pwr_db = %d", rsfr->base_pwr_db);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"rsfr->fft_chn_idx = %d", rsfr->fft_chn_idx);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"rsfr->peak_sidx = %d", rsfr->peak_sidx);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"rsfr->relpwr_db = %d", rsfr->relpwr_db);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"rsfr->avgpwr_db = %d", rsfr->avgpwr_db);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"rsfr->peak_mag = %d", rsfr->peak_mag);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+		"rsfr->num_str_bins_ib = %d", rsfr->num_str_bins_ib);
 
 	if (dfs->dfs_caps.wlan_chip_is_ht160) {
 		rsfr->seg_id =
 		    MS(rs[SEARCH_FFT_REPORT_REG_3], SEARCH_FFT_REPORT_SEG_ID);
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-			"%s: rsfr->seg_id = %d\n", __func__, rsfr->seg_id);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+			"rsfr->seg_id = %d", rsfr->seg_id);
 	}
 }
 
@@ -293,12 +281,9 @@ static inline void dfs_check_for_false_detection(
 	}
 
 	if (*false_detect)
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-				"%s: setting false_detect to TRUE because of mb/total_gain/rssi, agc_mb_gain=%d, agc_total_gain=%d, rssi=%d\n",
-				__func__,
-				rs->agc_mb_gain,
-				rs->agc_total_gain,
-				rssi);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+				"setting false_detect to TRUE because of mb/total_gain/rssi, agc_mb_gain=%d, agc_total_gain=%d, rssi=%d",
+				rs->agc_mb_gain, rs->agc_total_gain, rssi);
 }
 
 /**
@@ -329,18 +314,14 @@ static int dfs_tlv_parse_frame(struct wlan_dfs *dfs,
 	bool first_tlv = true;
 	bool false_detect = false;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-			"%s: total length = %zu bytes\n",
-			__func__, len);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+			"total length = %zu bytes", len);
 	while ((i < len) && (false_detect == false)) {
 		/* Ensure we at least have four bytes. */
 		if ((len - i) < sizeof(tlv_hdr)) {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR |
+			dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR |
 				WLAN_DEBUG_DFS_PHYERR_SUM,
-				"%s: ran out of bytes, len=%zu, i=%d\n",
-				__func__, len, i);
-			DFS_PRINTK("%s: ran out of bytes, len=%zu, i=%d\n",
-				__func__, len, i);
+				"ran out of bytes, len=%zu, i=%d", len, i);
 			return 0;
 		}
 
@@ -350,9 +331,8 @@ static int dfs_tlv_parse_frame(struct wlan_dfs *dfs,
 		 */
 		qdf_mem_copy(&tlv_hdr, buf + i, sizeof(tlv_hdr));
 
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-			"%s: HDR: TLV SIG=0x%x, TAG=0x%x, LEN=%d bytes\n",
-			__func__,
+		dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+			"HDR: TLV SIG=0x%x, TAG=0x%x, LEN=%d bytes",
 			MS(tlv_hdr[TLV_REG], TLV_SIG),
 			MS(tlv_hdr[TLV_REG], TLV_TAG),
 			MS(tlv_hdr[TLV_REG], TLV_LEN));
@@ -363,9 +343,9 @@ static int dfs_tlv_parse_frame(struct wlan_dfs *dfs,
 		 * rest of the TLV entries.
 		 */
 		if (MS(tlv_hdr[TLV_REG], TLV_LEN) + i >= len) {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-				"%s: TLV oversize: TLV LEN=%d, available=%zu, i=%d\n",
-				__func__, MS(tlv_hdr[TLV_REG], TLV_LEN),
+			dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+				"TLV oversize: TLV LEN=%d, available=%zu, i=%d",
+				 MS(tlv_hdr[TLV_REG], TLV_LEN),
 				len, i);
 			break;
 		}
@@ -416,22 +396,21 @@ static int dfs_tlv_parse_frame(struct wlan_dfs *dfs,
 				(rsfr->peak_mag < (2 * dfs->wlan_dfs_peak_mag))
 				) {
 				false_detect = true;
-				DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-					"%s: setting false_detect to TRUE because of false_rssi_thres\n",
-					__func__);
+				dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+					"setting false_detect to TRUE because of false_rssi_thres");
 			}
 			break;
 		default:
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-				"%s: unknown entry, SIG=0x%02x\n",
-				__func__, MS(tlv_hdr[TLV_REG], TLV_SIG));
+			dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+				"unknown entry, SIG=0x%02x",
+				 MS(tlv_hdr[TLV_REG], TLV_SIG));
 		}
 
 		/* Skip the payload. */
 		i += MS(tlv_hdr[TLV_REG], TLV_LEN);
 		first_tlv = false;
 	}
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR, "%s: done\n\n", __func__);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR, "done");
 
 	return false_detect ? 0 : 1;
 }
@@ -451,8 +430,8 @@ static int dfs_tlv_calc_freq_info(struct wlan_dfs *dfs,
 	int chan_offset;
 
 	/* For now, just handle up to VHT80 correctly. */
-	if (dfs->dfs_curchan == NULL) {
-		DFS_PRINTK("%s: dfs_curchan is null\n", __func__);
+	if (!dfs->dfs_curchan) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs_curchan is null");
 		return 0;
 		/*
 		 * For now, the only 11ac channel with freq1/freq2 setup is
@@ -595,9 +574,8 @@ static int dfs_tlv_calc_event_freq_chirp(struct wlan_dfs *dfs,
 	total_bw = delta_peak * (bin_resolution / radar_fft_long_period) *
 		pulse_duration;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR | WLAN_DEBUG_DFS_PHYERR_SUM,
-		"%s: delta_peak=%d, pulse_duration=%d, bin_resolution=%d.%dKHz, radar_fft_long_period=%d, total_bw=%d.%ldKHz\n",
-		__func__,
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR | WLAN_DEBUG_DFS_PHYERR_SUM,
+		"delta_peak=%d, pulse_duration=%d, bin_resolution=%d.%dKHz, radar_fft_long_period=%d, total_bw=%d.%ldKHz",
 		delta_peak, pulse_duration, bin_resolution / THOUSAND,
 		bin_resolution % THOUSAND, radar_fft_long_period,
 		total_bw / HUNDRED,
@@ -725,9 +703,9 @@ int dfs_process_phyerr_bb_tlv(struct wlan_dfs *dfs,
 	e->mb_gain = rs.agc_mb_gain;
 	e->relpwr_db = rsfr.relpwr_db;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR_SUM,
-		"%s: fbin=%d, freq=%d.%d MHz, raw tsf=%u, offset=%d, cooked tsf=%u, rssi=%d, dur=%d, is_chirp=%d, fulltsf=%llu, freq=%d.%d MHz, freq_lo=%d.%dMHz, freq_hi=%d.%d MHz\n",
-		__func__, rs.sidx, (int) (rs.freq_offset / 1000),
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR_SUM,
+		"fbin=%d, freq=%d.%d MHz, raw tsf=%u, offset=%d, cooked tsf=%u, rssi=%d, dur=%d, is_chirp=%d, fulltsf=%llu, freq=%d.%d MHz, freq_lo=%d.%dMHz, freq_hi=%d.%d MHz",
+		 rs.sidx, (int) (rs.freq_offset / 1000),
 		(int) abs(rs.freq_offset % 1000), rs.raw_tsf, rs.tsf_offset,
 		e->rs_tstamp, rs.rssi, rs.pulse_duration, (int)rs.is_chirp,
 		(unsigned long long) fulltsf, (int)e->freq / 1000,
@@ -735,8 +713,8 @@ int dfs_process_phyerr_bb_tlv(struct wlan_dfs *dfs,
 		(int) abs(e->freq_lo) % 1000, (int)e->freq_hi / 1000,
 		(int) abs(e->freq_hi) % 1000);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_FALSE_DET,
-		"ts=%u, dur=%d, rssi=%d, freq_offset=%d.%dMHz, is_chirp=%d, seg_id=%d, peak_mag=%d, total_gain=%d, mb_gain=%d, relpwr_db=%d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS_FALSE_DET,
+		"ts=%u, dur=%d, rssi=%d, freq_offset=%d.%dMHz, is_chirp=%d, seg_id=%d, peak_mag=%d, total_gain=%d, mb_gain=%d, relpwr_db=%d",
 		e->rs_tstamp, rs.pulse_duration, rs.rssi,
 		(int)e->freq_offset_khz / 1000,
 		(int)abs(e->freq_offset_khz) % 1000, (int)rs.is_chirp,

+ 51 - 61
umac/dfs/core/src/filtering/dfs_process_phyerr.c

@@ -39,10 +39,10 @@
 static inline int dfs_get_event_freqwidth(struct wlan_dfs *dfs)
 {
 	/* Handle edge cases during startup/transition, shouldn't happen! */
-	if (dfs == NULL)
+	if (!dfs)
 		return 0;
 
-	if (dfs->dfs_curchan == NULL)
+	if (!dfs->dfs_curchan)
 		return 0;
 
 	/*
@@ -70,9 +70,9 @@ static inline uint16_t dfs_get_event_freqcentre(struct wlan_dfs *dfs,
 	int chan_offset = 0, chan_width;
 
 	/* Handle edge cases during startup/transition, shouldn't happen! */
-	if (dfs == NULL)
+	if (!dfs)
 		return 0;
-	if (dfs->dfs_curchan == NULL)
+	if (!dfs->dfs_curchan)
 		return 0;
 
 	/*
@@ -160,9 +160,9 @@ int dfs_process_phyerr_owl(struct wlan_dfs *dfs,
 	e->freq_lo = e->freq - (event_width / 2) * 1000;
 	e->freq_hi = e->freq + (event_width / 2) * 1000;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR_SUM,
-		"%s: rssi=%u dur=%u, freq=%d MHz, freq_lo=%d MHz, freq_hi=%d MHz\n",
-		__func__, rssi, dur, e->freq/1000, e->freq_lo/1000,
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR_SUM,
+		"rssi=%u dur=%u, freq=%d MHz, freq_lo=%d MHz, freq_hi=%d MHz",
+		 rssi, dur, e->freq/1000, e->freq_lo/1000,
 		e->freq_hi / 1000);
 
 	return 1;
@@ -198,9 +198,8 @@ int dfs_process_phyerr_sowl(struct wlan_dfs *dfs,
 
 	/* Ensure that we have at least three bytes of payload. */
 	if (datalen < 3) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			"%s: short error frame (%d bytes)\n",
-			__func__, datalen);
+		dfs_debug(dfs, WLAN_DEBUG_DFS,
+			"short error frame (%d bytes)", datalen);
 		dfs->wlan_dfs_stats.datalen_discards++;
 		return 0;
 	}
@@ -255,13 +254,13 @@ int dfs_process_phyerr_sowl(struct wlan_dfs *dfs,
 			ext_found = 1;
 			early_ext = 1;
 			dfs->wlan_dfs_stats.early_ext_phy_errors++;
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-				"EARLY ext channel dur=%u rssi=%u datalen=%d\n",
+			dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+				"EARLY ext channel dur=%u rssi=%u datalen=%d",
 				dur, rssi, datalen);
 		}
 		if (!pulse_bw_info) {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-				"ERROR channel dur=%u rssi=%u pulse_bw_info=0x%x datalen MOD 4 = %d\n",
+			dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+				"ERROR channel dur=%u rssi=%u pulse_bw_info=0x%x datalen MOD 4 = %d",
 				dur, rssi, pulse_bw_info, (datalen & 0x3));
 			/*
 			 * Bogus bandwidth info received in descriptor, so
@@ -298,9 +297,9 @@ int dfs_process_phyerr_sowl(struct wlan_dfs *dfs,
 	e->freq_lo = e->freq - (event_width / 2) * 1000;
 	e->freq_hi = e->freq + (event_width / 2) * 1000;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR_SUM,
-		"%s: pulse_bw_info=0x%x pulse_length_ext=%u pulse_length_pri=%u rssi=%u ext_rssi=%u, freq=%d MHz, freq_lo=%d MHz, freq_hi=%d MHz\n",
-		__func__, pulse_bw_info, pulse_length_ext, pulse_length_pri,
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR_SUM,
+		"pulse_bw_info=0x%x pulse_length_ext=%u pulse_length_pri=%u rssi=%u ext_rssi=%u, freq=%d MHz, freq_lo=%d MHz, freq_hi=%d MHz",
+		 pulse_bw_info, pulse_length_ext, pulse_length_pri,
 		rssi, ext_rssi, e->freq/1000, e->freq_lo/1000, e->freq_hi/1000);
 #undef EXT_CH_RADAR_FOUND
 #undef PRI_CH_RADAR_FOUND
@@ -341,8 +340,8 @@ int dfs_process_phyerr_merlin(struct wlan_dfs *dfs,
 		break;
 	case 0x01:
 		/* Radar in ctrl channel */
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-			"RAW RSSI: rssi=%u ext_rssi=%u\n", rssi, ext_rssi);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+			"RAW RSSI: rssi=%u ext_rssi=%u", rssi, ext_rssi);
 		if (ext_rssi >= (rssi + 3)) {
 			/*
 			 * Cannot use ctrl channel RSSI if extension channel is
@@ -353,8 +352,8 @@ int dfs_process_phyerr_merlin(struct wlan_dfs *dfs,
 		break;
 	case 0x02:
 		/* Radar in extension channel */
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-			"RAW RSSI: rssi=%u ext_rssi=%u\n", rssi, ext_rssi);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+			"RAW RSSI: rssi=%u ext_rssi=%u", rssi, ext_rssi);
 		if (rssi >= (ext_rssi + 12)) {
 			/*
 			 * Cannot use extension channel RSSI if control channel
@@ -410,7 +409,7 @@ static void dfs_dump_phyerr_contents(const char *d, int len)
 
 		n += snprintf(buf + n, bufsize - n, "%02x ", d[i] & 0xff);
 		if (i % 16 == 15) {
-			DFS_PRINTK("%s: %s\n", __func__, buf);
+			dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "%s", buf);
 			n = 0;
 			buf[0] = '\0';
 		}
@@ -418,7 +417,7 @@ static void dfs_dump_phyerr_contents(const char *d, int len)
 
 	/* Print the final line if we didn't print it above. */
 	if (n != 0)
-		DFS_PRINTK("%s: %s\n", __func__, buf);
+		dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "%s", buf);
 }
 
 /**
@@ -432,7 +431,7 @@ static inline void dfs_bump_up_bin5_pulse_dur(
 		struct dfs_phy_err *e,
 		int slope)
 {
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR, "old dur %d slope =%d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR, "old dur %d slope =%d",
 			e->dur, slope);
 
 	e->is_sw_chirp = 1;
@@ -440,7 +439,7 @@ static inline void dfs_bump_up_bin5_pulse_dur(
 	if (e->dur < MIN_BIN5_DUR)
 		e->dur = dfs_get_random_bin5_dur(dfs, e->fulltsf);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR, "new dur %d\n", e->dur);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR, "new dur %d", e->dur);
 }
 
 /**
@@ -471,8 +470,8 @@ static inline void dfs_filter_short_pulses(
 	}
 
 	if (*retval) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-				"%s pulse is discarded: dur=%d, maxpulsedur=%d, rssi=%d, minrssi=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS1,
+				"%s pulse is discarded: dur=%d, maxpulsedur=%d, rssi=%d, minrssi=%d",
 				(dfs->dfs_caps.wlan_dfs_ext_chan_ok) ?
 				"Extension channel" : "",
 				e->dur, dfs->dfs_rinfo.rn_maxpulsedur,
@@ -494,9 +493,8 @@ static inline bool dfs_is_second_seg_radar_disabled(
 	if ((seg_id == SEG_ID_SECONDARY) &&
 			!(dfs->dfs_proc_phyerr &
 				DFS_SECOND_SEGMENT_RADAR_EN)) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS3,
-				"%s: Do not process PHY error data from Second segment, DFS_SECOND_SEGMENT_RADAR_EN is not enabled\n",
-				__func__);
+		dfs_debug(dfs, WLAN_DEBUG_DFS3,
+				"Do not process PHY error data from Second segment, DFS_SECOND_SEGMENT_RADAR_EN is not enabled");
 		return true;
 	}
 
@@ -518,11 +516,10 @@ static inline void dfs_set_chan_index(
 		event->re_chanindex = dfs->dfs_curchan_radindex;
 	} else {
 		event->re_chanindex = dfs->dfs_extchan_radindex;
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-				"%s %s New extension channel event is added to queue\n",
-				__func__,
+		dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+				"%s New extension channel event is added to queue",
 				(event->re_chanindex == -1) ?
-				"- phyerr on ext channel\n" : "");
+				"- phyerr on ext channel" : "");
 	}
 }
 
@@ -534,15 +531,13 @@ void dfs_process_phyerr(struct wlan_dfs *dfs, void *buf, uint16_t datalen,
 	struct dfs_phy_err e;
 	int empty;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			"%s: sc_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
 	if (dfs->dfs_ignore_dfs) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"%s: ignoring dfs\n", __func__);
+		dfs_debug(dfs, WLAN_DEBUG_DFS1, "ignoring dfs");
 		return;
 	}
 
@@ -552,9 +547,8 @@ void dfs_process_phyerr(struct wlan_dfs *dfs, void *buf, uint16_t datalen,
 	 */
 
 	if (!(dfs->dfs_proc_phyerr & DFS_RADAR_EN)) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"%s: DFS_RADAR_EN not set in dfs->dfs_proc_phyerr\n",
-			__func__);
+		dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"DFS_RADAR_EN not set in dfs->dfs_proc_phyerr");
 		return;
 	}
 
@@ -578,15 +572,13 @@ void dfs_process_phyerr(struct wlan_dfs *dfs, void *buf, uint16_t datalen,
 		dfs_dump_phyerr_contents(buf, datalen);
 
 	if (IEEE80211_IS_CHAN_RADAR(dfs->dfs_curchan)) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"%s: Radar already found in the channel, do not queue radar data\n",
-			__func__);
+		dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"Radar already found in the channel, do not queue radar data");
 		return;
 	}
 
 	dfs->wlan_dfs_stats.total_phy_errors++;
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2, "%s : %d phyerr %d len %d\n",
-		__func__, __LINE__,
+	dfs_debug(dfs, WLAN_DEBUG_DFS2, "phyerr %d len %d",
 		dfs->wlan_dfs_stats.total_phy_errors, datalen);
 
 	/*
@@ -691,8 +683,8 @@ void dfs_process_phyerr(struct wlan_dfs *dfs, void *buf, uint16_t datalen,
 				/* Set the duration so that it is rejected. */
 				e.is_sw_chirp = 0;
 				e.dur = MAX_BIN5_DUR + 100;
-				DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_PHYERR,
-					"is_chirping = %d dur=%d\n",
+				dfs_debug(dfs, WLAN_DEBUG_DFS_PHYERR,
+					"is_chirping = %d dur=%d",
 					add_dur, e.dur);
 			}
 		} else {
@@ -735,16 +727,16 @@ void dfs_process_phyerr(struct wlan_dfs *dfs, void *buf, uint16_t datalen,
 	 */
 	if ((dfs->dfs_curchan->dfs_ch_flags & CHANNEL_108G) == CHANNEL_108G) {
 		if (!(dfs->dfs_proc_phyerr & DFS_AR_EN)) {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"%s: DFS_AR_EN not enabled\n", __func__);
+			dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"DFS_AR_EN not enabled");
 			return;
 		}
 		WLAN_DFSEVENTQ_LOCK(dfs);
 		event = STAILQ_FIRST(&(dfs->dfs_eventq));
-		if (event == NULL) {
+		if (!event) {
 			WLAN_DFSEVENTQ_UNLOCK(dfs);
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-				"%s: no more events space left\n", __func__);
+			dfs_debug(dfs, WLAN_DEBUG_DFS,
+				"no more events space left");
 			return;
 		}
 		STAILQ_REMOVE_HEAD(&(dfs->dfs_eventq), re_list);
@@ -778,9 +770,8 @@ void dfs_process_phyerr(struct wlan_dfs *dfs, void *buf, uint16_t datalen,
 			int retval = 0;
 
 			if (!(dfs->dfs_proc_phyerr & DFS_RADAR_EN)) {
-				DFS_DPRINTK(dfs, WLAN_DEBUG_DFS3,
-					"%s: DFS_RADAR_EN not enabled\n",
-					__func__);
+				dfs_debug(dfs, WLAN_DEBUG_DFS3,
+					"DFS_RADAR_EN not enabled");
 				return;
 			}
 
@@ -794,11 +785,10 @@ void dfs_process_phyerr(struct wlan_dfs *dfs, void *buf, uint16_t datalen,
 			/* Add the event to the list, if there's space. */
 			WLAN_DFSEVENTQ_LOCK(dfs);
 			event = STAILQ_FIRST(&(dfs->dfs_eventq));
-			if (event == NULL) {
+			if (!event) {
 				WLAN_DFSEVENTQ_UNLOCK(dfs);
-				DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-					"%s: no more events space left\n",
-					__func__);
+				dfs_debug(dfs, WLAN_DEBUG_DFS,
+					"no more events space left");
 				return;
 			}
 			STAILQ_REMOVE_HEAD(&(dfs->dfs_eventq), re_list);

+ 56 - 59
umac/dfs/core/src/filtering/dfs_process_radarevent.c

@@ -90,21 +90,21 @@ static void dfs_print_radar_events(struct wlan_dfs *dfs)
 {
 	int i;
 
-	DFS_PRINTK("%s:#Phyerr=%d, #false detect=%d, #queued=%d\n",
-		__func__, dfs->dfs_phyerr_count, dfs->dfs_phyerr_reject_count,
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "#Phyerr=%d, #false detect=%d, #queued=%d",
+		 dfs->dfs_phyerr_count, dfs->dfs_phyerr_reject_count,
 		dfs->dfs_phyerr_queued_count);
 
-	DFS_PRINTK("%s:dfs_phyerr_freq_min=%d, dfs_phyerr_freq_max=%d\n",
-		__func__, dfs->dfs_phyerr_freq_min, dfs->dfs_phyerr_freq_max);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "dfs_phyerr_freq_min=%d, dfs_phyerr_freq_max=%d",
+		 dfs->dfs_phyerr_freq_min, dfs->dfs_phyerr_freq_max);
 
-	DFS_PRINTK(
-		"%s:Total radar events detected=%d, entries in the radar queue follows:\n",
-		__func__, dfs->dfs_event_log_count);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+		"Total radar events detected=%d, entries in the radar queue follows:",
+		 dfs->dfs_event_log_count);
 
 	for (i = 0; (i < DFS_EVENT_LOG_SIZE) && (i < dfs->dfs_event_log_count);
 			i++) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			"ts=%llu diff_ts=%u rssi=%u dur=%u, is_chirp=%d, seg_id=%d, sidx=%d, freq_offset=%d.%dMHz, peak_mag=%d, total_gain=%d, mb_gain=%d, relpwr_db=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS,
+			"ts=%llu diff_ts=%u rssi=%u dur=%u, is_chirp=%d, seg_id=%d, sidx=%d, freq_offset=%d.%dMHz, peak_mag=%d, total_gain=%d, mb_gain=%d, relpwr_db=%d",
 			dfs->radar_log[i].ts, dfs->radar_log[i].diff_ts,
 			dfs->radar_log[i].rssi, dfs->radar_log[i].dur,
 			dfs->radar_log[i].is_chirp, dfs->radar_log[i].seg_id,
@@ -139,8 +139,8 @@ static inline bool dfs_reject_on_pri(
 {
 	if ((deltaT < rf->rf_minpri) && (deltaT != 0)) {
 		/* Second line of PRI filtering. */
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"filterID %d : Rejecting on individual filter min PRI deltaT=%lld rf->rf_minpri=%u\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"filterID %d : Rejecting on individual filter min PRI deltaT=%lld rf->rf_minpri=%u",
 				rf->rf_pulseid, (uint64_t)deltaT,
 				rf->rf_minpri);
 		return 1;
@@ -148,8 +148,8 @@ static inline bool dfs_reject_on_pri(
 
 	if (rf->rf_ignore_pri_window > 0) {
 		if (deltaT < rf->rf_minpri) {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-					"filterID %d : Rejecting on individual filter max PRI deltaT=%lld rf->rf_minpri=%u\n",
+			dfs_debug(dfs, WLAN_DEBUG_DFS2,
+					"filterID %d : Rejecting on individual filter max PRI deltaT=%lld rf->rf_minpri=%u",
 					rf->rf_pulseid, (uint64_t)deltaT,
 					rf->rf_minpri);
 			/* But update the last time stamp. */
@@ -169,8 +169,8 @@ static inline bool dfs_reject_on_pri(
 
 		if ((deltaT > (dfs->dfs_pri_multiplier * rf->rf_maxpri)) ||
 				(deltaT < rf->rf_minpri)) {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-					"filterID %d : Rejecting on individual filter max PRI deltaT=%lld rf->rf_minpri=%u\n",
+			dfs_debug(dfs, WLAN_DEBUG_DFS2,
+					"filterID %d : Rejecting on individual filter max PRI deltaT=%lld rf->rf_minpri=%u",
 					rf->rf_pulseid, (uint64_t) deltaT,
 					rf->rf_minpri);
 			/* But update the last time stamp. */
@@ -232,7 +232,8 @@ void __dfs_process_radarevent(struct wlan_dfs *dfs,
 	}
 
 	if (*found) {
-		DFS_PRINTK("Found on channel minDur = %d, filterId = %d\n",
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"Found on channel minDur = %d, filterId = %d",
 				ft->ft_mindur,
 				rf != NULL ?  rf->rf_pulseid : -1);
 	}
@@ -266,10 +267,12 @@ static inline void dfs_radarfound_reset_vars(
 	if ((seg_id == SEG_ID_SECONDARY) &&
 			(dfs_is_precac_timer_running(dfs))) {
 		dfs->is_radar_during_precac = 1;
-		DFS_PRINTK("Radar found on second segment VHT80 freq=%d MHz\n",
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"Radar found on second segment VHT80 freq=%d MHz",
 				dfs->dfs_precac_secondary_freq);
 	} else {
-		DFS_PRINTK("Radar found on channel %d (%d MHz)\n",
+		dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS,
+				"Radar found on channel %d (%d MHz)",
 				thischan->dfs_ch_ieee, thischan->dfs_ch_freq);
 	}
 
@@ -284,13 +287,13 @@ static inline void dfs_radarfound_reset_vars(
 	dfs_reset_radarq(dfs);
 	dfs_reset_alldelaylines(dfs);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"Primary channel freq = %u flags=0x%x\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"Primary channel freq = %u flags=0x%x",
 			chan->dfs_ch_freq, chan->dfs_ch_flagext);
 
 	if (chan->dfs_ch_freq != thischan->dfs_ch_freq)
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-				"Ext channel freq = %u flags=0x%x\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS1,
+				"Ext channel freq = %u flags=0x%x",
 				thischan->dfs_ch_freq,
 				thischan->dfs_ch_flagext);
 
@@ -320,8 +323,8 @@ static inline int dfs_radarevent_basic_sanity(
 			    ((IEEE80211_IS_CHAN_11AC_VHT160(chan) ||
 			      IEEE80211_IS_CHAN_11AC_VHT80_80(chan)) &&
 			     IEEE80211_IS_CHAN_DFS_CFREQ2(chan)))) {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"%s: radar event on non-DFS chan\n", __func__);
+			dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"radar event on non-DFS chan");
 			dfs_reset_radarq(dfs);
 			dfs_reset_alldelaylines(dfs);
 			dfs->dfs_bangradar = 0;
@@ -353,7 +356,7 @@ static inline int dfs_handle_bangradar(
 		 */
 		*rs = &dfs->dfs_radar[dfs->dfs_curchan_radindex];
 		dfs->dfs_bangradar = 0; /* Reset */
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s: bangradar\n", __func__);
+		dfs_debug(dfs, WLAN_DEBUG_DFS, "bangradar");
 		*retval = 1;
 		return 1;
 	}
@@ -364,16 +367,14 @@ static inline int dfs_handle_bangradar(
 				IEEE80211_IS_CHAN_11AC_VHT80_80(chan)) {
 			dfs->is_radar_found_on_secondary_seg = 1;
 			*rs = &dfs->dfs_radar[dfs->dfs_curchan_radindex];
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-					"%s: second segment bangradar on cfreq = %u\n",
-					__func__,
+			dfs_debug(dfs, WLAN_DEBUG_DFS,
+					"second segment bangradar on cfreq = %u",
 					dfs->dfs_precac_secondary_freq);
 			*retval = 1;
 			*seg_id = SEG_ID_SECONDARY;
 		} else {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-					"%s: Do not process the second segment bangradar\n",
-					__func__);
+			dfs_debug(dfs, WLAN_DEBUG_DFS,
+					"Do not process the second segment bangradar");
 		}
 		dfs->dfs_second_segment_bangradar = 0; /* Reset */
 		return 1;
@@ -396,9 +397,9 @@ static inline void dfs_process_w53_pulses(
 			DFS_MAX_FREQ_SPREAD)
 		dfs->dfs_pri_multiplier = DFS_LARGE_PRI_MULTIPLIER;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"%s: w53_counter=%d, freq_max=%d, freq_min=%d, pri_multiplier=%d\n",
-			__func__, dfs->dfs_phyerr_w53_counter,
+	dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"w53_counter=%d, freq_max=%d, freq_min=%d, pri_multiplier=%d",
+			 dfs->dfs_phyerr_w53_counter,
 			dfs->dfs_phyerr_freq_max, dfs->dfs_phyerr_freq_min,
 			dfs->dfs_pri_multiplier);
 
@@ -436,8 +437,8 @@ static inline int dfs_handle_missing_pulses(
 			return 0;
 	}
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1, "%s: pri_multiplier=%d\n",
-			__func__, dfs->dfs_pri_multiplier);
+	dfs_debug(dfs, WLAN_DEBUG_DFS1, "pri_multiplier=%d",
+			 dfs->dfs_pri_multiplier);
 
 	return 1;
 }
@@ -546,8 +547,8 @@ static inline void dfs_check_if_nonbin5(
 	struct dfs_filtertype *ft;
 	uint64_t deltaT;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"  *** chan freq (%d): ts %llu dur %u rssi %u\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"  *** chan freq (%d): ts %llu dur %u rssi %u",
 			(*rs)->rs_chan.dfs_ch_freq, (uint64_t)this_ts,
 			(*re).re_dur, (*re).re_rssi);
 
@@ -556,23 +557,23 @@ static inline void dfs_check_if_nonbin5(
 			 -1) && (!*retval)) {
 		ft = dfs->dfs_radarf[((dfs->dfs_ftindextable[(*re).re_dur])
 				[tabledepth])];
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"  ** RD (%d): ts %x dur %u rssi %u\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"  ** RD (%d): ts %x dur %u rssi %u",
 				(*rs)->rs_chan.dfs_ch_freq, (*re).re_ts,
 				(*re).re_dur, (*re).re_rssi);
 
 		if ((*re).re_rssi < ft->ft_rssithresh &&
 				(*re).re_dur > MAX_DUR_FOR_LOW_RSSI) {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-					"%s : Rejecting on rssi rssi=%u thresh=%u\n",
-					__func__, (*re).re_rssi,
+			dfs_debug(dfs, WLAN_DEBUG_DFS2,
+					"Rejecting on rssi rssi=%u thresh=%u",
+					 (*re).re_rssi,
 					ft->ft_rssithresh);
 			tabledepth++;
 			continue;
 		}
 		deltaT = this_ts - ft->ft_last_ts;
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"deltaT = %lld (ts: 0x%llx) (last ts: 0x%llx)\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"deltaT = %lld (ts: 0x%llx) (last ts: 0x%llx)",
 				(uint64_t)deltaT, (uint64_t)this_ts,
 				(uint64_t)ft->ft_last_ts);
 
@@ -582,10 +583,9 @@ static inline void dfs_check_if_nonbin5(
 			 * Individual filters will check this again.
 			 * This is first line of filtering.
 			 */
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-					"%s: Rejecting on pri pri=%lld minpri=%u\n",
-					__func__, (uint64_t)deltaT,
-					ft->ft_minpri);
+			dfs_debug(dfs, WLAN_DEBUG_DFS2,
+					"Rejecting on pri pri=%lld minpri=%u",
+					 (uint64_t)deltaT, ft->ft_minpri);
 			tabledepth++;
 			continue;
 		}
@@ -632,9 +632,8 @@ static inline void dfs_check_each_b5radar(
 		if (dfs_bin5_addpulse(dfs, br, re, this_ts))
 			*found |= dfs_bin5_check(dfs);
 	} else {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_BIN5_PULSE,
-				"%s not a BIN5 pulse (dur=%d)\n",
-				__func__, (*re).re_dur);
+		dfs_debug(dfs, WLAN_DEBUG_DFS_BIN5_PULSE,
+				"not a BIN5 pulse (dur=%d)", (*re).re_dur);
 	}
 }
 
@@ -669,8 +668,7 @@ static inline void dfs_check_if_bin5(
 	}
 
 	if (*found)
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-				"%s: Found bin5 radar\n", __func__);
+		dfs_debug(dfs, WLAN_DEBUG_DFS, "Found bin5 radar");
 }
 
 /**
@@ -789,8 +787,7 @@ static inline void  dfs_calculate_timestamps(
 		if ((*re).re_dur == 0 && (*re).re_ts ==
 				dfs->dfs_rinfo.rn_last_unique_ts) {
 			debug_dup[debug_dup_cnt++] = '1';
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-					"\n %s deltaT is 0\n", __func__);
+			dfs_debug(dfs, WLAN_DEBUG_DFS1, "deltaT is 0");
 		} else {
 			dfs->dfs_rinfo.rn_last_unique_ts = (*re).re_ts;
 			debug_dup[debug_dup_cnt++] = '0';
@@ -872,8 +869,8 @@ static inline void dfs_add_to_pulseline(
 	*diff_ts = (uint32_t)*this_ts - *test_ts;
 	*test_ts = (uint32_t)*this_ts;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"ts%u %u %u diff %u pl->pl_lastelem.p_time=%llu\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"ts%u %u %u diff %u pl->pl_lastelem.p_time=%llu",
 			(uint32_t)*this_ts, (*re).re_dur,
 			(*re).re_rssi, *diff_ts,
 			(uint64_t)pl->pl_elems[index].p_time);
@@ -926,7 +923,7 @@ static inline int dfs_process_each_radarevent(
 
 	while ((!empty) && (!*retval) && (events_processed < MAX_EVENTS)) {
 		dfs_remove_event_from_radarq(dfs, &event);
-		if (event == NULL) {
+		if (!event) {
 			empty = 1;
 			break;
 		}

+ 13 - 18
umac/dfs/core/src/filtering/dfs_radar.c

@@ -280,8 +280,6 @@ void ol_if_dfs_configure(struct wlan_dfs *dfs)
 	uint32_t target_type;
 	int dfsdomain = DFS_FCC_DOMAIN;
 
-	DFS_PRINTK(KERN_DEBUG"%s: called\n", __func__);
-
 	/* Fetch current radar patterns from the lmac */
 	qdf_mem_zero(&rinfo, sizeof(rinfo));
 
@@ -294,14 +292,14 @@ void ol_if_dfs_configure(struct wlan_dfs *dfs)
 
 	psoc = wlan_pdev_get_psoc(dfs->dfs_pdev_obj);
 	if (!psoc) {
-		DFS_PRINTK("%s: PSOC is NULL\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "psoc is NULL");
 		return;
 	}
 
 	tx_ops = &(psoc->soc_cb.tx_ops.target_tx_ops);
 	switch (dfsdomain) {
 	case DFS_FCC_DOMAIN:
-		DFS_PRINTK("%s: FCC domain\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "FCC domain");
 		rinfo.dfsdomain = DFS_FCC_DOMAIN;
 		/*
 		 * China uses a radar pattern that is similar to ETSI but it
@@ -309,9 +307,9 @@ void ol_if_dfs_configure(struct wlan_dfs *dfs)
 		 * threshold etc.
 		 */
 		if (lmac_is_countryCode_CHINA(dfs->dfs_pdev_obj)) {
-			DFS_PRINTK(
-					"%s: FCC domain -- Country China(156) override FCC radar pattern\n",
-					__func__);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"FCC domain -- Country China(156) override FCC radar pattern"
+					);
 			rinfo.dfs_radars = dfs_china_radars;
 			rinfo.numradars = QDF_ARRAY_SIZE(dfs_china_radars);
 			rinfo.b5pulses = NULL;
@@ -322,7 +320,7 @@ void ol_if_dfs_configure(struct wlan_dfs *dfs)
 
 		break;
 	case DFS_ETSI_DOMAIN:
-		DFS_PRINTK("%s: ETSI domain\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "ETSI domain");
 		rinfo.dfsdomain = DFS_ETSI_DOMAIN;
 		rinfo.dfs_radars = dfs_etsi_radars;
 		rinfo.numradars = QDF_ARRAY_SIZE(dfs_etsi_radars);
@@ -337,9 +335,7 @@ void ol_if_dfs_configure(struct wlan_dfs *dfs)
 		 */
 
 		if (lmac_is_countryCode_KOREA_ROC3(dfs->dfs_pdev_obj)) {
-			DFS_PRINTK(
-					"%s: ETSI domain -- Korea(412)\n",
-					__func__);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "ETSI domain -- Korea(412)");
 			rinfo.dfs_radars = dfs_korea_radars;
 			rinfo.numradars = QDF_ARRAY_SIZE(dfs_korea_radars);
 		}
@@ -348,7 +344,7 @@ void ol_if_dfs_configure(struct wlan_dfs *dfs)
 		rinfo.numb5radars = 0;
 		break;
 	case DFS_MKK4_DOMAIN:
-		DFS_PRINTK("%s: MKK4 domain\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "MKK4 domain");
 		rinfo.dfsdomain = DFS_MKK4_DOMAIN;
 		rinfo.dfs_radars = dfs_mkk4_radars;
 		rinfo.numradars = QDF_ARRAY_SIZE(dfs_mkk4_radars);
@@ -370,7 +366,7 @@ void ol_if_dfs_configure(struct wlan_dfs *dfs)
 		}
 		break;
 	default:
-		DFS_PRINTK("%s: UNINIT domain\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "UNINIT domain");
 		rinfo.dfsdomain = DFS_UNINIT_DOMAIN;
 		rinfo.dfs_radars = NULL;
 		rinfo.numradars = 0;
@@ -438,8 +434,8 @@ void dfs_get_radars(struct wlan_dfs *dfs)
 #define AR9300_DEVID_AR956X_PCIE    0x0036 /* Aphrodite: 1x1 DB + BT - AR9564 */
 #define AR9300_DEVID_EMU_PCIE       0xabcd
 
-	if (dfs == NULL) {
-		DFS_PRINTK("%s: dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -503,9 +499,8 @@ void dfs_radar_found_action(struct wlan_dfs *dfs)
 		 * Otherwise random channel selection can choose this
 		 * channel.
 		 */
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-				"%s : found_on_second = %d is_pre = %d\n",
-				__func__,
+		dfs_debug(dfs, WLAN_DEBUG_DFS,
+				"found_on_second = %d is_pre = %d",
 				dfs->is_radar_found_on_secondary_seg,
 				dfs_is_precac_timer_running(dfs));
 

+ 20 - 20
umac/dfs/core/src/filtering/dfs_staggered.c

@@ -91,15 +91,15 @@ int dfs_staggered_check(struct wlan_dfs *dfs, struct dfs_filter *rf,
 
 	dl = &rf->rf_dl;
 	if (dl->dl_numelems < (rf->rf_threshold-1)) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"numelems %d < threshold for filter %d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"numelems %d < threshold for filter %d",
 				dl->dl_numelems,
 				rf->rf_pulseid);
 		return 0;
 	}
 	if (deltaT > rf->rf_filterlen) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"numelems %d < threshold for filter %d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"numelems %d < threshold for filter %d",
 				dl->dl_numelems,
 				rf->rf_pulseid);
 		return 0;
@@ -147,8 +147,8 @@ int dfs_staggered_check(struct wlan_dfs *dfs, struct dfs_filter *rf,
 	for (n = 0; n < dl->dl_numelems; n++) {
 		delayindex = (dl->dl_firstelem + n) & DFS_MAX_DL_MASK;
 		refdur = dl->dl_elems[delayindex].de_time;
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"score[%d]=%d pri=%d\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"score[%d]=%d pri=%d",
 				n, score[n], refdur);
 	}
 
@@ -197,24 +197,24 @@ int dfs_staggered_check(struct wlan_dfs *dfs, struct dfs_filter *rf,
 	if (midscore == 0)
 		return 0;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"FINAL highestscore=%d highestscoreindex = %d highestpri = %d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"FINAL highestscore=%d highestscoreindex = %d highestpri = %d",
 			highestscore, highestscoreindex, highestpri);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"FINAL lowestscore=%d lowestscoreindex=%d lowpri=%d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"FINAL lowestscore=%d lowestscoreindex=%d lowpri=%d",
 			lowestscore, lowestscoreindex, lowestpri);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"FINAL midscore=%d midscoreindex=%d midpri=%d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"FINAL midscore=%d midscoreindex=%d midpri=%d",
 			midscore, midscoreindex, midpri);
 
 	delayindex = (dl->dl_firstelem + highestscoreindex) & DFS_MAX_DL_MASK;
 	refdur = dl->dl_elems[delayindex].de_dur;
 	refpri = dl->dl_elems[delayindex].de_time;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"highscoreindex=%d refdur=%d refpri=%d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"highscoreindex=%d refdur=%d refpri=%d",
 			highestscoreindex, refdur, refpri);
 
 	numpulsestemp = dfs_bin_pri_check(dfs, rf, dl, highestscore, refpri,
@@ -233,8 +233,8 @@ int dfs_staggered_check(struct wlan_dfs *dfs, struct dfs_filter *rf,
 	delayindex = (dl->dl_firstelem + midscoreindex) & DFS_MAX_DL_MASK;
 	refdur = dl->dl_elems[delayindex].de_dur;
 	refpri = dl->dl_elems[delayindex].de_time;
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-			"midscoreindex=%d refdur=%d refpri=%d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS1,
+			"midscoreindex=%d refdur=%d refpri=%d",
 			midscoreindex, refdur, refpri);
 
 	numpulsestemp = dfs_bin_pri_check(dfs, rf, dl, midscore, refpri, refdur,
@@ -249,15 +249,15 @@ int dfs_staggered_check(struct wlan_dfs *dfs, struct dfs_filter *rf,
 	if (numpulsestemp > numpulsesmid)
 		numpulsesmid = numpulsestemp;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-			"numpulseshigh=%d, numpulsesmid=%d\n",
+	dfs_debug(dfs, WLAN_DEBUG_DFS2,
+			"numpulseshigh=%d, numpulsesmid=%d",
 			numpulseshigh, numpulsesmid);
 
 	if ((numpulseshigh >= rf->rf_threshold) &&
 			(numpulsesmid >= rf->rf_threshold)) {
 		found = 1;
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"MATCH filter=%u numpulseshigh=%u numpulsesmid= %u thresh=%u\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"MATCH filter=%u numpulseshigh=%u numpulsesmid= %u thresh=%u",
 				rf->rf_pulseid, numpulseshigh,
 				numpulsesmid, rf->rf_threshold);
 	}

+ 108 - 111
umac/dfs/core/src/misc/dfs.c

@@ -52,8 +52,8 @@ static os_timer_func(dfs_task)
 
 	OS_GET_TIMER_ARG(dfs, struct wlan_dfs *);
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s: dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -81,8 +81,9 @@ static os_timer_func(dfs_testtimer_task)
 	 * Flip the channel back to the original channel.
 	 * Make sure this is done properly with a CSA.
 	 */
-	DFS_PRINTK("%s: go back to channel %d\n", __func__,
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "go back to channel %d",
 			dfs->wlan_dfstest_ieeechan);
+
 	dfs_mlme_start_csa(dfs->dfs_pdev_obj, dfs->wlan_dfstest_ieeechan);
 }
 
@@ -112,8 +113,8 @@ void dfs_main_timer_init(struct wlan_dfs *dfs)
 int dfs_create_object(struct wlan_dfs **dfs)
 {
 	*dfs = (struct wlan_dfs *)qdf_mem_malloc(sizeof(**dfs));
-	if (*dfs == NULL) {
-		DFS_PRINTK("%s: wlan_dfs allocation failed\n", __func__);
+	if (!(*dfs)) {
+		dfs_alert(*dfs, WLAN_DEBUG_DFS_ALWAYS, "wlan_dfs allocation failed");
 		return 1;
 	}
 
@@ -122,8 +123,8 @@ int dfs_create_object(struct wlan_dfs **dfs)
 	(*dfs)->dfs_curchan = (struct dfs_ieee80211_channel *)qdf_mem_malloc(
 			sizeof(struct dfs_ieee80211_channel));
 
-	if ((*dfs)->dfs_curchan == NULL) {
-		DFS_PRINTK("%s: dfs_curchan allocation failed\n", __func__);
+	if (!((*dfs)->dfs_curchan)) {
+		dfs_alert(*dfs, WLAN_DEBUG_DFS_ALWAYS, "dfs_curchan allocation failed");
 		return 1;
 	}
 
@@ -139,16 +140,14 @@ int dfs_main_attach(struct wlan_dfs *dfs)
 	bool chip_is_false_detect;
 	uint32_t fastdiv_val;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-				"%s: dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return 0;
 	}
 
 	/* If ignore_dfs is set to 1 then Radar detection is disabled. */
 	if (dfs->dfs_ignore_dfs) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-				"%s: ignoring dfs\n", __func__);
+		dfs_debug(dfs, WLAN_DEBUG_DFS1, "ignoring dfs");
 		return 0;
 	}
 
@@ -183,7 +182,7 @@ int dfs_main_attach(struct wlan_dfs *dfs)
 
 	dfs_clear_stats(dfs);
 	dfs->dfs_event_log_on = 1;
-	DFS_PRINTK("%s: event log enabled by default\n", __func__);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "event log enabled by default");
 
 	dfs->dfs_enable = 1;
 
@@ -199,9 +198,8 @@ int dfs_main_attach(struct wlan_dfs *dfs)
 
 	dfs->events = (struct dfs_event *)qdf_mem_malloc(
 			sizeof(struct dfs_event)*DFS_MAX_EVENTS);
-	if (dfs->events == NULL) {
-		qdf_mem_free(dfs);
-		DFS_PRINTK("%s: events allocation failed\n", __func__);
+	if (!(dfs->events)) {
+		dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS, "events allocation failed");
 		return 1;
 	}
 	for (i = 0; i < DFS_MAX_EVENTS; i++)
@@ -210,10 +208,10 @@ int dfs_main_attach(struct wlan_dfs *dfs)
 
 	dfs->pulses = (struct dfs_pulseline *)qdf_mem_malloc(
 			sizeof(struct dfs_pulseline));
-	if (dfs->pulses == NULL) {
+	if (!(dfs->pulses)) {
 		qdf_mem_free(dfs->events);
 		dfs->events = NULL;
-		DFS_PRINTK("%s: Pulse buffer allocation failed\n", __func__);
+		dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS, "Pulse buffer allocation failed");
 		return 1;
 	}
 
@@ -223,10 +221,9 @@ int dfs_main_attach(struct wlan_dfs *dfs)
 	for (n = 0; n < DFS_MAX_RADAR_TYPES; n++) {
 		dfs->dfs_radarf[n] = (struct dfs_filtertype *)
 			qdf_mem_malloc(sizeof(struct dfs_filtertype));
-		if (dfs->dfs_radarf[n] == NULL) {
-			DFS_PRINTK(
-					"%s: cannot allocate memory for radar filter types\n",
-					__func__);
+		if (!(dfs->dfs_radarf[n])) {
+			dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"cannot allocate memory for radar filter types");
 			goto bad1;
 		}
 		qdf_mem_zero(dfs->dfs_radarf[n], sizeof(struct dfs_filtertype));
@@ -234,27 +231,24 @@ int dfs_main_attach(struct wlan_dfs *dfs)
 
 	/* Allocate memory for radar table. */
 	dfs->dfs_ftindextable = (int8_t **)qdf_mem_malloc(256*sizeof(int8_t *));
-	if (dfs->dfs_ftindextable == NULL) {
-		DFS_PRINTK(
-				"%s: Cannot allocate memory for radar table\n",
-				__func__);
+	if (!(dfs->dfs_ftindextable)) {
+		dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS, "Cannot allocate memory for radar table");
 		goto bad1;
 	}
 	for (n = 0; n < 256; n++) {
 		dfs->dfs_ftindextable[n] = qdf_mem_malloc(
 				DFS_MAX_RADAR_OVERLAP*sizeof(int8_t));
-		if (dfs->dfs_ftindextable[n] == NULL) {
-			DFS_PRINTK(
-					"%s: cannot allocate memory for radar table entry\n",
-					__func__);
+		if (!(dfs->dfs_ftindextable[n])) {
+			dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"cannot allocate memory for radar table entry");
 			goto bad2;
 		}
 	}
 
 	if (usenol == 0)
-		DFS_PRINTK("%s: NOL disabled\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "NOL disabled");
 	else if (usenol == 2)
-		DFS_PRINTK("%s: NOL disabled; no CSA\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "NOL disabled; no CSA");
 
 	dfs->dfs_rinfo.rn_use_nol = usenol;
 
@@ -272,9 +266,7 @@ int dfs_main_attach(struct wlan_dfs *dfs)
 	 * is available.
 	 */
 	if (dfs_init_radar_filters(dfs, &radar_info)) {
-		DFS_PRINTK(
-				"%s: Radar Filter Intialization Failed\n",
-				__func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "Radar Filter Intialization Failed");
 		return 1;
 	}
 
@@ -318,7 +310,7 @@ int dfs_attach(struct wlan_dfs *dfs)
 	if (!dfs->dfs_is_offload_enabled) {
 		ret = dfs_main_attach(dfs);
 		if (ret) {
-			DFS_PRINTK("%s: dfs_main_attach failed\n", __func__);
+			dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs_main_attach failed");
 			return ret;
 		}
 	}
@@ -350,9 +342,8 @@ void dfs_main_timer_reset(struct wlan_dfs *dfs)
 
 void dfs_reset(struct wlan_dfs *dfs)
 {
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-				"%s: sc_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -464,8 +455,8 @@ struct dfs_state *dfs_getchanstate(struct wlan_dfs *dfs, uint8_t *index,
 	int i;
 	QDF_STATUS err;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s: dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return NULL;
 	}
 
@@ -480,16 +471,16 @@ struct dfs_state *dfs_getchanstate(struct wlan_dfs *dfs, uint8_t *index,
 				&(cmp_ch->dfs_ch_vhtop_ch_freq_seg2));
 
 		if (err == QDF_STATUS_SUCCESS) {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-					"Extension channel freq = %u flags=0x%x\n",
+			dfs_debug(dfs, WLAN_DEBUG_DFS2,
+					"Extension channel freq = %u flags=0x%x",
 					cmp_ch->dfs_ch_freq,
 					cmp_ch->dfs_ch_flagext);
 		} else
 			return NULL;
 	} else {
 		cmp_ch = dfs->dfs_curchan;
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-				"Primary channel freq = %u flags=0x%x\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS2,
+				"Primary channel freq = %u flags=0x%x",
 				cmp_ch->dfs_ch_freq, cmp_ch->dfs_ch_flagext);
 	}
 
@@ -521,8 +512,7 @@ struct dfs_state *dfs_getchanstate(struct wlan_dfs *dfs, uint8_t *index,
 			return rs;
 		}
 	}
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS2,
-			"%s: No more radar states left.\n", __func__);
+	dfs_debug(dfs, WLAN_DEBUG_DFS2, "No more radar states left.");
 
 	return NULL;
 }
@@ -534,9 +524,8 @@ void dfs_radar_enable(struct wlan_dfs *dfs, int no_cac, uint32_t opmode)
 	struct dfs_ieee80211_channel *ext_ch, extchan;
 	QDF_STATUS err = QDF_STATUS_E_FAILURE;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-				"%s: dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -593,9 +582,9 @@ void dfs_radar_enable(struct wlan_dfs *dfs, int no_cac, uint32_t opmode)
 				dfs->dfs_extchan_radindex = (int16_t)index_ext;
 
 			dfs_phyerr_param_copy(&pe, &rs_pri->rs_param);
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS3,
-					"%s: firpwr=%d, rssi=%d, height=%d, prssi=%d, inband=%d, relpwr=%d, relstep=%d, maxlen=%d\n",
-					__func__, pe.pe_firpwr,
+			dfs_debug(dfs, WLAN_DEBUG_DFS3,
+					"firpwr=%d, rssi=%d, height=%d, prssi=%d, inband=%d, relpwr=%d, relstep=%d, maxlen=%d",
+					 pe.pe_firpwr,
 					pe.pe_rrssi, pe.pe_height,
 					pe.pe_prssi, pe.pe_inband,
 					pe.pe_relpwr, pe.pe_relstep,
@@ -611,21 +600,20 @@ void dfs_radar_enable(struct wlan_dfs *dfs, int no_cac, uint32_t opmode)
 					pe.pe_relstep,
 					pe.pe_maxlen,
 					dfs->dfsdomain);
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-					"Enabled radar detection on channel %d\n",
+			dfs_debug(dfs, WLAN_DEBUG_DFS,
+					"Enabled radar detection on channel %d",
 					dfs->dfs_curchan->dfs_ch_freq);
 
 			dfs->dur_multiplier = is_fastclk ?
 				DFS_FAST_CLOCK_MULTIPLIER :
 				DFS_NO_FAST_CLOCK_MULTIPLIER;
 
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS3,
-					"%s: duration multiplier is %d\n",
-					__func__, dfs->dur_multiplier);
+			dfs_debug(dfs, WLAN_DEBUG_DFS3,
+					"duration multiplier is %d",
+					 dfs->dur_multiplier);
 		} else
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-					"%s: No more radar states left\n",
-					__func__);
+			dfs_debug(dfs, WLAN_DEBUG_DFS,
+					"No more radar states left");
 	}
 }
 
@@ -644,8 +632,9 @@ int dfs_control(struct wlan_dfs *dfs,
 	uint32_t *data = NULL;
 	int i;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1, "%s DFS is null\n", __func__);
+	/* dfs is dereferenced (dfs->dfs_ignore_dfs) when dfs is NULL */
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		/*
 		 * Enable/Disable DFS can be done prior to attach,
 		 * So handle here.
@@ -653,15 +642,13 @@ int dfs_control(struct wlan_dfs *dfs,
 		switch (id) {
 		case DFS_DISABLE_DETECT:
 			dfs->dfs_ignore_dfs = 1;
-			DFS_PRINTK(
-					"%s enable detects, ignore_dfs %d\n",
-					__func__, dfs->dfs_ignore_dfs ? 1:0);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "enable detects, ignore_dfs %d",
+					dfs->dfs_ignore_dfs ? 1:0);
 			break;
 		case DFS_ENABLE_DETECT:
 			dfs->dfs_ignore_dfs = 0;
-			DFS_PRINTK(
-					"%s enable detects, ignore_dfs %d\n",
-					__func__, dfs->dfs_ignore_dfs ? 1:0);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "enable detects, ignore_dfs %d",
+					dfs->dfs_ignore_dfs ? 1:0);
 			break;
 		default:
 			error = -EINVAL;
@@ -673,9 +660,9 @@ int dfs_control(struct wlan_dfs *dfs,
 	switch (id) {
 	case DFS_SET_THRESH:
 		if (insize < sizeof(struct dfs_ioctl_params) || !indata) {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-					"%s: insize = %d, expected = %zu bytes, indata = %pK\n",
-					__func__, insize,
+			dfs_debug(dfs, WLAN_DEBUG_DFS1,
+					"insize = %d, expected = %zu bytes, indata = %p",
+					insize,
 					sizeof(struct dfs_ioctl_params),
 					indata);
 			error = -EINVAL;
@@ -736,21 +723,25 @@ int dfs_control(struct wlan_dfs *dfs,
 		dfs->dfs_proc_phyerr &= ~DFS_RADAR_EN;
 		dfs->dfs_proc_phyerr &= ~DFS_SECOND_SEGMENT_RADAR_EN;
 		dfs->dfs_ignore_dfs = 1;
-		DFS_PRINTK("%s enable detects, ignore_dfs %d\n", __func__,
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"enable detects, ignore_dfs %d",
 				dfs->dfs_ignore_dfs ? 1:0);
 		break;
 	case DFS_ENABLE_DETECT:
 		dfs->dfs_proc_phyerr |= DFS_RADAR_EN;
 		dfs->dfs_proc_phyerr |= DFS_SECOND_SEGMENT_RADAR_EN;
 		dfs->dfs_ignore_dfs = 0;
-		DFS_PRINTK("%s enable detects, ignore_dfs %d\n", __func__,
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS
+				, "enable detects, ignore_dfs %d",
 				dfs->dfs_ignore_dfs ? 1:0);
 		break;
 	case DFS_DISABLE_FFT:
-		DFS_PRINTK("%s TODO disable FFT val=0x%x\n", __func__, val);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"TODO disable FFT val=0x%x", val);
 		break;
 	case DFS_ENABLE_FFT:
-		DFS_PRINTK("%s TODO enable FFT val=0x%x\n", __func__, val);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"TODO enable FFT val=0x%x", val);
 		break;
 	case DFS_SET_DEBUG_LEVEL:
 		if (insize < sizeof(uint32_t) || !indata) {
@@ -758,8 +749,15 @@ int dfs_control(struct wlan_dfs *dfs,
 			break;
 		}
 		dfs->dfs_debug_mask = *(uint32_t *)indata;
-		DFS_PRINTK("%s debug level now = 0x%x\n", __func__,
-				dfs->dfs_debug_mask);
+
+		/* Do not allow user to set the ALWAYS/MAX bit.
+		 * It will be used internally  by dfs print macro(s)
+		 * to print messages when dfs is NULL.
+		 */
+		dfs->dfs_debug_mask &= ~(WLAN_DEBUG_DFS_ALWAYS);
+
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"debug level now = 0x%x", dfs->dfs_debug_mask);
 		if (dfs->dfs_debug_mask & WLAN_DEBUG_DFS3) {
 			/* Enable debug Radar Event */
 			dfs->dfs_event_log_on = 1;
@@ -773,7 +771,8 @@ int dfs_control(struct wlan_dfs *dfs,
 			break;
 		}
 		dfs->wlan_dfs_false_rssi_thres = *(uint32_t *)indata;
-		DFS_PRINTK("%s false RSSI threshold now = 0x%x\n", __func__,
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"false RSSI threshold now = 0x%x",
 				dfs->wlan_dfs_false_rssi_thres);
 		break;
 	case DFS_SET_PEAK_MAG:
@@ -782,7 +781,8 @@ int dfs_control(struct wlan_dfs *dfs,
 			break;
 		}
 		dfs->wlan_dfs_peak_mag = *(uint32_t *)indata;
-		DFS_PRINTK("%s peak_mag now = 0x%x\n", __func__,
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"peak_mag now = 0x%x",
 				dfs->wlan_dfs_peak_mag);
 		break;
 	case DFS_GET_CAC_VALID_TIME:
@@ -799,8 +799,8 @@ int dfs_control(struct wlan_dfs *dfs,
 			break;
 		}
 		dfs->dfs_cac_valid_time = *(uint32_t *)indata;
-		DFS_PRINTK("%s dfs timeout = %d\n", __func__,
-				dfs->dfs_cac_valid_time);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"dfs timeout = %d", dfs->dfs_cac_valid_time);
 		break;
 	case DFS_IGNORE_CAC:
 		if (insize < sizeof(uint32_t) || !indata) {
@@ -813,8 +813,8 @@ int dfs_control(struct wlan_dfs *dfs,
 		else
 			dfs->dfs_ignore_cac = 0;
 
-		DFS_PRINTK("%s ignore cac = 0x%x\n", __func__,
-				dfs->dfs_ignore_cac);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"ignore cac = 0x%x", dfs->dfs_ignore_cac);
 		break;
 	case DFS_SET_NOL_TIMEOUT:
 		if (insize < sizeof(uint32_t) || !indata) {
@@ -826,7 +826,7 @@ int dfs_control(struct wlan_dfs *dfs,
 		else
 			dfs->wlan_dfs_nol_timeout = DFS_NOL_TIMEOUT_S;
 
-		DFS_PRINTK("%s nol timeout = %d sec\n", __func__,
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "nol timeout = %d sec",
 				dfs->wlan_dfs_nol_timeout);
 		break;
 	case DFS_MUTE_TIME:
@@ -846,25 +846,25 @@ int dfs_control(struct wlan_dfs *dfs,
 		*outsize = sizeof(uint32_t);
 		*((uint32_t *)outdata) = dfs->dfs_rinfo.rn_use_nol;
 
-		DFS_PRINTK(
-				"%s:#Phyerr=%d, #false detect=%d, #queued=%d\n",
-				__func__, dfs->dfs_phyerr_count,
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"#Phyerr=%d, #false detect=%d, #queued=%d",
+				 dfs->dfs_phyerr_count,
 				dfs->dfs_phyerr_reject_count,
 				dfs->dfs_phyerr_queued_count);
 
-		DFS_PRINTK(
-				"%s:dfs_phyerr_freq_min=%d, dfs_phyerr_freq_max=%d\n",
-				__func__, dfs->dfs_phyerr_freq_min,
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"dfs_phyerr_freq_min=%d, dfs_phyerr_freq_max=%d",
+				 dfs->dfs_phyerr_freq_min,
 				dfs->dfs_phyerr_freq_max);
 
-		DFS_PRINTK(
-				"%s:Total radar events detected=%d, entries in the radar queue follows:\n",
-				__func__, dfs->dfs_event_log_count);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"Total radar events detected=%d, entries in the radar queue follows:",
+				 dfs->dfs_event_log_count);
 
 		for (i = 0; (i < DFS_EVENT_LOG_SIZE) &&
 				(i < dfs->dfs_event_log_count); i++) {
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			    "ts=%llu diff_ts=%u rssi=%u dur=%u, is_chirp=%d, seg_id=%d, sidx=%d, freq_offset=%d.%dMHz, peak_mag=%d, total_gain=%d, mb_gain=%d, relpwr_db=%d\n",
+			dfs_debug(dfs, WLAN_DEBUG_DFS,
+			    "ts=%llu diff_ts=%u rssi=%u dur=%u, is_chirp=%d, seg_id=%d, sidx=%d, freq_offset=%d.%dMHz, peak_mag=%d, total_gain=%d, mb_gain=%d, relpwr_db=%d",
 			    dfs->radar_log[i].ts,
 			    dfs->radar_log[i].diff_ts,
 			    dfs->radar_log[i].rssi,
@@ -961,23 +961,21 @@ int dfs_set_thresholds(struct wlan_dfs *dfs, const uint32_t threshtype,
 	struct wlan_dfs_phyerr_param pe;
 	int is_fastclk = 0;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-				"%s: dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return 0;
 	}
 
 	chanindex = dfs->dfs_curchan_radindex;
 	if ((chanindex < 0) || (chanindex >= DFS_NUM_RADAR_STATES)) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-				"%s: chanindex = %d, DFS_NUM_RADAR_STATES=%d\n",
-				__func__, chanindex, DFS_NUM_RADAR_STATES);
+		dfs_debug(dfs, WLAN_DEBUG_DFS1,
+				"chanindex = %d, DFS_NUM_RADAR_STATES=%d",
+				 chanindex, DFS_NUM_RADAR_STATES);
 		return 0;
 	}
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			"%s: threshtype=%d, value=%d\n",
-			__func__, threshtype, value);
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+			"threshtype=%d, value=%d", threshtype, value);
 
 	wlan_dfs_phyerr_init_noval(&pe);
 
@@ -1017,9 +1015,8 @@ int dfs_set_thresholds(struct wlan_dfs *dfs, const uint32_t threshtype,
 		pe.pe_maxlen = value;
 		break;
 	default:
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS1,
-				"%s: unknown threshtype (%d)\n",
-				__func__, threshtype);
+		dfs_debug(dfs, WLAN_DEBUG_DFS1,
+				"unknown threshtype (%d)", threshtype);
 		break;
 	}
 
@@ -1068,8 +1065,8 @@ void dfs_set_current_channel(struct wlan_dfs *dfs,
 		uint8_t dfs_ch_vhtop_ch_freq_seg1,
 		uint8_t dfs_ch_vhtop_ch_freq_seg2)
 {
-	if (dfs == NULL) {
-		DFS_PRINTK("%s: wlan_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -1083,7 +1080,7 @@ void dfs_set_current_channel(struct wlan_dfs *dfs,
 
 u_int dfs_ieee80211_chan2freq(struct dfs_ieee80211_channel *chan)
 {
-	if (chan == NULL)
+	if (!chan)
 		return 0;
 
 	return chan == IEEE80211_CHAN_ANYC ?

+ 38 - 38
umac/dfs/core/src/misc/dfs_cac.c

@@ -41,11 +41,11 @@
 
 int dfs_override_cac_timeout(struct wlan_dfs *dfs, int cac_timeout)
 {
-	if (dfs == NULL)
+	if (!dfs)
 		return -EIO;
 
 	dfs->dfs_cac_timeout_override = cac_timeout;
-	DFS_PRINTK("%s: CAC timeout is now %s %d\n", __func__,
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "CAC timeout is now %s %d",
 		(cac_timeout == -1) ? "default" : "overridden",
 		cac_timeout);
 
@@ -54,7 +54,7 @@ int dfs_override_cac_timeout(struct wlan_dfs *dfs, int cac_timeout)
 
 int dfs_get_override_cac_timeout(struct wlan_dfs *dfs, int *cac_timeout)
 {
-	if (dfs == NULL)
+	if (!dfs)
 		return -EIO;
 
 	(*cac_timeout) = dfs->dfs_cac_timeout_override;
@@ -69,9 +69,9 @@ void dfs_cac_valid_reset(struct wlan_dfs *dfs,
 	if (dfs->dfs_cac_valid_time) {
 		if ((prevchan_ieee != dfs->dfs_curchan->dfs_ch_ieee) ||
 			(prevchan_flags != dfs->dfs_curchan->dfs_ch_flags)) {
-			DFS_PRINTK(
-				"%s : Cancelling timer & clearing cac_valid\n",
-				__func__);
+			dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"Cancelling timer & clearing cac_valid"
+					);
 			qdf_timer_stop(&dfs->dfs_cac_valid_timer);
 			dfs->dfs_cac_valid = 0;
 		}
@@ -103,7 +103,7 @@ static os_timer_func(dfs_cac_valid_timeout)
 
 	OS_GET_TIMER_ARG(dfs, struct wlan_dfs *);
 	dfs->dfs_cac_valid = 0;
-	DFS_PRINTK("%s : Timed out!!\n", __func__);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, ": Timed out!!");
 }
 
 /**
@@ -118,7 +118,7 @@ static os_timer_func(dfs_cac_timeout)
 	OS_GET_TIMER_ARG(dfs, struct wlan_dfs *);
 	dfs->dfs_cac_timer_running = 0;
 
-	DFS_PRINTK("%s cac expired, chan %d curr time %d\n", __func__,
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "cac expired, chan %d curr time %d",
 		dfs->dfs_curchan->dfs_ch_freq,
 		(qdf_system_ticks_to_msecs(qdf_system_ticks()) / 1000));
 	/*
@@ -131,13 +131,13 @@ static os_timer_func(dfs_cac_timeout)
 				dfs->dfs_curchan->dfs_ch_freq,
 				dfs->dfs_curchan->dfs_ch_vhtop_ch_freq_seg2,
 				dfs->dfs_curchan->dfs_ch_flags);
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			"CAC timer on channel %u (%u MHz) stopped due to radar\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS,
+			"CAC timer on channel %u (%u MHz) stopped due to radar",
 			dfs->dfs_curchan->dfs_ch_ieee,
 			dfs->dfs_curchan->dfs_ch_freq);
 	} else {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			"CAC timer on channel %u (%u MHz) expired; no radar detected\n",
+		dfs_debug(dfs, WLAN_DEBUG_DFS,
+			"CAC timer on channel %u (%u MHz) expired; no radar detected",
 			dfs->dfs_curchan->dfs_ch_ieee,
 			dfs->dfs_curchan->dfs_ch_freq);
 
@@ -219,9 +219,9 @@ void dfs_cac_stop(struct wlan_dfs *dfs)
 	uint32_t phyerr;
 
 	dfs_get_debug_info(dfs, (void *)&phyerr);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : Stopping CAC Timer %d procphyerr 0x%08x\n",
-		__func__, dfs->dfs_curchan->dfs_ch_freq, phyerr);
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+		"Stopping CAC Timer %d procphyerr 0x%08x",
+		 dfs->dfs_curchan->dfs_ch_freq, phyerr);
 	qdf_timer_stop(&dfs->dfs_cac_timer);
 	dfs->dfs_cac_timer_running = 0;
 }
@@ -231,9 +231,9 @@ void dfs_stacac_stop(struct wlan_dfs *dfs)
 	uint32_t phyerr;
 
 	dfs_get_debug_info(dfs, (void *)&phyerr);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : Stopping STA CAC Timer %d procphyerr 0x%08x\n",
-		__func__, dfs->dfs_curchan->dfs_ch_freq, phyerr);
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+		"Stopping STA CAC Timer %d procphyerr 0x%08x",
+		 dfs->dfs_curchan->dfs_ch_freq, phyerr);
 }
 
 int dfs_random_channel(struct wlan_dfs *dfs,
@@ -277,8 +277,8 @@ int dfs_random_channel(struct wlan_dfs *dfs,
 	available_chan_idx = qdf_mem_malloc(
 			(IEEE80211_CHAN_MAX + 1) * sizeof(int));
 
-	if (available_chan_idx == NULL) {
-		DFS_PRINTK("%s: cannot allocate memory\n", __func__);
+	if (!(available_chan_idx)) {
+		dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS, "cannot allocate memory");
 		return ret_val;
 	}
 
@@ -293,29 +293,29 @@ int dfs_random_channel(struct wlan_dfs *dfs,
 			/* No action required for now. */
 			use_lower_5g_only = 0;
 			use_upper_5g_only = 0;
-			DFS_PRINTK(
-				"%s -- MMK4 domain, HT80_80, no restriction on using upper or lower 5G channel\n",
-				__func__);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"-- MMK4 domain, HT80_80, no restriction on using upper or lower 5G channel"
+				);
 		} else if (IEEE80211_IS_CHAN_11AC_VHT160(dfs->dfs_curchan)) {
 			/* No action required for now. */
 			use_lower_5g_only = 0;
 			use_upper_5g_only = 0;
-			DFS_PRINTK(
-				"%s -- MMK4 domain, HT160, will look for HT160. if can't find no restriction on using upper or lower 5G channel\n",
-				__func__);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"-- MMK4 domain, HT160, will look for HT160. if can't find no restriction on using upper or lower 5G channel"
+				);
 		} else {
 			if (dfs->dfs_curchan->dfs_ch_freq < CH100_START_FREQ) {
 				use_lower_5g_only = 1;
 				use_upper_5g_only = 0;
-				DFS_PRINTK(
-					"%s -- MMK4 domain, search for lower 5G (less than 5490 MHz) channels\n",
-					__func__);
+				dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"-- MMK4 domain, search for lower 5G (less than 5490 MHz) channels"
+					);
 			} else {
 				use_lower_5g_only = 0;
 				use_upper_5g_only = 1;
-				DFS_PRINTK(
-					"%s -- MMK4 domain, search for upper 5G (more than 5490 MHz) channels\n",
-					__func__);
+				dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"-- MMK4 domain, search for upper 5G (more than 5490 MHz) channels"
+					);
 			}
 		}
 	}
@@ -483,9 +483,9 @@ int dfs_random_channel(struct wlan_dfs *dfs,
 		chanStart = (available_chan_idx[j]);
 		ret_val = chanStart;
 	} else {
-		DFS_PRINTK(
-			"%s: Cannot find a channel, looking for channel in other mode. ht80_count=%d, ht80_80_count=%d, ht160_count=%d\n",
-			__func__, ht80_count,
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+			"Cannot find a channel, looking for channel in other mode. ht80_count=%d, ht80_80_count=%d, ht160_count=%d",
+			 ht80_count,
 			ht80_80_count, ht160_count);
 		/*
 		 * We need to handle HT160/HT80_80 in a special way HT160
@@ -525,9 +525,9 @@ int dfs_random_channel(struct wlan_dfs *dfs,
 				(dfs->dfs_pdev_obj, alt_chan_mode, chan_count);
 			if (ret_val == -1) {
 				/* Last attempt to get a valid channel. */
-				DFS_PRINTK(
-					"%s: Cannot find a channel. Forcing to first available HT20 channel\n",
-					__func__);
+				dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"Cannot find a channel. Forcing to first available HT20 channel"
+					);
 				dfs_mlme_find_any_valid_channel
 					(dfs->dfs_pdev_obj,
 					 IEEE80211_CHAN_VHT20, &ret_val);

+ 44 - 55
umac/dfs/core/src/misc/dfs_nol.c

@@ -77,9 +77,9 @@ static os_timer_func(dfs_nol_timeout)
 					 * msg instead of one for every channel
 					 * table entry.
 					 */
-					DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-						"%s : radar on channel %u (%u MHz) cleared after timeout\n",
-						__func__,
+					dfs_debug(dfs, WLAN_DEBUG_DFS,
+						"radar on channel %u (%u MHz) cleared after timeout",
+
 						c->dfs_ch_ieee,
 						c->dfs_ch_freq);
 				}
@@ -122,24 +122,23 @@ static void dfs_nol_delete(struct wlan_dfs *dfs,
 {
 	struct dfs_nolelem *nol, **prev_next;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			"%s: sc_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-		"%s: remove channel=%d/%d MHz from NOL\n",
-		__func__, delfreq, delchwidth);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_NOL,
+		"remove channel=%d/%d MHz from NOL",
+		 delfreq, delchwidth);
 	prev_next = &(dfs->dfs_nol);
 	nol = dfs->dfs_nol;
 	while (nol != NULL) {
 		if (nol->nol_freq == delfreq &&
 			nol->nol_chwidth == delchwidth) {
 			*prev_next = nol->nol_next;
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-				"%s removing channel %d/%dMHz from NOL tstamp=%d\n",
-				__func__, nol->nol_freq,
+			dfs_debug(dfs, WLAN_DEBUG_DFS_NOL,
+				"removing channel %d/%dMHz from NOL tstamp=%d",
+				 nol->nol_freq,
 				nol->nol_chwidth,
 				(qdf_system_ticks_to_msecs
 				 (qdf_system_ticks()) / 1000));
@@ -153,9 +152,7 @@ static void dfs_nol_delete(struct wlan_dfs *dfs,
 
 			/* Be paranoid! */
 			if (dfs->dfs_nol_count < 0) {
-				DFS_PRINTK(
-					"%s: dfs_nol_count < 0; eek!\n",
-					__func__);
+				dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "dfs_nol_count < 0; eek!");
 				dfs->dfs_nol_count = 0;
 			}
 
@@ -193,8 +190,8 @@ static os_timer_func(dfs_remove_from_nol)
 
 	dfs_mlme_nol_timeout_notification(dfs->dfs_pdev_obj);
 	chan = utils_dfs_freq_to_chan(delfreq);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-		    "%s: remove channel %d from nol\n", __func__, chan);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_NOL,
+		    "remove channel %d from nol", chan);
 	utils_dfs_reg_update_nol_ch(dfs->dfs_pdev_obj,
 			(uint8_t *)&chan, 1, DFS_NOL_RESET);
 	dfs_save_nol(dfs->dfs_pdev_obj);
@@ -206,21 +203,20 @@ void dfs_print_nol(struct wlan_dfs *dfs)
 	int i = 0;
 	uint32_t diff_ms, remaining_sec;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-			"%s: sc_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
 	nol = dfs->dfs_nol;
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL, "%s: NOL\n", __func__);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_NOL, "NOL");
 	while (nol != NULL) {
 		diff_ms = qdf_system_ticks_to_msecs(qdf_system_ticks() -
 				nol->nol_start_ticks);
 		diff_ms = (nol->nol_timeout_ms - diff_ms);
 		remaining_sec = diff_ms / 1000; /* Convert to seconds */
-		DFS_PRINTK(
-			"nol:%d channel=%d MHz width=%d MHz time left=%u seconds nol starttick=%llu\n",
+		dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS,
+			"nol:%d channel=%d MHz width=%d MHz time left=%u seconds nol starttick=%llu",
 			i++, nol->nol_freq,
 			nol->nol_chwidth,
 			remaining_sec,
@@ -235,9 +231,8 @@ void dfs_print_nolhistory(struct wlan_dfs *dfs)
 	int i, j = 0;
 	int nchans = 0;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-			"%s: sc_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -254,8 +249,8 @@ void dfs_print_nolhistory(struct wlan_dfs *dfs)
 				&(c->dfs_ch_vhtop_ch_freq_seg2),
 				i);
 		if (IEEE80211_IS_CHAN_HISTORY_RADAR(c)) {
-			DFS_PRINTK(
-				"nolhistory:%d channel=%d MHz Flags=%llx\n",
+			dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS,
+				"nolhistory:%d channel=%d MHz Flags=%llx",
 				j, c->dfs_ch_freq, c->dfs_ch_flags);
 			j++;
 		}
@@ -270,9 +265,8 @@ void dfs_get_nol(struct wlan_dfs *dfs,
 
 	*nchan = 0;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-			"%s: sc_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -296,9 +290,8 @@ void dfs_set_nol(struct wlan_dfs *dfs,
 	struct dfs_ieee80211_channel chan;
 	int i;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-			"%s: sc_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -330,9 +323,8 @@ void dfs_nol_addchan(struct wlan_dfs *dfs,
 	/* For now, assume all events are 20MHz wide. */
 	int ch_width = 20;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-			"%s: dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 	nol = dfs->dfs_nol;
@@ -344,9 +336,9 @@ void dfs_nol_addchan(struct wlan_dfs *dfs,
 			nol->nol_start_ticks = qdf_system_ticks();
 			nol->nol_timeout_ms = dfs_nol_timeout * TIME_IN_MS;
 
-			DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-				"%s: Update OS Ticks for NOL %d MHz / %d MHz\n",
-				__func__, nol->nol_freq, nol->nol_chwidth);
+			dfs_debug(dfs, WLAN_DEBUG_DFS_NOL,
+				"Update OS Ticks for NOL %d MHz / %d MHz",
+				 nol->nol_freq, nol->nol_chwidth);
 
 			qdf_timer_stop(&nol->nol_timer);
 			qdf_timer_mod(&nol->nol_timer,
@@ -359,7 +351,7 @@ void dfs_nol_addchan(struct wlan_dfs *dfs,
 
 	/* Add a new element to the NOL. */
 	elem = (struct dfs_nolelem *)qdf_mem_malloc(sizeof(struct dfs_nolelem));
-	if (elem == NULL)
+	if (!elem)
 		goto bad;
 
 	elem->nol_dfs = dfs;
@@ -383,15 +375,14 @@ void dfs_nol_addchan(struct wlan_dfs *dfs,
 	/* Update the NOL counter. */
 	dfs->dfs_nol_count++;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-		"%s: new NOL channel %d MHz / %d MHz\n",
-		__func__, elem->nol_freq, elem->nol_chwidth);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_NOL,
+		"new NOL channel %d MHz / %d MHz",
+		 elem->nol_freq, elem->nol_chwidth);
 	return;
 
 bad:
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL | WLAN_DEBUG_DFS,
-		"%s: failed to allocate memory for nol entry\n",
-		__func__);
+	dfs_debug(dfs, WLAN_DEBUG_DFS_NOL | WLAN_DEBUG_DFS,
+		"failed to allocate memory for nol entry");
 
 #undef TIME_IN_MS
 #undef TIME_IN_US
@@ -402,7 +393,7 @@ void dfs_get_nol_chfreq_and_chwidth(struct dfs_nol_chan_entry *nollist,
 		uint32_t *nol_chwidth,
 		int index)
 {
-	if (nollist == NULL)
+	if (!nollist)
 		return;
 
 	*nol_chfreq = nollist[index].nol_chfreq;
@@ -424,16 +415,14 @@ void dfs_nol_update(struct wlan_dfs *dfs)
 	dfs_nol = (struct dfs_nol_chan_entry *)qdf_mem_malloc(
 		sizeof(struct dfs_nol_chan_entry) * dfs->dfs_nol_count);
 
-	if (dfs_nol == NULL) {
+	if (!dfs_nol) {
 		/*
 		 * XXX TODO: if this fails, just schedule a task to retry
 		 * updating the NOL at a later stage.  That way the NOL
 		 * update _DOES_ happen - hopefully the failure was just
 		 * temporary.
 		 */
-		DFS_PRINTK(
-			"%s: failed to allocate NOL update memory!\n",
-			__func__);
+		dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS, "failed to allocate NOL update memory!");
 		return;
 	}
 
@@ -452,8 +441,8 @@ void dfs_nol_update(struct wlan_dfs *dfs)
 
 	/* Be suitably paranoid for now. */
 	if (nlen != dfs->dfs_nol_count)
-		DFS_PRINTK("%s: nlen (%d) != dfs->dfs_nol_count (%d)!\n",
-			__func__, nlen, dfs->dfs_nol_count);
+		dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "nlen (%d) != dfs->dfs_nol_count (%d)!",
+			 nlen, dfs->dfs_nol_count);
 
 	/*
 	 * Call the driver layer to have it recalculate the NOL flags
@@ -490,7 +479,7 @@ void dfs_nol_timer_cleanup(struct wlan_dfs *dfs)
 		dfs->dfs_nol_count--;
 
 		if (dfs->dfs_nol_count < 0) {
-			DFS_PRINTK("%s: dfs_nol_count < 0\n", __func__);
+			dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs_nol_count < 0");
 			ASSERT(0);
 		}
 	}

+ 15 - 11
umac/dfs/core/src/misc/dfs_process_radar_found_ind.c

@@ -94,15 +94,17 @@ static void dfs_radar_add_to_nol(struct wlan_dfs *dfs,
 			continue;
 		if (!utils_is_dfs_ch(dfs->dfs_pdev_obj,
 		     freq_offset->chan_num[i])) {
-			DFS_PRINTK("%s: ch=%d is not dfs skip\n",
-				   __func__, freq_offset->chan_num[i]);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"ch=%d is not dfs skip",
+					freq_offset->chan_num[i]);
 			continue;
 		}
 		last_chan = freq_offset->chan_num[i];
 		dfs_nol_addchan(dfs, (uint16_t)freq_offset->freq[i],
 				dfs->wlan_dfs_nol_timeout);
 		nollist[num_ch++] = last_chan;
-		DFS_PRINTK("%s: ch=%d Added to NOL\n", __func__, last_chan);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"ch=%d Added to NOL", last_chan);
 	}
 	utils_dfs_reg_update_nol_ch(dfs->dfs_pdev_obj,
 			nollist, num_ch, DFS_NOL_SET);
@@ -217,7 +219,7 @@ void dfs_process_radar_found_indication(struct wlan_dfs *dfs,
 	int32_t sidx;
 
 	if (!dfs || !dfs->dfs_curchan) {
-		DFS_PRINTK("%s: dfs is null\n", __func__);
+		dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS, "dfs is null");
 		return;
 	}
 
@@ -239,10 +241,11 @@ void dfs_process_radar_found_indication(struct wlan_dfs *dfs,
 			freq_center += DFS_160MHZ_SECOND_SEG_OFFSET;
 	}
 
-	DFS_PRINTK("%s: seg=%d, sidx=%d, offset=%d, chirp=%d, flag=%d, f=%d\n",
-		   __func__, radar_found->segment_id, sidx,
-		   radar_found->freq_offset, radar_found->is_chirp,
-		   flag, freq_center);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+			"seg=%d, sidx=%d, offset=%d, chirp=%d, flag=%d, f=%d",
+			radar_found->segment_id, sidx,
+			radar_found->freq_offset, radar_found->is_chirp,
+			flag, freq_center);
 
 	if ((flag & IEEE80211_CHAN_A)         ||
 	    (flag & IEEE80211_CHAN_11NA_HT20) ||
@@ -280,15 +283,16 @@ void dfs_process_radar_found_indication(struct wlan_dfs *dfs,
 		}
 		dfs_radar_chan_for_80(&freq_offset, freq_center);
 	} else {
-		DFS_PRINTK("%s: channel flag(%d) is invalid\n", __func__, flag);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"channel flag(%d) is invalid", flag);
 		return;
 	}
 
 	for (i = 0; i < DFS_NUM_FREQ_OFFSET; i++) {
 		freq_offset.chan_num[i] = utils_dfs_freq_to_chan(
 				freq_offset.freq[i]);
-		DFS_PRINTK("%s: offset=%d, channel%d\n",
-			   __func__, i, freq_offset.chan_num[i]);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "offset=%d, channel%d",
+			    i, freq_offset.chan_num[i]);
 	}
 
 	dfs_radar_add_to_nol(dfs, &freq_offset);

+ 63 - 51
umac/dfs/core/src/misc/dfs_random_chan_sel.c

@@ -60,7 +60,7 @@ static uint8_t dfs_populate_80mhz_available_channels(
 				(DFS_NEXT_5GHZ_CHANNEL * 3);
 		}
 	}
-	DFS_PRINTK("%s: channel count %d\n", __func__, chnl_count);
+	dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "channel count %d", chnl_count);
 
 	return chnl_count;
 }
@@ -99,7 +99,7 @@ static uint8_t dfs_populate_40mhz_available_channels(
 				(DFS_NEXT_5GHZ_CHANNEL * 3);
 		}
 	}
-	DFS_PRINTK("%s: channel count %d\n", __func__, chnl_count);
+	dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "channel count %d", chnl_count);
 
 	return chnl_count;
 }
@@ -129,8 +129,8 @@ static uint8_t dfs_populate_available_channels(
 		return dfs_populate_40mhz_available_channels(
 			bitmap, avail_chnl);
 	default:
-		DFS_PRINTK(
-		"%s: Invalid ch_width %d\n", __func__, ch_width);
+		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,
+				"Invalid ch_width %d", ch_width);
 		break;
 	}
 
@@ -152,15 +152,16 @@ static uint8_t dfs_get_rand_from_lst(uint8_t *ch_lst, uint8_t num_ch)
 	uint32_t rand_byte = 0;
 
 	if (!num_ch || !ch_lst) {
-		DFS_PRINTK("%s: invalid param ch_lst %pK, num_ch = %d\n",
-			   __func__, ch_lst, num_ch);
+		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,
+				"invalid param ch_lst %p, num_ch = %d",
+				ch_lst, num_ch);
 		return 0;
 	}
 
 	get_random_bytes((uint8_t *)&rand_byte, 1);
 	i = (rand_byte + qdf_mc_timer_get_system_ticks()) % num_ch;
 
-	DFS_PRINTK("%s: random channel %d\n", __func__, ch_lst[i]);
+	dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "random channel %d", ch_lst[i]);
 	return ch_lst[i];
 }
 
@@ -190,8 +191,9 @@ static void dfs_random_channel_sel_set_bitmap(
 			return;
 		}
 	}
-	DFS_PRINTK(
-	"%s: Channel=%d is not in the bitmap\n", __func__, channel);
+
+	dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS,
+			"Channel=%d is not in the bitmap", channel);
 }
 
 /**
@@ -227,8 +229,8 @@ static uint8_t dfs_find_ch_with_fallback(uint8_t *ch_wd,
 	ch_map.chan_bonding_set[5].start_chan = 149;
 
 	for (i = 0; i < num_ch; i++) {
-		DFS_PRINTK(
-		"%s: channel = %d added to bitmap\n", __func__, ch_lst[i]);
+		dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS,
+				"channel = %d added to bitmap", ch_lst[i]);
 		dfs_random_channel_sel_set_bitmap(&ch_map, ch_lst[i]);
 	}
 
@@ -240,12 +242,11 @@ static uint8_t dfs_find_ch_with_fallback(uint8_t *ch_wd,
 		if ((*ch_wd == DFS_CH_WIDTH_160MHZ) ||
 		    (*ch_wd == DFS_CH_WIDTH_80P80MHZ) ||
 		    (*ch_wd == DFS_CH_WIDTH_80MHZ)) {
-			DFS_PRINTK(
-			"%s: from [%d] to 40Mhz\n", __func__, *ch_wd);
+			dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS,
+					"from [%d] to 40Mhz", *ch_wd);
 			*ch_wd = DFS_CH_WIDTH_40MHZ;
 		} else if (*ch_wd == DFS_CH_WIDTH_40MHZ) {
-			DFS_PRINTK(
-			"%s: from 40Mhz to 20MHz\n", __func__);
+			dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "from 40Mhz to 20MHz");
 			*ch_wd = DFS_CH_WIDTH_20MHZ;
 		}
 		return 0;
@@ -255,8 +256,8 @@ static uint8_t dfs_find_ch_with_fallback(uint8_t *ch_wd,
 	if (((*ch_wd == DFS_CH_WIDTH_160MHZ) ||
 	     (*ch_wd == DFS_CH_WIDTH_80P80MHZ)) &&
 	     (final_cnt < DFS_MAX_20M_SUB_CH)) {
-		DFS_PRINTK(
-		"%s: from [%d] to 80Mhz\n", __func__, *ch_wd);
+		dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS,
+				"from [%d] to 80Mhz", *ch_wd);
 		*ch_wd = DFS_CH_WIDTH_80MHZ;
 		return 0;
 	}
@@ -284,7 +285,8 @@ static uint8_t dfs_find_ch_with_fallback(uint8_t *ch_wd,
 	}
 
 	if ((flag == false) && (*ch_wd > DFS_CH_WIDTH_80MHZ)) {
-		DFS_PRINTK("%s: from [%d] to 80Mhz\n", __func__, *ch_wd);
+		dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS,
+				"from [%d] to 80Mhz", *ch_wd);
 		*ch_wd = DFS_CH_WIDTH_80MHZ;
 		return 0;
 	}
@@ -325,12 +327,13 @@ static uint8_t dfs_find_ch_with_fallback(uint8_t *ch_wd,
 			*ch_wd = DFS_CH_WIDTH_80MHZ;
 
 		*center_freq_seg1 = sec_seg_ch;
-		DFS_PRINTK(
-		"%s: Center frequency seg1 = %d\n", __func__, sec_seg_ch);
+		dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS,
+				"Center frequency seg1 = %d", sec_seg_ch);
 	} else {
 		target_channel = dfs_get_rand_from_lst(final_lst, final_cnt);
 	}
-	DFS_PRINTK("%s: target channel = %d\n", __func__, target_channel);
+	dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS,
+			"target channel = %d", target_channel);
 
 	return target_channel;
 }
@@ -370,14 +373,15 @@ static bool dfs_freq_is_in_nol(struct wlan_dfs *dfs, uint32_t freq)
 	struct dfs_nolelem *nol;
 
 	if (!dfs) {
-		DFS_PRINTK("%s: null dfs\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null dfs");
 		return false;
 	}
 
 	nol = dfs->dfs_nol;
 	while (nol) {
 		if (freq == nol->nol_freq) {
-			DFS_PRINTK("%s: %d is in nol\n", __func__, freq);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"%d is in nol", freq);
 			return true;
 		}
 		nol = nol->nol_next;
@@ -419,7 +423,7 @@ static void dfs_apply_rules(struct wlan_dfs *dfs,
 	uint16_t flag_no_5g_chan  = 0;
 	int i;
 
-	DFS_PRINTK("%s: flags %d\n", __func__, flags);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "flags %d", flags);
 	flag_no_wheather = (dfs_region == DFS_ETSI_REGION_VAL) ?
 		flags & DFS_RANDOM_CH_FLAG_NO_WEATHER_CH : 0;
 
@@ -438,17 +442,17 @@ static void dfs_apply_rules(struct wlan_dfs *dfs,
 
 		if ((chan->dfs_ch_ieee == 0) ||
 				(chan->dfs_ch_ieee > MAX_CHANNEL_NUM)) {
-			DFS_PRINTK("%s: invalid channel %d\n",
-				   __func__, chan->dfs_ch_ieee);
+			dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "invalid channel %d",
+					chan->dfs_ch_ieee);
 			continue;
 		}
 
 		if (acs_info && (acs_info->acs_mode == 1) &&
 		    ((chan->dfs_ch_ieee < acs_info->start_ch) ||
 		    (chan->dfs_ch_ieee > acs_info->end_ch))) {
-			DFS_PRINTK("%s: skip ch %d not in acs range (%d-%d)\n",
-				   __func__, chan->dfs_ch_ieee,
-				   acs_info->start_ch,
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"skip ch %d not in acs range (%d-%d)",
+				    chan->dfs_ch_ieee, acs_info->start_ch,
 				   acs_info->end_ch);
 			continue;
 
@@ -456,15 +460,17 @@ static void dfs_apply_rules(struct wlan_dfs *dfs,
 
 		if (flag_no_2g_chan &&
 				chan->dfs_ch_ieee <= DFS_MAX_24GHZ_CHANNEL) {
-			DFS_PRINTK("%s: skip 2.4 GHz channel=%d\n",
-				   __func__, chan->dfs_ch_ieee);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"skip 2.4 GHz channel=%d",
+				    chan->dfs_ch_ieee);
 			continue;
 		}
 
 		if (flag_no_5g_chan &&
 				chan->dfs_ch_ieee > DFS_MAX_24GHZ_CHANNEL) {
-			DFS_PRINTK("%s: skip 5 GHz channel=%d\n",
-				   __func__, chan->dfs_ch_ieee);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"skip 5 GHz channel=%d",
+				    chan->dfs_ch_ieee);
 			continue;
 		}
 
@@ -475,44 +481,47 @@ static void dfs_apply_rules(struct wlan_dfs *dfs,
 			 */
 			/* TODO check if reg updating chan->dfs_ch_flags for
 			 * IEEE80211_CHAN_11NA_HT40PLUS
-			 * */
+			 */
 			if (DFS_IS_CHANNEL_WEATHER_RADAR(chan->dfs_ch_freq)) {
-				DFS_PRINTK("%s: skip weather channel=%d\n",
-					   __func__, chan->dfs_ch_ieee);
+				dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+						"skip weather channel=%d",
+						chan->dfs_ch_ieee);
 				continue;
 			} else if (DFS_ADJACENT_WEATHER_RADAR_CHANNEL ==
 				   chan->dfs_ch_freq && (chan->dfs_ch_flags &
 				   IEEE80211_CHAN_11NA_HT40PLUS)) {
-				DFS_PRINTK("%s: skip weather adjacent ch=%d\n",
-					   __func__, chan->dfs_ch_ieee);
+				dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+						"skip weather adjacent ch=%d",
+					    chan->dfs_ch_ieee);
 				continue;
 			}
 		}
 
 		if (flag_no_lower_5g &&
 		    DFS_IS_CHAN_JAPAN_INDOOR(chan->dfs_ch_freq)) {
-			DFS_PRINTK("%s: skip indoor channel=%d\n",
-				   __func__, chan->dfs_ch_ieee);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+					"skip indoor channel=%d",
+					chan->dfs_ch_ieee);
 			continue;
 		}
 
 		if (flag_no_upper_5g &&
 		    DFS_IS_CHAN_JAPAN_OUTDOOR(chan->dfs_ch_freq)) {
-			DFS_PRINTK("%s: skip outdoor channel=%d\n",
-				   __func__, chan->dfs_ch_ieee);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "skip outdoor channel=%d",
+				    chan->dfs_ch_ieee);
 			continue;
 		}
 
 		if (flag_no_dfs_chan &&
 		    (chan->dfs_ch_flagext & IEEE80211_CHAN_DFS)) {
-			DFS_PRINTK("%s: skip dfs channel=%d\n",
-				   __func__, chan->dfs_ch_ieee);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "skip dfs channel=%d",
+				    chan->dfs_ch_ieee);
 			continue;
 		}
 
 		if (dfs_freq_is_in_nol(dfs, chan->dfs_ch_freq)) {
-			DFS_PRINTK("%s: skip nol channel=%d\n",
-				   __func__, chan->dfs_ch_ieee);
+			dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "skip nol channel=%d",
+				    chan->dfs_ch_ieee);
 			continue;
 		}
 
@@ -535,19 +544,22 @@ int dfs_prepare_random_channel(struct wlan_dfs *dfs,
 	uint32_t random_chan_cnt = 0;
 
 	if (!ch_list || !ch_cnt) {
-		DFS_PRINTK("%s: Invalid params %pK, ch_cnt=%d\n",
-			   __func__, ch_list, ch_cnt);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"Invalid params %p, ch_cnt=%d",
+				ch_list, ch_cnt);
 		return 0;
 	}
 
 	if (*ch_wd < DFS_CH_WIDTH_20MHZ || *ch_wd > DFS_CH_WIDTH_80P80MHZ) {
-		DFS_PRINTK("%s: Invalid ch_wd %d\n", __func__, *ch_wd);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"Invalid ch_wd %d", *ch_wd);
 		return 0;
 	}
 
 	random_chan_list = qdf_mem_malloc(ch_cnt * sizeof(*random_chan_list));
 	if (!random_chan_list) {
-		DFS_PRINTK("%s: Memory allocation failed\n", __func__);
+		dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"Memory allocation failed");
 		return 0;
 	}
 
@@ -573,7 +585,7 @@ int dfs_prepare_random_channel(struct wlan_dfs *dfs,
 	} while (true);
 
 	qdf_mem_free(random_chan_list);
-	DFS_PRINTK("%s: target_ch = %d\n", __func__, target_ch);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "target_ch = %d", target_ch);
 
 	return target_ch;
 }

+ 67 - 82
umac/dfs/core/src/misc/dfs_zero_cac.c

@@ -120,12 +120,11 @@ void dfs_zero_cac_reset(struct wlan_dfs *dfs)
 
 int dfs_override_precac_timeout(struct wlan_dfs *dfs, int precac_timeout)
 {
-	if (dfs == NULL)
+	if (!dfs)
 		return -EIO;
 
 	dfs->dfs_precac_timeout_override = precac_timeout;
-	DFS_PRINTK("%s: PreCAC timeout is now %s (%d)\n",
-		__func__,
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "PreCAC timeout is now %s (%d)",
 		(precac_timeout == -1) ? "default" : "overridden",
 		precac_timeout);
 
@@ -134,7 +133,7 @@ int dfs_override_precac_timeout(struct wlan_dfs *dfs, int precac_timeout)
 
 int dfs_get_override_precac_timeout(struct wlan_dfs *dfs, int *precac_timeout)
 {
-	if (dfs == NULL)
+	if (!dfs)
 		return -EIO;
 
 	(*precac_timeout) = dfs->dfs_precac_timeout_override;
@@ -170,8 +169,8 @@ bool dfs_is_ht20_40_80_chan_in_precac_done_list(struct wlan_dfs *dfs)
 		}
 	PRECAC_LIST_UNLOCK(dfs);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s : vht80_freq = %u ret_val = %d\n",
-		__func__, dfs->dfs_curchan->dfs_ch_ieee, ret_val);
+	dfs_debug(dfs, WLAN_DEBUG_DFS, "vht80_freq = %u ret_val = %d",
+		 dfs->dfs_curchan->dfs_ch_ieee, ret_val);
 
 	return ret_val;
 }
@@ -219,9 +218,8 @@ bool dfs_is_ht80_80_chan_in_precac_done_list(struct wlan_dfs *dfs)
 	}
 	PRECAC_LIST_UNLOCK(dfs);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : freq_seg1 = %u freq_seq2 = %u ret_val = %d\n",
-		__func__,
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+		"freq_seg1 = %u freq_seq2 = %u ret_val = %d",
 		dfs->dfs_curchan->dfs_ch_vhtop_ch_freq_seg1,
 		dfs->dfs_curchan->dfs_ch_vhtop_ch_freq_seg2,
 		ret_val);
@@ -242,8 +240,7 @@ bool dfs_is_precac_done(struct wlan_dfs *dfs)
 		ret_val = dfs_is_ht80_80_chan_in_precac_done_list(dfs);
 	}
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : ret_val = %d\n", __func__, ret_val);
+	dfs_debug(dfs, WLAN_DEBUG_DFS, "ret_val = %d", ret_val);
 
 	return ret_val;
 }
@@ -256,9 +253,8 @@ void dfs_mark_precac_dfs(struct wlan_dfs *dfs,
 	struct dfs_precac_entry *precac_entry = NULL, *tmp_precac_entry = NULL;
 	uint8_t found = 0;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : is_radar_found_on_secondary_seg = %u secondary_freq = %u primary_freq = %u\n",
-		__func__,
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+		"is_radar_found_on_secondary_seg = %u secondary_freq = %u primary_freq = %u",
 		is_radar_found_on_secondary_seg,
 		dfs->dfs_precac_secondary_freq,
 		dfs->dfs_precac_primary_freq);
@@ -286,9 +282,8 @@ void dfs_mark_precac_dfs(struct wlan_dfs *dfs,
 				TAILQ_REMOVE(&dfs->dfs_precac_required_list,
 						precac_entry, pe_list);
 
-				DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-					"%s : removing the freq = %u from required list and adding to NOL list\n",
-					__func__,
+				dfs_debug(dfs, WLAN_DEBUG_DFS,
+					"removing the freq = %u from required list and adding to NOL list",
 					precac_entry->vht80_freq);
 				TAILQ_INSERT_TAIL(&dfs->dfs_precac_nol_list,
 						precac_entry, pe_list);
@@ -319,9 +314,8 @@ void dfs_mark_precac_dfs(struct wlan_dfs *dfs,
 				TAILQ_REMOVE(&dfs->dfs_precac_done_list,
 					precac_entry, pe_list);
 
-				DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-					"%s : removing the the freq = %u from done list and adding to NOL list\n",
-					__func__,
+				dfs_debug(dfs, WLAN_DEBUG_DFS,
+					"removing the the freq = %u from done list and adding to NOL list",
 					precac_entry->vht80_freq);
 				TAILQ_INSERT_TAIL(&dfs->dfs_precac_nol_list,
 						precac_entry, pe_list);
@@ -353,9 +347,9 @@ void dfs_mark_precac_dfs(struct wlan_dfs *dfs,
 		if (is_radar_found_on_secondary_seg) {
 			if (dfs_is_ap_cac_timer_running(dfs)) {
 				dfs->dfs_defer_precac_channel_change = 1;
-				DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-					"%s : Primary CAC is running, defer the channel change\n",
-					__func__);
+				dfs_debug(dfs, WLAN_DEBUG_DFS,
+					"Primary CAC is running, defer the channel change"
+					);
 			} else {
 				dfs_mlme_channel_change_by_precac(
 						dfs->dfs_pdev_obj);
@@ -418,9 +412,8 @@ static os_timer_func(dfs_precac_timeout)
 					precac_entry->vht80_freq) {
 				TAILQ_REMOVE(&dfs->dfs_precac_required_list,
 						precac_entry, pe_list);
-				DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-					"%s : removing the the freq = %u from required list and adding to done list\n",
-					__func__,
+				dfs_debug(dfs, WLAN_DEBUG_DFS,
+					"removing the the freq = %u from required list and adding to done list",
 					precac_entry->vht80_freq);
 				TAILQ_INSERT_TAIL(&dfs->dfs_precac_done_list,
 						precac_entry, pe_list);
@@ -430,9 +423,8 @@ static os_timer_func(dfs_precac_timeout)
 	}
 	PRECAC_LIST_UNLOCK(dfs);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : Pre-cac expired, Precac Secondary chan %u curr time %d\n",
-		__func__,
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+		"Pre-cac expired, Precac Secondary chan %u curr time %d",
 		dfs->dfs_precac_secondary_freq,
 		(qdf_system_ticks_to_msecs(qdf_system_ticks()) / 1000));
 	/* Do vdev restart so that we can change the secondary VHT80 channel. */
@@ -475,9 +467,9 @@ static os_timer_func(dfs_precac_nol_timeout)
 	if (!TAILQ_EMPTY(&dfs->dfs_precac_nol_list)) {
 		/* Move the channel from precac-NOL to precac-required-list */
 		TAILQ_REMOVE(&dfs->dfs_precac_nol_list, precac_entry, pe_list);
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			"%s : removing the the freq = %u from PreCAC NOL-list and adding Precac-required list\n",
-			__func__, precac_entry->vht80_freq);
+		dfs_debug(dfs, WLAN_DEBUG_DFS,
+			"removing the the freq = %u from PreCAC NOL-list and adding Precac-required list",
+			 precac_entry->vht80_freq);
 		TAILQ_INSERT_TAIL(&dfs->dfs_precac_required_list, precac_entry,
 				pe_list);
 	}
@@ -562,22 +554,22 @@ void dfs_init_precac_list(struct wlan_dfs *dfs)
 	}
 	PRECAC_LIST_UNLOCK(dfs);
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : Print the list of VHT80 frequencies from linked list\n",
-		__func__);
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+		"Print the list of VHT80 frequencies from linked list");
 	TAILQ_FOREACH(tmp_precac_entry,
 			&dfs->dfs_precac_required_list,
 			pe_list)
-		DFS_PRINTK("freq=%u\n", tmp_precac_entry->vht80_freq);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "freq=%u",
+				tmp_precac_entry->vht80_freq);
 }
 
 void dfs_deinit_precac_list(struct wlan_dfs *dfs)
 {
 	struct dfs_precac_entry *tmp_precac_entry, *precac_entry;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : Free the list of VHT80 frequencies from linked list(precac_required)\n",
-		__func__);
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+		"Free the list of VHT80 frequencies from linked list(precac_required)"
+		);
 	PRECAC_LIST_LOCK(dfs);
 	if (!TAILQ_EMPTY(&dfs->dfs_precac_required_list))
 		TAILQ_FOREACH_SAFE(precac_entry,
@@ -588,9 +580,9 @@ void dfs_deinit_precac_list(struct wlan_dfs *dfs)
 			qdf_mem_free(precac_entry);
 		}
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : Free the list of VHT80 frequencies from linked list(precac_done)\n",
-		__func__);
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+		"Free the list of VHT80 frequencies from linked list(precac_done)"
+		);
 	if (!TAILQ_EMPTY(&dfs->dfs_precac_done_list))
 		TAILQ_FOREACH_SAFE(precac_entry,
 				&dfs->dfs_precac_done_list,
@@ -600,9 +592,9 @@ void dfs_deinit_precac_list(struct wlan_dfs *dfs)
 			qdf_mem_free(precac_entry);
 		}
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : Free the list of VHT80 frequencies from linked list(precac_nol)\n",
-		__func__);
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+		"Free the list of VHT80 frequencies from linked list(precac_nol)"
+		);
 	if (!TAILQ_EMPTY(&dfs->dfs_precac_nol_list))
 		TAILQ_FOREACH_SAFE(precac_entry,
 				&dfs->dfs_precac_nol_list,
@@ -628,8 +620,8 @@ uint8_t dfs_get_freq_from_precac_required_list(struct wlan_dfs *dfs,
 	struct dfs_precac_entry *precac_entry;
 	uint8_t ieee_freq = 0;
 
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s : exclude_ieee_freq = %u\n",
-		__func__, exclude_ieee_freq);
+	dfs_debug(dfs, WLAN_DEBUG_DFS, "exclude_ieee_freq = %u",
+		 exclude_ieee_freq);
 
 	PRECAC_LIST_LOCK(dfs);
 	if (!TAILQ_EMPTY(&dfs->dfs_precac_required_list)) {
@@ -642,8 +634,7 @@ uint8_t dfs_get_freq_from_precac_required_list(struct wlan_dfs *dfs,
 		}
 	}
 	PRECAC_LIST_UNLOCK(dfs);
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS, "%s : ieee_freq = %u\n",
-		__func__, ieee_freq);
+	dfs_debug(dfs, WLAN_DEBUG_DFS, "ieee_freq = %u", ieee_freq);
 
 	return ieee_freq;
 }
@@ -705,9 +696,8 @@ void dfs_start_precac_timer(struct wlan_dfs *dfs, uint8_t precac_chan)
 	 */
 	precac_timeout = QDF_MAX(primary_cac_timeout, secondary_cac_timeout) +
 		EXTRA_TIME_IN_SEC;
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : precactimeout = %d\n",
-		__func__, (precac_timeout)*1000);
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+		"precactimeout = %d", (precac_timeout)*1000);
 	qdf_timer_mod(&dfs->dfs_precac_timer, (precac_timeout) * 1000);
 }
 
@@ -715,40 +705,41 @@ void dfs_print_precaclists(struct wlan_dfs *dfs)
 {
 	struct dfs_precac_entry *tmp_precac_entry;
 
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-			"%s: sc_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
 	PRECAC_LIST_LOCK(dfs);
 
 	/* Print the Pre-CAC required List */
-	DFS_PRINTK("%s : Pre-cac-required list of VHT80 frequencies\n",
-		__func__);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+			"Pre-cac-required list of VHT80 frequencies");
 	TAILQ_FOREACH(tmp_precac_entry,
 			&dfs->dfs_precac_required_list,
 			pe_list) {
-		DFS_PRINTK("%s : freq=%u\n", __func__,
-				tmp_precac_entry->vht80_freq);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"freq=%u", tmp_precac_entry->vht80_freq);
 	}
 
 	/* Print the Pre-CAC done List */
-	DFS_PRINTK("%s : Pre-cac-done list of VHT80 frequencies\n", __func__);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+			"Pre-cac-done list of VHT80 frequencies");
 	TAILQ_FOREACH(tmp_precac_entry,
 			&dfs->dfs_precac_done_list,
 			pe_list) {
-		DFS_PRINTK("%s : freq=%u\n",
-			__func__, tmp_precac_entry->vht80_freq);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "freq=%u",
+			 tmp_precac_entry->vht80_freq);
 	}
 
 	/* Print the Pre-CAC NOL List */
-	DFS_PRINTK("%s Pre-cac-NOL list of VHT80 frequencies\n", __func__);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+			"Pre-cac-NOL list of VHT80 frequencies");
 	TAILQ_FOREACH(tmp_precac_entry,
 			&dfs->dfs_precac_nol_list,
 			pe_list) {
-		DFS_PRINTK("%s : freq=%u\n", __func__,
-			tmp_precac_entry->vht80_freq);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"freq=%u", tmp_precac_entry->vht80_freq);
 	}
 
 	PRECAC_LIST_UNLOCK(dfs);
@@ -756,17 +747,16 @@ void dfs_print_precaclists(struct wlan_dfs *dfs)
 
 void dfs_reset_precaclists(struct wlan_dfs *dfs)
 {
-	DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-		"%s : Reset precaclist of VHT80 frequencies\n", __func__);
+	dfs_debug(dfs, WLAN_DEBUG_DFS,
+		"Reset precaclist of VHT80 frequencies");
 	dfs_deinit_precac_list(dfs);
 	dfs_init_precac_list(dfs);
 }
 
 void dfs_reset_precac_lists(struct wlan_dfs *dfs)
 {
-	if (dfs == NULL) {
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS_NOL,
-			"%s: sc_dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 	dfs_reset_precaclists(dfs);
@@ -787,7 +777,7 @@ void dfs_find_vht80_chan_for_precac(struct wlan_dfs *dfs,
 
 	psoc = wlan_pdev_get_psoc(dfs->dfs_pdev_obj);
 	if (!psoc) {
-		DFS_PRINTK("%s: PSOC is NULL\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "psoc is NULL");
 		return;
 	}
 
@@ -806,9 +796,8 @@ void dfs_find_vht80_chan_for_precac(struct wlan_dfs *dfs,
 		 */
 		uint8_t ieee_freq;
 
-		DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-			"%s : precac_secondary_freq = %u precac_running = %u\n",
-			__func__,
+		dfs_debug(dfs, WLAN_DEBUG_DFS,
+			"precac_secondary_freq = %u precac_running = %u",
 			dfs->dfs_precac_secondary_freq,
 			dfs->dfs_precac_timer_running);
 
@@ -896,14 +885,10 @@ void dfs_find_vht80_chan_for_precac(struct wlan_dfs *dfs,
 				else
 					*set_agile = false;
 
-				DFS_DPRINTK(dfs, WLAN_DEBUG_DFS,
-					"%s : cfreq1 = %u cfreq2 = %u ieee_freq = %u mode = %u set_agile = %d\n",
-					__func__,
-					*cfreq1,
-					*cfreq2,
-					ieee_freq,
-					chan_mode,
-					*set_agile);
+				dfs_debug(dfs, WLAN_DEBUG_DFS,
+					"cfreq1 = %u cfreq2 = %u ieee_freq = %u mode = %u set_agile = %d",
+					*cfreq1, *cfreq2, ieee_freq,
+					chan_mode, *set_agile);
 
 				dfs->dfs_precac_secondary_freq = ieee_freq;
 				dfs->dfs_precac_primary_freq = ch_freq_seg1;

+ 28 - 22
umac/dfs/dispatcher/src/wlan_dfs_init_deinit_api.c

@@ -32,6 +32,7 @@
 #include "../../core/src/dfs.h"
 #include "a_types.h"
 #include "wlan_serialization_api.h"
+#include <qdf_trace.h>
 
 struct dfs_to_mlme global_dfs_to_mlme;
 
@@ -101,6 +102,8 @@ void register_dfs_callbacks(void)
 
 QDF_STATUS dfs_init(void)
 {
+	QDF_STATUS res;
+
 	register_dfs_callbacks();
 
 	if (wlan_objmgr_register_pdev_create_handler(WLAN_UMAC_COMP_DFS,
@@ -116,6 +119,13 @@ QDF_STATUS dfs_init(void)
 		return QDF_STATUS_E_FAILURE;
 	}
 
+	res = qdf_print_set_category_verbose(qdf_get_pidx(),
+			QDF_MODULE_ID_DFS, QDF_TRACE_LEVEL_INFO, true);
+	if (res) {
+		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "Failed to set verbose for category");
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -143,13 +153,13 @@ QDF_STATUS wlan_dfs_pdev_obj_create_notification(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs = NULL;
 	struct wlan_objmgr_psoc *psoc;
 
-	if (pdev == NULL) {
-		DFS_PRINTK("%s: null pdev\n", __func__);
+	if (!pdev) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null pdev");
 		return QDF_STATUS_E_FAILURE;
 	}
 
 	if (dfs_create_object(&dfs) == 1) {
-		DFS_PRINTK("%s: failed to create object\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "failed to create object");
 		return QDF_STATUS_E_FAILURE;
 	}
 
@@ -158,16 +168,16 @@ QDF_STATUS wlan_dfs_pdev_obj_create_notification(struct wlan_objmgr_pdev *pdev,
 	dfs->dfs_pdev_obj = pdev;
 	psoc = wlan_pdev_get_psoc(pdev);
 	if (!psoc) {
-		DFS_PRINTK("%s: null psoc\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null psoc");
 		return QDF_STATUS_E_FAILURE;
 	}
 	dfs->dfs_is_offload_enabled =
 		DFS_OFFLOAD_IS_ENABLED(psoc->service_param.service_bitmap);
-	DFS_PRINTK("%s: dfs_offload %d\n", __func__,
-		dfs->dfs_is_offload_enabled);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+			"dfs_offload %d", dfs->dfs_is_offload_enabled);
 	dfs = wlan_pdev_get_dfs_obj(pdev);
 	if (dfs_attach(dfs) == 1) {
-		DFS_PRINTK("%s: dfs_attch failed\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs_attch failed");
 		dfs_destroy_object(dfs);
 		return QDF_STATUS_E_FAILURE;
 	}
@@ -182,8 +192,8 @@ QDF_STATUS wlan_dfs_pdev_obj_destroy_notification(struct wlan_objmgr_pdev *pdev,
 {
 	struct wlan_dfs *dfs;
 
-	if (pdev == NULL) {
-		DFS_PRINTK("%s:PDEV is NULL\n", __func__);
+	if (!pdev) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "PDEV is NULL");
 		return QDF_STATUS_E_FAILURE;
 	}
 
@@ -212,24 +222,24 @@ static void dfs_scan_serialization_comp_info_cb(
 	struct wlan_objmgr_pdev *pdev;
 
 	if (!comp_info) {
-		DFS_PRINTK("%s: comp_info is NULL\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "comp_info is NULL");
 		return;
 	}
 
 	if (!vdev) {
-		DFS_PRINTK("%s: vdev is NULL\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "vdev is NULL");
 		return;
 	}
 
 	pdev = wlan_vdev_get_pdev(vdev);
 	if (!pdev) {
-		DFS_PRINTK("%s: pdev is NULL\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "pdev is NULL");
 		return;
 	}
 
 	dfs = wlan_pdev_get_dfs_obj(pdev);
-	if (dfs == NULL) {
-		DFS_PRINTK("%s: dfs is NULL\n", __func__);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return;
 	}
 
@@ -245,11 +255,11 @@ QDF_STATUS wifi_dfs_psoc_enable(struct wlan_objmgr_psoc *psoc)
 	bool dfs_offload =
 		DFS_OFFLOAD_IS_ENABLED(psoc->service_param.service_bitmap);
 
-	DFS_PRINTK("%s: dfs_offload %d\n", __func__, dfs_offload);
+	dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "dfs_offload %d", dfs_offload);
 
 	status = tgt_dfs_reg_ev_handler(psoc, dfs_offload);
 	if (status != QDF_STATUS_SUCCESS) {
-		DFS_PRINTK("%s: tgt_dfs_reg_ev_handler failed\n", __func__);
+		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tgt_dfs_reg_ev_handler failed");
 		return QDF_STATUS_E_FAILURE;
 	}
 
@@ -258,9 +268,7 @@ QDF_STATUS wifi_dfs_psoc_enable(struct wlan_objmgr_psoc *psoc)
 			WLAN_SER_CMD_SCAN,
 			dfs_scan_serialization_comp_info_cb);
 	if (status != QDF_STATUS_SUCCESS) {
-		DFS_PRINTK(
-				"%s :Serialize scan cmd register failed\n",
-				__func__);
+		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "Serialize scan cmd register failed");
 		return status;
 	}
 
@@ -275,9 +283,7 @@ QDF_STATUS wifi_dfs_psoc_disable(struct wlan_objmgr_psoc *psoc)
 			WLAN_UMAC_COMP_DFS,
 			WLAN_SER_CMD_SCAN);
 	if (status != QDF_STATUS_SUCCESS) {
-		DFS_PRINTK(
-				"%s :Serialize scan cmd deregister failed\n",
-				__func__);
+		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "Serialize scan cmd deregister failed");
 		return status;
 	}
 

+ 5 - 5
umac/dfs/dispatcher/src/wlan_dfs_mlme_api.c

@@ -75,8 +75,8 @@ static void dfs_send_radar_ind(struct wlan_objmgr_pdev *pdev,
 	sme_msg.bodyptr = NULL;
 	sme_msg.bodyval = vdev_id;
 	scheduler_post_msg(QDF_MODULE_ID_SME, &sme_msg);
-	DFS_PRINTK("%s: eWNI_SME_DFS_RADAR_FOUND pdev%d posted\n",
-		   __func__, vdev_id);
+	dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "eWNI_SME_DFS_RADAR_FOUND pdev%d posted",
+		    vdev_id);
 }
 
 void dfs_mlme_mark_dfs(struct wlan_objmgr_pdev *pdev,
@@ -86,7 +86,7 @@ void dfs_mlme_mark_dfs(struct wlan_objmgr_pdev *pdev,
 		uint64_t flags)
 {
 	if (!pdev) {
-		DFS_PRINTK("%s: null pdev\n", __func__);
+		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "null pdev");
 		return;
 	}
 
@@ -119,8 +119,8 @@ void dfs_mlme_proc_cac(struct wlan_objmgr_pdev *pdev, uint32_t vdev_id)
 	sme_msg.bodyptr = NULL;
 	sme_msg.bodyval = vdev_id;
 	scheduler_post_msg(QDF_MODULE_ID_SME, &sme_msg);
-	DFS_PRINTK("%s: eWNI_SME_DFS_CAC_COMPLETE vdev%d posted\n",
-		   __func__, vdev_id);
+	dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "eWNI_SME_DFS_CAC_COMPLETE vdev%d posted",
+		    vdev_id);
 }
 #endif
 

+ 41 - 18
umac/dfs/dispatcher/src/wlan_dfs_tgt_api.c

@@ -46,8 +46,10 @@ QDF_STATUS tgt_dfs_set_current_channel(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return  QDF_STATUS_E_FAILURE;
+	}
 
 	dfs_set_current_channel(dfs,
 			dfs_ch_freq,
@@ -67,8 +69,10 @@ QDF_STATUS tgt_dfs_radar_enable(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return  QDF_STATUS_E_FAILURE;
+	}
 
 	if (!dfs->dfs_is_offload_enabled)
 		dfs_radar_enable(dfs, no_cac, opmode);
@@ -88,16 +92,18 @@ QDF_STATUS tgt_dfs_process_phyerr(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return  QDF_STATUS_E_FAILURE;
+	}
 
 	if (!dfs->dfs_is_offload_enabled)
 		dfs_process_phyerr(dfs, buf, datalen, r_rssi,
 				r_ext_rssi, r_rs_tstamp, r_fulltsf);
 	else
-		DFS_PRINTK(
-				"%s: Received a pulse from firmware even though the DFS is offloaded\n",
-				__func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"Received a pulse from firmware even though the DFS is offloaded"
+				);
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -109,8 +115,10 @@ QDF_STATUS tgt_dfs_is_precac_timer_running(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return  QDF_STATUS_E_FAILURE;
+	}
 
 	*is_precac_timer_running = dfs_is_precac_timer_running(dfs);
 
@@ -123,8 +131,10 @@ QDF_STATUS tgt_dfs_get_radars(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return  QDF_STATUS_E_FAILURE;
+	}
 
 	if (!dfs->dfs_is_offload_enabled)
 		dfs_get_radars(dfs);
@@ -138,8 +148,10 @@ QDF_STATUS tgt_dfs_destroy_object(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return  QDF_STATUS_E_FAILURE;
+	}
 
 	dfs_destroy_object(dfs);
 	dfs = NULL;
@@ -159,8 +171,10 @@ QDF_STATUS tgt_dfs_control(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return  QDF_STATUS_E_FAILURE;
+	}
 
 	*error = dfs_control(dfs, id, indata, insize, outdata, outsize);
 
@@ -180,8 +194,10 @@ QDF_STATUS tgt_dfs_find_vht80_chan_for_precac(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return  QDF_STATUS_E_FAILURE;
+	}
 
 	dfs_find_vht80_chan_for_precac(dfs,
 			chan_mode,
@@ -202,14 +218,18 @@ QDF_STATUS tgt_dfs_process_radar_ind(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	if (!pdev) {
-		DFS_PRINTK("%s: null pdev\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null pdev");
 		return QDF_STATUS_E_FAILURE;
 	}
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (!dfs || !dfs->dfs_curchan) {
-		DFS_PRINTK("%s: err, dfs=%pK, dfs->dfs_curchan=%pK\n",
-			   __func__, dfs, dfs->dfs_curchan);
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is null");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	if (!dfs->dfs_curchan) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs->dfs_curchan is NULL");
 		return QDF_STATUS_E_FAILURE;
 	}
 
@@ -240,7 +260,7 @@ QDF_STATUS tgt_dfs_reg_ev_handler(struct wlan_objmgr_psoc *psoc,
 
 	pdev = wlan_objmgr_get_pdev_by_id(psoc, 0, WLAN_DFS_ID);
 	if (!pdev) {
-		DFS_PRINTK("%s: null pdev\n", __func__);
+		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "null pdev");
 		return QDF_STATUS_E_FAILURE;
 	}
 
@@ -248,7 +268,8 @@ QDF_STATUS tgt_dfs_reg_ev_handler(struct wlan_objmgr_psoc *psoc,
 	if (dfs_tx_ops && dfs_tx_ops->dfs_reg_ev_handler)
 		status = dfs_tx_ops->dfs_reg_ev_handler(pdev, dfs_offload);
 	else
-		DFS_PRINTK("%s: err, dfs_tx_ops=%pK\n", __func__, dfs_tx_ops);
+		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,
+				"dfs_tx_ops=%p", dfs_tx_ops);
 
 	wlan_objmgr_pdev_release_ref(pdev, WLAN_DFS_ID);
 
@@ -261,8 +282,10 @@ QDF_STATUS tgt_dfs_stop(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs) {
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
 		return  QDF_STATUS_E_FAILURE;
+	}
 
 	dfs_stop(dfs);
 

+ 8 - 8
umac/dfs/dispatcher/src/wlan_dfs_ucfg_api.c

@@ -32,7 +32,7 @@ QDF_STATUS ucfg_dfs_is_ap_cac_timer_running(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*is_ap_cac_timer_running = dfs_is_ap_cac_timer_running(dfs);
@@ -47,7 +47,7 @@ QDF_STATUS ucfg_dfs_getnol(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_getnol(dfs, dfs_nolinfo);
@@ -63,7 +63,7 @@ QDF_STATUS ucfg_dfs_override_cac_timeout(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*status = dfs_override_cac_timeout(dfs, cac_timeout);
@@ -79,7 +79,7 @@ QDF_STATUS ucfg_dfs_get_override_cac_timeout(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*status = dfs_get_override_cac_timeout(dfs, cac_timeout);
@@ -94,7 +94,7 @@ QDF_STATUS ucfg_dfs_get_override_precac_timeout(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_get_override_precac_timeout(dfs, precac_timeout);
@@ -109,7 +109,7 @@ QDF_STATUS ucfg_dfs_override_precac_timeout(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_override_precac_timeout(dfs, precac_timeout);
@@ -124,7 +124,7 @@ QDF_STATUS ucfg_dfs_set_precac_enable(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_set_precac_enable(dfs, value);
@@ -139,7 +139,7 @@ QDF_STATUS ucfg_dfs_get_precac_enable(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*buff = dfs_get_precac_enable(dfs);

+ 59 - 48
umac/dfs/dispatcher/src/wlan_dfs_utils_api.c

@@ -42,7 +42,7 @@ QDF_STATUS utils_dfs_reset(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_reset(dfs);
@@ -59,7 +59,7 @@ QDF_STATUS utils_dfs_cac_valid_reset(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_cac_valid_reset(dfs, prevchan_ieee, prevchan_flags);
@@ -73,7 +73,7 @@ QDF_STATUS utils_dfs_reset_precaclists(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_reset_precaclists(dfs);
@@ -87,7 +87,7 @@ QDF_STATUS utils_dfs_cancel_precac_timer(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_cancel_precac_timer(dfs);
@@ -102,7 +102,7 @@ QDF_STATUS utils_dfs_is_precac_done(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*is_precac_done = dfs_is_precac_done(dfs);
@@ -116,7 +116,7 @@ QDF_STATUS utils_dfs_cancel_cac_timer(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_cancel_cac_timer(dfs);
@@ -130,7 +130,7 @@ QDF_STATUS utils_dfs_start_cac_timer(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_start_cac_timer(dfs);
@@ -144,7 +144,7 @@ QDF_STATUS utils_dfs_cac_stop(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_cac_stop(dfs);
@@ -157,7 +157,7 @@ QDF_STATUS utils_dfs_stacac_stop(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_stacac_stop(dfs);
@@ -174,7 +174,7 @@ QDF_STATUS utils_dfs_random_channel(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*target_channel = dfs_random_channel(dfs,
@@ -190,7 +190,7 @@ QDF_STATUS utils_dfs_get_usenol(struct wlan_objmgr_pdev *pdev, uint16_t *usenol)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*usenol = dfs_get_usenol(dfs);
@@ -204,7 +204,7 @@ QDF_STATUS utils_dfs_radar_disable(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_radar_disable(dfs);
@@ -219,7 +219,7 @@ QDF_STATUS utils_dfs_set_update_nol_flag(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_set_update_nol_flag(dfs, val);
@@ -234,7 +234,7 @@ QDF_STATUS utils_dfs_get_update_nol_flag(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*nol_flag = dfs_get_update_nol_flag(dfs);
@@ -249,7 +249,7 @@ QDF_STATUS utils_dfs_get_rn_use_nol(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*rn_use_nol = dfs_get_rn_use_nol(dfs);
@@ -264,7 +264,7 @@ QDF_STATUS utils_dfs_get_nol_timeout(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*dfs_nol_timeout = dfs_get_nol_timeout(dfs);
@@ -280,7 +280,7 @@ QDF_STATUS utils_dfs_nol_addchan(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_nol_addchan(dfs, freq, dfs_nol_timeout);
@@ -294,7 +294,7 @@ QDF_STATUS utils_dfs_nol_update(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_nol_update(dfs);
@@ -308,7 +308,7 @@ QDF_STATUS utils_dfs_second_segment_radar_disable(struct wlan_objmgr_pdev *pdev)
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_second_segment_radar_disable(dfs);
@@ -322,7 +322,7 @@ QDF_STATUS utils_dfs_is_ignore_dfs(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*ignore_dfs = dfs->dfs_ignore_dfs;
@@ -337,7 +337,7 @@ QDF_STATUS utils_dfs_is_cac_valid(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*is_cac_valid = dfs->dfs_cac_valid;
@@ -352,7 +352,7 @@ QDF_STATUS utils_dfs_is_ignore_cac(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	*ignore_cac = dfs->dfs_ignore_cac;
@@ -367,7 +367,7 @@ QDF_STATUS utils_dfs_set_cac_timer_running(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs->dfs_cac_timer_running = val;
@@ -385,7 +385,7 @@ QDF_STATUS utils_dfs_get_nol_chfreq_and_chwidth(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_get_nol_chfreq_and_chwidth(nollist, nol_chfreq, nol_chwidth, index);
@@ -401,7 +401,7 @@ QDF_STATUS utils_dfs_update_cur_chan_flags(struct wlan_objmgr_pdev *pdev,
 	struct wlan_dfs *dfs;
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
-	if (dfs == NULL)
+	if (!dfs)
 		return  QDF_STATUS_E_FAILURE;
 
 	dfs_update_cur_chan_flags(dfs, flags, flagext);
@@ -428,16 +428,22 @@ static void utils_dfs_get_chan_list(struct wlan_objmgr_pdev *pdev,
 	int i = 0, j = 0;
 	enum channel_state state;
 	struct regulatory_channel *cur_chan_list;
+	struct wlan_dfs *dfs;
+
+	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
+	if (!dfs)
+		return;
 
 	cur_chan_list = qdf_mem_malloc(NUM_CHANNELS *
 			sizeof(struct regulatory_channel));
 	if (cur_chan_list == NULL)
-		DFS_PRINTK("%s: fail to alloc\n", __func__);
+		dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS, "fail to alloc");
 
 	if (wlan_reg_get_current_chan_list(
 			pdev, cur_chan_list) != QDF_STATUS_SUCCESS) {
 		*num_chan = 0;
-		DFS_PRINTK("%s: failed to get curr channel list\n", __func__);
+		dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"failed to get curr channel list");
 		return;
 	}
 
@@ -470,7 +476,7 @@ static void utils_dfs_get_chan_list(struct wlan_objmgr_pdev *pdev,
 	psoc = wlan_pdev_get_psoc(pdev);
 	if (!psoc) {
 		*num_chan = 0;
-		DFS_PRINTK("%s: null psoc\n", __func__);
+		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "null psoc");
 		return;
 	}
 
@@ -486,8 +492,9 @@ static void utils_dfs_get_chan_list(struct wlan_objmgr_pdev *pdev,
 				&len, weight_list, weight_len, true);
 
 	if (*num_chan < len) {
-		DFS_PRINTK("%s: Invalid len src=%d, dst=%d\n",
-			   __func__, *num_chan, len);
+		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,
+				"Invalid len src=%d, dst=%d",
+				*num_chan, len);
 		*num_chan = 0;
 		return;
 	}
@@ -498,7 +505,7 @@ static void utils_dfs_get_chan_list(struct wlan_objmgr_pdev *pdev,
 			wlan_reg_chan_to_freq(pdev, pcl_ch[i]);
 	}
 	*num_chan = i;
-	DFS_PRINTK("%s: num channels %d\n", __func__, i);
+	dfs_info(NULL, WLAN_DEBUG_DFS_ALWAYS, "num channels %d", i);
 }
 #endif
 
@@ -521,26 +528,26 @@ QDF_STATUS dfs_get_random_channel(
 	*target_chan = 0;
 	psoc = wlan_pdev_get_psoc(pdev);
 	if (!psoc) {
-		DFS_PRINTK("%s: null psoc\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null psoc");
 		goto random_chan_error;
 	}
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
 	if (!dfs) {
-		DFS_PRINTK("%s: null dfs\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null dfs");
 		goto random_chan_error;
 	}
 
 	wlan_reg_get_dfs_region(pdev, &dfs_reg);
 	chan_list = qdf_mem_malloc(num_chan * sizeof(*chan_list));
 	if (!chan_list) {
-		DFS_PRINTK("%s: mem alloc failed\n", __func__);
+		dfs_alert(dfs, WLAN_DEBUG_DFS_ALWAYS, "mem alloc failed");
 		goto random_chan_error;
 	}
 
 	utils_dfs_get_chan_list(pdev, chan_list, &num_chan);
 	if (!num_chan) {
-		DFS_PRINTK("%s: zero channels\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "zero channels");
 		goto random_chan_error;
 	}
 
@@ -557,7 +564,8 @@ QDF_STATUS dfs_get_random_channel(
 
 	ch_params->center_freq_seg0 = cur_chan.dfs_ch_vhtop_ch_freq_seg1;
 	ch_params->center_freq_seg1 = cur_chan.dfs_ch_vhtop_ch_freq_seg2;
-	DFS_PRINTK("%s: input width=%d\n", __func__, ch_params->ch_width);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+			"input width=%d", ch_params->ch_width);
 
 	if (*target_chan) {
 		wlan_reg_set_channel_params(pdev,
@@ -566,9 +574,11 @@ QDF_STATUS dfs_get_random_channel(
 		status = QDF_STATUS_SUCCESS;
 	}
 
-	DFS_PRINTK("%s: ch=%d, seg0=%d, seg1=%d, width=%d\n",
-		   __func__, *target_chan, ch_params->center_freq_seg0,
-		   ch_params->center_freq_seg1, ch_params->ch_width);
+	dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS,
+			"ch=%d, seg0=%d, seg1=%d, width=%d",
+			*target_chan, ch_params->center_freq_seg0,
+			ch_params->center_freq_seg1, ch_params->ch_width);
+
 random_chan_error:
 	qdf_mem_free(chan_list);
 
@@ -592,13 +602,14 @@ void dfs_init_nol(struct wlan_objmgr_pdev *pdev)
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
 	psoc = wlan_pdev_get_psoc(pdev);
 	if (!dfs || !psoc) {
-		DFS_PRINTK("%s: dfs %pK, psoc %pK\n", __func__, dfs, psoc);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,
+				"dfs %p, psoc %p", dfs, psoc);
 		return;
 	}
 
 	qdf_dev = psoc->soc_objmgr.qdf_dev;
 	if (!qdf_dev->dev) {
-		DFS_PRINTK("%s: null device\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null device");
 		return;
 	}
 
@@ -607,10 +618,10 @@ void dfs_init_nol(struct wlan_objmgr_pdev *pdev)
 			(uint16_t)sizeof(dfs_nolinfo));
 	if (len > 0) {
 		dfs_set_nol(dfs, dfs_nolinfo.dfs_nol, dfs_nolinfo.num_chans);
-		DFS_PRINTK("%s: nol channels in pld\n", __func__);
+		dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "nol channels in pld");
 		dfs_print_nol(dfs);
 	} else {
-		DFS_PRINTK("%s: no nol in pld\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "no nol in pld");
 	}
 }
 #endif
@@ -631,19 +642,19 @@ void dfs_save_nol(struct wlan_objmgr_pdev *pdev)
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
 	if (!dfs) {
-		DFS_PRINTK("%s: null dfs\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null dfs");
 		return;
 	}
 
 	psoc = wlan_pdev_get_psoc(pdev);
 	if (!psoc) {
-		DFS_PRINTK("%s: null psoc\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null psoc");
 		return;
 	}
 
 	qdf_dev = psoc->soc_objmgr.qdf_dev;
 	if (!qdf_dev->dev) {
-		DFS_PRINTK("%s: null device\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null device");
 		return;
 	}
 
@@ -669,7 +680,7 @@ void dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev)
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
 	if (!dfs) {
-		DFS_PRINTK("%s: null dfs\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null dfs");
 		return;
 	}
 
@@ -683,7 +694,7 @@ void dfs_clear_nol_channels(struct wlan_objmgr_pdev *pdev)
 
 	dfs = global_dfs_to_mlme.pdev_get_comp_private_obj(pdev);
 	if (!dfs) {
-		DFS_PRINTK("%s: null dfs\n", __func__);
+		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "null dfs");
 		return;
 	}