1 /*
2  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /**
19  * DOC: contains dcs structure definitions
20  */
21 
22 #ifndef _WLAN_DCS_PUBLIC_STRUCTS_H_
23 #define _WLAN_DCS_PUBLIC_STRUCTS_H_
24 
25 /**
26  * enum wlan_host_dcs_type - types of DCS interference events
27  * @WLAN_HOST_DCS_NONE: invalid type
28  * @WLAN_HOST_DCS_CWIM: continuous wave interference
29  * @WLAN_HOST_DCS_WLANIM: wlan interference stats
30  * @WLAN_HOST_DCS_AWGNIM: additive white Gaussian noise (awgn) interference
31  * @WLAN_HOST_DCS_AFC: AFC data update 6 GHz SP channels
32  */
33 enum wlan_host_dcs_type {
34 	WLAN_HOST_DCS_NONE   = 0,      /* 0x0 */
35 	WLAN_HOST_DCS_CWIM   = BIT(0), /* 0x1 */
36 	WLAN_HOST_DCS_WLANIM = BIT(1), /* 0x2 */
37 	WLAN_HOST_DCS_AWGNIM = BIT(2), /* 0x4 */
38 	WLAN_HOST_DCS_AFC    = BIT(3), /* 0x8 */
39 };
40 
41 /**
42  * struct wlan_host_dcs_interference_param - dcs interference parameters
43  * @interference_type: type of DCS interference
44  * @pdev_id: pdev id
45  */
46 struct wlan_host_dcs_interference_param {
47 	uint32_t interference_type;
48 	uint32_t pdev_id;
49 };
50 
51 /**
52  * struct wlan_host_dcs_mib_stats - WLAN IM stats from target to host
53  * @listen_time:
54  * @reg_tx_frame_cnt:
55  * @reg_rx_frame_cnt:
56  * @reg_rxclr_cnt:
57  * @reg_cycle_cnt: delta cycle count
58  * @reg_rxclr_ext_cnt:
59  * @reg_ofdm_phyerr_cnt:
60  * @reg_cck_phyerr_cnt: CCK err count since last reset, read from register
61  */
62 struct wlan_host_dcs_mib_stats {
63 	int32_t listen_time;
64 	uint32_t reg_tx_frame_cnt;
65 	uint32_t reg_rx_frame_cnt;
66 	uint32_t reg_rxclr_cnt;
67 	uint32_t reg_cycle_cnt;
68 	uint32_t reg_rxclr_ext_cnt;
69 	uint32_t reg_ofdm_phyerr_cnt;
70 	uint32_t reg_cck_phyerr_cnt;
71 };
72 
73 /**
74  * struct wlan_host_dcs_im_tgt_stats - DCS IM target stats
75  * @reg_tsf32: current running TSF from the TSF-1
76  * @last_ack_rssi: known last frame rssi, in case of multiple stations, if
77  *      and at different ranges, this would not guarantee that
78  *      this is the least rssi.
79  * @tx_waste_time: sum of all the failed durations in the last
80  *      one second interval.
81  * @rx_time: count how many times the hal_rxerr_phy is marked, in this
82  *      time period
83  * @phyerr_cnt:
84  * @mib_stats: collected mib stats as explained in mib structure
85  * @chan_nf: Channel noise floor (units are in dBm)
86  * @my_bss_rx_cycle_count: BSS rx cycle count
87  * @reg_rxclr_ext40_cnt: extension channel 40Mhz rxclear count
88  * @reg_rxclr_ext80_cnt: extension channel 80Mhz rxclear count
89  */
90 struct wlan_host_dcs_im_tgt_stats {
91 	uint32_t reg_tsf32;
92 	uint32_t last_ack_rssi;
93 	uint32_t tx_waste_time;
94 	uint32_t rx_time;
95 	uint32_t phyerr_cnt;
96 	struct wlan_host_dcs_mib_stats mib_stats;
97 	uint32_t chan_nf;
98 	uint32_t my_bss_rx_cycle_count;
99 	uint32_t reg_rxclr_ext40_cnt;
100 	uint32_t reg_rxclr_ext80_cnt;
101 };
102 
103 /**
104  * struct wlan_host_dcs_ch_util_stats - DCS IM chan utilization stats
105  * @rx_cu: rx channel utilization
106  * @tx_cu: tx channel utilization
107  * @obss_rx_cu: obss rx channel utilization
108  * @total_cu: total channel utilization
109  * @chan_nf: Channel noise floor (units are in dBm)
110  */
111 struct wlan_host_dcs_ch_util_stats {
112 	uint32_t rx_cu;
113 	uint32_t tx_cu;
114 	uint32_t obss_rx_cu;
115 	uint32_t total_cu;
116 	uint32_t chan_nf;
117 };
118 
119 /**
120  * struct wlan_host_dcs_im_user_stats - DCS IM stats requested by userspace
121  * @max_rssi: max rssi of the bss traffic
122  * @min_rssi: min rssi of the bss traffic
123  * @cycle_count: cycle count
124  * @rxclr_count: rx clear count
125  * @rx_frame_count: rx frame count
126  * @my_bss_rx_cycle_count: BSS rx cycle count
127  */
128 struct wlan_host_dcs_im_user_stats {
129 	uint32_t max_rssi;
130 	uint32_t min_rssi;
131 	uint32_t cycle_count;
132 	uint32_t rxclr_count;
133 	uint32_t rx_frame_count;
134 	uint32_t my_bss_rx_cycle_count;
135 };
136 
137 /**
138  * struct wlan_host_dcs_awgn_info - DCS AWGN info
139  * @channel_width: Channel width, enum phy_ch_width
140  * @center_freq: Center frequency of primary channel
141  * @center_freq0: Center frequency of segment 1
142  * @center_freq1: Center frequency of segment 2
143  * @chan_bw_intf_bitmap: Per-20MHz interference bitmap, each bit
144  *  indicates 20MHz in which interference is seen, e.g.
145  *  bit0 - primary 20MHz, bit1 - secondary 20MHz,
146  *  bit2 - secondary 40MHz Lower, bit3 - secondary 40MHz Upper
147  */
148 struct wlan_host_dcs_awgn_info {
149 	enum phy_ch_width channel_width;
150 	qdf_freq_t center_freq;
151 	qdf_freq_t center_freq0;
152 	qdf_freq_t center_freq1;
153 	uint32_t chan_bw_intf_bitmap;
154 };
155 
156 /**
157  * struct wlan_host_dcs_event - define dcs event
158  * @wlan_stat: wlan interference target statistics
159  * @dcs_param: dcs event param
160  * @awgn_info: awgn info
161  */
162 struct wlan_host_dcs_event {
163 	struct wlan_host_dcs_im_tgt_stats wlan_stat;
164 	struct wlan_host_dcs_interference_param dcs_param;
165 	struct wlan_host_dcs_awgn_info awgn_info;
166 };
167 #endif
168