examples/ipsec-secgw: add event port-lcore link
[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 /* Max event queues supported per event device */
20 #define EVENT_MODE_MAX_EVENT_QUEUES_PER_DEV RTE_EVENT_MAX_QUEUES_PER_DEV
21
22 /* Max event-lcore links */
23 #define EVENT_MODE_MAX_LCORE_LINKS \
24         (EVENT_MODE_MAX_EVENT_DEVS * EVENT_MODE_MAX_EVENT_QUEUES_PER_DEV)
25
26 /**
27  * Packet transfer mode of the application
28  */
29 enum eh_pkt_transfer_mode {
30         EH_PKT_TRANSFER_MODE_POLL = 0,
31         EH_PKT_TRANSFER_MODE_EVENT,
32 };
33
34 /* Event dev params */
35 struct eventdev_params {
36         uint8_t eventdev_id;
37         uint8_t nb_eventqueue;
38         uint8_t nb_eventport;
39         uint8_t ev_queue_mode;
40 };
41
42 /**
43  * Event-lcore link configuration
44  */
45 struct eh_event_link_info {
46         uint8_t eventdev_id;
47                 /**< Event device ID */
48         uint8_t event_port_id;
49                 /**< Event port ID */
50         uint8_t eventq_id;
51                 /**< Event queue to be linked to the port */
52         uint8_t lcore_id;
53                 /**< Lcore to be polling on this port */
54 };
55
56 /* Eventmode conf data */
57 struct eventmode_conf {
58         int nb_eventdev;
59                 /**< No of event devs */
60         struct eventdev_params eventdev_config[EVENT_MODE_MAX_EVENT_DEVS];
61                 /**< Per event dev conf */
62         uint8_t nb_link;
63                 /**< No of links */
64         struct eh_event_link_info
65                 link[EVENT_MODE_MAX_LCORE_LINKS];
66                 /**< Per link conf */
67         struct rte_bitmap *eth_core_mask;
68                 /**< Core mask of cores to be used for software Rx and Tx */
69         union {
70                 RTE_STD_C11
71                 struct {
72                         uint64_t sched_type                     : 2;
73                 /**< Schedule type */
74                         uint64_t all_ev_queue_to_ev_port        : 1;
75                 /**<
76                  * When enabled, all event queues need to be mapped to
77                  * each event port
78                  */
79                 };
80                 uint64_t u64;
81         } ext_params;
82                 /**< 64 bit field to specify extended params */
83 };
84
85 /**
86  * Event helper configuration
87  */
88 struct eh_conf {
89         enum eh_pkt_transfer_mode mode;
90                 /**< Packet transfer mode of the application */
91         uint32_t eth_portmask;
92                 /**<
93                  * Mask of the eth ports to be used. This portmask would be
94                  * checked while initializing devices using helper routines.
95                  */
96         void *mode_params;
97                 /**< Mode specific parameters */
98 };
99
100 /**
101  * Initialize event mode devices
102  *
103  * Application can call this function to get the event devices, eth devices
104  * and eth rx & tx adapters initialized according to the default config or
105  * config populated using the command line args.
106  *
107  * Application is expected to initialize the eth devices and then the event
108  * mode helper subsystem will stop & start eth devices according to its
109  * requirement. Call to this function should be done after the eth devices
110  * are successfully initialized.
111  *
112  * @param conf
113  *   Event helper configuration
114  * @return
115  *  - 0 on success.
116  *  - (<0) on failure.
117  */
118 int32_t
119 eh_devs_init(struct eh_conf *conf);
120
121 /**
122  * Release event mode devices
123  *
124  * Application can call this function to release event devices,
125  * eth rx & tx adapters according to the config.
126  *
127  * Call to this function should be done before application stops
128  * and closes eth devices. This function will not close and stop
129  * eth devices.
130  *
131  * @param conf
132  *   Event helper configuration
133  * @return
134  *  - 0 on success.
135  *  - (<0) on failure.
136  */
137 int32_t
138 eh_devs_uninit(struct eh_conf *conf);
139
140 #endif /* _EVENT_HELPER_H_ */