1 /* 2 * Copyright (c) 2013-2014, 2016-2019 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_send_pkt - Send an HTC packet 486 * @HTCHandle - HTC handle 487 * @pPacket - packet to send 488 * 489 * Caller must initialize packet using SET_HTC_PACKET_INFO_TX() macro. 490 * This interface is fully asynchronous. On error, HTC SendPkt will 491 * call the registered Endpoint callback to cleanup the packet. 492 * Return: QDF_STATUS_SUCCESS 493 */ 494 QDF_STATUS htc_send_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket); 495 496 /** 497 * htc_send_data_pkt - Send an HTC packet containing a tx descriptor and data 498 * @HTCHandle - HTC handle 499 * @pPacket - packet to send 500 * 501 * Caller must initialize packet using SET_HTC_PACKET_INFO_TX() macro. 502 * Caller must provide headroom in an initial fragment added to the 503 * network buffer to store a HTC_FRAME_HDR. 504 * This interface is fully asynchronous. On error, htc_send_data_pkt will 505 * call the registered Endpoint EpDataTxComplete callback to cleanup 506 * the packet. 507 * Return: A_OK 508 */ 509 #ifdef ATH_11AC_TXCOMPACT 510 QDF_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, qdf_nbuf_t netbuf, 511 int Epid, int ActualLength); 512 #else /*ATH_11AC_TXCOMPACT */ 513 QDF_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket, 514 uint8_t more_data); 515 #endif /*ATH_11AC_TXCOMPACT */ 516 517 /** 518 * htc_flush_surprise_remove - Flush HTC when target is removed surprisely 519 * service communications 520 * @HTCHandle - HTC handle 521 * 522 * All receive and pending TX packets will be flushed. 523 * Return: None 524 */ 525 void htc_flush_surprise_remove(HTC_HANDLE HTCHandle); 526 527 /** 528 * htc_stop - Stop HTC service communications 529 * @HTCHandle - HTC handle 530 * 531 * HTC communications is halted. All receive and pending TX packets 532 * will be flushed. 533 * Return: None 534 */ 535 void htc_stop(HTC_HANDLE HTCHandle); 536 537 /** 538 * htc_destroy - Destroy HTC service 539 * @HTCHandle - HTC handle 540 * 541 * This cleans up all resources allocated by htc_create(). 542 * Return: None 543 */ 544 void htc_destroy(HTC_HANDLE HTCHandle); 545 546 /** 547 * htc_flush_endpoint - Flush pending TX packets 548 * @HTCHandle - HTC handle 549 * @Endpoint - Endpoint to flush 550 * @Tag - flush tag 551 * 552 * The Tag parameter is used to selectively flush packets with matching 553 * tags. The value of 0 forces all packets to be flush regardless of tag 554 * Return: None 555 */ 556 void htc_flush_endpoint(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint, 557 HTC_TX_TAG Tag); 558 /** 559 * htc_dump_credit_states - Dump credit distribution state 560 * @HTCHandle - HTC handle 561 * 562 * This dumps all credit distribution information to the debugger 563 * Return: None 564 */ 565 void htc_dump_credit_states(HTC_HANDLE HTCHandle); 566 567 /** 568 * htc_indicate_activity_change - Indicate a traffic activity change on an 569 * endpoint 570 * @HTCHandle - HTC handle 571 * @Endpoint - endpoint in which activity has changed 572 * @Active - true if active, false if it has become inactive 573 * 574 * This triggers the registered credit distribution function to 575 * re-adjust credits for active/inactive endpoints. 576 * Return: None 577 */ 578 void htc_indicate_activity_change(HTC_HANDLE HTCHandle, 579 HTC_ENDPOINT_ID Endpoint, bool Active); 580 581 /** 582 * htc_get_endpoint_statistics - Get endpoint statistics 583 * @HTCHandle - HTC handle 584 * @Endpoint - Endpoint identifier 585 * @Action - action to take with statistics 586 * @pStats - statistics that were sampled (can be NULL if Action is 587 * HTC_EP_STAT_CLEAR) 588 * 589 * Statistics is a compile-time option and this function may return 590 * false if HTC is not compiled with profiling. 591 * The caller can specify the statistic "action" to take when sampling 592 * the statistics. This includes : 593 * HTC_EP_STAT_SAMPLE : The pStats structure is filled with the current 594 * values. 595 * HTC_EP_STAT_SAMPLE_AND_CLEAR : The structure is filled and the current 596 * statisticsare cleared. 597 * HTC_EP_STAT_CLEA : the statistics are cleared, the called can pass 598 * a NULL value for pStats 599 * Return: true if statistics profiling is enabled, otherwise false. 600 */ 601 bool htc_get_endpoint_statistics(HTC_HANDLE HTCHandle, 602 HTC_ENDPOINT_ID Endpoint, 603 enum htc_endpoint_stat_action Action, 604 struct htc_endpoint_stats *pStats); 605 606 /** 607 * htc_unblock_recv - Unblock HTC message reception 608 * @HTCHandle - HTC handle 609 * 610 * HTC will block the receiver if the EpRecvAlloc callback fails to provide a 611 * packet. The caller can use this API to indicate to HTC when resources 612 * (buffers) are available such that the receiver can be unblocked and HTC 613 * may re-attempt fetching the pending message. 614 * This API is not required if the user uses the EpRecvRefill callback or uses 615 * the HTCAddReceivePacket()API to recycle or provide receive packets to HTC. 616 * Return: None 617 */ 618 void htc_unblock_recv(HTC_HANDLE HTCHandle); 619 620 /** 621 * htc_add_receive_pkt_multiple - Add multiple receive packets to HTC 622 * @HTCHandle - HTC handle 623 * @pPktQueue - HTC receive packet queue holding packets to add 624 * 625 * User must supply HTC packets for capturing incoming HTC frames. 626 * The caller mmust initialize each HTC packet using the 627 * SET_HTC_PACKET_INFO_RX_REFILL() macro. The queue must only contain 628 * recv packets for the same endpoint. Caller supplies a pointer to an 629 * HTC_PACKET_QUEUE structure holding the recv packet. This API will 630 * remove the packets from the pkt queue and place them into internal 631 * recv packet list. 632 * The caller may allocate the pkt queue on the stack to hold the pkts. 633 * Return: A_OK on success 634 */ 635 A_STATUS htc_add_receive_pkt_multiple(HTC_HANDLE HTCHandle, 636 HTC_PACKET_QUEUE *pPktQueue); 637 638 /** 639 * htc_is_endpoint_active - Check if an endpoint is marked active 640 * @HTCHandle - HTC handle 641 * @Endpoint - endpoint to check for active state 642 * 643 * Return: returns true if Endpoint is Active 644 */ 645 bool htc_is_endpoint_active(HTC_HANDLE HTCHandle, 646 HTC_ENDPOINT_ID Endpoint); 647 648 /** 649 * htc_set_nodrop_pkt - Set up nodrop pkt flag for mboxping nodrop pkt 650 * @HTCHandle - HTC handle 651 * @isNodropPkt - indicates whether it is nodrop pkt 652 * 653 * Return: None 654 * 655 */ 656 void htc_set_nodrop_pkt(HTC_HANDLE HTCHandle, A_BOOL isNodropPkt); 657 658 /** 659 * htc_enable_hdr_length_check - Set up htc_hdr_length_check flag 660 * @HTCHandle - HTC handle 661 * @htc_hdr_length_check - flag to indicate whether htc header length check is 662 * required 663 * 664 * Return: None 665 * 666 */ 667 void 668 htc_enable_hdr_length_check(HTC_HANDLE htc_handle, bool htc_hdr_length_check); 669 670 /** 671 * htc_get_num_recv_buffers - Get the number of recv buffers currently queued 672 * into an HTC endpoint 673 * @HTCHandle - HTC handle 674 * @Endpoint - endpoint to check 675 * 676 * Return: returns number of buffers in queue 677 * 678 */ 679 int htc_get_num_recv_buffers(HTC_HANDLE HTCHandle, 680 HTC_ENDPOINT_ID Endpoint); 681 682 /** 683 * htc_set_target_failure_callback - Set the target failure handling callback 684 * in HTC layer 685 * @HTCHandle - HTC handle 686 * @Callback - target failure handling callback 687 * 688 * Return: None 689 */ 690 void htc_set_target_failure_callback(HTC_HANDLE HTCHandle, 691 HTC_TARGET_FAILURE Callback); 692 693 /* internally used functions for testing... */ 694 void htc_enable_recv(HTC_HANDLE HTCHandle); 695 void htc_disable_recv(HTC_HANDLE HTCHandle); 696 A_STATUS HTCWaitForPendingRecv(HTC_HANDLE HTCHandle, 697 uint32_t TimeoutInMs, 698 bool *pbIsRecvPending); 699 700 /* function to fetch stats from htc layer*/ 701 struct ol_ath_htc_stats *ieee80211_ioctl_get_htc_stats(HTC_HANDLE 702 HTCHandle); 703 /** 704 * htc_get_tx_queue_depth() - get the tx queue depth of an htc endpoint 705 * @htc_handle: htc handle 706 * @enpoint_id: endpoint to check 707 * 708 * Return: htc_handle tx queue depth 709 */ 710 int htc_get_tx_queue_depth(HTC_HANDLE htc_handle, HTC_ENDPOINT_ID endpoint_id); 711 712 #ifdef WLAN_FEATURE_FASTPATH 713 void htc_ctrl_msg_cmpl(HTC_HANDLE htc_pdev, HTC_ENDPOINT_ID htc_ep_id); 714 715 #define HTC_TX_DESC_FILL(_htc_tx_desc, _download_len, _ep_id, _seq_no) \ 716 do { \ 717 HTC_WRITE32((_htc_tx_desc), \ 718 SM((_download_len), HTC_FRAME_HDR_PAYLOADLEN) | \ 719 SM((_ep_id), HTC_FRAME_HDR_ENDPOINTID)); \ 720 HTC_WRITE32((uint32_t *)(_htc_tx_desc) + 1, \ 721 SM((_seq_no), HTC_FRAME_HDR_CONTROLBYTES1)); \ 722 } while (0) 723 #endif /* WLAN_FEATURE_FASTPATH */ 724 725 #ifdef __cplusplus 726 } 727 #endif 728 void htc_get_control_endpoint_tx_host_credits(HTC_HANDLE HTCHandle, 729 int *credit); 730 void htc_dump_counter_info(HTC_HANDLE HTCHandle); 731 void *htc_get_targetdef(HTC_HANDLE htc_handle); 732 #ifdef FEATURE_RUNTIME_PM 733 int htc_runtime_suspend(HTC_HANDLE htc_ctx); 734 int htc_runtime_resume(HTC_HANDLE htc_ctx); 735 #endif 736 void htc_global_credit_flow_disable(void); 737 void htc_global_credit_flow_enable(void); 738 739 /* Disable ASPM : Disable PCIe low power */ 740 bool htc_can_suspend_link(HTC_HANDLE HTCHandle); 741 void htc_vote_link_down(HTC_HANDLE HTCHandle); 742 void htc_vote_link_up(HTC_HANDLE HTCHandle); 743 #ifdef IPA_OFFLOAD 744 void htc_ipa_get_ce_resource(HTC_HANDLE htc_handle, 745 qdf_shared_mem_t **ce_sr, 746 uint32_t *ce_sr_ring_size, 747 qdf_dma_addr_t *ce_reg_paddr); 748 #else 749 #define htc_ipa_get_ce_resource(htc_handle, \ 750 ce_sr, ce_sr_ring_size, ce_reg_paddr) /* NO-OP */ 751 #endif /* IPA_OFFLOAD */ 752 753 #if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT) 754 755 /** 756 * htc_dump_bundle_stats() - dump tx and rx htc message bundle stats 757 * @HTCHandle: htc handle 758 * 759 * Return: None 760 */ 761 void htc_dump_bundle_stats(HTC_HANDLE HTCHandle); 762 763 /** 764 * htc_clear_bundle_stats() - clear tx and rx htc message bundle stats 765 * @HTCHandle: htc handle 766 * 767 * Return: None 768 */ 769 void htc_clear_bundle_stats(HTC_HANDLE HTCHandle); 770 #endif 771 772 #ifdef FEATURE_RUNTIME_PM 773 int htc_pm_runtime_get(HTC_HANDLE htc_handle); 774 int htc_pm_runtime_put(HTC_HANDLE htc_handle); 775 #else 776 static inline int htc_pm_runtime_get(HTC_HANDLE htc_handle) { return 0; } 777 static inline int htc_pm_runtime_put(HTC_HANDLE htc_handle) { return 0; } 778 #endif 779 780 /** 781 * htc_set_async_ep() - set async HTC end point 782 * user should call this function after htc_connect_service before 783 * queing any packets to end point 784 * @HTCHandle: htc handle 785 * @HTC_ENDPOINT_ID: end point id 786 * @value: true or false 787 * 788 * Return: None 789 */ 790 791 void htc_set_async_ep(HTC_HANDLE HTCHandle, 792 HTC_ENDPOINT_ID htc_ep_id, bool value); 793 794 /** 795 * htc_set_wmi_endpoint_count: Set number of WMI endpoint 796 * @htc_handle: HTC handle 797 * @wmi_ep_count: WMI enpoint count 798 * 799 * return: None 800 */ 801 void htc_set_wmi_endpoint_count(HTC_HANDLE htc_handle, uint8_t wmi_ep_count); 802 803 /** 804 * htc_get_wmi_endpoint_count: Get number of WMI endpoint 805 * @htc_handle: HTC handle 806 * 807 * return: WMI enpoint count 808 */ 809 uint8_t htc_get_wmi_endpoint_count(HTC_HANDLE htc_handle); 810 811 /** 812 * htc_print_credit_history: print HTC credit history in buffer 813 * @htc: HTC handle 814 * @count: Number of lines to be copied 815 * @print: Print callback to print in the buffer 816 * @print_priv: any data required by the print method, e.g. a file handle 817 * 818 * return: None 819 */ 820 #ifdef FEATURE_HTC_CREDIT_HISTORY 821 void htc_print_credit_history(HTC_HANDLE htc, uint32_t count, 822 qdf_abstract_print * print, void *print_priv); 823 #else 824 static inline 825 void htc_print_credit_history(HTC_HANDLE htc, uint32_t count, 826 qdf_abstract_print *print, void *print_priv) 827 { 828 print(print_priv, "HTC Credit History Feature is disabled"); 829 } 830 #endif 831 #endif /* _HTC_API_H_ */ 832