Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 1 | /* |
Srinivas Girigowda | 2e3a106 | 2016-04-13 18:25:09 -0700 | [diff] [blame] | 2 | * Copyright (c) 2011, 2014, 2016 The Linux Foundation. All rights reserved. |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 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 | */ |
Prakash Dhavali | 7410fac | 2014-02-05 21:27:47 -0800 | [diff] [blame] | 27 | |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 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 <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 | |
| 51 | struct htt_pdev_t; |
| 52 | typedef 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 | */ |
| 77 | htt_pdev_handle |
| 78 | htt_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 | */ |
| 93 | A_STATUS |
| 94 | htt_attach_target(htt_pdev_handle htt_pdev); |
| 95 | |
| 96 | /** |
| 97 | * @brief modes that a virtual device can operate as |
| 98 | * @details |
Samuel Ahn | 3a68982 | 2014-12-10 16:25:29 -0800 | [diff] [blame] | 99 | * A virtual device can operate as an AP, an IBSS, a STA |
| 100 | * (client), in monitor mode or in OCB mode |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 101 | */ |
| 102 | enum 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 Ahn | 3a68982 | 2014-12-10 16:25:29 -0800 | [diff] [blame] | 108 | htt_op_mode_ocb, |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 111 | /* 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 Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 116 | |
| 117 | /** |
| 118 | * @brief Deallocate a HTT instance. |
| 119 | * |
| 120 | * @param htt_pdev - handle to the HTT instance being torn down |
| 121 | */ |
| 122 | void |
| 123 | htt_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 | */ |
| 136 | void |
| 137 | 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 | */ |
| 145 | A_STATUS |
| 146 | htt_h2t_sync_msg(htt_pdev_handle htt_pdev, u_int8_t sync_cnt); |
| 147 | |
| 148 | |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 149 | int |
| 150 | htt_h2t_aggr_cfg_msg(htt_pdev_handle htt_pdev, |
Jeff Johnson | 88a5741 | 2014-02-18 15:58:27 -0800 | [diff] [blame] | 151 | int max_subfrms_ampdu, |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 152 | int max_subfrms_amsdu); |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 153 | |
| 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 | */ |
| 166 | int |
| 167 | htt_h2t_dbg_stats_get( |
Jeff Johnson | 88a5741 | 2014-02-18 15:58:27 -0800 | [diff] [blame] | 168 | struct htt_pdev_t *pdev, |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 169 | 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 | */ |
| 187 | void |
| 188 | htt_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 | */ |
| 204 | void |
| 205 | htt_t2h_stats_print(u_int8_t *stats_data, int concise); |
| 206 | |
| 207 | #ifndef HTT_DEBUG_LEVEL |
Srinivas Girigowda | 2e3a106 | 2016-04-13 18:25:09 -0700 | [diff] [blame] | 208 | #if defined(WLAN_DEBUG) |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 209 | #define HTT_DEBUG_LEVEL 10 |
| 210 | #else |
| 211 | #define HTT_DEBUG_LEVEL 0 |
| 212 | #endif |
| 213 | #endif |
| 214 | |
| 215 | #if HTT_DEBUG_LEVEL > 5 |
| 216 | void htt_display(htt_pdev_handle pdev, int indent); |
| 217 | #else |
| 218 | #define htt_display(pdev, indent) |
| 219 | #endif |
| 220 | |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 221 | #define HTT_DXE_RX_LOG 0 |
| 222 | #define htt_rx_reorder_log_print(pdev) |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 223 | |
Leo Chang | c19d4de | 2014-06-05 14:01:56 -0700 | [diff] [blame] | 224 | #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 | */ |
| 232 | int |
| 233 | htt_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 | */ |
| 253 | int |
| 254 | htt_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 | */ |
| 275 | int |
| 276 | htt_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 | */ |
| 287 | int |
| 288 | htt_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 Chang | 198c3f8 | 2014-08-14 08:52:15 -0700 | [diff] [blame] | 293 | * @brief query uc data path stats |
| 294 | * |
| 295 | * @param pdev - handle to the HTT instance |
| 296 | */ |
| 297 | int |
| 298 | htt_h2t_ipa_uc_get_stats(struct htt_pdev_t *pdev); |
| 299 | |
| 300 | /** |
Leo Chang | c19d4de | 2014-06-05 14:01:56 -0700 | [diff] [blame] | 301 | * @brief Attach IPA UC data path |
| 302 | * |
| 303 | * @param pdev - handle to the HTT instance |
| 304 | */ |
| 305 | int |
| 306 | htt_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 | */ |
| 313 | void |
| 314 | htt_ipa_uc_detach(struct htt_pdev_t *pdev); |
| 315 | #endif /* IPA_UC_OFFLOAD */ |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 316 | |
Nirav Shah | c381b50 | 2015-03-12 19:05:23 +0530 | [diff] [blame] | 317 | #if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT) |
| 318 | void |
| 319 | htt_dump_bundle_stats(struct htt_pdev_t *pdev); |
| 320 | void |
| 321 | htt_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 Singh | 9890e99 | 2016-07-14 18:53:17 +0530 | [diff] [blame] | 329 | typedef void (*tp_rx_pkt_dump_cb)(adf_nbuf_t msdu, struct ol_txrx_peer_t *peer, |
Himanshu Agarwal | dd90bdb | 2016-03-09 10:26:47 +0530 | [diff] [blame] | 330 | uint8_t status); |
| 331 | void htt_register_rx_pkt_dump_callback(struct htt_pdev_t *pdev, |
| 332 | tp_rx_pkt_dump_cb ol_rx_pkt_dump_call); |
| 333 | void htt_deregister_rx_pkt_dump_callback(struct htt_pdev_t *pdev); |
Govind Singh | 9890e99 | 2016-07-14 18:53:17 +0530 | [diff] [blame] | 334 | void ol_rx_pkt_dump_call(adf_nbuf_t msdu, struct ol_txrx_peer_t *peer, uint8_t status); |
Himanshu Agarwal | fe8d94e | 2016-05-26 18:27:34 +0530 | [diff] [blame] | 335 | void htt_mark_first_wakeup_packet(htt_pdev_handle pdev, uint8_t value); |
Himanshu Agarwal | dd90bdb | 2016-03-09 10:26:47 +0530 | [diff] [blame] | 336 | |
Madan Mohan Koyyalamudi | e32d219 | 2013-09-28 23:54:37 -0700 | [diff] [blame] | 337 | #endif /* _OL_HTT_API__H_ */ |