12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073 |
- /*
- * Copyright (c) 2013-2014, 2016-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
- *
- * Permission to use, copy, modify, and/or distribute this software for
- * any purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all
- * copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
- * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
- #ifndef _HTC_API_H_
- #define _HTC_API_H_
- #include <htc.h>
- #include <htc_services.h>
- #include <qdf_types.h> /* qdf_device_t */
- #include "htc_packet.h"
- #ifdef __cplusplus
- extern "C" {
- #endif /* __cplusplus */
- /* TODO.. for BMI */
- #define ENDPOINT1 0
- /* TODO -remove me, but we have to fix BMI first */
- #define HTC_MAILBOX_NUM_MAX 4
- /* this is the amount of header room required by users of HTC */
- #define HTC_HEADER_LEN HTC_HDR_LENGTH
- #define HTC_HTT_TRANSFER_HDRSIZE 24
- /*
- * NOTE WELL: struct opaque_htc_handle is not defined anywhere. This
- * reference is used to help ensure that a HTC_HANDLE is never used
- * where a different handle type is expected
- */
- struct opaque_htc_handle;
- typedef struct opaque_htc_handle *HTC_HANDLE;
- typedef uint16_t HTC_SERVICE_ID;
- typedef void (*HTC_TARGET_FAILURE)(void *Instance, QDF_STATUS Status);
- struct htc_init_info {
- void *pContext; /* context for target notifications */
- void (*TargetFailure)(void *Instance, QDF_STATUS Status);
- void (*TargetSendSuspendComplete)(void *ctx, bool is_nack,
- uint16_t reason_code);
- void (*target_initial_wakeup_cb)(void *cb_ctx);
- void *target_psoc;
- uint32_t cfg_wmi_credit_cnt;
- /* HTC Pipe Ready Timeout in msecs */
- uint32_t htc_ready_timeout_ms;
- };
- /* Struct for HTC layer packet stats*/
- struct ol_ath_htc_stats {
- int htc_get_pkt_q_fail_count;
- int htc_pkt_q_empty_count;
- int htc_send_q_empty_count;
- };
- /* To resume HTT Tx queue during runtime resume */
- typedef void (*HTC_EP_RESUME_TX_QUEUE)(void *);
- typedef int (*HTC_EP_PADDING_CREDIT_UPDATE) (void *, int);
- /* per service connection send completion */
- typedef void (*HTC_EP_SEND_PKT_COMPLETE)(void *, HTC_PACKET *);
- /* per service connection callback when a plurality of packets have been sent
- * The HTC_PACKET_QUEUE is a temporary queue object (e.g. freed on return from
- * the callback) to hold a list of completed send packets.
- * If the handler cannot fully traverse the packet queue before returning, it
- * should transfer the items of the queue into the caller's private queue using:
- * HTC_PACKET_ENQUEUE()
- */
- typedef void (*HTC_EP_SEND_PKT_COMP_MULTIPLE)(void *,
- HTC_PACKET_QUEUE *);
- /* per service connection pkt received */
- typedef void (*HTC_EP_RECV_PKT)(void *, HTC_PACKET *);
- /* per service connection callback when a plurality of packets are received
- * The HTC_PACKET_QUEUE is a temporary queue object (e.g. freed on return from
- * the callback) to hold a list of recv packets.
- * If the handler cannot fully traverse the packet queue before returning, it
- * should transfer the items of the queue into the caller's private queue using:
- * HTC_PACKET_ENQUEUE()
- */
- typedef void (*HTC_EP_RECV_PKT_MULTIPLE)(void *, HTC_PACKET_QUEUE *);
- /* Optional per service connection receive buffer re-fill callback,
- * On some OSes (like Linux) packets are allocated from a global pool and
- * indicated up to the network stack. The driver never gets the packets back
- * from the OS. For these OSes a refill callback can be used to allocate and
- * re-queue buffers into HTC.
- *
- * On other OSes, the network stack can call into the driver's OS-specific
- * "return_packet" handler and the driver can re-queue these buffers into HTC.
- * In this regard a refill callback is unnecessary
- */
- typedef void (*HTC_EP_RECV_REFILL)(void *, HTC_ENDPOINT_ID Endpoint);
- /* Optional per service connection receive buffer allocation callback.
- * On some systems packet buffers are an extremely limited resource. Rather than
- * queue largest-possible-sized buffers to HTC, some systems would rather
- * allocate a specific size as the packet is received. The trade off is
- * slightly more processing (callback invoked for each RX packet)
- * for the benefit of committing fewer buffer resources into HTC.
- *
- * The callback is provided the length of the pending packet to fetch. This
- * includes the HTC header length plus the length of payload. The callback can
- * return a pointer to the allocated HTC packet for immediate use.
- *
- * Alternatively a variant of this handler can be used to allocate large receive
- * packets as needed. For example an application can use the refill mechanism
- * for normal packets and the recv-alloc mechanism to handle the case where a
- * large packet buffer is required. This can significantly reduce the
- * amount of "committed" memory used to receive packets.
- */
- typedef HTC_PACKET *(*HTC_EP_RECV_ALLOC)(void *,
- HTC_ENDPOINT_ID Endpoint,
- int Length);
- /* Optional per service connection callback to log packet information.
- */
- typedef void (*HTC_EP_LOG_PKT)(void *, HTC_PACKET *);
- enum htc_send_full_action {
- /* packet that overflowed should be kept in the queue */
- HTC_SEND_FULL_KEEP = 0,
- /* packet that overflowed should be dropped */
- HTC_SEND_FULL_DROP = 1,
- };
- /* Optional per service connection callback when a send queue is full. This can
- * occur if host continues queueing up TX packets faster than credits can arrive
- * To prevent the host (on some Oses like Linux) from continuously queueing pkts
- * and consuming resources, this callback is provided so that that the host
- * can disable TX in the subsystem (i.e. network stack).
- * This callback is invoked for each packet that "overflows" the HTC queue. The
- * callback can determine whether the new packet that overflowed the queue can
- * be kept (HTC_SEND_FULL_KEEP) or dropped (HTC_SEND_FULL_DROP). If a packet is
- * dropped, the EpTxComplete handler will be called and the packet's status
- * field will be set to A_NO_RESOURCE.
- * Other OSes require a "per-packet" indication for each completed TX packet,
- * this closed loop mechanism will prevent the network stack from overunning the
- * NIC. The packet to keep or drop is passed for inspection to the registered
- * handler the handler must ONLY inspect the packet, it may not free or reclaim
- * the packet.
- */
- typedef enum htc_send_full_action (*HTC_EP_SEND_QUEUE_FULL)(void *,
- HTC_PACKET *pPacket);
- struct htc_ep_callbacks {
- /* context for each callback */
- void *pContext;
- /* tx completion callback for connected endpoint */
- HTC_EP_SEND_PKT_COMPLETE EpTxComplete;
- /* receive callback for connected endpoint */
- HTC_EP_RECV_PKT EpRecv;
- /* OPTIONAL receive re-fill callback for connected endpoint */
- HTC_EP_RECV_REFILL EpRecvRefill;
- /* OPTIONAL send full callback */
- HTC_EP_SEND_QUEUE_FULL EpSendFull;
- /* OPTIONAL recv allocation callback */
- HTC_EP_RECV_ALLOC EpRecvAlloc;
- /* OPTIONAL recv allocation callback based on a threshold */
- HTC_EP_RECV_ALLOC EpRecvAllocThresh;
- /* OPTIONAL completion handler for multiple complete
- * indications (EpTxComplete must be NULL)
- */
- HTC_EP_SEND_PKT_COMP_MULTIPLE EpTxCompleteMultiple;
- HTC_EP_RESUME_TX_QUEUE ep_resume_tx_queue;
- HTC_EP_PADDING_CREDIT_UPDATE ep_padding_credit_update;
- /* if EpRecvAllocThresh is non-NULL, HTC will compare the
- * threshold value to the current recv packet length and invoke
- * the EpRecvAllocThresh callback to acquire a packet buffer
- */
- int RecvAllocThreshold;
- /* if a EpRecvRefill handler is provided, this value
- * can be used to set a trigger refill callback
- * when the recv queue drops below this value
- * if set to 0, the refill is only called when packets
- * are empty
- */
- int RecvRefillWaterMark;
- /* OPTIONAL callback to log packet information */
- HTC_EP_LOG_PKT ep_log_pkt;
- };
- /* service connection information */
- struct htc_service_connect_req {
- /* service ID to connect to */
- HTC_SERVICE_ID service_id;
- /* connection flags, see htc protocol definition */
- uint16_t ConnectionFlags;
- /* ptr to optional service-specific meta-data */
- uint8_t *pMetaData;
- /* optional meta data length */
- uint8_t MetaDataLength;
- /* endpoint callbacks */
- struct htc_ep_callbacks EpCallbacks;
- /* maximum depth of any send queue */
- int MaxSendQueueDepth;
- /* HTC flags for the host-side (local) connection */
- uint32_t LocalConnectionFlags;
- /* override max message size in send direction */
- unsigned int MaxSendMsgSize;
- };
- /* enable send bundle padding for this endpoint */
- #define HTC_LOCAL_CONN_FLAGS_ENABLE_SEND_BUNDLE_PADDING (1 << 0)
- /* service connection response information */
- struct htc_service_connect_resp {
- /* caller supplied buffer to optional meta-data */
- uint8_t *pMetaData;
- /* length of caller supplied buffer */
- uint8_t BufferLength;
- /* actual length of meta data */
- uint8_t ActualLength;
- /* endpoint to communicate over */
- HTC_ENDPOINT_ID Endpoint;
- /* max length of all messages over this endpoint */
- unsigned int MaxMsgLength;
- /* connect response code from target */
- uint8_t ConnectRespCode;
- };
- /* endpoint distribution structure */
- struct htc_endpoint_credit_dist {
- struct _htc_endpoint_credit_dist *pNext;
- struct _htc_endpoint_credit_dist *pPrev;
- /* Service ID (set by HTC) */
- HTC_SERVICE_ID service_id;
- /* endpoint for this distribution struct (set by HTC) */
- HTC_ENDPOINT_ID Endpoint;
- /* distribution flags, distribution function can
- * set default activity using SET_EP_ACTIVE() macro
- */
- uint32_t DistFlags;
- /* credits for normal operation, anything above this
- * indicates the endpoint is over-subscribed, this field
- * is only relevant to the credit distribution function
- */
- int TxCreditsNorm;
- /* floor for credit distribution, this field is
- * only relevant to the credit distribution function
- */
- int TxCreditsMin;
- /* number of credits assigned to this EP, this field
- * is only relevant to the credit dist function
- */
- int TxCreditsAssigned;
- /* current credits available, this field is used by
- * HTC to determine whether a message can be sent or
- * must be queued
- */
- int TxCredits;
- /* pending credits to distribute on this endpoint, this
- * is set by HTC when credit reports arrive.
- * The credit distribution functions sets this to zero
- * when it distributes the credits
- */
- int TxCreditsToDist;
- /* this is the number of credits that the current pending TX
- * packet needs to transmit. This is set by HTC when
- * and endpoint needs credits in order to transmit
- */
- int TxCreditsSeek;
- /* size in bytes of each credit (set by HTC) */
- int TxCreditSize;
- /* credits required for a maximum sized messages (set by HTC) */
- int TxCreditsPerMaxMsg;
- /* reserved for HTC use */
- void *pHTCReserved;
- /* current depth of TX queue , i.e. messages waiting for credits
- * This field is valid only when HTC_CREDIT_DIST_ACTIVITY_CHANGE
- * or HTC_CREDIT_DIST_SEND_COMPLETE is indicated on an endpoint
- * that has non-zero credits to recover
- */
- int TxQueueDepth;
- };
- #define HTC_EP_ACTIVE ((uint32_t) (1u << 31))
- /* macro to check if an endpoint has gone active, useful for credit
- * distributions */
- #define IS_EP_ACTIVE(epDist) ((epDist)->DistFlags & HTC_EP_ACTIVE)
- #define SET_EP_ACTIVE(epDist) (epDist)->DistFlags |= HTC_EP_ACTIVE
- /* credit distribution code that is passed into the distribution function,
- * there are mandatory and optional codes that must be handled
- */
- enum htc_credit_dist_reason {
- /* credits available as a result of completed
- * send operations (MANDATORY) resulting in credit reports
- */
- HTC_CREDIT_DIST_SEND_COMPLETE = 0,
- /* a change in endpoint activity occurred (OPTIONAL) */
- HTC_CREDIT_DIST_ACTIVITY_CHANGE = 1,
- /* an endpoint needs to "seek" credits (OPTIONAL) */
- HTC_CREDIT_DIST_SEEK_CREDITS,
- /* for debugging, dump any state information that is kept by
- * the distribution function
- */
- HTC_DUMP_CREDIT_STATE
- };
- typedef void (*HTC_CREDIT_DIST_CALLBACK)(void *Context,
- struct htc_endpoint_credit_dist *
- pEPList,
- enum htc_credit_dist_reason
- Reason);
- typedef void (*HTC_CREDIT_INIT_CALLBACK)(void *Context,
- struct htc_endpoint_credit_dist *
- pEPList, int TotalCredits);
- /* endpoint statistics action */
- enum htc_endpoint_stat_action {
- /* only read statistics */
- HTC_EP_STAT_SAMPLE = 0,
- /* sample and immediately clear statistics */
- HTC_EP_STAT_SAMPLE_AND_CLEAR = 1,
- /* clear only */
- HTC_EP_STAT_CLEAR
- };
- /* endpoint statistics */
- struct htc_endpoint_stats {
- /* number of TX packets posted to the endpoint */
- uint32_t TxPosted;
- /* number of times the host set the credit-low flag in a send message on
- * this endpoint
- */
- uint32_t TxCreditLowIndications;
- /* running count of total TX packets issued */
- uint32_t TxIssued;
- /* running count of TX packets that were issued in bundles */
- uint32_t TxPacketsBundled;
- /* running count of TX bundles that were issued */
- uint32_t TxBundles;
- /* tx packets that were dropped */
- uint32_t TxDropped;
- /* running count of total credit reports received for this endpoint */
- uint32_t TxCreditRpts;
- /* credit reports received from this endpoint's RX packets */
- uint32_t TxCreditRptsFromRx;
- /* credit reports received from RX packets of other endpoints */
- uint32_t TxCreditRptsFromOther;
- /* credit reports received from endpoint 0 RX packets */
- uint32_t TxCreditRptsFromEp0;
- /* count of credits received via Rx packets on this endpoint */
- uint32_t TxCreditsFromRx;
- /* count of credits received via another endpoint */
- uint32_t TxCreditsFromOther;
- /* count of credits received via another endpoint */
- uint32_t TxCreditsFromEp0;
- /* count of consumed credits */
- uint32_t TxCreditsConsummed;
- /* count of credits returned */
- uint32_t TxCreditsReturned;
- /* count of RX packets received */
- uint32_t RxReceived;
- /* count of lookahead records
- * found in messages received on this endpoint
- */
- uint32_t RxLookAheads;
- /* count of recv packets received in a bundle */
- uint32_t RxPacketsBundled;
- /* count of number of bundled lookaheads */
- uint32_t RxBundleLookAheads;
- /* count of the number of bundle indications from the HTC header */
- uint32_t RxBundleIndFromHdr;
- /* number of times the recv allocation threshold was hit */
- uint32_t RxAllocThreshHit;
- /* total number of bytes */
- uint32_t RxAllocThreshBytes;
- };
- /**
- * enum htc_link_vote_user_id - user ids for each link vote type
- * @HTC_LINK_VOTE_INVALID_MIN_USER_ID: min user id
- * @HTC_LINK_VOTE_SAP_USER_ID: sap user id
- * @HTC_LINK_VOTE_GO_USER_ID: go user id
- * @HTC_LINK_VOTE_NDP_USER_ID: ndp user id
- * @HTC_LINK_VOTE_SAP_DFS_USER_ID: sap dfs user id
- * @HTC_LINK_VOTE_STA_USER_ID: sta user id
- * @HTC_LINK_VOTE_INVALID_MAX_USER_ID: max user id
- */
- enum htc_link_vote_user_id {
- HTC_LINK_VOTE_INVALID_MIN_USER_ID = 0,
- HTC_LINK_VOTE_SAP_USER_ID = 1,
- HTC_LINK_VOTE_GO_USER_ID = 2,
- HTC_LINK_VOTE_NDP_USER_ID = 3,
- HTC_LINK_VOTE_SAP_DFS_USER_ID = 4,
- HTC_LINK_VOTE_STA_USER_ID = 5,
- HTC_LINK_VOTE_INVALID_MAX_USER_ID
- };
- /* ------ Function Prototypes ------ */
- /**
- * htc_create() - Create an instance of HTC over the underlying HIF device
- * @HifDevice: hif device handle,
- * @pInfo: initialization information
- * @osdev: QDF device structure
- * @con_mode: driver connection mode
- *
- * Return: HTC_HANDLE on success, NULL on failure
- */
- HTC_HANDLE htc_create(void *HifDevice, struct htc_init_info *pInfo,
- qdf_device_t osdev, uint32_t con_mode);
- /**
- * htc_get_hif_device() - Get the underlying HIF device handle
- * @HTCHandle: handle passed into the AddInstance callback
- *
- * Return: opaque HIF device handle usable in HIF API calls.
- */
- void *htc_get_hif_device(HTC_HANDLE HTCHandle);
- /**
- * htc_set_credit_distribution() - Set credit distribution parameters
- * @HTCHandle: HTC handle
- * @pCreditDistContext: caller supplied context to pass into distribution
- * functions
- * @CreditDistFunc: Distribution function callback
- * @CreditInitFunc: Credit Distribution initialization callback
- * @ServicePriorityOrder: Array containing list of service IDs, lowest index
- * is highestpriority
- * @ListLength: number of elements in ServicePriorityOrder
- *
- * The user can set a custom credit distribution function to handle
- * special requirementsfor each endpoint. A default credit distribution
- * routine can be used by setting CreditInitFunc to NULL. The default
- * credit distribution is only provided for simple "fair" credit distribution
- * without regard to any prioritization.
- *
- * Return: None
- */
- void htc_set_credit_distribution(HTC_HANDLE HTCHandle,
- void *pCreditDistContext,
- HTC_CREDIT_DIST_CALLBACK CreditDistFunc,
- HTC_CREDIT_INIT_CALLBACK CreditInitFunc,
- HTC_SERVICE_ID ServicePriorityOrder[],
- int ListLength);
- /**
- * htc_wait_target() - Wait for the target to indicate the HTC layer is ready
- * @HTCHandle: HTC handle
- *
- * This API blocks until the target responds with an HTC ready message.
- * The caller should not connect services until the target has indicated it is
- * ready.
- *
- * Return: None
- */
- QDF_STATUS htc_wait_target(HTC_HANDLE HTCHandle);
- /**
- * htc_start() - Start target service communications
- * @HTCHandle: HTC handle
- *
- * This API indicates to the target that the service connection phase
- * is completeand the target can freely start all connected services. This
- * API should only be called AFTER all service connections have been made.
- * TCStart will issue a SETUP_COMPLETE message to the target to indicate that
- * all service connections have been made and the target can start
- * communicating over the endpoints.
- * Return: None
- */
- QDF_STATUS htc_start(HTC_HANDLE HTCHandle);
- /**
- * htc_connect_service() - Connect to an HTC service
- * @HTCHandle: HTC handle
- * @pReq: connection details
- * @pResp: connection response
- *
- * Service connections must be performed before htc_start.
- * User provides callback handlersfor various endpoint events.
- * Return: None
- */
- QDF_STATUS htc_connect_service(HTC_HANDLE HTCHandle,
- struct htc_service_connect_req *pReq,
- struct htc_service_connect_resp *pResp);
- /**
- * htc_dump() - HTC register log dump
- * @HTCHandle: HTC handle
- * @CmdId: Log command
- * @start: start/print logs
- *
- * Register logs will be started/printed/ be flushed.
- *
- * Return: None
- */
- void htc_dump(HTC_HANDLE HTCHandle, uint8_t CmdId, bool start);
- /**
- * htc_ce_tasklet_debug_dump() - Dump ce tasklet rings debug data
- * @htc_handle: HTC handle
- *
- * Debug logs will be printed.
- *
- * Return: None
- */
- void htc_ce_tasklet_debug_dump(HTC_HANDLE htc_handle);
- /**
- * htc_send_pkt() - Send an HTC packet
- * @HTCHandle: HTC handle
- * @pPacket: packet to send
- *
- * Caller must initialize packet using SET_HTC_PACKET_INFO_TX() macro.
- * This interface is fully asynchronous. On error, HTC SendPkt will
- * call the registered Endpoint callback to cleanup the packet.
- *
- * Return: QDF_STATUS_SUCCESS
- */
- QDF_STATUS htc_send_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket);
- #ifdef CUSTOM_CB_SCHEDULER_SUPPORT
- /**
- * htc_register_custom_cb() - Helper API to register the custom callback
- * @htc_handle: HTC handle
- * @endpoint_id: Endpoint ID
- * @custom_cb: Custom call back function pointer
- * @custom_cb_context: Custom callback context
- *
- * return: QDF_STATUS
- */
- QDF_STATUS
- htc_register_custom_cb(HTC_HANDLE htc_handle, HTC_ENDPOINT_ID endpoint_id,
- void (*custom_cb)(void *), void *custom_cb_context);
- /**
- * htc_unregister_custom_cb() - Helper API to unregister the custom callback
- * @htc_handle: HTC handle
- * @endpoint_id: Endpoint ID
- *
- * return: QDF_STATUS
- */
- QDF_STATUS
- htc_unregister_custom_cb(HTC_HANDLE htc_handle, HTC_ENDPOINT_ID endpoint_id);
- /**
- * htc_enable_custom_cb() - Helper API to enable the custom callback
- * @htc_handle: HTC handle
- * @endpoint_id: Endpoint ID
- *
- * return: QDF_STATUS
- */
- QDF_STATUS
- htc_enable_custom_cb(HTC_HANDLE htc_handle, HTC_ENDPOINT_ID endpoint_id);
- /**
- * htc_disable_custom_cb() - Helper API to disable the custom callback
- * @htc_handle: HTC handle
- * @endpoint_id: Endpoint ID
- *
- * return: QDF_STATUS
- */
- QDF_STATUS
- htc_disable_custom_cb(HTC_HANDLE htc_handle, HTC_ENDPOINT_ID endpoint_id);
- #else
- /**
- * htc_register_custom_cb() - Helper API to register the custom callback
- * @htc_handle: HTC handle
- * @endpoint_id: Endpoint ID
- * @custom_cb: Custom call back function pointer
- * @custom_cb_context: Custom callback context
- *
- * return: QDF_STATUS
- */
- static inline QDF_STATUS
- htc_register_custom_cb(HTC_HANDLE htc_handle, HTC_ENDPOINT_ID endpoint_id,
- void (*custom_cb)(void *), void *custom_cb_context)
- {
- return QDF_STATUS_SUCCESS;
- }
- /**
- * htc_unregister_custom_cb() - Helper API to unregister the custom callback
- * @htc_handle: HTC handle
- * @endpoint_id: Endpoint ID
- *
- * return: QDF_STATUS
- */
- static inline QDF_STATUS
- htc_unregister_custom_cb(HTC_HANDLE htc_handle, HTC_ENDPOINT_ID endpoint_id)
- {
- return QDF_STATUS_SUCCESS;
- }
- /**
- * htc_enable_custom_cb() - Helper API to enable the custom callback
- * @htc_handle: HTC handle
- * @endpoint_id: Endpoint ID
- *
- * return: QDF_STATUS
- */
- static inline QDF_STATUS
- htc_enable_custom_cb(HTC_HANDLE htc_handle, HTC_ENDPOINT_ID endpoint_id)
- {
- return QDF_STATUS_SUCCESS;
- }
- /**
- * htc_disable_custom_cb() - Helper API to disable the custom callback
- * @htc_handle: HTC handle
- * @endpoint_id: Endpoint ID
- *
- * return: QDF_STATUS
- */
- static inline QDF_STATUS
- htc_disable_custom_cb(HTC_HANDLE htc_handle, HTC_ENDPOINT_ID endpoint_id)
- {
- return QDF_STATUS_SUCCESS;
- }
- #endif /* CUSTOM_CB_SCHEDULER_SUPPORT */
- #ifdef ATH_11AC_TXCOMPACT
- /**
- * htc_send_data_pkt() - Send an HTC packet containing a tx descriptor and data
- * @HTCHandle: HTC handle
- * @netbuf: network buffer containing the packet to send
- * @Epid: endpoint id
- * @ActualLength: actual length of the packet
- *
- * Caller must initialize packet using SET_HTC_PACKET_INFO_TX() macro.
- * Caller must provide headroom in an initial fragment added to the
- * network buffer to store a HTC_FRAME_HDR.
- * This interface is fully asynchronous. On error, htc_send_data_pkt will
- * call the registered Endpoint EpDataTxComplete callback to cleanup
- * the packet.
- *
- * Return: QDF_STATUS
- */
- QDF_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, qdf_nbuf_t netbuf,
- int Epid, int ActualLength);
- #else /*ATH_11AC_TXCOMPACT */
- /**
- * htc_send_data_pkt() - Send an HTC packet containing a tx descriptor and data
- * @HTCHandle: HTC handle
- * @pPacket: packet to send
- * @more_data:
- *
- * Caller must initialize packet using SET_HTC_PACKET_INFO_TX() macro.
- * Caller must provide headroom in an initial fragment added to the
- * network buffer to store a HTC_FRAME_HDR.
- * This interface is fully asynchronous. On error, htc_send_data_pkt will
- * call the registered Endpoint EpDataTxComplete callback to cleanup
- * the packet.
- *
- * Return: QDF_STATUS
- */
- QDF_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket,
- uint8_t more_data);
- #endif /*ATH_11AC_TXCOMPACT */
- /**
- * htc_flush_surprise_remove() - Flush HTC when target is removed surprisely
- * service communications
- * @HTCHandle: HTC handle
- *
- * All receive and pending TX packets will be flushed.
- * Return: None
- */
- void htc_flush_surprise_remove(HTC_HANDLE HTCHandle);
- /**
- * htc_stop() - Stop HTC service communications
- * @HTCHandle: HTC handle
- *
- * HTC communications is halted. All receive and pending TX packets
- * will be flushed.
- * Return: None
- */
- void htc_stop(HTC_HANDLE HTCHandle);
- /**
- * htc_destroy() - Destroy HTC service
- * @HTCHandle: HTC handle
- *
- * This cleans up all resources allocated by htc_create().
- * Return: None
- */
- void htc_destroy(HTC_HANDLE HTCHandle);
- /**
- * htc_flush_endpoint() - Flush pending TX packets
- * @HTCHandle: HTC handle
- * @Endpoint: Endpoint to flush
- * @Tag: flush tag
- *
- * The Tag parameter is used to selectively flush packets with matching
- * tags. The value of 0 forces all packets to be flush regardless of tag
- * Return: None
- */
- void htc_flush_endpoint(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint,
- HTC_TX_TAG Tag);
- /**
- * htc_dump_credit_states() - Dump credit distribution state
- * @HTCHandle: HTC handle
- *
- * This dumps all credit distribution information to the debugger
- * Return: None
- */
- void htc_dump_credit_states(HTC_HANDLE HTCHandle);
- /**
- * htc_indicate_activity_change() - Indicate a traffic activity change on an
- * endpoint
- * @HTCHandle: HTC handle
- * @Endpoint: endpoint in which activity has changed
- * @Active: true if active, false if it has become inactive
- *
- * This triggers the registered credit distribution function to
- * re-adjust credits for active/inactive endpoints.
- * Return: None
- */
- void htc_indicate_activity_change(HTC_HANDLE HTCHandle,
- HTC_ENDPOINT_ID Endpoint, bool Active);
- /**
- * htc_get_endpoint_statistics() - Get endpoint statistics
- * @HTCHandle: HTC handle
- * @Endpoint: Endpoint identifier
- * @Action: action to take with statistics
- * @pStats: statistics that were sampled (can be NULL if Action is
- * HTC_EP_STAT_CLEAR)
- *
- * Statistics is a compile-time option and this function may return
- * false if HTC is not compiled with profiling.
- * The caller can specify the statistic "action" to take when sampling
- * the statistics. This includes :
- * HTC_EP_STAT_SAMPLE : The pStats structure is filled with the current
- * values.
- * HTC_EP_STAT_SAMPLE_AND_CLEAR : The structure is filled and the current
- * statisticsare cleared.
- * HTC_EP_STAT_CLEA : the statistics are cleared, the called can pass
- * a NULL value for pStats
- * Return: true if statistics profiling is enabled, otherwise false.
- */
- bool htc_get_endpoint_statistics(HTC_HANDLE HTCHandle,
- HTC_ENDPOINT_ID Endpoint,
- enum htc_endpoint_stat_action Action,
- struct htc_endpoint_stats *pStats);
- /**
- * htc_unblock_recv() - Unblock HTC message reception
- * @HTCHandle: HTC handle
- *
- * HTC will block the receiver if the EpRecvAlloc callback fails to provide a
- * packet. The caller can use this API to indicate to HTC when resources
- * (buffers) are available such that the receiver can be unblocked and HTC
- * may re-attempt fetching the pending message.
- * This API is not required if the user uses the EpRecvRefill callback or uses
- * the HTCAddReceivePacket()API to recycle or provide receive packets to HTC.
- * Return: None
- */
- void htc_unblock_recv(HTC_HANDLE HTCHandle);
- /**
- * htc_add_receive_pkt_multiple() - Add multiple receive packets to HTC
- * @HTCHandle: HTC handle
- * @pPktQueue: HTC receive packet queue holding packets to add
- *
- * User must supply HTC packets for capturing incoming HTC frames.
- * The caller mmust initialize each HTC packet using the
- * SET_HTC_PACKET_INFO_RX_REFILL() macro. The queue must only contain
- * recv packets for the same endpoint. Caller supplies a pointer to an
- * HTC_PACKET_QUEUE structure holding the recv packet. This API will
- * remove the packets from the pkt queue and place them into internal
- * recv packet list.
- * The caller may allocate the pkt queue on the stack to hold the pkts.
- * Return: A_OK on success
- */
- A_STATUS htc_add_receive_pkt_multiple(HTC_HANDLE HTCHandle,
- HTC_PACKET_QUEUE *pPktQueue);
- /**
- * htc_is_endpoint_active() - Check if an endpoint is marked active
- * @HTCHandle: HTC handle
- * @Endpoint: endpoint to check for active state
- *
- * Return: returns true if Endpoint is Active
- */
- bool htc_is_endpoint_active(HTC_HANDLE HTCHandle,
- HTC_ENDPOINT_ID Endpoint);
- /**
- * htc_set_pkt_dbg() - Set up debug flag for HTC packets
- * @handle: HTC handle
- * @dbg_flag: enable or disable flag
- *
- * Return: none
- */
- void htc_set_pkt_dbg(HTC_HANDLE handle, A_BOOL dbg_flag);
- /**
- * htc_set_nodrop_pkt() - Set up nodrop pkt flag for mboxping nodrop pkt
- * @HTCHandle: HTC handle
- * @isNodropPkt: indicates whether it is nodrop pkt
- *
- * Return: None
- *
- */
- void htc_set_nodrop_pkt(HTC_HANDLE HTCHandle, A_BOOL isNodropPkt);
- /**
- * htc_enable_hdr_length_check() - Set up htc_hdr_length_check flag
- * @htc_handle: HTC handle
- * @htc_hdr_length_check: flag to indicate whether htc header length check is
- * required
- *
- * Return: None
- *
- */
- void
- htc_enable_hdr_length_check(HTC_HANDLE htc_handle, bool htc_hdr_length_check);
- /**
- * htc_get_num_recv_buffers() - Get the number of recv buffers currently queued
- * into an HTC endpoint
- * @HTCHandle: HTC handle
- * @Endpoint: endpoint to check
- *
- * Return: returns number of buffers in queue
- *
- */
- int htc_get_num_recv_buffers(HTC_HANDLE HTCHandle,
- HTC_ENDPOINT_ID Endpoint);
- /**
- * htc_set_target_failure_callback() - Set the target failure handling callback
- * in HTC layer
- * @HTCHandle: HTC handle
- * @Callback: target failure handling callback
- *
- * Return: None
- */
- void htc_set_target_failure_callback(HTC_HANDLE HTCHandle,
- HTC_TARGET_FAILURE Callback);
- /* internally used functions for testing... */
- void htc_enable_recv(HTC_HANDLE HTCHandle);
- void htc_disable_recv(HTC_HANDLE HTCHandle);
- A_STATUS HTCWaitForPendingRecv(HTC_HANDLE HTCHandle,
- uint32_t TimeoutInMs,
- bool *pbIsRecvPending);
- /* function to fetch stats from htc layer*/
- struct ol_ath_htc_stats *ieee80211_ioctl_get_htc_stats(HTC_HANDLE
- HTCHandle);
- /**
- * htc_get_tx_queue_depth() - get the tx queue depth of an htc endpoint
- * @htc_handle: htc handle
- * @endpoint_id: endpoint to check
- *
- * Return: htc_handle tx queue depth
- */
- int htc_get_tx_queue_depth(HTC_HANDLE htc_handle, HTC_ENDPOINT_ID endpoint_id);
- #ifdef WLAN_FEATURE_FASTPATH
- void htc_ctrl_msg_cmpl(HTC_HANDLE htc_pdev, HTC_ENDPOINT_ID htc_ep_id);
- #define HTC_TX_DESC_FILL(_htc_tx_desc, _download_len, _ep_id, _seq_no) \
- do { \
- HTC_WRITE32((_htc_tx_desc), \
- SM((_download_len), HTC_FRAME_HDR_PAYLOADLEN) | \
- SM((_ep_id), HTC_FRAME_HDR_ENDPOINTID)); \
- HTC_WRITE32((uint32_t *)(_htc_tx_desc) + 1, \
- SM((_seq_no), HTC_FRAME_HDR_CONTROLBYTES1)); \
- } while (0)
- #endif /* WLAN_FEATURE_FASTPATH */
- #ifdef __cplusplus
- }
- #endif
- void htc_get_control_endpoint_tx_host_credits(HTC_HANDLE HTCHandle,
- int *credit);
- void htc_dump_counter_info(HTC_HANDLE HTCHandle);
- void *htc_get_targetdef(HTC_HANDLE htc_handle);
- #ifdef FEATURE_RUNTIME_PM
- int htc_runtime_suspend(HTC_HANDLE htc_ctx);
- int htc_runtime_resume(HTC_HANDLE htc_ctx);
- #endif
- void htc_global_credit_flow_disable(void);
- void htc_global_credit_flow_enable(void);
- /* Disable ASPM : Disable PCIe low power */
- bool htc_can_suspend_link(HTC_HANDLE HTCHandle);
- #ifdef IPA_OFFLOAD
- void htc_ipa_get_ce_resource(HTC_HANDLE htc_handle,
- qdf_shared_mem_t **ce_sr,
- uint32_t *ce_sr_ring_size,
- qdf_dma_addr_t *ce_reg_paddr);
- #else
- #define htc_ipa_get_ce_resource(htc_handle, \
- ce_sr, ce_sr_ring_size, ce_reg_paddr) /* NO-OP */
- #endif /* IPA_OFFLOAD */
- #if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT)
- /**
- * htc_dump_bundle_stats() - dump tx and rx htc message bundle stats
- * @HTCHandle: htc handle
- *
- * Return: None
- */
- void htc_dump_bundle_stats(HTC_HANDLE HTCHandle);
- /**
- * htc_clear_bundle_stats() - clear tx and rx htc message bundle stats
- * @HTCHandle: htc handle
- *
- * Return: None
- */
- void htc_clear_bundle_stats(HTC_HANDLE HTCHandle);
- #endif
- #ifdef FEATURE_RUNTIME_PM
- int htc_pm_runtime_get(HTC_HANDLE htc_handle);
- int htc_pm_runtime_put(HTC_HANDLE htc_handle);
- /**
- * htc_dec_return_htt_runtime_cnt: Decrement htc htt runtime count
- * @htc: HTC handle
- *
- * Return: value of runtime count after decrement
- */
- int32_t htc_dec_return_htt_runtime_cnt(HTC_HANDLE htc);
- #else
- static inline int htc_pm_runtime_get(HTC_HANDLE htc_handle) { return 0; }
- static inline int htc_pm_runtime_put(HTC_HANDLE htc_handle) { return 0; }
- static inline
- int32_t htc_dec_return_htt_runtime_cnt(HTC_HANDLE htc)
- {
- return -1;
- }
- #endif
- #ifdef WLAN_DEBUG_LINK_VOTE
- /**
- * htc_log_link_user_votes() - API to log link user votes
- *
- * API to log the link user votes
- *
- * Return: void
- */
- void htc_log_link_user_votes(void);
- /**
- * htc_vote_link_down() - API to vote for link down
- * @htc_handle: HTC handle
- * @id: PCIe link vote user id
- *
- * API for upper layers to call HIF to vote for link down
- *
- * Return: void
- */
- void htc_vote_link_down(HTC_HANDLE htc_handle, enum htc_link_vote_user_id id);
- /**
- * htc_vote_link_up() - API to vote for link up
- * @htc_handle: HTC Handle
- * @id: PCIe link vote user id
- *
- * API for upper layers to call HIF to vote for link up
- *
- * Return: void
- */
- void htc_vote_link_up(HTC_HANDLE htc_handle, enum htc_link_vote_user_id id);
- #else
- static inline
- void htc_log_link_user_votes(void)
- {
- }
- static inline
- void htc_vote_link_down(HTC_HANDLE htc_handle, enum htc_link_vote_user_id id)
- {
- }
- static inline
- void htc_vote_link_up(HTC_HANDLE htc_handle, enum htc_link_vote_user_id id)
- {
- }
- #endif
- /**
- * htc_set_async_ep() - set async HTC end point
- * user should call this function after htc_connect_service before
- * queueing any packets to end point
- * @HTCHandle: htc handle
- * @htc_ep_id: end point id
- * @value: true or false
- *
- * Return: None
- */
- void htc_set_async_ep(HTC_HANDLE HTCHandle,
- HTC_ENDPOINT_ID htc_ep_id, bool value);
- /**
- * htc_set_wmi_endpoint_count: Set number of WMI endpoint
- * @htc_handle: HTC handle
- * @wmi_ep_count: WMI endpoint count
- *
- * return: None
- */
- void htc_set_wmi_endpoint_count(HTC_HANDLE htc_handle, uint8_t wmi_ep_count);
- /**
- * htc_get_wmi_endpoint_count: Get number of WMI endpoint
- * @htc_handle: HTC handle
- *
- * return: WMI endpoint count
- */
- uint8_t htc_get_wmi_endpoint_count(HTC_HANDLE htc_handle);
- /**
- * htc_print_credit_history: print HTC credit history in buffer
- * @htc: HTC handle
- * @count: Number of lines to be copied
- * @print: Print callback to print in the buffer
- * @print_priv: any data required by the print method, e.g. a file handle
- *
- * return: None
- */
- #ifdef FEATURE_HTC_CREDIT_HISTORY
- void htc_print_credit_history(HTC_HANDLE htc, uint32_t count,
- qdf_abstract_print * print, void *print_priv);
- #else
- static inline
- void htc_print_credit_history(HTC_HANDLE htc, uint32_t count,
- qdf_abstract_print *print, void *print_priv)
- {
- print(print_priv, "HTC Credit History Feature is disabled");
- }
- #endif
- #ifdef SYSTEM_PM_CHECK
- /**
- * htc_system_resume() - Send out any pending WMI/HTT
- * messages pending in htc queues on system resume.
- * @htc: HTC handle
- *
- * Return: None
- */
- void htc_system_resume(HTC_HANDLE htc);
- #else
- static inline void htc_system_resume(HTC_HANDLE htc)
- {
- }
- #endif
- #endif /* _HTC_API_H_ */
|