ACPI / dock: fix error return code in dock_add()
[firefly-linux-kernel-4.4.55.git] / drivers / staging / csr / csr_wifi_router_lib.h
1 /*****************************************************************************
2
3             (c) Cambridge Silicon Radio Limited 2011
4             All rights reserved and confidential information of CSR
5
6             Refer to LICENSE.txt included with this source for details
7             on the license terms.
8
9 *****************************************************************************/
10
11 /* Note: this is an auto-generated file. */
12
13 #ifndef CSR_WIFI_ROUTER_LIB_H__
14 #define CSR_WIFI_ROUTER_LIB_H__
15
16 #include "csr_sched.h"
17 #include "csr_macro.h"
18 #include "csr_msg_transport.h"
19
20 #include "csr_wifi_lib.h"
21
22 #include "csr_wifi_router_prim.h"
23 #include "csr_wifi_router_task.h"
24
25 /*----------------------------------------------------------------------------*
26  *  CsrWifiRouterFreeUpstreamMessageContents
27  *
28  *  DESCRIPTION
29  *      Free the allocated memory in a CSR_WIFI_ROUTER upstream message. Does not
30  *      free the message itself, and can only be used for upstream messages.
31  *
32  *  PARAMETERS
33  *      Deallocates the resources in a CSR_WIFI_ROUTER upstream message
34  *----------------------------------------------------------------------------*/
35 void CsrWifiRouterFreeUpstreamMessageContents(u16 eventClass, void *message);
36
37 /*----------------------------------------------------------------------------*
38  *  CsrWifiRouterFreeDownstreamMessageContents
39  *
40  *  DESCRIPTION
41  *      Free the allocated memory in a CSR_WIFI_ROUTER downstream message. Does not
42  *      free the message itself, and can only be used for downstream messages.
43  *
44  *  PARAMETERS
45  *      Deallocates the resources in a CSR_WIFI_ROUTER downstream message
46  *----------------------------------------------------------------------------*/
47 void CsrWifiRouterFreeDownstreamMessageContents(u16 eventClass, void *message);
48
49 /*----------------------------------------------------------------------------*
50  * Enum to string functions
51  *----------------------------------------------------------------------------*/
52 const char* CsrWifiRouterAppTypeToString(CsrWifiRouterAppType value);
53 const char* CsrWifiRouterEncapsulationToString(CsrWifiRouterEncapsulation value);
54 const char* CsrWifiRouterOuiToString(CsrWifiRouterOui value);
55 const char* CsrWifiRouterPriorityToString(CsrWifiRouterPriority value);
56
57
58 /*----------------------------------------------------------------------------*
59  * CsrPrim Type toString function.
60  * Converts a message type to the String name of the Message
61  *----------------------------------------------------------------------------*/
62 const char* CsrWifiRouterPrimTypeToString(CsrPrim msgType);
63
64 /*----------------------------------------------------------------------------*
65  * Lookup arrays for PrimType name Strings
66  *----------------------------------------------------------------------------*/
67 extern const char *CsrWifiRouterUpstreamPrimNames[CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT];
68 extern const char *CsrWifiRouterDownstreamPrimNames[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT];
69
70 /*******************************************************************************
71
72   NAME
73     CsrWifiRouterMaPacketCancelReqSend
74
75   DESCRIPTION
76     This primitive is used to request cancellation of a previously send
77     CsrWifiRouterMaPacketReq.
78     The frame may already have been transmitted so there is no guarantees
79     that the CsrWifiRouterMaPacketCancelReq actually cancels the transmission
80     of the frame in question.
81     If the cancellation fails, the Router will send, if required,
82     CsrWifiRouterMaPacketCfm.
83     If the cancellation succeeds, the Router will not send
84     CsrWifiRouterMaPacketCfm.
85
86   PARAMETERS
87     queue          - Message Source Task Queue (Cfm's will be sent to this Queue)
88     interfaceTag   - Interface Identifier; unique identifier of an interface
89     hostTag        - The hostTag for the frame, which should be cancelled.
90     priority       - Priority of the frame, which should be cancelled
91     peerMacAddress - Destination MAC address of the frame, which should be
92                      cancelled
93
94 *******************************************************************************/
95 #define CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
96     msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketCancelReq), GFP_KERNEL); \
97     CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ, dst__, src__); \
98     msg__->interfaceTag = (interfaceTag__); \
99     msg__->hostTag = (hostTag__); \
100     msg__->priority = (priority__); \
101     msg__->peerMacAddress = (peerMacAddress__);
102
103 #define CsrWifiRouterMaPacketCancelReqSendTo(dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
104     { \
105         CsrWifiRouterMaPacketCancelReq *msg__; \
106         CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__); \
107         CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
108     }
109
110 #define CsrWifiRouterMaPacketCancelReqSend(src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
111     CsrWifiRouterMaPacketCancelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__)
112
113 /*******************************************************************************
114
115   NAME
116     CsrWifiRouterMaPacketReqSend
117
118   DESCRIPTION
119     A task sends this primitive to transmit a frame.
120
121   PARAMETERS
122     queue              - Message Source Task Queue (Cfm's will be sent to this Queue)
123     interfaceTag       - Interface Identifier; unique identifier of an interface
124     subscriptionHandle - The handle of the subscription
125     frameLength        - Length of the frame to be sent in bytes
126     frame              - Pointer to the frame to be sent
127     freeFunction       - Pointer to function to be used to free the frame
128     priority           - Priority of the frame, which should be sent
129     hostTag            - An application shall set the bits b31..b28 using one of
130                          the CSR_WIFI_ROUTER_APP_TYPE_* masks. Bits b0..b27 can
131                          be used by the requestor without any restrictions, but
132                          the hostTag shall be unique so the hostTag for
133                          CSR_WIFI_ROUTER_APP _TYPE_OTHER should be constructured
134                          in the following way [ CSR_WIFI_ROUTER_APP_TYPE_OTHER
135                          (4 bits) | SubscriptionHandle (8 bits) | Sequence no.
136                          (20 bits) ]. If the hostTag is not unique, the
137                          behaviour of the system is unpredicatable with respect
138                          to data/management frame transfer.
139     cfmRequested       - Indicates if the requestor needs a confirm for packet
140                          requests sent under this subscription. If set to TRUE,
141                          the router will send a confirm, else it will not send
142                          any confirm
143
144 *******************************************************************************/
145 #define CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
146     msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketReq), GFP_KERNEL); \
147     CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_REQ, dst__, src__); \
148     msg__->interfaceTag = (interfaceTag__); \
149     msg__->subscriptionHandle = (subscriptionHandle__); \
150     msg__->frameLength = (frameLength__); \
151     msg__->frame = (frame__); \
152     msg__->freeFunction = (freeFunction__); \
153     msg__->priority = (priority__); \
154     msg__->hostTag = (hostTag__); \
155     msg__->cfmRequested = (cfmRequested__);
156
157 #define CsrWifiRouterMaPacketReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
158     { \
159         CsrWifiRouterMaPacketReq *msg__; \
160         CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__); \
161         CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
162     }
163
164 #define CsrWifiRouterMaPacketReqSend(src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
165     CsrWifiRouterMaPacketReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__)
166
167 /*******************************************************************************
168
169   NAME
170     CsrWifiRouterMaPacketIndSend
171
172   DESCRIPTION
173     The router sends the primitive to a subscribed task when it receives a
174     frame matching the subscription.
175
176   PARAMETERS
177     queue              - Destination Task Queue
178     interfaceTag       - Interface Identifier; unique identifier of an interface
179     subscriptionHandle - The handle of the subscription
180     result             - Status of the operation
181     frameLength        - Length of the received frame in bytes
182     frame              - Pointer to the received frame
183     freeFunction       - Pointer to function to be used to free the frame
184     rssi               - Received signal strength indication in dBm
185     snr                - Signal to Noise Ratio
186     rate               - Transmission/Reception rate
187
188 *******************************************************************************/
189 #define CsrWifiRouterMaPacketIndCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
190     msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketInd), GFP_KERNEL); \
191     CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_IND, dst__, src__); \
192     msg__->interfaceTag = (interfaceTag__); \
193     msg__->subscriptionHandle = (subscriptionHandle__); \
194     msg__->result = (result__); \
195     msg__->frameLength = (frameLength__); \
196     msg__->frame = (frame__); \
197     msg__->freeFunction = (freeFunction__); \
198     msg__->rssi = (rssi__); \
199     msg__->snr = (snr__); \
200     msg__->rate = (rate__);
201
202 #define CsrWifiRouterMaPacketIndSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
203     { \
204         CsrWifiRouterMaPacketInd *msg__; \
205         CsrWifiRouterMaPacketIndCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__); \
206         CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
207     }
208
209 #define CsrWifiRouterMaPacketIndSend(dst__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
210     CsrWifiRouterMaPacketIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__)
211
212 /*******************************************************************************
213
214   NAME
215     CsrWifiRouterMaPacketResSend
216
217   DESCRIPTION
218     A task send this primitive to confirm the reception of the received
219     frame.
220
221   PARAMETERS
222     interfaceTag       - Interface Identifier; unique identifier of an interface
223     subscriptionHandle - The handle of the subscription
224     result             - Status of the operation
225
226 *******************************************************************************/
227 #define CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__) \
228     msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketRes), GFP_KERNEL); \
229     CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_RES, dst__, src__); \
230     msg__->interfaceTag = (interfaceTag__); \
231     msg__->subscriptionHandle = (subscriptionHandle__); \
232     msg__->result = (result__);
233
234 #define CsrWifiRouterMaPacketResSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__) \
235     { \
236         CsrWifiRouterMaPacketRes *msg__; \
237         CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__); \
238         CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
239     }
240
241 #define CsrWifiRouterMaPacketResSend(src__, interfaceTag__, subscriptionHandle__, result__) \
242     CsrWifiRouterMaPacketResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, result__)
243
244 /*******************************************************************************
245
246   NAME
247     CsrWifiRouterMaPacketCfmSend
248
249   DESCRIPTION
250     The router sends the primitive to confirm the result of the transmission
251     of the packet of the corresponding CSR_WIFI_ROUTER MA_PACKET_REQ request.
252
253   PARAMETERS
254     queue        - Destination Task Queue
255     interfaceTag - Interface Identifier; unique identifier of an interface
256     result       - Status of the operation
257     hostTag      - The hostTrag will match the hostTag sent in the request.
258     rate         - Transmission/Reception rate
259
260 *******************************************************************************/
261 #define CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__) \
262     msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketCfm), GFP_KERNEL); \
263     CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_CFM, dst__, src__); \
264     msg__->interfaceTag = (interfaceTag__); \
265     msg__->result = (result__); \
266     msg__->hostTag = (hostTag__); \
267     msg__->rate = (rate__);
268
269 #define CsrWifiRouterMaPacketCfmSendTo(dst__, src__, interfaceTag__, result__, hostTag__, rate__) \
270     { \
271         CsrWifiRouterMaPacketCfm *msg__; \
272         CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__); \
273         CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
274     }
275
276 #define CsrWifiRouterMaPacketCfmSend(dst__, interfaceTag__, result__, hostTag__, rate__) \
277     CsrWifiRouterMaPacketCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, result__, hostTag__, rate__)
278
279 /*******************************************************************************
280
281   NAME
282     CsrWifiRouterMaPacketSubscribeReqSend
283
284   DESCRIPTION
285     A task can use this primitive to subscribe for a particular OUI/protocol
286     and transmit and receive frames matching the subscription.
287     NOTE: Multiple subscriptions for a given protocol and OUI will result in
288     the first subscription receiving the data and not the subsequent
289     subscriptions.
290
291   PARAMETERS
292     queue         - Message Source Task Queue (Cfm's will be sent to this Queue)
293     interfaceTag  - Interface Identifier; unique identifier of an interface
294     encapsulation - Specifies the encapsulation type, which will be used for the
295                     subscription
296     protocol      - Together with the OUI, specifies the protocol, which a task
297                     wants to subscribe to
298     oui           - Specifies the OUI for the protocol, which a task wants to
299                     subscribe to
300
301 *******************************************************************************/
302 #define CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \
303     msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeReq), GFP_KERNEL); \
304     CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ, dst__, src__); \
305     msg__->interfaceTag = (interfaceTag__); \
306     msg__->encapsulation = (encapsulation__); \
307     msg__->protocol = (protocol__); \
308     msg__->oui = (oui__);
309
310 #define CsrWifiRouterMaPacketSubscribeReqSendTo(dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \
311     { \
312         CsrWifiRouterMaPacketSubscribeReq *msg__; \
313         CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__); \
314         CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
315     }
316
317 #define CsrWifiRouterMaPacketSubscribeReqSend(src__, interfaceTag__, encapsulation__, protocol__, oui__) \
318     CsrWifiRouterMaPacketSubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, encapsulation__, protocol__, oui__)
319
320 /*******************************************************************************
321
322   NAME
323     CsrWifiRouterMaPacketSubscribeCfmSend
324
325   DESCRIPTION
326     The router sends this primitive to confirm the result of the
327     subscription.
328
329   PARAMETERS
330     queue              - Destination Task Queue
331     interfaceTag       - Interface Identifier; unique identifier of an interface
332     subscriptionHandle - Handle to the subscription
333                          This handle must be used in all subsequent requests
334     status             - Status of the operation
335     allocOffset        - Size of the offset for the frames of the subscription
336
337 *******************************************************************************/
338 #define CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
339     msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeCfm), GFP_KERNEL); \
340     CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM, dst__, src__); \
341     msg__->interfaceTag = (interfaceTag__); \
342     msg__->subscriptionHandle = (subscriptionHandle__); \
343     msg__->status = (status__); \
344     msg__->allocOffset = (allocOffset__);
345
346 #define CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
347     { \
348         CsrWifiRouterMaPacketSubscribeCfm *msg__; \
349         CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__); \
350         CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
351     }
352
353 #define CsrWifiRouterMaPacketSubscribeCfmSend(dst__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
354     CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, status__, allocOffset__)
355
356 /*******************************************************************************
357
358   NAME
359     CsrWifiRouterMaPacketUnsubscribeReqSend
360
361   DESCRIPTION
362     A task sends this primitive to unsubscribe a subscription
363
364   PARAMETERS
365     queue              - Message Source Task Queue (Cfm's will be sent to this Queue)
366     interfaceTag       - Interface Identifier; unique identifier of an interface
367     subscriptionHandle - The handle of the subscription
368
369 *******************************************************************************/
370 #define CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__) \
371     msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeReq), GFP_KERNEL); \
372     CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ, dst__, src__); \
373     msg__->interfaceTag = (interfaceTag__); \
374     msg__->subscriptionHandle = (subscriptionHandle__);
375
376 #define CsrWifiRouterMaPacketUnsubscribeReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__) \
377     { \
378         CsrWifiRouterMaPacketUnsubscribeReq *msg__; \
379         CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__); \
380         CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
381     }
382
383 #define CsrWifiRouterMaPacketUnsubscribeReqSend(src__, interfaceTag__, subscriptionHandle__) \
384     CsrWifiRouterMaPacketUnsubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__)
385
386 /*******************************************************************************
387
388   NAME
389     CsrWifiRouterMaPacketUnsubscribeCfmSend
390
391   DESCRIPTION
392     The router sends this primitive to confirm the result of the
393     unsubscription.
394
395   PARAMETERS
396     queue        - Destination Task Queue
397     interfaceTag - Interface Identifier; unique identifier of an interface
398     status       - Status of the operation
399
400 *******************************************************************************/
401 #define CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
402     msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeCfm), GFP_KERNEL); \
403     CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM, dst__, src__); \
404     msg__->interfaceTag = (interfaceTag__); \
405     msg__->status = (status__);
406
407 #define CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, src__, interfaceTag__, status__) \
408     { \
409         CsrWifiRouterMaPacketUnsubscribeCfm *msg__; \
410         CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
411         CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
412     }
413
414 #define CsrWifiRouterMaPacketUnsubscribeCfmSend(dst__, interfaceTag__, status__) \
415     CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, status__)
416
417 #endif /* CSR_WIFI_ROUTER_LIB_H__ */