IxEthDBPortDefs.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. * 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. * @par
  29. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  30. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  32. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  33. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  34. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  35. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  36. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  37. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  38. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  39. * SUCH DAMAGE.
  40. *
  41. * @par
  42. * -- End of Copyright Notice --
  43. */
  44. /**
  45. * @defgroup IxEthDBPortDefs IXP400 Ethernet Database Port Definitions (IxEthDBPortDefs)
  46. *
  47. * @brief IXP400 Public definition of the ports and port capabilities
  48. *
  49. * @{
  50. */
  51. #ifndef IxEthDBPortDefs_H
  52. #define IxEthDBPortDefs_H
  53. /**
  54. * @brief Port types - currently only Ethernet NPEs are recognized as specific types
  55. * All other (user-defined) ports must be specified as IX_ETH_GENERIC
  56. */
  57. typedef enum
  58. {
  59. IX_ETH_GENERIC = 0, /**< generic ethernet port */
  60. IX_ETH_NPE /**< specific Ethernet NPE */
  61. } IxEthDBPortType;
  62. /**
  63. * @brief Port capabilities - used by ixEthAccDatabaseMaintenance to decide whether it
  64. * should manually age entries or not depending on the port capabilities.
  65. *
  66. * Ethernet NPEs have aging capabilities, meaning that they will age the entries
  67. * automatically (by themselves).*/
  68. typedef enum
  69. {
  70. IX_ETH_NO_CAPABILITIES = 0, /**< no aging capabilities */
  71. IX_ETH_ENTRY_AGING = 0x1 /**< aging capabilities present */
  72. } IxEthDBPortCapability;
  73. /**
  74. * @brief Port Definition - a structure contains the Port type and capabilities
  75. */
  76. typedef struct
  77. {
  78. IxEthDBPortType type;
  79. IxEthDBPortCapability capabilities;
  80. } IxEthDBPortDefinition;
  81. /**
  82. * @brief Port definitions structure, indexed on the port ID
  83. * @warning Ports 0 and 1 are used by the Ethernet access component therefore
  84. * it is essential to be left untouched. Port 2 here (WAN) is given as
  85. * an example port. The NPE firmware also assumes the NPE B to be
  86. * the port 0 and NPE C to be the port 1.
  87. *
  88. * @note that only 32 ports (0..31) are supported by EthDB
  89. */
  90. static const IxEthDBPortDefinition ixEthDBPortDefinitions[] =
  91. {
  92. /* id type capabilities */
  93. { /* 0 */ IX_ETH_NPE, IX_ETH_NO_CAPABILITIES }, /* Ethernet NPE B */
  94. { /* 1 */ IX_ETH_NPE, IX_ETH_NO_CAPABILITIES }, /* Ethernet NPE C */
  95. { /* 2 */ IX_ETH_NPE, IX_ETH_NO_CAPABILITIES }, /* Ethernet NPE A */
  96. { /* 3 */ IX_ETH_GENERIC, IX_ETH_NO_CAPABILITIES }, /* WAN port */
  97. };
  98. /**
  99. * @def IX_ETH_DB_NUMBER_OF_PORTS
  100. * @brief number of supported ports
  101. */
  102. #define IX_ETH_DB_NUMBER_OF_PORTS (sizeof (ixEthDBPortDefinitions) / sizeof (ixEthDBPortDefinitions[0]))
  103. /**
  104. * @def IX_ETH_DB_UNKNOWN_PORT
  105. * @brief definition of an unknown port
  106. */
  107. #define IX_ETH_DB_UNKNOWN_PORT (0xff)
  108. /**
  109. * @def IX_ETH_DB_ALL_PORTS
  110. * @brief Special port ID indicating all the ports
  111. * @note This port ID can be used only by a subset of the EthDB API; each
  112. * function specifically mentions whether this is a valid parameter as the port ID
  113. */
  114. #define IX_ETH_DB_ALL_PORTS (IX_ETH_DB_NUMBER_OF_PORTS + 1)
  115. /**
  116. * @def IX_ETH_DB_PORTS_ASSERTION
  117. * @brief catch invalid port definitions (<2) with a
  118. * compile-time assertion resulting in a duplicate case error.
  119. */
  120. #define IX_ETH_DB_PORTS_ASSERTION { switch(0) { case 0 : ; case 1 : ; case IX_ETH_DB_NUMBER_OF_PORTS : ; }}
  121. /**
  122. * @def IX_ETH_DB_CHECK_PORT(portID)
  123. * @brief safety checks to verify whether the port is invalid or uninitialized
  124. */
  125. #define IX_ETH_DB_CHECK_PORT(portID) \
  126. { \
  127. if ((portID) >= IX_ETH_DB_NUMBER_OF_PORTS) \
  128. { \
  129. return IX_ETH_DB_INVALID_PORT; \
  130. } \
  131. \
  132. if (!ixEthDBPortInfo[(portID)].enabled) \
  133. { \
  134. return IX_ETH_DB_PORT_UNINITIALIZED; \
  135. } \
  136. }
  137. /**
  138. * @def IX_ETH_DB_CHECK_PORT_ALL(portID)
  139. * @brief safety checks to verify whether the port is invalid or uninitialized;
  140. * tolerates the use of IX_ETH_DB_ALL_PORTS
  141. */
  142. #define IX_ETH_DB_CHECK_PORT_ALL(portID) \
  143. { \
  144. if ((portID) != IX_ETH_DB_ALL_PORTS) \
  145. IX_ETH_DB_CHECK_PORT(portID) \
  146. }
  147. #endif /* IxEthDBPortDefs_H */
  148. /**
  149. *@}
  150. */