IxEthDBPortDefs.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /**
  2. * @file IxEthDBPortDefs.h
  3. *
  4. * @brief Public definition of the ports and port capabilities
  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
  16. * SPDX-License-Identifier: BSD-3-Clause
  17. * @par
  18. * -- End of Copyright Notice --
  19. */
  20. /**
  21. * @defgroup IxEthDBPortDefs IXP400 Ethernet Database Port Definitions (IxEthDBPortDefs)
  22. *
  23. * @brief IXP400 Public definition of the ports and port capabilities
  24. *
  25. * @{
  26. */
  27. #ifndef IxEthDBPortDefs_H
  28. #define IxEthDBPortDefs_H
  29. /**
  30. * @brief Port types - currently only Ethernet NPEs are recognized as specific types
  31. * All other (user-defined) ports must be specified as IX_ETH_GENERIC
  32. */
  33. typedef enum
  34. {
  35. IX_ETH_GENERIC = 0, /**< generic ethernet port */
  36. IX_ETH_NPE /**< specific Ethernet NPE */
  37. } IxEthDBPortType;
  38. /**
  39. * @brief Port capabilities - used by ixEthAccDatabaseMaintenance to decide whether it
  40. * should manually age entries or not depending on the port capabilities.
  41. *
  42. * Ethernet NPEs have aging capabilities, meaning that they will age the entries
  43. * automatically (by themselves).*/
  44. typedef enum
  45. {
  46. IX_ETH_NO_CAPABILITIES = 0, /**< no aging capabilities */
  47. IX_ETH_ENTRY_AGING = 0x1 /**< aging capabilities present */
  48. } IxEthDBPortCapability;
  49. /**
  50. * @brief Port Definition - a structure contains the Port type and capabilities
  51. */
  52. typedef struct
  53. {
  54. IxEthDBPortType type;
  55. IxEthDBPortCapability capabilities;
  56. } IxEthDBPortDefinition;
  57. /**
  58. * @brief Port definitions structure, indexed on the port ID
  59. * @warning Ports 0 and 1 are used by the Ethernet access component therefore
  60. * it is essential to be left untouched. Port 2 here (WAN) is given as
  61. * an example port. The NPE firmware also assumes the NPE B to be
  62. * the port 0 and NPE C to be the port 1.
  63. *
  64. * @note that only 32 ports (0..31) are supported by EthDB
  65. */
  66. static const IxEthDBPortDefinition ixEthDBPortDefinitions[] =
  67. {
  68. /* id type capabilities */
  69. { /* 0 */ IX_ETH_NPE, IX_ETH_NO_CAPABILITIES }, /* Ethernet NPE B */
  70. { /* 1 */ IX_ETH_NPE, IX_ETH_NO_CAPABILITIES }, /* Ethernet NPE C */
  71. { /* 2 */ IX_ETH_NPE, IX_ETH_NO_CAPABILITIES }, /* Ethernet NPE A */
  72. { /* 3 */ IX_ETH_GENERIC, IX_ETH_NO_CAPABILITIES }, /* WAN port */
  73. };
  74. /**
  75. * @def IX_ETH_DB_NUMBER_OF_PORTS
  76. * @brief number of supported ports
  77. */
  78. #define IX_ETH_DB_NUMBER_OF_PORTS ARRAY_SIZE(ixEthDBPortDefinitions)
  79. /**
  80. * @def IX_ETH_DB_UNKNOWN_PORT
  81. * @brief definition of an unknown port
  82. */
  83. #define IX_ETH_DB_UNKNOWN_PORT (0xff)
  84. /**
  85. * @def IX_ETH_DB_ALL_PORTS
  86. * @brief Special port ID indicating all the ports
  87. * @note This port ID can be used only by a subset of the EthDB API; each
  88. * function specifically mentions whether this is a valid parameter as the port ID
  89. */
  90. #define IX_ETH_DB_ALL_PORTS (IX_ETH_DB_NUMBER_OF_PORTS + 1)
  91. /**
  92. * @def IX_ETH_DB_PORTS_ASSERTION
  93. * @brief catch invalid port definitions (<2) with a
  94. * compile-time assertion resulting in a duplicate case error.
  95. */
  96. #define IX_ETH_DB_PORTS_ASSERTION { switch(0) { case 0 : ; case 1 : ; case IX_ETH_DB_NUMBER_OF_PORTS : ; }}
  97. /**
  98. * @def IX_ETH_DB_CHECK_PORT(portID)
  99. * @brief safety checks to verify whether the port is invalid or uninitialized
  100. */
  101. #define IX_ETH_DB_CHECK_PORT(portID) \
  102. { \
  103. if ((portID) >= IX_ETH_DB_NUMBER_OF_PORTS) \
  104. { \
  105. return IX_ETH_DB_INVALID_PORT; \
  106. } \
  107. \
  108. if (!ixEthDBPortInfo[(portID)].enabled) \
  109. { \
  110. return IX_ETH_DB_PORT_UNINITIALIZED; \
  111. } \
  112. }
  113. /**
  114. * @def IX_ETH_DB_CHECK_PORT_ALL(portID)
  115. * @brief safety checks to verify whether the port is invalid or uninitialized;
  116. * tolerates the use of IX_ETH_DB_ALL_PORTS
  117. */
  118. #define IX_ETH_DB_CHECK_PORT_ALL(portID) \
  119. { \
  120. if ((portID) != IX_ETH_DB_ALL_PORTS) \
  121. IX_ETH_DB_CHECK_PORT(portID) \
  122. }
  123. #endif /* IxEthDBPortDefs_H */
  124. /**
  125. *@}
  126. */