2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted (subject to the limitations in the
7 * disclaimer below) provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
17 * * Neither the name of Qualcomm Atheros nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22 * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 * This file contains the API for the Wireless Module Interface (WMI) Service
39 #ifndef WMI_SVC_API_H_
40 #define WMI_SVC_API_H_
46 #include <buf_pool_api.h>
48 #define WMI_SVC_MAX_BUFFERED_EVENT_SIZE 100
49 #define WMI_SVC_MSG_SIZE 1536 /* maximum size of any WMI control or event message */
52 typedef enum WMI_EVT_CLASS {
53 WMI_EVT_CLASS_NONE = -1,
54 WMI_EVT_CLASS_CMD_EVENT = 0,
55 WMI_EVT_CLASS_CMD_REPLY = 1,
59 /* command handler callback when a message is dispatched */
60 typedef void (* WMI_CMD_HANDLER)(void *pContext, /* application supplied context from dispatch table */
61 A_UINT16 Command, /* command ID that was dispatched */
63 A_UINT8 *pCmdBuffer, /* command data, 256 bytes max, 32-bit aligned */
64 int Length); /* length of command (excludes WMI header) */
66 /* configuration settings for the WMI service */
67 typedef struct _WMI_SVC_CONFIG {
68 htc_handle_t HtcHandle;
69 pool_handle_t PoolHandle;
70 int MaxCmdReplyEvts; /* total buffers for command replies */
71 int MaxEventEvts; /* total buffers for low priority events */
74 /* command dispatch entry */
75 typedef struct _WMI_DISPATCH_ENTRY {
76 WMI_CMD_HANDLER pCmdHandler; /* dispatch function */
77 A_UINT16 CmdID; /* WMI command to dispatch from */
78 A_UINT16 CheckLength; /* expected length of command, set to 0 to bypass check */
81 /* dispatch table that is used to register a set of dispatch entries */
82 typedef struct _WMI_DISPATCH_TABLE {
83 struct _WMI_DISPATCH_TABLE *pNext; /* next dispatch, WMI-reserved */
84 void *pContext; /* optional context that is passed to command handlers
85 assigned to this dispatch table */
86 int NumberOfEntries; /* number of elements pointed to by pTable */
87 WMI_DISPATCH_ENTRY *pTable; /* start of table */
90 #define WMI_DISPATCH_ENTRY_COUNT(table) \
91 (sizeof((table)) / sizeof(WMI_DISPATCH_ENTRY))
93 /* handy macro to declare a dispatch table */
94 #define WMI_DECLARE_DISPATCH_TABLE(name,dispatchEntries) \
95 WMI_DISPATCH_TABLE name = \
96 { NULL, NULL, WMI_DISPATCH_ENTRY_COUNT(dispatchEntries), dispatchEntries }
98 /* macro to programatically set the dispatch table context */
99 #define WMI_SET_DISPATCH_CONTEXT(pDispTable, pCtxt) (pDispTable)->pContext = (pCtxt)
101 typedef struct _WMI_BUF_CONTEXT {
102 HTC_BUF_CONTEXT HtcBufCtx;
104 WMI_EVT_CLASS EventClass; /* the event class this packet belongs to */
105 A_UINT16 Flags; /* internal flags reserved for WMI */
108 /* ROM-version, eventually. For now, in RAM */
110 typedef void* wmi_handle_t;
113 typedef struct _wmi_svc_apis {
114 wmi_handle_t (* _WMI_Init)(WMI_SVC_CONFIG *pWmiConfig);
115 void (* _WMI_RegisterDispatchTable)(wmi_handle_t h, WMI_DISPATCH_TABLE *pDispatchTable);
116 adf_nbuf_t (* _WMI_AllocEvent)(wmi_handle_t h, WMI_EVT_CLASS EventClass, int Length);
117 void (* _WMI_SendEvent)(wmi_handle_t h, adf_nbuf_t pEvt, A_UINT16 EventId, A_UINT16 SeqNo, int Length);
118 int (* _WMI_GetPendingEventsCount)(wmi_handle_t handle);
119 void (* _WMI_SendCompleteHandler)(HTC_ENDPOINT_ID Endpt, adf_nbuf_t pHTCBuf, void *arg);
120 int (* _WMI_GetControlEp)(wmi_handle_t h);
121 void (* _WMI_Shutdown)(wmi_handle_t h);
124 void (*_WMI_RecvMessageHandler)(HTC_ENDPOINT_ID EndPt, adf_nbuf_t hdr_buf, adf_nbuf_t pHTCBuf, void *arg);
125 A_UINT8 (*_WMI_ServiceConnect)(HTC_SERVICE *pService, HTC_ENDPOINT_ID eid,
131 void *pReserved; /* for expansion if need be */
134 extern void WMI_service_module_install(WMI_SVC_APIS *pAPIs);
136 #endif /*WMI_SVC_API_H_*/