blob: c3acbdddef735f57b26460d0050075b82e0e2d12 [file] [log] [blame]
Wolfgang Denk4646d2a2006-05-30 15:56:48 +02001/**
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/**
46 * @defgroup IxEthDBPortDefs IXP400 Ethernet Database Port Definitions (IxEthDBPortDefs)
47 *
48 * @brief IXP400 Public definition of the ports and port capabilities
49 *
50 * @{
51 */
52
53#ifndef IxEthDBPortDefs_H
54#define IxEthDBPortDefs_H
55
56/**
57 * @brief Port types - currently only Ethernet NPEs are recognized as specific types
58 * All other (user-defined) ports must be specified as IX_ETH_GENERIC
59 */
60typedef enum
61{
62 IX_ETH_GENERIC = 0, /**< generic ethernet port */
63 IX_ETH_NPE /**< specific Ethernet NPE */
64} IxEthDBPortType;
65
66/**
67 * @brief Port capabilities - used by ixEthAccDatabaseMaintenance to decide whether it
68 * should manually age entries or not depending on the port capabilities.
69 *
70 * Ethernet NPEs have aging capabilities, meaning that they will age the entries
71 * automatically (by themselves).*/
72typedef enum
73{
74 IX_ETH_NO_CAPABILITIES = 0, /**< no aging capabilities */
75 IX_ETH_ENTRY_AGING = 0x1 /**< aging capabilities present */
76} IxEthDBPortCapability;
77
78/**
79 * @brief Port Definition - a structure contains the Port type and capabilities
80 */
81typedef struct
82{
83 IxEthDBPortType type;
84 IxEthDBPortCapability capabilities;
85} IxEthDBPortDefinition;
86
87/**
88 * @brief Port definitions structure, indexed on the port ID
89 * @warning Ports 0 and 1 are used by the Ethernet access component therefore
90 * it is essential to be left untouched. Port 2 here (WAN) is given as
91 * an example port. The NPE firmware also assumes the NPE B to be
92 * the port 0 and NPE C to be the port 1.
93 *
94 * @note that only 32 ports (0..31) are supported by EthDB
95 */
96static const IxEthDBPortDefinition ixEthDBPortDefinitions[] =
97{
98 /* id type capabilities */
99 { /* 0 */ IX_ETH_NPE, IX_ETH_NO_CAPABILITIES }, /* Ethernet NPE B */
100 { /* 1 */ IX_ETH_NPE, IX_ETH_NO_CAPABILITIES }, /* Ethernet NPE C */
101 { /* 2 */ IX_ETH_NPE, IX_ETH_NO_CAPABILITIES }, /* Ethernet NPE A */
102 { /* 3 */ IX_ETH_GENERIC, IX_ETH_NO_CAPABILITIES }, /* WAN port */
103};
104
105/**
106 * @def IX_ETH_DB_NUMBER_OF_PORTS
107 * @brief number of supported ports
108 */
109#define IX_ETH_DB_NUMBER_OF_PORTS (sizeof (ixEthDBPortDefinitions) / sizeof (ixEthDBPortDefinitions[0]))
110
111/**
112 * @def IX_ETH_DB_UNKNOWN_PORT
113 * @brief definition of an unknown port
114 */
115#define IX_ETH_DB_UNKNOWN_PORT (0xff)
116
117/**
118 * @def IX_ETH_DB_ALL_PORTS
119 * @brief Special port ID indicating all the ports
120 * @note This port ID can be used only by a subset of the EthDB API; each
121 * function specifically mentions whether this is a valid parameter as the port ID
122 */
123#define IX_ETH_DB_ALL_PORTS (IX_ETH_DB_NUMBER_OF_PORTS + 1)
124
125/**
126 * @def IX_ETH_DB_PORTS_ASSERTION
127 * @brief catch invalid port definitions (<2) with a
128 * compile-time assertion resulting in a duplicate case error.
129 */
130#define IX_ETH_DB_PORTS_ASSERTION { switch(0) { case 0 : ; case 1 : ; case IX_ETH_DB_NUMBER_OF_PORTS : ; }}
131
132/**
133 * @def IX_ETH_DB_CHECK_PORT(portID)
134 * @brief safety checks to verify whether the port is invalid or uninitialized
135 */
136#define IX_ETH_DB_CHECK_PORT(portID) \
137{ \
138 if ((portID) >= IX_ETH_DB_NUMBER_OF_PORTS) \
139 { \
140 return IX_ETH_DB_INVALID_PORT; \
141 } \
142 \
143 if (!ixEthDBPortInfo[(portID)].enabled) \
144 { \
145 return IX_ETH_DB_PORT_UNINITIALIZED; \
146 } \
147}
148
149/**
150 * @def IX_ETH_DB_CHECK_PORT_ALL(portID)
151 * @brief safety checks to verify whether the port is invalid or uninitialized;
152 * tolerates the use of IX_ETH_DB_ALL_PORTS
153 */
154#define IX_ETH_DB_CHECK_PORT_ALL(portID) \
155{ \
156 if ((portID) != IX_ETH_DB_ALL_PORTS) \
157 IX_ETH_DB_CHECK_PORT(portID) \
158}
159
160#endif /* IxEthDBPortDefs_H */
161/**
162 *@}
163 */