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"
25 /*----------------------------------------------------------------------------*
26 * CsrWifiRouterFreeUpstreamMessageContents
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.
33 * Deallocates the resources in a CSR_WIFI_ROUTER upstream message
34 *----------------------------------------------------------------------------*/
35 void CsrWifiRouterFreeUpstreamMessageContents(u16 eventClass, void *message);
37 /*----------------------------------------------------------------------------*
38 * CsrWifiRouterFreeDownstreamMessageContents
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.
45 * Deallocates the resources in a CSR_WIFI_ROUTER downstream message
46 *----------------------------------------------------------------------------*/
47 void CsrWifiRouterFreeDownstreamMessageContents(u16 eventClass, void *message);
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);
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);
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];
70 /*******************************************************************************
73 CsrWifiRouterMaPacketCancelReqSend
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.
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
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__);
103 #define CsrWifiRouterMaPacketCancelReqSendTo(dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
105 CsrWifiRouterMaPacketCancelReq *msg__; \
106 CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__); \
107 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
110 #define CsrWifiRouterMaPacketCancelReqSend(src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
111 CsrWifiRouterMaPacketCancelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__)
113 /*******************************************************************************
116 CsrWifiRouterMaPacketReqSend
119 A task sends this primitive to transmit a frame.
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
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__);
157 #define CsrWifiRouterMaPacketReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
159 CsrWifiRouterMaPacketReq *msg__; \
160 CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__); \
161 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
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__)
167 /*******************************************************************************
170 CsrWifiRouterMaPacketIndSend
173 The router sends the primitive to a subscribed task when it receives a
174 frame matching the subscription.
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
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__);
202 #define CsrWifiRouterMaPacketIndSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
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__); \
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__)
212 /*******************************************************************************
215 CsrWifiRouterMaPacketResSend
218 A task send this primitive to confirm the reception of the received
222 interfaceTag - Interface Identifier; unique identifier of an interface
223 subscriptionHandle - The handle of the subscription
224 result - Status of the operation
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__);
234 #define CsrWifiRouterMaPacketResSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__) \
236 CsrWifiRouterMaPacketRes *msg__; \
237 CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__); \
238 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
241 #define CsrWifiRouterMaPacketResSend(src__, interfaceTag__, subscriptionHandle__, result__) \
242 CsrWifiRouterMaPacketResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, result__)
244 /*******************************************************************************
247 CsrWifiRouterMaPacketCfmSend
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.
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
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__);
269 #define CsrWifiRouterMaPacketCfmSendTo(dst__, src__, interfaceTag__, result__, hostTag__, rate__) \
271 CsrWifiRouterMaPacketCfm *msg__; \
272 CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__); \
273 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
276 #define CsrWifiRouterMaPacketCfmSend(dst__, interfaceTag__, result__, hostTag__, rate__) \
277 CsrWifiRouterMaPacketCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, result__, hostTag__, rate__)
279 /*******************************************************************************
282 CsrWifiRouterMaPacketSubscribeReqSend
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
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
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
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__);
310 #define CsrWifiRouterMaPacketSubscribeReqSendTo(dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \
312 CsrWifiRouterMaPacketSubscribeReq *msg__; \
313 CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__); \
314 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
317 #define CsrWifiRouterMaPacketSubscribeReqSend(src__, interfaceTag__, encapsulation__, protocol__, oui__) \
318 CsrWifiRouterMaPacketSubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, encapsulation__, protocol__, oui__)
320 /*******************************************************************************
323 CsrWifiRouterMaPacketSubscribeCfmSend
326 The router sends this primitive to confirm the result of the
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
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__);
346 #define CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
348 CsrWifiRouterMaPacketSubscribeCfm *msg__; \
349 CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__); \
350 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
353 #define CsrWifiRouterMaPacketSubscribeCfmSend(dst__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
354 CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, status__, allocOffset__)
356 /*******************************************************************************
359 CsrWifiRouterMaPacketUnsubscribeReqSend
362 A task sends this primitive to unsubscribe a subscription
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
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__);
376 #define CsrWifiRouterMaPacketUnsubscribeReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__) \
378 CsrWifiRouterMaPacketUnsubscribeReq *msg__; \
379 CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__); \
380 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
383 #define CsrWifiRouterMaPacketUnsubscribeReqSend(src__, interfaceTag__, subscriptionHandle__) \
384 CsrWifiRouterMaPacketUnsubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__)
386 /*******************************************************************************
389 CsrWifiRouterMaPacketUnsubscribeCfmSend
392 The router sends this primitive to confirm the result of the
396 queue - Destination Task Queue
397 interfaceTag - Interface Identifier; unique identifier of an interface
398 status - Status of the operation
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__);
407 #define CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, src__, interfaceTag__, status__) \
409 CsrWifiRouterMaPacketUnsubscribeCfm *msg__; \
410 CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
411 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
414 #define CsrWifiRouterMaPacketUnsubscribeCfmSend(dst__, interfaceTag__, status__) \
415 CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, status__)
417 #endif /* CSR_WIFI_ROUTER_LIB_H__ */