htc_api.h 34 KB

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