Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1 | /* |
Dustin Brown | 1e61fbc | 2018-01-08 12:30:30 -0800 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, 2016-2018 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_API_H_ |
| 29 | #define _HTC_API_H_ |
| 30 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 31 | #include <htc.h> |
| 32 | #include <htc_services.h> |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 33 | #include <qdf_types.h> /* qdf_device_t */ |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 34 | #include "htc_packet.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 35 | |
| 36 | #ifdef __cplusplus |
| 37 | extern "C" { |
| 38 | #endif /* __cplusplus */ |
| 39 | |
| 40 | /* TODO.. for BMI */ |
| 41 | #define ENDPOINT1 0 |
| 42 | /* TODO -remove me, but we have to fix BMI first */ |
| 43 | #define HTC_MAILBOX_NUM_MAX 4 |
| 44 | |
| 45 | /* this is the amount of header room required by users of HTC */ |
| 46 | #define HTC_HEADER_LEN HTC_HDR_LENGTH |
| 47 | |
Houston Hoffman | 9348186 | 2016-05-05 18:49:59 -0700 | [diff] [blame] | 48 | #define HTC_HTT_TRANSFER_HDRSIZE 24 |
| 49 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 50 | typedef void *HTC_HANDLE; |
| 51 | |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 52 | typedef uint16_t HTC_SERVICE_ID; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 53 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 54 | typedef void (*HTC_TARGET_FAILURE)(void *Instance, QDF_STATUS Status); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 55 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 56 | struct htc_init_info { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 57 | void *pContext; /* context for target notifications */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 58 | void (*TargetFailure)(void *Instance, QDF_STATUS Status); |
Houston Hoffman | 61fad9f | 2016-04-14 17:09:37 -0700 | [diff] [blame] | 59 | void (*TargetSendSuspendComplete)(void *ctx, bool is_nack); |
Mukul Sharma | 5142017 | 2017-03-06 14:28:56 +0530 | [diff] [blame] | 60 | void (*target_initial_wakeup_cb)(void *cb_ctx); |
| 61 | void *target_psoc; |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 62 | }; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 63 | |
| 64 | /* Struct for HTC layer packet stats*/ |
| 65 | struct ol_ath_htc_stats { |
| 66 | int htc_get_pkt_q_fail_count; |
| 67 | int htc_pkt_q_empty_count; |
| 68 | int htc_send_q_empty_count; |
| 69 | }; |
| 70 | |
Houston Hoffman | 47e387b | 2015-10-20 17:04:42 -0700 | [diff] [blame] | 71 | /* To resume HTT Tx queue during runtime resume */ |
| 72 | typedef void (*HTC_EP_RESUME_TX_QUEUE)(void *); |
| 73 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 74 | /* per service connection send completion */ |
| 75 | typedef void (*HTC_EP_SEND_PKT_COMPLETE)(void *, HTC_PACKET *); |
| 76 | /* per service connection callback when a plurality of packets have been sent |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 77 | * The HTC_PACKET_QUEUE is a temporary queue object (e.g. freed on return from |
| 78 | * the callback) to hold a list of completed send packets. |
| 79 | * If the handler cannot fully traverse the packet queue before returning, it |
| 80 | * should transfer the items of the queue into the caller's private queue using: |
| 81 | * HTC_PACKET_ENQUEUE() |
| 82 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 83 | typedef void (*HTC_EP_SEND_PKT_COMP_MULTIPLE)(void *, |
| 84 | HTC_PACKET_QUEUE *); |
| 85 | /* per service connection pkt received */ |
| 86 | typedef void (*HTC_EP_RECV_PKT)(void *, HTC_PACKET *); |
| 87 | /* per service connection callback when a plurality of packets are received |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 88 | * The HTC_PACKET_QUEUE is a temporary queue object (e.g. freed on return from |
| 89 | * the callback) to hold a list of recv packets. |
| 90 | * If the handler cannot fully traverse the packet queue before returning, it |
| 91 | * should transfer the items of the queue into the caller's private queue using: |
| 92 | * HTC_PACKET_ENQUEUE() |
| 93 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 94 | typedef void (*HTC_EP_RECV_PKT_MULTIPLE)(void *, HTC_PACKET_QUEUE *); |
| 95 | |
| 96 | /* Optional per service connection receive buffer re-fill callback, |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 97 | * On some OSes (like Linux) packets are allocated from a global pool and |
| 98 | * indicated up to the network stack. The driver never gets the packets back |
| 99 | * from the OS. For these OSes a refill callback can be used to allocate and |
| 100 | * re-queue buffers into HTC. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 101 | * |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 102 | * On other OSes, the network stack can call into the driver's OS-specific |
| 103 | * "return_packet" handler and the driver can re-queue these buffers into HTC. |
| 104 | * In this regard a refill callback is unnecessary |
| 105 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 106 | typedef void (*HTC_EP_RECV_REFILL)(void *, HTC_ENDPOINT_ID Endpoint); |
| 107 | |
| 108 | /* Optional per service connection receive buffer allocation callback. |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 109 | * On some systems packet buffers are an extremely limited resource. Rather than |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 110 | * queue largest-possible-sized buffers to HTC, some systems would rather |
| 111 | * allocate a specific size as the packet is received. The trade off is |
| 112 | * slightly more processing (callback invoked for each RX packet) |
| 113 | * for the benefit of committing fewer buffer resources into HTC. |
| 114 | * |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 115 | * The callback is provided the length of the pending packet to fetch. This |
| 116 | * includes the HTC header length plus the length of payload. The callback can |
| 117 | * return a pointer to the allocated HTC packet for immediate use. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 118 | * |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 119 | * Alternatively a variant of this handler can be used to allocate large receive |
| 120 | * packets as needed. For example an application can use the refill mechanism |
| 121 | * for normal packets and the recv-alloc mechanism to handle the case where a |
| 122 | * large packet buffer is required. This can significantly reduce the |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 123 | * amount of "committed" memory used to receive packets. |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 124 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 125 | typedef HTC_PACKET *(*HTC_EP_RECV_ALLOC)(void *, |
| 126 | HTC_ENDPOINT_ID Endpoint, |
| 127 | int Length); |
| 128 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 129 | enum htc_send_full_action { |
| 130 | /* packet that overflowed should be kept in the queue */ |
| 131 | HTC_SEND_FULL_KEEP = 0, |
| 132 | /* packet that overflowed should be dropped */ |
| 133 | HTC_SEND_FULL_DROP = 1, |
| 134 | }; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 135 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 136 | /* Optional per service connection callback when a send queue is full. This can |
| 137 | * occur if host continues queueing up TX packets faster than credits can arrive |
| 138 | * To prevent the host (on some Oses like Linux) from continuously queueing pkts |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 139 | * and consuming resources, this callback is provided so that that the host |
| 140 | * can disable TX in the subsystem (i.e. network stack). |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 141 | * This callback is invoked for each packet that "overflows" the HTC queue. The |
| 142 | * callback can determine whether the new packet that overflowed the queue can |
| 143 | * be kept (HTC_SEND_FULL_KEEP) or dropped (HTC_SEND_FULL_DROP). If a packet is |
| 144 | * dropped, the EpTxComplete handler will be called and the packet's status |
| 145 | * field will be set to A_NO_RESOURCE. |
| 146 | * Other OSes require a "per-packet" indication for each completed TX packet, |
| 147 | * this closed loop mechanism will prevent the network stack from overunning the |
| 148 | * NIC. The packet to keep or drop is passed for inspection to the registered |
| 149 | * handler the handler must ONLY inspect the packet, it may not free or reclaim |
| 150 | * the packet. |
| 151 | */ |
| 152 | typedef enum htc_send_full_action (*HTC_EP_SEND_QUEUE_FULL)(void *, |
| 153 | HTC_PACKET *pPacket); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 154 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 155 | struct htc_ep_callbacks { |
| 156 | /* context for each callback */ |
| 157 | void *pContext; |
| 158 | /* tx completion callback for connected endpoint */ |
| 159 | HTC_EP_SEND_PKT_COMPLETE EpTxComplete; |
| 160 | /* receive callback for connected endpoint */ |
| 161 | HTC_EP_RECV_PKT EpRecv; |
| 162 | /* OPTIONAL receive re-fill callback for connected endpoint */ |
| 163 | HTC_EP_RECV_REFILL EpRecvRefill; |
| 164 | /* OPTIONAL send full callback */ |
| 165 | HTC_EP_SEND_QUEUE_FULL EpSendFull; |
| 166 | /* OPTIONAL recv allocation callback */ |
| 167 | HTC_EP_RECV_ALLOC EpRecvAlloc; |
| 168 | /* OPTIONAL recv allocation callback based on a threshold */ |
| 169 | HTC_EP_RECV_ALLOC EpRecvAllocThresh; |
| 170 | /* OPTIONAL completion handler for multiple complete |
| 171 | * indications (EpTxComplete must be NULL) |
| 172 | */ |
| 173 | HTC_EP_SEND_PKT_COMP_MULTIPLE EpTxCompleteMultiple; |
Dustin Brown | 1e61fbc | 2018-01-08 12:30:30 -0800 | [diff] [blame] | 174 | |
Houston Hoffman | 47e387b | 2015-10-20 17:04:42 -0700 | [diff] [blame] | 175 | HTC_EP_RESUME_TX_QUEUE ep_resume_tx_queue; |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 176 | /* if EpRecvAllocThresh is non-NULL, HTC will compare the |
| 177 | * threshold value to the current recv packet length and invoke |
| 178 | * the EpRecvAllocThresh callback to acquire a packet buffer |
| 179 | */ |
| 180 | int RecvAllocThreshold; |
| 181 | /* if a EpRecvRefill handler is provided, this value |
| 182 | * can be used to set a trigger refill callback |
| 183 | * when the recv queue drops below this value |
| 184 | * if set to 0, the refill is only called when packets |
| 185 | * are empty |
| 186 | */ |
| 187 | int RecvRefillWaterMark; |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 188 | }; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 189 | |
| 190 | /* service connection information */ |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 191 | struct htc_service_connect_req { |
| 192 | /* service ID to connect to */ |
| 193 | HTC_SERVICE_ID service_id; |
| 194 | /* connection flags, see htc protocol definition */ |
| 195 | uint16_t ConnectionFlags; |
| 196 | /* ptr to optional service-specific meta-data */ |
| 197 | uint8_t *pMetaData; |
| 198 | /* optional meta data length */ |
| 199 | uint8_t MetaDataLength; |
| 200 | /* endpoint callbacks */ |
| 201 | struct htc_ep_callbacks EpCallbacks; |
| 202 | /* maximum depth of any send queue */ |
| 203 | int MaxSendQueueDepth; |
| 204 | /* HTC flags for the host-side (local) connection */ |
| 205 | uint32_t LocalConnectionFlags; |
| 206 | /* override max message size in send direction */ |
| 207 | unsigned int MaxSendMsgSize; |
| 208 | }; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 209 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 210 | /* enable send bundle padding for this endpoint */ |
| 211 | #define HTC_LOCAL_CONN_FLAGS_ENABLE_SEND_BUNDLE_PADDING (1 << 0) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 212 | |
| 213 | /* service connection response information */ |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 214 | struct htc_service_connect_resp { |
| 215 | /* caller supplied buffer to optional meta-data */ |
| 216 | uint8_t *pMetaData; |
| 217 | /* length of caller supplied buffer */ |
| 218 | uint8_t BufferLength; |
| 219 | /* actual length of meta data */ |
| 220 | uint8_t ActualLength; |
| 221 | /* endpoint to communicate over */ |
| 222 | HTC_ENDPOINT_ID Endpoint; |
| 223 | /* max length of all messages over this endpoint */ |
| 224 | unsigned int MaxMsgLength; |
| 225 | /* connect response code from target */ |
| 226 | uint8_t ConnectRespCode; |
| 227 | }; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 228 | |
| 229 | /* endpoint distribution structure */ |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 230 | struct htc_endpoint_credit_dist { |
| 231 | struct _htc_endpoint_credit_dist *pNext; |
| 232 | struct _htc_endpoint_credit_dist *pPrev; |
| 233 | /* Service ID (set by HTC) */ |
| 234 | HTC_SERVICE_ID service_id; |
| 235 | /* endpoint for this distribution struct (set by HTC) */ |
| 236 | HTC_ENDPOINT_ID Endpoint; |
| 237 | /* distribution flags, distribution function can |
| 238 | * set default activity using SET_EP_ACTIVE() macro |
| 239 | */ |
| 240 | uint32_t DistFlags; |
| 241 | /* credits for normal operation, anything above this |
| 242 | * indicates the endpoint is over-subscribed, this field |
| 243 | * is only relevant to the credit distribution function |
| 244 | */ |
| 245 | int TxCreditsNorm; |
| 246 | /* floor for credit distribution, this field is |
| 247 | * only relevant to the credit distribution function |
| 248 | */ |
| 249 | int TxCreditsMin; |
| 250 | /* number of credits assigned to this EP, this field |
| 251 | * is only relevant to the credit dist function |
| 252 | */ |
| 253 | int TxCreditsAssigned; |
| 254 | /* current credits available, this field is used by |
| 255 | * HTC to determine whether a message can be sent or |
| 256 | * must be queued |
| 257 | */ |
| 258 | int TxCredits; |
| 259 | /* pending credits to distribute on this endpoint, this |
| 260 | * is set by HTC when credit reports arrive. |
| 261 | * The credit distribution functions sets this to zero |
| 262 | * when it distributes the credits |
| 263 | */ |
| 264 | int TxCreditsToDist; |
| 265 | /* this is the number of credits that the current pending TX |
| 266 | * packet needs to transmit. This is set by HTC when |
| 267 | * and endpoint needs credits in order to transmit |
| 268 | */ |
| 269 | int TxCreditsSeek; |
| 270 | /* size in bytes of each credit (set by HTC) */ |
| 271 | int TxCreditSize; |
| 272 | /* credits required for a maximum sized messages (set by HTC) */ |
| 273 | int TxCreditsPerMaxMsg; |
| 274 | /* reserved for HTC use */ |
| 275 | void *pHTCReserved; |
| 276 | /* current depth of TX queue , i.e. messages waiting for credits |
| 277 | * This field is valid only when HTC_CREDIT_DIST_ACTIVITY_CHANGE |
| 278 | * or HTC_CREDIT_DIST_SEND_COMPLETE is indicated on an endpoint |
| 279 | * that has non-zero credits to recover |
| 280 | */ |
| 281 | int TxQueueDepth; |
| 282 | }; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 283 | |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 284 | #define HTC_EP_ACTIVE ((uint32_t) (1u << 31)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 285 | |
| 286 | /* macro to check if an endpoint has gone active, useful for credit |
| 287 | * distributions */ |
| 288 | #define IS_EP_ACTIVE(epDist) ((epDist)->DistFlags & HTC_EP_ACTIVE) |
| 289 | #define SET_EP_ACTIVE(epDist) (epDist)->DistFlags |= HTC_EP_ACTIVE |
| 290 | |
| 291 | /* credit distibution code that is passed into the distrbution function, |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 292 | * there are mandatory and optional codes that must be handled |
| 293 | */ |
| 294 | enum htc_credit_dist_reason { |
| 295 | /* credits available as a result of completed |
| 296 | * send operations (MANDATORY) resulting in credit reports |
| 297 | */ |
| 298 | HTC_CREDIT_DIST_SEND_COMPLETE = 0, |
| 299 | /* a change in endpoint activity occurred (OPTIONAL) */ |
| 300 | HTC_CREDIT_DIST_ACTIVITY_CHANGE = 1, |
| 301 | /* an endpoint needs to "seek" credits (OPTIONAL) */ |
| 302 | HTC_CREDIT_DIST_SEEK_CREDITS, |
| 303 | /* for debugging, dump any state information that is kept by |
| 304 | * the distribution function |
| 305 | */ |
| 306 | HTC_DUMP_CREDIT_STATE |
| 307 | }; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 308 | |
| 309 | typedef void (*HTC_CREDIT_DIST_CALLBACK)(void *Context, |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 310 | struct htc_endpoint_credit_dist * |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 311 | pEPList, |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 312 | enum htc_credit_dist_reason |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 313 | Reason); |
| 314 | |
| 315 | typedef void (*HTC_CREDIT_INIT_CALLBACK)(void *Context, |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 316 | struct htc_endpoint_credit_dist * |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 317 | pEPList, int TotalCredits); |
| 318 | |
| 319 | /* endpoint statistics action */ |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 320 | enum htc_endpoint_stat_action { |
| 321 | /* only read statistics */ |
| 322 | HTC_EP_STAT_SAMPLE = 0, |
| 323 | /* sample and immediately clear statistics */ |
| 324 | HTC_EP_STAT_SAMPLE_AND_CLEAR = 1, |
| 325 | /* clear only */ |
| 326 | HTC_EP_STAT_CLEAR |
| 327 | }; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 328 | |
| 329 | /* endpoint statistics */ |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 330 | struct htc_endpoint_stats { |
| 331 | /* number of TX packets posted to the endpoint */ |
| 332 | uint32_t TxPosted; |
| 333 | /* number of times the host set the credit-low flag in a send message on |
| 334 | * this endpoint |
| 335 | */ |
| 336 | uint32_t TxCreditLowIndications; |
| 337 | /* running count of total TX packets issued */ |
| 338 | uint32_t TxIssued; |
| 339 | /* running count of TX packets that were issued in bundles */ |
| 340 | uint32_t TxPacketsBundled; |
| 341 | /* running count of TX bundles that were issued */ |
| 342 | uint32_t TxBundles; |
| 343 | /* tx packets that were dropped */ |
| 344 | uint32_t TxDropped; |
| 345 | /* running count of total credit reports received for this endpoint */ |
| 346 | uint32_t TxCreditRpts; |
| 347 | /* credit reports received from this endpoint's RX packets */ |
| 348 | uint32_t TxCreditRptsFromRx; |
| 349 | /* credit reports received from RX packets of other endpoints */ |
| 350 | uint32_t TxCreditRptsFromOther; |
| 351 | /* credit reports received from endpoint 0 RX packets */ |
| 352 | uint32_t TxCreditRptsFromEp0; |
| 353 | /* count of credits received via Rx packets on this endpoint */ |
| 354 | uint32_t TxCreditsFromRx; |
| 355 | /* count of credits received via another endpoint */ |
| 356 | uint32_t TxCreditsFromOther; |
| 357 | /* count of credits received via another endpoint */ |
| 358 | uint32_t TxCreditsFromEp0; |
| 359 | /* count of consummed credits */ |
| 360 | uint32_t TxCreditsConsummed; |
| 361 | /* count of credits returned */ |
| 362 | uint32_t TxCreditsReturned; |
| 363 | /* count of RX packets received */ |
| 364 | uint32_t RxReceived; |
| 365 | /* count of lookahead records |
| 366 | * found in messages received on this endpoint |
| 367 | */ |
| 368 | uint32_t RxLookAheads; |
| 369 | /* count of recv packets received in a bundle */ |
| 370 | uint32_t RxPacketsBundled; |
| 371 | /* count of number of bundled lookaheads */ |
| 372 | uint32_t RxBundleLookAheads; |
| 373 | /* count of the number of bundle indications from the HTC header */ |
| 374 | uint32_t RxBundleIndFromHdr; |
| 375 | /* number of times the recv allocation threshold was hit */ |
| 376 | uint32_t RxAllocThreshHit; |
| 377 | /* total number of bytes */ |
| 378 | uint32_t RxAllocThreshBytes; |
| 379 | }; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 380 | |
| 381 | /* ------ Function Prototypes ------ */ |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 382 | /** |
| 383 | * htc_create - Create an instance of HTC over the underlying HIF device |
| 384 | * @HifDevice: hif device handle, |
| 385 | * @pInfo: initialization information |
| 386 | * @osdev: QDF device structure |
| 387 | * @con_mode: driver connection mode |
| 388 | * |
| 389 | * Return: HTC_HANDLE on success, NULL on failure |
| 390 | */ |
| 391 | HTC_HANDLE htc_create(void *HifDevice, struct htc_init_info *pInfo, |
| 392 | qdf_device_t osdev, uint32_t con_mode); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 393 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 394 | /** |
| 395 | * htc_get_hif_device - Get the underlying HIF device handle |
| 396 | * @HTCHandle: handle passed into the AddInstance callback |
| 397 | * |
| 398 | * Return: opaque HIF device handle usable in HIF API calls. |
| 399 | */ |
| 400 | void *htc_get_hif_device(HTC_HANDLE HTCHandle); |
| 401 | |
| 402 | /** |
| 403 | * htc_set_credit_distribution - Set credit distribution parameters |
| 404 | * @HTCHandle: HTC handle |
| 405 | * @pCreditDistCont: caller supplied context to pass into distribution functions |
| 406 | * @CreditDistFunc: Distribution function callback |
| 407 | * @CreditDistInit: Credit Distribution initialization callback |
| 408 | * @ServicePriorityOrder: Array containing list of service IDs, lowest index |
| 409 | * @is highestpriority: ListLength - number of elements in ServicePriorityOrder |
| 410 | * |
| 411 | * The user can set a custom credit distribution function to handle |
| 412 | * special requirementsfor each endpoint. A default credit distribution |
| 413 | * routine can be used by setting CreditInitFunc to NULL. The default |
| 414 | * credit distribution is only provided for simple "fair" credit distribution |
| 415 | * without regard to any prioritization. |
| 416 | * Return: None |
| 417 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 418 | void htc_set_credit_distribution(HTC_HANDLE HTCHandle, |
| 419 | void *pCreditDistContext, |
| 420 | HTC_CREDIT_DIST_CALLBACK CreditDistFunc, |
| 421 | HTC_CREDIT_INIT_CALLBACK CreditInitFunc, |
| 422 | HTC_SERVICE_ID ServicePriorityOrder[], |
| 423 | int ListLength); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 424 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 425 | /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 426 | * Wait for the target to indicate the HTC layer is ready |
| 427 | * htc_wait_target |
| 428 | * @HTCHandle - HTC handle |
| 429 | * |
| 430 | * This API blocks until the target responds with an HTC ready message. |
| 431 | * The caller should not connect services until the target has indicated it is |
| 432 | * ready. |
| 433 | * Return: None |
| 434 | */ |
Rakesh Pillai | 1314645 | 2017-06-22 12:52:31 +0530 | [diff] [blame] | 435 | QDF_STATUS htc_wait_target(HTC_HANDLE HTCHandle); |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 436 | |
| 437 | /** |
| 438 | * htc_start - Start target service communications |
| 439 | * @HTCHandle - HTC handle |
| 440 | * |
| 441 | * This API indicates to the target that the service connection phase |
| 442 | * is completeand the target can freely start all connected services. This |
| 443 | * API should only be called AFTER all service connections have been made. |
| 444 | * TCStart will issue a SETUP_COMPLETE message to the target to indicate that |
| 445 | * all service connections have been made and the target can start |
| 446 | * communicating over the endpoints. |
| 447 | * Return: None |
| 448 | */ |
Rakesh Pillai | 1314645 | 2017-06-22 12:52:31 +0530 | [diff] [blame] | 449 | QDF_STATUS htc_start(HTC_HANDLE HTCHandle); |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 450 | |
| 451 | /** |
| 452 | * htc_add_receive_pkt - Add receive packet to HTC |
| 453 | * @HTCHandle - HTC handle |
| 454 | * @pPacket - HTC receive packet to add |
| 455 | * |
| 456 | * User must supply HTC packets for capturing incoming HTC frames. |
| 457 | * The caller must initialize each HTC packet using the |
| 458 | * SET_HTC_PACKET_INFO_RX_REFILL() macro. |
| 459 | * Return: A_OK on success |
| 460 | */ |
| 461 | A_STATUS htc_add_receive_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket); |
| 462 | |
| 463 | /** |
| 464 | * htc_connect_service - Connect to an HTC service |
| 465 | * @HTCHandle - HTC handle |
| 466 | * @pReq - connection details |
| 467 | * @pResp - connection response |
| 468 | * |
| 469 | * Service connections must be performed before htc_start. |
| 470 | * User provides callback handlersfor various endpoint events. |
| 471 | * Return: None |
| 472 | */ |
Rakesh Pillai | 1314645 | 2017-06-22 12:52:31 +0530 | [diff] [blame] | 473 | QDF_STATUS htc_connect_service(HTC_HANDLE HTCHandle, |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 474 | struct htc_service_connect_req *pReq, |
| 475 | struct htc_service_connect_resp *pResp); |
| 476 | |
| 477 | /** |
| 478 | * htc_dump - HTC register log dump |
| 479 | * @HTCHandle - HTC handle |
| 480 | * @CmdId - Log command |
| 481 | * @start - start/print logs |
| 482 | * |
| 483 | * Register logs will be started/printed/ be flushed. |
| 484 | * Return: None |
| 485 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 486 | void htc_dump(HTC_HANDLE HTCHandle, uint8_t CmdId, bool start); |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 487 | |
| 488 | /** |
| 489 | * htc_send_pkt - Send an HTC packet |
| 490 | * @HTCHandle - HTC handle |
| 491 | * @pPacket - packet to send |
| 492 | * |
| 493 | * Caller must initialize packet using SET_HTC_PACKET_INFO_TX() macro. |
| 494 | * This interface is fully asynchronous. On error, HTC SendPkt will |
| 495 | * call the registered Endpoint callback to cleanup the packet. |
Rakesh Pillai | 1314645 | 2017-06-22 12:52:31 +0530 | [diff] [blame] | 496 | * Return: QDF_STATUS_SUCCESS |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 497 | */ |
Rakesh Pillai | 1314645 | 2017-06-22 12:52:31 +0530 | [diff] [blame] | 498 | QDF_STATUS htc_send_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket); |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 499 | |
| 500 | /** |
| 501 | * htc_send_data_pkt - Send an HTC packet containing a tx descriptor and data |
| 502 | * @HTCHandle - HTC handle |
| 503 | * @pPacket - packet to send |
| 504 | * |
| 505 | * Caller must initialize packet using SET_HTC_PACKET_INFO_TX() macro. |
| 506 | * Caller must provide headroom in an initial fragment added to the |
| 507 | * network buffer to store a HTC_FRAME_HDR. |
| 508 | * This interface is fully asynchronous. On error, htc_send_data_pkt will |
| 509 | * call the registered Endpoint EpDataTxComplete callback to cleanup |
| 510 | * the packet. |
| 511 | * Return: A_OK |
| 512 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 513 | #ifdef ATH_11AC_TXCOMPACT |
Rakesh Pillai | 1314645 | 2017-06-22 12:52:31 +0530 | [diff] [blame] | 514 | QDF_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, qdf_nbuf_t netbuf, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 515 | int Epid, int ActualLength); |
| 516 | #else /*ATH_11AC_TXCOMPACT */ |
Rakesh Pillai | 1314645 | 2017-06-22 12:52:31 +0530 | [diff] [blame] | 517 | QDF_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket, |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 518 | uint8_t more_data); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 519 | #endif /*ATH_11AC_TXCOMPACT */ |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 520 | |
| 521 | /** |
| 522 | * htc_flush_surprise_remove - Flush HTC when target is removed surprisely |
| 523 | * service communications |
| 524 | * @HTCHandle - HTC handle |
| 525 | * |
| 526 | * All receive and pending TX packets will be flushed. |
| 527 | * Return: None |
| 528 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 529 | void htc_flush_surprise_remove(HTC_HANDLE HTCHandle); |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 530 | |
| 531 | /** |
| 532 | * htc_stop - Stop HTC service communications |
| 533 | * @HTCHandle - HTC handle |
| 534 | * |
| 535 | * HTC communications is halted. All receive and pending TX packets |
| 536 | * will be flushed. |
| 537 | * Return: None |
| 538 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 539 | void htc_stop(HTC_HANDLE HTCHandle); |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 540 | |
| 541 | /** |
| 542 | * htc_destroy - Destroy HTC service |
| 543 | * @HTCHandle - HTC handle |
| 544 | * |
| 545 | * This cleans up all resources allocated by htc_create(). |
| 546 | * Return: None |
| 547 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 548 | void htc_destroy(HTC_HANDLE HTCHandle); |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 549 | |
| 550 | /** |
| 551 | * htc_flush_endpoint - Flush pending TX packets |
| 552 | * @HTCHandle - HTC handle |
| 553 | * @Endpoint - Endpoint to flush |
| 554 | * @Tag - flush tag |
| 555 | * |
| 556 | * The Tag parameter is used to selectively flush packets with matching |
| 557 | * tags. The value of 0 forces all packets to be flush regardless of tag |
| 558 | * Return: None |
| 559 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 560 | void htc_flush_endpoint(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint, |
| 561 | HTC_TX_TAG Tag); |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 562 | /** |
| 563 | * htc_dump_credit_states - Dump credit distribution state |
| 564 | * @HTCHandle - HTC handle |
| 565 | * |
| 566 | * This dumps all credit distribution information to the debugger |
| 567 | * Return: None |
| 568 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 569 | void htc_dump_credit_states(HTC_HANDLE HTCHandle); |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 570 | |
| 571 | /** |
| 572 | * htc_indicate_activity_change - Indicate a traffic activity change on an |
| 573 | * endpoint |
| 574 | * @HTCHandle - HTC handle |
| 575 | * @Endpoint - endpoint in which activity has changed |
| 576 | * @Active - true if active, false if it has become inactive |
| 577 | * |
| 578 | * This triggers the registered credit distribution function to |
| 579 | * re-adjust credits for active/inactive endpoints. |
| 580 | * Return: None |
| 581 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 582 | void htc_indicate_activity_change(HTC_HANDLE HTCHandle, |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 583 | HTC_ENDPOINT_ID Endpoint, bool Active); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 584 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 585 | /** |
| 586 | * htc_get_endpoint_statistics - Get endpoint statistics |
| 587 | * @HTCHandle - HTC handle |
| 588 | * @Endpoint - Endpoint identifier |
| 589 | * @Action - action to take with statistics |
| 590 | * @pStats - statistics that were sampled (can be NULL if Action is |
| 591 | * HTC_EP_STAT_CLEAR) |
| 592 | * |
| 593 | * Statistics is a compile-time option and this function may return |
| 594 | * false if HTC is not compiled with profiling. |
| 595 | * The caller can specify the statistic "action" to take when sampling |
| 596 | * the statistics. This includes : |
| 597 | * HTC_EP_STAT_SAMPLE : The pStats structure is filled with the current |
| 598 | * values. |
| 599 | * HTC_EP_STAT_SAMPLE_AND_CLEAR : The structure is filled and the current |
| 600 | * statisticsare cleared. |
| 601 | * HTC_EP_STAT_CLEA : the statistics are cleared, the called can pass |
| 602 | * a NULL value for pStats |
| 603 | * Return: true if statistics profiling is enabled, otherwise false. |
| 604 | */ |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 605 | bool htc_get_endpoint_statistics(HTC_HANDLE HTCHandle, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 606 | HTC_ENDPOINT_ID Endpoint, |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 607 | enum htc_endpoint_stat_action Action, |
| 608 | struct htc_endpoint_stats *pStats); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 609 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 610 | /** |
| 611 | * htc_unblock_recv - Unblock HTC message reception |
| 612 | * @HTCHandle - HTC handle |
| 613 | * |
| 614 | * HTC will block the receiver if the EpRecvAlloc callback fails to provide a |
| 615 | * packet. The caller can use this API to indicate to HTC when resources |
| 616 | * (buffers) are available such that the receiver can be unblocked and HTC |
| 617 | * may re-attempt fetching the pending message. |
| 618 | * This API is not required if the user uses the EpRecvRefill callback or uses |
| 619 | * the HTCAddReceivePacket()API to recycle or provide receive packets to HTC. |
| 620 | * Return: None |
| 621 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 622 | void htc_unblock_recv(HTC_HANDLE HTCHandle); |
| 623 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 624 | /** |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 625 | * htc_add_receive_pkt_multiple - Add multiple receive packets to HTC |
| 626 | * @HTCHandle - HTC handle |
| 627 | * @pPktQueue - HTC receive packet queue holding packets to add |
| 628 | * |
| 629 | * User must supply HTC packets for capturing incoming HTC frames. |
| 630 | * The caller mmust initialize each HTC packet using the |
| 631 | * SET_HTC_PACKET_INFO_RX_REFILL() macro. The queue must only contain |
| 632 | * recv packets for the same endpoint. Caller supplies a pointer to an |
| 633 | * HTC_PACKET_QUEUE structure holding the recv packet. This API will |
| 634 | * remove the packets from the pkt queue and place them into internal |
| 635 | * recv packet list. |
| 636 | * The caller may allocate the pkt queue on the stack to hold the pkts. |
| 637 | * Return: A_OK on success |
| 638 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 639 | A_STATUS htc_add_receive_pkt_multiple(HTC_HANDLE HTCHandle, |
| 640 | HTC_PACKET_QUEUE *pPktQueue); |
| 641 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 642 | /** |
| 643 | * htc_is_endpoint_active - Check if an endpoint is marked active |
| 644 | * @HTCHandle - HTC handle |
| 645 | * @Endpoint - endpoint to check for active state |
| 646 | * |
| 647 | * Return: returns true if Endpoint is Active |
| 648 | */ |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 649 | bool htc_is_endpoint_active(HTC_HANDLE HTCHandle, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 650 | HTC_ENDPOINT_ID Endpoint); |
| 651 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 652 | /** |
| 653 | * htc_set_nodrop_pkt - Set up nodrop pkt flag for mboxping nodrop pkt |
| 654 | * @HTCHandle - HTC handle |
| 655 | * @isNodropPkt - indicates whether it is nodrop pkt |
| 656 | * |
| 657 | * Return: None |
| 658 | * Return: |
| 659 | * |
| 660 | */ |
gbian | b417db2 | 2016-09-30 17:01:07 +0800 | [diff] [blame] | 661 | void htc_set_nodrop_pkt(HTC_HANDLE HTCHandle, A_BOOL isNodropPkt); |
| 662 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 663 | /** |
| 664 | * htc_get_num_recv_buffers - Get the number of recv buffers currently queued |
| 665 | * into an HTC endpoint |
| 666 | * @HTCHandle - HTC handle |
| 667 | * @Endpoint - endpoint to check |
| 668 | * |
| 669 | * Return: returns number of buffers in queue |
| 670 | * |
| 671 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 672 | int htc_get_num_recv_buffers(HTC_HANDLE HTCHandle, |
| 673 | HTC_ENDPOINT_ID Endpoint); |
| 674 | |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 675 | /** |
| 676 | * htc_set_target_failure_callback - Set the target failure handling callback |
| 677 | * in HTC layer |
| 678 | * @HTCHandle - HTC handle |
| 679 | * @Callback - target failure handling callback |
| 680 | * |
| 681 | * Return: None |
| 682 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 683 | void htc_set_target_failure_callback(HTC_HANDLE HTCHandle, |
| 684 | HTC_TARGET_FAILURE Callback); |
| 685 | |
| 686 | /* internally used functions for testing... */ |
| 687 | void htc_enable_recv(HTC_HANDLE HTCHandle); |
| 688 | void htc_disable_recv(HTC_HANDLE HTCHandle); |
| 689 | A_STATUS HTCWaitForPendingRecv(HTC_HANDLE HTCHandle, |
Yue Ma | b16cf30 | 2016-03-08 18:30:25 -0800 | [diff] [blame] | 690 | uint32_t TimeoutInMs, |
| 691 | bool *pbIsRecvPending); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 692 | |
| 693 | /* function to fetch stats from htc layer*/ |
| 694 | struct ol_ath_htc_stats *ieee80211_ioctl_get_htc_stats(HTC_HANDLE |
| 695 | HTCHandle); |
Houston Hoffman | adc3147 | 2017-03-14 16:15:29 -0700 | [diff] [blame] | 696 | /** |
| 697 | * htc_get_tx_queue_depth() - get the tx queue depth of an htc endpoint |
| 698 | * @htc_handle: htc handle |
| 699 | * @enpoint_id: endpoint to check |
| 700 | * |
| 701 | * Return: htc_handle tx queue depth |
| 702 | */ |
| 703 | int htc_get_tx_queue_depth(HTC_HANDLE *htc_handle, HTC_ENDPOINT_ID endpoint_id); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 704 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 705 | #ifdef HIF_USB |
| 706 | #define HTCReturnReceivePkt(target, p, osbuf) \ |
| 707 | do { \ |
| 708 | A_NETBUF_FREE(osbuf); \ |
| 709 | if (p->Status == A_CLONE) { \ |
| 710 | qdf_mem_free(p); \ |
| 711 | } \ |
| 712 | } while (0) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 713 | #else |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 714 | #define HTCReturnReceivePkt(target, p, osbuf) htc_add_receive_pkt(target, p) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 715 | #endif |
| 716 | |
| 717 | #ifdef WLAN_FEATURE_FASTPATH |
Houston Hoffman | 9348186 | 2016-05-05 18:49:59 -0700 | [diff] [blame] | 718 | void htc_ctrl_msg_cmpl(HTC_HANDLE htc_pdev, HTC_ENDPOINT_ID htc_ep_id); |
| 719 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 720 | #define HTC_TX_DESC_FILL(_htc_tx_desc, _download_len, _ep_id, _seq_no) \ |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 721 | do { \ |
| 722 | HTC_WRITE32((_htc_tx_desc), \ |
| 723 | SM((_download_len), HTC_FRAME_HDR_PAYLOADLEN) | \ |
| 724 | SM((_ep_id), HTC_FRAME_HDR_ENDPOINTID)); \ |
| 725 | HTC_WRITE32((uint32_t *)(_htc_tx_desc) + 1, \ |
| 726 | SM((_seq_no), HTC_FRAME_HDR_CONTROLBYTES1)); \ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 727 | } while (0) |
| 728 | #endif /* WLAN_FEATURE_FASTPATH */ |
| 729 | |
| 730 | #ifdef __cplusplus |
| 731 | } |
| 732 | #endif |
Manikandan Mohan | e3e209e | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 733 | void htc_get_control_endpoint_tx_host_credits(HTC_HANDLE HTCHandle, |
| 734 | int *credit); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 735 | void htc_dump_counter_info(HTC_HANDLE HTCHandle); |
| 736 | void *htc_get_targetdef(HTC_HANDLE htc_handle); |
Yue Ma | ec9e71c | 2016-02-26 18:52:20 -0800 | [diff] [blame] | 737 | #ifdef FEATURE_RUNTIME_PM |
| 738 | int htc_runtime_suspend(HTC_HANDLE htc_ctx); |
| 739 | int htc_runtime_resume(HTC_HANDLE htc_ctx); |
| 740 | #endif |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 741 | void htc_global_credit_flow_disable(void); |
| 742 | void htc_global_credit_flow_enable(void); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 743 | |
| 744 | /* Disable ASPM : Disable PCIe low power */ |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 745 | bool htc_can_suspend_link(HTC_HANDLE HTCHandle); |
| 746 | void htc_vote_link_down(HTC_HANDLE HTCHandle); |
| 747 | void htc_vote_link_up(HTC_HANDLE HTCHandle); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 748 | #ifdef IPA_OFFLOAD |
| 749 | void htc_ipa_get_ce_resource(HTC_HANDLE htc_handle, |
Sravan Kumar Kairam | 58e0adf | 2018-02-27 18:37:40 +0530 | [diff] [blame] | 750 | qdf_shared_mem_t **ce_sr, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 751 | uint32_t *ce_sr_ring_size, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 752 | qdf_dma_addr_t *ce_reg_paddr); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 753 | #else |
| 754 | #define htc_ipa_get_ce_resource(htc_handle, \ |
Sravan Kumar Kairam | 58e0adf | 2018-02-27 18:37:40 +0530 | [diff] [blame] | 755 | ce_sr, ce_sr_ring_size, ce_reg_paddr) /* NO-OP */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 756 | #endif /* IPA_OFFLOAD */ |
Houston Hoffman | 9348186 | 2016-05-05 18:49:59 -0700 | [diff] [blame] | 757 | |
Poddar, Siddarth | df03009 | 2016-04-28 11:41:57 +0530 | [diff] [blame] | 758 | #if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT) |
| 759 | |
| 760 | /** |
| 761 | * htc_dump_bundle_stats() - dump tx and rx htc message bundle stats |
| 762 | * @HTCHandle: htc handle |
| 763 | * |
| 764 | * Return: None |
| 765 | */ |
| 766 | void htc_dump_bundle_stats(HTC_HANDLE HTCHandle); |
| 767 | |
| 768 | /** |
| 769 | * htc_clear_bundle_stats() - clear tx and rx htc message bundle stats |
| 770 | * @HTCHandle: htc handle |
| 771 | * |
| 772 | * Return: None |
| 773 | */ |
| 774 | void htc_clear_bundle_stats(HTC_HANDLE HTCHandle); |
| 775 | #endif |
| 776 | |
Houston Hoffman | 4d9b080 | 2016-07-20 10:10:35 -0700 | [diff] [blame] | 777 | #ifdef FEATURE_RUNTIME_PM |
| 778 | int htc_pm_runtime_get(HTC_HANDLE htc_handle); |
| 779 | int htc_pm_runtime_put(HTC_HANDLE htc_handle); |
| 780 | #else |
| 781 | static inline int htc_pm_runtime_get(HTC_HANDLE htc_handle) { return 0; } |
| 782 | static inline int htc_pm_runtime_put(HTC_HANDLE htc_handle) { return 0; } |
| 783 | #endif |
Venkateswara Swamy Bandaru | ae41b9e | 2016-11-21 15:06:24 +0530 | [diff] [blame] | 784 | |
| 785 | /** |
| 786 | * htc_set_async_ep() - set async HTC end point |
| 787 | * user should call this function after htc_connect_service before |
| 788 | * queing any packets to end point |
| 789 | * @HTCHandle: htc handle |
| 790 | * @HTC_ENDPOINT_ID: end point id |
| 791 | * @value: true or false |
| 792 | * |
| 793 | * Return: None |
| 794 | */ |
| 795 | |
| 796 | void htc_set_async_ep(HTC_HANDLE HTCHandle, |
| 797 | HTC_ENDPOINT_ID htc_ep_id, bool value); |
Kiran Venkatappa | e17e3b6 | 2017-02-10 16:31:49 +0530 | [diff] [blame] | 798 | |
| 799 | /** |
| 800 | * htc_set_wmi_endpoint_count: Set number of WMI endpoint |
| 801 | * @htc_handle: HTC handle |
| 802 | * @wmi_ep_count: WMI enpoint count |
| 803 | * |
| 804 | * return: None |
| 805 | */ |
| 806 | void htc_set_wmi_endpoint_count(HTC_HANDLE htc_handle, uint8_t wmi_ep_count); |
| 807 | |
| 808 | /** |
| 809 | * htc_get_wmi_endpoint_count: Get number of WMI endpoint |
| 810 | * @htc_handle: HTC handle |
| 811 | * |
| 812 | * return: WMI enpoint count |
| 813 | */ |
| 814 | uint8_t htc_get_wmi_endpoint_count(HTC_HANDLE htc_handle); |
Dustin Brown | 536064a | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 815 | |
Rachit Kankane | 1bc1149 | 2018-01-24 18:48:17 +0530 | [diff] [blame] | 816 | /** |
| 817 | * htc_print_credit_history: print HTC credit history in buffer |
| 818 | * @htc: HTC handle |
| 819 | * @count: Number of lines to be copied |
| 820 | * @print: Print callback to print in the buffer |
| 821 | * @print_priv: any data required by the print method, e.g. a file handle |
| 822 | * |
| 823 | * return: None |
| 824 | */ |
| 825 | #ifdef FEATURE_HTC_CREDIT_HISTORY |
Dustin Brown | 536064a | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 826 | void htc_print_credit_history(HTC_HANDLE htc, uint32_t count, |
| 827 | qdf_abstract_print * print, void *print_priv); |
Rachit Kankane | 1bc1149 | 2018-01-24 18:48:17 +0530 | [diff] [blame] | 828 | #else |
| 829 | static inline |
| 830 | void htc_print_credit_history(HTC_HANDLE htc, uint32_t count, |
| 831 | qdf_abstract_print *print, void *print_priv) |
| 832 | { |
| 833 | print(print_priv, "HTC Credit History Feature is disabled"); |
| 834 | } |
Dustin Brown | 536064a | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 835 | #endif |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 836 | #endif /* _HTC_API_H_ */ |