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