htc_api.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. /*
  2. * Copyright (c) 2013-2014, 2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. #ifndef _HTC_API_H_
  27. #define _HTC_API_H_
  28. #include <htc.h>
  29. #include <htc_services.h>
  30. #include <qdf_types.h> /* qdf_device_t */
  31. #include "htc_packet.h"
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif /* __cplusplus */
  35. /* TODO.. for BMI */
  36. #define ENDPOINT1 0
  37. /* TODO -remove me, but we have to fix BMI first */
  38. #define HTC_MAILBOX_NUM_MAX 4
  39. /* this is the amount of header room required by users of HTC */
  40. #define HTC_HEADER_LEN HTC_HDR_LENGTH
  41. #define HTC_HTT_TRANSFER_HDRSIZE 24
  42. typedef void *HTC_HANDLE;
  43. typedef uint16_t HTC_SERVICE_ID;
  44. typedef void (*HTC_TARGET_FAILURE)(void *Instance, QDF_STATUS Status);
  45. typedef struct _HTC_INIT_INFO {
  46. void *pContext; /* context for target notifications */
  47. void (*TargetFailure)(void *Instance, QDF_STATUS Status);
  48. void (*TargetSendSuspendComplete)(void *ctx, bool is_nack);
  49. } HTC_INIT_INFO;
  50. /* Struct for HTC layer packet stats*/
  51. struct ol_ath_htc_stats {
  52. int htc_get_pkt_q_fail_count;
  53. int htc_pkt_q_empty_count;
  54. int htc_send_q_empty_count;
  55. };
  56. /* To resume HTT Tx queue during runtime resume */
  57. typedef void (*HTC_EP_RESUME_TX_QUEUE)(void *);
  58. /* per service connection send completion */
  59. typedef void (*HTC_EP_SEND_PKT_COMPLETE)(void *, HTC_PACKET *);
  60. /* per service connection callback when a plurality of packets have been sent
  61. * The HTC_PACKET_QUEUE is a temporary queue object (e.g. freed on return from the callback)
  62. * to hold a list of completed send packets.
  63. * If the handler cannot fully traverse the packet queue before returning, it should
  64. * transfer the items of the queue into the caller's private queue using:
  65. * HTC_PACKET_ENQUEUE() */
  66. typedef void (*HTC_EP_SEND_PKT_COMP_MULTIPLE)(void *,
  67. HTC_PACKET_QUEUE *);
  68. /* per service connection pkt received */
  69. typedef void (*HTC_EP_RECV_PKT)(void *, HTC_PACKET *);
  70. /* per service connection callback when a plurality of packets are received
  71. * The HTC_PACKET_QUEUE is a temporary queue object (e.g. freed on return from the callback)
  72. * to hold a list of recv packets.
  73. * If the handler cannot fully traverse the packet queue before returning, it should
  74. * transfer the items of the queue into the caller's private queue using:
  75. * HTC_PACKET_ENQUEUE() */
  76. typedef void (*HTC_EP_RECV_PKT_MULTIPLE)(void *, HTC_PACKET_QUEUE *);
  77. /* Optional per service connection receive buffer re-fill callback,
  78. * On some OSes (like Linux) packets are allocated from a global pool and indicated up
  79. * to the network stack. The driver never gets the packets back from the OS. For these OSes
  80. * a refill callback can be used to allocate and re-queue buffers into HTC.
  81. *
  82. * On other OSes, the network stack can call into the driver's OS-specifc "return_packet" handler and
  83. * the driver can re-queue these buffers into HTC. In this regard a refill callback is
  84. * unnecessary */
  85. typedef void (*HTC_EP_RECV_REFILL)(void *, HTC_ENDPOINT_ID Endpoint);
  86. /* Optional per service connection receive buffer allocation callback.
  87. * On some systems packet buffers are an extremely limited resource. Rather than
  88. * queue largest-possible-sized buffers to HTC, some systems would rather
  89. * allocate a specific size as the packet is received. The trade off is
  90. * slightly more processing (callback invoked for each RX packet)
  91. * for the benefit of committing fewer buffer resources into HTC.
  92. *
  93. * The callback is provided the length of the pending packet to fetch. This includes the
  94. * HTC header length plus the length of payload. The callback can return a pointer to
  95. * the allocated HTC packet for immediate use.
  96. *
  97. * Alternatively a variant of this handler can be used to allocate large receive packets as needed.
  98. * For example an application can use the refill mechanism for normal packets and the recv-alloc mechanism to
  99. * handle the case where a large packet buffer is required. This can significantly reduce the
  100. * amount of "committed" memory used to receive packets.
  101. *
  102. * */
  103. typedef HTC_PACKET *(*HTC_EP_RECV_ALLOC)(void *,
  104. HTC_ENDPOINT_ID Endpoint,
  105. int Length);
  106. typedef enum _HTC_SEND_FULL_ACTION {
  107. HTC_SEND_FULL_KEEP = 0, /* packet that overflowed should be kept in the queue */
  108. HTC_SEND_FULL_DROP = 1, /* packet that overflowed should be dropped */
  109. } HTC_SEND_FULL_ACTION;
  110. /* Optional per service connection callback when a send queue is full. This can occur if the
  111. * host continues queueing up TX packets faster than credits can arrive
  112. * To prevent the host (on some Oses like Linux) from continuously queueing packets
  113. * and consuming resources, this callback is provided so that that the host
  114. * can disable TX in the subsystem (i.e. network stack).
  115. * This callback is invoked for each packet that "overflows" the HTC queue. The callback can
  116. * determine whether the new packet that overflowed the queue can be kept (HTC_SEND_FULL_KEEP) or
  117. * dropped (HTC_SEND_FULL_DROP). If a packet is dropped, the EpTxComplete handler will be called
  118. * and the packet's status field will be set to A_NO_RESOURCE.
  119. * Other OSes require a "per-packet" indication for each completed TX packet, this
  120. * closed loop mechanism will prevent the network stack from overunning the NIC
  121. * The packet to keep or drop is passed for inspection to the registered handler the handler
  122. * must ONLY inspect the packet, it may not free or reclaim the packet. */
  123. typedef HTC_SEND_FULL_ACTION (*HTC_EP_SEND_QUEUE_FULL)(void *,
  124. HTC_PACKET *
  125. pPacket);
  126. typedef struct _HTC_EP_CALLBACKS {
  127. void *pContext; /* context for each callback */
  128. HTC_EP_SEND_PKT_COMPLETE EpTxComplete; /* tx completion callback for connected endpoint */
  129. HTC_EP_RECV_PKT EpRecv; /* receive callback for connected endpoint */
  130. HTC_EP_RECV_REFILL EpRecvRefill; /* OPTIONAL receive re-fill callback for connected endpoint */
  131. HTC_EP_SEND_QUEUE_FULL EpSendFull; /* OPTIONAL send full callback */
  132. HTC_EP_RECV_ALLOC EpRecvAlloc; /* OPTIONAL recv allocation callback */
  133. HTC_EP_RECV_ALLOC EpRecvAllocThresh; /* OPTIONAL recv allocation callback based on a threshold */
  134. HTC_EP_SEND_PKT_COMP_MULTIPLE EpTxCompleteMultiple; /* OPTIONAL completion handler for multiple complete
  135. indications (EpTxComplete must be NULL) */
  136. HTC_EP_RECV_PKT_MULTIPLE EpRecvPktMultiple; /* OPTIONAL completion handler for multiple
  137. recv packet indications (EpRecv must be NULL) */
  138. HTC_EP_RESUME_TX_QUEUE ep_resume_tx_queue;
  139. int RecvAllocThreshold; /* if EpRecvAllocThresh is non-NULL, HTC will compare the
  140. threshold value to the current recv packet length and invoke
  141. the EpRecvAllocThresh callback to acquire a packet buffer */
  142. int RecvRefillWaterMark; /* if a EpRecvRefill handler is provided, this value
  143. can be used to set a trigger refill callback
  144. when the recv queue drops below this value
  145. if set to 0, the refill is only called when packets
  146. are empty */
  147. } HTC_EP_CALLBACKS;
  148. /* service connection information */
  149. typedef struct _HTC_SERVICE_CONNECT_REQ {
  150. HTC_SERVICE_ID service_id; /* service ID to connect to */
  151. uint16_t ConnectionFlags; /* connection flags, see htc protocol definition */
  152. uint8_t *pMetaData; /* ptr to optional service-specific meta-data */
  153. uint8_t MetaDataLength; /* optional meta data length */
  154. HTC_EP_CALLBACKS EpCallbacks; /* endpoint callbacks */
  155. int MaxSendQueueDepth; /* maximum depth of any send queue */
  156. uint32_t LocalConnectionFlags; /* HTC flags for the host-side (local) connection */
  157. unsigned int MaxSendMsgSize; /* override max message size in send direction */
  158. } HTC_SERVICE_CONNECT_REQ;
  159. #define HTC_LOCAL_CONN_FLAGS_ENABLE_SEND_BUNDLE_PADDING (1 << 0) /* enable send bundle padding for this endpoint */
  160. /* service connection response information */
  161. typedef struct _HTC_SERVICE_CONNECT_RESP {
  162. uint8_t *pMetaData; /* caller supplied buffer to optional meta-data */
  163. uint8_t BufferLength; /* length of caller supplied buffer */
  164. uint8_t ActualLength; /* actual length of meta data */
  165. HTC_ENDPOINT_ID Endpoint; /* endpoint to communicate over */
  166. unsigned int MaxMsgLength; /* max length of all messages over this endpoint */
  167. uint8_t ConnectRespCode; /* connect response code from target */
  168. } HTC_SERVICE_CONNECT_RESP;
  169. /* endpoint distribution structure */
  170. typedef struct _HTC_ENDPOINT_CREDIT_DIST {
  171. struct _HTC_ENDPOINT_CREDIT_DIST *pNext;
  172. struct _HTC_ENDPOINT_CREDIT_DIST *pPrev;
  173. HTC_SERVICE_ID service_id; /* Service ID (set by HTC) */
  174. HTC_ENDPOINT_ID Endpoint; /* endpoint for this distribution struct (set by HTC) */
  175. uint32_t DistFlags; /* distribution flags, distribution function can
  176. set default activity using SET_EP_ACTIVE() macro */
  177. int TxCreditsNorm; /* credits for normal operation, anything above this
  178. indicates the endpoint is over-subscribed, this field
  179. is only relevant to the credit distribution function */
  180. int TxCreditsMin; /* floor for credit distribution, this field is
  181. only relevant to the credit distribution function */
  182. int TxCreditsAssigned; /* number of credits assigned to this EP, this field
  183. is only relevant to the credit dist function */
  184. int TxCredits; /* current credits available, this field is used by
  185. HTC to determine whether a message can be sent or
  186. must be queued */
  187. int TxCreditsToDist; /* pending credits to distribute on this endpoint, this
  188. is set by HTC when credit reports arrive.
  189. The credit distribution functions sets this to zero
  190. when it distributes the credits */
  191. int TxCreditsSeek; /* this is the number of credits that the current pending TX
  192. packet needs to transmit. This is set by HTC when
  193. and endpoint needs credits in order to transmit */
  194. int TxCreditSize; /* size in bytes of each credit (set by HTC) */
  195. int TxCreditsPerMaxMsg; /* credits required for a maximum sized messages (set by HTC) */
  196. void *pHTCReserved; /* reserved for HTC use */
  197. int TxQueueDepth; /* current depth of TX queue , i.e. messages waiting for credits
  198. This field is valid only when HTC_CREDIT_DIST_ACTIVITY_CHANGE
  199. or HTC_CREDIT_DIST_SEND_COMPLETE is indicated on an endpoint
  200. that has non-zero credits to recover
  201. */
  202. } HTC_ENDPOINT_CREDIT_DIST;
  203. #define HTC_EP_ACTIVE ((uint32_t) (1u << 31))
  204. /* macro to check if an endpoint has gone active, useful for credit
  205. * distributions */
  206. #define IS_EP_ACTIVE(epDist) ((epDist)->DistFlags & HTC_EP_ACTIVE)
  207. #define SET_EP_ACTIVE(epDist) (epDist)->DistFlags |= HTC_EP_ACTIVE
  208. /* credit distibution code that is passed into the distrbution function,
  209. * there are mandatory and optional codes that must be handled */
  210. typedef enum _HTC_CREDIT_DIST_REASON {
  211. HTC_CREDIT_DIST_SEND_COMPLETE = 0, /* credits available as a result of completed
  212. send operations (MANDATORY) resulting in credit reports */
  213. HTC_CREDIT_DIST_ACTIVITY_CHANGE = 1, /* a change in endpoint activity occured (OPTIONAL) */
  214. HTC_CREDIT_DIST_SEEK_CREDITS, /* an endpoint needs to "seek" credits (OPTIONAL) */
  215. HTC_DUMP_CREDIT_STATE /* for debugging, dump any state information that is kept by
  216. the distribution function */
  217. } HTC_CREDIT_DIST_REASON;
  218. typedef void (*HTC_CREDIT_DIST_CALLBACK)(void *Context,
  219. HTC_ENDPOINT_CREDIT_DIST *
  220. pEPList,
  221. HTC_CREDIT_DIST_REASON
  222. Reason);
  223. typedef void (*HTC_CREDIT_INIT_CALLBACK)(void *Context,
  224. HTC_ENDPOINT_CREDIT_DIST *
  225. pEPList, int TotalCredits);
  226. /* endpoint statistics action */
  227. typedef enum _HTC_ENDPOINT_STAT_ACTION {
  228. HTC_EP_STAT_SAMPLE = 0, /* only read statistics */
  229. HTC_EP_STAT_SAMPLE_AND_CLEAR = 1, /* sample and immediately clear statistics */
  230. HTC_EP_STAT_CLEAR /* clear only */
  231. } HTC_ENDPOINT_STAT_ACTION;
  232. /* endpoint statistics */
  233. typedef struct _HTC_ENDPOINT_STATS {
  234. uint32_t TxPosted; /* number of TX packets posted to the endpoint */
  235. uint32_t TxCreditLowIndications; /* number of times the host set the credit-low flag in a send message on
  236. this endpoint */
  237. uint32_t TxIssued; /* running count of total TX packets issued */
  238. uint32_t TxPacketsBundled; /* running count of TX packets that were issued in bundles */
  239. uint32_t TxBundles; /* running count of TX bundles that were issued */
  240. uint32_t TxDropped; /* tx packets that were dropped */
  241. uint32_t TxCreditRpts; /* running count of total credit reports received for this endpoint */
  242. uint32_t TxCreditRptsFromRx; /* credit reports received from this endpoint's RX packets */
  243. uint32_t TxCreditRptsFromOther; /* credit reports received from RX packets of other endpoints */
  244. uint32_t TxCreditRptsFromEp0; /* credit reports received from endpoint 0 RX packets */
  245. uint32_t TxCreditsFromRx; /* count of credits received via Rx packets on this endpoint */
  246. uint32_t TxCreditsFromOther; /* count of credits received via another endpoint */
  247. uint32_t TxCreditsFromEp0; /* count of credits received via another endpoint */
  248. uint32_t TxCreditsConsummed; /* count of consummed credits */
  249. uint32_t TxCreditsReturned; /* count of credits returned */
  250. uint32_t RxReceived; /* count of RX packets received */
  251. uint32_t RxLookAheads; /* count of lookahead records
  252. found in messages received on this endpoint */
  253. uint32_t RxPacketsBundled; /* count of recv packets received in a bundle */
  254. uint32_t RxBundleLookAheads; /* count of number of bundled lookaheads */
  255. uint32_t RxBundleIndFromHdr; /* count of the number of bundle indications from the HTC header */
  256. uint32_t RxAllocThreshHit; /* count of the number of times the recv allocation threshhold was hit */
  257. uint32_t RxAllocThreshBytes; /* total number of bytes */
  258. } HTC_ENDPOINT_STATS;
  259. /* ------ Function Prototypes ------ */
  260. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  261. @desc: Create an instance of HTC over the underlying HIF device
  262. @function name: htc_create
  263. @input: HifDevice - hif device handle,
  264. pInfo - initialization information
  265. osdev - QDF device structure
  266. con_mode - driver connection mode
  267. @output:
  268. @return: HTC_HANDLE on success, NULL on failure
  269. @notes:
  270. @example:
  271. @see also: htc_destroy
  272. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  273. HTC_HANDLE htc_create(void *HifDevice, HTC_INIT_INFO *pInfo, qdf_device_t osdev,
  274. uint32_t con_mode);
  275. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  276. @desc: Get the underlying HIF device handle
  277. @function name: htc_get_hif_device
  278. @input: HTCHandle - handle passed into the AddInstance callback
  279. @output:
  280. @return: opaque HIF device handle usable in HIF API calls.
  281. @notes:
  282. @example:
  283. @see also:
  284. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  285. void *htc_get_hif_device(HTC_HANDLE HTCHandle);
  286. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  287. @desc: Set credit distribution parameters
  288. @function name: htc_set_credit_distribution
  289. @input: HTCHandle - HTC handle
  290. pCreditDistCont - caller supplied context to pass into distribution functions
  291. CreditDistFunc - Distribution function callback
  292. CreditDistInit - Credit Distribution initialization callback
  293. ServicePriorityOrder - Array containing list of service IDs, lowest index
  294. is highestpriority
  295. ListLength - number of elements in ServicePriorityOrder
  296. @output:
  297. @return:
  298. @notes : The user can set a custom credit distribution function to handle
  299. special requirementsfor each endpoint. A default credit distribution
  300. routine can be used by setting CreditInitFunc to NULL. The default
  301. credit distribution is only provided for simple "fair" credit distribution
  302. without regard to any prioritization.
  303. @example:
  304. @see also:
  305. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  306. void htc_set_credit_distribution(HTC_HANDLE HTCHandle,
  307. void *pCreditDistContext,
  308. HTC_CREDIT_DIST_CALLBACK CreditDistFunc,
  309. HTC_CREDIT_INIT_CALLBACK CreditInitFunc,
  310. HTC_SERVICE_ID ServicePriorityOrder[],
  311. int ListLength);
  312. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  313. @desc: Wait for the target to indicate the HTC layer is ready
  314. @function name: htc_wait_target
  315. @input: HTCHandle - HTC handle
  316. @output:
  317. @return:
  318. @notes: This API blocks until the target responds with an HTC ready message.
  319. The caller should not connect services until the target has indicated it is
  320. ready.
  321. @example:
  322. @see also: htc_connect_service
  323. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  324. A_STATUS htc_wait_target(HTC_HANDLE HTCHandle);
  325. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  326. @desc: Start target service communications
  327. @function name: htc_start
  328. @input: HTCHandle - HTC handle
  329. @output:
  330. @return:
  331. @notes: This API indicates to the target that the service connection phase
  332. is completeand the target can freely start all connected services. This
  333. API should only be called AFTER all service connections have been made.
  334. TCStart will issue a SETUP_COMPLETE message to the target to indicate that
  335. all service connections have been made and the target can start
  336. communicating over the endpoints.
  337. @example:
  338. @see also: htc_connect_service
  339. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  340. A_STATUS htc_start(HTC_HANDLE HTCHandle);
  341. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  342. @desc: Add receive packet to HTC
  343. @function name: htc_add_receive_pkt
  344. @input: HTCHandle - HTC handle
  345. pPacket - HTC receive packet to add
  346. @output:
  347. @return: A_OK on success
  348. @notes: user must supply HTC packets for capturing incomming HTC frames.
  349. The caller must initialize each HTC packet using the
  350. SET_HTC_PACKET_INFO_RX_REFILL() macro.
  351. @example:
  352. @see also:
  353. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  354. A_STATUS htc_add_receive_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket);
  355. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  356. @desc: Connect to an HTC service
  357. @function name: htc_connect_service
  358. @input: HTCHandle - HTC handle
  359. pReq - connection details
  360. @output: pResp - connection response
  361. @return:
  362. @notes: Service connections must be performed before htc_start.
  363. User provides callback handlersfor various endpoint events.
  364. @example:
  365. @see also: htc_start
  366. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  367. A_STATUS htc_connect_service(HTC_HANDLE HTCHandle,
  368. HTC_SERVICE_CONNECT_REQ *pReq,
  369. HTC_SERVICE_CONNECT_RESP *pResp);
  370. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  371. @desc: HTC register log dump
  372. @function name: htc_dump
  373. @input: HTCHandle - HTC handle
  374. CmdId - Log command
  375. start - start/print logs
  376. @output:
  377. @return:
  378. @notes: Register logs will be started/printed.
  379. be flushed.
  380. @example:
  381. @see also:
  382. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  383. void htc_dump(HTC_HANDLE HTCHandle, uint8_t CmdId, bool start);
  384. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  385. @desc: Send an HTC packet
  386. @function name: htc_send_pkt
  387. @input: HTCHandle - HTC handle
  388. pPacket - packet to send
  389. @output:
  390. @return: A_OK
  391. @notes: Caller must initialize packet using SET_HTC_PACKET_INFO_TX() macro.
  392. This interface is fully asynchronous. On error, HTC SendPkt will
  393. call the registered Endpoint callback to cleanup the packet.
  394. @example:
  395. @see also: htc_flush_endpoint
  396. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  397. A_STATUS htc_send_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket);
  398. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  399. @desc: Send an HTC packet containing a tx descriptor and data
  400. @function name: htc_send_data_pkt
  401. @input: HTCHandle - HTC handle
  402. pPacket - packet to send
  403. @output:
  404. @return: A_OK
  405. @notes: Caller must initialize packet using SET_HTC_PACKET_INFO_TX() macro.
  406. Caller must provide headroom in an initial fragment added to the
  407. network buffer to store a HTC_FRAME_HDR.
  408. This interface is fully asynchronous. On error, htc_send_data_pkt will
  409. call the registered Endpoint EpDataTxComplete callback to cleanup
  410. the packet.
  411. @example:
  412. @see also: htc_send_pkt
  413. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  414. #ifdef ATH_11AC_TXCOMPACT
  415. A_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, qdf_nbuf_t netbuf,
  416. int Epid, int ActualLength);
  417. #else /*ATH_11AC_TXCOMPACT */
  418. A_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket,
  419. uint8_t more_data);
  420. #endif /*ATH_11AC_TXCOMPACT */
  421. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  422. @desc: Flush HTC when target is removed surprisely service communications
  423. @function name: htc_flush_surprise_remove
  424. @input: HTCHandle - HTC handle
  425. @output:
  426. @return:
  427. @notes: All receive and pending TX packets will
  428. be flushed.
  429. @example:
  430. @see also:
  431. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  432. void htc_flush_surprise_remove(HTC_HANDLE HTCHandle);
  433. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  434. @desc: Stop HTC service communications
  435. @function name: htc_stop
  436. @input: HTCHandle - HTC handle
  437. @output:
  438. @return:
  439. @notes: HTC communications is halted. All receive and pending TX packets will
  440. be flushed.
  441. @example:
  442. @see also:
  443. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  444. void htc_stop(HTC_HANDLE HTCHandle);
  445. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  446. @desc: Destory HTC service
  447. @function name: htc_destroy
  448. @input: HTCHandle
  449. @output:
  450. @return:
  451. @notes: This cleans up all resources allocated by htc_create().
  452. @example:
  453. @see also: htc_create
  454. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  455. void htc_destroy(HTC_HANDLE HTCHandle);
  456. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  457. @desc: Flush pending TX packets
  458. @function name: htc_flush_endpoint
  459. @input: HTCHandle - HTC handle
  460. Endpoint - Endpoint to flush
  461. Tag - flush tag
  462. @output:
  463. @return:
  464. @notes: The Tag parameter is used to selectively flush packets with matching tags.
  465. The value of 0 forces all packets to be flush regardless of tag.
  466. @example:
  467. @see also: htc_send_pkt
  468. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  469. void htc_flush_endpoint(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint,
  470. HTC_TX_TAG Tag);
  471. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  472. @desc: Dump credit distribution state
  473. @function name: htc_dump_credit_states
  474. @input: HTCHandle - HTC handle
  475. @output:
  476. @return:
  477. @notes: This dumps all credit distribution information to the debugger
  478. @example:
  479. @see also:
  480. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  481. void htc_dump_credit_states(HTC_HANDLE HTCHandle);
  482. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  483. @desc: Indicate a traffic activity change on an endpoint
  484. @function name: htc_indicate_activity_change
  485. @input: HTCHandle - HTC handle
  486. Endpoint - endpoint in which activity has changed
  487. Active - true if active, false if it has become inactive
  488. @output:
  489. @return:
  490. @notes: This triggers the registered credit distribution function to
  491. re-adjust credits for active/inactive endpoints.
  492. @example:
  493. @see also:
  494. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  495. void htc_indicate_activity_change(HTC_HANDLE HTCHandle,
  496. HTC_ENDPOINT_ID Endpoint, bool Active);
  497. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  498. @desc: Get endpoint statistics
  499. @function name: htc_get_endpoint_statistics
  500. @input: HTCHandle - HTC handle
  501. Endpoint - Endpoint identifier
  502. Action - action to take with statistics
  503. @output:
  504. pStats - statistics that were sampled (can be NULL if Action is HTC_EP_STAT_CLEAR)
  505. @return: true if statistics profiling is enabled, otherwise false.
  506. @notes : Statistics is a compile-time option and this function may return
  507. false if HTC is not compiled with profiling.
  508. The caller can specify the statistic "action" to take when sampling
  509. the statistics. This includes :
  510. HTC_EP_STAT_SAMPLE : The pStats structure is filled with the current
  511. values.
  512. HTC_EP_STAT_SAMPLE_AND_CLEAR : The structure is filled and the current
  513. statisticsare cleared.
  514. HTC_EP_STAT_CLEA : the statistics are cleared, the called can pass a NULL
  515. value forpStats
  516. @example:
  517. @see also:
  518. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  519. bool htc_get_endpoint_statistics(HTC_HANDLE HTCHandle,
  520. HTC_ENDPOINT_ID Endpoint,
  521. HTC_ENDPOINT_STAT_ACTION Action,
  522. HTC_ENDPOINT_STATS *pStats);
  523. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  524. @desc: Unblock HTC message reception
  525. @function name: htc_unblock_recv
  526. @input: HTCHandle - HTC handle
  527. @output:
  528. @return:
  529. @notes:
  530. HTC will block the receiver if the EpRecvAlloc callback fails to provide a
  531. packet. The caller can use this API to indicate to HTC when resources
  532. (buffers) are available such that the receiver can be unblocked and HTC
  533. may re-attempt fetching the pending message.
  534. This API is not required if the user uses the EpRecvRefill callback or uses
  535. the HTCAddReceivePacket()API to recycle or provide receive packets to HTC.
  536. @example:
  537. @see also:
  538. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  539. void htc_unblock_recv(HTC_HANDLE HTCHandle);
  540. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  541. @desc: send a series of HTC packets
  542. @function name: htc_send_pkts_multiple
  543. @input: HTCHandle - HTC handle
  544. pPktQueue - local queue holding packets to send
  545. @output:
  546. @return: A_OK
  547. @notes: Caller must initialize each packet using SET_HTC_PACKET_INFO_TX() macro.
  548. The queue must only contain packets directed at the same endpoint.
  549. Caller supplies a pointer to an HTC_PACKET_QUEUE structure holding the TX packets in FIFO order.
  550. This API will remove the packets from the pkt queue and place them into the HTC Tx Queue
  551. and bundle messages where possible.
  552. The caller may allocate the pkt queue on the stack to hold the packets.
  553. This interface is fully asynchronous. On error, htc_send_pkts will
  554. call the registered Endpoint callback to cleanup the packet.
  555. @example:
  556. @see also: htc_flush_endpoint
  557. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  558. A_STATUS htc_send_pkts_multiple(HTC_HANDLE HTCHandle,
  559. HTC_PACKET_QUEUE *pPktQueue);
  560. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  561. @desc: Add multiple receive packets to HTC
  562. @function name: htc_add_receive_pkt_multiple
  563. @input: HTCHandle - HTC handle
  564. pPktQueue - HTC receive packet queue holding packets to add
  565. @output:
  566. @return: A_OK on success
  567. @notes: user must supply HTC packets for capturing incomming HTC frames. The caller
  568. must initialize each HTC packet using the SET_HTC_PACKET_INFO_RX_REFILL()
  569. macro. The queue must only contain recv packets for the same endpoint.
  570. Caller supplies a pointer to an HTC_PACKET_QUEUE structure holding the recv packet.
  571. This API will remove the packets from the pkt queue and place them into internal
  572. recv packet list.
  573. The caller may allocate the pkt queue on the stack to hold the packets.
  574. @example:
  575. @see also:
  576. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  577. A_STATUS htc_add_receive_pkt_multiple(HTC_HANDLE HTCHandle,
  578. HTC_PACKET_QUEUE *pPktQueue);
  579. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  580. @desc: Check if an endpoint is marked active
  581. @function name: htc_is_endpoint_active
  582. @input: HTCHandle - HTC handle
  583. Endpoint - endpoint to check for active state
  584. @output:
  585. @return: returns true if Endpoint is Active
  586. @notes:
  587. @example:
  588. @see also:
  589. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  590. bool htc_is_endpoint_active(HTC_HANDLE HTCHandle,
  591. HTC_ENDPOINT_ID Endpoint);
  592. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  593. @desc: Get the number of recv buffers currently queued into an HTC endpoint
  594. @function name: htc_get_num_recv_buffers
  595. @input: HTCHandle - HTC handle
  596. Endpoint - endpoint to check
  597. @output:
  598. @return: returns number of buffers in queue
  599. @notes:
  600. @example:
  601. @see also:
  602. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  603. int htc_get_num_recv_buffers(HTC_HANDLE HTCHandle,
  604. HTC_ENDPOINT_ID Endpoint);
  605. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  606. @desc: Set the target failure handling callback in HTC layer
  607. @function name: htc_set_target_failure_callback
  608. @input: HTCHandle - HTC handle
  609. Callback - target failure handling callback
  610. @output:
  611. @return:
  612. @notes:
  613. @example:
  614. @see also:
  615. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  616. void htc_set_target_failure_callback(HTC_HANDLE HTCHandle,
  617. HTC_TARGET_FAILURE Callback);
  618. /* internally used functions for testing... */
  619. void htc_enable_recv(HTC_HANDLE HTCHandle);
  620. void htc_disable_recv(HTC_HANDLE HTCHandle);
  621. A_STATUS HTCWaitForPendingRecv(HTC_HANDLE HTCHandle,
  622. uint32_t TimeoutInMs,
  623. bool *pbIsRecvPending);
  624. /* function to fetch stats from htc layer*/
  625. struct ol_ath_htc_stats *ieee80211_ioctl_get_htc_stats(HTC_HANDLE
  626. HTCHandle);
  627. #ifdef HIF_USB
  628. #define HTCReturnReceivePkt(target, p, osbuf) \
  629. do { \
  630. A_NETBUF_FREE(osbuf); \
  631. if (p->Status == A_CLONE) { \
  632. qdf_mem_free(p); \
  633. } \
  634. } while (0)
  635. #else
  636. #define HTCReturnReceivePkt(target, p, osbuf) htc_add_receive_pkt(target, p)
  637. #endif
  638. #ifdef WLAN_FEATURE_FASTPATH
  639. void htc_ctrl_msg_cmpl(HTC_HANDLE htc_pdev, HTC_ENDPOINT_ID htc_ep_id);
  640. #define HTC_TX_DESC_FILL(_htc_tx_desc, _download_len, _ep_id, _seq_no) \
  641. do { \
  642. HTC_WRITE32((_htc_tx_desc), \
  643. SM((_download_len), HTC_FRAME_HDR_PAYLOADLEN) | \
  644. SM((_ep_id), HTC_FRAME_HDR_ENDPOINTID)); \
  645. \
  646. HTC_WRITE32((uint32_t *)(_htc_tx_desc) + 1, \
  647. SM((_seq_no), HTC_FRAME_HDR_CONTROLBYTES1));\
  648. } while (0)
  649. #endif /* WLAN_FEATURE_FASTPATH */
  650. #ifdef __cplusplus
  651. }
  652. #endif
  653. void htc_get_control_endpoint_tx_host_credits(HTC_HANDLE HTCHandle, int *credit);
  654. void htc_dump_counter_info(HTC_HANDLE HTCHandle);
  655. void *htc_get_targetdef(HTC_HANDLE htc_handle);
  656. #ifdef FEATURE_RUNTIME_PM
  657. int htc_runtime_suspend(HTC_HANDLE htc_ctx);
  658. int htc_runtime_resume(HTC_HANDLE htc_ctx);
  659. #endif
  660. void htc_global_credit_flow_disable(void);
  661. void htc_global_credit_flow_enable(void);
  662. /* Disable ASPM : Disable PCIe low power */
  663. bool htc_can_suspend_link(HTC_HANDLE HTCHandle);
  664. void htc_vote_link_down(HTC_HANDLE HTCHandle);
  665. void htc_vote_link_up(HTC_HANDLE HTCHandle);
  666. #ifdef IPA_OFFLOAD
  667. void htc_ipa_get_ce_resource(HTC_HANDLE htc_handle,
  668. qdf_dma_addr_t *ce_sr_base_paddr,
  669. uint32_t *ce_sr_ring_size,
  670. qdf_dma_addr_t *ce_reg_paddr);
  671. #else
  672. #define htc_ipa_get_ce_resource(htc_handle, \
  673. ce_sr_base_paddr, \
  674. ce_sr_ring_size, \
  675. ce_reg_paddr) /* NO-OP */
  676. #endif /* IPA_OFFLOAD */
  677. #if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT)
  678. /**
  679. * htc_dump_bundle_stats() - dump tx and rx htc message bundle stats
  680. * @HTCHandle: htc handle
  681. *
  682. * Return: None
  683. */
  684. void htc_dump_bundle_stats(HTC_HANDLE HTCHandle);
  685. /**
  686. * htc_clear_bundle_stats() - clear tx and rx htc message bundle stats
  687. * @HTCHandle: htc handle
  688. *
  689. * Return: None
  690. */
  691. void htc_clear_bundle_stats(HTC_HANDLE HTCHandle);
  692. #endif
  693. #endif /* _HTC_API_H_ */