lib: fix doxygen for parameters of function pointers
[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 queues
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 mode
387  *   Level (device, port or queue)
388  * @param queue_port_id
389  *   Queue or port number depending on mode
390  * @param ids
391  *   The stat ids to retrieve
392  * @param values
393  *   The returned stat values
394  * @param n
395  *   The number of id values and entries in the values array
396  * @return
397  *   The number of stat values successfully filled into the values array
398  */
399 typedef int (*eventdev_xstats_get_t)(const struct rte_eventdev *dev,
400                 enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
401                 const unsigned int ids[], uint64_t values[], unsigned int n);
402
403 /**
404  * Resets the statistic values in xstats for the device, based on mode.
405  */
406 typedef int (*eventdev_xstats_reset_t)(struct rte_eventdev *dev,
407                 enum rte_event_dev_xstats_mode mode,
408                 int16_t queue_port_id,
409                 const uint32_t ids[],
410                 uint32_t nb_ids);
411
412 /**
413  * Get names of extended stats of an event device
414  *
415  * @param dev
416  *   Event device pointer
417  * @param mode
418  *   Level (device, port or queue)
419  * @param queue_port_id
420  *   Queue or port number depending on mode
421  * @param xstats_names
422  *   Array of name values to be filled in
423  * @param ids
424  *   The stat ids to retrieve
425  * @param size
426  *   Number of values in the xstats_names array
427  * @return
428  *   When size >= the number of stats, return the number of stat values filled
429  *   into the array.
430  *   When size < the number of available stats, return the number of stats
431  *   values, and do not fill in any data into xstats_names.
432  */
433 typedef int (*eventdev_xstats_get_names_t)(const struct rte_eventdev *dev,
434                 enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
435                 struct rte_event_dev_xstats_name *xstats_names,
436                 unsigned int *ids, unsigned int size);
437
438 /**
439  * Get value of one stats and optionally return its id
440  *
441  * @param dev
442  *   Event device pointer
443  * @param name
444  *   The name of the stat to retrieve
445  * @param id
446  *   Pointer to an unsigned int where we store the stat-id for future reference.
447  *   This pointer may be null if the id is not required.
448  * @return
449  *   The value of the stat, or (uint64_t)-1 if the stat is not found.
450  *   If the stat is not found, the id value will be returned as (unsigned)-1,
451  *   if id pointer is non-NULL
452  */
453 typedef uint64_t (*eventdev_xstats_get_by_name)(const struct rte_eventdev *dev,
454                 const char *name, unsigned int *id);
455
456
457 /**
458  * Retrieve the event device's ethdev Rx adapter capabilities for the
459  * specified ethernet port
460  *
461  * @param dev
462  *   Event device pointer
463  *
464  * @param eth_dev
465  *   Ethernet device pointer
466  *
467  * @param[out] caps
468  *   A pointer to memory filled with Rx event adapter capabilities.
469  *
470  * @return
471  *   - 0: Success, driver provides Rx event adapter capabilities for the
472  *      ethernet device.
473  *   - <0: Error code returned by the driver function.
474  *
475  */
476 typedef int (*eventdev_eth_rx_adapter_caps_get_t)
477                                         (const struct rte_eventdev *dev,
478                                         const struct rte_eth_dev *eth_dev,
479                                         uint32_t *caps);
480
481 struct rte_event_eth_rx_adapter_queue_conf;
482
483 /**
484  * Retrieve the event device's timer adapter capabilities, as well as the ops
485  * structure that an event timer adapter should call through to enter the
486  * driver
487  *
488  * @param dev
489  *   Event device pointer
490  *
491  * @param flags
492  *   Flags that can be used to determine how to select an event timer
493  *   adapter ops structure
494  *
495  * @param[out] caps
496  *   A pointer to memory filled with Rx event adapter capabilities.
497  *
498  * @param[out] ops
499  *   A pointer to the ops pointer to set with the address of the desired ops
500  *   structure
501  *
502  * @return
503  *   - 0: Success, driver provides Rx event adapter capabilities for the
504  *      ethernet device.
505  *   - <0: Error code returned by the driver function.
506  *
507  */
508 typedef int (*eventdev_timer_adapter_caps_get_t)(
509                                 const struct rte_eventdev *dev,
510                                 uint64_t flags,
511                                 uint32_t *caps,
512                                 const struct rte_event_timer_adapter_ops **ops);
513
514 /**
515  * Add ethernet Rx queues to event device. This callback is invoked if
516  * the caps returned from rte_eventdev_eth_rx_adapter_caps_get(, eth_port_id)
517  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set.
518  *
519  * @param dev
520  *   Event device pointer
521  *
522  * @param eth_dev
523  *   Ethernet device pointer
524  *
525  * @param rx_queue_id
526  *   Ethernet device receive queue index
527  *
528  * @param queue_conf
529  *  Additional configuration structure
530
531  * @return
532  *   - 0: Success, ethernet receive queue added successfully.
533  *   - <0: Error code returned by the driver function.
534  *
535  */
536 typedef int (*eventdev_eth_rx_adapter_queue_add_t)(
537                 const struct rte_eventdev *dev,
538                 const struct rte_eth_dev *eth_dev,
539                 int32_t rx_queue_id,
540                 const struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
541
542 /**
543  * Delete ethernet Rx queues from event device. This callback is invoked if
544  * the caps returned from eventdev_eth_rx_adapter_caps_get(, eth_port_id)
545  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set.
546  *
547  * @param dev
548  *   Event device pointer
549  *
550  * @param eth_dev
551  *   Ethernet device pointer
552  *
553  * @param rx_queue_id
554  *   Ethernet device receive queue index
555  *
556  * @return
557  *   - 0: Success, ethernet receive queue deleted successfully.
558  *   - <0: Error code returned by the driver function.
559  *
560  */
561 typedef int (*eventdev_eth_rx_adapter_queue_del_t)
562                                         (const struct rte_eventdev *dev,
563                                         const struct rte_eth_dev *eth_dev,
564                                         int32_t rx_queue_id);
565
566 /**
567  * Start ethernet Rx adapter. This callback is invoked if
568  * the caps returned from eventdev_eth_rx_adapter_caps_get(.., eth_port_id)
569  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues
570  * from eth_port_id have been added to the event device.
571  *
572  * @param dev
573  *   Event device pointer
574  *
575  * @param eth_dev
576  *   Ethernet device pointer
577  *
578  * @return
579  *   - 0: Success, ethernet Rx adapter started successfully.
580  *   - <0: Error code returned by the driver function.
581  */
582 typedef int (*eventdev_eth_rx_adapter_start_t)
583                                         (const struct rte_eventdev *dev,
584                                         const struct rte_eth_dev *eth_dev);
585
586 /**
587  * Stop ethernet Rx adapter. This callback is invoked if
588  * the caps returned from eventdev_eth_rx_adapter_caps_get(..,eth_port_id)
589  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues
590  * from eth_port_id have been added to the event device.
591  *
592  * @param dev
593  *   Event device pointer
594  *
595  * @param eth_dev
596  *   Ethernet device pointer
597  *
598  * @return
599  *   - 0: Success, ethernet Rx adapter stopped successfully.
600  *   - <0: Error code returned by the driver function.
601  */
602 typedef int (*eventdev_eth_rx_adapter_stop_t)
603                                         (const struct rte_eventdev *dev,
604                                         const struct rte_eth_dev *eth_dev);
605
606 struct rte_event_eth_rx_adapter_stats;
607
608 /**
609  * Retrieve ethernet Rx adapter statistics.
610  *
611  * @param dev
612  *   Event device pointer
613  *
614  * @param eth_dev
615  *   Ethernet device pointer
616  *
617  * @param[out] stats
618  *   Pointer to stats structure
619  *
620  * @return
621  *   Return 0 on success.
622  */
623
624 typedef int (*eventdev_eth_rx_adapter_stats_get)
625                         (const struct rte_eventdev *dev,
626                         const struct rte_eth_dev *eth_dev,
627                         struct rte_event_eth_rx_adapter_stats *stats);
628 /**
629  * Reset ethernet Rx adapter statistics.
630  *
631  * @param dev
632  *   Event device pointer
633  *
634  * @param eth_dev
635  *   Ethernet device pointer
636  *
637  * @return
638  *   Return 0 on success.
639  */
640 typedef int (*eventdev_eth_rx_adapter_stats_reset)
641                         (const struct rte_eventdev *dev,
642                         const struct rte_eth_dev *eth_dev);
643 /**
644  * Start eventdev selftest.
645  *
646  * @return
647  *   Return 0 on success.
648  */
649 typedef int (*eventdev_selftest)(void);
650
651 typedef uint32_t rte_event_pmd_selftest_seqn_t;
652 extern int rte_event_pmd_selftest_seqn_dynfield_offset;
653
654 /**
655  * Read test sequence number from mbuf.
656  *
657  * @param mbuf Structure to read from.
658  * @return pointer to test sequence number.
659  */
660 __rte_internal
661 static inline rte_event_pmd_selftest_seqn_t *
662 rte_event_pmd_selftest_seqn(struct rte_mbuf *mbuf)
663 {
664         return RTE_MBUF_DYNFIELD(mbuf,
665                 rte_event_pmd_selftest_seqn_dynfield_offset,
666                 rte_event_pmd_selftest_seqn_t *);
667 }
668
669 struct rte_cryptodev;
670
671 /**
672  * This API may change without prior notice
673  *
674  * Retrieve the event device's crypto adapter capabilities for the
675  * specified cryptodev
676  *
677  * @param dev
678  *   Event device pointer
679  *
680  * @param cdev
681  *   cryptodev pointer
682  *
683  * @param[out] caps
684  *   A pointer to memory filled with event adapter capabilities.
685  *   It is expected to be pre-allocated & initialized by caller.
686  *
687  * @return
688  *   - 0: Success, driver provides event adapter capabilities for the
689  *      cryptodev.
690  *   - <0: Error code returned by the driver function.
691  *
692  */
693 typedef int (*eventdev_crypto_adapter_caps_get_t)
694                                         (const struct rte_eventdev *dev,
695                                          const struct rte_cryptodev *cdev,
696                                          uint32_t *caps);
697
698 /**
699  * This API may change without prior notice
700  *
701  * Add crypto queue pair to event device. This callback is invoked if
702  * the caps returned from rte_event_crypto_adapter_caps_get(, cdev_id)
703  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set.
704  *
705  * @param dev
706  *   Event device pointer
707  *
708  * @param cdev
709  *   cryptodev pointer
710  *
711  * @param queue_pair_id
712  *   cryptodev queue pair identifier.
713  *
714  * @param event
715  *  Event information required for binding cryptodev queue pair to event queue.
716  *  This structure will have a valid value for only those HW PMDs supporting
717  *  @see RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND capability.
718  *
719  * @return
720  *   - 0: Success, cryptodev queue pair added successfully.
721  *   - <0: Error code returned by the driver function.
722  *
723  */
724 typedef int (*eventdev_crypto_adapter_queue_pair_add_t)
725                         (const struct rte_eventdev *dev,
726                          const struct rte_cryptodev *cdev,
727                          int32_t queue_pair_id,
728                          const struct rte_event *event);
729
730
731 /**
732  * This API may change without prior notice
733  *
734  * Delete crypto queue pair to event device. This callback is invoked if
735  * the caps returned from rte_event_crypto_adapter_caps_get(, cdev_id)
736  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set.
737  *
738  * @param dev
739  *   Event device pointer
740  *
741  * @param cdev
742  *   cryptodev pointer
743  *
744  * @param queue_pair_id
745  *   cryptodev queue pair identifier.
746  *
747  * @return
748  *   - 0: Success, cryptodev queue pair deleted successfully.
749  *   - <0: Error code returned by the driver function.
750  *
751  */
752 typedef int (*eventdev_crypto_adapter_queue_pair_del_t)
753                                         (const struct rte_eventdev *dev,
754                                          const struct rte_cryptodev *cdev,
755                                          int32_t queue_pair_id);
756
757 /**
758  * Start crypto adapter. This callback is invoked if
759  * the caps returned from rte_event_crypto_adapter_caps_get(.., cdev_id)
760  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs
761  * from cdev_id have been added to the event device.
762  *
763  * @param dev
764  *   Event device pointer
765  *
766  * @param cdev
767  *   Crypto device pointer
768  *
769  * @return
770  *   - 0: Success, crypto adapter started successfully.
771  *   - <0: Error code returned by the driver function.
772  */
773 typedef int (*eventdev_crypto_adapter_start_t)
774                                         (const struct rte_eventdev *dev,
775                                          const struct rte_cryptodev *cdev);
776
777 /**
778  * Stop crypto adapter. This callback is invoked if
779  * the caps returned from rte_event_crypto_adapter_caps_get(.., cdev_id)
780  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs
781  * from cdev_id have been added to the event device.
782  *
783  * @param dev
784  *   Event device pointer
785  *
786  * @param cdev
787  *   Crypto device pointer
788  *
789  * @return
790  *   - 0: Success, crypto adapter stopped successfully.
791  *   - <0: Error code returned by the driver function.
792  */
793 typedef int (*eventdev_crypto_adapter_stop_t)
794                                         (const struct rte_eventdev *dev,
795                                          const struct rte_cryptodev *cdev);
796
797 struct rte_event_crypto_adapter_stats;
798
799 /**
800  * Retrieve crypto adapter statistics.
801  *
802  * @param dev
803  *   Event device pointer
804  *
805  * @param cdev
806  *   Crypto device pointer
807  *
808  * @param[out] stats
809  *   Pointer to stats structure
810  *
811  * @return
812  *   Return 0 on success.
813  */
814
815 typedef int (*eventdev_crypto_adapter_stats_get)
816                         (const struct rte_eventdev *dev,
817                          const struct rte_cryptodev *cdev,
818                          struct rte_event_crypto_adapter_stats *stats);
819
820 /**
821  * Reset crypto adapter statistics.
822  *
823  * @param dev
824  *   Event device pointer
825  *
826  * @param cdev
827  *   Crypto device pointer
828  *
829  * @return
830  *   Return 0 on success.
831  */
832
833 typedef int (*eventdev_crypto_adapter_stats_reset)
834                         (const struct rte_eventdev *dev,
835                          const struct rte_cryptodev *cdev);
836
837 /**
838  * Retrieve the event device's eth Tx adapter capabilities.
839  *
840  * @param dev
841  *   Event device pointer
842  *
843  * @param eth_dev
844  *   Ethernet device pointer
845  *
846  * @param[out] caps
847  *   A pointer to memory filled with eth Tx adapter capabilities.
848  *
849  * @return
850  *   - 0: Success, driver provides eth Tx adapter capabilities
851  *   - <0: Error code returned by the driver function.
852  *
853  */
854 typedef int (*eventdev_eth_tx_adapter_caps_get_t)
855                                         (const struct rte_eventdev *dev,
856                                         const struct rte_eth_dev *eth_dev,
857                                         uint32_t *caps);
858
859 /**
860  * Create adapter callback.
861  *
862  * @param id
863  *   Adapter identifier
864  *
865  * @param dev
866  *   Event device pointer
867  *
868  * @return
869  *   - 0: Success.
870  *   - <0: Error code on failure.
871  */
872 typedef int (*eventdev_eth_tx_adapter_create_t)(uint8_t id,
873                                         const struct rte_eventdev *dev);
874
875 /**
876  * Free adapter callback.
877  *
878  * @param id
879  *   Adapter identifier
880  *
881  * @param dev
882  *   Event device pointer
883  *
884  * @return
885  *   - 0: Success.
886  *   - <0: Error code on failure.
887  */
888 typedef int (*eventdev_eth_tx_adapter_free_t)(uint8_t id,
889                                         const struct rte_eventdev *dev);
890
891 /**
892  * Add a Tx queue to the adapter.
893  * A queue value of -1 is used to indicate all
894  * queues within the device.
895  *
896  * @param id
897  *   Adapter identifier
898  *
899  * @param dev
900  *   Event device pointer
901  *
902  * @param eth_dev
903  *   Ethernet device pointer
904  *
905  * @param tx_queue_id
906  *   Transmit queue index
907  *
908  * @return
909  *   - 0: Success.
910  *   - <0: Error code on failure.
911  */
912 typedef int (*eventdev_eth_tx_adapter_queue_add_t)(
913                                         uint8_t id,
914                                         const struct rte_eventdev *dev,
915                                         const struct rte_eth_dev *eth_dev,
916                                         int32_t tx_queue_id);
917
918 /**
919  * Delete a Tx queue from the adapter.
920  * A queue value of -1 is used to indicate all
921  * queues within the device, that have been added to this
922  * adapter.
923  *
924  * @param id
925  *   Adapter identifier
926  *
927  * @param dev
928  *   Event device pointer
929  *
930  * @param eth_dev
931  *   Ethernet device pointer
932  *
933  * @param tx_queue_id
934  *   Transmit queue index
935  *
936  * @return
937  *  - 0: Success, Queues deleted successfully.
938  *  - <0: Error code on failure.
939  */
940 typedef int (*eventdev_eth_tx_adapter_queue_del_t)(
941                                         uint8_t id,
942                                         const struct rte_eventdev *dev,
943                                         const struct rte_eth_dev *eth_dev,
944                                         int32_t tx_queue_id);
945
946 /**
947  * Start the adapter.
948  *
949  * @param id
950  *   Adapter identifier
951  *
952  * @param dev
953  *   Event device pointer
954  *
955  * @return
956  *  - 0: Success, Adapter started correctly.
957  *  - <0: Error code on failure.
958  */
959 typedef int (*eventdev_eth_tx_adapter_start_t)(uint8_t id,
960                                         const struct rte_eventdev *dev);
961
962 /**
963  * Stop the adapter.
964  *
965  * @param id
966  *  Adapter identifier
967  *
968  * @param dev
969  *   Event device pointer
970  *
971  * @return
972  *  - 0: Success.
973  *  - <0: Error code on failure.
974  */
975 typedef int (*eventdev_eth_tx_adapter_stop_t)(uint8_t id,
976                                         const struct rte_eventdev *dev);
977
978 struct rte_event_eth_tx_adapter_stats;
979
980 /**
981  * Retrieve statistics for an adapter
982  *
983  * @param id
984  *  Adapter identifier
985  *
986  * @param dev
987  *   Event device pointer
988  *
989  * @param [out] stats
990  *  A pointer to structure used to retrieve statistics for an adapter
991  *
992  * @return
993  *  - 0: Success, statistics retrieved successfully.
994  *  - <0: Error code on failure.
995  */
996 typedef int (*eventdev_eth_tx_adapter_stats_get_t)(
997                                 uint8_t id,
998                                 const struct rte_eventdev *dev,
999                                 struct rte_event_eth_tx_adapter_stats *stats);
1000
1001 /**
1002  * Reset statistics for an adapter
1003  *
1004  * @param id
1005  *  Adapter identifier
1006  *
1007  * @param dev
1008  *   Event device pointer
1009  *
1010  * @return
1011  *  - 0: Success, statistics retrieved successfully.
1012  *  - <0: Error code on failure.
1013  */
1014 typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
1015                                         const struct rte_eventdev *dev);
1016
1017 /** Event device operations function pointer table */
1018 struct rte_eventdev_ops {
1019         eventdev_info_get_t dev_infos_get;      /**< Get device info. */
1020         eventdev_configure_t dev_configure;     /**< Configure device. */
1021         eventdev_start_t dev_start;             /**< Start device. */
1022         eventdev_stop_t dev_stop;               /**< Stop device. */
1023         eventdev_close_t dev_close;             /**< Close device. */
1024
1025         eventdev_queue_default_conf_get_t queue_def_conf;
1026         /**< Get default queue configuration. */
1027         eventdev_queue_setup_t queue_setup;
1028         /**< Set up an event queue. */
1029         eventdev_queue_release_t queue_release;
1030         /**< Release an event queue. */
1031
1032         eventdev_port_default_conf_get_t port_def_conf;
1033         /**< Get default port configuration. */
1034         eventdev_port_setup_t port_setup;
1035         /**< Set up an event port. */
1036         eventdev_port_release_t port_release;
1037         /**< Release an event port. */
1038
1039         eventdev_port_link_t port_link;
1040         /**< Link event queues to an event port. */
1041         eventdev_port_unlink_t port_unlink;
1042         /**< Unlink event queues from an event port. */
1043         eventdev_port_unlinks_in_progress_t port_unlinks_in_progress;
1044         /**< Unlinks in progress on an event port. */
1045         eventdev_dequeue_timeout_ticks_t timeout_ticks;
1046         /**< Converts ns to *timeout_ticks* value for rte_event_dequeue() */
1047         eventdev_dump_t dump;
1048         /* Dump internal information */
1049
1050         eventdev_xstats_get_t xstats_get;
1051         /**< Get extended device statistics. */
1052         eventdev_xstats_get_names_t xstats_get_names;
1053         /**< Get names of extended stats. */
1054         eventdev_xstats_get_by_name xstats_get_by_name;
1055         /**< Get one value by name. */
1056         eventdev_xstats_reset_t xstats_reset;
1057         /**< Reset the statistics values in xstats. */
1058
1059         eventdev_eth_rx_adapter_caps_get_t eth_rx_adapter_caps_get;
1060         /**< Get ethernet Rx adapter capabilities */
1061         eventdev_eth_rx_adapter_queue_add_t eth_rx_adapter_queue_add;
1062         /**< Add Rx queues to ethernet Rx adapter */
1063         eventdev_eth_rx_adapter_queue_del_t eth_rx_adapter_queue_del;
1064         /**< Delete Rx queues from ethernet Rx adapter */
1065         eventdev_eth_rx_adapter_start_t eth_rx_adapter_start;
1066         /**< Start ethernet Rx adapter */
1067         eventdev_eth_rx_adapter_stop_t eth_rx_adapter_stop;
1068         /**< Stop ethernet Rx adapter */
1069         eventdev_eth_rx_adapter_stats_get eth_rx_adapter_stats_get;
1070         /**< Get ethernet Rx stats */
1071         eventdev_eth_rx_adapter_stats_reset eth_rx_adapter_stats_reset;
1072         /**< Reset ethernet Rx stats */
1073
1074         eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
1075         /**< Get timer adapter capabilities */
1076
1077         eventdev_crypto_adapter_caps_get_t crypto_adapter_caps_get;
1078         /**< Get crypto adapter capabilities */
1079         eventdev_crypto_adapter_queue_pair_add_t crypto_adapter_queue_pair_add;
1080         /**< Add queue pair to crypto adapter */
1081         eventdev_crypto_adapter_queue_pair_del_t crypto_adapter_queue_pair_del;
1082         /**< Delete queue pair from crypto adapter */
1083         eventdev_crypto_adapter_start_t crypto_adapter_start;
1084         /**< Start crypto adapter */
1085         eventdev_crypto_adapter_stop_t crypto_adapter_stop;
1086         /**< Stop crypto adapter */
1087         eventdev_crypto_adapter_stats_get crypto_adapter_stats_get;
1088         /**< Get crypto stats */
1089         eventdev_crypto_adapter_stats_reset crypto_adapter_stats_reset;
1090         /**< Reset crypto stats */
1091
1092         eventdev_eth_tx_adapter_caps_get_t eth_tx_adapter_caps_get;
1093         /**< Get ethernet Tx adapter capabilities */
1094
1095         eventdev_eth_tx_adapter_create_t eth_tx_adapter_create;
1096         /**< Create adapter callback */
1097         eventdev_eth_tx_adapter_free_t eth_tx_adapter_free;
1098         /**< Free adapter callback */
1099         eventdev_eth_tx_adapter_queue_add_t eth_tx_adapter_queue_add;
1100         /**< Add Tx queues to the eth Tx adapter */
1101         eventdev_eth_tx_adapter_queue_del_t eth_tx_adapter_queue_del;
1102         /**< Delete Tx queues from the eth Tx adapter */
1103         eventdev_eth_tx_adapter_start_t eth_tx_adapter_start;
1104         /**< Start eth Tx adapter */
1105         eventdev_eth_tx_adapter_stop_t eth_tx_adapter_stop;
1106         /**< Stop eth Tx adapter */
1107         eventdev_eth_tx_adapter_stats_get_t eth_tx_adapter_stats_get;
1108         /**< Get eth Tx adapter statistics */
1109         eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset;
1110         /**< Reset eth Tx adapter statistics */
1111
1112         eventdev_selftest dev_selftest;
1113         /**< Start eventdev Selftest */
1114
1115         eventdev_stop_flush_t dev_stop_flush;
1116         /**< User-provided event flush function */
1117 };
1118
1119 /**
1120  * Allocates a new eventdev slot for an event device and returns the pointer
1121  * to that slot for the driver to use.
1122  *
1123  * @param name
1124  *   Unique identifier name for each device
1125  * @param socket_id
1126  *   Socket to allocate resources on.
1127  * @return
1128  *   - Slot in the rte_dev_devices array for a new device;
1129  */
1130 struct rte_eventdev *
1131 rte_event_pmd_allocate(const char *name, int socket_id);
1132
1133 /**
1134  * Release the specified eventdev device.
1135  *
1136  * @param eventdev
1137  * The *eventdev* pointer is the address of the *rte_eventdev* structure.
1138  * @return
1139  *   - 0 on success, negative on error
1140  */
1141 int
1142 rte_event_pmd_release(struct rte_eventdev *eventdev);
1143
1144 #ifdef __cplusplus
1145 }
1146 #endif
1147
1148 #endif /* _RTE_EVENTDEV_PMD_H_ */