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