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