xref: /wlan-driver/qcacld-3.0/core/dp/ol/inc/ol_htt_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2011, 2014-2019-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 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 /**
21  * @file ol_htt_api.h
22  * @brief Specify the general HTT API functions called by the host data SW.
23  * @details
24  *  This file declares the HTT API functions that are not specific to
25  *  either tx nor rx.
26  */
27 #ifndef _OL_HTT_API__H_
28 #define _OL_HTT_API__H_
29 
30 #include <qdf_types.h>          /* qdf_device_t */
31 #include <qdf_nbuf.h>           /* qdf_nbuf_t */
32 #include <athdefs.h>            /* A_STATUS */
33 #include <htc_api.h>            /* HTC_HANDLE */
34 #include "htt.h"                /* htt_dbg_stats_type, etc. */
35 #include <cdp_txrx_cmn.h>       /* ol_pdev_handle */
36 #include <ol_defines.h>
37 #include <cdp_txrx_handle.h>
38 
39 struct htt_pdev_t;
40 typedef struct htt_pdev_t *htt_pdev_handle;
41 
42 htt_pdev_handle
43 htt_pdev_alloc(ol_txrx_pdev_handle txrx_pdev,
44 	struct cdp_cfg *ctrl_pdev,
45 	HTC_HANDLE htc_pdev, qdf_device_t osdev);
46 
47 /**
48  * @brief Allocate and initialize a HTT instance.
49  * @details
50  *  This function allocates and initializes an HTT instance.
51  *  This involves allocating a pool of HTT tx descriptors in
52  *  consistent memory, allocating and filling a rx ring (LL only),
53  *  and connecting the HTC's HTT_DATA_MSG service.
54  *  The HTC service connect call will block, so this function
55  *  needs to be called in passive context.
56  *  Because HTC setup has not been completed at the time this function
57  *  is called, this function cannot send any HTC messages to the target.
58  *  Messages to configure the target are instead sent in the
59  *  htc_attach_target function.
60  *
61  * @param pdev - data SW's physical device handle
62  *      (used as context pointer during HTT -> txrx calls)
63  * @param desc_pool_size - number of HTT descriptors to (pre)allocate
64  * @return success -> HTT pdev handle; failure -> NULL
65  */
66 int
67 htt_attach(struct htt_pdev_t *pdev, int desc_pool_size);
68 
69 /**
70  * @brief Send HTT configuration messages to the target.
71  * @details
72  *  For LL only, this function sends a rx ring configuration message to the
73  *  target.  For HL, this function is a no-op.
74  *
75  * @param htt_pdev - handle to the HTT instance being initialized
76  */
77 QDF_STATUS htt_attach_target(htt_pdev_handle htt_pdev);
78 
79 /**
80  * enum htt_op_mode - Virtual device operation mode
81  *
82  * @htt_op_mode_unknown: Unknown mode
83  * @htt_op_mode_ap: AP mode
84  * @htt_op_mode_ibss: IBSS mode
85  * @htt_op_mode_sta: STA (client) mode
86  * @htt_op_mode_monitor: Monitor mode
87  * @htt_op_mode_ocb: OCB mode
88  */
89 enum htt_op_mode {
90 	htt_op_mode_unknown,
91 	htt_op_mode_ap,
92 	htt_op_mode_ibss,
93 	htt_op_mode_sta,
94 	htt_op_mode_monitor,
95 	htt_op_mode_ocb,
96 };
97 
98 /* no-ops */
99 #define htt_vdev_attach(htt_pdev, vdev_id, op_mode)
100 #define htt_vdev_detach(htt_pdev, vdev_id)
101 #define htt_peer_qos_update(htt_pdev, peer_id, qos_capable)
102 #define htt_peer_uapsdmask_update(htt_pdev, peer_id, uapsd_mask)
103 
104 void htt_pdev_free(htt_pdev_handle pdev);
105 
106 /**
107  * @brief Deallocate a HTT instance.
108  *
109  * @param htt_pdev - handle to the HTT instance being torn down
110  */
111 void htt_detach(htt_pdev_handle htt_pdev);
112 
113 /**
114  * @brief Stop the communication between HTT and target
115  * @details
116  *  For ISOC solution, this function stop the communication between HTT and
117  *  target.
118  *  For Peregrine/Rome, it's already stopped by ol_ath_disconnect_htc
119  *  before ol_txrx_pdev_detach called in ol_ath_detach. So this function is
120  *  a no-op.
121  *  Peregrine/Rome HTT layer is on top of HTC while ISOC solution HTT layer is
122  *  on top of DXE layer.
123  *
124  * @param htt_pdev - handle to the HTT instance being initialized
125  */
126 void htt_detach_target(htt_pdev_handle htt_pdev);
127 
128 /*
129  * @brief Tell the target side of HTT to suspend H2T processing until synced
130  * @param htt_pdev - the host HTT object
131  * @param sync_cnt - what sync count value the target HTT FW should wait for
132  *      before resuming H2T processing
133  */
134 A_STATUS htt_h2t_sync_msg(htt_pdev_handle htt_pdev, uint8_t sync_cnt);
135 
136 int
137 htt_h2t_aggr_cfg_msg(htt_pdev_handle htt_pdev,
138 		     int max_subfrms_ampdu, int max_subfrms_amsdu);
139 
140 /**
141  * @brief Get the FW status
142  * @details
143  *  Trigger FW HTT to retrieve FW status.
144  *  A separate HTT message will come back with the statistics we want.
145  *
146  * @param pdev - handle to the HTT instance
147  * @param stats_type_upload_mask - bitmask identifying which stats to upload
148  * @param stats_type_reset_mask - bitmask identifying which stats to reset
149  * @param cookie - unique value to distinguish and identify stats requests
150  * @return 0 - succeed to send the request to FW; otherwise, failed to do so.
151  */
152 int
153 htt_h2t_dbg_stats_get(struct htt_pdev_t *pdev,
154 		      uint32_t stats_type_upload_mask,
155 		      uint32_t stats_type_reset_mask,
156 		      uint8_t cfg_stats_type,
157 		      uint32_t cfg_val, uint8_t cookie);
158 
159 /**
160  * @brief Get the fields from HTT T2H stats upload message's stats info header
161  * @details
162  *  Parse the a HTT T2H message's stats info tag-length-value header,
163  *  to obtain the stats type, status, data length, and data address.
164  *
165  * @param stats_info_list - address of stats record's header
166  * @param[out] type - which type of FW stats are contained in the record
167  * @param[out] status - whether the stats are (fully) present in the record
168  * @param[out] length - how large the data portion of the stats record is
169  * @param[out] stats_data - where the data portion of the stats record is
170  */
171 void
172 htt_t2h_dbg_stats_hdr_parse(uint8_t *stats_info_list,
173 			    enum htt_dbg_stats_type *type,
174 			    enum htt_dbg_stats_status *status,
175 			    int *length, uint8_t **stats_data);
176 
177 /**
178  * @brief Display a stats record from the HTT T2H STATS_CONF message.
179  * @details
180  *  Parse the stats type and status, and invoke a type-specified printout
181  *  to display the stats values.
182  *
183  *  @param stats_data - buffer holding the stats record from the STATS_CONF msg
184  *  @param concise - whether to do a verbose or concise printout
185  */
186 void htt_t2h_stats_print(uint8_t *stats_data, int concise);
187 
188 /**
189  * htt_log_rx_ring_info() - log htt rx ring info during FW_RX_REFILL failure
190  * @pdev: handle to the HTT instance
191  *
192  * Return: None
193  */
194 void htt_log_rx_ring_info(htt_pdev_handle pdev);
195 
196 /**
197  * htt_rx_refill_failure() - During refill failure check if debt is zero
198  * @pdev: handle to the HTT instance
199  *
200  * Return: None
201  */
202 void htt_rx_refill_failure(htt_pdev_handle pdev);
203 
204 #ifndef HTT_DEBUG_LEVEL
205 #if defined(DEBUG)
206 #define HTT_DEBUG_LEVEL 10
207 #else
208 #define HTT_DEBUG_LEVEL 0
209 #endif
210 #endif
211 
212 #if HTT_DEBUG_LEVEL > 5
213 void htt_display(htt_pdev_handle pdev, int indent);
214 #else
215 #define htt_display(pdev, indent)
216 #endif
217 
218 #define HTT_DXE_RX_LOG 0
219 #define htt_rx_reorder_log_print(pdev)
220 
221 #ifdef IPA_OFFLOAD
222 int htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t *pdev);
223 
224 /**
225  * htt_ipa_uc_get_resource() - Get uc resource from htt and lower layer
226  * @pdev - handle to the HTT instance
227  * @ce_sr - CE source ring DMA mapping info
228  * @tx_comp_ring - tx completion ring DMA mapping info
229  * @rx_rdy_ring - rx Ready ring DMA mapping info
230  * @rx2_rdy_ring - rx2 Ready ring DMA mapping info
231  * @rx_proc_done_idx - rx process done index
232  * @rx2_proc_done_idx - rx2 process done index
233  * @ce_sr_ring_size: copyengine source ring size
234  * @ce_reg_paddr - CE Register address
235  * @tx_num_alloc_buffer - Number of TX allocated buffers
236  *
237  * Return: 0 success
238  */
239 int
240 htt_ipa_uc_get_resource(htt_pdev_handle pdev,
241 			qdf_shared_mem_t **ce_sr,
242 			qdf_shared_mem_t **tx_comp_ring,
243 			qdf_shared_mem_t **rx_rdy_ring,
244 			qdf_shared_mem_t **rx2_rdy_ring,
245 			qdf_shared_mem_t **rx_proc_done_idx,
246 			qdf_shared_mem_t **rx2_proc_done_idx,
247 			uint32_t *ce_sr_ring_size,
248 			qdf_dma_addr_t *ce_reg_paddr,
249 			uint32_t *tx_num_alloc_buffer);
250 
251 int
252 htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,
253 			      qdf_dma_addr_t ipa_uc_tx_doorbell_paddr,
254 			      qdf_dma_addr_t ipa_uc_rx_doorbell_paddr);
255 
256 int
257 htt_h2t_ipa_uc_set_active(struct htt_pdev_t *pdev, bool uc_active, bool is_tx);
258 
259 int htt_h2t_ipa_uc_get_stats(struct htt_pdev_t *pdev);
260 
261 int htt_h2t_ipa_uc_get_share_stats(struct htt_pdev_t *pdev,
262 				   uint8_t reset_stats);
263 
264 int htt_h2t_ipa_uc_set_quota(struct htt_pdev_t *pdev, uint64_t quota_bytes);
265 
266 int htt_ipa_uc_attach(struct htt_pdev_t *pdev);
267 
268 void htt_ipa_uc_detach(struct htt_pdev_t *pdev);
269 #else
270 /**
271  * htt_h2t_ipa_uc_rsc_cfg_msg() - Send WDI IPA config message to firmware
272  * @pdev: handle to the HTT instance
273  *
274  * Return: 0 success
275  */
htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t * pdev)276 static inline int htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t *pdev)
277 {
278 	return 0;
279 }
280 
281 /**
282  * htt_ipa_uc_set_doorbell_paddr() - Propagate IPA doorbell address
283  * @pdev: handle to the HTT instance
284  * @ipa_uc_tx_doorbell_paddr: TX doorbell base physical address
285  * @ipa_uc_rx_doorbell_paddr: RX doorbell base physical address
286  *
287  * Return: 0 success
288  */
289 static inline int
htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,uint32_t ipa_uc_tx_doorbell_paddr,uint32_t ipa_uc_rx_doorbell_paddr)290 htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,
291 			      uint32_t ipa_uc_tx_doorbell_paddr,
292 			      uint32_t ipa_uc_rx_doorbell_paddr)
293 {
294 	return 0;
295 }
296 
297 /**
298  * htt_h2t_ipa_uc_set_active() - Propagate WDI path enable/disable to firmware
299  * @pdev: handle to the HTT instance
300  * @uc_active: WDI UC path enable or not
301  * @is_tx: TX path or RX path
302  *
303  * Return: 0 success
304  */
305 static inline int
htt_h2t_ipa_uc_set_active(struct htt_pdev_t * pdev,bool uc_active,bool is_tx)306 htt_h2t_ipa_uc_set_active(struct htt_pdev_t *pdev, bool uc_active,
307 	bool is_tx)
308 {
309 	return 0;
310 }
311 
312 /**
313  * htt_h2t_ipa_uc_get_stats() - WDI UC state query request to firmware
314  * @pdev: handle to the HTT instance
315  *
316  * Return: 0 success
317  */
htt_h2t_ipa_uc_get_stats(struct htt_pdev_t * pdev)318 static inline int htt_h2t_ipa_uc_get_stats(struct htt_pdev_t *pdev)
319 {
320 	return 0;
321 }
322 
323 /**
324  * htt_h2t_ipa_uc_get_share_stats() - WDI UC wifi sharing state request to FW
325  * @pdev: handle to the HTT instance
326  *
327  * Return: 0 success
328  */
htt_h2t_ipa_uc_get_share_stats(struct htt_pdev_t * pdev,uint8_t reset_stats)329 static inline int htt_h2t_ipa_uc_get_share_stats(struct htt_pdev_t *pdev,
330 						uint8_t reset_stats)
331 {
332 	return 0;
333 }
334 
335 /**
336  * htt_h2t_ipa_uc_set_quota() - WDI UC set quota request to firmware
337  * @pdev: handle to the HTT instance
338  *
339  * Return: 0 success
340  */
htt_h2t_ipa_uc_set_quota(struct htt_pdev_t * pdev,uint64_t quota_bytes)341 static inline int htt_h2t_ipa_uc_set_quota(struct htt_pdev_t *pdev,
342 					   uint64_t quota_bytes)
343 {
344 	return 0;
345 }
346 
347 /**
348  * htt_ipa_uc_attach() - Allocate UC data path resources
349  * @pdev: handle to the HTT instance
350  *
351  * Return: 0 success
352  */
htt_ipa_uc_attach(struct htt_pdev_t * pdev)353 static inline int htt_ipa_uc_attach(struct htt_pdev_t *pdev)
354 {
355 	return 0;
356 }
357 
358 /**
359  * htt_ipa_uc_attach() - Remove UC data path resources
360  * @pdev: handle to the HTT instance
361  *
362  * Return: 0 success
363  */
htt_ipa_uc_detach(struct htt_pdev_t * pdev)364 static inline void htt_ipa_uc_detach(struct htt_pdev_t *pdev)
365 {
366 }
367 #endif /* IPA_OFFLOAD */
368 
369 #ifdef FEATURE_MONITOR_MODE_SUPPORT
370 void htt_rx_mon_note_capture_channel(htt_pdev_handle pdev, int mon_ch);
371 
372 void ol_htt_mon_note_chan(struct cdp_pdev *ppdev, int mon_ch);
373 #else
374 static inline
htt_rx_mon_note_capture_channel(htt_pdev_handle pdev,int mon_ch)375 void htt_rx_mon_note_capture_channel(htt_pdev_handle pdev, int mon_ch) {}
376 
377 static inline
ol_htt_mon_note_chan(struct cdp_pdev * ppdev,int mon_ch)378 void ol_htt_mon_note_chan(struct cdp_pdev *ppdev, int mon_ch) {}
379 #endif
380 
381 #if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT)
382 
383 void htt_dump_bundle_stats(struct htt_pdev_t *pdev);
384 void htt_clear_bundle_stats(struct htt_pdev_t *pdev);
385 #else
386 
htt_dump_bundle_stats(struct htt_pdev_t * pdev)387 static inline void htt_dump_bundle_stats(struct htt_pdev_t *pdev)
388 {
389 }
390 
htt_clear_bundle_stats(struct htt_pdev_t * pdev)391 static inline void htt_clear_bundle_stats(struct htt_pdev_t *pdev)
392 {
393 }
394 #endif
395 
396 void htt_mark_first_wakeup_packet(htt_pdev_handle pdev, uint8_t value);
397 
398 typedef void (*tp_rx_pkt_dump_cb)(qdf_nbuf_t msdu, uint8_t peer_id,
399 			uint8_t status);
400 #ifndef CONNECTIVITY_PKTLOG
401 static inline
htt_register_rx_pkt_dump_callback(struct htt_pdev_t * pdev,tp_rx_pkt_dump_cb ol_rx_pkt_dump_call)402 void htt_register_rx_pkt_dump_callback(struct htt_pdev_t *pdev,
403 				       tp_rx_pkt_dump_cb ol_rx_pkt_dump_call)
404 {
405 }
406 
407 static inline
htt_deregister_rx_pkt_dump_callback(struct htt_pdev_t * pdev)408 void htt_deregister_rx_pkt_dump_callback(struct htt_pdev_t *pdev)
409 {
410 }
411 
412 static inline
ol_rx_pkt_dump_call(qdf_nbuf_t msdu,uint8_t peer_id,uint8_t status)413 void ol_rx_pkt_dump_call(qdf_nbuf_t msdu, uint8_t peer_id, uint8_t status)
414 {
415 }
416 #else
417 void htt_register_rx_pkt_dump_callback(struct htt_pdev_t *pdev,
418 				       tp_rx_pkt_dump_cb ol_rx_pkt_dump_call);
419 void htt_deregister_rx_pkt_dump_callback(struct htt_pdev_t *pdev);
420 void ol_rx_pkt_dump_call(qdf_nbuf_t msdu, uint8_t peer_id, uint8_t status);
421 #endif
422 
423 #endif /* _OL_HTT_API__H_ */
424