blob: e1eaf3acbc74110ffe55055c235a36dc752e2c00 [file] [log] [blame]
developer69bcd592024-03-25 14:26:39 +08001/* FILE NAME: air_qos.h
2* PURPOSE:
3 * Define the Quailty of Service function in AIR SDK.
4*
5* NOTES:
6* None
7*/
8
9#ifndef AIR_QOS_H
10#define AIR_QOS_H
11
12/* INCLUDE FILE DECLARATIONS
13*/
14
15/* NAMING CONSTANT DECLARATIONS
16*/
17#define AIR_QOS_MAX_TOKEN (128)
18#define AIR_QOS_MAX_CIR (80001)
19#define AIR_QOS_TOKEN_PERIOD_1_4MS (5)
20#define AIR_QOS_TOKEN_PERIOD_4MS (9)
21#define AIR_QOS_L1_RATE_LIMIT (0x18)
22#define AIR_QOS_L2_RATE_LIMIT (0x04)
23#define AIR_QOS_QUEUE_PIM_WIDTH (3)
24#define AIR_QOS_QUEUE_PIM_MASK (7)
25#define AIR_QOS_QUEUE_DEFAULT_VAL (0x222227)
26#define AIR_QOS_QUEUE_TRUST_HIGH_WEIGHT (6)
27#define AIR_QOS_QUEUE_TRUST_MID_WEIGHT (5)
28#define AIR_QOS_QUEUE_TRUST_LOW_WEIGHT (4)
29#define AIR_QOS_SHAPER_RATE_MAX_EXP (4)
30#define AIR_QOS_SHAPER_RATE_MAX_MAN (0x1ffff)
31#define AIR_QOS_SHAPER_RATE_MIN_WEIGHT (1)
32#define AIR_QOS_SHAPER_RATE_MAX_WEIGHT (128)
33#define AIR_QOS_QUEUE_0 (0)
34#define AIR_QOS_QUEUE_1 (1)
35#define AIR_QOS_QUEUE_2 (2)
36#define AIR_QOS_QUEUE_3 (3)
37#define AIR_QOS_QUEUE_4 (4)
38#define AIR_QOS_QUEUE_5 (5)
39#define AIR_QOS_QUEUE_6 (6)
40#define AIR_QOS_QUEUE_7 (7)
41#define AIR_QOS_MIN_TRAFFIC_ARBITRATION_SCHEME_SP (1)
42#define AIR_QOS_MIN_TRAFFIC_ARBITRATION_SCHEME_WRR (0)
43#define AIR_QOS_MAX_TRAFFIC_ARBITRATION_SCHEME_SP (1)
44#define AIR_QOS_MAX_TRAFFIC_ARBITRATION_SCHEME_WFQ (0)
45#define AIR_QOS_MAX_EXCESS_SP (1)
46#define AIR_QOS_MAX_EXCESS_DROP (0)
47#define AIR_QOS_QUEUE_MAX_NUM (8)
48#define AIR_QOS_QUEUE_DSCP_MAX_NUM (64)
49#define AIR_MAX_NUM_OF_QUEUE (8) /*need to be replaced by AIR_QOS_QUEUE_MAX_NUM*/
50
51#define AIR_QOS_SHAPER_NOSETTING (0xffffffff)
52#define AIR_QOS_SHAPER_RATE_MIN_WEIGHT (1)
53#define AIR_QOS_SHAPER_RATE_MAX_WEIGHT (128)
54
55/* MACRO FUNCTION DECLARATIONS
56*/
57
58/* DATA TYPE DECLARATIONS
59*/
60typedef enum
61{
62 AIR_QOS_SCH_MODE_SP,
63 AIR_QOS_SCH_MODE_WRR,
64 AIR_QOS_SCH_MODE_WFQ,
65 AIR_QOS_SCH_MODE_LAST,
66} AIR_QOS_SCH_MODE_T;
67
68typedef union AIR_QOS_SHAPER_MIN_S
69{
70 struct
71 {
72 UI32_T min_rate_man :17;
73 UI32_T min_reserve :2;
74 UI32_T min_rate_en :1;
75 UI32_T min_rate_exp :4;
76 UI32_T min_weight :7;
77 UI32_T min_sp_wrr_q :1;
78 }raw;
79 UI32_T byte;
80}AIR_QOS_SHAPER_MIN_T;
81
82typedef union AIR_QOS_SHAPER_MAX_S
83{
84 struct
85 {
86 UI32_T max_rate_man :17;
87 UI32_T max_reserve :1;
88 UI32_T max_excess_en :1;
89 UI32_T max_rate_en :1;
90 UI32_T max_rate_exp :4;
91 UI32_T max_weight :7;
92 UI32_T max_sp_wfq_q :1;
93 }raw;
94 UI32_T byte;
95}AIR_QOS_SHAPER_MAX_T;
96
97typedef enum
98{
99 /* The packet priority is based on port's priority. */
100 AIR_QOS_TRUST_MODE_PORT,
101
102 /*
103 * The precedence of packet priority is based on 802.1p,
104 * then port's priority.
105 */
106 AIR_QOS_TRUST_MODE_1P_PORT,
107
108 /*
109 * The precedence of packet priority is based on DSCP,
110 * then port's priority.
111 */
112 AIR_QOS_TRUST_MODE_DSCP_PORT,
113
114 /*
115 * The precedence of packet priority is based on DSCP, 802.1p,
116 * then port's priority.
117 */
118 AIR_QOS_TRUST_MODE_DSCP_1P_PORT,
119 AIR_QOS_TRUST_MODE_LAST
120} AIR_QOS_TRUST_MODE_T;
121
122typedef union AIR_QOS_QUEUE_UPW_S
123{
124 struct
125 {
126 UI32_T csr_acl_weight :3;
127 UI32_T :1;
128 UI32_T csr_stag_weight :3;/*Not use yet*/
129 UI32_T :1;
130 UI32_T csr_1p_weight :3;
131 UI32_T :1;
132 UI32_T csr_dscp_weight :3;
133 UI32_T :1;
134 UI32_T csr_port_weight :3;
135 UI32_T :1;
136 UI32_T csr_arl_weight :3;
137 UI32_T :9;
138 }raw;
139 UI32_T byte;
140}AIR_QOS_QUEUE_UPW_T;
141
142typedef union AIR_QOS_QUEUE_PEM_S
143{
144 struct
145 {
146 UI32_T csr_dscp_pri_l :6;/*Not use yet*/
147 UI32_T csr_que_lan_l :2;/*Not use yet*/
148 UI32_T csr_que_cpu_l :3;
149 UI32_T csr_tag_pri_l :3;/*Not use yet*/
150 UI32_T :2;
151 UI32_T csr_dscp_pri_h :6;/*Not use yet*/
152 UI32_T csr_que_lan_h :2;/*Not use yet*/
153 UI32_T csr_que_cpu_h :3;
154 UI32_T csr_tag_pri_h :3;/*Not use yet*/
155 UI32_T :2;
156 }raw;
157 UI32_T byte;
158}AIR_QOS_QUEUE_PEM_T;
159
160typedef enum
161{
162 AIR_QOS_RATE_DIR_INGRESS,
163 AIR_QOS_RATE_DIR_EGRESS,
164 AIR_QOS_RATE_DIR_LAST
165} AIR_QOS_RATE_DIR_T;
166
167typedef struct AIR_RATE_LIMIT_S
168{
169#define AIR_QOS_RATE_LIMIT_CFG_FLAGS_ENABLE_INGRESS (1U << 0)
170#define AIR_QOS_RATE_LIMIT_CFG_FLAGS_ENABLE_EGRESS (1U << 1)
171 UI32_T flags;
172
173 /*
174 * The limit cover up to 2.5G
175 * Rate = CIR * 32kbps
176 * Range = 0..80000
177 */
178 UI32_T ingress_cir;
179 UI32_T egress_cir;
180
181 /*
182 * Bucket = Max{(CBS * 512), (CIR * 2500)} Bytes
183 * Range: 0..127
184 */
185 UI32_T ingress_cbs;
186 UI32_T egress_cbs;
187} AIR_QOS_RATE_LIMIT_CFG_T;
188
189
190/* EXPORTED SUBPROGRAM SPECIFICATIONS
191*/
192
193/* FUNCTION NAME: air_qos_setScheduleAlgo
194 * PURPOSE:
195 * Set schedule mode of a port queue.
196 * INPUT:
197 * unit -- Device unit number
198 * port -- Port id
199 * queue -- Queue id
200 * sch_mode -- AIR_QOS_SCH_MODE_T
201 * weight -- weight for WRR/WFQ
202 * OUTPUT:
203 * None
204 * RETURN:
205 * AIR_E_OK -- Operation success.
206 * AIR_E_BAD_PARAMETER -- Parameter is wrong.
207 * NOTES:
208 * Weight default value is 1, only for WRR/WFQ mode
209 */
210AIR_ERROR_NO_T
211air_qos_setScheduleAlgo(
212 const UI32_T unit,
213 const UI32_T port,
214 const UI32_T queue,
215 const AIR_QOS_SCH_MODE_T sch_mode,
216 const UI32_T weight);
217
218
219/* FUNCTION NAME: air_qos_getScheduleAlgo
220 * PURPOSE:
221 * Get schedule mode of a port queue.
222 *
223 * INPUT:
224 * unit -- Select device ID
225 * port -- Port id
226 * queue -- Queue id
227 * OUTPUT:
228 * ptr_sch_mode -- AIR_QOS_SCH_MODE_T
229 * ptr_weight -- weight for WRR/WFQ
230 * RETURN:
231 * AIR_E_OK
232 * AIR_E_BAD_PARAMETER
233 *
234 * NOTES:
235 * None
236 */
237AIR_ERROR_NO_T
238air_qos_getScheduleAlgo(
239 const UI32_T unit,
240 const UI32_T port,
241 const UI32_T queue,
242 AIR_QOS_SCH_MODE_T *ptr_sch_mode,
243 UI32_T *ptr_weight);
244
245/* FUNCTION NAME: air_qos_setTrustMode
246 * PURPOSE:
247 * Set qos trust mode value.
248 * INPUT:
249 * unit -- Device unit number
250 * port -.Select port number
251 * mode -- Qos support mode
252 * AIR_QOS_TRUST_MODE_T
253 * OUTPUT:
254 * None
255 * RETURN:
256 * AIR_E_OK -- Operation success.
257 * AIR_E_BAD_PARAMETER -- Parameter is wrong.
258 * NOTES:
259 * None
260 */
261
262AIR_ERROR_NO_T
263air_qos_setTrustMode(
264 const UI32_T unit,
265 const UI32_T port,
266 const AIR_QOS_TRUST_MODE_T mode);
267
268
269/* FUNCTION NAME: air_qos_getTrustMode
270 * PURPOSE:
271 * Get qos trust mode value.
272 *
273 * INPUT:
274 * unit -- Select device ID
275 * port -.Select port number
276 * OUTPUT:
277 * ptr_weight -- All Qos weight value
278 * RETURN:
279 * AIR_E_OK
280 * AIR_E_BAD_PARAMETER
281 *
282 * NOTES:
283 * None
284 */
285AIR_ERROR_NO_T
286air_qos_getTrustMode(
287 const UI32_T unit,
288 const UI32_T port,
289 AIR_QOS_TRUST_MODE_T *const ptr_mode);
290
291/* FUNCTION NAME: air_qos_setPri2Queue
292 * PURPOSE:
293 * Set per port priority to out queue.
294 *
295 * INPUT:
296 * unit -- Select device ID
297 * pri -- Qos pri value
298 * queue -- Qos Queue value
299 *
300 * OUTPUT:
301 * None
302 *
303 * RETURN:
304 * AIR_E_OK
305 * AIR_E_BAD_PARAMETER
306 *
307 * NOTES:
308 * None
309 */
310AIR_ERROR_NO_T
311air_qos_setPri2Queue(
312 const UI32_T unit,
313 const UI32_T pri,
314 const UI32_T queue);
315
316/* FUNCTION NAME: air_qos_getPri2Queue
317 * PURPOSE:
318 * Get per port priority to out queue.
319 *
320 * INPUT:
321 * unit -- Select device ID
322 * pri -- Qos pri value
323 *
324 * OUTPUT:
325 * ptr_queue -- Select out queue (0..7)
326 *
327 * RETURN:
328 * AIR_E_OK
329 * AIR_E_BAD_PARAMETER
330 *
331 * NOTES:
332 * None
333 */
334AIR_ERROR_NO_T
335air_qos_getPri2Queue(
336 const UI32_T unit,
337 const UI32_T pri,
338 UI32_T *const ptr_queue);
339
340/* FUNCTION NAME: air_qos_setDscp2Pri
341 * PURPOSE:
342 * Set DSCP mapping to priority.
343 *
344 * INPUT:
345 * unit -- Select device ID
346 * dscp -- Select DSCP value (0..63)
347 * priority -- Select priority (0..7)
348 *
349 * OUTPUT:
350 * None
351 *
352 * RETURN:
353 * AIR_E_OK
354 * AIR_E_BAD_PARAMETER
355 *
356 * NOTES:
357 * None
358 */
359AIR_ERROR_NO_T
360air_qos_setDscp2Pri(
361 const UI32_T unit,
362 const UI32_T dscp,
363 const UI32_T pri);
364
365/* FUNCTION NAME: air_qos_getDscp2Pri
366 * PURPOSE:
367 * Get DSCP mapping priority.
368 *
369 * INPUT:
370 * unit -- Select device ID
371 * dscp -- Select DSCP value (0..63)
372 *
373 * OUTPUT:
374 * ptr_pri -- Priority value (0..7)
375 *
376 * RETURN:
377 * AIR_E_OK
378 * AIR_E_BAD_PARAMETER
379 *
380 * NOTES:
381 * None
382 */
383AIR_ERROR_NO_T
384air_qos_getDscp2Pri(
385 const UI32_T unit,
386 const UI32_T dscp,
387 UI32_T * const ptr_pri);
388
389/* FUNCTION NAME: air_qos_setRateLimitEnable
390 * PURPOSE:
391 * Enable or disable port rate limit.
392 *
393 * INPUT:
394 * unit -- Select device ID
395 * port -- Select port number (0..6)
396 * dir -- AIR_QOS_RATE_DIR_INGRESS
397 * AIR_QOS_RATE_DIR_EGRESS
398 * rate_en -- TRUE: eanble rate limit
399 * FALSE: disable rate limit
400 * OUTPUT:
401 * None
402 *
403 * RETURN:
404 * AIR_E_OK
405 * AIR_E_BAD_PARAMETER
406 *
407 * NOTES:
408 * None
409 */
410AIR_ERROR_NO_T
411air_qos_setRateLimitEnable(
412 const UI32_T unit,
413 const UI32_T port,
414 const AIR_QOS_RATE_DIR_T dir,
415 const BOOL_T enable);
416
417/* FUNCTION NAME: air_qos_getRateLimitEnable
418 * PURPOSE:
419 * Get port rate limit state.
420 *
421 * INPUT:
422 * unit -- Select device ID
423 * port -- Select port number (0..6)
424 * dir -- AIR_QOS_RATE_DIR_T
425 * OUTPUT:
426 * ptr_enable -- TRUE: eanble rate limit
427 * FALSE: disable rate limit
428 * RETURN:
429 * AIR_E_OK
430 * AIR_E_BAD_PARAMETER
431 *
432 * NOTES:
433 * None
434 */
435AIR_ERROR_NO_T
436air_qos_getRateLimitEnable(
437 const UI32_T unit,
438 const UI32_T port,
439 const AIR_QOS_RATE_DIR_T dir,
440 BOOL_T *ptr_enable);
441
442/* FUNCTION NAME: air_qos_setRateLimit
443 * PURPOSE:
444 * Set per port rate limit.
445 *
446 * INPUT:
447 * unit -- Select device ID
448 * port -- Select port number
449 * ptr_cfg -- AIR_QOS_RATE_LIMIT_CFG_T
450 *
451 * OUTPUT:
452 * None
453 *
454 * RETURN:
455 * AIR_E_OK
456 * AIR_E_BAD_PARAMETER
457 *
458 * NOTES:
459 * None
460 */
461AIR_ERROR_NO_T
462air_qos_setRateLimit(
463 const UI32_T unit,
464 const UI32_T port,
465 AIR_QOS_RATE_LIMIT_CFG_T *ptr_cfg);
466
467/* FUNCTION NAME: air_qos_getRateLimit
468 * PURPOSE:
469 * Get per port rate limit.
470 *
471 * INPUT:
472 * unit -- Select device ID
473 * port -- Select port number
474 *
475 * OUTPUT:
476 * ptr_cfg -- AIR_QOS_RATE_LIMIT_CFG_T
477 *
478 * RETURN:
479 * AIR_E_OK
480 * AIR_E_BAD_PARAMETER
481 *
482 * NOTES:
483 * None
484 */
485AIR_ERROR_NO_T
486air_qos_getRateLimit(
487 const UI32_T unit,
488 const UI32_T port,
489 AIR_QOS_RATE_LIMIT_CFG_T *ptr_cfg);
490
491/* FUNCTION NAME: air_qos_setPortPriority
492 * PURPOSE:
493 * Get poer port based priority.
494 *
495 * INPUT:
496 * unit -- Select device ID
497 * port -- Select port number
498 * priority -- Select port priority
499 *
500 * OUTPUT:
501 * None
502 *
503 * RETURN:
504 * AIR_E_OK
505 * AIR_E_BAD_PARAMETER
506 *
507 * NOTES:
508 * None
509 */
510AIR_ERROR_NO_T
511air_qos_setPortPriority(
512 const UI32_T unit,
513 const UI32_T port,
514 const UI32_T priority);
515
516/* FUNCTION NAME: air_qos_getPortPriority
517 * PURPOSE:
518 * Set per port based priority.
519 *
520 * INPUT:
521 * unit -- Select device ID
522 * port -- Select port number
523 *
524 * OUTPUT:
525 * ptr_pri -- Get port based priority
526 *
527 * RETURN:
528 * AIR_E_OK
529 * AIR_E_BAD_PARAMETER
530 *
531 * NOTES:
532 * None
533 */
534AIR_ERROR_NO_T
535air_qos_getPortPriority(
536 const UI32_T unit,
537 const UI32_T port,
538 UI32_T *ptr_pri);
539
540/* FUNCTION NAME: air_qos_setRateLimitExMngFrm
541 * PURPOSE:
542 * Set rate limit control exclude/include management frames.
543 *
544 * INPUT:
545 * unit -- Select device ID
546 * dir -- AIR_RATE_DIR_INGRESS
547 * AIR_RATE_DIR_EGRESS
548 * exclude -- TRUE: Exclude management frame
549 * FALSE:Include management frame
550 * OUTPUT:
551 * None
552 *
553 * RETURN:
554 * AIR_E_OK
555 * AIR_E_BAD_PARAMETER
556 *
557 * NOTES:
558 * None
559 */
560AIR_ERROR_NO_T
561air_qos_setRateLimitExMngFrm(
562 const UI32_T unit,
563 const AIR_QOS_RATE_DIR_T dir,
564 const BOOL_T exclude);
565
566/* FUNCTION NAME: air_qos_getRateLimitExMngFrm
567 * PURPOSE:
568 * Get rate limit control exclude/include management frames.
569 *
570 * INPUT:
571 * unit -- Select device ID
572 * dir -- AIR_RATE_DIR_INGRESS
573 * AIR_RATE_DIR_EGRESS
574 * OUTPUT:
575 * ptr_exclude -- TRUE: Exclude management frame
576 * FALSE:Include management frame
577 * RETURN:
578 * AIR_E_OK
579 * AIR_E_BAD_PARAMETER
580 *
581 * NOTES:
582 * None
583 */
584AIR_ERROR_NO_T
585air_qos_getRateLimitExMngFrm(
586 const UI32_T unit,
587 const AIR_QOS_RATE_DIR_T dir,
588 BOOL_T *ptr_exclude);
589
590#endif /* End of AIR_QOS_H */