xref: /dpdk/examples/qos_meter/main.h (revision 93998f3c5f22747e4f2c5e8714fa5cbe6c9d1574)
13998e2a0SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
23998e2a0SBruce Richardson  * Copyright(c) 2010-2014 Intel Corporation
3e6541fdeSIntel  */
4e6541fdeSIntel 
5e6541fdeSIntel #ifndef _MAIN_H_
6e6541fdeSIntel #define _MAIN_H_
7e6541fdeSIntel 
8fc8a10d8SIntel enum policer_action {
9c1656328SJasvinder Singh 		GREEN = RTE_COLOR_GREEN,
10c1656328SJasvinder Singh 		YELLOW = RTE_COLOR_YELLOW,
11c1656328SJasvinder Singh 		RED = RTE_COLOR_RED,
12fc8a10d8SIntel 		DROP = 3,
13fc8a10d8SIntel };
14fc8a10d8SIntel 
159a212dc0SConor Fogarty /* Policy implemented as a static structure. 8< */
16c1656328SJasvinder Singh enum policer_action policer_table[RTE_COLORS][RTE_COLORS] =
17fc8a10d8SIntel {
18fc8a10d8SIntel 	{ GREEN, RED, RED},
19fc8a10d8SIntel 	{ DROP, YELLOW, RED},
20fc8a10d8SIntel 	{ DROP, DROP, RED}
21fc8a10d8SIntel };
229a212dc0SConor Fogarty /* >8 End of policy implemented as a static structure. */
23fc8a10d8SIntel 
24e6541fdeSIntel #if APP_MODE == APP_MODE_FWD
25e6541fdeSIntel 
26c06ddf96SCristian Dumitrescu #define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
27*93998f3cSTyler Retzlaff __extension__ ({					\
28c06ddf96SCristian Dumitrescu 	void *mp = m;					\
29c06ddf96SCristian Dumitrescu 	void *pp = p;					\
30c06ddf96SCristian Dumitrescu 	mp = mp;					\
31c06ddf96SCristian Dumitrescu 	pp = pp;					\
32c06ddf96SCristian Dumitrescu 	time = time;					\
33c06ddf96SCristian Dumitrescu 	pkt_len = pkt_len;				\
34c06ddf96SCristian Dumitrescu 	pkt_color;					\
35c06ddf96SCristian Dumitrescu })
36e752649cSSlawomir Mrozowicz #define FUNC_CONFIG(a, b) 0
37e6541fdeSIntel #define FLOW_METER int
38c06ddf96SCristian Dumitrescu #define PROFILE	app_srtcm_profile
39e6541fdeSIntel 
40e6541fdeSIntel #elif APP_MODE == APP_MODE_SRTCM_COLOR_BLIND
41e6541fdeSIntel 
42c06ddf96SCristian Dumitrescu #define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
43c06ddf96SCristian Dumitrescu 	rte_meter_srtcm_color_blind_check(m, p, time, pkt_len)
44e6541fdeSIntel #define FUNC_CONFIG   rte_meter_srtcm_config
45e6541fdeSIntel #define FLOW_METER    struct rte_meter_srtcm
46c06ddf96SCristian Dumitrescu #define PROFILE       app_srtcm_profile
47e6541fdeSIntel 
48e6541fdeSIntel #elif (APP_MODE == APP_MODE_SRTCM_COLOR_AWARE)
49e6541fdeSIntel 
50e6541fdeSIntel #define FUNC_METER    rte_meter_srtcm_color_aware_check
51e6541fdeSIntel #define FUNC_CONFIG   rte_meter_srtcm_config
52e6541fdeSIntel #define FLOW_METER    struct rte_meter_srtcm
53c06ddf96SCristian Dumitrescu #define PROFILE       app_srtcm_profile
54e6541fdeSIntel 
55e6541fdeSIntel #elif (APP_MODE == APP_MODE_TRTCM_COLOR_BLIND)
56e6541fdeSIntel 
57c06ddf96SCristian Dumitrescu #define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
58c06ddf96SCristian Dumitrescu 	rte_meter_trtcm_color_blind_check(m, p, time, pkt_len)
59e6541fdeSIntel #define FUNC_CONFIG  rte_meter_trtcm_config
60e6541fdeSIntel #define FLOW_METER   struct rte_meter_trtcm
61c06ddf96SCristian Dumitrescu #define PROFILE      app_trtcm_profile
62e6541fdeSIntel 
63e6541fdeSIntel #elif (APP_MODE == APP_MODE_TRTCM_COLOR_AWARE)
64e6541fdeSIntel 
65e6541fdeSIntel #define FUNC_METER rte_meter_trtcm_color_aware_check
66e6541fdeSIntel #define FUNC_CONFIG  rte_meter_trtcm_config
67e6541fdeSIntel #define FLOW_METER   struct rte_meter_trtcm
68c06ddf96SCristian Dumitrescu #define PROFILE      app_trtcm_profile
69e6541fdeSIntel 
70e6541fdeSIntel #else
71e6541fdeSIntel #error Invalid value for APP_MODE
72e6541fdeSIntel #endif
73e6541fdeSIntel 
74e6541fdeSIntel #endif /* _MAIN_H_ */
75