summaryrefslogtreecommitdiff
path: root/drivers/net/npe/include/IxEthDBPortDefs.h
blob: 9f5e4678329dd27b7575ad95f402570b20bc8aeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
 * @file IxEthDBPortDefs.h
 *
 * @brief Public definition of the ports and port capabilities
 * 
 * @par
 * IXP400 SW Release version 2.0
 * 
 * -- Copyright Notice --
 * 
 * @par
 * Copyright 2001-2005, Intel Corporation.
 * All rights reserved.
 * 
 * @par
 * SPDX-License-Identifier:	BSD-3-Clause
 * @par
 * -- End of Copyright Notice --
 */

/**
 * @defgroup IxEthDBPortDefs IXP400 Ethernet Database Port Definitions (IxEthDBPortDefs)
 *
 * @brief IXP400 Public definition of the ports and port capabilities
 *
 * @{
 */

#ifndef IxEthDBPortDefs_H
#define IxEthDBPortDefs_H

/** 
 * @brief Port types - currently only Ethernet NPEs are recognized as specific types 
 * All other (user-defined) ports must be specified as IX_ETH_GENERIC
 */
typedef enum
{
    IX_ETH_GENERIC = 0, /**< generic ethernet port */
    IX_ETH_NPE          /**< specific Ethernet NPE */
} IxEthDBPortType;

/** 
 * @brief Port capabilities - used by ixEthAccDatabaseMaintenance to decide whether it
 * should manually age entries or not depending on the port capabilities.
 *
 * Ethernet NPEs have aging capabilities, meaning that they will age the entries
 * automatically (by themselves).*/
typedef enum
{
    IX_ETH_NO_CAPABILITIES = 0,   /**< no aging capabilities */
    IX_ETH_ENTRY_AGING     = 0x1  /**< aging capabilities present */
} IxEthDBPortCapability;

/** 
 * @brief Port Definition - a structure contains the Port type and capabilities 
 */
typedef struct
{
    IxEthDBPortType type;
    IxEthDBPortCapability capabilities;
} IxEthDBPortDefinition;

/** 
 * @brief Port definitions structure, indexed on the port ID
 * @warning Ports 0 and 1 are used by the Ethernet access component therefore
 * it is essential to be left untouched. Port 2 here (WAN) is given as 
 * an example port. The NPE firmware also assumes the NPE B to be
 * the port 0 and NPE C to be the port 1.
 *
 * @note that only 32 ports (0..31) are supported by EthDB
 */
static const IxEthDBPortDefinition ixEthDBPortDefinitions[] = 
{
    /*    id       type              capabilities */
    {   /* 0 */    IX_ETH_NPE,       IX_ETH_NO_CAPABILITIES },    /* Ethernet NPE B */
    {   /* 1 */    IX_ETH_NPE,       IX_ETH_NO_CAPABILITIES },    /* Ethernet NPE C */
    {   /* 2 */    IX_ETH_NPE,       IX_ETH_NO_CAPABILITIES },    /* Ethernet NPE A */
    {   /* 3 */    IX_ETH_GENERIC,   IX_ETH_NO_CAPABILITIES },    /* WAN port */
};

/** 
 * @def IX_ETH_DB_NUMBER_OF_PORTS
 * @brief number of supported ports 
 */
#define IX_ETH_DB_NUMBER_OF_PORTS ARRAY_SIZE(ixEthDBPortDefinitions)

/**
 * @def IX_ETH_DB_UNKNOWN_PORT
 * @brief definition of an unknown port
 */
#define IX_ETH_DB_UNKNOWN_PORT (0xff)

/** 
 * @def IX_ETH_DB_ALL_PORTS
 * @brief Special port ID indicating all the ports
 * @note This port ID can be used only by a subset of the EthDB API; each
 * function specifically mentions whether this is a valid parameter as the port ID
 */
#define IX_ETH_DB_ALL_PORTS (IX_ETH_DB_NUMBER_OF_PORTS + 1)

/**
 * @def IX_ETH_DB_PORTS_ASSERTION
 * @brief catch invalid port definitions (<2) with a 
 * compile-time assertion resulting in a duplicate case error. 
 */
#define IX_ETH_DB_PORTS_ASSERTION { switch(0) { case 0 : ; case 1 : ; case IX_ETH_DB_NUMBER_OF_PORTS : ; }}

/** 
 * @def IX_ETH_DB_CHECK_PORT(portID)
 * @brief safety checks to verify whether the port is invalid or uninitialized
 */
#define IX_ETH_DB_CHECK_PORT(portID) \
{ \
  if ((portID) >= IX_ETH_DB_NUMBER_OF_PORTS) \
  { \
      return IX_ETH_DB_INVALID_PORT; \
  } \
  \
  if (!ixEthDBPortInfo[(portID)].enabled) \
  { \
      return IX_ETH_DB_PORT_UNINITIALIZED; \
  } \
}

/**
 * @def IX_ETH_DB_CHECK_PORT_ALL(portID)
 * @brief safety checks to verify whether the port is invalid or uninitialized; 
 * tolerates the use of IX_ETH_DB_ALL_PORTS
 */
#define IX_ETH_DB_CHECK_PORT_ALL(portID) \
{ \
  if ((portID) != IX_ETH_DB_ALL_PORTS) \
    IX_ETH_DB_CHECK_PORT(portID) \
}

#endif /* IxEthDBPortDefs_H */
/**
 *@}
 */