4 * @Abstract: host-target communications API
8 * Copyright (c) 2008 Atheros Communications Inc.
19 #include <buf_pool_api.h>
21 #define HTC_HDR_SZ HTC_HDR_LENGTH
22 #define HTC_BUFSZ_MAX_SEND 2048
24 typedef void (* HTC_SERVICE_ProcessRecvMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, adf_nbuf_t, void *ServiceCtx);
25 typedef void (* HTC_SERVICE_ProcessSendBufferComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, void *ServiceCtx);
27 /* HTC service structure :
28 * the caller is required to allocate storage for the service structure and register the
29 * structure using HTC_RegisterService() The service must set the following fields:
31 * ProcessSendBufferComplete
34 * MaxSvcMsgSize (for message validation)
36 typedef struct _HTC_SERVICE {
37 struct _HTC_SERVICE *pNext;
38 /* Callback for processing receive messages. HTC calls this callback whenever a
39 * message arrives on the endpoint assigned to this service.
40 * HTC_BUFFER is a chain of buffers containing a full application message.
41 * HTC_BUFFER->buffer points to the start of the msg buffer (past the HTC header) */
42 void (* ProcessRecvMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, adf_nbuf_t, void *ServiceCtx);
43 /* callback to process completed send buffers */
44 void (* ProcessSendBufferComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, void *ServiceCtx);
45 /* optional callback when a connection request occurs.
46 * The EndpointID is the assigned endpoint, the callback returns a connect
47 * response status code to allow or disallow the connection.
48 * pDataIn points to the optional meta data supplied in the connection request
49 * pDataOut points to a buffer to send back meta data
50 * If no callback is supplied, HTC assumes the connect is allowed */
51 A_UINT8 (* ProcessConnect)(struct _HTC_SERVICE *pService,
52 HTC_ENDPOINT_ID EndpointID,
58 A_UINT16 ServiceID; /* service ID to match connection requests */
59 A_UINT16 ServiceFlags; /* service flags */
60 A_UINT16 MaxSvcMsgSize; /* maximum length of service-specific messages exchanged on the endpoint */
61 A_UINT16 TrailerSpcCheckLimit; /* amount of space in each send buffer that HTC can check for trailer
62 data. This should be set to the smallest HTC buffer that can be sent
63 through the service. The service can disable trailer data insertion
64 by setting this value to 0. */
68 #define HTC_SERVICE_FLAGS_CONNECTED (1 << 0) /* service has at least 1 connection */
70 #define IS_SERVICE_CONNECTED(s) ((s)->ServiceFlags & HTC_SERVICE_FLAGS_CONNECTED)
72 /* configuration settings for the WMI service */
73 typedef struct _HTC_CONFIG {
76 adf_os_handle_t OSHandle;
77 hif_handle_t HIFHandle;
78 pool_handle_t PoolHandle;
81 typedef struct _HTC_BUF_CONTEXT {
83 A_UINT8 htc_flags; /* htc flags (used by HTC layer only) */
86 typedef void* htc_handle_t;
89 * setup complete function, supplied by HTC caller at HTC_init time.
90 * HTC calls this function after the host has indicated that the service connection
94 typedef void (* HTC_SETUP_COMPLETE_CB)(void);
97 htc_handle_t (* _HTC_Init)(HTC_SETUP_COMPLETE_CB, HTC_CONFIG *pConfig);
98 void (* _HTC_Shutdown)(htc_handle_t);
99 void (* _HTC_RegisterService)(htc_handle_t, HTC_SERVICE *);
100 void (* _HTC_Ready)(htc_handle_t);
101 void (* _HTC_ReturnBuffers)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_t);
102 void (* _HTC_ReturnBuffersList)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_queue_t);
103 void (* _HTC_SendMsg)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_t);
104 int (* _HTC_GetReservedHeadroom)(htc_handle_t handle);
106 /* These APIs below are for patch purpose only */
107 void (*_HTC_MsgRecvHandler)(adf_nbuf_t hdr_buf, adf_nbuf_t buf, void *context);
108 void (*_HTC_SendDoneHandler)(adf_nbuf_t buf, void *context);
109 void (*_HTC_ControlSvcProcessMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t hdr_buf, adf_nbuf_t buf, void *arg);
110 void (*_HTC_ControlSvcProcessSendComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t pBuffers, void *arg);
112 void *pReserved; /* for expansion if need be */
115 extern void htc_module_install(struct htc_apis *pAPIs);
117 #endif /* _HTC_API_H__ */