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