source: SVN/cambria/redboot/packages/devs/eth/intel/npe/ethDB/current/src/IxEthDBFeatures.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: 31.1 KB
Line 
1/**
2 * @file IxEthDBFeatures.c
3 *
4 * @brief Implementation of the EthDB feature control 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 "IxNpeDl.h"
48#include "IxEthDBQoS.h"
49#include "IxEthDB_p.h"
50
51/**
52 * @brief Port definitions structure, indexed on the port ID
53 * @warning Ports 0 and 1 are used by the Ethernet access component therefore
54 * it is essential to be left untouched. Port 2 can be Ethernet Port or
55 * WAN port. Port 3 here (WAN) is given as an example port. The NPE firmware
56 * also assumes the NPE B to be the port 0, NPE C to be the port 1, and
57 * NPE A to be port 2.
58 *
59 * @note that only 32 ports (0..31) are supported by EthDB
60 */
61IxEthDBPortDefinition ixEthDBPortDefinitions[IX_ETH_DB_NUMBER_OF_PORTS] = 
62{
63    /*    id       type              capabilities */
64    {   /* 0 */    IX_ETH_NPE,       IX_ETH_NO_CAPABILITIES },    /* Ethernet NPE B */
65    {   /* 1 */    IX_ETH_NPE,       IX_ETH_NO_CAPABILITIES },    /* Ethernet NPE C */
66    {   /* 2 */    IX_ETH_NPE,       IX_ETH_NO_CAPABILITIES }     /* Ethernet NPE A or WAN Port */
67};
68
69/**
70 * @brief scans the capabilities of the loaded NPE images
71 *
72 * This function MUST be called by the ixEthDBInit() function.
73 * No EthDB features (including learning and filtering) are enabled
74 * before this function is called.
75 *
76 * @return none
77 *
78 * @internal
79 */
80IX_ETH_DB_PUBLIC
81void ixEthDBFeatureCapabilityScan(void)
82{
83    UINT8 functionalityId, npeAFunctionalityId;
84    IxEthDBPortId portIndex;
85    PortInfo *portInfo;
86    IxEthDBPriorityTable defaultPriorityTable;
87    IX_STATUS result;
88    UINT32 queueIndex;
89    UINT32 queueStructureIndex;
90    UINT32 trafficClassDefinitionIndex, totalTrafficClass;
91
92    totalTrafficClass = sizeof (ixEthDBTrafficClassDefinitions) / sizeof (ixEthDBTrafficClassDefinitions[0]);
93
94    /* ensure there's at least 2 traffic class records in the definition table, otherwise we have no default cases, hence no queues */
95    IX_ENSURE(totalTrafficClass >= 2, 
96        "DB: no traffic class definitions found, check IxEthDBQoS.h");
97
98    /* read version of NPE A - required to set the AQM queues for B and C */
99    npeAFunctionalityId = 0;
100
101    if(IX_FAIL == ixNpeDlLoadedImageFunctionalityGet(IX_NPEDL_NPEID_NPEA, &npeAFunctionalityId))
102    {
103        /* IX_FAIL is returned when there is no image loaded in NPEA.  Then we can use all 8 queues */
104        trafficClassDefinitionIndex = 1; /* the second record is the default if no image loaded */
105    } 
106    else 
107    {
108        /* find the traffic class definition index compatible with the current NPE A functionality ID */
109        for (trafficClassDefinitionIndex = 0 ; 
110             trafficClassDefinitionIndex < totalTrafficClass ;
111             trafficClassDefinitionIndex++)
112        {
113            if (ixEthDBTrafficClassDefinitions[trafficClassDefinitionIndex][IX_ETH_DB_NPE_A_FUNCTIONALITY_ID_INDEX] == npeAFunctionalityId)
114            {
115                /* found it */
116                break;
117            }
118        }
119
120        /* select the default case if we went over the array boundary */
121        if (trafficClassDefinitionIndex == totalTrafficClass)
122        {
123            trafficClassDefinitionIndex = 0; /* the first record is the default case */
124        }
125    }
126
127    /* To decide port definition for NPE A - IX_ETH_NPE or IX_ETH_GENERIC
128       IX_ETH_NPE will be set for NPE A when the functionality id is ranged from 0x80 to 0x8F
129       and ethernet + hss co-exists images range from 0x90 to 0x9F. For the rest of functionality
130       Ids, the port type will be set to IX_ETH_GENERIC. */
131    if ((npeAFunctionalityId & 0xF0) != 0x80 && (npeAFunctionalityId & 0xF0) != 0x90)
132    {
133        /* NPEA is not Ethernet capable. Override default port definition */
134        ixEthDBPortDefinitions[IX_NPEA_PORT].type = IX_ETH_GENERIC;
135    }
136
137    /* select queue assignment structure based on the traffic class configuration index */
138    queueStructureIndex = ixEthDBTrafficClassDefinitions[trafficClassDefinitionIndex][IX_ETH_DB_QUEUE_ASSIGNMENT_INDEX];
139
140    for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++)
141    {
142        IxNpeMhMessage msg;
143
144        portInfo = &ixEthDBPortInfo[portIndex];
145
146        /* check and bypass if NPE A, B or C is fused out */
147        if (ixEthDBSingleEthNpeCheck(portIndex) != IX_ETH_DB_SUCCESS) continue;
148       
149        /* all ports are capable of LEARNING by default */
150        portInfo->featureCapability = IX_ETH_DB_LEARNING;
151        portInfo->featureStatus     = IX_ETH_DB_LEARNING;
152
153        if (ixEthDBPortDefinitions[portIndex].type == IX_ETH_NPE)
154        {
155
156            if (IX_SUCCESS != ixNpeDlLoadedImageFunctionalityGet(IX_ETHNPE_PHYSICAL_ID_TO_NODE(portIndex), &functionalityId))
157            {
158                WARNING_LOG("DB: (FeatureScan) NpeDl did not provide the image ID for NPE port %d\n", portIndex);
159            }
160            else
161            {
162                /* initialize and empty NPE response mutex */
163                ixOsalMutexInit(&portInfo->npeAckLock);
164
165                /* check NPE response to GetStatus */
166                msg.data[0] = IX_ETHNPE_NPE_GETSTATUS << 24;
167                msg.data[1] = 0;
168                IX_ETHDB_SEND_NPE_MSG(IX_ETHNPE_PHYSICAL_ID_TO_NODE(portIndex), msg, result);
169                if (result != IX_SUCCESS)
170                {
171                    WARNING_LOG("DB: (FeatureScan) warning, %d port could not send message to the NPE\n", portIndex);
172                    continue;
173                }
174
175                if (functionalityId == 0x00
176                    || functionalityId == 0x03
177                    || functionalityId == 0x04
178                    || functionalityId == 0x80)
179                {
180                    portInfo->featureCapability |= IX_ETH_DB_FILTERING;
181                    portInfo->featureCapability |= IX_ETH_DB_FIREWALL;
182                    portInfo->featureCapability |= IX_ETH_DB_SPANNING_TREE_PROTOCOL;
183                }
184                else if (functionalityId == 0x01
185                         || functionalityId == 0x81
186                         || functionalityId == 0x0B
187                         || functionalityId == 0x8B
188                         || functionalityId == 0x90)
189                {
190                    portInfo->featureCapability |= IX_ETH_DB_FILTERING;
191                    portInfo->featureCapability |= IX_ETH_DB_FIREWALL;
192                    portInfo->featureCapability |= IX_ETH_DB_SPANNING_TREE_PROTOCOL;
193                    portInfo->featureCapability |= IX_ETH_DB_VLAN_QOS;
194                }
195                else if (functionalityId == 0x02
196                         || functionalityId == 0x82
197                         || functionalityId == 0x0D
198                         || functionalityId == 0x8D
199                         || functionalityId == 0x91)
200                {
201                    portInfo->featureCapability |= IX_ETH_DB_WIFI_HEADER_CONVERSION;
202                    portInfo->featureCapability |= IX_ETH_DB_FIREWALL;
203                    portInfo->featureCapability |= IX_ETH_DB_SPANNING_TREE_PROTOCOL;
204                    portInfo->featureCapability |= IX_ETH_DB_VLAN_QOS;
205                }
206                else if (functionalityId == 0x0C
207                         || functionalityId == 0x8C)
208                {
209                    portInfo->featureCapability |= IX_ETH_DB_WIFI_HEADER_CONVERSION;
210                    portInfo->featureCapability |= IX_ETH_DB_SPANNING_TREE_PROTOCOL;
211                    portInfo->featureCapability |= IX_ETH_DB_VLAN_QOS;
212                }
213
214                /* check if image supports mask based firewall */
215                if (functionalityId == 0x0B
216                    || functionalityId == 0x8B
217                    || functionalityId == 0x0D
218                    || functionalityId == 0x8D
219                    || functionalityId == 0x90
220                    || functionalityId == 0x91)
221                {
222                    /* this feature is always on and is based on the NPE */
223                    portInfo->featureStatus |= IX_ETH_DB_ADDRESS_MASKING;
224                    portInfo->featureCapability |= IX_ETH_DB_ADDRESS_MASKING;
225                }
226
227                /* reset AQM queues */
228                ixOsalMemSet(portInfo->ixEthDBTrafficClassAQMAssignments, 0, sizeof (portInfo->ixEthDBTrafficClassAQMAssignments));
229
230                /* only traffic class 0 is active at initialization time */
231                portInfo->ixEthDBTrafficClassCount = 1;
232
233                /* enable port, VLAN and Firewall feature bits to initialize QoS/VLAN/Firewall configuration */
234                portInfo->featureStatus |= IX_ETH_DB_VLAN_QOS;
235                portInfo->featureStatus |= IX_ETH_DB_FIREWALL;
236                portInfo->enabled        = TRUE;
237
238                /* set VLAN initial configuration (permissive) */
239                if ((portInfo->featureCapability & IX_ETH_DB_VLAN_QOS) != 0) /* QoS-enabled image */
240                {
241                    /* QoS capable */
242                    portInfo->ixEthDBTrafficClassAvailable = ixEthDBTrafficClassDefinitions[trafficClassDefinitionIndex][IX_ETH_DB_TRAFFIC_CLASS_COUNT_INDEX];
243
244                    /* set AQM queues */
245                    for (queueIndex = 0 ; queueIndex < IX_IEEE802_1Q_QOS_PRIORITY_COUNT ; queueIndex++)
246                    {
247                        portInfo->ixEthDBTrafficClassAQMAssignments[queueIndex] = ixEthDBQueueAssignments[queueStructureIndex][queueIndex];
248                    }
249
250                    /* set default PVID (0) and default traffic class 0 */
251                    ixEthDBPortVlanTagSet(portIndex, 0);
252
253                    /* enable reception of all frames */
254                    ixEthDBAcceptableFrameTypeSet(portIndex, IX_ETH_DB_ACCEPT_ALL_FRAMES);
255
256                    /* clear full VLAN membership */
257                    ixEthDBPortVlanMembershipRangeRemove(portIndex, 0, IX_ETH_DB_802_1Q_MAX_VLAN_ID);
258
259                    /* clear TTI table - no VLAN tagged frames will be transmitted */
260                    ixEthDBEgressVlanRangeTaggingEnabledSet(portIndex, 0, 4094, FALSE);
261
262                    /* set membership on 0, otherwise no Tx or Rx is working */
263                    ixEthDBPortVlanMembershipAdd(portIndex, 0);
264                }
265                else /* QoS not available in this image */
266                {
267                    /* initialize traffic class availability (only class 0 is available) */
268                    portInfo->ixEthDBTrafficClassAvailable = 1;
269
270                    /* point all AQM queues to traffic class 0 */
271                    for (queueIndex = 0 ; queueIndex < IX_IEEE802_1Q_QOS_PRIORITY_COUNT ; queueIndex++)
272                    {
273                        portInfo->ixEthDBTrafficClassAQMAssignments[queueIndex] = 
274                            ixEthDBQueueAssignments[queueStructureIndex][0];
275                    }
276                }
277
278                /* download priority mapping table and Rx queue configuration */
279                ixOsalMemSet (defaultPriorityTable, 0, sizeof (defaultPriorityTable));
280                ixEthDBPriorityMappingTableSet(portIndex, defaultPriorityTable);
281
282                /* by default we turn off invalid source MAC address filtering */
283                ixEthDBFirewallInvalidAddressFilterEnable(portIndex, FALSE);
284
285                /* Notify VLAN tagging is disabled */
286                if (ixEthDBIngressVlanTaggingEnabledSet(portIndex, IX_ETH_DB_DISABLE_VLAN)
287                    != IX_SUCCESS)
288                {
289                  WARNING_LOG("DB: (FeatureScan) warning, %d port could not disable VLAN \n", portIndex);
290                  continue;               
291                }
292
293                /* disable port, VLAN, Firewall feature bits */
294                portInfo->featureStatus &= ~IX_ETH_DB_VLAN_QOS;
295                portInfo->featureStatus &= ~IX_ETH_DB_FIREWALL;
296                portInfo->enabled        = FALSE;
297
298                /* enable filtering by default if present */
299                if ((portInfo->featureCapability & IX_ETH_DB_FILTERING) != 0)
300                {
301                    portInfo->featureStatus |= IX_ETH_DB_FILTERING;
302                }
303            }
304        } 
305    }
306}
307
308/**
309 * @brief returns the capability of a port
310 *
311 * @param portID ID of the port
312 * @param featureSet location to store the port capability in
313 *
314 * This function will save the capability set of the given port
315 * into the given location. Capabilities are bit-ORed, each representing
316 * a bit of the feature set.
317 *
318 * Note that this function is documented in the main component
319 * public header file, IxEthDB.h.
320 *
321 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
322 * or IX_ETH_DB_INVALID_PORT if the given port is invalid
323 */
324IX_ETH_DB_PUBLIC
325IxEthDBStatus ixEthDBFeatureCapabilityGet(IxEthDBPortId portID, IxEthDBFeature *featureSet)
326{
327    IX_ETH_DB_CHECK_PORT_INITIALIZED(portID);
328
329    IX_ETH_DB_CHECK_REFERENCE(featureSet);
330   
331    *featureSet = ixEthDBPortInfo[portID].featureCapability;
332   
333    return IX_ETH_DB_SUCCESS;
334}
335
336/**
337 * @brief enables or disables a port capability
338 *
339 * @param portID ID of the port
340 * @param feature feature to enable or disable
341 * @param enabled TRUE to enable the selected feature or FALSE to disable it
342 *
343 * Note that this function is documented in the main component
344 * header file, IxEthDB.h.
345 *
346 * @return IX_ETH_DB_SUCCESS if the operation completed
347 * successfully or an appropriate error message otherwise
348 */
349IX_ETH_DB_PUBLIC
350IxEthDBStatus ixEthDBFeatureEnable(IxEthDBPortId portID, IxEthDBFeature feature, BOOL enable)
351{
352    PortInfo *portInfo;
353    IxEthDBPriorityTable defaultPriorityTable;
354    IxEthDBVlanSet vlanSet;
355    IxEthDBStatus status = IX_ETH_DB_SUCCESS;
356    BOOL portEnabled;
357
358    IX_ETH_DB_CHECK_PORT_INITIALIZED(portID);
359
360    portInfo    = &ixEthDBPortInfo[portID];
361    portEnabled = portInfo->enabled;
362   
363    /* check that only one feature is selected */
364    if (!ixEthDBCheckSingleBitValue(feature))
365    {
366        return IX_ETH_DB_FEATURE_UNAVAILABLE;
367    }
368           
369    /* port capable of this feature? */
370    if ((portInfo->featureCapability & feature) == 0)
371    {
372        return IX_ETH_DB_FEATURE_UNAVAILABLE;
373    }
374   
375    /* mutual exclusion between learning and WiFi header conversion */
376    if (enable && ((feature | portInfo->featureStatus) & (IX_ETH_DB_FILTERING | IX_ETH_DB_WIFI_HEADER_CONVERSION))
377            == (IX_ETH_DB_FILTERING | IX_ETH_DB_WIFI_HEADER_CONVERSION))
378    {
379        return IX_ETH_DB_NO_PERMISSION;
380    }
381
382    /* learning must be enabled before filtering */
383    if (enable && (feature == IX_ETH_DB_FILTERING) && ((portInfo->featureStatus & IX_ETH_DB_LEARNING) == 0))
384    {
385        return IX_ETH_DB_NO_PERMISSION;
386    }
387           
388    /* filtering must be disabled before learning */
389    if (!enable && (feature == IX_ETH_DB_LEARNING) && ((portInfo->featureStatus & IX_ETH_DB_FILTERING) != 0))
390    {
391        return IX_ETH_DB_NO_PERMISSION;
392    }
393           
394    /* redundant enabling or disabling */
395    if ((!enable && ((portInfo->featureStatus & feature) == 0))
396        || (enable && ((portInfo->featureStatus & feature) != 0)))
397    {
398        /* do nothing */
399        return IX_ETH_DB_SUCCESS;
400    }
401
402    /* force port enabled */
403    portInfo->enabled = TRUE;
404
405    if (enable)
406    {
407        /* turn on enable bit */
408        portInfo->featureStatus |= feature;
409       
410        /* if this is VLAN/QoS set the default priority table */
411        if (feature == IX_ETH_DB_VLAN_QOS)
412        {
413            /* turn on VLAN/QoS (most permissive mode):
414                - set default 802.1Q priority mapping table, in accordance to the
415                  availability of traffic classes
416                - set the acceptable frame filter to accept all
417                - set the Ingress tagging mode to pass-through
418                - set full VLAN membership list
419                - set full TTI table
420                - set the default 802.1Q tag to 0 (VLAN ID 0, Pri 0, CFI 0)
421                - enable TPID port extraction
422            */
423
424            portInfo->ixEthDBTrafficClassCount = portInfo->ixEthDBTrafficClassAvailable;
425
426            /* set default 802.1Q priority mapping table - note that C indexing starts from 0, so we substract 1 here */
427            ixOsalMemCopy (defaultPriorityTable, 
428                (void *) ixEthIEEE802_1QUserPriorityToTrafficClassMapping[portInfo->ixEthDBTrafficClassCount - 1], 
429                sizeof (defaultPriorityTable));
430
431            /* update priority mapping and AQM queue assignments */
432            status = ixEthDBPriorityMappingTableSet(portID, defaultPriorityTable);
433
434            if (status == IX_ETH_DB_SUCCESS)
435            {
436                status = ixEthDBAcceptableFrameTypeSet(portID, IX_ETH_DB_ACCEPT_ALL_FRAMES);
437            }
438
439            if (status == IX_ETH_DB_SUCCESS)
440            {
441                status = ixEthDBIngressVlanTaggingEnabledSet(portID, IX_ETH_DB_ENABLE_VLAN);
442            }
443
444            /* set membership and TTI tables */
445            ixOsalMemSet (vlanSet, 0xFF, sizeof (vlanSet));
446
447            if (status == IX_ETH_DB_SUCCESS)
448            {
449                /* use the internal function to bypass PVID check */
450                status = ixEthDBPortVlanTableSet(portID, portInfo->vlanMembership, vlanSet);
451            }
452
453            if (status == IX_ETH_DB_SUCCESS)
454            {
455                /* use the internal function to bypass PVID check */
456                status = ixEthDBPortVlanTableSet(portID, portInfo->transmitTaggingInfo, vlanSet);
457            }
458
459            /* reset the PVID */
460            if (status == IX_ETH_DB_SUCCESS)
461            {
462                status = ixEthDBPortVlanTagSet(portID, 0);
463            }
464
465            /* enable TPID port extraction */
466            if (status == IX_ETH_DB_SUCCESS)
467            {
468                status = ixEthDBVlanPortExtractionEnable(portID, TRUE);
469            }
470        }
471        else if (feature == IX_ETH_DB_FIREWALL)
472        {
473            /* firewall starts in black-list mode unless otherwise configured before *
474             * note that invalid source MAC address filtering is disabled by default */
475            if (portInfo->firewallMode != IX_ETH_DB_FIREWALL_BLACK_LIST
476                && portInfo->firewallMode != IX_ETH_DB_FIREWALL_WHITE_LIST)
477            {
478                status = ixEthDBFirewallModeSet(portID, IX_ETH_DB_FIREWALL_BLACK_LIST);
479
480                if (status == IX_ETH_DB_SUCCESS)
481                {
482                    status = ixEthDBFirewallInvalidAddressFilterEnable(portID, FALSE);
483                }
484            }
485        }
486       
487        if (status != IX_ETH_DB_SUCCESS)
488        {
489            /* checks failed, disable */
490            portInfo->featureStatus &= ~feature;
491        }
492    }
493    else
494    {
495        /* turn off features */
496        if (feature == IX_ETH_DB_FIREWALL)
497        {
498            /* turning off the firewall is equivalent to:
499                - set to black-list mode
500                - clear all the entries and download the new table
501                - turn off the invalid source address checking
502            */
503           
504            status = ixEthDBDatabaseClear(portID, IX_ETH_DB_FIREWALL_RECORD);
505
506            if (status == IX_ETH_DB_SUCCESS)
507            {
508                status = ixEthDBFirewallModeSet(portID, IX_ETH_DB_FIREWALL_BLACK_LIST);
509            }
510
511            if (status == IX_ETH_DB_SUCCESS)
512            {
513                status = ixEthDBFirewallInvalidAddressFilterEnable(portID, FALSE);
514            }
515
516            if (status == IX_ETH_DB_SUCCESS)
517            {
518                status = ixEthDBFirewallTableDownload(portID);
519            }
520        }
521        else if (feature == IX_ETH_DB_WIFI_HEADER_CONVERSION)
522        {
523            /* turn off header conversion */
524            status = ixEthDBDatabaseClear(portID, IX_ETH_DB_WIFI_RECORD);
525
526            if (status == IX_ETH_DB_SUCCESS)
527            {
528                status = ixEthDBWiFiConversionTableDownload(portID);
529            }
530        }
531        else if (feature == IX_ETH_DB_VLAN_QOS)
532        {
533            /* turn off VLAN/QoS:
534                - set a priority mapping table with one traffic class
535                - set the acceptable frame filter to accept all
536                - set the Ingress tagging mode to pass-through
537                - clear the VLAN membership list
538                - clear the TTI table
539                - set the default 802.1Q tag to 0 (VLAN ID 0, Pri 0, CFI 0)
540                - disable TPID port extraction
541            */
542
543            /* initialize all => traffic class 0 priority mapping table */
544            ixOsalMemSet (defaultPriorityTable, 0, sizeof (defaultPriorityTable));
545            portInfo->ixEthDBTrafficClassCount = 1;
546            status = ixEthDBPriorityMappingTableSet(portID, defaultPriorityTable);
547
548            if (status == IX_ETH_DB_SUCCESS)
549            {
550                status = ixEthDBAcceptableFrameTypeSet(portID, IX_ETH_DB_ACCEPT_ALL_FRAMES);
551            }
552
553            if (status == IX_ETH_DB_SUCCESS)
554            {
555                status = ixEthDBIngressVlanTaggingEnabledSet(portID, IX_ETH_DB_DISABLE_VLAN);
556            }
557
558            /* clear membership and TTI tables */
559            ixOsalMemSet (vlanSet, 0, sizeof (vlanSet));
560
561            if (status == IX_ETH_DB_SUCCESS)
562            {
563                /* use the internal function to bypass PVID check */
564                status = ixEthDBPortVlanTableSet(portID, portInfo->vlanMembership, vlanSet);
565            }
566
567            if (status == IX_ETH_DB_SUCCESS)
568            {
569                /* use the internal function to bypass PVID check */
570                status = ixEthDBPortVlanTableSet(portID, portInfo->transmitTaggingInfo, vlanSet);
571            }
572
573            /* reset the PVID */
574            if (status == IX_ETH_DB_SUCCESS)
575            {
576                status = ixEthDBPortVlanTagSet(portID, 0);
577            }
578
579            /* disable TPID port extraction */
580            if (status == IX_ETH_DB_SUCCESS)
581            {
582                status = ixEthDBVlanPortExtractionEnable(portID, FALSE);
583            }
584        }
585
586        if (status == IX_ETH_DB_SUCCESS)
587        {
588            /* checks passed, disable */
589            portInfo->featureStatus &= ~feature;
590        }
591    }
592
593    /* restore port enabled state */
594    portInfo->enabled = portEnabled; 
595   
596    return status;
597}
598
599/**
600 * @brief returns the status of a feature
601 *
602 * @param portID port ID
603 * @param present location to store a boolean value indicating
604 * if the feature is present (TRUE) or not (FALSE)
605 * @param enabled location to store a booleam value indicating
606 * if the feature is present (TRUE) or not (FALSE)
607 *
608 * Note that this function is documented in the main component
609 * header file, IxEthDB.h.
610 *
611 * @return IX_ETH_DB_SUCCESS if the operation completed
612 * successfully or an appropriate error message otherwise
613 */
614IX_ETH_DB_PUBLIC
615IxEthDBStatus ixEthDBFeatureStatusGet(IxEthDBPortId portID, IxEthDBFeature feature, BOOL *present, BOOL *enabled)
616{
617    PortInfo *portInfo;
618   
619    IX_ETH_DB_CHECK_PORT(portID);
620
621    IX_ETH_DB_CHECK_REFERENCE(present);
622
623    IX_ETH_DB_CHECK_REFERENCE(enabled);
624   
625    portInfo = &ixEthDBPortInfo[portID];
626   
627    *present = (portInfo->featureCapability & feature) != 0;
628    *enabled = (portInfo->featureStatus & feature) != 0;
629   
630    return IX_ETH_DB_SUCCESS;
631}
632
633/**
634 * @brief returns the value of an EthDB property
635 *
636 * @param portID ID of the port
637 * @param feature feature owning the property
638 * @param property ID of the property
639 * @param type location to store the property type into
640 * @param value location to store the property value into
641 *
642 * Note that this function is documented in the main component
643 * header file, IxEthDB.h.
644 *
645 * @return IX_ETH_DB_SUCCESS if the operation completed
646 * successfully or an appropriate error message otherwise
647 */
648IX_ETH_DB_PUBLIC
649IxEthDBStatus ixEthDBFeaturePropertyGet(IxEthDBPortId portID, IxEthDBFeature feature, IxEthDBProperty property, IxEthDBPropertyType *type, void *value)
650{
651    IX_ETH_DB_CHECK_PORT_EXISTS(portID);
652
653    IX_ETH_DB_CHECK_REFERENCE(type);
654
655    IX_ETH_DB_CHECK_REFERENCE(value);
656   
657    if (feature == IX_ETH_DB_VLAN_QOS)
658    {
659        if (property == IX_ETH_DB_QOS_TRAFFIC_CLASS_COUNT_PROPERTY)
660        {
661            * (UINT32 *) value = ixEthDBPortInfo[portID].ixEthDBTrafficClassCount;
662            *type              = IX_ETH_DB_INTEGER_PROPERTY;
663
664            return IX_ETH_DB_SUCCESS;
665        }
666        else if (property >= IX_ETH_DB_QOS_TRAFFIC_CLASS_0_RX_QUEUE_PROPERTY
667            && property <= IX_ETH_DB_QOS_TRAFFIC_CLASS_7_RX_QUEUE_PROPERTY)
668        {
669            UINT32 classDelta = property - IX_ETH_DB_QOS_TRAFFIC_CLASS_0_RX_QUEUE_PROPERTY;
670
671            if (classDelta >= ixEthDBPortInfo[portID].ixEthDBTrafficClassCount)
672            {
673                return IX_ETH_DB_FAIL;
674            }
675
676            * (UINT32 *) value = ixEthDBPortInfo[portID].ixEthDBTrafficClassAQMAssignments[classDelta];
677            *type              = IX_ETH_DB_INTEGER_PROPERTY;
678
679            return IX_ETH_DB_SUCCESS;
680        }
681    }
682   
683    return IX_ETH_DB_INVALID_ARG;
684}
685
686/**
687 * @brief sets the value of an EthDB property
688 *
689 * @param portID ID of the port
690 * @param feature feature owning the property
691 * @param property ID of the property
692 * @param value location containing the property value
693 *
694 * This function implements a private property intended
695 * only for EthAcc usage. Upon setting the IX_ETH_DB_QOS_QUEUE_CONFIGURATION_COMPLETE
696 * property (the value is ignored), the availability of traffic classes is
697 * frozen to whatever traffic class structure is currently in use.
698 * This means that if VLAN_QOS has been enabled before EthAcc
699 * initialization then all the defined traffic classes will be available;
700 * otherwise only one traffic class (0) will be available.
701 *
702 * Note that this function is documented in the main component
703 * header file, IxEthDB.h as not accepting any parameters. The
704 * current implementation is only intended for the private use of EthAcc.
705 *
706 * Also note that once this function is called the effect is irreversible,
707 * unless EthDB is complete unloaded and re-initialized.
708 *
709 * @return IX_ETH_DB_INVALID_ARG (no read-write properties are
710 * supported in this release)
711 */
712IX_ETH_DB_PUBLIC
713IxEthDBStatus ixEthDBFeaturePropertySet(IxEthDBPortId portID, IxEthDBFeature feature, IxEthDBProperty property, void *value)
714{
715    IX_ETH_DB_CHECK_PORT_EXISTS(portID);
716
717    if ((feature == IX_ETH_DB_VLAN_QOS) && (property == IX_ETH_DB_QOS_QUEUE_CONFIGURATION_COMPLETE))
718    {
719        ixEthDBPortInfo[portID].ixEthDBTrafficClassAvailable = ixEthDBPortInfo[portID].ixEthDBTrafficClassCount;
720
721        return IX_ETH_DB_SUCCESS;
722    }
723   
724    return IX_ETH_DB_INVALID_ARG;
725}
726
727
728/**
729 * @brief Restore the states of EthDB Features
730 *
731 * @param portID ID of the port
732 *
733 * See IxEthDB.h for more details.
734 */
735IX_ETH_DB_PUBLIC
736IxEthDBStatus ixEthDBFeatureStatesRestore(IxEthDBPortId portID)
737{
738    PortInfo *portInfo = &ixEthDBPortInfo[portID];
739
740    /* Check whether port if enabled */
741    IX_ETH_DB_CHECK_PORT_INITIALIZED(portID);
742    IX_ETH_DB_CHECK_PORT(portID);
743
744   /* ========================  Basic ==========================
745    *  Set up Port MAC Address
746    */
747    if (ixEthDBPortAddressSet(portID, &(portInfo->macAddr)) != IX_SUCCESS)
748    {
749        return IX_ETH_DB_FAIL;
750    }
751   
752    /*
753     * Set up Port Max Rx/Tx frame lengths
754     */ 
755    if(ixEthDBPortFrameLengthsUpdate(portID) != IX_SUCCESS)
756    {
757        return IX_ETH_DB_FAIL;
758    }
759
760    /* ========================  VLAN/QoS ==========================         
761     * Only performs VLAN feature update if it is enabled before
762     */ 
763    if ((portInfo->featureStatus & IX_ETH_DB_VLAN_QOS) != 0)
764    {
765      /* Set VLAN Rx tag mode */
766      if (ixEthDBIngressVlanModeUpdate(portID) != IX_SUCCESS)
767      {
768         return IX_ETH_DB_FAIL;
769      }
770
771      /* Set Default Rx VID */
772      if (ixEthDBPortVlanTagSet(portID, portInfo->vlanTag) != IX_SUCCESS)
773      {
774         return IX_ETH_DB_FAIL;
775      }
776 
777      /* Set PortID extraction mode */
778      if (ixEthDBVlanPortExtractionEnable(portID, portInfo->portIdExtractionEnable) != IX_SUCCESS)
779      {
780         return IX_ETH_DB_FAIL;   
781      }
782
783      /* Set VLAN Table */
784      if (ixEthDBVlanTableRangeUpdate(portID) != IX_SUCCESS)
785      {
786         return IX_ETH_DB_FAIL; 
787      }
788    } /* VLAN/QoS */
789
790   /* ========================  Firewall ==========================         
791    * Only performs Firewall feature update if it is enabled before
792    */   
793    if ((portInfo->featureStatus & IX_ETH_DB_FIREWALL) != 0)
794    {
795      if(ixEthDBFirewallTableDownload(portID) != IX_SUCCESS)
796      {
797        return IX_ETH_DB_FAIL;
798      } 
799    } /* Firewall */
800 
801   /* ===================== Header Conversion ==========================         
802    * Only performs Header Conversion feature update if it is enabled before
803    */   
804    if ((portInfo->featureStatus & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0)
805    {
806      /* Update WiFi FC & DID */
807      if (ixEthDBWiFiFrameControlDurationIDUpdate(portID) != IX_SUCCESS)
808      {     
809        return IX_ETH_DB_FAIL; 
810      }
811
812      /* Update BSSID */
813      if (ixEthDBWiFiBSSIDSet(portID, (IxEthDBMacAddr *) portInfo->bssid) != IX_SUCCESS)
814      {
815        return IX_ETH_DB_FAIL;
816      }
817
818      /* Update Header Conversion Table & AP MAC Table */
819      if (ixEthDBWiFiConversionTableDownload(portID) != IX_ETH_DB_SUCCESS)
820      {
821        return IX_ETH_DB_FAIL;
822      }
823    } /* Header Conversion */
824 
825   /* ====================== Learning & Filtering ==========================         
826    * Learning & Filtering feature update is not neccessary as we can rely
827    * on EthNPE to learn the src address again. As for the entry added by client
828    * earlier, it will be lost. This is the constraint as the mechanism to retrieve
829    * the entry that has been added by client from NPE is not trivial.
830    */
831
832   /* ============================== STP ===================================         
833    * Only performs STP feature update if it is enabled before
834    */
835    if ((portInfo->featureStatus & IX_ETH_DB_SPANNING_TREE_PROTOCOL) != 0)
836    {   
837      if (ixEthDBSpanningTreeBlockingStateSet(portID, portInfo->stpBlocked) != IX_SUCCESS)
838      {
839        return IX_ETH_DB_FAIL;
840      }
841    }
842
843    return IX_ETH_DB_SUCCESS;
844}
Note: See TracBrowser for help on using the repository browser.