1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (C) 2020 Marvell International Ltd.
4 #ifndef _EVENT_HELPER_H_
5 #define _EVENT_HELPER_H_
9 #define RTE_LOGTYPE_EH RTE_LOGTYPE_USER4
11 #define EH_LOG_ERR(...) \
13 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
14 __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,)))
16 /* Max event devices supported */
17 #define EVENT_MODE_MAX_EVENT_DEVS RTE_EVENT_MAX_DEVS
19 /* Max Rx adapters supported */
20 #define EVENT_MODE_MAX_RX_ADAPTERS RTE_EVENT_MAX_DEVS
22 /* Max Tx adapters supported */
23 #define EVENT_MODE_MAX_TX_ADAPTERS RTE_EVENT_MAX_DEVS
25 /* Max Rx adapter connections */
26 #define EVENT_MODE_MAX_CONNECTIONS_PER_ADAPTER 16
28 /* Max Tx adapter connections */
29 #define EVENT_MODE_MAX_CONNECTIONS_PER_TX_ADAPTER 16
31 /* Max event queues supported per event device */
32 #define EVENT_MODE_MAX_EVENT_QUEUES_PER_DEV RTE_EVENT_MAX_QUEUES_PER_DEV
34 /* Max event-lcore links */
35 #define EVENT_MODE_MAX_LCORE_LINKS \
36 (EVENT_MODE_MAX_EVENT_DEVS * EVENT_MODE_MAX_EVENT_QUEUES_PER_DEV)
38 /* Max adapters that one Tx core can handle */
39 #define EVENT_MODE_MAX_ADAPTERS_PER_TX_CORE EVENT_MODE_MAX_TX_ADAPTERS
42 * Packet transfer mode of the application
44 enum eh_pkt_transfer_mode {
45 EH_PKT_TRANSFER_MODE_POLL = 0,
46 EH_PKT_TRANSFER_MODE_EVENT,
49 /* Event dev params */
50 struct eventdev_params {
52 uint8_t nb_eventqueue;
54 uint8_t ev_queue_mode;
58 * Event-lcore link configuration
60 struct eh_event_link_info {
62 /**< Event device ID */
63 uint8_t event_port_id;
66 /**< Event queue to be linked to the port */
68 /**< Lcore to be polling on this port */
71 /* Rx adapter connection info */
72 struct rx_adapter_connection_info {
75 int32_t ethdev_rx_qid;
79 struct rx_adapter_conf {
83 uint8_t nb_connections;
84 struct rx_adapter_connection_info
85 conn[EVENT_MODE_MAX_CONNECTIONS_PER_ADAPTER];
88 /* Tx adapter connection info */
89 struct tx_adapter_connection_info {
91 int32_t ethdev_tx_qid;
95 struct tx_adapter_conf {
99 uint8_t nb_connections;
100 struct tx_adapter_connection_info
101 conn[EVENT_MODE_MAX_CONNECTIONS_PER_TX_ADAPTER];
105 /* Eventmode conf data */
106 struct eventmode_conf {
108 /**< No of event devs */
109 struct eventdev_params eventdev_config[EVENT_MODE_MAX_EVENT_DEVS];
110 /**< Per event dev conf */
111 uint8_t nb_rx_adapter;
112 /**< No of Rx adapters */
113 struct rx_adapter_conf rx_adapter[EVENT_MODE_MAX_RX_ADAPTERS];
114 /**< Rx adapter conf */
115 uint8_t nb_tx_adapter;
116 /**< No of Tx adapters */
117 struct tx_adapter_conf tx_adapter[EVENT_MODE_MAX_TX_ADAPTERS];
118 /** Tx adapter conf */
121 struct eh_event_link_info
122 link[EVENT_MODE_MAX_LCORE_LINKS];
123 /**< Per link conf */
124 struct rte_bitmap *eth_core_mask;
125 /**< Core mask of cores to be used for software Rx and Tx */
126 uint32_t eth_portmask;
127 /**< Mask of the eth ports to be used */
131 uint64_t sched_type : 2;
132 /**< Schedule type */
133 uint64_t all_ev_queue_to_ev_port : 1;
135 * When enabled, all event queues need to be mapped to
141 /**< 64 bit field to specify extended params */
145 * Event helper configuration
148 enum eh_pkt_transfer_mode mode;
149 /**< Packet transfer mode of the application */
150 uint32_t eth_portmask;
152 * Mask of the eth ports to be used. This portmask would be
153 * checked while initializing devices using helper routines.
156 /**< Mode specific parameters */
160 * Initialize event mode devices
162 * Application can call this function to get the event devices, eth devices
163 * and eth rx & tx adapters initialized according to the default config or
164 * config populated using the command line args.
166 * Application is expected to initialize the eth devices and then the event
167 * mode helper subsystem will stop & start eth devices according to its
168 * requirement. Call to this function should be done after the eth devices
169 * are successfully initialized.
172 * Event helper configuration
178 eh_devs_init(struct eh_conf *conf);
181 * Release event mode devices
183 * Application can call this function to release event devices,
184 * eth rx & tx adapters according to the config.
186 * Call to this function should be done before application stops
187 * and closes eth devices. This function will not close and stop
191 * Event helper configuration
197 eh_devs_uninit(struct eh_conf *conf);
200 * Get eventdev tx queue
202 * If the application uses event device which does not support internal port
203 * then it needs to submit the events to a Tx queue before final transmission.
204 * This Tx queue will be created internally by the eventmode helper subsystem,
205 * and application will need its queue ID when it runs the execution loop.
208 * Event helper configuration
215 eh_get_tx_queue(struct eh_conf *conf, uint8_t eventdev_id);
217 #endif /* _EVENT_HELPER_H_ */