blob: 99d2028eb409c3d7b0aa36c64994817c1ac5b532 [file] [log] [blame]
developer69bcd592024-03-25 14:26:39 +08001/* FILE NAME: air_sptag.h
2 * PURPOSE:
3 * Define the Special Tag function in AIR SDK.
4 *
5 * NOTES:
6 * None
7 */
8
9#ifndef AIR_SPTAG_H
10#define AIR_SPTAG_H
11
12/* INCLUDE FILE DECLARATIONS
13*/
14
15/* NAMING CONSTANT DECLARATIONS
16*/
17
18#define AIR_STAG_BUF_LEN (4)
19#define AIR_STAG_ALIGN_BIT_WIDTH (8)
20#define AIR_STAG_REPLACE_MODE_MAX_DP (10)
21
22/* cpu tx stag offset */
23#define AIR_STAG_TX_OPC_BIT_OFFSET (5)
24#define AIR_STAG_TX_OPC_BIT_WIDTH (3)
25#define AIR_STAG_TX_VPM_BIT_OFFSET (0)
26#define AIR_STAG_TX_VPM_BIT_WIDTH (2)
27#define AIR_STAG_TX_PCP_BIT_OFFSET (5)
28#define AIR_STAG_TX_PCP_BIT_WIDTH (3)
29#define AIR_STAG_TX_DEI_BIT_OFFSET (4)
30#define AIR_STAG_TX_DEI_BIT_WIDTH (1)
31
32/* cpu rx stag offset */
33#define AIR_STAG_RX_RSN_BIT_OFFSET (2)
34#define AIR_STAG_RX_RSN_BIT_WIDTH (3)
35#define AIR_STAG_RX_VPM_BIT_OFFSET (0)
36#define AIR_STAG_RX_VPM_BIT_WIDTH (2)
37#define AIR_STAG_RX_SP_BIT_OFFSET (0)
38#define AIR_STAG_RX_SP_BIT_WIDTH (5)
39#define AIR_STAG_RX_PCP_BIT_OFFSET (5)
40#define AIR_STAG_RX_PCP_BIT_WIDTH (3)
41#define AIR_STAG_RX_DEI_BIT_OFFSET (4)
42#define AIR_STAG_RX_DEI_BIT_WIDTH (1)
43#define AIR_PORT_NUM (6)
44
45#define AIR_PORT_FOREACH(bitmap, port) \
46 for(port = 0; port < AIR_PORT_NUM; port++) \
47 if(bitmap & BIT(port))
48
49
50/* MACRO FUNCTION DECLARATIONS
51*/
52
53/* DATA TYPE DECLARATIONS
54*/
55typedef enum
56{
57 AIR_STAG_MODE_INSERT,
58 AIR_STAG_MODE_REPLACE,
59 AIR_STAG_MODE_LAST
60} AIR_STAG_MODE_T;
61
62typedef enum
63{
64 /* Egress DP is port map */
65 AIR_STAG_OPC_PORTMAP,
66
67 /* Egress DP is port id */
68 AIR_STAG_OPC_PORTID,
69
70 /* Forward the packet according to lookup result */
71 AIR_STAG_OPC_LOOKUP,
72 AIR_STAG_OPC_LAST
73} AIR_STAG_OPC_T;
74
75typedef enum
76{
77 AIR_STAG_REASON_CODE_NORMAL,
78 AIR_STAG_REASON_CODE_SFLOW,
79 AIR_STAG_REASON_CODE_TTL_ERR,
80 AIR_STAG_REASON_CODE_ACL,
81 AIR_STAG_REASON_CODE_SA_FULL,
82 AIR_STAG_REASON_CODE_PORT_MOVE_ERR,
83 AIR_STAG_REASON_CODE_LAST,
84} AIR_STAG_REASON_CODE_T;
85
86typedef enum
87{
88 AIR_STAG_VPM_UNTAG,
89 AIR_STAG_VPM_TPID_8100,
90 AIR_STAG_VPM_TPID_88A8,
91 AIR_STAG_VPM_TPID_PRE_DEFINED,
92 AIR_STAG_VPM_LAST,
93} AIR_STAG_VPM_T;
94
95typedef struct AIR_STAG_TX_PARA_S
96{
97 /* destination port operation code */
98 AIR_STAG_OPC_T opc;
99
100 /* tag attribute */
101 AIR_STAG_VPM_T vpm;
102
103 /* destination port map */
104 UI32_T pbm;
105
106 /* PRI in vlan tag */
107 UI32_T pri :3;
108
109 /* CFI in vlan tag */
110 UI32_T cfi :1;
111
112 /* VID in vlan tag */
113 UI32_T vid :12;
114} AIR_STAG_TX_PARA_T;
115
116
117typedef struct AIR_SPTAG_RX_PARA_S
118{
119 AIR_STAG_REASON_CODE_T rsn; /* tag attribute */
120 AIR_STAG_VPM_T vpm; /* tag attribute */
121 UI32_T spn; /* source port */
122 UI32_T pri; /* PRI in vlan tag */
123 UI32_T cfi; /* CFI in vlan tag */
124 UI32_T vid; /* VID in vlan tag */
125}AIR_SPTAG_RX_PARA_T;
126
127/* EXPORTED SUBPROGRAM SPECIFICATIONS
128*/
129/* FUNCTION NAME: air_sptag_setState
130 * PURPOSE:
131 * Set special tag enable/disable for port
132 *
133 * INPUT:
134 * unit -- Device ID
135 * port -- Special tag Port
136 * sp_en -- special tag Enable or Disable
137 *
138 * OUTPUT:
139 * None
140 *
141 * RETURN:
142 * AIR_E_OK
143 * AIR_E_BAD_PARAMETER
144 *
145 * NOTES:
146 * None
147 */
148AIR_ERROR_NO_T
149air_sptag_setState(
150 const UI32_T unit,
151 const UI32_T port,
152 const BOOL_T sp_en);
153
154/* FUNCTION NAME: air_switch_getCpuPortEn
155 * PURPOSE:
156 * Get CPU port member
157 *
158 * INPUT:
159 * unit -- Device ID
160 * port -- Special tag Port
161 *
162 * OUTPUT:
163 * sp_en -- special tag enable or disable
164 *
165 * RETURN:
166 * AIR_E_OK
167 * AIR_E_BAD_PARAMETER
168 *
169 * NOTES:
170 * None
171 */
172AIR_ERROR_NO_T
173air_sptag_getState(
174 const UI32_T unit,
175 const UI32_T port,
176 BOOL_T *sp_en);
177
178/* FUNCTION NAME: air_sptag_setMode
179 * PURPOSE:
180 * Set special tag enable/disable for port
181 *
182 * INPUT:
183 * unit -- Device ID
184 * port -- Special tag Port
185 * mode -- insert mode or replace mode
186 *
187 * OUTPUT:
188 * None
189 *
190 * RETURN:
191 * AIR_E_OK
192 * AIR_E_BAD_PARAMETER
193 *
194 * NOTES:
195 * None
196 */
197AIR_ERROR_NO_T
198air_sptag_setMode(
199 const UI32_T unit,
200 const UI32_T port,
201 const BOOL_T mode);
202
203/* FUNCTION NAME: air_sptag_getMode
204 * PURPOSE:
205 * Get CPU port member
206 *
207 * INPUT:
208 * unit -- Device ID
209 * port -- Special tag Port
210 *
211 * OUTPUT:
212 * mode -- insert or replace mode
213 *
214 * RETURN:
215 * AIR_E_OK
216 * AIR_E_BAD_PARAMETER
217 *
218 * NOTES:
219 * None
220 */
221AIR_ERROR_NO_T
222air_sptag_getMode(
223 const UI32_T unit,
224 const UI32_T port,
225 BOOL_T *mode);
226
227/* FUNCTION NAME: air_sptag_encodeTx
228 * PURPOSE:
229 * Encode tx special tag into buffer.
230 * INPUT:
231 * unit -- Device ID
232 * ptr_sptag_tx -- Special tag parameters
233 * ptr_buf -- Buffer address
234 * ptr_len -- Buffer length
235 * OUTPUT:
236 * ptr_len -- Written buffer length
237 *
238 * RETURN:
239 * AIR_E_OK
240 * AIR_E_BAD_PARAMETER
241 *
242 * NOTES:
243 * None
244 */
245AIR_ERROR_NO_T
246air_sptag_encodeTx(
247 const UI32_T unit,
248 const AIR_STAG_MODE_T mode,
249 AIR_STAG_TX_PARA_T *ptr_sptag_tx,
250 UI8_T *ptr_buf,
251 UI32_T *ptr_len);
252
253/* FUNCTION NAME: air_sptag_decodeRx
254 * PURPOSE:
255 * Decode rx special tag from buffer.
256 * INPUT:
257 * unit -- Device ID
258 * ptr_buf -- Buffer address
259 * len -- Buffer length
260 * OUTPUT:
261 * ptr_sptag_rx -- Special tag parameters
262 *
263 * RETURN:
264 * AIR_E_OK
265 * AIR_E_BAD_PARAMETER
266 *
267 * NOTES:
268 * None
269 */
270AIR_ERROR_NO_T
271air_sptag_decodeRx(
272 const UI32_T unit,
273 const UI8_T *ptr_buf,
274 const UI32_T len,
275 AIR_SPTAG_RX_PARA_T *ptr_sptag_rx);
276
277#endif /* AIR_SPTAG_H */