Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1 | /* |
Kiran Venkatappa | e17e3b6 | 2017-02-10 16:31:49 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [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 | */ |
| 27 | |
| 28 | #ifndef _HTC_INTERNAL_H_ |
| 29 | #define _HTC_INTERNAL_H_ |
| 30 | |
| 31 | #ifdef __cplusplus |
| 32 | extern "C" { |
| 33 | #endif /* __cplusplus */ |
| 34 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 35 | #include "htc_api.h" |
| 36 | #include "htc_packet.h" |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 37 | #include <hif.h> |
| 38 | #include <htc.h> |
| 39 | #include <qdf_atomic.h> |
| 40 | #include <qdf_event.h> |
| 41 | #include <qdf_lock.h> |
| 42 | #include <qdf_nbuf.h> |
| 43 | #include <qdf_timer.h> |
| 44 | #include <qdf_types.h> |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 45 | |
| 46 | /* HTC operational parameters */ |
| 47 | #define HTC_TARGET_RESPONSE_TIMEOUT 2000 /* in ms */ |
| 48 | #define HTC_TARGET_DEBUG_INTR_MASK 0x01 |
| 49 | #define HTC_TARGET_CREDIT_INTR_MASK 0xF0 |
| 50 | #define HTC_MIN_MSG_PER_BUNDLE 2 |
| 51 | #if defined(HIF_USB) |
Poddar, Siddarth | 416b706 | 2016-04-29 11:02:13 +0530 | [diff] [blame] | 52 | #define HTC_MAX_MSG_PER_BUNDLE_RX 11 |
| 53 | #define HTC_MAX_MSG_PER_BUNDLE_TX 8 |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 54 | #else |
Poddar, Siddarth | 416b706 | 2016-04-29 11:02:13 +0530 | [diff] [blame] | 55 | #define HTC_MAX_MSG_PER_BUNDLE_RX 64 |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 56 | #define HTC_MAX_MSG_PER_BUNDLE 16 |
Poddar, Siddarth | 416b706 | 2016-04-29 11:02:13 +0530 | [diff] [blame] | 57 | #define HTC_MAX_MSG_PER_BUNDLE_TX 32 |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 58 | #endif |
Poddar, Siddarth | df03009 | 2016-04-28 11:41:57 +0530 | [diff] [blame] | 59 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 60 | /* |
| 61 | * HTC_MAX_TX_BUNDLE_SEND_LIMIT - |
| 62 | * This value is in units of tx frame fragments. |
| 63 | * It needs to be at least as large as the maximum number of tx frames in a |
| 64 | * HTC download bundle times the average number of fragments in each such frame |
| 65 | * (In certain operating systems, such as Linux, we expect to only have |
| 66 | * a single fragment per frame anyway.) |
| 67 | */ |
| 68 | #define HTC_MAX_TX_BUNDLE_SEND_LIMIT 255 |
| 69 | |
| 70 | #define HTC_PACKET_CONTAINER_ALLOCATION 32 |
| 71 | #define NUM_CONTROL_TX_BUFFERS 2 |
| 72 | #define HTC_CONTROL_BUFFER_SIZE (HTC_MAX_CONTROL_MESSAGE_LENGTH + HTC_HDR_LENGTH) |
| 73 | #define HTC_CONTROL_BUFFER_ALIGN 32 |
| 74 | #define HTC_TARGET_RESPONSE_POLL_MS 10 |
| 75 | #if !defined(A_SIMOS_DEVHOST) |
| 76 | #define HTC_TARGET_MAX_RESPONSE_POLL 200 /* actual HW */ |
| 77 | #else |
| 78 | #define HTC_TARGET_MAX_RESPONSE_POLL 600 /* host + target simulation */ |
| 79 | #endif |
| 80 | |
| 81 | #define HTC_SERVICE_TX_PACKET_TAG HTC_TX_PACKET_TAG_INTERNAL |
| 82 | |
| 83 | #define HTC_CREDIT_HISTORY_MAX 1024 |
| 84 | |
Yue Ma | ec9e71c | 2016-02-26 18:52:20 -0800 | [diff] [blame] | 85 | #define HTC_IS_EPPING_ENABLED(_x) ((_x) == QDF_GLOBAL_EPPING_MODE) |
| 86 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 87 | typedef enum { |
| 88 | HTC_REQUEST_CREDIT, |
| 89 | HTC_PROCESS_CREDIT_REPORT, |
| 90 | HTC_SUSPEND_ACK, |
| 91 | HTC_SUSPEND_NACK, |
Rajeev Kumar | 296c019 | 2016-08-08 10:51:33 -0700 | [diff] [blame] | 92 | HTC_INITIAL_WAKE_UP, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 93 | } htc_credit_exchange_type; |
| 94 | |
Dustin Brown | 536064a | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 95 | static inline const char* |
| 96 | htc_credit_exchange_type_str(htc_credit_exchange_type type) |
| 97 | { |
| 98 | switch (type) { |
| 99 | case HTC_REQUEST_CREDIT: |
| 100 | return "HTC_REQUEST_CREDIT"; |
| 101 | case HTC_PROCESS_CREDIT_REPORT: |
| 102 | return "HTC_PROCESS_CREDIT_REPORT"; |
| 103 | case HTC_SUSPEND_ACK: |
| 104 | return "HTC_SUSPEND_ACK"; |
| 105 | case HTC_SUSPEND_NACK: |
| 106 | return "HTC_SUSPEND_NACK"; |
| 107 | case HTC_INITIAL_WAKE_UP: |
| 108 | return "HTC_INITIAL_WAKE_UP"; |
| 109 | default: |
| 110 | return "Unknown htc_credit_exchange_type"; |
| 111 | } |
| 112 | } |
| 113 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 114 | typedef struct { |
| 115 | htc_credit_exchange_type type; |
| 116 | uint64_t time; |
| 117 | uint32_t tx_credit; |
| 118 | uint32_t htc_tx_queue_depth; |
| 119 | } HTC_CREDIT_HISTORY; |
| 120 | |
| 121 | typedef struct _HTC_ENDPOINT { |
| 122 | HTC_ENDPOINT_ID Id; |
Houston Hoffman | 4f2f459 | 2015-10-20 18:00:29 -0700 | [diff] [blame] | 123 | |
| 124 | /* service ID this endpoint is bound to |
| 125 | * non-zero value means this endpoint is in use |
| 126 | */ |
| 127 | HTC_SERVICE_ID service_id; |
| 128 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 129 | HTC_EP_CALLBACKS EpCallBacks; /* callbacks associated with this endpoint */ |
| 130 | HTC_PACKET_QUEUE TxQueue; /* HTC frame buffer TX queue */ |
| 131 | int MaxTxQueueDepth; /* max depth of the TX queue before we need to |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 132 | call driver's full handler */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 133 | int MaxMsgLength; /* max length of endpoint message */ |
| 134 | uint8_t UL_PipeID; |
| 135 | uint8_t DL_PipeID; |
| 136 | int ul_is_polled; /* Need to call HIF to get tx completion callbacks? */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 137 | qdf_timer_t ul_poll_timer; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 138 | int ul_poll_timer_active; |
| 139 | int ul_outstanding_cnt; |
| 140 | int dl_is_polled; /* Need to call HIF to fetch rx? (Not currently supported.) */ |
| 141 | #if 0 /* not currently supported */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 142 | qdf_timer_t dl_poll_timer; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 143 | #endif |
| 144 | |
| 145 | HTC_PACKET_QUEUE TxLookupQueue; /* lookup queue to match netbufs to htc packets */ |
| 146 | HTC_PACKET_QUEUE RxBufferHoldQueue; /* temporary hold queue for back compatibility */ |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 147 | uint8_t SeqNo; /* TX seq no (helpful) for debugging */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 148 | qdf_atomic_t TxProcessCount; /* serialization */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 149 | struct _HTC_TARGET *target; |
| 150 | int TxCredits; /* TX credits available on this endpoint */ |
| 151 | int TxCreditSize; /* size in bytes of each credit (set by HTC) */ |
| 152 | int TxCreditsPerMaxMsg; /* credits required per max message (precalculated) */ |
| 153 | #ifdef HTC_EP_STAT_PROFILING |
Houston Hoffman | 29573d9 | 2015-10-20 17:49:44 -0700 | [diff] [blame] | 154 | HTC_ENDPOINT_STATS endpoint_stats; /* endpoint statistics */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 155 | #endif |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 156 | bool TxCreditFlowEnabled; |
Venkateswara Swamy Bandaru | ae41b9e | 2016-11-21 15:06:24 +0530 | [diff] [blame] | 157 | bool async_update; /* packets can be queued asynchronously */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 158 | } HTC_ENDPOINT; |
| 159 | |
| 160 | #ifdef HTC_EP_STAT_PROFILING |
Houston Hoffman | 29573d9 | 2015-10-20 17:49:44 -0700 | [diff] [blame] | 161 | #define INC_HTC_EP_STAT(p, stat, count) ((p)->endpoint_stats.stat += (count)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 162 | #else |
Houston Hoffman | 29573d9 | 2015-10-20 17:49:44 -0700 | [diff] [blame] | 163 | #define INC_HTC_EP_STAT(p, stat, count) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 164 | #endif |
| 165 | |
| 166 | typedef struct { |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 167 | uint16_t service_id; |
| 168 | uint8_t CreditAllocation; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 169 | } HTC_SERVICE_TX_CREDIT_ALLOCATION; |
| 170 | |
| 171 | #define HTC_MAX_SERVICE_ALLOC_ENTRIES 8 |
| 172 | |
| 173 | /* Error codes for HTC layer packet stats*/ |
| 174 | enum ol_ath_htc_pkt_ecodes { |
| 175 | GET_HTC_PKT_Q_FAIL = 0, /* error- get packet at head of HTC_PACKET_Q */ |
| 176 | HTC_PKT_Q_EMPTY, |
| 177 | HTC_SEND_Q_EMPTY |
| 178 | }; |
| 179 | /* our HTC target state */ |
| 180 | typedef struct _HTC_TARGET { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 181 | struct hif_opaque_softc *hif_dev; |
Houston Hoffman | 29573d9 | 2015-10-20 17:49:44 -0700 | [diff] [blame] | 182 | HTC_ENDPOINT endpoint[ENDPOINT_MAX]; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 183 | qdf_spinlock_t HTCLock; |
| 184 | qdf_spinlock_t HTCRxLock; |
| 185 | qdf_spinlock_t HTCTxLock; |
| 186 | qdf_spinlock_t HTCCreditLock; |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 187 | uint32_t HTCStateFlags; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 188 | void *host_handle; |
| 189 | HTC_INIT_INFO HTCInitInfo; |
| 190 | HTC_PACKET *pHTCPacketStructPool; /* pool of HTC packets */ |
| 191 | HTC_PACKET_QUEUE ControlBufferTXFreeList; |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 192 | uint8_t CtrlResponseBuffer[HTC_MAX_CONTROL_MESSAGE_LENGTH]; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 193 | int CtrlResponseLength; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 194 | qdf_event_t ctrl_response_valid; |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 195 | bool CtrlResponseProcessing; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 196 | int TotalTransmitCredits; |
| 197 | HTC_SERVICE_TX_CREDIT_ALLOCATION |
| 198 | ServiceTxAllocTable[HTC_MAX_SERVICE_ALLOC_ENTRIES]; |
| 199 | int TargetCreditSize; |
| 200 | #ifdef RX_SG_SUPPORT |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 201 | qdf_nbuf_queue_t RxSgQueue; |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 202 | bool IsRxSgInprogress; |
| 203 | uint32_t CurRxSgTotalLen; /* current total length */ |
| 204 | uint32_t ExpRxSgTotalLen; /* expected total length */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 205 | #endif |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 206 | qdf_device_t osdev; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 207 | struct ol_ath_htc_stats htc_pkt_stats; |
| 208 | HTC_PACKET *pBundleFreeList; |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 209 | uint32_t ce_send_cnt; |
| 210 | uint32_t TX_comp_cnt; |
| 211 | uint8_t MaxMsgsPerHTCBundle; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 212 | qdf_work_t queue_kicker; |
Poddar, Siddarth | df03009 | 2016-04-28 11:41:57 +0530 | [diff] [blame] | 213 | |
| 214 | #ifdef HIF_SDIO |
| 215 | A_UINT16 AltDataCreditSize; |
| 216 | #endif |
Mohit Khanna | 0f6194e | 2016-05-17 15:30:44 -0700 | [diff] [blame] | 217 | A_UINT32 avail_tx_credits; |
Poddar, Siddarth | 416b706 | 2016-04-29 11:02:13 +0530 | [diff] [blame] | 218 | #if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT) |
| 219 | A_UINT32 rx_bundle_stats[HTC_MAX_MSG_PER_BUNDLE_RX]; |
| 220 | A_UINT32 tx_bundle_stats[HTC_MAX_MSG_PER_BUNDLE_TX]; |
| 221 | #endif |
Poddar, Siddarth | df03009 | 2016-04-28 11:41:57 +0530 | [diff] [blame] | 222 | |
Yue Ma | ec9e71c | 2016-02-26 18:52:20 -0800 | [diff] [blame] | 223 | uint32_t con_mode; |
gbian | b417db2 | 2016-09-30 17:01:07 +0800 | [diff] [blame] | 224 | |
| 225 | /* |
| 226 | * This flag is from the mboxping tool. It indicates that we cannot |
| 227 | * drop it. Besides, nodrop pkts have higher priority than normal pkts. |
| 228 | */ |
| 229 | A_BOOL is_nodrop_pkt; |
Kiran Venkatappa | e17e3b6 | 2017-02-10 16:31:49 +0530 | [diff] [blame] | 230 | |
| 231 | /* |
| 232 | * Number of WMI endpoints used. |
| 233 | * Default value is 1. But it should be overidden after htc_create to |
| 234 | * reflect the actual count. |
| 235 | */ |
| 236 | uint8_t wmi_ep_count; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 237 | } HTC_TARGET; |
| 238 | |
Mohit Khanna | 0f6194e | 2016-05-17 15:30:44 -0700 | [diff] [blame] | 239 | #if defined ENABLE_BUNDLE_TX |
| 240 | #define HTC_TX_BUNDLE_ENABLED(target) (target->MaxMsgsPerHTCBundle > 1) |
| 241 | #else |
| 242 | #define HTC_TX_BUNDLE_ENABLED(target) 0 |
| 243 | #endif |
| 244 | |
| 245 | #if defined ENABLE_BUNDLE_RX |
| 246 | #define HTC_RX_BUNDLE_ENABLED(target) (target->MaxMsgsPerHTCBundle > 1) |
| 247 | #else |
| 248 | #define HTC_RX_BUNDLE_ENABLED(target) 0 |
| 249 | #endif |
| 250 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 251 | #define HTC_ENABLE_BUNDLE(target) (target->MaxMsgsPerHTCBundle > 1) |
Mohit Khanna | 0f6194e | 2016-05-17 15:30:44 -0700 | [diff] [blame] | 252 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 253 | #ifdef RX_SG_SUPPORT |
| 254 | #define RESET_RX_SG_CONFIG(_target) \ |
| 255 | _target->ExpRxSgTotalLen = 0; \ |
| 256 | _target->CurRxSgTotalLen = 0; \ |
| 257 | _target->IsRxSgInprogress = false; |
| 258 | #endif |
| 259 | |
| 260 | #define HTC_STATE_STOPPING (1 << 0) |
| 261 | #define HTC_STOPPING(t) ((t)->HTCStateFlags & HTC_STATE_STOPPING) |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 262 | #define LOCK_HTC(t) qdf_spin_lock_bh(&(t)->HTCLock); |
| 263 | #define UNLOCK_HTC(t) qdf_spin_unlock_bh(&(t)->HTCLock); |
| 264 | #define LOCK_HTC_RX(t) qdf_spin_lock_bh(&(t)->HTCRxLock); |
| 265 | #define UNLOCK_HTC_RX(t) qdf_spin_unlock_bh(&(t)->HTCRxLock); |
| 266 | #define LOCK_HTC_TX(t) qdf_spin_lock_bh(&(t)->HTCTxLock); |
| 267 | #define UNLOCK_HTC_TX(t) qdf_spin_unlock_bh(&(t)->HTCTxLock); |
| 268 | #define LOCK_HTC_CREDIT(t) qdf_spin_lock_bh(&(t)->HTCCreditLock); |
| 269 | #define UNLOCK_HTC_CREDIT(t) qdf_spin_unlock_bh(&(t)->HTCCreditLock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 270 | |
| 271 | #define GET_HTC_TARGET_FROM_HANDLE(hnd) ((HTC_TARGET *)(hnd)) |
| 272 | |
| 273 | #define IS_TX_CREDIT_FLOW_ENABLED(ep) ((ep)->TxCreditFlowEnabled) |
| 274 | |
| 275 | #define HTC_POLL_CLEANUP_PERIOD_MS 10 /* milliseconds */ |
| 276 | |
| 277 | /* Macro to Increment the HTC_PACKET_ERRORS for Tx.*/ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 278 | #define OL_ATH_HTC_PKT_ERROR_COUNT_INCR(_target, _ecode) \ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 279 | do { \ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 280 | if (_ecode == GET_HTC_PKT_Q_FAIL) \ |
| 281 | (_target->htc_pkt_stats.htc_get_pkt_q_fail_count) += 1 \ |
| 282 | ; \ |
| 283 | if (_ecode == HTC_PKT_Q_EMPTY) \ |
| 284 | (_target->htc_pkt_stats.htc_pkt_q_empty_count) += 1 \ |
| 285 | ; \ |
| 286 | if (_ecode == HTC_SEND_Q_EMPTY) \ |
| 287 | (_target->htc_pkt_stats.htc_send_q_empty_count) += 1 \ |
| 288 | ; \ |
| 289 | } while (0); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 290 | /* internal HTC functions */ |
| 291 | |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 292 | QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 293 | uint8_t pipeID); |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 294 | QDF_STATUS htc_tx_completion_handler(void *Context, qdf_nbuf_t netbuf, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 295 | unsigned int transferID, uint32_t toeplitz_hash_result); |
| 296 | |
| 297 | HTC_PACKET *allocate_htc_bundle_packet(HTC_TARGET *target); |
| 298 | void free_htc_bundle_packet(HTC_TARGET *target, HTC_PACKET *pPacket); |
| 299 | |
| 300 | HTC_PACKET *allocate_htc_packet_container(HTC_TARGET *target); |
| 301 | void free_htc_packet_container(HTC_TARGET *target, HTC_PACKET *pPacket); |
| 302 | void htc_flush_rx_hold_queue(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint); |
| 303 | void htc_flush_endpoint_tx(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint, |
| 304 | HTC_TX_TAG Tag); |
| 305 | void htc_recv_init(HTC_TARGET *target); |
| 306 | A_STATUS htc_wait_recv_ctrl_message(HTC_TARGET *target); |
| 307 | void htc_free_control_tx_packet(HTC_TARGET *target, HTC_PACKET *pPacket); |
| 308 | HTC_PACKET *htc_alloc_control_tx_packet(HTC_TARGET *target); |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 309 | uint8_t htc_get_credit_allocation(HTC_TARGET *target, uint16_t service_id); |
| 310 | void htc_tx_resource_avail_handler(void *context, uint8_t pipeID); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 311 | void htc_control_rx_complete(void *Context, HTC_PACKET *pPacket); |
| 312 | void htc_process_credit_rpt(HTC_TARGET *target, |
| 313 | HTC_CREDIT_REPORT *pRpt, |
| 314 | int NumEntries, HTC_ENDPOINT_ID FromEndpoint); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 315 | void htc_fw_event_handler(void *context, QDF_STATUS status); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 316 | void htc_send_complete_check_cleanup(void *context); |
Yue Ma | ec9e71c | 2016-02-26 18:52:20 -0800 | [diff] [blame] | 317 | #ifdef FEATURE_RUNTIME_PM |
Houston Hoffman | 47e387b | 2015-10-20 17:04:42 -0700 | [diff] [blame] | 318 | void htc_kick_queues(void *context); |
Yue Ma | ec9e71c | 2016-02-26 18:52:20 -0800 | [diff] [blame] | 319 | #endif |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 320 | |
| 321 | void htc_credit_record(htc_credit_exchange_type type, uint32_t tx_credit, |
| 322 | uint32_t htc_tx_queue_depth); |
| 323 | |
| 324 | static inline void htc_send_complete_poll_timer_stop(HTC_ENDPOINT * |
| 325 | pEndpoint) { |
| 326 | LOCK_HTC_TX(pEndpoint->target); |
| 327 | if (pEndpoint->ul_poll_timer_active) { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 328 | /* qdf_timer_stop(&pEndpoint->ul_poll_timer); */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 329 | pEndpoint->ul_poll_timer_active = 0; |
| 330 | } |
| 331 | UNLOCK_HTC_TX(pEndpoint->target); |
| 332 | } |
| 333 | |
| 334 | static inline void htc_send_complete_poll_timer_start(HTC_ENDPOINT * |
| 335 | pEndpoint) { |
| 336 | LOCK_HTC_TX(pEndpoint->target); |
| 337 | if (pEndpoint->ul_outstanding_cnt |
| 338 | && !pEndpoint->ul_poll_timer_active) { |
| 339 | /* |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 340 | qdf_timer_start( |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 341 | &pEndpoint->ul_poll_timer, HTC_POLL_CLEANUP_PERIOD_MS); |
| 342 | */ |
| 343 | pEndpoint->ul_poll_timer_active = 1; |
| 344 | } |
| 345 | UNLOCK_HTC_TX(pEndpoint->target); |
| 346 | } |
| 347 | |
| 348 | static inline void |
| 349 | htc_send_complete_check(HTC_ENDPOINT *pEndpoint, int force) { |
| 350 | /* |
| 351 | * Stop the polling-cleanup timer that will result in a later call to |
| 352 | * this function. It may get started again below, if there are still |
| 353 | * outsending sends. |
| 354 | */ |
| 355 | htc_send_complete_poll_timer_stop(pEndpoint); |
| 356 | /* |
| 357 | * Check whether HIF has any prior sends that have finished, |
| 358 | * have not had the post-processing done. |
| 359 | */ |
| 360 | hif_send_complete_check(pEndpoint->target->hif_dev, |
| 361 | pEndpoint->UL_PipeID, force); |
| 362 | /* |
| 363 | * If there are still outstanding sends after polling, start a timer |
| 364 | * to check again a little later. |
| 365 | */ |
| 366 | htc_send_complete_poll_timer_start(pEndpoint); |
| 367 | } |
| 368 | |
| 369 | #ifdef __cplusplus |
| 370 | } |
| 371 | #endif |
| 372 | |
| 373 | #ifndef DEBUG_BUNDLE |
| 374 | #define DEBUG_BUNDLE 0 |
| 375 | #endif |
| 376 | |
Mohit Khanna | 0f6194e | 2016-05-17 15:30:44 -0700 | [diff] [blame] | 377 | #if defined(HIF_SDIO) || defined(HIF_USB) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 378 | #ifndef ENABLE_BUNDLE_TX |
| 379 | #define ENABLE_BUNDLE_TX 1 |
| 380 | #endif |
| 381 | |
| 382 | #ifndef ENABLE_BUNDLE_RX |
| 383 | #define ENABLE_BUNDLE_RX 1 |
| 384 | #endif |
Mohit Khanna | 0f6194e | 2016-05-17 15:30:44 -0700 | [diff] [blame] | 385 | #endif /*defined(HIF_SDIO) || defined(HIF_USB)*/ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 386 | #endif /* !_HTC_HOST_INTERNAL_H_ */ |