040f977b47ec277be4b60702b724606beee146c6
[dpdk.git] / examples / ipsec-secgw / event_helper.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (C) 2020 Marvell International Ltd.
3  */
4 #ifndef _EVENT_HELPER_H_
5 #define _EVENT_HELPER_H_
6
7 #include <rte_log.h>
8
9 #define RTE_LOGTYPE_EH  RTE_LOGTYPE_USER4
10
11 #define EH_LOG_ERR(...) \
12         RTE_LOG(ERR, EH, \
13                 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
14                         __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,)))
15
16 /* Max event devices supported */
17 #define EVENT_MODE_MAX_EVENT_DEVS RTE_EVENT_MAX_DEVS
18
19 /**
20  * Packet transfer mode of the application
21  */
22 enum eh_pkt_transfer_mode {
23         EH_PKT_TRANSFER_MODE_POLL = 0,
24         EH_PKT_TRANSFER_MODE_EVENT,
25 };
26
27 /* Event dev params */
28 struct eventdev_params {
29         uint8_t eventdev_id;
30         uint8_t nb_eventqueue;
31         uint8_t nb_eventport;
32         uint8_t ev_queue_mode;
33 };
34
35 /* Eventmode conf data */
36 struct eventmode_conf {
37         int nb_eventdev;
38                 /**< No of event devs */
39         struct eventdev_params eventdev_config[EVENT_MODE_MAX_EVENT_DEVS];
40                 /**< Per event dev conf */
41         union {
42                 RTE_STD_C11
43                 struct {
44                         uint64_t sched_type                     : 2;
45                 /**< Schedule type */
46                 };
47                 uint64_t u64;
48         } ext_params;
49                 /**< 64 bit field to specify extended params */
50 };
51
52 /**
53  * Event helper configuration
54  */
55 struct eh_conf {
56         enum eh_pkt_transfer_mode mode;
57                 /**< Packet transfer mode of the application */
58         uint32_t eth_portmask;
59                 /**<
60                  * Mask of the eth ports to be used. This portmask would be
61                  * checked while initializing devices using helper routines.
62                  */
63         void *mode_params;
64                 /**< Mode specific parameters */
65 };
66
67 /**
68  * Initialize event mode devices
69  *
70  * Application can call this function to get the event devices, eth devices
71  * and eth rx & tx adapters initialized according to the default config or
72  * config populated using the command line args.
73  *
74  * Application is expected to initialize the eth devices and then the event
75  * mode helper subsystem will stop & start eth devices according to its
76  * requirement. Call to this function should be done after the eth devices
77  * are successfully initialized.
78  *
79  * @param conf
80  *   Event helper configuration
81  * @return
82  *  - 0 on success.
83  *  - (<0) on failure.
84  */
85 int32_t
86 eh_devs_init(struct eh_conf *conf);
87
88 /**
89  * Release event mode devices
90  *
91  * Application can call this function to release event devices,
92  * eth rx & tx adapters according to the config.
93  *
94  * Call to this function should be done before application stops
95  * and closes eth devices. This function will not close and stop
96  * eth devices.
97  *
98  * @param conf
99  *   Event helper configuration
100  * @return
101  *  - 0 on success.
102  *  - (<0) on failure.
103  */
104 int32_t
105 eh_devs_uninit(struct eh_conf *conf);
106
107 #endif /* _EVENT_HELPER_H_ */