1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45#include "IxEthDB_p.h"
46
47
48IX_ETH_DB_PUBLIC
49MacTreeNode *ixEthDBGatewaySelect(MacTreeNode *stations);
50
51
52
53
54
55
56
57
58
59
60
61
62
63IX_ETH_DB_PUBLIC
64IxEthDBStatus ixEthDBWiFiBBSIDSet(IxEthDBPortId portID, IxEthDBMacAddr *bbsid)
65{
66 IxNpeMhMessage message;
67 IX_STATUS result;
68
69 IX_ETH_DB_CHECK_PORT(portID);
70
71 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
72
73 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
74
75 IX_ETH_DB_CHECK_REFERENCE(bbsid);
76
77 memcpy(ixEthDBPortInfo[portID].bbsid, bbsid, sizeof (IxEthDBMacAddr));
78
79 FILL_SETBBSID_MSG(message, portID, bbsid);
80
81 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
82
83 return result;
84}
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100IX_ETH_DB_PRIVATE
101IxEthDBStatus ixEthDBWiFiFrameControlDurationIDUpdate(IxEthDBPortId portID)
102{
103 IxNpeMhMessage message;
104 IX_STATUS result;
105
106 FILL_SETFRAMECONTROLDURATIONID(message, portID, ixEthDBPortInfo[portID].frameControlDurationID);
107
108 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
109
110 return result;
111}
112
113
114
115
116
117
118
119
120
121
122
123
124
125IX_ETH_DB_PUBLIC
126IxEthDBStatus ixEthDBWiFiDurationIDSet(IxEthDBPortId portID, UINT16 durationID)
127{
128 IX_ETH_DB_CHECK_PORT(portID);
129
130 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
131
132 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
133
134 ixEthDBPortInfo[portID].frameControlDurationID = (ixEthDBPortInfo[portID].frameControlDurationID & 0xFFFF0000) | durationID;
135
136 return ixEthDBWiFiFrameControlDurationIDUpdate(portID);
137}
138
139
140
141
142
143
144
145
146
147
148
149
150
151IX_ETH_DB_PUBLIC
152IxEthDBStatus ixEthDBWiFiFrameControlSet(IxEthDBPortId portID, UINT16 frameControl)
153{
154 IX_ETH_DB_CHECK_PORT(portID);
155
156 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
157
158 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
159
160 ixEthDBPortInfo[portID].frameControlDurationID = (ixEthDBPortInfo[portID].frameControlDurationID & 0xFFFF) | (frameControl << 16);
161
162 return ixEthDBWiFiFrameControlDurationIDUpdate(portID);
163}
164
165
166
167
168
169
170
171
172
173
174
175
176
177IX_ETH_DB_PUBLIC
178IxEthDBStatus ixEthDBWiFiEntryRemove(IxEthDBPortId portID, IxEthDBMacAddr *macAddr)
179{
180 MacDescriptor recordTemplate;
181
182 IX_ETH_DB_CHECK_PORT(portID);
183
184 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
185
186 IX_ETH_DB_CHECK_REFERENCE(macAddr);
187
188 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
189
190 memcpy(recordTemplate.macAddress, macAddr, sizeof (IxEthDBMacAddr));
191
192 recordTemplate.type = IX_ETH_DB_WIFI_RECORD;
193 recordTemplate.portID = portID;
194
195 return ixEthDBRemove(&recordTemplate, NULL);
196}
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215IX_ETH_DB_PRIVATE
216IxEthDBStatus ixEthDBWiFiEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr, IxEthDBMacAddr *gatewayMacAddr)
217{
218 MacDescriptor recordTemplate;
219
220 IX_ETH_DB_CHECK_PORT(portID);
221
222 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
223
224 IX_ETH_DB_CHECK_REFERENCE(macAddr);
225
226 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
227
228 memcpy(recordTemplate.macAddress, macAddr, sizeof (IxEthDBMacAddr));
229
230 recordTemplate.type = IX_ETH_DB_WIFI_RECORD;
231 recordTemplate.portID = portID;
232
233 if (gatewayMacAddr != NULL)
234 {
235 memcpy(recordTemplate.recordData.wifiData.gwMacAddress, gatewayMacAddr, sizeof (IxEthDBMacAddr));
236
237 recordTemplate.recordData.wifiData.type = IX_ETH_DB_WIFI_AP_TO_AP;
238 }
239 else
240 {
241 memset(recordTemplate.recordData.wifiData.gwMacAddress, 0, sizeof (IxEthDBMacAddr));
242
243 recordTemplate.recordData.wifiData.type = IX_ETH_DB_WIFI_AP_TO_STA;
244 }
245
246 return ixEthDBAdd(&recordTemplate, NULL);
247}
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267IX_ETH_DB_PUBLIC
268IxEthDBStatus ixEthDBWiFiAccessPointEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr, IxEthDBMacAddr *gatewayMacAddr)
269{
270 IX_ETH_DB_CHECK_REFERENCE(gatewayMacAddr);
271
272 return ixEthDBWiFiEntryAdd(portID, macAddr, gatewayMacAddr);
273}
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292IX_ETH_DB_PUBLIC
293IxEthDBStatus ixEthDBWiFiStationEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr)
294{
295 return ixEthDBWiFiEntryAdd(portID, macAddr, NULL);
296}
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316IX_ETH_DB_PUBLIC
317MacTreeNode *ixEthDBGatewaySelect(MacTreeNode *stations)
318{
319 MacTreeNodeStack *stack;
320 MacTreeNode *gateways, *insertionPlace;
321 UINT32 gwIndex = 1;
322
323 if (stations == NULL)
324 {
325 return NULL;
326 }
327
328 stack = ixOsalCacheDmaMalloc(sizeof (MacTreeNodeStack));
329
330 if (stack == NULL)
331 {
332 ERROR_LOG("DB: (WiFi) failed to allocate the node stack for gateway tree linearization, out of memory?\n");
333 return NULL;
334 }
335
336
337 gateways = insertionPlace = NULL;
338
339
340 NODE_STACK_INIT(stack);
341
342
343 NODE_STACK_PUSH(stack, stations, 0);
344
345 while (NODE_STACK_NONEMPTY(stack))
346 {
347 MacTreeNode *node;
348 UINT32 offset;
349
350 NODE_STACK_POP(stack, node, offset);
351
352
353 if (offset > (MAX_GW_SIZE - 1)) break;
354
355
356 if (node->descriptor != NULL && node->descriptor->recordData.wifiData.type == IX_ETH_DB_WIFI_AP_TO_AP)
357 {
358
359 if (insertionPlace != NULL)
360 {
361 insertionPlace->right = ixEthDBAllocMacTreeNode();
362 insertionPlace = insertionPlace->right;
363 }
364 else
365 {
366 gateways = ixEthDBAllocMacTreeNode();
367 insertionPlace = gateways;
368 }
369
370 if (insertionPlace == NULL)
371 {
372
373 ixOsalCacheDmaFree(stack);
374 return gateways;
375 }
376
377
378 insertionPlace->descriptor = ixEthDBCloneMacDescriptor(node->descriptor);
379
380
381 node->descriptor->recordData.wifiData.gwAddressIndex = gwIndex++;
382 }
383
384
385 if (node->left != NULL)
386 {
387 NODE_STACK_PUSH(stack, node->left, LEFT_CHILD_OFFSET(offset));
388 }
389
390 if (node->right != NULL)
391 {
392 NODE_STACK_PUSH(stack, node->right, RIGHT_CHILD_OFFSET(offset));
393 }
394 }
395
396 ixOsalCacheDmaFree(stack);
397 return gateways;
398}
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419IX_ETH_DB_PUBLIC
420IxEthDBStatus ixEthDBWiFiConversionTableDownload(IxEthDBPortId portID)
421{
422 IxEthDBPortMap query;
423 MacTreeNode *stations = NULL, *gateways = NULL, *gateway = NULL;
424 IxNpeMhMessage message;
425 PortInfo *portInfo;
426 IX_STATUS result;
427
428 IX_ETH_DB_CHECK_PORT(portID);
429
430 IX_ETH_DB_CHECK_SINGLE_NPE(portID);
431
432 IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
433
434 portInfo = &ixEthDBPortInfo[portID];
435
436 SET_DEPENDENCY_MAP(query, portID);
437
438 ixEthDBUpdateLock();
439
440 stations = ixEthDBQuery(NULL, query, IX_ETH_DB_WIFI_RECORD, MAX_ELT_SIZE);
441 gateways = ixEthDBGatewaySelect(stations);
442
443
444 memset((void *) portInfo->updateMethod.npeGwUpdateZone, FULL_GW_BYTE_SIZE, 0);
445
446
447 gateway = gateways;
448
449 while (gateway != NULL)
450 {
451 ixEthDBNPEGatewayNodeWrite((void *) (((UINT32) portInfo->updateMethod.npeGwUpdateZone)
452 + gateway->descriptor->recordData.wifiData.gwAddressIndex * ELT_ENTRY_SIZE),
453 gateway);
454
455 gateway = gateway->right;
456 }
457
458
459 if (gateways != NULL)
460 {
461 ixEthDBFreeMacTreeNode(gateways);
462 }
463
464 FILL_SETAPMACTABLE_MSG(message,
465 IX_OSAL_MMU_VIRT_TO_PHYS(portInfo->updateMethod.npeGwUpdateZone));
466
467 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
468
469 if (result == IX_SUCCESS)
470 {
471
472 portInfo->updateMethod.searchTree = stations;
473
474 result = ixEthDBNPEUpdateHandler(portID, IX_ETH_DB_WIFI_RECORD);
475 }
476
477 ixEthDBUpdateUnlock();
478
479 return result;
480}
481