source: SVN/cambria/redboot/packages/devs/eth/intel/npe/ethDB/current/src/IxEthDBWiFi.c @ 1

Last change on this file since 1 was 1, checked in by Tim Harvey, 2 years ago

restored latest version of files from server backup

Signed-off-by: Tim Harvey <tharvey@…>

File size: 25.2 KB
Line 
1/**
2 * @file IxEthDBAPI.c
3 *
4 * @brief Implementation of the public API
5 *
6 * @par
7 * IXP400 SW Release version 2.3
8 *
9 * -- Copyright Notice --
10 *
11 * @par
12 * Copyright (c) 2001-2005, Intel Corporation.
13 * All rights reserved.
14 *
15 * @par
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 *    notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 *    notice, this list of conditions and the following disclaimer in the
23 *    documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of the Intel Corporation nor the names of its contributors
25 *    may be used to endorse or promote products derived from this software
26 *    without specific prior written permission.
27 *
28 *
29 * @par
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 *
42 *
43 * @par
44 * -- End of Copyright Notice --
45 */
46
47#include "IxEthDB_p.h"
48
49/* forward prototypes */
50IX_ETH_DB_PRIVATE MacTreeNode *ixEthDBGatewaySelect(MacTreeNode *stations, UINT32 *gwCount);
51IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBWiFiEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr, IxEthDBWiFiRecData *wifiRecData);
52IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBDownloadGatewayTable (IxEthDBPortId portID, MacTreeNode *gateways);
53IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBDownloadBssidTable (IxEthDBPortId portID, MacTreeNode *bssids);
54IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBDuplicateAddressCheck(MacTreeNode *rootNode, MacTreeNode *currentNode, UINT32 *dgwIndexAddr);
55
56/* forward prototypes */
57IX_ETH_DB_PUBLIC MacTreeNode *ixEthDBGatewaySelect(MacTreeNode *stations, UINT32 *gwCount);
58
59/**
60 * @brief sets the BSSID value for the WiFi header conversion feature
61 *
62 * @param portID ID of the port
63 * @param bssid pointer to the 6-byte BSSID value
64 *
65 * Note that this function is documented in the main component
66 * header file, IxEthDB.h.
67 *
68 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
69 * or an appropriate error message otherwise
70 */
71IX_ETH_DB_PUBLIC
72IxEthDBStatus ixEthDBWiFiBSSIDSet(IxEthDBPortId portID, IxEthDBMacAddr *bssid)
73{
74    IX_ETH_DB_CHECK_PORT(portID);
75   
76    IX_ETH_DB_CHECK_SINGLE_NPE(portID);
77   
78    IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
79 
80    IX_ETH_DB_CHECK_REFERENCE(bssid);
81   
82    if (ixOsalMemCopy(ixEthDBPortInfo[portID].bssid, bssid, IX_IEEE803_MAC_ADDRESS_SIZE) == NULL)
83    {
84       return IX_ETH_DB_FAIL;
85    }
86
87    return IX_ETH_DB_SUCCESS;
88}
89
90/**
91 * @brief updates the Frame Control and Duration/ID WiFi header
92 * conversion parameters in an NPE
93 *
94 * @param portID ID of the port
95 *
96 * This function will send a message to the NPE updating the
97 * frame conversion parameters for 802.3 => 802.11 header conversion.
98 *
99 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
100 * or IX_ETH_DB_FAIL otherwise
101 *
102 * @internal
103 */
104IX_ETH_DB_PUBLIC
105IxEthDBStatus ixEthDBWiFiFrameControlDurationIDUpdate(IxEthDBPortId portID)
106{
107    IxNpeMhMessage message;
108    IX_STATUS result;
109
110    FILL_SETFRAMECONTROLDURATIONID(message, portID, ixEthDBPortInfo[portID].frameControlDurationID);
111   
112    IX_ETHDB_SEND_NPE_MSG(IX_ETHNPE_PHYSICAL_ID_TO_NODE(portID), message, result);
113   
114    return result;
115}
116
117/**
118 * @brief sets the Duration/ID WiFi frame header conversion parameter
119 *
120 * @param portID ID of the port
121 * @param durationID 16-bit value containing the new Duration/ID parameter
122 *
123 * Note that this function is documented in the main component
124 * header file, IxEthDB.h.
125 *
126 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
127 * or an appropriate error message otherwise
128 */
129IX_ETH_DB_PUBLIC
130IxEthDBStatus ixEthDBWiFiDurationIDSet(IxEthDBPortId portID, UINT16 durationID)
131{
132    IX_ETH_DB_CHECK_PORT(portID);
133   
134    IX_ETH_DB_CHECK_SINGLE_NPE(portID);
135   
136    IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
137
138    ixEthDBPortInfo[portID].frameControlDurationID = (ixEthDBPortInfo[portID].frameControlDurationID & 0xFFFF0000) | durationID;
139   
140    return ixEthDBWiFiFrameControlDurationIDUpdate(portID);
141}
142
143/**
144 * @brief sets the Frame Control WiFi frame header conversion parameter
145 *
146 * @param portID ID of the port
147 * @param durationID 16-bit value containing the new Frame Control parameter
148 *
149 * Note that this function is documented in the main component
150 * header file, IxEthDB.h.
151 *
152 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
153 * or an appropriate error message otherwise
154 */
155IX_ETH_DB_PUBLIC
156IxEthDBStatus ixEthDBWiFiFrameControlSet(IxEthDBPortId portID, UINT16 frameControl)
157{
158    IX_ETH_DB_CHECK_PORT(portID);
159   
160    IX_ETH_DB_CHECK_SINGLE_NPE(portID);
161   
162    IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
163
164    ixEthDBPortInfo[portID].frameControlDurationID = (ixEthDBPortInfo[portID].frameControlDurationID & 0xFFFF) | (frameControl << 16); 
165   
166    return ixEthDBWiFiFrameControlDurationIDUpdate(portID);
167}
168
169/**
170 * @brief removes a WiFi header conversion record
171 *
172 * @param portID ID of the port
173 * @param macAddr MAC address of the record to remove
174 *
175 * Note that this function is documented in the main
176 * component header file, IxEthDB.h.
177 *
178 * @return IX_ETH_DB_SUCCESS if the operation completed
179 * successfully or an appropriate error message otherwise
180 */
181IX_ETH_DB_PUBLIC
182IxEthDBStatus ixEthDBWiFiEntryRemove(IxEthDBPortId portID, IxEthDBMacAddr *macAddr)
183{
184    MacDescriptor recordTemplate;
185   
186    IX_ETH_DB_CHECK_PORT(portID);
187   
188    IX_ETH_DB_CHECK_SINGLE_NPE(portID);
189   
190    IX_ETH_DB_CHECK_REFERENCE(macAddr);
191   
192    IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
193   
194    ixOsalMemCopy(recordTemplate.macAddress, macAddr, IX_IEEE803_MAC_ADDRESS_SIZE);
195   
196    recordTemplate.type   = IX_ETH_DB_WIFI_RECORD;
197    recordTemplate.portID = portID;
198   
199    return ixEthDBRemove(&recordTemplate, NULL);
200}
201
202/**
203 * @brief adds a WiFi header conversion record
204 *
205 * @param portID ID of the port
206 * @param macAddr MAC address of the record to add
207 * @param wifiRecData pointer to the wifi specific data (flags, gw etc.)
208 * (GW address is NULL if this is a station record)
209 *
210 * This function adds a record of type AP_TO_AP (gateway is not NULL)
211 * or AP_TO_STA (gateway is NULL) in the main database as a
212 * WiFi header conversion record.
213 *
214 * @return IX_ETH_DB_SUCCESS if the operation completed
215 * successfully or an appropriate error message otherwise
216 *
217 * @internal
218 */
219IX_ETH_DB_PRIVATE
220IxEthDBStatus ixEthDBWiFiEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr, IxEthDBWiFiRecData *wifiRecData)
221{
222    MacDescriptor recordTemplate;
223    IxEthDBPortMap query;
224    MacTreeNode *stations = NULL;
225    MacTreeNode *gateways = NULL;
226    PortInfo *portInfo;
227    UINT32 gatewayCount = 1;
228
229    IX_ETH_DB_CHECK_REFERENCE(wifiRecData);
230
231    IX_ETH_DB_CHECK_REC_TYPE(wifiRecData->recType);
232
233    IX_ETH_DB_CHECK_ODD_PAD(wifiRecData->padLength);
234
235    IX_ETH_DB_CHECK_PAD_LENGTH(wifiRecData->padLength);
236
237    IX_ETH_DB_CHECK_LOG_PORT(wifiRecData->logicalPortID);
238
239    IX_ETH_DB_CHECK_WIFI_VLAN_TAG(wifiRecData->vlanTagFlag);
240
241    if (wifiRecData->recType != IX_ETH_DB_WIFI_TO_ETHER && wifiRecData->recType != IX_ETH_DB_WIFI_TO_LOCAL)
242    {
243        IX_ETH_DB_CHECK_ADDR(wifiRecData->bssid);
244
245        if (wifiRecData->recType == IX_ETH_DB_WIFI_AP_TO_AP)
246        {
247            IX_ETH_DB_CHECK_ADDR(wifiRecData->gatewayMacAddr);
248        }
249    }
250
251    portInfo = &ixEthDBPortInfo[portID];
252
253    if (portInfo->wifiRecordsCount >= MAX_ELT_SIZE)
254    {
255        ERROR_LOG("DB: In ixEthDBWiFiEntryAdd(): Exceeded the maximum limit of wi-fi records\n");
256        return IX_ETH_DB_FAIL;
257    }
258
259    if (wifiRecData->recType == IX_ETH_DB_WIFI_AP_TO_STA || wifiRecData->recType == IX_ETH_DB_WIFI_AP_TO_AP)
260    {
261        /* Check that the number of Wifi records do not exceed the maximum capacity */
262        SET_DEPENDENCY_MAP(query, portID);
263
264        stations = ixEthDBQuery(NULL, query, IX_ETH_DB_WIFI_RECORD, MAX_ELT_SIZE);
265        gateways = ixEthDBGatewaySelect(stations, &gatewayCount);
266
267        if (stations != NULL)
268            ixEthDBFreeMacTreeNode(stations);
269
270        if (gateways != NULL)
271            ixEthDBFreeMacTreeNode(gateways);
272
273        if (gatewayCount >= MAX_GW_SIZE)
274        {
275           ERROR_LOG("DB: In ixEthDBWiFiEntryAdd(): Exceeded maximum limit of gateway entries\n");
276           return IX_ETH_DB_FAIL;
277        }
278
279        if (wifiRecData->recType == IX_ETH_DB_WIFI_AP_TO_AP)
280        {
281           ixOsalMemCopy(recordTemplate.recordData.wifiData.gwMacAddress, wifiRecData->gatewayMacAddr, IX_IEEE803_MAC_ADDRESS_SIZE);
282        }
283        else
284        {
285           ixOsalMemSet(recordTemplate.recordData.wifiData.gwMacAddress, 0, IX_IEEE803_MAC_ADDRESS_SIZE);
286        }
287
288        ixOsalMemCopy(recordTemplate.recordData.wifiData.bssid, wifiRecData->bssid, IX_IEEE803_MAC_ADDRESS_SIZE);
289        recordTemplate.recordData.wifiData.recType = (wifiRecData->recType | (wifiRecData->vlanTagFlag <<2));
290    }
291    else
292    {
293        ixOsalMemSet(recordTemplate.recordData.wifiData.gwMacAddress, 0, IX_IEEE803_MAC_ADDRESS_SIZE);
294        ixOsalMemSet(recordTemplate.recordData.wifiData.bssid, 0, IX_IEEE803_MAC_ADDRESS_SIZE);
295        recordTemplate.recordData.wifiData.recType = (wifiRecData->recType | (0 <<2));
296    }
297
298    ixOsalMemCopy(recordTemplate.macAddress, macAddr, IX_IEEE803_MAC_ADDRESS_SIZE);
299
300    recordTemplate.type   = IX_ETH_DB_WIFI_RECORD;
301    recordTemplate.portID = portID;
302
303    /* This value will be overwritten for AP and STA cases later */
304    recordTemplate.recordData.wifiData.recIndex = portID;
305
306    /* Divide pad length by 2 because we have only 4 bits to store the value 16 */
307    recordTemplate.recordData.wifiData.padLength     = (wifiRecData->padLength)/2;
308    recordTemplate.recordData.wifiData.logicalPortID = wifiRecData->logicalPortID;
309
310    return ixEthDBAdd(&recordTemplate, NULL);
311}
312
313/**
314 * @brief sets the BSSID/GW/Flag values in the WiFi header conversion table
315 *
316 * @param portID ID of the port
317 * @param macAddr MAC address of the record to add
318 * @param wifiRecData pointer to the wifi specific data (flags, gw, bssid etc.)
319 *
320 * Note that this function is documented in the main component
321 * header file, IxEthDB.h.
322 *
323 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
324 * or an appropriate error message otherwise
325 */
326IX_ETH_DB_PUBLIC
327IxEthDBStatus ixEthDBWiFiRecordEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr, IxEthDBWiFiRecData *wifiRecData)
328{
329    IX_ETH_DB_CHECK_PORT(portID);
330
331    IX_ETH_DB_CHECK_SINGLE_NPE(portID);
332
333    IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
334
335    IX_ETH_DB_CHECK_REFERENCE(macAddr);
336   
337    return ixEthDBWiFiEntryAdd(portID, macAddr, wifiRecData);
338}
339
340/**
341 * @brief adds a WiFi header conversion record
342 *
343 * @param portID ID of the port
344 * @param macAddr MAC address of the record to add
345 * @param gatewayMacAddr address of the gateway
346 *
347 * This function adds a record of type AP_TO_AP
348 * in the main database as a WiFi header conversion record.
349 *
350 * This is simply a wrapper over @ref ixEthDBWiFiEntryAdd().
351 *
352 * Note that this function is documented in the main
353 * component header file, IxEthDB.h.
354 *
355 * @return IX_ETH_DB_SUCCESS if the operation completed
356 * successfully or an appropriate error message otherwise
357 */
358IX_ETH_DB_PUBLIC
359IxEthDBStatus ixEthDBWiFiAccessPointEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr, IxEthDBMacAddr *gatewayMacAddr)
360{
361    IxEthDBWiFiRecData wifiRecData;
362    PortInfo *portInfo;
363
364    IX_ETH_DB_CHECK_PORT(portID);
365
366    IX_ETH_DB_CHECK_SINGLE_NPE(portID);
367
368    IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
369
370    IX_ETH_DB_CHECK_REFERENCE(macAddr);
371   
372    IX_ETH_DB_CHECK_REFERENCE(gatewayMacAddr);
373
374    portInfo = &ixEthDBPortInfo[portID];
375
376    IX_ETH_DB_CHECK_ADDR(portInfo->bssid);
377
378    ixOsalMemCopy(wifiRecData.bssid, portInfo->bssid, IX_IEEE803_MAC_ADDRESS_SIZE);
379    ixOsalMemCopy(wifiRecData.gatewayMacAddr, gatewayMacAddr, IX_IEEE803_MAC_ADDRESS_SIZE);
380
381    wifiRecData.recType = IX_ETH_DB_WIFI_AP_TO_AP;
382    wifiRecData.vlanTagFlag = IX_ETH_DB_WIFI_VLAN_NOTAG;
383    wifiRecData.padLength = IX_ETH_DB_WIFI_MIN_PAD_SIZE;
384    wifiRecData.logicalPortID = 0xFF;
385
386    return ixEthDBWiFiEntryAdd(portID, macAddr, &wifiRecData);
387}
388
389/**
390 * @brief adds a WiFi header conversion record
391 *
392 * @param portID ID of the port
393 * @param macAddr MAC address of the record to add
394 *
395 * This function adds a record of type AP_TO_STA
396 * in the main database as a WiFi header conversion record.
397 *
398 * This is simply a wrapper over @ref ixEthDBWiFiEntryAdd().
399 *
400 * Note that this function is documented in the main
401 * component header file, IxEthDB.h.
402 *
403 * @return IX_ETH_DB_SUCCESS if the operation completed
404 * successfully or an appropriate error message otherwise
405 */
406IX_ETH_DB_PUBLIC
407IxEthDBStatus ixEthDBWiFiStationEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr)
408{
409    IxEthDBWiFiRecData wifiRecData;
410    PortInfo *portInfo;
411
412    IX_ETH_DB_CHECK_PORT(portID);
413
414    IX_ETH_DB_CHECK_SINGLE_NPE(portID);
415
416    IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
417
418    IX_ETH_DB_CHECK_REFERENCE(macAddr);
419   
420    portInfo = &ixEthDBPortInfo[portID];
421
422    IX_ETH_DB_CHECK_ADDR(portInfo->bssid);
423
424    ixOsalMemCopy(wifiRecData.bssid, portInfo->bssid, IX_IEEE803_MAC_ADDRESS_SIZE);
425    ixOsalMemSet(wifiRecData.gatewayMacAddr, 0, IX_IEEE803_MAC_ADDRESS_SIZE);
426
427    wifiRecData.recType = IX_ETH_DB_WIFI_AP_TO_STA;
428    wifiRecData.vlanTagFlag = IX_ETH_DB_WIFI_VLAN_NOTAG;
429    wifiRecData.padLength = IX_ETH_DB_WIFI_MIN_PAD_SIZE;
430    wifiRecData.logicalPortID = 0xFF;
431
432    return ixEthDBWiFiEntryAdd(portID, macAddr, &wifiRecData);
433}
434
435/**
436 * @brief selects a set of gateways and stations from a tree of
437 * WiFi header conversion records
438 *
439 * @param stations binary tree containing pointers to WiFi header
440 * conversion records
441 *
442 * This function browses through the input binary tree, identifies
443 * records of type AP_TO_AP and AP_TO_STA, clones these records and
444 * appends them to a vine (a single right-branch binary tree) which
445 * is returned as result. A maximum of MAX_GW_SIZE entries containing
446 * gateways and bssids will be cloned from the original tree.
447 *
448 * @return vine (linear binary tree) containing record
449 * clones of AP_TO_AP and AP_TO_STA types, which have a gateway field
450 * and bssid filed
451 *
452 * @internal
453 */
454IX_ETH_DB_PUBLIC
455MacTreeNode *ixEthDBGatewaySelect(MacTreeNode *stations, UINT32 *gwCount)
456{
457    MacTreeNodeStack *stack;
458    MacTreeNode *gateways, *insertionPlace;
459    UINT32 gwIndex = 1; /* skip the empty root */
460    IxEthDBStatus matchResult = IX_ETH_DB_FAIL;
461   
462    if (stations == NULL)
463    {
464        return NULL;
465    }
466
467    stack = ixOsalCacheDmaMalloc(sizeof (MacTreeNodeStack));
468
469    if (stack == NULL)
470    {
471        ERROR_LOG("DB: (WiFi) failed to allocate the node stack for gateway tree linearization, out of memory?\n");
472        return NULL;
473    }
474   
475    /* initialize root node */
476    gateways = insertionPlace = NULL;
477       
478    /* start browsing the station tree */
479    NODE_STACK_INIT(stack);
480   
481    /* initialize stack by pushing the tree root at offset 0 */
482    NODE_STACK_PUSH(stack, stations, 0);
483   
484    while (NODE_STACK_NONEMPTY(stack))
485    {
486        MacTreeNode *node;
487        UINT32 offset, dgwIndex;
488       
489        NODE_STACK_POP(stack, node, offset);
490
491        /* we can store maximum 40 (40 total, 1 empty root) entries in the gateway tree */
492        if (gwIndex > MAX_GW_SIZE) break;
493       
494        /* check if this record has a valid BSSID address */
495        if (node->descriptor != NULL && ((node->descriptor->recordData.wifiData.recType & 0x03) == IX_ETH_DB_WIFI_AP_TO_AP
496                                      || (node->descriptor->recordData.wifiData.recType & 0x03) == IX_ETH_DB_WIFI_AP_TO_STA))
497        {
498            /* found a record, create an insertion place */
499            if (insertionPlace != NULL)
500            {
501                matchResult = ixEthDBDuplicateAddressCheck(gateways, node, &dgwIndex);
502
503                if (matchResult != IX_ETH_DB_SUCCESS)
504                {
505                   /* Not a duplicate node, add a node into the tree */
506                   insertionPlace->right = ixEthDBAllocMacTreeNode();
507                   insertionPlace        = insertionPlace->right;
508                }
509                else
510                {
511                   /* Address already exists in the tree, update the same index in the original record */
512                   node->descriptor->recordData.wifiData.recIndex = dgwIndex;
513                }
514            }
515            else
516            {
517                /* Add first node into the tree */
518                gateways       = ixEthDBAllocMacTreeNode();
519                insertionPlace = gateways;
520            }
521
522            if (insertionPlace == NULL)
523            {
524                /* no nodes left, bail out with what we have */
525                ixOsalCacheDmaFree(stack);
526                return gateways;
527            }
528           
529            if (matchResult != IX_ETH_DB_SUCCESS)
530            {
531                /* clone the original record for the gateway tree */
532                insertionPlace->descriptor = ixEthDBCloneMacDescriptor(node->descriptor);
533
534                /* insert and update the offset in the original record */
535                /* NPE expects index = [0,39], we need to offset gwIndex by one
536                 * to fit the NPE's indexing
537                 */ 
538                node->descriptor->recordData.wifiData.recIndex = gwIndex-1;
539                (*gwCount) = gwIndex;
540                gwIndex = gwIndex+1;
541            }
542        }
543       
544        /* browse the tree */
545        if (node->left != NULL)
546        {
547            NODE_STACK_PUSH(stack, node->left, LEFT_CHILD_OFFSET(offset));
548        }
549
550        if (node->right != NULL)
551        {
552            NODE_STACK_PUSH(stack, node->right, RIGHT_CHILD_OFFSET(offset));
553        }
554    }
555   
556    ixOsalCacheDmaFree(stack);
557    return gateways;   
558}
559
560/**
561 * @brief duplicate gateway and bssid entries in the wi-fi record table checking function
562 *
563 * @param rootNode address of the root node gateway/bssid tree (1:1 mapped)
564 * @param currentNode node to be searched in the gateway/bssid tree
565 * @param dgwIndexAddr of a matched entry(duplicate) to update the index field of the main table
566 *
567 * This function browses through the input binary gateway/bssid tree, identifies
568 * duplicate record and returns SUCCESS if the match founf in the tree else
569 * returns a FAIL if matching address not found in the tree.
570 *
571 * @return IX_ETH_DB_SUCCESS if the operation completed
572 * successfully or else IX_ETH_DB_FAIL
573 *
574 * @internal
575 */
576IX_ETH_DB_PRIVATE
577IxEthDBStatus ixEthDBDuplicateAddressCheck(MacTreeNode *rootNode, MacTreeNode *currentNode, UINT32 *dgwIndexAddr)
578{
579   MacTreeNode *wifiTree = NULL;
580
581   wifiTree = rootNode;
582
583   while (wifiTree != NULL)
584   {
585      if (currentNode->descriptor->recordData.wifiData.recType == IX_ETH_DB_WIFI_AP_TO_STA)
586      {
587         if (ixEthDBAddressCompare(wifiTree->descriptor->recordData.wifiData.bssid,
588                currentNode->descriptor->recordData.wifiData.bssid)==0)
589         {
590             (*dgwIndexAddr) = wifiTree->descriptor->recordData.wifiData.recIndex;
591             return IX_ETH_DB_SUCCESS;
592         }
593      }
594      else
595      {
596         if ((ixEthDBAddressCompare(wifiTree->descriptor->recordData.wifiData.bssid,
597                                    currentNode->descriptor->recordData.wifiData.bssid)==0) &&
598             (ixEthDBAddressCompare(wifiTree->descriptor->recordData.wifiData.gwMacAddress,
599                                    currentNode->descriptor->recordData.wifiData.gwMacAddress)==0))
600         {
601             (*dgwIndexAddr) = wifiTree->descriptor->recordData.wifiData.recIndex;
602             return IX_ETH_DB_SUCCESS;
603         }
604
605      }
606      wifiTree = wifiTree->right;
607   }
608
609   return IX_ETH_DB_FAIL;
610}
611
612/**
613 * @brief downloads the WiFi header conversion GW table to an NPE
614 *
615 * @param portID ID of the port
616 * @param gateways MAC addresses
617 *
618 * This function prepares the WiFi header conversion GW tables and
619 * downloads them to the specified NPE port.
620 *
621 * The header conversion tables consist in the main table of
622 * addresses and the secondary table of gateways. AP_TO_AP records
623 * from the first table contain index fields into the second table
624 * for gateway selection. But AP_TO_STA contains NULL
625 *
626 * Note that this function is documented in the main component
627 * header file, IxEthDB.h.
628 *
629 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
630 * or an appropriate error message otherwise
631 */
632IX_ETH_DB_PRIVATE
633IxEthDBStatus ixEthDBDownloadGatewayTable (IxEthDBPortId portID, MacTreeNode *gateways)
634{
635    MacTreeNode *gateway = NULL;
636    IxNpeMhMessage message;
637    PortInfo *portInfo;
638    IX_STATUS result;
639
640    portInfo = &ixEthDBPortInfo[portID];
641
642    ixOsalMemSet((void *) portInfo->updateMethod.npeGwUpdateZone, 0, FULL_GW_BYTE_SIZE);
643
644    /* write all gateways */
645    gateway = gateways;
646
647    while (gateway != NULL)
648    {
649        ixEthDBNPEGatewayNodeWrite(gateway, portInfo->updateMethod.npeGwUpdateZone,
650            gateway->descriptor->recordData.wifiData.recIndex, FULL_GW_BYTE_SIZE);
651
652        gateway = gateway->right;
653    }
654
655    FILL_SETAPMACTABLE_MSG(message,
656        IX_OSAL_MMU_VIRT_TO_PHYS(portInfo->updateMethod.npeGwUpdateZone));
657
658    IX_ETHDB_SEND_NPE_MSG(IX_ETHNPE_PHYSICAL_ID_TO_NODE(portID), message, result);
659
660    return result;
661}
662
663/**
664 * @brief downloads the WiFi header conversion bssid table to an NPE
665 *
666 * @param portID ID of the port
667 * @param bssids - AP MAC addresses
668 *
669 * This function prepares the WiFi header conversion bssid tables and
670 * downloads them to the specified NPE port.
671 *
672 * The header conversion tables consist in the main table of
673 * addresses and the secondary table of bssids. AP_TO_AP and AP_TO_STA
674 * records from the first table contain index fields into the second table
675 * for bssid selection.
676 *
677 * Note that this function is documented in the main component
678 * header file, IxEthDB.h.
679 *
680 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
681 * or an appropriate error message otherwise
682 */
683IX_ETH_DB_PRIVATE
684IxEthDBStatus ixEthDBDownloadBssidTable (IxEthDBPortId portID, MacTreeNode *bssids)
685{
686    MacTreeNode *bssid = NULL;
687    IxNpeMhMessage message;
688    PortInfo *portInfo;
689    IX_STATUS result;
690
691    portInfo = &ixEthDBPortInfo[portID];
692
693    ixOsalMemSet((void *) portInfo->updateMethod.npeBssidUpdateZone, 0, FULL_BSSID_BYTE_SIZE);
694
695    /* write all gateways */
696    bssid = bssids;
697
698    while (bssid != NULL)
699    { 
700        ixEthDBNPEBssidNodeWrite(bssid, portInfo->updateMethod.npeBssidUpdateZone,
701            bssid->descriptor->recordData.wifiData.recIndex, FULL_BSSID_BYTE_SIZE);
702
703        bssid = bssid->right;
704    }
705
706    FILL_SETBSSIDTABLE_MSG(message,
707        IX_OSAL_MMU_VIRT_TO_PHYS(portInfo->updateMethod.npeBssidUpdateZone));
708
709    IX_ETHDB_SEND_NPE_MSG(IX_ETHNPE_PHYSICAL_ID_TO_NODE(portID), message, result);
710
711    return result;
712}
713
714/**
715 * @brief downloads the WiFi header conversion table to an NPE
716 *
717 * @param portID ID of the port
718 *
719 * This function prepares the WiFi header conversion tables and
720 * downloads them to the specified NPE port.
721 *
722 * The header conversion tables consist in the main table of
723 * addresses and the secondary table of gateways and BSSIDs. Records
724 * from the first table contain index fields into the second table
725 * for gateway selection.This index is same for both GW & BSSID tables.
726 *
727 * Note that this function is documented in the main component
728 * header file, IxEthDB.h.
729 *
730 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
731 * or an appropriate error message otherwise
732 */
733IX_ETH_DB_PUBLIC
734IxEthDBStatus ixEthDBWiFiConversionTableDownload(IxEthDBPortId portID)
735{
736    IxEthDBPortMap query;
737    MacTreeNode *stations = NULL;
738    MacTreeNode *gateways = NULL;
739    PortInfo *portInfo;
740    IX_STATUS result;
741    UINT32 dummy;
742
743    IX_ETH_DB_CHECK_PORT(portID);
744
745    IX_ETH_DB_CHECK_SINGLE_NPE(portID);
746
747    IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
748
749    portInfo = &ixEthDBPortInfo[portID];
750
751    SET_DEPENDENCY_MAP(query, portID);
752
753    ixEthDBUpdateLock();
754
755    stations = ixEthDBQuery(NULL, query, IX_ETH_DB_WIFI_RECORD, MAX_ELT_SIZE);
756    gateways = ixEthDBGatewaySelect(stations, &dummy);
757
758    result = ixEthDBDownloadGatewayTable (portID, gateways);
759
760    if (result == IX_SUCCESS)
761    {
762        result = ixEthDBDownloadBssidTable (portID, gateways);
763    }
764
765    /* free the gateways tree */
766    if (gateways != NULL)
767    {
768        ixEthDBFreeMacTreeNode(gateways);
769    }
770
771    if (result == IX_SUCCESS)
772    {
773        /* update the main tree (the stations tree) */
774        portInfo->updateMethod.searchTree = stations;
775
776        result = ixEthDBNPEUpdateHandler(portID, IX_ETH_DB_WIFI_RECORD);
777    }
778
779    ixEthDBUpdateUnlock();
780
781    return result;
782}
783
Note: See TracBrowser for help on using the repository browser.