xref: /wlan-driver/qca-wifi-host-cmn/umac/dfs/core/src/filtering/dfs_debug.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2013, 2016-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2002-2010, Atheros Communications Inc.
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14  */
15 
16 /**
17  * DOC: It contains useful print functions that can be used for debug.
18  * Add all debug related functionality into this file.
19  */
20 #include "../dfs.h"
21 #include "wlan_dfs_lmac_api.h"
22 
23 #if defined(WLAN_DFS_PARTIAL_OFFLOAD)
dfs_print_delayline(struct wlan_dfs * dfs,struct dfs_delayline * dl)24 void dfs_print_delayline(struct wlan_dfs *dfs, struct dfs_delayline *dl)
25 {
26 	int i = 0, index;
27 	struct dfs_delayelem *de;
28 
29 	index = dl->dl_firstelem;
30 	for (i = 0; i < dl->dl_numelems; i++) {
31 		de = &dl->dl_elems[index];
32 		dfs_debug(dfs, WLAN_DEBUG_DFS2,
33 				"Elem %u: ts=%llu diff_ts=%u (0x%x) dur=%u, seg_id=%d sidx=%d delta_peak=%d psidx_diff=%d seq_num=%d",
34 				i, de->de_ts, de->de_time, de->de_time,
35 				de->de_dur, de->de_seg_id, de->de_sidx,
36 				de->de_delta_peak, de->de_psidx_diff,
37 				de->de_seq_num);
38 
39 		index = (index + 1) & DFS_MAX_DL_MASK;
40 	}
41 }
42 #endif
43 
dfs_print_filter(struct wlan_dfs * dfs,struct dfs_filter * rf)44 void dfs_print_filter(struct wlan_dfs *dfs, struct dfs_filter *rf)
45 {
46 	dfs_debug(dfs, WLAN_DEBUG_DFS1,
47 		"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",
48 		rf->rf_pulseid, rf->rf_numpulses, rf->rf_minpri, rf->rf_maxpri,
49 		rf->rf_threshold, rf->rf_filterlen, rf->rf_mindur,
50 		rf->rf_maxdur);
51 }
52 
53 /**
54  * dfs_print_filtertype() - Print the filtertype
55  * @dfs: Pointer to wlan_dfs structure.
56  * @ft:  Pointer to dfs_filtertype structure.
57  */
dfs_print_filtertype(struct wlan_dfs * dfs,struct dfs_filtertype * ft)58 static void dfs_print_filtertype(
59 		struct wlan_dfs *dfs,
60 		struct dfs_filtertype *ft)
61 {
62 	uint32_t j;
63 	struct dfs_filter *rf;
64 
65 	for (j = 0; j < ft->ft_numfilters; j++) {
66 		rf = ft->ft_filters[j];
67 		dfs_debug(dfs, WLAN_DEBUG_DFS2,
68 				"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",
69 				j, rf->rf_pulseid, rf->rf_numpulses,
70 				rf->rf_minpri, rf->rf_maxpri,
71 				rf->rf_threshold, rf->rf_filterlen,
72 				rf->rf_mindur, rf->rf_maxdur);
73 	}
74 }
75 
dfs_print_filters(struct wlan_dfs * dfs)76 void dfs_print_filters(struct wlan_dfs *dfs)
77 {
78 	struct dfs_filtertype *ft = NULL;
79 	uint8_t i;
80 
81 	if (!dfs) {
82 		dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS,  "dfs is NULL");
83 		return;
84 	}
85 
86 	for (i = 0; i < DFS_MAX_RADAR_TYPES; i++) {
87 		if (dfs->dfs_radarf[i]) {
88 			ft = dfs->dfs_radarf[i];
89 			if ((ft->ft_numfilters > DFS_MAX_NUM_RADAR_FILTERS) ||
90 					(!ft->ft_numfilters)) {
91 				continue;
92 			}
93 			dfs_debug(dfs, WLAN_DEBUG_DFS2,
94 					"===========ft->ft_numfilters = %u===========",
95 					ft->ft_numfilters);
96 			dfs_print_filtertype(dfs, ft);
97 		}
98 	}
99 }
100