htc_api.h 34 KB

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