blob: c19827e9aa2c8a6ece67999d3ee087377458394c [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002 * Copyright (c) 2011, 2014-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * @file ol_htt_api.h
30 * @brief Specify the general HTT API functions called by the host data SW.
31 * @details
32 * This file declares the HTT API functions that are not specific to
33 * either tx nor rx.
34 */
35#ifndef _OL_HTT_API__H_
36#define _OL_HTT_API__H_
37
Anurag Chouhan6d760662016-02-20 16:05:43 +053038#include <qdf_types.h> /* qdf_device_t */
Nirav Shahcbc6d722016-03-01 16:24:53 +053039#include <qdf_nbuf.h> /* qdf_nbuf_t */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include <athdefs.h> /* A_STATUS */
41#include <htc_api.h> /* HTC_HANDLE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042#include "htt.h" /* htt_dbg_stats_type, etc. */
Dhanashri Atre12a08392016-02-17 13:10:34 -080043#include <cdp_txrx_cmn.h> /* ol_pdev_handle */
Leo Chang98726762016-10-28 11:07:18 -070044#include <ol_defines.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080045#include <cdp_txrx_handle.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046/* TID */
47#define OL_HTT_TID_NON_QOS_UNICAST 16
48#define OL_HTT_TID_NON_QOS_MCAST_BCAST 18
49
50struct htt_pdev_t;
51typedef struct htt_pdev_t *htt_pdev_handle;
52
53htt_pdev_handle
54htt_pdev_alloc(ol_txrx_pdev_handle txrx_pdev,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080055 struct cdp_cfg *ctrl_pdev,
Anurag Chouhan6d760662016-02-20 16:05:43 +053056 HTC_HANDLE htc_pdev, qdf_device_t osdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080057
58/**
59 * @brief Allocate and initialize a HTT instance.
60 * @details
61 * This function allocates and initializes an HTT instance.
62 * This involves allocating a pool of HTT tx descriptors in
63 * consistent memory, allocating and filling a rx ring (LL only),
64 * and connecting the HTC's HTT_DATA_MSG service.
65 * The HTC service connect call will block, so this function
66 * needs to be called in passive context.
67 * Because HTC setup has not been completed at the time this function
68 * is called, this function cannot send any HTC messages to the target.
69 * Messages to configure the target are instead sent in the
70 * htc_attach_target function.
71 *
72 * @param pdev - data SW's physical device handle
73 * (used as context pointer during HTT -> txrx calls)
74 * @param desc_pool_size - number of HTT descriptors to (pre)allocate
75 * @return success -> HTT pdev handle; failure -> NULL
76 */
77int
78htt_attach(struct htt_pdev_t *pdev, int desc_pool_size);
79
80/**
81 * @brief Send HTT configuration messages to the target.
82 * @details
83 * For LL only, this function sends a rx ring configuration message to the
84 * target. For HL, this function is a no-op.
85 *
86 * @param htt_pdev - handle to the HTT instance being initialized
87 */
88A_STATUS htt_attach_target(htt_pdev_handle htt_pdev);
89
90/**
91 * enum htt_op_mode - Virtual device operation mode
92 *
93 * @htt_op_mode_unknown: Unknown mode
94 * @htt_op_mode_ap: AP mode
95 * @htt_op_mode_ibss: IBSS mode
96 * @htt_op_mode_sta: STA (client) mode
97 * @htt_op_mode_monitor: Monitor mode
98 * @htt_op_mode_ocb: OCB mode
99 */
100enum htt_op_mode {
101 htt_op_mode_unknown,
102 htt_op_mode_ap,
103 htt_op_mode_ibss,
104 htt_op_mode_sta,
105 htt_op_mode_monitor,
106 htt_op_mode_ocb,
107};
108
109/* no-ops */
110#define htt_vdev_attach(htt_pdev, vdev_id, op_mode)
111#define htt_vdev_detach(htt_pdev, vdev_id)
112#define htt_peer_qos_update(htt_pdev, peer_id, qos_capable)
113#define htt_peer_uapsdmask_update(htt_pdev, peer_id, uapsd_mask)
114
115void htt_pdev_free(htt_pdev_handle pdev);
116
117/**
118 * @brief Deallocate a HTT instance.
119 *
120 * @param htt_pdev - handle to the HTT instance being torn down
121 */
122void htt_detach(htt_pdev_handle htt_pdev);
123
124/**
125 * @brief Stop the communication between HTT and target
126 * @details
127 * For ISOC solution, this function stop the communication between HTT and
128 * target.
129 * For Peregrine/Rome, it's already stopped by ol_ath_disconnect_htc
130 * before ol_txrx_pdev_detach called in ol_ath_detach. So this function is
131 * a no-op.
132 * Peregrine/Rome HTT layer is on top of HTC while ISOC solution HTT layer is
133 * on top of DXE layer.
134 *
135 * @param htt_pdev - handle to the HTT instance being initialized
136 */
137void htt_detach_target(htt_pdev_handle htt_pdev);
138
139/*
140 * @brief Tell the target side of HTT to suspend H2T processing until synced
141 * @param htt_pdev - the host HTT object
142 * @param sync_cnt - what sync count value the target HTT FW should wait for
143 * before resuming H2T processing
144 */
145A_STATUS htt_h2t_sync_msg(htt_pdev_handle htt_pdev, uint8_t sync_cnt);
146
147int
148htt_h2t_aggr_cfg_msg(htt_pdev_handle htt_pdev,
149 int max_subfrms_ampdu, int max_subfrms_amsdu);
150
151/**
152 * @brief Get the FW status
153 * @details
154 * Trigger FW HTT to retrieve FW status.
155 * A separate HTT message will come back with the statistics we want.
156 *
157 * @param pdev - handle to the HTT instance
158 * @param stats_type_upload_mask - bitmask identifying which stats to upload
159 * @param stats_type_reset_mask - bitmask identifying which stats to reset
160 * @param cookie - unique value to distinguish and identify stats requests
161 * @return 0 - succeed to send the request to FW; otherwise, failed to do so.
162 */
163int
164htt_h2t_dbg_stats_get(struct htt_pdev_t *pdev,
165 uint32_t stats_type_upload_mask,
166 uint32_t stats_type_reset_mask,
167 uint8_t cfg_stats_type,
168 uint32_t cfg_val, uint64_t cookie);
169
170/**
171 * @brief Get the fields from HTT T2H stats upload message's stats info header
172 * @details
173 * Parse the a HTT T2H message's stats info tag-length-value header,
174 * to obtain the stats type, status, data lenght, and data address.
175 *
176 * @param stats_info_list - address of stats record's header
177 * @param[out] type - which type of FW stats are contained in the record
178 * @param[out] status - whether the stats are (fully) present in the record
179 * @param[out] length - how large the data portion of the stats record is
180 * @param[out] stats_data - where the data portion of the stats record is
181 */
182void
183htt_t2h_dbg_stats_hdr_parse(uint8_t *stats_info_list,
184 enum htt_dbg_stats_type *type,
185 enum htt_dbg_stats_status *status,
186 int *length, uint8_t **stats_data);
187
188/**
189 * @brief Display a stats record from the HTT T2H STATS_CONF message.
190 * @details
191 * Parse the stats type and status, and invoke a type-specified printout
192 * to display the stats values.
193 *
194 * @param stats_data - buffer holding the stats record from the STATS_CONF msg
195 * @param concise - whether to do a verbose or concise printout
196 */
197void htt_t2h_stats_print(uint8_t *stats_data, int concise);
198
199#ifndef HTT_DEBUG_LEVEL
200#if defined(DEBUG)
201#define HTT_DEBUG_LEVEL 10
202#else
203#define HTT_DEBUG_LEVEL 0
204#endif
205#endif
206
207#if HTT_DEBUG_LEVEL > 5
208void htt_display(htt_pdev_handle pdev, int indent);
209#else
210#define htt_display(pdev, indent)
211#endif
212
213#define HTT_DXE_RX_LOG 0
214#define htt_rx_reorder_log_print(pdev)
215
216#ifdef IPA_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217int htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t *pdev);
218
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800219int
220htt_ipa_uc_get_resource(htt_pdev_handle pdev,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530221 qdf_dma_addr_t *ce_sr_base_paddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 uint32_t *ce_sr_ring_size,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530223 qdf_dma_addr_t *ce_reg_paddr,
224 qdf_dma_addr_t *tx_comp_ring_base_paddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 uint32_t *tx_comp_ring_size,
226 uint32_t *tx_num_alloc_buffer,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530227 qdf_dma_addr_t *rx_rdy_ring_base_paddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 uint32_t *rx_rdy_ring_size,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530229 qdf_dma_addr_t *rx_proc_done_idx_paddr,
Leo Chang8e073612015-11-13 10:55:34 -0800230 void **rx_proc_done_idx_vaddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530231 qdf_dma_addr_t *rx2_rdy_ring_base_paddr,
Leo Chang8e073612015-11-13 10:55:34 -0800232 uint32_t *rx2_rdy_ring_size,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530233 qdf_dma_addr_t *rx2_proc_done_idx_paddr,
Leo Chang8e073612015-11-13 10:55:34 -0800234 void **rx2_proc_done_idx_vaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236int
237htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530238 qdf_dma_addr_t ipa_uc_tx_doorbell_paddr,
239 qdf_dma_addr_t ipa_uc_rx_doorbell_paddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241int
242htt_h2t_ipa_uc_set_active(struct htt_pdev_t *pdev, bool uc_active, bool is_tx);
243
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244int htt_h2t_ipa_uc_get_stats(struct htt_pdev_t *pdev);
245
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246int htt_ipa_uc_attach(struct htt_pdev_t *pdev);
247
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248void htt_ipa_uc_detach(struct htt_pdev_t *pdev);
249#else
Leo Chang8e073612015-11-13 10:55:34 -0800250/**
251 * htt_h2t_ipa_uc_rsc_cfg_msg() - Send WDI IPA config message to firmware
252 * @pdev: handle to the HTT instance
253 *
254 * Return: 0 success
255 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256static inline int htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t *pdev)
257{
258 return 0;
259}
260
Leo Chang8e073612015-11-13 10:55:34 -0800261/**
262 * htt_ipa_uc_get_resource() - Get uc resource from htt and lower layer
263 * @pdev: handle to the HTT instance
264 * @ce_sr_base_paddr: copy engine source ring base physical address
265 * @ce_sr_ring_size: copy engine source ring size
266 * @ce_reg_paddr: copy engine register physical address
267 * @tx_comp_ring_base_paddr: tx comp ring base physical address
268 * @tx_comp_ring_size: tx comp ring size
269 * @tx_num_alloc_buffer: number of allocated tx buffer
270 * @rx_rdy_ring_base_paddr: rx ready ring base physical address
271 * @rx_rdy_ring_size: rx ready ring size
272 * @rx_proc_done_idx_paddr: rx process done index physical address
273 * @rx_proc_done_idx_vaddr: rx process done index virtual address
274 * @rx2_rdy_ring_base_paddr: rx done ring base physical address
275 * @rx2_rdy_ring_size: rx done ring size
276 * @rx2_proc_done_idx_paddr: rx done index physical address
277 * @rx2_proc_done_idx_vaddr: rx done index virtual address
278 *
279 * Return: 0 success
280 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281static inline int
282htt_ipa_uc_get_resource(htt_pdev_handle pdev,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530283 qdf_dma_addr_t *ce_sr_base_paddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 uint32_t *ce_sr_ring_size,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530285 qdf_dma_addr_t *ce_reg_paddr,
286 qdf_dma_addr_t *tx_comp_ring_base_paddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287 uint32_t *tx_comp_ring_size,
288 uint32_t *tx_num_alloc_buffer,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530289 qdf_dma_addr_t *rx_rdy_ring_base_paddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800290 uint32_t *rx_rdy_ring_size,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530291 qdf_dma_addr_t *rx_proc_done_idx_paddr,
Leo Chang8e073612015-11-13 10:55:34 -0800292 void **rx_proc_done_idx_vaddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530293 qdf_dma_addr_t *rx2_rdy_ring_base_paddr,
Leo Chang8e073612015-11-13 10:55:34 -0800294 uint32_t *rx2_rdy_ring_size,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530295 qdf_dma_addr_t *rx2_proc_done_idx_paddr,
Leo Chang8e073612015-11-13 10:55:34 -0800296 void **rx2_proc_done_idx_vaddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297{
298 return 0;
299}
300
Leo Chang8e073612015-11-13 10:55:34 -0800301/**
302 * htt_ipa_uc_set_doorbell_paddr() - Propagate IPA doorbell address
303 * @pdev: handle to the HTT instance
304 * @ipa_uc_tx_doorbell_paddr: TX doorbell base physical address
305 * @ipa_uc_rx_doorbell_paddr: RX doorbell base physical address
306 *
307 * Return: 0 success
308 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309static inline int
310htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,
311 uint32_t ipa_uc_tx_doorbell_paddr,
312 uint32_t ipa_uc_rx_doorbell_paddr)
313{
314 return 0;
315}
316
Leo Chang8e073612015-11-13 10:55:34 -0800317/**
318 * htt_h2t_ipa_uc_set_active() - Propagate WDI path enable/disable to firmware
319 * @pdev: handle to the HTT instance
320 * @uc_active: WDI UC path enable or not
321 * @is_tx: TX path or RX path
322 *
323 * Return: 0 success
324 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325static inline int
326htt_h2t_ipa_uc_set_active(struct htt_pdev_t *pdev, bool uc_active,
327 bool is_tx)
328{
329 return 0;
330}
331
Leo Chang8e073612015-11-13 10:55:34 -0800332/**
333 * htt_h2t_ipa_uc_get_stats() - WDI UC state query request to firmware
334 * @pdev: handle to the HTT instance
335 *
336 * Return: 0 success
337 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338static inline int htt_h2t_ipa_uc_get_stats(struct htt_pdev_t *pdev)
339{
340 return 0;
341}
342
Leo Chang8e073612015-11-13 10:55:34 -0800343/**
344 * htt_ipa_uc_attach() - Allocate UC data path resources
345 * @pdev: handle to the HTT instance
346 *
347 * Return: 0 success
348 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800349static inline int htt_ipa_uc_attach(struct htt_pdev_t *pdev)
350{
351 return 0;
352}
353
Leo Chang8e073612015-11-13 10:55:34 -0800354/**
355 * htt_ipa_uc_attach() - Remove UC data path resources
356 * @pdev: handle to the HTT instance
357 *
358 * Return: 0 success
359 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360static inline void htt_ipa_uc_detach(struct htt_pdev_t *pdev)
361{
362 return;
363}
364#endif /* IPA_OFFLOAD */
365
Manjunathappa Prakashb7573722016-04-21 11:24:07 -0700366void htt_rx_mon_note_capture_channel(htt_pdev_handle pdev, int mon_ch);
367
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800368void ol_htt_mon_note_chan(struct cdp_pdev *ppdev, int mon_ch);
Siddarth Poddar1df1cd82016-04-27 17:32:21 +0530369
370#if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT)
371
372void htt_dump_bundle_stats(struct htt_pdev_t *pdev);
373void htt_clear_bundle_stats(struct htt_pdev_t *pdev);
374#else
375
376static inline void htt_dump_bundle_stats(struct htt_pdev_t *pdev)
377{
378 return;
379}
380
381static inline void htt_clear_bundle_stats(struct htt_pdev_t *pdev)
382{
383 return;
384}
385#endif
386
Himanshu Agarwal19141bb2016-07-20 20:15:48 +0530387void htt_mark_first_wakeup_packet(htt_pdev_handle pdev, uint8_t value);
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +0530388typedef void (*tp_rx_pkt_dump_cb)(qdf_nbuf_t msdu, uint8_t peer_id,
389 uint8_t status);
390void htt_register_rx_pkt_dump_callback(struct htt_pdev_t *pdev,
391 tp_rx_pkt_dump_cb ol_rx_pkt_dump_call);
392void htt_deregister_rx_pkt_dump_callback(struct htt_pdev_t *pdev);
393void ol_rx_pkt_dump_call(qdf_nbuf_t msdu, uint8_t peer_id, uint8_t status);
Siddarth Poddar1df1cd82016-04-27 17:32:21 +0530394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395#endif /* _OL_HTT_API__H_ */