27be376ed1ead7423b08ca6d3c257ba8e67416e9
[dpdk.git] / lib / librte_eventdev / rte_eventdev_pmd.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016 Cavium, Inc
3  */
4
5 #ifndef _RTE_EVENTDEV_PMD_H_
6 #define _RTE_EVENTDEV_PMD_H_
7
8 /** @file
9  * RTE Event PMD APIs
10  *
11  * @note
12  * These API are from event PMD only and user applications should not call
13  * them directly.
14  */
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 #include <string.h>
21
22 #include <rte_common.h>
23 #include <rte_compat.h>
24 #include <rte_config.h>
25 #include <rte_dev.h>
26 #include <rte_log.h>
27 #include <rte_malloc.h>
28 #include <rte_mbuf.h>
29 #include <rte_mbuf_dyn.h>
30
31 #include "rte_eventdev.h"
32 #include "rte_event_timer_adapter_pmd.h"
33
34 /* Logging Macros */
35 #define RTE_EDEV_LOG_ERR(...) \
36         RTE_LOG(ERR, EVENTDEV, \
37                 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
38                         __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
39
40 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
41 #define RTE_EDEV_LOG_DEBUG(...) \
42         RTE_LOG(DEBUG, EVENTDEV, \
43                 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
44                         __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
45 #else
46 #define RTE_EDEV_LOG_DEBUG(...) (void)0
47 #endif
48
49 /* Macros to check for valid device */
50 #define RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, retval) do { \
51         if (!rte_event_pmd_is_valid_dev((dev_id))) { \
52                 RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
53                 return retval; \
54         } \
55 } while (0)
56
57 #define RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, errno, retval) do { \
58         if (!rte_event_pmd_is_valid_dev((dev_id))) { \
59                 RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
60                 rte_errno = errno; \
61                 return retval; \
62         } \
63 } while (0)
64
65 #define RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id) do { \
66         if (!rte_event_pmd_is_valid_dev((dev_id))) { \
67                 RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
68                 return; \
69         } \
70 } while (0)
71
72 #define RTE_EVENT_ETH_RX_ADAPTER_SW_CAP \
73                 ((RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID) | \
74                         (RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ))
75
76 #define RTE_EVENT_CRYPTO_ADAPTER_SW_CAP \
77                 RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA
78
79 /**< Ethernet Rx adapter cap to return If the packet transfers from
80  * the ethdev to eventdev use a SW service function
81  */
82
83 #define RTE_EVENTDEV_DETACHED  (0)
84 #define RTE_EVENTDEV_ATTACHED  (1)
85
86 struct rte_eth_dev;
87
88 /** Global structure used for maintaining state of allocated event devices */
89 struct rte_eventdev_global {
90         uint8_t nb_devs;        /**< Number of devices found */
91 };
92
93 extern struct rte_eventdev *rte_eventdevs;
94 /** The pool of rte_eventdev structures. */
95
96 /**
97  * Get the rte_eventdev structure device pointer for the named device.
98  *
99  * @param name
100  *   device name to select the device structure.
101  *
102  * @return
103  *   - The rte_eventdev structure pointer for the given device ID.
104  */
105 static inline struct rte_eventdev *
106 rte_event_pmd_get_named_dev(const char *name)
107 {
108         struct rte_eventdev *dev;
109         unsigned int i;
110
111         if (name == NULL)
112                 return NULL;
113
114         for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
115                 dev = &rte_eventdevs[i];
116                 if ((dev->attached == RTE_EVENTDEV_ATTACHED) &&
117                                 (strcmp(dev->data->name, name) == 0))
118                         return dev;
119         }
120
121         return NULL;
122 }
123
124 /**
125  * Validate if the event device index is valid attached event device.
126  *
127  * @param dev_id
128  *   Event device index.
129  *
130  * @return
131  *   - If the device index is valid (1) or not (0).
132  */
133 static inline unsigned
134 rte_event_pmd_is_valid_dev(uint8_t dev_id)
135 {
136         struct rte_eventdev *dev;
137
138         if (dev_id >= RTE_EVENT_MAX_DEVS)
139                 return 0;
140
141         dev = &rte_eventdevs[dev_id];
142         if (dev->attached != RTE_EVENTDEV_ATTACHED)
143                 return 0;
144         else
145                 return 1;
146 }
147
148 /**
149  * Definitions of all functions exported by a driver through the
150  * the generic structure of type *event_dev_ops* supplied in the
151  * *rte_eventdev* structure associated with a device.
152  */
153
154 /**
155  * Get device information of a device.
156  *
157  * @param dev
158  *   Event device pointer
159  * @param dev_info
160  *   Event device information structure
161  *
162  * @return
163  *   Returns 0 on success
164  */
165 typedef void (*eventdev_info_get_t)(struct rte_eventdev *dev,
166                 struct rte_event_dev_info *dev_info);
167
168 /**
169  * Configure a device.
170  *
171  * @param dev
172  *   Event device pointer
173  *
174  * @return
175  *   Returns 0 on success
176  */
177 typedef int (*eventdev_configure_t)(const struct rte_eventdev *dev);
178
179 /**
180  * Start a configured device.
181  *
182  * @param dev
183  *   Event device pointer
184  *
185  * @return
186  *   Returns 0 on success
187  */
188 typedef int (*eventdev_start_t)(struct rte_eventdev *dev);
189
190 /**
191  * Stop a configured device.
192  *
193  * @param dev
194  *   Event device pointer
195  */
196 typedef void (*eventdev_stop_t)(struct rte_eventdev *dev);
197
198 /**
199  * Close a configured device.
200  *
201  * @param dev
202  *   Event device pointer
203  *
204  * @return
205  * - 0 on success
206  * - (-EAGAIN) if can't close as device is busy
207  */
208 typedef int (*eventdev_close_t)(struct rte_eventdev *dev);
209
210 /**
211  * Retrieve the default event queue configuration.
212  *
213  * @param dev
214  *   Event device pointer
215  * @param queue_id
216  *   Event queue index
217  * @param[out] queue_conf
218  *   Event queue configuration structure
219  *
220  */
221 typedef void (*eventdev_queue_default_conf_get_t)(struct rte_eventdev *dev,
222                 uint8_t queue_id, struct rte_event_queue_conf *queue_conf);
223
224 /**
225  * Setup an event queue.
226  *
227  * @param dev
228  *   Event device pointer
229  * @param queue_id
230  *   Event queue index
231  * @param queue_conf
232  *   Event queue configuration structure
233  *
234  * @return
235  *   Returns 0 on success.
236  */
237 typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
238                 uint8_t queue_id,
239                 const struct rte_event_queue_conf *queue_conf);
240
241 /**
242  * Release resources allocated by given event queue.
243  *
244  * @param dev
245  *   Event device pointer
246  * @param queue_id
247  *   Event queue index
248  *
249  */
250 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
251                 uint8_t queue_id);
252
253 /**
254  * Retrieve the default event port configuration.
255  *
256  * @param dev
257  *   Event device pointer
258  * @param port_id
259  *   Event port index
260  * @param[out] port_conf
261  *   Event port configuration structure
262  *
263  */
264 typedef void (*eventdev_port_default_conf_get_t)(struct rte_eventdev *dev,
265                 uint8_t port_id, struct rte_event_port_conf *port_conf);
266
267 /**
268  * Setup an event port.
269  *
270  * @param dev
271  *   Event device pointer
272  * @param port_id
273  *   Event port index
274  * @param port_conf
275  *   Event port configuration structure
276  *
277  * @return
278  *   Returns 0 on success.
279  */
280 typedef int (*eventdev_port_setup_t)(struct rte_eventdev *dev,
281                 uint8_t port_id,
282                 const struct rte_event_port_conf *port_conf);
283
284 /**
285  * Release memory resources allocated by given event port.
286  *
287  * @param port
288  *   Event port pointer
289  *
290  */
291 typedef void (*eventdev_port_release_t)(void *port);
292
293 /**
294  * Link multiple source event queues to destination event port.
295  *
296  * @param dev
297  *   Event device pointer
298  * @param port
299  *   Event port pointer
300  * @param link
301  *   Points to an array of *nb_links* event queues to be linked
302  *   to the event port.
303  * @param priorities
304  *   Points to an array of *nb_links* service priorities associated with each
305  *   event queue link to event port.
306  * @param nb_links
307  *   The number of links to establish
308  *
309  * @return
310  *   Returns 0 on success.
311  *
312  */
313 typedef int (*eventdev_port_link_t)(struct rte_eventdev *dev, void *port,
314                 const uint8_t queues[], const uint8_t priorities[],
315                 uint16_t nb_links);
316
317 /**
318  * Unlink multiple source event queues from destination event port.
319  *
320  * @param dev
321  *   Event device pointer
322  * @param port
323  *   Event port pointer
324  * @param queues
325  *   An array of *nb_unlinks* event queues to be unlinked from the event port.
326  * @param nb_unlinks
327  *   The number of unlinks to establish
328  *
329  * @return
330  *   Returns 0 on success.
331  *
332  */
333 typedef int (*eventdev_port_unlink_t)(struct rte_eventdev *dev, void *port,
334                 uint8_t queues[], uint16_t nb_unlinks);
335
336 /**
337  * Unlinks in progress. Returns number of unlinks that the PMD is currently
338  * performing, but have not yet been completed.
339  *
340  * @param dev
341  *   Event device pointer
342  *
343  * @param port
344  *   Event port pointer
345  *
346  * @return
347  *   Returns the number of in-progress unlinks. Zero is returned if none are
348  *   in progress.
349  */
350 typedef int (*eventdev_port_unlinks_in_progress_t)(struct rte_eventdev *dev,
351                 void *port);
352
353 /**
354  * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue()
355  *
356  * @param dev
357  *   Event device pointer
358  * @param ns
359  *   Wait time in nanosecond
360  * @param[out] timeout_ticks
361  *   Value for the *timeout_ticks* parameter in rte_event_dequeue() function
362  *
363  * @return
364  *   Returns 0 on success.
365  *
366  */
367 typedef int (*eventdev_dequeue_timeout_ticks_t)(struct rte_eventdev *dev,
368                 uint64_t ns, uint64_t *timeout_ticks);
369
370 /**
371  * Dump internal information
372  *
373  * @param dev
374  *   Event device pointer
375  * @param f
376  *   A pointer to a file for output
377  *
378  */
379 typedef void (*eventdev_dump_t)(struct rte_eventdev *dev, FILE *f);
380
381 /**
382  * Retrieve a set of statistics from device
383  *
384  * @param dev
385  *   Event device pointer
386  * @param ids
387  *   The stat ids to retrieve
388  * @param values
389  *   The returned stat values
390  * @param n
391  *   The number of id values and entries in the values array
392  * @return
393  *   The number of stat values successfully filled into the values array
394  */
395 typedef int (*eventdev_xstats_get_t)(const struct rte_eventdev *dev,
396                 enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
397                 const unsigned int ids[], uint64_t values[], unsigned int n);
398
399 /**
400  * Resets the statistic values in xstats for the device, based on mode.
401  */
402 typedef int (*eventdev_xstats_reset_t)(struct rte_eventdev *dev,
403                 enum rte_event_dev_xstats_mode mode,
404                 int16_t queue_port_id,
405                 const uint32_t ids[],
406                 uint32_t nb_ids);
407
408 /**
409  * Get names of extended stats of an event device
410  *
411  * @param dev
412  *   Event device pointer
413  * @param xstats_names
414  *   Array of name values to be filled in
415  * @param size
416  *   Number of values in the xstats_names array
417  * @return
418  *   When size >= the number of stats, return the number of stat values filled
419  *   into the array.
420  *   When size < the number of available stats, return the number of stats
421  *   values, and do not fill in any data into xstats_names.
422  */
423 typedef int (*eventdev_xstats_get_names_t)(const struct rte_eventdev *dev,
424                 enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
425                 struct rte_event_dev_xstats_name *xstats_names,
426                 unsigned int *ids, unsigned int size);
427
428 /**
429  * Get value of one stats and optionally return its id
430  *
431  * @param dev
432  *   Event device pointer
433  * @param name
434  *   The name of the stat to retrieve
435  * @param id
436  *   Pointer to an unsigned int where we store the stat-id for future reference.
437  *   This pointer may be null if the id is not required.
438  * @return
439  *   The value of the stat, or (uint64_t)-1 if the stat is not found.
440  *   If the stat is not found, the id value will be returned as (unsigned)-1,
441  *   if id pointer is non-NULL
442  */
443 typedef uint64_t (*eventdev_xstats_get_by_name)(const struct rte_eventdev *dev,
444                 const char *name, unsigned int *id);
445
446
447 /**
448  * Retrieve the event device's ethdev Rx adapter capabilities for the
449  * specified ethernet port
450  *
451  * @param dev
452  *   Event device pointer
453  *
454  * @param eth_dev
455  *   Ethernet device pointer
456  *
457  * @param[out] caps
458  *   A pointer to memory filled with Rx event adapter capabilities.
459  *
460  * @return
461  *   - 0: Success, driver provides Rx event adapter capabilities for the
462  *      ethernet device.
463  *   - <0: Error code returned by the driver function.
464  *
465  */
466 typedef int (*eventdev_eth_rx_adapter_caps_get_t)
467                                         (const struct rte_eventdev *dev,
468                                         const struct rte_eth_dev *eth_dev,
469                                         uint32_t *caps);
470
471 struct rte_event_eth_rx_adapter_queue_conf;
472
473 /**
474  * Retrieve the event device's timer adapter capabilities, as well as the ops
475  * structure that an event timer adapter should call through to enter the
476  * driver
477  *
478  * @param dev
479  *   Event device pointer
480  *
481  * @param flags
482  *   Flags that can be used to determine how to select an event timer
483  *   adapter ops structure
484  *
485  * @param[out] caps
486  *   A pointer to memory filled with Rx event adapter capabilities.
487  *
488  * @param[out] ops
489  *   A pointer to the ops pointer to set with the address of the desired ops
490  *   structure
491  *
492  * @return
493  *   - 0: Success, driver provides Rx event adapter capabilities for the
494  *      ethernet device.
495  *   - <0: Error code returned by the driver function.
496  *
497  */
498 typedef int (*eventdev_timer_adapter_caps_get_t)(
499                                 const struct rte_eventdev *dev,
500                                 uint64_t flags,
501                                 uint32_t *caps,
502                                 const struct rte_event_timer_adapter_ops **ops);
503
504 /**
505  * Add ethernet Rx queues to event device. This callback is invoked if
506  * the caps returned from rte_eventdev_eth_rx_adapter_caps_get(, eth_port_id)
507  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set.
508  *
509  * @param dev
510  *   Event device pointer
511  *
512  * @param eth_dev
513  *   Ethernet device pointer
514  *
515  * @param rx_queue_id
516  *   Ethernet device receive queue index
517  *
518  * @param queue_conf
519  *  Additional configuration structure
520
521  * @return
522  *   - 0: Success, ethernet receive queue added successfully.
523  *   - <0: Error code returned by the driver function.
524  *
525  */
526 typedef int (*eventdev_eth_rx_adapter_queue_add_t)(
527                 const struct rte_eventdev *dev,
528                 const struct rte_eth_dev *eth_dev,
529                 int32_t rx_queue_id,
530                 const struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
531
532 /**
533  * Delete ethernet Rx queues from event device. This callback is invoked if
534  * the caps returned from eventdev_eth_rx_adapter_caps_get(, eth_port_id)
535  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set.
536  *
537  * @param dev
538  *   Event device pointer
539  *
540  * @param eth_dev
541  *   Ethernet device pointer
542  *
543  * @param rx_queue_id
544  *   Ethernet device receive queue index
545  *
546  * @return
547  *   - 0: Success, ethernet receive queue deleted successfully.
548  *   - <0: Error code returned by the driver function.
549  *
550  */
551 typedef int (*eventdev_eth_rx_adapter_queue_del_t)
552                                         (const struct rte_eventdev *dev,
553                                         const struct rte_eth_dev *eth_dev,
554                                         int32_t rx_queue_id);
555
556 /**
557  * Start ethernet Rx adapter. This callback is invoked if
558  * the caps returned from eventdev_eth_rx_adapter_caps_get(.., eth_port_id)
559  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues
560  * from eth_port_id have been added to the event device.
561  *
562  * @param dev
563  *   Event device pointer
564  *
565  * @param eth_dev
566  *   Ethernet device pointer
567  *
568  * @return
569  *   - 0: Success, ethernet Rx adapter started successfully.
570  *   - <0: Error code returned by the driver function.
571  */
572 typedef int (*eventdev_eth_rx_adapter_start_t)
573                                         (const struct rte_eventdev *dev,
574                                         const struct rte_eth_dev *eth_dev);
575
576 /**
577  * Stop ethernet Rx adapter. This callback is invoked if
578  * the caps returned from eventdev_eth_rx_adapter_caps_get(..,eth_port_id)
579  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues
580  * from eth_port_id have been added to the event device.
581  *
582  * @param dev
583  *   Event device pointer
584  *
585  * @param eth_dev
586  *   Ethernet device pointer
587  *
588  * @return
589  *   - 0: Success, ethernet Rx adapter stopped successfully.
590  *   - <0: Error code returned by the driver function.
591  */
592 typedef int (*eventdev_eth_rx_adapter_stop_t)
593                                         (const struct rte_eventdev *dev,
594                                         const struct rte_eth_dev *eth_dev);
595
596 struct rte_event_eth_rx_adapter_stats;
597
598 /**
599  * Retrieve ethernet Rx adapter statistics.
600  *
601  * @param dev
602  *   Event device pointer
603  *
604  * @param eth_dev
605  *   Ethernet device pointer
606  *
607  * @param[out] stats
608  *   Pointer to stats structure
609  *
610  * @return
611  *   Return 0 on success.
612  */
613
614 typedef int (*eventdev_eth_rx_adapter_stats_get)
615                         (const struct rte_eventdev *dev,
616                         const struct rte_eth_dev *eth_dev,
617                         struct rte_event_eth_rx_adapter_stats *stats);
618 /**
619  * Reset ethernet Rx adapter statistics.
620  *
621  * @param dev
622  *   Event device pointer
623  *
624  * @param eth_dev
625  *   Ethernet device pointer
626  *
627  * @return
628  *   Return 0 on success.
629  */
630 typedef int (*eventdev_eth_rx_adapter_stats_reset)
631                         (const struct rte_eventdev *dev,
632                         const struct rte_eth_dev *eth_dev);
633 /**
634  * Start eventdev selftest.
635  *
636  * @return
637  *   Return 0 on success.
638  */
639 typedef int (*eventdev_selftest)(void);
640
641 typedef uint32_t rte_event_pmd_selftest_seqn_t;
642 extern int rte_event_pmd_selftest_seqn_dynfield_offset;
643
644 /**
645  * Read test sequence number from mbuf.
646  *
647  * @param mbuf Structure to read from.
648  * @return pointer to test sequence number.
649  */
650 __rte_internal
651 static inline rte_event_pmd_selftest_seqn_t *
652 rte_event_pmd_selftest_seqn(struct rte_mbuf *mbuf)
653 {
654         return RTE_MBUF_DYNFIELD(mbuf,
655                 rte_event_pmd_selftest_seqn_dynfield_offset,
656                 rte_event_pmd_selftest_seqn_t *);
657 }
658
659 struct rte_cryptodev;
660
661 /**
662  * This API may change without prior notice
663  *
664  * Retrieve the event device's crypto adapter capabilities for the
665  * specified cryptodev
666  *
667  * @param dev
668  *   Event device pointer
669  *
670  * @param cdev
671  *   cryptodev pointer
672  *
673  * @param[out] caps
674  *   A pointer to memory filled with event adapter capabilities.
675  *   It is expected to be pre-allocated & initialized by caller.
676  *
677  * @return
678  *   - 0: Success, driver provides event adapter capabilities for the
679  *      cryptodev.
680  *   - <0: Error code returned by the driver function.
681  *
682  */
683 typedef int (*eventdev_crypto_adapter_caps_get_t)
684                                         (const struct rte_eventdev *dev,
685                                          const struct rte_cryptodev *cdev,
686                                          uint32_t *caps);
687
688 /**
689  * This API may change without prior notice
690  *
691  * Add crypto queue pair to event device. This callback is invoked if
692  * the caps returned from rte_event_crypto_adapter_caps_get(, cdev_id)
693  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set.
694  *
695  * @param dev
696  *   Event device pointer
697  *
698  * @param cdev
699  *   cryptodev pointer
700  *
701  * @param queue_pair_id
702  *   cryptodev queue pair identifier.
703  *
704  * @param event
705  *  Event information required for binding cryptodev queue pair to event queue.
706  *  This structure will have a valid value for only those HW PMDs supporting
707  *  @see RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND capability.
708  *
709  * @return
710  *   - 0: Success, cryptodev queue pair added successfully.
711  *   - <0: Error code returned by the driver function.
712  *
713  */
714 typedef int (*eventdev_crypto_adapter_queue_pair_add_t)
715                         (const struct rte_eventdev *dev,
716                          const struct rte_cryptodev *cdev,
717                          int32_t queue_pair_id,
718                          const struct rte_event *event);
719
720
721 /**
722  * This API may change without prior notice
723  *
724  * Delete crypto queue pair to event device. This callback is invoked if
725  * the caps returned from rte_event_crypto_adapter_caps_get(, cdev_id)
726  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set.
727  *
728  * @param dev
729  *   Event device pointer
730  *
731  * @param cdev
732  *   cryptodev pointer
733  *
734  * @param queue_pair_id
735  *   cryptodev queue pair identifier.
736  *
737  * @return
738  *   - 0: Success, cryptodev queue pair deleted successfully.
739  *   - <0: Error code returned by the driver function.
740  *
741  */
742 typedef int (*eventdev_crypto_adapter_queue_pair_del_t)
743                                         (const struct rte_eventdev *dev,
744                                          const struct rte_cryptodev *cdev,
745                                          int32_t queue_pair_id);
746
747 /**
748  * Start crypto adapter. This callback is invoked if
749  * the caps returned from rte_event_crypto_adapter_caps_get(.., cdev_id)
750  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs
751  * from cdev_id have been added to the event device.
752  *
753  * @param dev
754  *   Event device pointer
755  *
756  * @param cdev
757  *   Crypto device pointer
758  *
759  * @return
760  *   - 0: Success, crypto adapter started successfully.
761  *   - <0: Error code returned by the driver function.
762  */
763 typedef int (*eventdev_crypto_adapter_start_t)
764                                         (const struct rte_eventdev *dev,
765                                          const struct rte_cryptodev *cdev);
766
767 /**
768  * Stop crypto adapter. This callback is invoked if
769  * the caps returned from rte_event_crypto_adapter_caps_get(.., cdev_id)
770  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs
771  * from cdev_id have been added to the event device.
772  *
773  * @param dev
774  *   Event device pointer
775  *
776  * @param cdev
777  *   Crypto device pointer
778  *
779  * @return
780  *   - 0: Success, crypto adapter stopped successfully.
781  *   - <0: Error code returned by the driver function.
782  */
783 typedef int (*eventdev_crypto_adapter_stop_t)
784                                         (const struct rte_eventdev *dev,
785                                          const struct rte_cryptodev *cdev);
786
787 struct rte_event_crypto_adapter_stats;
788
789 /**
790  * Retrieve crypto adapter statistics.
791  *
792  * @param dev
793  *   Event device pointer
794  *
795  * @param cdev
796  *   Crypto device pointer
797  *
798  * @param[out] stats
799  *   Pointer to stats structure
800  *
801  * @return
802  *   Return 0 on success.
803  */
804
805 typedef int (*eventdev_crypto_adapter_stats_get)
806                         (const struct rte_eventdev *dev,
807                          const struct rte_cryptodev *cdev,
808                          struct rte_event_crypto_adapter_stats *stats);
809
810 /**
811  * Reset crypto adapter statistics.
812  *
813  * @param dev
814  *   Event device pointer
815  *
816  * @param cdev
817  *   Crypto device pointer
818  *
819  * @return
820  *   Return 0 on success.
821  */
822
823 typedef int (*eventdev_crypto_adapter_stats_reset)
824                         (const struct rte_eventdev *dev,
825                          const struct rte_cryptodev *cdev);
826
827 /**
828  * Retrieve the event device's eth Tx adapter capabilities.
829  *
830  * @param dev
831  *   Event device pointer
832  *
833  * @param eth_dev
834  *   Ethernet device pointer
835  *
836  * @param[out] caps
837  *   A pointer to memory filled with eth Tx adapter capabilities.
838  *
839  * @return
840  *   - 0: Success, driver provides eth Tx adapter capabilities
841  *   - <0: Error code returned by the driver function.
842  *
843  */
844 typedef int (*eventdev_eth_tx_adapter_caps_get_t)
845                                         (const struct rte_eventdev *dev,
846                                         const struct rte_eth_dev *eth_dev,
847                                         uint32_t *caps);
848
849 /**
850  * Create adapter callback.
851  *
852  * @param id
853  *   Adapter identifier
854  *
855  * @param dev
856  *   Event device pointer
857  *
858  * @return
859  *   - 0: Success.
860  *   - <0: Error code on failure.
861  */
862 typedef int (*eventdev_eth_tx_adapter_create_t)(uint8_t id,
863                                         const struct rte_eventdev *dev);
864
865 /**
866  * Free adapter callback.
867  *
868  * @param id
869  *   Adapter identifier
870  *
871  * @param dev
872  *   Event device pointer
873  *
874  * @return
875  *   - 0: Success.
876  *   - <0: Error code on failure.
877  */
878 typedef int (*eventdev_eth_tx_adapter_free_t)(uint8_t id,
879                                         const struct rte_eventdev *dev);
880
881 /**
882  * Add a Tx queue to the adapter.
883  * A queue value of -1 is used to indicate all
884  * queues within the device.
885  *
886  * @param id
887  *   Adapter identifier
888  *
889  * @param dev
890  *   Event device pointer
891  *
892  * @param eth_dev
893  *   Ethernet device pointer
894  *
895  * @param tx_queue_id
896  *   Transmit queue index
897  *
898  * @return
899  *   - 0: Success.
900  *   - <0: Error code on failure.
901  */
902 typedef int (*eventdev_eth_tx_adapter_queue_add_t)(
903                                         uint8_t id,
904                                         const struct rte_eventdev *dev,
905                                         const struct rte_eth_dev *eth_dev,
906                                         int32_t tx_queue_id);
907
908 /**
909  * Delete a Tx queue from the adapter.
910  * A queue value of -1 is used to indicate all
911  * queues within the device, that have been added to this
912  * adapter.
913  *
914  * @param id
915  *   Adapter identifier
916  *
917  * @param dev
918  *   Event device pointer
919  *
920  * @param eth_dev
921  *   Ethernet device pointer
922  *
923  * @param tx_queue_id
924  *   Transmit queue index
925  *
926  * @return
927  *  - 0: Success, Queues deleted successfully.
928  *  - <0: Error code on failure.
929  */
930 typedef int (*eventdev_eth_tx_adapter_queue_del_t)(
931                                         uint8_t id,
932                                         const struct rte_eventdev *dev,
933                                         const struct rte_eth_dev *eth_dev,
934                                         int32_t tx_queue_id);
935
936 /**
937  * Start the adapter.
938  *
939  * @param id
940  *   Adapter identifier
941  *
942  * @param dev
943  *   Event device pointer
944  *
945  * @return
946  *  - 0: Success, Adapter started correctly.
947  *  - <0: Error code on failure.
948  */
949 typedef int (*eventdev_eth_tx_adapter_start_t)(uint8_t id,
950                                         const struct rte_eventdev *dev);
951
952 /**
953  * Stop the adapter.
954  *
955  * @param id
956  *  Adapter identifier
957  *
958  * @param dev
959  *   Event device pointer
960  *
961  * @return
962  *  - 0: Success.
963  *  - <0: Error code on failure.
964  */
965 typedef int (*eventdev_eth_tx_adapter_stop_t)(uint8_t id,
966                                         const struct rte_eventdev *dev);
967
968 struct rte_event_eth_tx_adapter_stats;
969
970 /**
971  * Retrieve statistics for an adapter
972  *
973  * @param id
974  *  Adapter identifier
975  *
976  * @param dev
977  *   Event device pointer
978  *
979  * @param [out] stats
980  *  A pointer to structure used to retrieve statistics for an adapter
981  *
982  * @return
983  *  - 0: Success, statistics retrieved successfully.
984  *  - <0: Error code on failure.
985  */
986 typedef int (*eventdev_eth_tx_adapter_stats_get_t)(
987                                 uint8_t id,
988                                 const struct rte_eventdev *dev,
989                                 struct rte_event_eth_tx_adapter_stats *stats);
990
991 /**
992  * Reset statistics for an adapter
993  *
994  * @param id
995  *  Adapter identifier
996  *
997  * @param dev
998  *   Event device pointer
999  *
1000  * @return
1001  *  - 0: Success, statistics retrieved successfully.
1002  *  - <0: Error code on failure.
1003  */
1004 typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
1005                                         const struct rte_eventdev *dev);
1006
1007 /** Event device operations function pointer table */
1008 struct rte_eventdev_ops {
1009         eventdev_info_get_t dev_infos_get;      /**< Get device info. */
1010         eventdev_configure_t dev_configure;     /**< Configure device. */
1011         eventdev_start_t dev_start;             /**< Start device. */
1012         eventdev_stop_t dev_stop;               /**< Stop device. */
1013         eventdev_close_t dev_close;             /**< Close device. */
1014
1015         eventdev_queue_default_conf_get_t queue_def_conf;
1016         /**< Get default queue configuration. */
1017         eventdev_queue_setup_t queue_setup;
1018         /**< Set up an event queue. */
1019         eventdev_queue_release_t queue_release;
1020         /**< Release an event queue. */
1021
1022         eventdev_port_default_conf_get_t port_def_conf;
1023         /**< Get default port configuration. */
1024         eventdev_port_setup_t port_setup;
1025         /**< Set up an event port. */
1026         eventdev_port_release_t port_release;
1027         /**< Release an event port. */
1028
1029         eventdev_port_link_t port_link;
1030         /**< Link event queues to an event port. */
1031         eventdev_port_unlink_t port_unlink;
1032         /**< Unlink event queues from an event port. */
1033         eventdev_port_unlinks_in_progress_t port_unlinks_in_progress;
1034         /**< Unlinks in progress on an event port. */
1035         eventdev_dequeue_timeout_ticks_t timeout_ticks;
1036         /**< Converts ns to *timeout_ticks* value for rte_event_dequeue() */
1037         eventdev_dump_t dump;
1038         /* Dump internal information */
1039
1040         eventdev_xstats_get_t xstats_get;
1041         /**< Get extended device statistics. */
1042         eventdev_xstats_get_names_t xstats_get_names;
1043         /**< Get names of extended stats. */
1044         eventdev_xstats_get_by_name xstats_get_by_name;
1045         /**< Get one value by name. */
1046         eventdev_xstats_reset_t xstats_reset;
1047         /**< Reset the statistics values in xstats. */
1048
1049         eventdev_eth_rx_adapter_caps_get_t eth_rx_adapter_caps_get;
1050         /**< Get ethernet Rx adapter capabilities */
1051         eventdev_eth_rx_adapter_queue_add_t eth_rx_adapter_queue_add;
1052         /**< Add Rx queues to ethernet Rx adapter */
1053         eventdev_eth_rx_adapter_queue_del_t eth_rx_adapter_queue_del;
1054         /**< Delete Rx queues from ethernet Rx adapter */
1055         eventdev_eth_rx_adapter_start_t eth_rx_adapter_start;
1056         /**< Start ethernet Rx adapter */
1057         eventdev_eth_rx_adapter_stop_t eth_rx_adapter_stop;
1058         /**< Stop ethernet Rx adapter */
1059         eventdev_eth_rx_adapter_stats_get eth_rx_adapter_stats_get;
1060         /**< Get ethernet Rx stats */
1061         eventdev_eth_rx_adapter_stats_reset eth_rx_adapter_stats_reset;
1062         /**< Reset ethernet Rx stats */
1063
1064         eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
1065         /**< Get timer adapter capabilities */
1066
1067         eventdev_crypto_adapter_caps_get_t crypto_adapter_caps_get;
1068         /**< Get crypto adapter capabilities */
1069         eventdev_crypto_adapter_queue_pair_add_t crypto_adapter_queue_pair_add;
1070         /**< Add queue pair to crypto adapter */
1071         eventdev_crypto_adapter_queue_pair_del_t crypto_adapter_queue_pair_del;
1072         /**< Delete queue pair from crypto adapter */
1073         eventdev_crypto_adapter_start_t crypto_adapter_start;
1074         /**< Start crypto adapter */
1075         eventdev_crypto_adapter_stop_t crypto_adapter_stop;
1076         /**< Stop crypto adapter */
1077         eventdev_crypto_adapter_stats_get crypto_adapter_stats_get;
1078         /**< Get crypto stats */
1079         eventdev_crypto_adapter_stats_reset crypto_adapter_stats_reset;
1080         /**< Reset crypto stats */
1081
1082         eventdev_eth_tx_adapter_caps_get_t eth_tx_adapter_caps_get;
1083         /**< Get ethernet Tx adapter capabilities */
1084
1085         eventdev_eth_tx_adapter_create_t eth_tx_adapter_create;
1086         /**< Create adapter callback */
1087         eventdev_eth_tx_adapter_free_t eth_tx_adapter_free;
1088         /**< Free adapter callback */
1089         eventdev_eth_tx_adapter_queue_add_t eth_tx_adapter_queue_add;
1090         /**< Add Tx queues to the eth Tx adapter */
1091         eventdev_eth_tx_adapter_queue_del_t eth_tx_adapter_queue_del;
1092         /**< Delete Tx queues from the eth Tx adapter */
1093         eventdev_eth_tx_adapter_start_t eth_tx_adapter_start;
1094         /**< Start eth Tx adapter */
1095         eventdev_eth_tx_adapter_stop_t eth_tx_adapter_stop;
1096         /**< Stop eth Tx adapter */
1097         eventdev_eth_tx_adapter_stats_get_t eth_tx_adapter_stats_get;
1098         /**< Get eth Tx adapter statistics */
1099         eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset;
1100         /**< Reset eth Tx adapter statistics */
1101
1102         eventdev_selftest dev_selftest;
1103         /**< Start eventdev Selftest */
1104
1105         eventdev_stop_flush_t dev_stop_flush;
1106         /**< User-provided event flush function */
1107 };
1108
1109 /**
1110  * Allocates a new eventdev slot for an event device and returns the pointer
1111  * to that slot for the driver to use.
1112  *
1113  * @param name
1114  *   Unique identifier name for each device
1115  * @param socket_id
1116  *   Socket to allocate resources on.
1117  * @return
1118  *   - Slot in the rte_dev_devices array for a new device;
1119  */
1120 struct rte_eventdev *
1121 rte_event_pmd_allocate(const char *name, int socket_id);
1122
1123 /**
1124  * Release the specified eventdev device.
1125  *
1126  * @param eventdev
1127  * The *eventdev* pointer is the address of the *rte_eventdev* structure.
1128  * @return
1129  *   - 0 on success, negative on error
1130  */
1131 int
1132 rte_event_pmd_release(struct rte_eventdev *eventdev);
1133
1134 #ifdef __cplusplus
1135 }
1136 #endif
1137
1138 #endif /* _RTE_EVENTDEV_PMD_H_ */