blob: 222db3d0462a49ebd413f5fa80d09a28ec9f972e [file] [log] [blame]
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -07001/*
Srinivas Girigowda2e3a1062016-04-13 18:25:09 -07002 * Copyright (c) 2011, 2014, 2016 The Linux Foundation. All rights reserved.
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -07003 *
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 */
Prakash Dhavali7410fac2014-02-05 21:27:47 -080027
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -070028/**
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 <adf_os_types.h> /* adf_os_device_t */
39#include <adf_nbuf.h> /* adf_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
50
51struct htt_pdev_t;
52typedef struct htt_pdev_t *htt_pdev_handle;
53
54/**
55 * @brief Allocate and initialize a HTT instance.
56 * @details
57 * This function allocates and initializes an HTT instance.
58 * This involves allocating a pool of HTT tx descriptors in
59 * consistent memory, allocating and filling a rx ring (LL only),
60 * and connecting the HTC's HTT_DATA_MSG service.
61 * The HTC service connect call will block, so this function
62 * needs to be called in passive context.
63 * Because HTC setup has not been completed at the time this function
64 * is called, this function cannot send any HTC messages to the target.
65 * Messages to configure the target are instead sent in the
66 * htc_attach_target function.
67 *
68 * @param txrx_pdev - data SW's physical device handle
69 * (used as context pointer during HTT -> txrx calls)
70 * @param ctrl_pdev - control SW's physical device handle
71 * (used to query configuration functions)
72 * @param osdev - abstract OS device handle
73 * (used for mem allocation)
74 * @param desc_pool_size - number of HTT descriptors to (pre)allocate
75 * @return success -> HTT pdev handle; failure -> NULL
76 */
77htt_pdev_handle
78htt_attach(
79 ol_txrx_pdev_handle txrx_pdev,
80 ol_pdev_handle ctrl_pdev,
81 HTC_HANDLE htc_pdev,
82 adf_os_device_t osdev,
83 int desc_pool_size);
84
85/**
86 * @brief Send HTT configuration messages to the target.
87 * @details
88 * For LL only, this function sends a rx ring configuration message to the
89 * target. For HL, this function is a no-op.
90 *
91 * @param htt_pdev - handle to the HTT instance being initialized
92 */
93A_STATUS
94htt_attach_target(htt_pdev_handle htt_pdev);
95
96/**
97 * @brief modes that a virtual device can operate as
98 * @details
Samuel Ahn3a689822014-12-10 16:25:29 -080099 * A virtual device can operate as an AP, an IBSS, a STA
100 * (client), in monitor mode or in OCB mode
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700101 */
102enum htt_op_mode {
103 htt_op_mode_unknown,
104 htt_op_mode_ap,
105 htt_op_mode_ibss,
106 htt_op_mode_sta,
107 htt_op_mode_monitor,
Samuel Ahn3a689822014-12-10 16:25:29 -0800108 htt_op_mode_ocb,
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700109};
110
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700111/* no-ops */
112#define htt_vdev_attach(htt_pdev, vdev_id, op_mode)
113#define htt_vdev_detach(htt_pdev, vdev_id)
114#define htt_peer_qos_update(htt_pdev, peer_id, qos_capable)
115#define htt_peer_uapsdmask_update(htt_pdev, peer_id, uapsd_mask)
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700116
117/**
118 * @brief Deallocate a HTT instance.
119 *
120 * @param htt_pdev - handle to the HTT instance being torn down
121 */
122void
123htt_detach(htt_pdev_handle htt_pdev);
124
125/**
126 * @brief Stop the communication between HTT and target
127 * @details
128 * For ISOC solution, this function stop the communication between HTT and 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 a no-op.
131 * Peregrine/Rome HTT layer is on top of HTC while ISOC solution HTT layer is
132 * on top of DXE layer.
133 *
134 * @param htt_pdev - handle to the HTT instance being initialized
135 */
136void
137htt_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
146htt_h2t_sync_msg(htt_pdev_handle htt_pdev, u_int8_t sync_cnt);
147
148
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700149int
150htt_h2t_aggr_cfg_msg(htt_pdev_handle htt_pdev,
Jeff Johnson88a57412014-02-18 15:58:27 -0800151 int max_subfrms_ampdu,
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700152 int max_subfrms_amsdu);
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700153
154/**
155 * @brief Get the FW status
156 * @details
157 * Trigger FW HTT to retrieve FW status.
158 * A separate HTT message will come back with the statistics we want.
159 *
160 * @param pdev - handle to the HTT instance
161 * @param stats_type_upload_mask - bitmask identifying which stats to upload
162 * @param stats_type_reset_mask - bitmask identifying which stats to reset
163 * @param cookie - unique value to distinguish and identify stats requests
164 * @return 0 - succeed to send the request to FW; otherwise, failed to do so.
165 */
166int
167htt_h2t_dbg_stats_get(
Jeff Johnson88a57412014-02-18 15:58:27 -0800168 struct htt_pdev_t *pdev,
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700169 u_int32_t stats_type_upload_mask,
170 u_int32_t stats_type_reset_mask,
171 u_int8_t cfg_stats_type,
172 u_int32_t cfg_val,
173 u_int64_t cookie);
174
175/**
176 * @brief Get the fields from HTT T2H stats upload message's stats info header
177 * @details
178 * Parse the a HTT T2H message's stats info tag-length-value header,
179 * to obtain the stats type, status, data lenght, and data address.
180 *
181 * @param stats_info_list - address of stats record's header
182 * @param[out] type - which type of FW stats are contained in the record
183 * @param[out] status - whether the stats are (fully) present in the record
184 * @param[out] length - how large the data portion of the stats record is
185 * @param[out] stats_data - where the data portion of the stats record is
186 */
187void
188htt_t2h_dbg_stats_hdr_parse(
189 u_int8_t *stats_info_list,
190 enum htt_dbg_stats_type *type,
191 enum htt_dbg_stats_status *status,
192 int *length,
193 u_int8_t **stats_data);
194
195/**
196 * @brief Display a stats record from the HTT T2H STATS_CONF message.
197 * @details
198 * Parse the stats type and status, and invoke a type-specified printout
199 * to display the stats values.
200 *
201 * @param stats_data - buffer holding the stats record from the STATS_CONF msg
202 * @param concise - whether to do a verbose or concise printout
203 */
204void
205htt_t2h_stats_print(u_int8_t *stats_data, int concise);
206
207#ifndef HTT_DEBUG_LEVEL
Srinivas Girigowda2e3a1062016-04-13 18:25:09 -0700208#if defined(WLAN_DEBUG)
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700209#define HTT_DEBUG_LEVEL 10
210#else
211#define HTT_DEBUG_LEVEL 0
212#endif
213#endif
214
215#if HTT_DEBUG_LEVEL > 5
216void htt_display(htt_pdev_handle pdev, int indent);
217#else
218#define htt_display(pdev, indent)
219#endif
220
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700221#define HTT_DXE_RX_LOG 0
222#define htt_rx_reorder_log_print(pdev)
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700223
Leo Changc19d4de2014-06-05 14:01:56 -0700224#ifdef IPA_UC_OFFLOAD
225/**
226 * @brief send IPA UC resource config message to firmware with HTT message
227 * @details
228 * send IPA UC resource config message to firmware with HTT message
229 *
230 * @param pdev - handle to the HTT instance
231 */
232int
233htt_h2t_ipa_uc_rsc_cfg_msg(struct htt_pdev_t *pdev);
234
235/**
236 * @brief Client request resource information
237 * @details
238 * OL client will reuqest IPA UC related resource information
239 * Resource information will be distributted to IPA module
240 * All of the required resources should be pre-allocated
241 *
242 * @param pdev - handle to the HTT instance
243 * @param ce_sr_base_paddr - copy engine source ring base physical address
244 * @param ce_sr_ring_size - copy engine source ring size
245 * @param ce_reg_paddr - copy engine register physical address
246 * @param tx_comp_ring_base_paddr - tx comp ring base physical address
247 * @param tx_comp_ring_size - tx comp ring size
248 * @param tx_num_alloc_buffer - number of allocated tx buffer
249 * @param rx_rdy_ring_base_paddr - rx ready ring base physical address
250 * @param rx_rdy_ring_size - rx ready ring size
251 * @param rx_proc_done_idx_paddr - rx process done index physical address
252 */
253int
254htt_ipa_uc_get_resource(htt_pdev_handle pdev,
255 a_uint32_t *ce_sr_base_paddr,
256 a_uint32_t *ce_sr_ring_size,
257 a_uint32_t *ce_reg_paddr,
258 a_uint32_t *tx_comp_ring_base_paddr,
259 a_uint32_t *tx_comp_ring_size,
260 a_uint32_t *tx_num_alloc_buffer,
261 a_uint32_t *rx_rdy_ring_base_paddr,
262 a_uint32_t *rx_rdy_ring_size,
263 a_uint32_t *rx_proc_done_idx_paddr);
264
265/**
266 * @brief Client set IPA UC doorbell register
267 * @details
268 * IPA UC let know doorbell register physical address
269 * WLAN firmware will use this physical address to notify IPA UC
270 *
271 * @param pdev - handle to the HTT instance
272 * @param ipa_uc_tx_doorbell_paddr - tx comp doorbell physical address
273 * @param ipa_uc_rx_doorbell_paddr - rx ready doorbell physical address
274 */
275int
276htt_ipa_uc_set_doorbell_paddr(htt_pdev_handle pdev,
277 a_uint32_t ipa_uc_tx_doorbell_paddr,
278 a_uint32_t ipa_uc_rx_doorbell_paddr);
279
280/**
281 * @brief Client notify IPA UC data path active or not
282 *
283 * @param pdev - handle to the HTT instance
284 * @param uc_active - UC data path is active or not
285 * @param is_tx - UC TX is active or not
286 */
287int
288htt_h2t_ipa_uc_set_active(struct htt_pdev_t *pdev,
289 a_bool_t uc_active,
290 a_bool_t is_tx);
291
292/**
Leo Chang198c3f82014-08-14 08:52:15 -0700293 * @brief query uc data path stats
294 *
295 * @param pdev - handle to the HTT instance
296 */
297int
298htt_h2t_ipa_uc_get_stats(struct htt_pdev_t *pdev);
299
300/**
Leo Changc19d4de2014-06-05 14:01:56 -0700301 * @brief Attach IPA UC data path
302 *
303 * @param pdev - handle to the HTT instance
304 */
305int
306htt_ipa_uc_attach(struct htt_pdev_t *pdev);
307
308/**
309 * @brief detach IPA UC data path
310 *
311 * @param pdev - handle to the HTT instance
312 */
313void
314htt_ipa_uc_detach(struct htt_pdev_t *pdev);
315#endif /* IPA_UC_OFFLOAD */
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700316
Nirav Shahc381b502015-03-12 19:05:23 +0530317#if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT)
318void
319htt_dump_bundle_stats(struct htt_pdev_t *pdev);
320void
321htt_clear_bundle_stats(struct htt_pdev_t *pdev);
322#else
323
324#define htt_dump_bundle_stats(pdev) /*no-op*/
325#define htt_clear_bundle_stats(pdev) /*no-op*/
326
327#endif
328
Govind Singh9890e992016-07-14 18:53:17 +0530329typedef void (*tp_rx_pkt_dump_cb)(adf_nbuf_t msdu, struct ol_txrx_peer_t *peer,
Himanshu Agarwaldd90bdb2016-03-09 10:26:47 +0530330 uint8_t status);
331void htt_register_rx_pkt_dump_callback(struct htt_pdev_t *pdev,
332 tp_rx_pkt_dump_cb ol_rx_pkt_dump_call);
333void htt_deregister_rx_pkt_dump_callback(struct htt_pdev_t *pdev);
Govind Singh9890e992016-07-14 18:53:17 +0530334void ol_rx_pkt_dump_call(adf_nbuf_t msdu, struct ol_txrx_peer_t *peer, uint8_t status);
Himanshu Agarwalfe8d94e2016-05-26 18:27:34 +0530335void htt_mark_first_wakeup_packet(htt_pdev_handle pdev, uint8_t value);
Himanshu Agarwaldd90bdb2016-03-09 10:26:47 +0530336
Madan Mohan Koyyalamudie32d2192013-09-28 23:54:37 -0700337#endif /* _OL_HTT_API__H_ */