3 * Copyright(c) 2016 Cavium networks. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
15 * * Neither the name of Cavium networks nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _RTE_EVENTDEV_PMD_H_
33 #define _RTE_EVENTDEV_PMD_H_
39 * These API are from event PMD only and user applications should not call
51 #include <rte_malloc.h>
53 #include <rte_common.h>
55 #include "rte_eventdev.h"
57 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
58 #define RTE_PMD_DEBUG_TRACE(...) \
59 rte_pmd_debug_trace(__func__, __VA_ARGS__)
61 #define RTE_PMD_DEBUG_TRACE(...)
65 #define RTE_EDEV_LOG_ERR(fmt, args...) \
66 RTE_LOG(ERR, EVENTDEV, "%s() line %u: " fmt "\n", \
67 __func__, __LINE__, ## args)
69 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
70 #define RTE_EDEV_LOG_DEBUG(fmt, args...) \
71 RTE_LOG(DEBUG, EVENTDEV, "%s() line %u: " fmt "\n", \
72 __func__, __LINE__, ## args)
74 #define RTE_EDEV_LOG_DEBUG(fmt, args...) (void)0
77 /* Macros to check for valid device */
78 #define RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, retval) do { \
79 if (!rte_event_pmd_is_valid_dev((dev_id))) { \
80 RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
85 #define RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id) do { \
86 if (!rte_event_pmd_is_valid_dev((dev_id))) { \
87 RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
92 #define RTE_EVENTDEV_DETACHED (0)
93 #define RTE_EVENTDEV_ATTACHED (1)
95 /** Global structure used for maintaining state of allocated event devices */
96 struct rte_eventdev_global {
97 uint8_t nb_devs; /**< Number of devices found */
98 uint8_t max_devs; /**< Max number of devices */
101 extern struct rte_eventdev_global *rte_eventdev_globals;
102 /** Pointer to global event devices data structure. */
103 extern struct rte_eventdev *rte_eventdevs;
104 /** The pool of rte_eventdev structures. */
107 * Get the rte_eventdev structure device pointer for the named device.
110 * device name to select the device structure.
113 * - The rte_eventdev structure pointer for the given device ID.
115 static inline struct rte_eventdev *
116 rte_event_pmd_get_named_dev(const char *name)
118 struct rte_eventdev *dev;
124 for (i = 0, dev = &rte_eventdevs[i];
125 i < rte_eventdev_globals->max_devs; i++) {
126 if ((dev->attached == RTE_EVENTDEV_ATTACHED) &&
127 (strcmp(dev->data->name, name) == 0))
135 * Validate if the event device index is valid attached event device.
138 * Event device index.
141 * - If the device index is valid (1) or not (0).
143 static inline unsigned
144 rte_event_pmd_is_valid_dev(uint8_t dev_id)
146 struct rte_eventdev *dev;
148 if (dev_id >= rte_eventdev_globals->nb_devs)
151 dev = &rte_eventdevs[dev_id];
152 if (dev->attached != RTE_EVENTDEV_ATTACHED)
159 * Definitions of all functions exported by a driver through the
160 * the generic structure of type *event_dev_ops* supplied in the
161 * *rte_eventdev* structure associated with a device.
165 * Get device information of a device.
168 * Event device pointer
170 * Event device information structure
173 * Returns 0 on success
175 typedef void (*eventdev_info_get_t)(struct rte_eventdev *dev,
176 struct rte_event_dev_info *dev_info);
179 * Configure a device.
182 * Event device pointer
185 * Returns 0 on success
187 typedef int (*eventdev_configure_t)(const struct rte_eventdev *dev);
190 * Start a configured device.
193 * Event device pointer
196 * Returns 0 on success
198 typedef int (*eventdev_start_t)(struct rte_eventdev *dev);
201 * Stop a configured device.
204 * Event device pointer
206 typedef void (*eventdev_stop_t)(struct rte_eventdev *dev);
209 * Close a configured device.
212 * Event device pointer
216 * - (-EAGAIN) if can't close as device is busy
218 typedef int (*eventdev_close_t)(struct rte_eventdev *dev);
221 * Retrieve the default event queue configuration.
224 * Event device pointer
227 * @param[out] queue_conf
228 * Event queue configuration structure
231 typedef void (*eventdev_queue_default_conf_get_t)(struct rte_eventdev *dev,
232 uint8_t queue_id, struct rte_event_queue_conf *queue_conf);
235 * Setup an event queue.
238 * Event device pointer
242 * Event queue configuration structure
245 * Returns 0 on success.
247 typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
249 const struct rte_event_queue_conf *queue_conf);
252 * Release resources allocated by given event queue.
255 * Event device pointer
260 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
264 * Retrieve the default event port configuration.
267 * Event device pointer
270 * @param[out] port_conf
271 * Event port configuration structure
274 typedef void (*eventdev_port_default_conf_get_t)(struct rte_eventdev *dev,
275 uint8_t port_id, struct rte_event_port_conf *port_conf);
278 * Setup an event port.
281 * Event device pointer
285 * Event port configuration structure
288 * Returns 0 on success.
290 typedef int (*eventdev_port_setup_t)(struct rte_eventdev *dev,
292 const struct rte_event_port_conf *port_conf);
295 * Release memory resources allocated by given event port.
301 typedef void (*eventdev_port_release_t)(void *port);
304 * Link multiple source event queues to destination event port.
309 * Points to an array of *nb_links* event queues to be linked
312 * Points to an array of *nb_links* service priorities associated with each
313 * event queue link to event port.
315 * The number of links to establish
318 * Returns 0 on success.
321 typedef int (*eventdev_port_link_t)(void *port,
322 const uint8_t queues[], const uint8_t priorities[],
326 * Unlink multiple source event queues from destination event port.
331 * An array of *nb_unlinks* event queues to be unlinked from the event port.
333 * The number of unlinks to establish
336 * Returns 0 on success.
339 typedef int (*eventdev_port_unlink_t)(void *port,
340 uint8_t queues[], uint16_t nb_unlinks);
343 * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue()
346 * Event device pointer
348 * Wait time in nanosecond
349 * @param[out] timeout_ticks
350 * Value for the *timeout_ticks* parameter in rte_event_dequeue() function
353 typedef void (*eventdev_dequeue_timeout_ticks_t)(struct rte_eventdev *dev,
354 uint64_t ns, uint64_t *timeout_ticks);
357 * Dump internal information
360 * Event device pointer
362 * A pointer to a file for output
365 typedef void (*eventdev_dump_t)(struct rte_eventdev *dev, FILE *f);
367 /** Event device operations function pointer table */
368 struct rte_eventdev_ops {
369 eventdev_info_get_t dev_infos_get; /**< Get device info. */
370 eventdev_configure_t dev_configure; /**< Configure device. */
371 eventdev_start_t dev_start; /**< Start device. */
372 eventdev_stop_t dev_stop; /**< Stop device. */
373 eventdev_close_t dev_close; /**< Close device. */
375 eventdev_queue_default_conf_get_t queue_def_conf;
376 /**< Get default queue configuration. */
377 eventdev_queue_setup_t queue_setup;
378 /**< Set up an event queue. */
379 eventdev_queue_release_t queue_release;
380 /**< Release an event queue. */
382 eventdev_port_default_conf_get_t port_def_conf;
383 /**< Get default port configuration. */
384 eventdev_port_setup_t port_setup;
385 /**< Set up an event port. */
386 eventdev_port_release_t port_release;
387 /**< Release an event port. */
389 eventdev_port_link_t port_link;
390 /**< Link event queues to an event port. */
391 eventdev_port_unlink_t port_unlink;
392 /**< Unlink event queues from an event port. */
393 eventdev_dequeue_timeout_ticks_t timeout_ticks;
394 /**< Converts ns to *timeout_ticks* value for rte_event_dequeue() */
395 eventdev_dump_t dump;
396 /* Dump internal information */
403 #endif /* _RTE_EVENTDEV_PMD_H_ */