xref: /wlan-dirver/qca-wifi-host-cmn/umac/cfr/dispatcher/inc/wlan_cfr_utils_api.h (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
1 /*
2  * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef _WLAN_CFR_UTILS_API_H_
21 #define _WLAN_CFR_UTILS_API_H_
22 
23 #include <wlan_objmgr_cmn.h>
24 #include <qdf_streamfs.h>
25 #ifdef WLAN_ENH_CFR_ENABLE
26 #include <qdf_timer.h>
27 #endif
28 
29 #define cfr_alert(format, args...) \
30 		QDF_TRACE_FATAL(QDF_MODULE_ID_CFR, format, ## args)
31 
32 #define cfr_err(format, args...) \
33 		QDF_TRACE_ERROR(QDF_MODULE_ID_CFR, format, ## args)
34 
35 #define cfr_warn(format, args...) \
36 		QDF_TRACE_WARN(QDF_MODULE_ID_CFR, format, ## args)
37 
38 #define cfr_info(format, args...) \
39 		QDF_TRACE_INFO(QDF_MODULE_ID_CFR, format, ## args)
40 
41 #define cfr_debug(format, args...) \
42 		QDF_TRACE_DEBUG(QDF_MODULE_ID_CFR, format, ## args)
43 
44 #define DBR_EVENT_TIMEOUT_IN_MS_CFR 1
45 #define DBR_NUM_RESP_PER_EVENT_CFR 1
46 #define MAX_CFR_ENABLED_CLIENTS 10
47 #define CFR_CAPTURE_HOST_MEM_REQ_ID 9
48 #define CFR_HOST_MEM_READ_INDEX_DEFAULT 8
49 #define CFR_VENDOR_ID 0x8cfdf0
50 #ifdef WLAN_ENH_CFR_ENABLE
51 #define MAX_CFR_MU_USERS 4
52 #define NUM_CHAN_CAPTURE_STATUS 4
53 #define NUM_CHAN_CAPTURE_REASON 6
54 #if defined(QCA_WIFI_QCA6750) || defined(QCA_WIFI_QCA6490)
55 #define MAX_TA_RA_ENTRIES 4
56 #define MAX_RESET_CFG_ENTRY 0xF
57 #else
58 #define MAX_TA_RA_ENTRIES 16
59 #define MAX_RESET_CFG_ENTRY 0xFFFF
60 #endif
61 #define CFR_INVALID_VDEV_ID 0xff
62 #define DEFAULT_SRNGID_CFR 0
63 #endif
64 
65 #define MAX_CFR_PRD  (10 * 60 * 1000)   /* 10 minutes */
66 #define CFR_MOD_PRD  10                 /* CFR period to be multiples of 10ms */
67 
68 #define MAX_AGC_GAIN 62
69 
70 enum cfrmetaversion {
71 	CFR_META_VERSION_NONE,
72 	CFR_META_VERSION_1, /* initial version for legacy_cfr_metadata */
73 	CFR_META_VERSION_2, /* initial version for dbr_cfr_metadata */
74 	CFR_META_VERSION_3, /* initial version for enh_cfr_metadata */
75 	CFR_META_VERSION_4, /* agc gain, cfo, rx_start_ts in dbr_cfr_metadata */
76 	CFR_META_VERSION_5, /* agc gain, cfo, rx_start_ts in enh_cfr_metadata */
77 	CFR_META_VERSION_6, /* mcs, gi_type in dbr_cfr_metadata */
78 	CFR_META_VERSION_7, /* mcs, gi_type, sig_info in enh_cfr_metadata */
79 	CFR_META_VERSION_8, /* agc gain table index in dbr_cfr_metadata */
80 	CFR_META_VERSION_9, /* agc gain table index in enh_cfr_metadata */
81 	CFR_META_VERSION_MAX = 0xFF,
82 };
83 
84 enum cfrdataversion {
85 	CFR_DATA_VERSION_NONE,
86 	CFR_DATA_VERSION_1,
87 	CFR_DATA_VERSION_MAX = 0xFF,
88 };
89 
90 enum cfrplatformtype {
91 	CFR_PLATFORM_TYPE_NONE,
92 	CFR_PLATFORM_TYPE_MIPS,
93 	CFR_PLATFORM_TYPE_ARM,
94 	CFR_PLATFFORM_TYPE_MAX = 0xFF,
95 };
96 
97 enum cfrradiotype {
98 	CFR_CAPTURE_RADIO_NONE,
99 	CFR_CAPTURE_RADIO_OSPREY,
100 	CFR_CAPTURE_RADIO_PEAKCOCK,
101 	CFR_CAPTURE_RADIO_SCORPION,
102 	CFR_CAPTURE_RADIO_HONEYBEE,
103 	CFR_CAPTURE_RADIO_DRAGONFLY,
104 	CFR_CAPTURE_RADIO_JET,
105 	CFR_CAPTURE_RADIO_PEREGRINE = 17,
106 	CFR_CAPTURE_RADIO_SWIFT,
107 	CFR_CAPTURE_RADIO_BEELINER,
108 	CFR_CAPTURE_RADIO_CASCADE,
109 	CFR_CAPTURE_RADIO_DAKOTA,
110 	CFR_CAPTURE_RADIO_BESRA,
111 	CFR_CAPTURE_RADIO_HKV2,
112 	CFR_CAPTURE_RADIO_CYP,
113 	CFR_CAPTURE_RADIO_HSP,
114 	CFR_CAPTURE_RADIO_PINE,
115 	CFR_CAPTURE_RADIO_ADRASTEA,
116 	CFR_CAPTURE_RADIO_MAPLE,
117 	CFR_CAPTURE_RADIO_MOSELLE,
118 	CFR_CAPTURE_RADIO_SPRUCE,
119 	CFR_CAPTURE_RADIO_ALDER,
120 	CFR_CAPTURE_RADIO_WAIKIKI,
121 	CFR_CAPTURE_RADIO_KIWI,
122 	CFR_CAPTURE_RADIO_MANGO,
123 	CFR_CAPTURE_RADIO_MIAMI,
124 	CFR_CAPTURE_RADIO_YORK,
125 	CFR_CAPTURE_RADIO_PEACH,
126 	CFR_CAPTURE_RADIO_MAX = 0xFF,
127 };
128 
129 enum ack_capture_mode {
130 	CFR_LEGACY_ACK     = 0,
131 	CFR_DUP_LEGACY_ACK = 1,
132 	CFR_HT_ACK         = 2,
133 	CFR_VHT_ACK        = 3,
134 	CFR_INVALID_ACK, /*Always keep this at last*/
135 };
136 
137 /* Similar to WMI_PEER_CFR_CAPTURE_METHOD used in one-shot capture */
138 enum cfr_capture_type {
139 	CFR_TYPE_METHOD_NULL_FRAME = 0,
140 	CFR_TYPE_METHOD_NULL_FRAME_WITH_PHASE = 1,
141 	CFR_TYPE_METHOD_PROBE_RESP = 2,
142 	CFR_TYPE_METHOD_TM = 3,
143 	CFR_TYPE_METHOD_FTM = 4,
144 	CFR_TYPE_METHOD_ACK_RESP_TO_TM_FTM = 5,
145 	CFR_TYPE_METHOD_TA_RA_TYPE_FILTER = 6,
146 	CFR_TYPE_METHOD_NDPA_NDP = 7,
147 	CFR_TYPE_METHOD_ALL_PACKET = 8,
148 	/* Add new capture methods before this line */
149 	CFR_TYPE_METHOD_LAST_VALID,
150 	CFR_TYPE_METHOD_AUTO = 0xff,
151 	CFR_TYPE_METHOD_MAX,
152 };
153 
154 #define HOST_MAX_CHAINS 8
155 
156 /* ensure to add new members at the end of the structure only */
157 struct dbr_cfr_metadata {
158 	u_int8_t    peer_addr[QDF_MAC_ADDR_SIZE];
159 	u_int8_t    status;
160 	u_int8_t    capture_bw;
161 	u_int8_t    channel_bw;
162 	u_int8_t    phy_mode;
163 	u_int16_t   prim20_chan;
164 	u_int16_t   center_freq1;
165 	u_int16_t   center_freq2;
166 	u_int8_t    capture_mode;
167 	u_int8_t    capture_type;
168 	u_int8_t    sts_count;
169 	u_int8_t    num_rx_chain;
170 	u_int32_t   timestamp;
171 	u_int32_t   length;
172 	u_int32_t   chain_rssi[HOST_MAX_CHAINS];
173 	u_int16_t   chain_phase[HOST_MAX_CHAINS];
174 	u_int32_t   rtt_cfo_measurement;
175 	u_int8_t    agc_gain[HOST_MAX_CHAINS];
176 	u_int32_t   rx_start_ts;
177 	u_int16_t   mcs_rate;
178 	u_int16_t   gi_type;
179 	u_int8_t    agc_gain_tbl_index[HOST_MAX_CHAINS];
180 } __attribute__ ((__packed__));
181 
182 #ifdef WLAN_ENH_CFR_ENABLE
183 struct cfr_su_sig_info {
184 	u_int8_t coding;
185 	u_int8_t stbc;
186 	u_int8_t beamformed;
187 	u_int8_t dcm;
188 	u_int8_t ltf_size;
189 	u_int8_t sgi;
190 	u_int16_t reserved;
191 } __attribute__ ((__packed__));
192 
193 /* ensure to add new members at the end of the structure only */
194 struct enh_cfr_metadata {
195 	u_int8_t    status;
196 	u_int8_t    capture_bw;
197 	u_int8_t    channel_bw;
198 	u_int8_t    phy_mode;
199 	u_int16_t   prim20_chan;
200 	u_int16_t   center_freq1;
201 	u_int16_t   center_freq2;
202 	u_int8_t    capture_mode; /* ack_capture_mode */
203 	u_int8_t    capture_type; /* cfr_capture_type */
204 	u_int8_t    sts_count;
205 	u_int8_t    num_rx_chain;
206 	u_int64_t   timestamp;
207 	u_int32_t   length;
208 	u_int8_t    is_mu_ppdu;
209 	u_int8_t    num_mu_users;
210 	union {
211 		u_int8_t    su_peer_addr[QDF_MAC_ADDR_SIZE];
212 		u_int8_t    mu_peer_addr[MAX_CFR_MU_USERS][QDF_MAC_ADDR_SIZE];
213 	} peer_addr;
214 	u_int32_t   chain_rssi[HOST_MAX_CHAINS];
215 	u_int16_t   chain_phase[HOST_MAX_CHAINS];
216 	u_int32_t   rtt_cfo_measurement;
217 	u_int8_t    agc_gain[HOST_MAX_CHAINS];
218 	u_int32_t   rx_start_ts;
219 	u_int16_t   mcs_rate;
220 	u_int16_t   gi_type;
221 	struct cfr_su_sig_info sig_info;
222 	u_int8_t    agc_gain_tbl_index[HOST_MAX_CHAINS];
223 } __attribute__ ((__packed__));
224 #endif
225 
226 #define  CFR_META_DATA_LEN \
227 	(sizeof(struct csi_cfr_header) - sizeof(struct cfr_header_cmn))
228 
229 struct cfr_header_cmn {
230 	u_int32_t   start_magic_num;
231 	u_int32_t   vendorid;
232 	u_int8_t    cfr_metadata_version;
233 	u_int8_t    cfr_data_version;
234 	u_int8_t    chip_type;
235 	u_int8_t    pltform_type;
236 	u_int32_t   cfr_metadata_len;
237 	u_int64_t   host_real_ts;
238 } __attribute__ ((__packed__));
239 
240 struct csi_cfr_header {
241 	struct cfr_header_cmn cmn;
242 	union {
243 		struct dbr_cfr_metadata meta_dbr;
244 #ifdef WLAN_ENH_CFR_ENABLE
245 		struct enh_cfr_metadata meta_enh;
246 #endif
247 	} u;
248 } __attribute__ ((__packed__));
249 
250 /**
251  * struct cfr_capture_params - structure to store cfr config param
252  * @bandwidth: bandwidth of capture
253  * @period: period of capture
254  * @method: enum of method being followed to capture cfr data. 0-QoS null data
255  */
256 struct cfr_capture_params {
257 	u_int8_t   bandwidth;
258 	u_int32_t  period;
259 	u_int8_t   method;
260 };
261 
262 /**
263  * struct psoc_cfr - private psoc object for cfr
264  * @psoc_obj: pointer to psoc object
265  * @is_cfr_capable: flag to determine if cfr is enabled or not
266  * @is_cap_interval_mode_sel_support: flag to determine if target supports both
267  *				      capture_count and capture_duration modes
268  *				      with a nob provided to configure
269  * @is_mo_marking_support: flag to determine if MO marking is supported or not
270  * @is_aoa_for_rcc_support:
271  */
272 struct psoc_cfr {
273 	struct wlan_objmgr_psoc *psoc_obj;
274 	uint8_t is_cfr_capable;
275 #ifdef WLAN_ENH_CFR_ENABLE
276 	uint8_t is_cap_interval_mode_sel_support;
277 	uint8_t is_mo_marking_support;
278 	uint8_t is_aoa_for_rcc_support;
279 #endif
280 };
281 
282 /**
283  * struct cfr_wmi_host_mem_chunk - wmi mem chunk related
284  * @vaddr: pointer to virtual address
285  * @paddr: physical address
286  * @len: len of the mem chunk allocated
287  * @req_id: reqid related to the mem chunk
288  */
289 struct cfr_wmi_host_mem_chunk {
290 	uint32_t *vaddr;
291 	qdf_dma_addr_t paddr;
292 	uint32_t len;
293 	uint32_t req_id;
294 };
295 
296 struct whal_cfir_dma_hdr {
297 	uint16_t
298 		// 'BA'
299 		tag                 : 8,
300 		// '02', length of header in 4 octet units
301 		length              : 6,
302 		// 00
303 		reserved            : 2;
304 	uint16_t
305 		// [16]
306 		upload_done         : 1,
307 		// [17:18], 0: invalid, 1: CFR, 2: CIR, 3: DebugH
308 		capture_type        : 3,
309 		// [19:20], 0: Legacy, 1: HT, 2: VHT, 3: HE
310 		preamble_type       : 2,
311 		// [21:23], 0: 1-stream, 1: 2-stream, ..., 7: 8-stream
312 		nss                 : 3,
313 		// [24:27], 0: invalid, 1: 1-chain, 2: 2-chain, etc.
314 		num_chains          : 3,
315 		// [28:30], 0: 20 MHz, 1: 40 MHz, 2: 80 MHz, 3: 160 MHz
316 		upload_pkt_bw       : 3,    // [31]
317 		sw_peer_id_valid    : 1;
318 	uint16_t
319 		sw_peer_id          : 16;   // [15:0]
320 	uint16_t
321 		phy_ppdu_id         : 16;   // [15:0]
322 };
323 
324 #define MAX_LUT_ENTRIES 140 /* For HKv2 136 is max */
325 
326 /**
327  * struct look_up_table - Placeholder for 2 asynchronous events (DBR and
328  * TXRX event)
329  * @dbr_recv: Indicates whether WMI for DBR completion is received or not
330  * @tx_recv: Indicates whether WMI for TX completion (or) WDI event for RX
331  * status is received or not
332  * @data: pointer to CFR data that ucode DMAs to host memory
333  * @data_len: length of CFR data DMAed by ucode
334  * @dbr_ppdu_id: PPDU id retrieved from DBR completion WMI event
335  * @tx_ppdu_id: PPDU id retrieved from WMI TX completion event (or) PPDU status
336  * TLV
337  * @dbr_address: Physical address of the CFR data dump retrieved from DBR
338  * completion WMI event
339  * @tx_address1: Physical address of the CFR data from TX/RX event
340  * @tx_address2: Physical address of the CFR data from TX/RX event
341  * @header: CFR header constructed by host
342  * @dma_hdr: CFR header constructed by ucode
343  * @txrx_tstamp: Timestamp when TX/RX event was received
344  * @dbr_tstamp: Timestamp when DBR completion event was received
345  * @header_length: Length of header DMAed by ucode in words
346  * @payload_length: Length of CFR payload
347  */
348 struct look_up_table {
349 	bool dbr_recv;
350 	bool tx_recv;
351 	uint8_t *data; /* capture payload */
352 	uint32_t data_len; /* capture len */
353 	uint16_t dbr_ppdu_id; /* ppdu id from dbr */
354 	uint16_t tx_ppdu_id; /* ppdu id from TX event */
355 	qdf_dma_addr_t dbr_address; /* capture len */
356 	uint32_t tx_address1; /* capture len */
357 	uint32_t tx_address2; /* capture len */
358 	struct csi_cfr_header header;
359 	struct whal_cfir_dma_hdr dma_hdr;
360 	uint64_t txrx_tstamp;
361 	uint64_t dbr_tstamp;
362 	uint32_t header_length;
363 	uint32_t payload_length;
364 };
365 
366 struct unassoc_pool_entry {
367 	struct qdf_mac_addr mac;
368 	struct cfr_capture_params cfr_params;
369 	bool is_valid;
370 };
371 
372 #ifdef WLAN_ENH_CFR_ENABLE
373 /**
374  * struct ta_ra_cfr_cfg - structure to store configuration of 16 groups in
375  * M_TA_RA mode
376  * @filter_group_id: Filter group number for which the below filters needs to be
377  * applied
378  * @bw: CFR capture will be done for packets matching the bandwidths specified
379  * within this bitmask
380  * @nss: CFR capture will be done for packets matching the Nss specified within
381  * this bitmask
382  * @rsvd0: reserved bits
383  * @valid_ta: Ta_addr is valid if set
384  * @valid_ta_mask: Ta_addr_mask is valid if set
385  * @valid_ra: Ra_addr is valid if set
386  * @valid_ra_mask: Ra_addr_mask is valid if set
387  * @valid_bw_mask: Bandwidth is valid if set
388  * @valid_nss_mask: NSS is valid if set
389  * @valid_mgmt_subtype: Mgmt_subtype is valid if set
390  * @valid_ctrl_subtype: Ctrl_subtype is valid if set
391  * @valid_data_subtype: Data_subtype is valid if set
392  * @rsvd1: reserved bits
393  * @mgmt_subtype_filter: Managments Packets matching the subtype filter
394  * categories will be filtered in by MAC for CFR capture.
395  * @ctrl_subtype_filter: Control Packets matching the subtype filter
396  * categories will be filtered in by MAC for CFR capture.
397  * @data_subtype_filter: Data Packets matching the subtype filter
398  * categories will be filtered in by MAC for CFR capture.
399  * @tx_addr: Packets whose transmitter address matches (tx_addr & tx_addr_mask)
400  * will be filtered in by MAC
401  * @tx_addr_mask: Packets whose transmitter address matches (tx_addr &
402  * tx_addr_mask) will be filtered in by MAC
403  * @rx_addr: Packets whose receiver address matches (rx_addr & rx_addr_mask)
404  * will be filtered in by MAC
405  * @rx_addr_mask: Packets whose receiver address matches (rx_addr &
406  * rx_addr_mask) will be filtered in by MAC
407  */
408 struct ta_ra_cfr_cfg {
409 	uint8_t filter_group_id;
410 	uint16_t bw                          :6,
411 		 nss                         :8,
412 		 rsvd0                       :2;
413 	uint16_t valid_ta                    :1,
414 		 valid_ta_mask               :1,
415 		 valid_ra                    :1,
416 		 valid_ra_mask               :1,
417 		 valid_bw_mask               :1,
418 		 valid_nss_mask              :1,
419 		 valid_mgmt_subtype          :1,
420 		 valid_ctrl_subtype          :1,
421 		 valid_data_subtype          :1,
422 		 rsvd1                       :7;
423 	uint16_t mgmt_subtype_filter;
424 	uint16_t ctrl_subtype_filter;
425 	uint16_t data_subtype_filter;
426 	uint8_t tx_addr[QDF_MAC_ADDR_SIZE];
427 	uint8_t rx_addr[QDF_MAC_ADDR_SIZE];
428 	uint8_t tx_addr_mask[QDF_MAC_ADDR_SIZE];
429 	uint8_t rx_addr_mask[QDF_MAC_ADDR_SIZE];
430 
431 } qdf_packed;
432 
433 /**
434  * struct cfr_rcc_param - structure to store cfr config param
435  * @pdev_id: pdev_id for identifying the MAC
436  * @vdev_id: vdev_id of current rcc configures
437  * @srng_id: srng id of current rcc configures
438  * @capture_duration: Capture Duration field for which CFR capture has to
439  * happen, in microsecond units
440  * @capture_interval: Capture interval field which is time in between
441  * consecutive CFR capture, in microsecond units
442  * @ul_mu_user_mask_lower: Bitfields indicates which of the users in the current
443  * UL MU transmission are enabled for CFR capture.
444  * @ul_mu_user_mask_upper: This is continuation of the above lower mask.
445  * @freeze_tlv_delay_cnt_en: Enable Freeze TLV delay counter in MAC
446  * @freeze_tlv_delay_cnt_thr: Indicates the number of consecutive Rx packets to
447  * be skipped before CFR capture is enabled again.
448  * @rsvd0: reserved bits
449  * @filter_group_bitmap: Bitfields set indicates which of the CFR group config
450  * is enabled
451  * @m_directed_ftm: Filter Directed FTM ACK frames for CFR capture
452  * @m_all_ftm_ack: Filter All FTM ACK frames for CFR capture
453  * @m_ndpa_ndp_directed: Filter NDPA NDP Directed Frames for CFR capture
454  * @m_ndpa_ndp_all: Filter all NDPA NDP for CFR capture
455  * @m_ta_ra_filter: Filter Frames based on TA/RA/Subtype as provided in CFR
456  * Group config
457  * @m_all_packet: Filter in All packets for CFR Capture
458  * @en_ta_ra_filter_in_as_fp: Filter in frames as FP/MO in m_ta_ra_filter mode
459  * @rsvd1: reserved bits
460  * @num_grp_tlvs: Indicates the number of groups in M_TA_RA mode, that have
461  * changes in the current commit session, use to construct WMI group TLV(s)
462  * @curr: Placeholder for M_TA_RA group config in current commit session
463  * @modified_in_curr_session: Bitmap indicating number of groups in M_TA_RA mode
464  * that have changed in current commit session.
465  * @capture_count: After capture_count+1 number of captures, MAC stops RCC  and
466  * waits for capture_interval duration before enabling again
467  * @capture_intval_mode_sel: 0 indicates capture_duration mode, 1 indicates the
468  * capture_count mode.
469  * @rsvd2: reserved bits
470  */
471 struct cfr_rcc_param {
472 	uint8_t pdev_id;
473 	uint8_t vdev_id;
474 	uint8_t srng_id;
475 	uint32_t capture_duration;
476 	uint32_t capture_interval;
477 	uint32_t ul_mu_user_mask_lower;
478 	uint32_t ul_mu_user_mask_upper;
479 	uint16_t freeze_tlv_delay_cnt_en  :1,
480 		 freeze_tlv_delay_cnt_thr :8,
481 		 rsvd0 :7;
482 	uint16_t filter_group_bitmap;
483 	uint8_t m_directed_ftm           : 1,
484 		m_all_ftm_ack            : 1,
485 		m_ndpa_ndp_directed      : 1,
486 		m_ndpa_ndp_all           : 1,
487 		m_ta_ra_filter           : 1,
488 		m_all_packet             : 1,
489 		en_ta_ra_filter_in_as_fp : 1,
490 		rsvd1                    : 1;
491 	uint8_t num_grp_tlvs;
492 
493 	struct ta_ra_cfr_cfg curr[MAX_TA_RA_ENTRIES];
494 	unsigned long modified_in_curr_session;
495 	uint32_t capture_count            :16,
496 		 capture_intval_mode_sel  :1,
497 		 rsvd2                    :15;
498 };
499 #endif /* WLAN_ENH_CFR_ENABLE */
500 
501 /**
502  * struct nl_event_cb - nl event cb for cfr data
503  * @vdev_id: vdev id
504  * @pid: PID to which data is sent via unicast nl event
505  * @cfr_nl_cb: callback to send nl event
506  */
507 struct nl_event_cb {
508 	uint8_t vdev_id;
509 	uint32_t pid;
510 	void (*cfr_nl_cb)(uint8_t vdev_id, uint32_t pid,
511 			  const void *data, uint32_t data_len);
512 };
513 
514 /**
515  * struct pdev_cfr - private pdev object for cfr
516  * @pdev_obj: pointer to pdev object
517  * @is_cfr_capable: flag to determine if cfr is enabled or not
518  * @cfr_timer_enable: flag to enable/disable timer
519  * @chip_type: chip type which is defined in enum cfrradiotype
520  * @cfr_mem_chunk: Region of memory used for storing cfr data
521  * @cfr_max_sta_count: Maximum stations supported in one-shot capture mode
522  * @cfr_current_sta_count:
523  * @num_subbufs: No. of sub-buffers used in relayfs
524  * @subbuf_size: Size of sub-buffer used in relayfs
525  * @chan_ptr: Channel in relayfs
526  * @dir_ptr: Parent directory of relayfs file
527  * @lut: lookup table used to store asynchronous DBR and TX/RX events for
528  * correlation
529  * @lut_num: Number of lut
530  * @dbr_buf_size: Size of DBR completion buffer
531  * @dbr_num_bufs: No. of DBR completions
532  * @max_mu_users: Max number of MU users
533  * @tx_evt_cnt: No. of TX completion events till CFR stop was issued
534  * @total_tx_evt_cnt: No. of Tx completion events since wifi was up
535  * @dbr_evt_cnt: No. of WMI DBR completion events
536  * @release_cnt: No. of CFR data buffers relayed to userspace
537  * @tx_peer_status_cfr_fail: No. of tx events without tx status set to
538  * PEER_CFR_CAPTURE_EVT_STATUS_MASK indicating CFR capture failure on a peer.
539  * @tx_evt_status_cfr_fail: No. of tx events without tx status set to
540  * CFR_TX_EVT_STATUS_MASK indicating CFR capture status failure.
541  * @tx_dbr_cookie_lookup_fail: No. of dbr cookie lookup failures during tx event
542  * process.
543  * @rcc_param: Structure to store CFR config for the current commit session
544  * @global: Structure to store accumulated CFR config
545  * @rx_tlv_evt_cnt: Number of CFR WDI events from datapath
546  * @lut_age_timer: Timer to flush pending TXRX/DBR events in lookup table
547  * @lut_timer_init: flag to determine if lut_age_timer is initialized or not
548  * @is_cfr_rcc_capable: Flag to determine if RCC is enabled or not.
549  * @flush_dbr_cnt: No. of un-correlated DBR completions flushed when a newer
550  * PPDU is correlated successfully with newer DBR completion
551  * @invalid_dma_length_cnt: No. of buffers for which CFR DMA header length (or)
552  * data length was invalid
553  * @flush_timeout_dbr_cnt: No. of DBR completion flushed out in ageout logic
554  * @clear_txrx_event: No. of PPDU status TLVs over-written in LUT
555  * @last_success_tstamp: DBR timestamp which indicates that both DBR and TX/RX
556  * events have been received successfully.
557  * @cfr_dma_aborts: No. of CFR DMA aborts in ucode
558  * @is_cap_interval_mode_sel_support: flag to determine if target supports both
559  * @is_mo_marking_support: flag to determine if MO marking is supported or not
560  * @is_aoa_for_rcc_support: flag to determine if AoA is available for RCC or not
561  * capture_count and capture_duration modes with a nob provided to configure.
562  * @unassoc_pool: Pool of un-associated clients used when capture method is
563  * CFR_CAPTURE_METHOD_PROBE_RESPONSE
564  * @nl_cb: call back to register for nl event for cfr data
565  * @lut_lock: Lock to protect access to cfr lookup table
566  * @is_prevent_suspend: CFR wake lock acquired or not
567  * @wake_lock: wake lock for cfr
568  * @runtime_lock: runtime lock for cfr
569  * @freq: current operating freq for which AoA Phase delta values reported by FW
570  * @max_aoa_chains: Indicate the max number of chains to which target supports
571  * AoA data.
572  * @phase_delta: per chain phase delta associated with 62 gain values reported
573  * by FW via WMI_PDEV_AOA_PHASEDELTA_EVENTID.
574  * @ibf_cal_val: Per chain IBF cal value from FW.
575  */
576 /*
577  * To be extended if we get more capbality info
578  * from FW's extended service ready event.
579  */
580 struct pdev_cfr {
581 	struct wlan_objmgr_pdev *pdev_obj;
582 	uint8_t is_cfr_capable;
583 	uint8_t cfr_timer_enable;
584 	uint8_t chip_type;
585 	struct cfr_wmi_host_mem_chunk cfr_mem_chunk;
586 	uint16_t cfr_max_sta_count;
587 	uint16_t cfr_current_sta_count;
588 	uint32_t num_subbufs;
589 	uint32_t subbuf_size;
590 	qdf_streamfs_chan_t chan_ptr;
591 	qdf_dentry_t dir_ptr;
592 	struct look_up_table **lut;
593 	uint32_t lut_num;
594 	uint32_t dbr_buf_size;
595 	uint32_t dbr_num_bufs;
596 	uint32_t max_mu_users;
597 	uint64_t tx_evt_cnt;
598 	uint64_t total_tx_evt_cnt;
599 	uint64_t dbr_evt_cnt;
600 	uint64_t release_cnt;
601 	uint64_t tx_peer_status_cfr_fail;
602 	uint64_t tx_evt_status_cfr_fail;
603 	uint64_t tx_dbr_cookie_lookup_fail;
604 #ifdef WLAN_ENH_CFR_ENABLE
605 	struct cfr_rcc_param rcc_param;
606 	struct ta_ra_cfr_cfg global[MAX_TA_RA_ENTRIES];
607 	uint64_t rx_tlv_evt_cnt;
608 	qdf_timer_t lut_age_timer;
609 	uint8_t lut_timer_init;
610 	uint8_t is_cfr_rcc_capable;
611 	uint64_t flush_dbr_cnt;
612 	uint64_t invalid_dma_length_cnt;
613 	uint64_t flush_timeout_dbr_cnt;
614 	uint64_t clear_txrx_event;
615 	uint64_t last_success_tstamp;
616 	uint64_t cfr_dma_aborts;
617 	uint8_t is_cap_interval_mode_sel_support;
618 	uint8_t is_mo_marking_support;
619 	uint8_t is_aoa_for_rcc_support;
620 #endif
621 	struct unassoc_pool_entry unassoc_pool[MAX_CFR_ENABLED_CLIENTS];
622 	struct nl_event_cb nl_cb;
623 	qdf_spinlock_t lut_lock;
624 #ifdef WLAN_CFR_PM
625 	bool is_prevent_suspend;
626 	qdf_wake_lock_t wake_lock;
627 	qdf_runtime_lock_t runtime_lock;
628 #endif
629 #ifdef WLAN_ENH_CFR_ENABLE
630 	uint32_t freq;
631 	uint32_t max_aoa_chains;
632 	uint16_t phase_delta[HOST_MAX_CHAINS][MAX_AGC_GAIN];
633 	uint32_t ibf_cal_val[HOST_MAX_CHAINS];
634 #endif
635 };
636 
637 /**
638  * enum cfr_capt_status - CFR capture status
639  * @PEER_CFR_CAPTURE_DISABLE: Capture not in progress
640  * @PEER_CFR_CAPTURE_ENABLE: Capture in progress
641  */
642 enum cfr_capt_status {
643 	PEER_CFR_CAPTURE_DISABLE,
644 	PEER_CFR_CAPTURE_ENABLE,
645 };
646 
647 /**
648  * struct peer_cfr - private peer object for cfr
649  * @peer_obj: pointer to peer_obj
650  * @request: Type of request (start/stop)
651  * @bandwidth: bandwitdth of capture for this peer
652  * @period: period of capture for this peer
653  * @capture_method: enum determining type of cfr data capture.
654  *                 0-Qos null data
655  */
656 struct peer_cfr {
657 	struct wlan_objmgr_peer *peer_obj;
658 	u_int8_t   request;            /* start/stop */
659 	u_int8_t   bandwidth;
660 	u_int32_t  period;
661 	u_int8_t   capture_method;
662 };
663 
664 /**
665  * cfr_initialize_pdev() - cfr initialize pdev
666  * @pdev: Pointer to pdev_obj
667  *
668  * Return: status of cfr pdev init
669  */
670 QDF_STATUS cfr_initialize_pdev(struct wlan_objmgr_pdev *pdev);
671 
672 /**
673  * cfr_deinitialize_pdev() - cfr deinitialize pdev
674  * @pdev: Pointer to pdev_obj
675  *
676  * Return: status of cfr pdev deinit
677  */
678 QDF_STATUS cfr_deinitialize_pdev(struct wlan_objmgr_pdev *pdev);
679 
680 /**
681  * wlan_cfr_init() - Global init for cfr.
682  *
683  * Return: status of global init pass/fail
684  */
685 QDF_STATUS wlan_cfr_init(void);
686 
687 /**
688  * wlan_cfr_deinit() - Global de-init for cfr.
689  *
690  * Return: status of global de-init pass/fail
691  */
692 QDF_STATUS wlan_cfr_deinit(void);
693 
694 /**
695  * wlan_cfr_pdev_open() - pdev_open function for cfr.
696  * @pdev: pointer to pdev object
697  *
698  * Return: status of pdev_open pass/fail
699  */
700 QDF_STATUS wlan_cfr_pdev_open(struct wlan_objmgr_pdev *pdev);
701 
702 /**
703  * wlan_cfr_pdev_close() - pdev_close function for cfr.
704  * @pdev: pointer to pdev object
705  *
706  * Return: status of pdev_close pass/fail
707  */
708 QDF_STATUS wlan_cfr_pdev_close(struct wlan_objmgr_pdev *pdev);
709 
710 /**
711  * count_set_bits() - function to count set bits in a bitmap
712  * @value: input bitmap
713  *
714  * Return: No. of set bits
715  */
716 uint8_t count_set_bits(unsigned long value);
717 
718 /**
719  * wlan_cfr_is_feature_disabled() - Check if cfr feature is disabled
720  * @pdev: the physical device object.
721  *
722  * Return : true if cfr is disabled, else false.
723  */
724 bool wlan_cfr_is_feature_disabled(struct wlan_objmgr_pdev *pdev);
725 
726 #ifdef WLAN_ENH_CFR_ENABLE
727 /**
728  * wlan_cfr_rx_tlv_process() - Process PPDU status TLVs and store info in
729  * lookup table
730  * @pdev: PDEV object
731  * @nbuf: ppdu info
732  *
733  * Return: none
734  */
735 void wlan_cfr_rx_tlv_process(struct wlan_objmgr_pdev *pdev, void *nbuf);
736 #endif
737 #endif
738