1 /*****************************************************************************
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
6 Refer to LICENSE.txt included with this source for details
9 *****************************************************************************/
11 /* Note: this is an auto-generated file. */
13 #ifndef CSR_WIFI_ROUTER_LIB_H__
14 #define CSR_WIFI_ROUTER_LIB_H__
16 #include "csr_sched.h"
17 #include "csr_macro.h"
18 #include "csr_msg_transport.h"
20 #include "csr_wifi_lib.h"
22 #include "csr_wifi_router_prim.h"
23 #include "csr_wifi_router_task.h"
30 /*----------------------------------------------------------------------------*
31 * CsrWifiRouterFreeUpstreamMessageContents
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.
38 * Deallocates the resources in a CSR_WIFI_ROUTER upstream message
39 *----------------------------------------------------------------------------*/
40 void CsrWifiRouterFreeUpstreamMessageContents(u16 eventClass, void *message);
42 /*----------------------------------------------------------------------------*
43 * CsrWifiRouterFreeDownstreamMessageContents
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.
50 * Deallocates the resources in a CSR_WIFI_ROUTER downstream message
51 *----------------------------------------------------------------------------*/
52 void CsrWifiRouterFreeDownstreamMessageContents(u16 eventClass, void *message);
54 /*----------------------------------------------------------------------------*
55 * Enum to string functions
56 *----------------------------------------------------------------------------*/
57 const char* CsrWifiRouterAppTypeToString(CsrWifiRouterAppType value);
58 const char* CsrWifiRouterEncapsulationToString(CsrWifiRouterEncapsulation value);
59 const char* CsrWifiRouterOuiToString(CsrWifiRouterOui value);
60 const char* CsrWifiRouterPriorityToString(CsrWifiRouterPriority value);
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);
69 /*----------------------------------------------------------------------------*
70 * Lookup arrays for PrimType name Strings
71 *----------------------------------------------------------------------------*/
72 extern const char *CsrWifiRouterUpstreamPrimNames[CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT];
73 extern const char *CsrWifiRouterDownstreamPrimNames[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT];
75 /*******************************************************************************
78 CsrWifiRouterMaPacketCancelReqSend
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.
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
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__);
108 #define CsrWifiRouterMaPacketCancelReqSendTo(dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
110 CsrWifiRouterMaPacketCancelReq *msg__; \
111 CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__); \
112 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
115 #define CsrWifiRouterMaPacketCancelReqSend(src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
116 CsrWifiRouterMaPacketCancelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__)
118 /*******************************************************************************
121 CsrWifiRouterMaPacketReqSend
124 A task sends this primitive to transmit a frame.
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
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__);
162 #define CsrWifiRouterMaPacketReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
164 CsrWifiRouterMaPacketReq *msg__; \
165 CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__); \
166 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
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__)
172 /*******************************************************************************
175 CsrWifiRouterMaPacketIndSend
178 The router sends the primitive to a subscribed task when it receives a
179 frame matching the subscription.
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
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__);
207 #define CsrWifiRouterMaPacketIndSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
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__); \
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__)
217 /*******************************************************************************
220 CsrWifiRouterMaPacketResSend
223 A task send this primitive to confirm the reception of the received
227 interfaceTag - Interface Identifier; unique identifier of an interface
228 subscriptionHandle - The handle of the subscription
229 result - Status of the operation
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__);
239 #define CsrWifiRouterMaPacketResSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__) \
241 CsrWifiRouterMaPacketRes *msg__; \
242 CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__); \
243 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
246 #define CsrWifiRouterMaPacketResSend(src__, interfaceTag__, subscriptionHandle__, result__) \
247 CsrWifiRouterMaPacketResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, result__)
249 /*******************************************************************************
252 CsrWifiRouterMaPacketCfmSend
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.
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
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__);
274 #define CsrWifiRouterMaPacketCfmSendTo(dst__, src__, interfaceTag__, result__, hostTag__, rate__) \
276 CsrWifiRouterMaPacketCfm *msg__; \
277 CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__); \
278 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
281 #define CsrWifiRouterMaPacketCfmSend(dst__, interfaceTag__, result__, hostTag__, rate__) \
282 CsrWifiRouterMaPacketCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, result__, hostTag__, rate__)
284 /*******************************************************************************
287 CsrWifiRouterMaPacketSubscribeReqSend
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
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
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
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__);
315 #define CsrWifiRouterMaPacketSubscribeReqSendTo(dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \
317 CsrWifiRouterMaPacketSubscribeReq *msg__; \
318 CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__); \
319 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
322 #define CsrWifiRouterMaPacketSubscribeReqSend(src__, interfaceTag__, encapsulation__, protocol__, oui__) \
323 CsrWifiRouterMaPacketSubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, encapsulation__, protocol__, oui__)
325 /*******************************************************************************
328 CsrWifiRouterMaPacketSubscribeCfmSend
331 The router sends this primitive to confirm the result of the
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
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__);
351 #define CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
353 CsrWifiRouterMaPacketSubscribeCfm *msg__; \
354 CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__); \
355 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
358 #define CsrWifiRouterMaPacketSubscribeCfmSend(dst__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
359 CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, status__, allocOffset__)
361 /*******************************************************************************
364 CsrWifiRouterMaPacketUnsubscribeReqSend
367 A task sends this primitive to unsubscribe a subscription
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
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__);
381 #define CsrWifiRouterMaPacketUnsubscribeReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__) \
383 CsrWifiRouterMaPacketUnsubscribeReq *msg__; \
384 CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__); \
385 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
388 #define CsrWifiRouterMaPacketUnsubscribeReqSend(src__, interfaceTag__, subscriptionHandle__) \
389 CsrWifiRouterMaPacketUnsubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__)
391 /*******************************************************************************
394 CsrWifiRouterMaPacketUnsubscribeCfmSend
397 The router sends this primitive to confirm the result of the
401 queue - Destination Task Queue
402 interfaceTag - Interface Identifier; unique identifier of an interface
403 status - Status of the operation
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__);
412 #define CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, src__, interfaceTag__, status__) \
414 CsrWifiRouterMaPacketUnsubscribeCfm *msg__; \
415 CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
416 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
419 #define CsrWifiRouterMaPacketUnsubscribeCfmSend(dst__, interfaceTag__, status__) \
420 CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, status__)
427 #endif /* CSR_WIFI_ROUTER_LIB_H__ */