blob: 79c720f93a896c8ec75df1ee8305032b41bd49f8 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Sravan Kumar Kairamb664b6c2018-02-27 17:43:10 +05302 * Copyright (c) 2011, 2014-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019/**
20 * @file ol_htt_api.h
21 * @brief Specify the general HTT API functions called by the host data SW.
22 * @details
23 * This file declares the HTT API functions that are not specific to
24 * either tx nor rx.
25 */
26#ifndef _OL_HTT_API__H_
27#define _OL_HTT_API__H_
28
Anurag Chouhan6d760662016-02-20 16:05:43 +053029#include <qdf_types.h> /* qdf_device_t */
Nirav Shahcbc6d722016-03-01 16:24:53 +053030#include <qdf_nbuf.h> /* qdf_nbuf_t */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080031#include <athdefs.h> /* A_STATUS */
32#include <htc_api.h> /* HTC_HANDLE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080033#include "htt.h" /* htt_dbg_stats_type, etc. */
Dhanashri Atre12a08392016-02-17 13:10:34 -080034#include <cdp_txrx_cmn.h> /* ol_pdev_handle */
Leo Chang98726762016-10-28 11:07:18 -070035#include <ol_defines.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080036#include <cdp_txrx_handle.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037/* TID */
38#define OL_HTT_TID_NON_QOS_UNICAST 16
39#define OL_HTT_TID_NON_QOS_MCAST_BCAST 18
40
41struct htt_pdev_t;
42typedef struct htt_pdev_t *htt_pdev_handle;
43
44htt_pdev_handle
45htt_pdev_alloc(ol_txrx_pdev_handle txrx_pdev,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080046 struct cdp_cfg *ctrl_pdev,
Anurag Chouhan6d760662016-02-20 16:05:43 +053047 HTC_HANDLE htc_pdev, qdf_device_t osdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048
49/**
50 * @brief Allocate and initialize a HTT instance.
51 * @details
52 * This function allocates and initializes an HTT instance.
53 * This involves allocating a pool of HTT tx descriptors in
54 * consistent memory, allocating and filling a rx ring (LL only),
55 * and connecting the HTC's HTT_DATA_MSG service.
56 * The HTC service connect call will block, so this function
57 * needs to be called in passive context.
58 * Because HTC setup has not been completed at the time this function
59 * is called, this function cannot send any HTC messages to the target.
60 * Messages to configure the target are instead sent in the
61 * htc_attach_target function.
62 *
63 * @param pdev - data SW's physical device handle
64 * (used as context pointer during HTT -> txrx calls)
65 * @param desc_pool_size - number of HTT descriptors to (pre)allocate
66 * @return success -> HTT pdev handle; failure -> NULL
67 */
68int
69htt_attach(struct htt_pdev_t *pdev, int desc_pool_size);
70
71/**
72 * @brief Send HTT configuration messages to the target.
73 * @details
74 * For LL only, this function sends a rx ring configuration message to the
75 * target. For HL, this function is a no-op.
76 *
77 * @param htt_pdev - handle to the HTT instance being initialized
78 */
Rakesh Pillai7fb7a1f2017-06-23 14:46:36 +053079QDF_STATUS htt_attach_target(htt_pdev_handle htt_pdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080
81/**
82 * enum htt_op_mode - Virtual device operation mode
83 *
84 * @htt_op_mode_unknown: Unknown mode
85 * @htt_op_mode_ap: AP mode
86 * @htt_op_mode_ibss: IBSS mode
87 * @htt_op_mode_sta: STA (client) mode
88 * @htt_op_mode_monitor: Monitor mode
89 * @htt_op_mode_ocb: OCB mode
90 */
91enum htt_op_mode {
92 htt_op_mode_unknown,
93 htt_op_mode_ap,
94 htt_op_mode_ibss,
95 htt_op_mode_sta,
96 htt_op_mode_monitor,
97 htt_op_mode_ocb,
98};
99
100/* no-ops */
101#define htt_vdev_attach(htt_pdev, vdev_id, op_mode)
102#define htt_vdev_detach(htt_pdev, vdev_id)
103#define htt_peer_qos_update(htt_pdev, peer_id, qos_capable)
104#define htt_peer_uapsdmask_update(htt_pdev, peer_id, uapsd_mask)
105
106void htt_pdev_free(htt_pdev_handle pdev);
107
108/**
109 * @brief Deallocate a HTT instance.
110 *
111 * @param htt_pdev - handle to the HTT instance being torn down
112 */
113void htt_detach(htt_pdev_handle htt_pdev);
114
115/**
116 * @brief Stop the communication between HTT and target
117 * @details
118 * For ISOC solution, this function stop the communication between HTT and
119 * target.
120 * For Peregrine/Rome, it's already stopped by ol_ath_disconnect_htc
121 * before ol_txrx_pdev_detach called in ol_ath_detach. So this function is
122 * a no-op.
123 * Peregrine/Rome HTT layer is on top of HTC while ISOC solution HTT layer is
124 * on top of DXE layer.
125 *
126 * @param htt_pdev - handle to the HTT instance being initialized
127 */
128void htt_detach_target(htt_pdev_handle htt_pdev);
129
130/*
131 * @brief Tell the target side of HTT to suspend H2T processing until synced
132 * @param htt_pdev - the host HTT object
133 * @param sync_cnt - what sync count value the target HTT FW should wait for
134 * before resuming H2T processing
135 */
136A_STATUS htt_h2t_sync_msg(htt_pdev_handle htt_pdev, uint8_t sync_cnt);
137
138int
139htt_h2t_aggr_cfg_msg(htt_pdev_handle htt_pdev,
140 int max_subfrms_ampdu, int max_subfrms_amsdu);
141
142/**
143 * @brief Get the FW status
144 * @details
145 * Trigger FW HTT to retrieve FW status.
146 * A separate HTT message will come back with the statistics we want.
147 *
148 * @param pdev - handle to the HTT instance
149 * @param stats_type_upload_mask - bitmask identifying which stats to upload
150 * @param stats_type_reset_mask - bitmask identifying which stats to reset
151 * @param cookie - unique value to distinguish and identify stats requests
152 * @return 0 - succeed to send the request to FW; otherwise, failed to do so.
153 */
154int
155htt_h2t_dbg_stats_get(struct htt_pdev_t *pdev,
156 uint32_t stats_type_upload_mask,
157 uint32_t stats_type_reset_mask,
158 uint8_t cfg_stats_type,
159 uint32_t cfg_val, uint64_t cookie);
160
161/**
162 * @brief Get the fields from HTT T2H stats upload message's stats info header
163 * @details
164 * Parse the a HTT T2H message's stats info tag-length-value header,
Jeff Johnsonfe8e9492018-05-06 15:40:52 -0700165 * to obtain the stats type, status, data length, and data address.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 *
167 * @param stats_info_list - address of stats record's header
168 * @param[out] type - which type of FW stats are contained in the record
169 * @param[out] status - whether the stats are (fully) present in the record
170 * @param[out] length - how large the data portion of the stats record is
171 * @param[out] stats_data - where the data portion of the stats record is
172 */
173void
174htt_t2h_dbg_stats_hdr_parse(uint8_t *stats_info_list,
175 enum htt_dbg_stats_type *type,
176 enum htt_dbg_stats_status *status,
177 int *length, uint8_t **stats_data);
178
179/**
180 * @brief Display a stats record from the HTT T2H STATS_CONF message.
181 * @details
182 * Parse the stats type and status, and invoke a type-specified printout
183 * to display the stats values.
184 *
185 * @param stats_data - buffer holding the stats record from the STATS_CONF msg
186 * @param concise - whether to do a verbose or concise printout
187 */
188void htt_t2h_stats_print(uint8_t *stats_data, int concise);
189
Poddar, Siddarthb9047592017-10-05 15:48:28 +0530190/**
191 * htt_log_rx_ring_info() - log htt rx ring info during FW_RX_REFILL failure
192 * @pdev: handle to the HTT instance
193 *
194 * Return: None
195 */
196void htt_log_rx_ring_info(htt_pdev_handle pdev);
197
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198#ifndef HTT_DEBUG_LEVEL
199#if defined(DEBUG)
200#define HTT_DEBUG_LEVEL 10
201#else
202#define HTT_DEBUG_LEVEL 0
203#endif
204#endif
205
206#if HTT_DEBUG_LEVEL > 5
207void htt_display(htt_pdev_handle pdev, int indent);
208#else
209#define htt_display(pdev, indent)
210#endif
211
212#define HTT_DXE_RX_LOG 0
213#define htt_rx_reorder_log_print(pdev)
214
215#ifdef IPA_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800216int htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t *pdev);
217
Sravan Kumar Kairamb664b6c2018-02-27 17:43:10 +0530218/**
219 * htt_ipa_uc_get_resource() - Get uc resource from htt and lower layer
220 * @pdev - handle to the HTT instance
221 * @ce_sr - CE source ring DMA mapping info
222 * @tx_comp_ring - tx completion ring DMA mapping info
223 * @rx_rdy_ring - rx Ready ring DMA mapping info
224 * @rx2_rdy_ring - rx2 Ready ring DMA mapping info
225 * @rx_proc_done_idx - rx process done index
226 * @rx2_proc_done_idx - rx2 process done index
227 * @ce_sr_ring_size: copyengine source ring size
228 * @ce_reg_paddr - CE Register address
229 * @tx_num_alloc_buffer - Number of TX allocated buffers
230 *
231 * Return: 0 success
232 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233int
234htt_ipa_uc_get_resource(htt_pdev_handle pdev,
Sravan Kumar Kairamb664b6c2018-02-27 17:43:10 +0530235 qdf_shared_mem_t **ce_sr,
236 qdf_shared_mem_t **tx_comp_ring,
237 qdf_shared_mem_t **rx_rdy_ring,
238 qdf_shared_mem_t **rx2_rdy_ring,
239 qdf_shared_mem_t **rx_proc_done_idx,
240 qdf_shared_mem_t **rx2_proc_done_idx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 uint32_t *ce_sr_ring_size,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530242 qdf_dma_addr_t *ce_reg_paddr,
Sravan Kumar Kairamb664b6c2018-02-27 17:43:10 +0530243 uint32_t *tx_num_alloc_buffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245int
246htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530247 qdf_dma_addr_t ipa_uc_tx_doorbell_paddr,
248 qdf_dma_addr_t ipa_uc_rx_doorbell_paddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250int
251htt_h2t_ipa_uc_set_active(struct htt_pdev_t *pdev, bool uc_active, bool is_tx);
252
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253int htt_h2t_ipa_uc_get_stats(struct htt_pdev_t *pdev);
254
Yun Park637d6482016-10-05 10:51:33 -0700255int htt_h2t_ipa_uc_get_share_stats(struct htt_pdev_t *pdev,
256 uint8_t reset_stats);
257
258int htt_h2t_ipa_uc_set_quota(struct htt_pdev_t *pdev, uint64_t quota_bytes);
259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260int htt_ipa_uc_attach(struct htt_pdev_t *pdev);
261
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262void htt_ipa_uc_detach(struct htt_pdev_t *pdev);
263#else
Leo Chang8e073612015-11-13 10:55:34 -0800264/**
265 * htt_h2t_ipa_uc_rsc_cfg_msg() - Send WDI IPA config message to firmware
266 * @pdev: handle to the HTT instance
267 *
268 * Return: 0 success
269 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270static inline int htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t *pdev)
271{
272 return 0;
273}
274
Leo Chang8e073612015-11-13 10:55:34 -0800275/**
Leo Chang8e073612015-11-13 10:55:34 -0800276 * htt_ipa_uc_set_doorbell_paddr() - Propagate IPA doorbell address
277 * @pdev: handle to the HTT instance
278 * @ipa_uc_tx_doorbell_paddr: TX doorbell base physical address
279 * @ipa_uc_rx_doorbell_paddr: RX doorbell base physical address
280 *
281 * Return: 0 success
282 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800283static inline int
284htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,
285 uint32_t ipa_uc_tx_doorbell_paddr,
286 uint32_t ipa_uc_rx_doorbell_paddr)
287{
288 return 0;
289}
290
Leo Chang8e073612015-11-13 10:55:34 -0800291/**
292 * htt_h2t_ipa_uc_set_active() - Propagate WDI path enable/disable to firmware
293 * @pdev: handle to the HTT instance
294 * @uc_active: WDI UC path enable or not
295 * @is_tx: TX path or RX path
296 *
297 * Return: 0 success
298 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299static inline int
300htt_h2t_ipa_uc_set_active(struct htt_pdev_t *pdev, bool uc_active,
301 bool is_tx)
302{
303 return 0;
304}
305
Leo Chang8e073612015-11-13 10:55:34 -0800306/**
307 * htt_h2t_ipa_uc_get_stats() - WDI UC state query request to firmware
308 * @pdev: handle to the HTT instance
309 *
310 * Return: 0 success
311 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312static inline int htt_h2t_ipa_uc_get_stats(struct htt_pdev_t *pdev)
313{
314 return 0;
315}
316
Leo Chang8e073612015-11-13 10:55:34 -0800317/**
Yun Park637d6482016-10-05 10:51:33 -0700318 * htt_h2t_ipa_uc_get_share_stats() - WDI UC wifi sharing state request to FW
319 * @pdev: handle to the HTT instance
320 *
321 * Return: 0 success
322 */
323static inline int htt_h2t_ipa_uc_get_share_stats(struct htt_pdev_t *pdev,
324 uint8_t reset_stats)
325{
326 return 0;
327}
328
329/**
330 * htt_h2t_ipa_uc_set_quota() - WDI UC set quota request to firmware
331 * @pdev: handle to the HTT instance
332 *
333 * Return: 0 success
334 */
335static inline int htt_h2t_ipa_uc_set_quota(struct htt_pdev_t *pdev,
336 uint64_t quota_bytes)
337{
338 return 0;
339}
340
341/**
Leo Chang8e073612015-11-13 10:55:34 -0800342 * htt_ipa_uc_attach() - Allocate UC data path resources
343 * @pdev: handle to the HTT instance
344 *
345 * Return: 0 success
346 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800347static inline int htt_ipa_uc_attach(struct htt_pdev_t *pdev)
348{
349 return 0;
350}
351
Leo Chang8e073612015-11-13 10:55:34 -0800352/**
353 * htt_ipa_uc_attach() - Remove UC data path resources
354 * @pdev: handle to the HTT instance
355 *
356 * Return: 0 success
357 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800358static inline void htt_ipa_uc_detach(struct htt_pdev_t *pdev)
359{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360}
361#endif /* IPA_OFFLOAD */
362
Nirav Shah73713f72018-05-17 14:50:41 +0530363#ifdef FEATURE_MONITOR_MODE_SUPPORT
Manjunathappa Prakashb7573722016-04-21 11:24:07 -0700364void htt_rx_mon_note_capture_channel(htt_pdev_handle pdev, int mon_ch);
365
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800366void ol_htt_mon_note_chan(struct cdp_pdev *ppdev, int mon_ch);
Nirav Shah73713f72018-05-17 14:50:41 +0530367#else
368static inline
369void htt_rx_mon_note_capture_channel(htt_pdev_handle pdev, int mon_ch) {}
370
371static inline
372void ol_htt_mon_note_chan(struct cdp_pdev *ppdev, int mon_ch) {}
373#endif
Siddarth Poddar1df1cd82016-04-27 17:32:21 +0530374
375#if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT)
376
377void htt_dump_bundle_stats(struct htt_pdev_t *pdev);
378void htt_clear_bundle_stats(struct htt_pdev_t *pdev);
379#else
380
381static inline void htt_dump_bundle_stats(struct htt_pdev_t *pdev)
382{
Siddarth Poddar1df1cd82016-04-27 17:32:21 +0530383}
384
385static inline void htt_clear_bundle_stats(struct htt_pdev_t *pdev)
386{
Siddarth Poddar1df1cd82016-04-27 17:32:21 +0530387}
388#endif
389
Himanshu Agarwal19141bb2016-07-20 20:15:48 +0530390void htt_mark_first_wakeup_packet(htt_pdev_handle pdev, uint8_t value);
Nirav Shahbb8e47c2018-05-17 16:56:41 +0530391
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +0530392typedef void (*tp_rx_pkt_dump_cb)(qdf_nbuf_t msdu, uint8_t peer_id,
393 uint8_t status);
Nirav Shahbb8e47c2018-05-17 16:56:41 +0530394#ifdef REMOVE_PKT_LOG
395static inline
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +0530396void htt_register_rx_pkt_dump_callback(struct htt_pdev_t *pdev,
Nirav Shahbb8e47c2018-05-17 16:56:41 +0530397 tp_rx_pkt_dump_cb ol_rx_pkt_dump_call)
398{
399}
400
401static inline
402void htt_deregister_rx_pkt_dump_callback(struct htt_pdev_t *pdev)
403{
404}
405
406static inline
407void ol_rx_pkt_dump_call(qdf_nbuf_t msdu, uint8_t peer_id, uint8_t status)
408{
409}
410#else
411void htt_register_rx_pkt_dump_callback(struct htt_pdev_t *pdev,
412 tp_rx_pkt_dump_cb ol_rx_pkt_dump_call);
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +0530413void htt_deregister_rx_pkt_dump_callback(struct htt_pdev_t *pdev);
414void ol_rx_pkt_dump_call(qdf_nbuf_t msdu, uint8_t peer_id, uint8_t status);
Nirav Shahbb8e47c2018-05-17 16:56:41 +0530415#endif
Siddarth Poddar1df1cd82016-04-27 17:32:21 +0530416
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417#endif /* _OL_HTT_API__H_ */