blob: 1f7624016afc7ac47bcae9cdff0812db956d12a4 [file] [log] [blame]
Wolfgang Denkba94a1b2006-05-30 15:56:48 +02001/**
2 * @file IxEthDBFeatures.c
3 *
4 * @brief Implementation of the EthDB feature control API
5 *
6 * @par
7 * IXP400 SW Release version 2.0
8 *
9 * -- Copyright Notice --
10 *
11 * @par
12 * Copyright 2001-2005, Intel Corporation.
13 * All rights reserved.
14 *
15 * @par
Wolfgang Denkcb3761e2013-07-28 22:12:47 +020016 * SPDX-License-Identifier: BSD-3-Clause
Wolfgang Denkba94a1b2006-05-30 15:56:48 +020017 * @par
18 * -- End of Copyright Notice --
19 */
20
21#include "IxNpeDl.h"
22#include "IxEthDBQoS.h"
23#include "IxEthDB_p.h"
24
25/**
26 * @brief scans the capabilities of the loaded NPE images
27 *
28 * This function MUST be called by the ixEthDBInit() function.
29 * No EthDB features (including learning and filtering) are enabled
30 * before this function is called.
31 *
32 * @return none
33 *
34 * @internal
35 */
36IX_ETH_DB_PUBLIC
37void ixEthDBFeatureCapabilityScan(void)
38{
39 IxNpeDlImageId imageId, npeAImageId;
40 IxEthDBPortId portIndex;
41 PortInfo *portInfo;
42 IxEthDBPriorityTable defaultPriorityTable;
43 IX_STATUS result;
44 UINT32 queueIndex;
45 UINT32 queueStructureIndex;
46 UINT32 trafficClassDefinitionIndex;
47
48 /* read version of NPE A - required to set the AQM queues for B and C */
49 npeAImageId.functionalityId = 0;
50 ixNpeDlLoadedImageGet(IX_NPEDL_NPEID_NPEA, &npeAImageId);
51
52 for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++)
53 {
54 IxNpeMhMessage msg;
55
56 portInfo = &ixEthDBPortInfo[portIndex];
57
58 /* check and bypass if NPE B or C is fused out */
59 if (ixEthDBSingleEthNpeCheck(portIndex) != IX_ETH_DB_SUCCESS) continue;
60
61 /* all ports are capable of LEARNING by default */
62 portInfo->featureCapability |= IX_ETH_DB_LEARNING;
63 portInfo->featureStatus |= IX_ETH_DB_LEARNING;
64
65 if (ixEthDBPortDefinitions[portIndex].type == IX_ETH_NPE)
66 {
67
68 if (ixNpeDlLoadedImageGet(IX_ETH_DB_PORT_ID_TO_NPE(portIndex), &imageId) != IX_SUCCESS)
69 {
70 WARNING_LOG("DB: (FeatureScan) NpeDl did not provide the image ID for NPE port %d\n", portIndex);
71 }
72 else
73 {
74 /* initialize and empty NPE response mutex */
75 ixOsalMutexInit(&portInfo->npeAckLock);
76 ixOsalMutexLock(&portInfo->npeAckLock, IX_OSAL_WAIT_FOREVER);
77
78 /* check NPE response to GetStatus */
79 msg.data[0] = IX_ETHNPE_NPE_GETSTATUS << 24;
80 msg.data[1] = 0;
81 IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portIndex), msg, result);
82 if (result != IX_SUCCESS)
83 {
84 WARNING_LOG("DB: (FeatureScan) warning, could not send message to the NPE\n");
85 continue;
86 }
87
88
89 if (imageId.functionalityId == 0x00
90 || imageId.functionalityId == 0x03
91 || imageId.functionalityId == 0x04
92 || imageId.functionalityId == 0x80)
93 {
94 portInfo->featureCapability |= IX_ETH_DB_FILTERING;
95 portInfo->featureCapability |= IX_ETH_DB_FIREWALL;
96 portInfo->featureCapability |= IX_ETH_DB_SPANNING_TREE_PROTOCOL;
97 }
98 else if (imageId.functionalityId == 0x01
99 || imageId.functionalityId == 0x81)
100 {
101 portInfo->featureCapability |= IX_ETH_DB_FILTERING;
102 portInfo->featureCapability |= IX_ETH_DB_FIREWALL;
103 portInfo->featureCapability |= IX_ETH_DB_SPANNING_TREE_PROTOCOL;
104 portInfo->featureCapability |= IX_ETH_DB_VLAN_QOS;
105 }
106 else if (imageId.functionalityId == 0x02
107 || imageId.functionalityId == 0x82)
108 {
109 portInfo->featureCapability |= IX_ETH_DB_WIFI_HEADER_CONVERSION;
110 portInfo->featureCapability |= IX_ETH_DB_FIREWALL;
111 portInfo->featureCapability |= IX_ETH_DB_SPANNING_TREE_PROTOCOL;
112 portInfo->featureCapability |= IX_ETH_DB_VLAN_QOS;
113 }
114
115 /* reset AQM queues */
116 memset(portInfo->ixEthDBTrafficClassAQMAssignments, 0, sizeof (portInfo->ixEthDBTrafficClassAQMAssignments));
117
118 /* ensure there's at least one traffic class record in the definition table, otherwise we have no default case, hence no queues */
119 IX_ENSURE(sizeof (ixEthDBTrafficClassDefinitions) != 0, "DB: no traffic class definitions found, check IxEthDBQoS.h");
120
121 /* find the traffic class definition index compatible with the current NPE A functionality ID */
122 for (trafficClassDefinitionIndex = 0 ;
Axel Lina62cd292013-07-03 11:24:18 +0800123 trafficClassDefinitionIndex < ARRAY_SIZE(ixEthDBTrafficClassDefinitions);
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200124 trafficClassDefinitionIndex++)
125 {
126 if (ixEthDBTrafficClassDefinitions[trafficClassDefinitionIndex][IX_ETH_DB_NPE_A_FUNCTIONALITY_ID_INDEX] == npeAImageId.functionalityId)
127 {
128 /* found it */
129 break;
130 }
131 }
132
133 /* select the default case if we went over the array boundary */
Axel Lina62cd292013-07-03 11:24:18 +0800134 if (trafficClassDefinitionIndex == ARRAY_SIZE(ixEthDBTrafficClassDefinitions))
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200135 {
136 trafficClassDefinitionIndex = 0; /* the first record is the default case */
137 }
138
139 /* select queue assignment structure based on the traffic class configuration index */
140 queueStructureIndex = ixEthDBTrafficClassDefinitions[trafficClassDefinitionIndex][IX_ETH_DB_QUEUE_ASSIGNMENT_INDEX];
141
142 /* only traffic class 0 is active at initialization time */
143 portInfo->ixEthDBTrafficClassCount = 1;
144
145 /* enable port, VLAN and Firewall feature bits to initialize QoS/VLAN/Firewall configuration */
146 portInfo->featureStatus |= IX_ETH_DB_VLAN_QOS;
147 portInfo->featureStatus |= IX_ETH_DB_FIREWALL;
York Sun472d5462013-04-01 11:29:11 -0700148 portInfo->enabled = true;
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200149
150#define CONFIG_WITH_VLAN /* test-only: VLAN support not included to save space!!! */
151#ifdef CONFIG_WITH_VLAN /* test-only: VLAN support not included to save space!!! */
152 /* set VLAN initial configuration (permissive) */
153 if ((portInfo->featureCapability & IX_ETH_DB_VLAN_QOS) != 0) /* QoS-enabled image */
154 {
155 /* QoS capable */
156 portInfo->ixEthDBTrafficClassAvailable = ixEthDBTrafficClassDefinitions[trafficClassDefinitionIndex][IX_ETH_DB_TRAFFIC_CLASS_COUNT_INDEX];
157
158 /* set AQM queues */
159 for (queueIndex = 0 ; queueIndex < IX_IEEE802_1Q_QOS_PRIORITY_COUNT ; queueIndex++)
160 {
161 portInfo->ixEthDBTrafficClassAQMAssignments[queueIndex] = ixEthDBQueueAssignments[queueStructureIndex][queueIndex];
162 }
163
164 /* set default PVID (0) and default traffic class 0 */
165 ixEthDBPortVlanTagSet(portIndex, 0);
166
167 /* enable reception of all frames */
168 ixEthDBAcceptableFrameTypeSet(portIndex, IX_ETH_DB_ACCEPT_ALL_FRAMES);
169
170 /* clear full VLAN membership */
171 ixEthDBPortVlanMembershipRangeRemove(portIndex, 0, IX_ETH_DB_802_1Q_MAX_VLAN_ID);
172
173 /* clear TTI table - no VLAN tagged frames will be transmitted */
York Sun472d5462013-04-01 11:29:11 -0700174 ixEthDBEgressVlanRangeTaggingEnabledSet(portIndex, 0, 4094, false);
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200175
176 /* set membership on 0, otherwise no Tx or Rx is working */
177 ixEthDBPortVlanMembershipAdd(portIndex, 0);
178 }
179 else /* QoS not available in this image */
180#endif /* test-only */
181 {
182 /* initialize traffic class availability (only class 0 is available) */
183 portInfo->ixEthDBTrafficClassAvailable = 1;
184
185 /* point all AQM queues to traffic class 0 */
186 for (queueIndex = 0 ; queueIndex < IX_IEEE802_1Q_QOS_PRIORITY_COUNT ; queueIndex++)
187 {
188 portInfo->ixEthDBTrafficClassAQMAssignments[queueIndex] =
189 ixEthDBQueueAssignments[queueStructureIndex][0];
190 }
191 }
192
193#ifdef CONFIG_WITH_VLAN /* test-only: VLAN support not included to save space!!! */
194 /* download priority mapping table and Rx queue configuration */
195 memset (defaultPriorityTable, 0, sizeof (defaultPriorityTable));
196 ixEthDBPriorityMappingTableSet(portIndex, defaultPriorityTable);
197#endif
198
199 /* by default we turn off invalid source MAC address filtering */
York Sun472d5462013-04-01 11:29:11 -0700200 ixEthDBFirewallInvalidAddressFilterEnable(portIndex, false);
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200201
202 /* disable port, VLAN, Firewall feature bits */
203 portInfo->featureStatus &= ~IX_ETH_DB_VLAN_QOS;
204 portInfo->featureStatus &= ~IX_ETH_DB_FIREWALL;
York Sun472d5462013-04-01 11:29:11 -0700205 portInfo->enabled = false;
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200206
207 /* enable filtering by default if present */
208 if ((portInfo->featureCapability & IX_ETH_DB_FILTERING) != 0)
209 {
210 portInfo->featureStatus |= IX_ETH_DB_FILTERING;
211 }
212 }
213 }
214 }
215}
216
217/**
218 * @brief returns the capability of a port
219 *
220 * @param portID ID of the port
221 * @param featureSet location to store the port capability in
222 *
223 * This function will save the capability set of the given port
224 * into the given location. Capabilities are bit-ORed, each representing
225 * a bit of the feature set.
226 *
227 * Note that this function is documented in the main component
228 * public header file, IxEthDB.h.
229 *
230 * @return IX_ETH_DB_SUCCESS if the operation completed successfully
231 * or IX_ETH_DB_INVALID_PORT if the given port is invalid
232 */
233IX_ETH_DB_PUBLIC
234IxEthDBStatus ixEthDBFeatureCapabilityGet(IxEthDBPortId portID, IxEthDBFeature *featureSet)
235{
236 IX_ETH_DB_CHECK_PORT_INITIALIZED(portID);
237
238 IX_ETH_DB_CHECK_REFERENCE(featureSet);
239
240 *featureSet = ixEthDBPortInfo[portID].featureCapability;
241
242 return IX_ETH_DB_SUCCESS;
243}
244
245/**
246 * @brief enables or disables a port capability
247 *
248 * @param portID ID of the port
249 * @param feature feature to enable or disable
York Sun472d5462013-04-01 11:29:11 -0700250 * @param enabled true to enable the selected feature or false to disable it
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200251 *
252 * Note that this function is documented in the main component
253 * header file, IxEthDB.h.
254 *
255 * @return IX_ETH_DB_SUCCESS if the operation completed
256 * successfully or an appropriate error message otherwise
257 */
258IX_ETH_DB_PUBLIC
259IxEthDBStatus ixEthDBFeatureEnable(IxEthDBPortId portID, IxEthDBFeature feature, BOOL enable)
260{
261 PortInfo *portInfo;
262 IxEthDBPriorityTable defaultPriorityTable;
263 IxEthDBVlanSet vlanSet;
264 IxEthDBStatus status = IX_ETH_DB_SUCCESS;
265 BOOL portEnabled;
266
267 IX_ETH_DB_CHECK_PORT_INITIALIZED(portID);
268
269 portInfo = &ixEthDBPortInfo[portID];
270 portEnabled = portInfo->enabled;
271
272 /* check that only one feature is selected */
273 if (!ixEthDBCheckSingleBitValue(feature))
274 {
275 return IX_ETH_DB_FEATURE_UNAVAILABLE;
276 }
277
278 /* port capable of this feature? */
279 if ((portInfo->featureCapability & feature) == 0)
280 {
281 return IX_ETH_DB_FEATURE_UNAVAILABLE;
282 }
283
284 /* mutual exclusion between learning and WiFi header conversion */
285 if (enable && ((feature | portInfo->featureStatus) & (IX_ETH_DB_FILTERING | IX_ETH_DB_WIFI_HEADER_CONVERSION))
286 == (IX_ETH_DB_FILTERING | IX_ETH_DB_WIFI_HEADER_CONVERSION))
287 {
288 return IX_ETH_DB_NO_PERMISSION;
289 }
290
291 /* learning must be enabled before filtering */
292 if (enable && (feature == IX_ETH_DB_FILTERING) && ((portInfo->featureStatus & IX_ETH_DB_LEARNING) == 0))
293 {
294 return IX_ETH_DB_NO_PERMISSION;
295 }
296
297 /* filtering must be disabled before learning */
298 if (!enable && (feature == IX_ETH_DB_LEARNING) && ((portInfo->featureStatus & IX_ETH_DB_FILTERING) != 0))
299 {
300 return IX_ETH_DB_NO_PERMISSION;
301 }
302
303 /* redundant enabling or disabling */
304 if ((!enable && ((portInfo->featureStatus & feature) == 0))
305 || (enable && ((portInfo->featureStatus & feature) != 0)))
306 {
307 /* do nothing */
308 return IX_ETH_DB_SUCCESS;
309 }
310
311 /* force port enabled */
York Sun472d5462013-04-01 11:29:11 -0700312 portInfo->enabled = true;
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200313
314 if (enable)
315 {
316 /* turn on enable bit */
317 portInfo->featureStatus |= feature;
318
319#ifdef CONFIG_WITH_VLAN /* test-only: VLAN support not included to save space!!! */
320 /* if this is VLAN/QoS set the default priority table */
321 if (feature == IX_ETH_DB_VLAN_QOS)
322 {
323 /* turn on VLAN/QoS (most permissive mode):
324 - set default 802.1Q priority mapping table, in accordance to the
325 availability of traffic classes
326 - set the acceptable frame filter to accept all
327 - set the Ingress tagging mode to pass-through
328 - set full VLAN membership list
329 - set full TTI table
330 - set the default 802.1Q tag to 0 (VLAN ID 0, Pri 0, CFI 0)
331 - enable TPID port extraction
332 */
333
334 portInfo->ixEthDBTrafficClassCount = portInfo->ixEthDBTrafficClassAvailable;
335
336 /* set default 802.1Q priority mapping table - note that C indexing starts from 0, so we substract 1 here */
337 memcpy (defaultPriorityTable,
338 (const void *) ixEthIEEE802_1QUserPriorityToTrafficClassMapping[portInfo->ixEthDBTrafficClassCount - 1],
339 sizeof (defaultPriorityTable));
340
341 /* update priority mapping and AQM queue assignments */
342 status = ixEthDBPriorityMappingTableSet(portID, defaultPriorityTable);
343
344 if (status == IX_ETH_DB_SUCCESS)
345 {
346 status = ixEthDBAcceptableFrameTypeSet(portID, IX_ETH_DB_ACCEPT_ALL_FRAMES);
347 }
348
349 if (status == IX_ETH_DB_SUCCESS)
350 {
351 status = ixEthDBIngressVlanTaggingEnabledSet(portID, IX_ETH_DB_PASS_THROUGH);
352 }
353
354 /* set membership and TTI tables */
355 memset (vlanSet, 0xFF, sizeof (vlanSet));
356
357 if (status == IX_ETH_DB_SUCCESS)
358 {
359 /* use the internal function to bypass PVID check */
360 status = ixEthDBPortVlanTableSet(portID, portInfo->vlanMembership, vlanSet);
361 }
362
363 if (status == IX_ETH_DB_SUCCESS)
364 {
365 /* use the internal function to bypass PVID check */
366 status = ixEthDBPortVlanTableSet(portID, portInfo->transmitTaggingInfo, vlanSet);
367 }
368
369 /* reset the PVID */
370 if (status == IX_ETH_DB_SUCCESS)
371 {
372 status = ixEthDBPortVlanTagSet(portID, 0);
373 }
374
375 /* enable TPID port extraction */
376 if (status == IX_ETH_DB_SUCCESS)
377 {
York Sun472d5462013-04-01 11:29:11 -0700378 status = ixEthDBVlanPortExtractionEnable(portID, true);
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200379 }
380 }
381 else if (feature == IX_ETH_DB_FIREWALL)
382#endif
383 {
384 /* firewall starts in black-list mode unless otherwise configured before *
385 * note that invalid source MAC address filtering is disabled by default */
386 if (portInfo->firewallMode != IX_ETH_DB_FIREWALL_BLACK_LIST
387 && portInfo->firewallMode != IX_ETH_DB_FIREWALL_WHITE_LIST)
388 {
389 status = ixEthDBFirewallModeSet(portID, IX_ETH_DB_FIREWALL_BLACK_LIST);
390
391 if (status == IX_ETH_DB_SUCCESS)
392 {
York Sun472d5462013-04-01 11:29:11 -0700393 status = ixEthDBFirewallInvalidAddressFilterEnable(portID, false);
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200394 }
395 }
396 }
397
398 if (status != IX_ETH_DB_SUCCESS)
399 {
400 /* checks failed, disable */
401 portInfo->featureStatus &= ~feature;
402 }
403 }
404 else
405 {
406 /* turn off features */
407 if (feature == IX_ETH_DB_FIREWALL)
408 {
409 /* turning off the firewall is equivalent to:
410 - set to black-list mode
411 - clear all the entries and download the new table
412 - turn off the invalid source address checking
413 */
414
415 status = ixEthDBDatabaseClear(portID, IX_ETH_DB_FIREWALL_RECORD);
416
417 if (status == IX_ETH_DB_SUCCESS)
418 {
419 status = ixEthDBFirewallModeSet(portID, IX_ETH_DB_FIREWALL_BLACK_LIST);
420 }
421
422 if (status == IX_ETH_DB_SUCCESS)
423 {
York Sun472d5462013-04-01 11:29:11 -0700424 status = ixEthDBFirewallInvalidAddressFilterEnable(portID, false);
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200425 }
426
427 if (status == IX_ETH_DB_SUCCESS)
428 {
429 status = ixEthDBFirewallTableDownload(portID);
430 }
431 }
432 else if (feature == IX_ETH_DB_WIFI_HEADER_CONVERSION)
433 {
434 /* turn off header conversion */
435 status = ixEthDBDatabaseClear(portID, IX_ETH_DB_WIFI_RECORD);
436
437 if (status == IX_ETH_DB_SUCCESS)
438 {
439 status = ixEthDBWiFiConversionTableDownload(portID);
440 }
441 }
442#ifdef CONFIG_WITH_VLAN /* test-only: VLAN support not included to save space!!! */
443 else if (feature == IX_ETH_DB_VLAN_QOS)
444 {
445 /* turn off VLAN/QoS:
446 - set a priority mapping table with one traffic class
447 - set the acceptable frame filter to accept all
448 - set the Ingress tagging mode to pass-through
449 - clear the VLAN membership list
450 - clear the TTI table
451 - set the default 802.1Q tag to 0 (VLAN ID 0, Pri 0, CFI 0)
452 - disable TPID port extraction
453 */
454
455 /* initialize all => traffic class 0 priority mapping table */
456 memset (defaultPriorityTable, 0, sizeof (defaultPriorityTable));
457 portInfo->ixEthDBTrafficClassCount = 1;
458 status = ixEthDBPriorityMappingTableSet(portID, defaultPriorityTable);
459
460 if (status == IX_ETH_DB_SUCCESS)
461 {
462 status = ixEthDBAcceptableFrameTypeSet(portID, IX_ETH_DB_ACCEPT_ALL_FRAMES);
463 }
464
465 if (status == IX_ETH_DB_SUCCESS)
466 {
467 status = ixEthDBIngressVlanTaggingEnabledSet(portID, IX_ETH_DB_PASS_THROUGH);
468 }
469
470 /* clear membership and TTI tables */
471 memset (vlanSet, 0, sizeof (vlanSet));
472
473 if (status == IX_ETH_DB_SUCCESS)
474 {
475 /* use the internal function to bypass PVID check */
476 status = ixEthDBPortVlanTableSet(portID, portInfo->vlanMembership, vlanSet);
477 }
478
479 if (status == IX_ETH_DB_SUCCESS)
480 {
481 /* use the internal function to bypass PVID check */
482 status = ixEthDBPortVlanTableSet(portID, portInfo->transmitTaggingInfo, vlanSet);
483 }
484
485 /* reset the PVID */
486 if (status == IX_ETH_DB_SUCCESS)
487 {
488 status = ixEthDBPortVlanTagSet(portID, 0);
489 }
490
491 /* disable TPID port extraction */
492 if (status == IX_ETH_DB_SUCCESS)
493 {
York Sun472d5462013-04-01 11:29:11 -0700494 status = ixEthDBVlanPortExtractionEnable(portID, false);
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200495 }
496 }
497#endif
498
499 if (status == IX_ETH_DB_SUCCESS)
500 {
501 /* checks passed, disable */
502 portInfo->featureStatus &= ~feature;
503 }
504 }
505
506 /* restore port enabled state */
507 portInfo->enabled = portEnabled;
508
509 return status;
510}
511
512/**
513 * @brief returns the status of a feature
514 *
515 * @param portID port ID
516 * @param present location to store a boolean value indicating
York Sun472d5462013-04-01 11:29:11 -0700517 * if the feature is present (true) or not (false)
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200518 * @param enabled location to store a booleam value indicating
York Sun472d5462013-04-01 11:29:11 -0700519 * if the feature is present (true) or not (false)
Wolfgang Denkba94a1b2006-05-30 15:56:48 +0200520 *
521 * Note that this function is documented in the main component
522 * header file, IxEthDB.h.
523 *
524 * @return IX_ETH_DB_SUCCESS if the operation completed
525 * successfully or an appropriate error message otherwise
526 */
527IX_ETH_DB_PUBLIC
528IxEthDBStatus ixEthDBFeatureStatusGet(IxEthDBPortId portID, IxEthDBFeature feature, BOOL *present, BOOL *enabled)
529{
530 PortInfo *portInfo;
531
532 IX_ETH_DB_CHECK_PORT(portID);
533
534 IX_ETH_DB_CHECK_REFERENCE(present);
535
536 IX_ETH_DB_CHECK_REFERENCE(enabled);
537
538 portInfo = &ixEthDBPortInfo[portID];
539
540 *present = (portInfo->featureCapability & feature) != 0;
541 *enabled = (portInfo->featureStatus & feature) != 0;
542
543 return IX_ETH_DB_SUCCESS;
544}
545
546/**
547 * @brief returns the value of an EthDB property
548 *
549 * @param portID ID of the port
550 * @param feature feature owning the property
551 * @param property ID of the property
552 * @param type location to store the property type into
553 * @param value location to store the property value into
554 *
555 * Note that this function is documented in the main component
556 * header file, IxEthDB.h.
557 *
558 * @return IX_ETH_DB_SUCCESS if the operation completed
559 * successfully or an appropriate error message otherwise
560 */
561IX_ETH_DB_PUBLIC
562IxEthDBStatus ixEthDBFeaturePropertyGet(IxEthDBPortId portID, IxEthDBFeature feature, IxEthDBProperty property, IxEthDBPropertyType *type, void *value)
563{
564 IX_ETH_DB_CHECK_PORT_EXISTS(portID);
565
566 IX_ETH_DB_CHECK_REFERENCE(type);
567
568 IX_ETH_DB_CHECK_REFERENCE(value);
569
570 if (feature == IX_ETH_DB_VLAN_QOS)
571 {
572 if (property == IX_ETH_DB_QOS_TRAFFIC_CLASS_COUNT_PROPERTY)
573 {
574 * (UINT32 *) value = ixEthDBPortInfo[portID].ixEthDBTrafficClassCount;
575 *type = IX_ETH_DB_INTEGER_PROPERTY;
576
577 return IX_ETH_DB_SUCCESS;
578 }
579 else if (property >= IX_ETH_DB_QOS_TRAFFIC_CLASS_0_RX_QUEUE_PROPERTY
580 && property <= IX_ETH_DB_QOS_TRAFFIC_CLASS_7_RX_QUEUE_PROPERTY)
581 {
582 UINT32 classDelta = property - IX_ETH_DB_QOS_TRAFFIC_CLASS_0_RX_QUEUE_PROPERTY;
583
584 if (classDelta >= ixEthDBPortInfo[portID].ixEthDBTrafficClassCount)
585 {
586 return IX_ETH_DB_FAIL;
587 }
588
589 * (UINT32 *) value = ixEthDBPortInfo[portID].ixEthDBTrafficClassAQMAssignments[classDelta];
590 *type = IX_ETH_DB_INTEGER_PROPERTY;
591
592 return IX_ETH_DB_SUCCESS;
593 }
594 }
595
596 return IX_ETH_DB_INVALID_ARG;
597}
598
599/**
600 * @brief sets the value of an EthDB property
601 *
602 * @param portID ID of the port
603 * @param feature feature owning the property
604 * @param property ID of the property
605 * @param value location containing the property value
606 *
607 * This function implements a private property intended
608 * only for EthAcc usage. Upon setting the IX_ETH_DB_QOS_QUEUE_CONFIGURATION_COMPLETE
609 * property (the value is ignored), the availability of traffic classes is
610 * frozen to whatever traffic class structure is currently in use.
611 * This means that if VLAN_QOS has been enabled before EthAcc
612 * initialization then all the defined traffic classes will be available;
613 * otherwise only one traffic class (0) will be available.
614 *
615 * Note that this function is documented in the main component
616 * header file, IxEthDB.h as not accepting any parameters. The
617 * current implementation is only intended for the private use of EthAcc.
618 *
619 * Also note that once this function is called the effect is irreversible,
620 * unless EthDB is complete unloaded and re-initialized.
621 *
622 * @return IX_ETH_DB_INVALID_ARG (no read-write properties are
623 * supported in this release)
624 */
625IX_ETH_DB_PUBLIC
626IxEthDBStatus ixEthDBFeaturePropertySet(IxEthDBPortId portID, IxEthDBFeature feature, IxEthDBProperty property, void *value)
627{
628 IX_ETH_DB_CHECK_PORT_EXISTS(portID);
629
630 if ((feature == IX_ETH_DB_VLAN_QOS) && (property == IX_ETH_DB_QOS_QUEUE_CONFIGURATION_COMPLETE))
631 {
632 ixEthDBPortInfo[portID].ixEthDBTrafficClassAvailable = ixEthDBPortInfo[portID].ixEthDBTrafficClassCount;
633
634 return IX_ETH_DB_SUCCESS;
635 }
636
637 return IX_ETH_DB_INVALID_ARG;
638}