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: declare the data structure to hold CFR specific configurations
20  */
21 #ifndef _WLAN_CFR_PUBLIC_STRUCTS_H_
22 #define _WLAN_CFR_PUBLIC_STRUCTS_H_
23 
24 #define MAC_ADDR_LEN 6
25 
26 #define MAX_CAPTURE_COUNT_VAL 0xFFFF
27 
28 /**
29  * enum cfr_cwm_width - Capture bandwidth
30  * @CFR_CWM_WIDTH20: 20 MHz
31  * @CFR_CWM_WIDTH40: 40 MHz
32  * @CFR_CWM_WIDTH80: 80 MHz
33  * @CFR_CWM_WIDTH160: 160 MHz
34  * @CFR_CWM_WIDTH80_80: 80+80 MHz
35  * @CFR_CWM_WIDTH320: 320 MHz
36  * @CFR_CWM_WIDTH_MAX:
37  * @CFR_CWM_WIDTHINVALID:
38  */
39 enum cfr_cwm_width {
40 	CFR_CWM_WIDTH20,
41 	CFR_CWM_WIDTH40,
42 	CFR_CWM_WIDTH80,
43 	CFR_CWM_WIDTH160,
44 	CFR_CWM_WIDTH80_80,
45 	CFR_CWM_WIDTH320,
46 
47 	CFR_CWM_WIDTH_MAX,
48 	CFR_CWM_WIDTHINVALID = 0xff
49 };
50 
51 /**
52  * enum cfr_capture_method - Tx based CFR capture method
53  * @CFR_CAPTURE_METHOD_QOS_NULL : Send QOS Null frame and capture CFR on ACK
54  * @CFR_CAPTURE_METHOD_QOS_NULL_WITH_PHASE: Send QoS Null frame with phase
55  * @CFR_CAPTURE_METHOD_PROBE_RESPONSE : Capture is enabled on probe response
56  * If node is not found, trigger unassociated capture.
57  * @CFR_CAPTURE_METHOD_LAST_VALID:
58  * @CFR_CAPTURE_METHOD_AUTO:
59  * @CFR_CAPTURE_METHOD_MAX:
60  */
61 enum cfr_capture_method {
62 	CFR_CAPTURE_METHOD_QOS_NULL = 0,
63 	CFR_CAPTURE_METHOD_QOS_NULL_WITH_PHASE = 1,
64 	CFR_CAPTURE_METHOD_PROBE_RESPONSE = 2,
65 	CFR_CAPTURE_METHOD_LAST_VALID,
66 	CFR_CAPTURE_METHOD_AUTO = 0xff,
67 	CFR_CAPTURE_METHOD_MAX,
68 };
69 
70 /**
71  * struct cfr_wlanconfig_param - CFR params used to store user provided inputs
72  * @bandwidth : CFR capture bandwidth
73  * @periodicity : CFR capture periodicity in milli seconds
74  * @capture_method : CFR capture method
75  * @mac : peer mac address
76  * @ta : Tx address
77  * @ra : Rx Address
78  * @ta_mask: Tx address mask
79  * @ra_mask: Rx address mask
80  * *** Controls for different capture modes in RCC ***
81  * @en_directed_ftm: Enable capture for directed RTT FTM Packet
82  * @en_directed_ndpa_ndp: Enable NDPA filter followed by directed NDP capture
83  * @en_ta_ra_filter: Enable MAC TA/RA/type filtering channel capture
84  * @en_all_ftm_ack: Enable all FTM and ACK capture
85  * @en_ndpa_ndp_all: Enable NDPA filter followed by NDP capture,
86  *                   capture includes both directed and non-directed packets.
87  * @en_all_pkt: Enable capture mode to filter in all packets
88  * @dis_directed_ftm: Drop directed RTT FTM packets
89  * @dis_directed_ndpa_ndp: Drop directed NDPA and NDP packets
90  * @dis_ta_ra_filter: Disable MAC TA/RA/type filtering channel capture
91  * @dis_all_ftm_ack: Drop all FTM and ACK capture
92  * @dis_ndpa_ndp_all: Drop all NDPA and NDP packets
93  * @dis_all_pkt: Do not filter in any packet
94  * @en_ta_ra_filter_in_as_fp: Filter in frames as FP/MO in m_ta_ra_filter mode
95  *		0: as MO
96  *		1: as FP
97  * @rsvd0: reserved bits
98  *
99  * **** Fixed parameters ****
100  * @cap_dur: Capture duration
101  * @rsvd1: reserved bits
102  * @cap_intvl: Capture interval
103  * FW may limit the interval and duration during which HW may attempt
104  * to capture by programming the user provided values.
105  * These values(cap_dur, cap_intvl) range from 1 us to roughly 16.8 in 1 us
106  * units. Max value is 0xFFFFFF, i.e., 16.777215 s
107  * @rsvd2: reserved bits
108  * @bw: Bandwidth: 20, 40, 80, 160, 240, 320MHz
109  * @nss: 8 bits are allotted for NSS mask. Specifies which numbers of
110  * spatial streams (MIMO factor) are permitted
111  * @grp_id:  Group id could of any value between 0 and 15
112  * @rsvd3: reserved bits
113  * @expected_mgmt_subtype:
114  * @expected_ctrl_subtype:
115  * @expected_data_subtype:
116  * corresponds to mgmt/ ctrl/ data, all are bitmasks, in which each bit
117  * represents the corresponding type/ subtype value as per IEEE80211.
118  * @rsvd5: reserved bits
119  *
120  * @en_cfg:
121  * @reset_cfg: This bitmap of 16 bits, indicates 16 groups.
122  * Valid entry should be in between 0 to 0xFFFF.
123  * Turning on a bit in en_cfg will enable MAC TA_RA filter
124  * for corresponding group; whereas turning on a bit in reset_cfg
125  * will reset all 9 params in the corresponding group to default values.
126  *
127  * @ul_mu_user_mask_lower:
128  * @ul_mu_user_mask_upper:
129  * Since Cypress supports max bandwidth of 80 MHz, maximum number
130  * of users in a UL MU-MIMO transmission would be 37.
131  * mask_lower_32: Bits from 31 to 0 indicate user indices for 32 users.
132  * mask_upper_32: Bits from 0 to 4 indicate user indices from 33 to 37.
133  *
134  * @freeze_tlv_delay_cnt_en: set to enable @freeze_tlv_delay_cnt_thr
135  * @freeze_tlv_delay_cnt_thr: the threshold for MAC to drop the
136  * freeze TLV. only be applicable if @freeze_tlv_delay_cnt_en is enabled.
137  * @rsvd6: reserved bits
138  *
139  * @cap_count: After capture_count+1 number of captures, MAC stops RCC and
140  * waits for capture_interval duration before enabling again
141  *
142  * @cap_intval_mode_sel: 0 indicates capture_duration mode, 1 indicates the
143  * capture_count mode.
144  * @rsvd7: reserved bits
145  */
146 struct cfr_wlanconfig_param {
147 	enum cfr_cwm_width bandwidth;
148 	uint32_t periodicity;
149 	enum cfr_capture_method capture_method;
150 	uint8_t mac[MAC_ADDR_LEN];
151 #ifdef WLAN_ENH_CFR_ENABLE
152 	uint8_t ta[MAC_ADDR_LEN];
153 	uint8_t ra[MAC_ADDR_LEN];
154 	uint8_t ta_mask[MAC_ADDR_LEN];
155 	uint8_t ra_mask[MAC_ADDR_LEN];
156 	uint16_t en_directed_ftm             :1,
157 		 en_directed_ndpa_ndp        :1,
158 		 en_ta_ra_filter             :1,
159 		 en_all_ftm_ack              :1,
160 		 en_ndpa_ndp_all             :1,
161 		 en_all_pkt                  :1,
162 		 dis_directed_ftm            :1,
163 		 dis_directed_ndpa_ndp       :1,
164 		 dis_ta_ra_filter            :1,
165 		 dis_all_ftm_ack             :1,
166 		 dis_ndpa_ndp_all            :1,
167 		 dis_all_pkt                 :1,
168 		 en_ta_ra_filter_in_as_fp    :1,
169 		 rsvd0                       :3;
170 
171 	uint32_t cap_dur                     :24,
172 		 rsvd1                       :8;
173 	uint32_t cap_intvl                   :24,
174 		 rsvd2                       :8;
175 	uint32_t bw                          :6,
176 		 nss                         :8,
177 		 grp_id                      :4,
178 		 rsvd3                       :14;
179 
180 	uint32_t expected_mgmt_subtype       :16,
181 		 expected_ctrl_subtype       :16;
182 
183 	uint32_t expected_data_subtype       :16,
184 		 rsvd5                       :16;
185 
186 	uint32_t en_cfg                      :16,
187 		 reset_cfg                   :16;
188 
189 	uint32_t ul_mu_user_mask_lower;
190 	uint32_t ul_mu_user_mask_upper;
191 
192 	uint32_t freeze_tlv_delay_cnt_en :1,
193 		 freeze_tlv_delay_cnt_thr :8,
194 		 rsvd6 :23;
195 
196 	uint32_t cap_count                   :16,
197 		 cap_intval_mode_sel         :1,
198 		 rsvd7                       :15;
199 #endif
200 };
201 
202 #endif /* _WLAN_CFR_PUBLIC_STRUCTS_H_ */
203 
204