blob: 4e9e58f1a004e1b7565cd61a5b5bc7989b5d82a1 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2011, 2014-2015 The Linux Foundation. All rights reserved.
3 *
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
38#include <cdf_types.h> /* cdf_device_t */
39#include <cdf_nbuf.h> /* cdf_nbuf_t */
40#include <athdefs.h> /* A_STATUS */
41#include <htc_api.h> /* HTC_HANDLE */
42#include <ol_ctrl_api.h> /* ol_pdev_handle */
43#include <ol_txrx_api.h> /* ol_txrx_pdev_handle */
44#include "htt.h" /* htt_dbg_stats_type, etc. */
45
46/* 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,
55 ol_pdev_handle ctrl_pdev,
56 HTC_HANDLE htc_pdev, cdf_device_t osdev);
57
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
217/**
218 * @brief send IPA UC resource config message to firmware with HTT message
219 * @details
220 * send IPA UC resource config message to firmware with HTT message
221 *
222 * @param pdev - handle to the HTT instance
223 */
224int htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t *pdev);
225
226/**
227 * @brief Client request resource information
228 * @details
229 * OL client will reuqest IPA UC related resource information
230 * Resource information will be distributted to IPA module
231 * All of the required resources should be pre-allocated
232 *
233 * @param pdev - handle to the HTT instance
234 * @param ce_sr_base_paddr - copy engine source ring base physical address
235 * @param ce_sr_ring_size - copy engine source ring size
236 * @param ce_reg_paddr - copy engine register physical address
237 * @param tx_comp_ring_base_paddr - tx comp ring base physical address
238 * @param tx_comp_ring_size - tx comp ring size
239 * @param tx_num_alloc_buffer - number of allocated tx buffer
240 * @param rx_rdy_ring_base_paddr - rx ready ring base physical address
241 * @param rx_rdy_ring_size - rx ready ring size
242 * @param rx_proc_done_idx_paddr - rx process done index physical address
243 */
244int
245htt_ipa_uc_get_resource(htt_pdev_handle pdev,
246 uint32_t *ce_sr_base_paddr,
247 uint32_t *ce_sr_ring_size,
248 cdf_dma_addr_t *ce_reg_paddr,
249 uint32_t *tx_comp_ring_base_paddr,
250 uint32_t *tx_comp_ring_size,
251 uint32_t *tx_num_alloc_buffer,
252 uint32_t *rx_rdy_ring_base_paddr,
253 uint32_t *rx_rdy_ring_size,
254 uint32_t *rx_proc_done_idx_paddr);
255
256/**
257 * @brief Client set IPA UC doorbell register
258 * @details
259 * IPA UC let know doorbell register physical address
260 * WLAN firmware will use this physical address to notify IPA UC
261 *
262 * @param pdev - handle to the HTT instance
263 * @param ipa_uc_tx_doorbell_paddr - tx comp doorbell physical address
264 * @param ipa_uc_rx_doorbell_paddr - rx ready doorbell physical address
265 */
266int
267htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,
268 uint32_t ipa_uc_tx_doorbell_paddr,
269 uint32_t ipa_uc_rx_doorbell_paddr);
270
271/**
272 * @brief Client notify IPA UC data path active or not
273 *
274 * @param pdev - handle to the HTT instance
275 * @param uc_active - UC data path is active or not
276 * @param is_tx - UC TX is active or not
277 */
278int
279htt_h2t_ipa_uc_set_active(struct htt_pdev_t *pdev, bool uc_active, bool is_tx);
280
281/**
282 * @brief query uc data path stats
283 *
284 * @param pdev - handle to the HTT instance
285 */
286int htt_h2t_ipa_uc_get_stats(struct htt_pdev_t *pdev);
287
288/**
289 * @brief Attach IPA UC data path
290 *
291 * @param pdev - handle to the HTT instance
292 */
293int htt_ipa_uc_attach(struct htt_pdev_t *pdev);
294
295/**
296 * @brief detach IPA UC data path
297 *
298 * @param pdev - handle to the HTT instance
299 */
300void htt_ipa_uc_detach(struct htt_pdev_t *pdev);
301#else
302static inline int htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t *pdev)
303{
304 return 0;
305}
306
307static inline int
308htt_ipa_uc_get_resource(htt_pdev_handle pdev,
309 uint32_t *ce_sr_base_paddr,
310 uint32_t *ce_sr_ring_size,
311 cdf_dma_addr_t *ce_reg_paddr,
312 uint32_t *tx_comp_ring_base_paddr,
313 uint32_t *tx_comp_ring_size,
314 uint32_t *tx_num_alloc_buffer,
315 uint32_t *rx_rdy_ring_base_paddr,
316 uint32_t *rx_rdy_ring_size,
317 uint32_t *rx_proc_done_idx_paddr)
318{
319 return 0;
320}
321
322static inline int
323htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,
324 uint32_t ipa_uc_tx_doorbell_paddr,
325 uint32_t ipa_uc_rx_doorbell_paddr)
326{
327 return 0;
328}
329
330static inline int
331htt_h2t_ipa_uc_set_active(struct htt_pdev_t *pdev, bool uc_active,
332 bool is_tx)
333{
334 return 0;
335}
336
337static inline int htt_h2t_ipa_uc_get_stats(struct htt_pdev_t *pdev)
338{
339 return 0;
340}
341
342static inline int htt_ipa_uc_attach(struct htt_pdev_t *pdev)
343{
344 return 0;
345}
346
347static inline void htt_ipa_uc_detach(struct htt_pdev_t *pdev)
348{
349 return;
350}
351#endif /* IPA_OFFLOAD */
352
353#endif /* _OL_HTT_API__H_ */