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