Setting up repository
[linux-libre-firmware.git] / ath9k_htc / target_firmware / magpie_fw_dev / target / inc / magpie / htc_api.h
1 /*\r
2  * @File: htc_api.h\r
3  * \r
4  * @Abstract: host-target communications API\r
5  * \r
6  * @Notes: \r
7  *  \r
8  * Copyright (c) 2008 Atheros Communications Inc.\r
9  * All rights reserved.\r
10  *\r
11  */\r
12 \r
13 #ifndef __HTC_API_H__\r
14 #define __HTC_API_H__\r
15 \r
16 #include <osapi.h>\r
17 #include <htc.h>\r
18 //#include <htc_buf.h>\r
19 //#include <htc_services.h>\r
20 #include <adf_nbuf.h>\r
21 #include <buf_pool_api.h>\r
22 \r
23 #define HTC_HDR_SZ          HTC_HDR_LENGTH\r
24 #define HTC_BUFSZ_MAX_SEND  2048\r
25 \r
26 typedef void (* HTC_SERVICE_ProcessRecvMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, adf_nbuf_t, void *ServiceCtx);\r
27 typedef void (* HTC_SERVICE_ProcessSendBufferComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, void *ServiceCtx);\r
28  \r
29 /* HTC service structure :\r
30  * the caller is required to allocate storage for the service structure and register the\r
31  * structure using HTC_RegisterService()  The service must set the following fields:\r
32  *    ProcessRecvMsg\r
33  *    ProcessSendBufferComplete\r
34  *    ProcessConnect\r
35  *    ServiceID\r
36  *    MaxSvcMsgSize (for message validation)\r
37  * */\r
38 typedef struct _HTC_SERVICE {\r
39     struct _HTC_SERVICE *pNext;\r
40         /* Callback for processing receive messages.  HTC calls this callback whenever a \r
41          * message arrives on the endpoint assigned to this service.\r
42          * HTC_BUFFER is a chain of buffers containing a full application message.\r
43          * HTC_BUFFER->buffer points to the start of the msg buffer (past the HTC header) */\r
44     //void (* ProcessRecvMsg)(HTC_ENDPOINT_ID EndpointID, HTC_BUFFER *); \r
45     void (* ProcessRecvMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, adf_nbuf_t, void *ServiceCtx); \r
46         /* callback to process completed send buffers */\r
47     //void (* ProcessSendBufferComplete)(HTC_ENDPOINT_ID EndpointID, HTC_BUFFER *); \r
48     void (* ProcessSendBufferComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t, void *ServiceCtx); \r
49         /* optional callback when a connection request occurs.\r
50          * The EndpointID is the assigned endpoint, the callback returns a connect \r
51          * response status code to allow or disallow the connection.\r
52          * pDataIn points to the optional meta data supplied in the connection request\r
53          * pDataOut points to a buffer to send back meta data \r
54          * If no callback is supplied, HTC assumes the connect is allowed  */\r
55     A_UINT8 (* ProcessConnect)(struct _HTC_SERVICE *pService,\r
56                                HTC_ENDPOINT_ID     EndpointID, \r
57                                A_UINT8 *pDataIn, \r
58                                int      LengthIn,\r
59                                A_UINT8 *pDataOut,\r
60                                int     *pLengthOut); \r
61     A_UINT16  ServiceID;        /* service ID to match connection requests */\r
62     A_UINT16  ServiceFlags;     /* service flags */\r
63     A_UINT16  MaxSvcMsgSize;    /* maximum length of service-specific messages exchanged on the endpoint */\r
64     A_UINT16  TrailerSpcCheckLimit;  /* amount of space in each send buffer that HTC can check for trailer\r
65                                         data. This should be set to the smallest HTC buffer that can be sent \r
66                                         through the service. The service can disable trailer data insertion\r
67                                         by setting this value to 0. */\r
68     void      *ServiceCtx;\r
69 } HTC_SERVICE;\r
70 \r
71 #define HTC_SERVICE_FLAGS_CONNECTED         (1 << 0)  /* service has at least 1 connection */\r
72 \r
73 #define IS_SERVICE_CONNECTED(s) ((s)->ServiceFlags & HTC_SERVICE_FLAGS_CONNECTED)\r
74 \r
75    /* configuration settings for the WMI service */\r
76 typedef struct _HTC_CONFIG {\r
77     int         CreditSize;    /*  */\r
78     int         CreditNumber;\r
79     //int         ControlDownLinkPipeID;\r
80     //int         ControlUpLinkPipeID;\r
81     adf_os_handle_t   OSHandle;\r
82     hif_handle_t      HIFHandle;\r
83     pool_handle_t     PoolHandle;\r
84 } HTC_CONFIG;\r
85 \r
86 typedef struct _HTC_BUF_CONTEXT {\r
87     A_UINT8         end_point;\r
88     A_UINT8         htc_flags;      /* htc flags (used by HTC layer only) */     \r
89 } HTC_BUF_CONTEXT;\r
90 \r
91 typedef void* htc_handle_t;\r
92 \r
93 /*\r
94  * setup complete function, supplied by HTC caller at HTC_init time.\r
95  * HTC calls this function after the host has indicated that the service connection\r
96  * phase is complete.\r
97  * \r
98  */\r
99 typedef void (* HTC_SETUP_COMPLETE_CB)(void);\r
100 \r
101 struct htc_apis {\r
102     htc_handle_t (* _HTC_Init)(HTC_SETUP_COMPLETE_CB, HTC_CONFIG *pConfig);    \r
103     void (* _HTC_Shutdown)(htc_handle_t);\r
104     void (* _HTC_RegisterService)(htc_handle_t, HTC_SERVICE *);\r
105     void (* _HTC_Ready)(htc_handle_t);\r
106     void (* _HTC_ReturnBuffers)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_t);\r
107     void (* _HTC_ReturnBuffersList)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_queue_t);\r
108     void (* _HTC_SendMsg)(htc_handle_t handle, HTC_ENDPOINT_ID EndpointID, adf_nbuf_t);        \r
109     int  (* _HTC_GetReservedHeadroom)(htc_handle_t handle);\r
110     \r
111     //void (* _HTC_PauseRecv)(HTC_ENDPOINT_ID EndpointID);\r
112     //void (* _HTC_ResumeRecv)(HTC_ENDPOINT_ID EndpointID);\r
113     //void (* _HTC_AddBufferResources)(int buffers);\r
114     \r
115     /* These APIs below are for patch purpose only */\r
116     void (*_HTC_MsgRecvHandler)(adf_nbuf_t hdr_buf, adf_nbuf_t buf, void *context);\r
117     void (*_HTC_SendDoneHandler)(adf_nbuf_t buf, void *context);\r
118     void (*_HTC_ControlSvcProcessMsg)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t hdr_buf, adf_nbuf_t buf, void *arg);\r
119     void (*_HTC_ControlSvcProcessSendComplete)(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t pBuffers, void *arg);\r
120     \r
121     void *pReserved;  /* for expansion if need be */\r
122 };\r
123 \r
124 extern void htc_module_install(struct htc_apis *pAPIs);\r
125 \r
126 #endif /* _HTC_API_H__ */\r