New upstream version 18.08
[deb_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_config.h>
24 #include <rte_dev.h>
25 #include <rte_log.h>
26 #include <rte_malloc.h>
27
28 #include "rte_eventdev.h"
29 #include "rte_event_timer_adapter_pmd.h"
30
31 /* Logging Macros */
32 #define RTE_EDEV_LOG_ERR(...) \
33         RTE_LOG(ERR, EVENTDEV, \
34                 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
35                         __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
36
37 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
38 #define RTE_EDEV_LOG_DEBUG(...) \
39         RTE_LOG(DEBUG, EVENTDEV, \
40                 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
41                         __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
42 #else
43 #define RTE_EDEV_LOG_DEBUG(...) (void)0
44 #endif
45
46 /* Macros to check for valid device */
47 #define RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, retval) do { \
48         if (!rte_event_pmd_is_valid_dev((dev_id))) { \
49                 RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
50                 return retval; \
51         } \
52 } while (0)
53
54 #define RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, errno, retval) do { \
55         if (!rte_event_pmd_is_valid_dev((dev_id))) { \
56                 RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
57                 rte_errno = errno; \
58                 return retval; \
59         } \
60 } while (0)
61
62 #define RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id) do { \
63         if (!rte_event_pmd_is_valid_dev((dev_id))) { \
64                 RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
65                 return; \
66         } \
67 } while (0)
68
69 #define RTE_EVENT_ETH_RX_ADAPTER_SW_CAP \
70                 ((RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID) | \
71                         (RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ))
72
73 #define RTE_EVENT_CRYPTO_ADAPTER_SW_CAP \
74                 RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA
75
76 /**< Ethernet Rx adapter cap to return If the packet transfers from
77  * the ethdev to eventdev use a SW service function
78  */
79
80 #define RTE_EVENTDEV_DETACHED  (0)
81 #define RTE_EVENTDEV_ATTACHED  (1)
82
83 struct rte_eth_dev;
84
85 /** Global structure used for maintaining state of allocated event devices */
86 struct rte_eventdev_global {
87         uint8_t nb_devs;        /**< Number of devices found */
88 };
89
90 extern struct rte_eventdev_global *rte_eventdev_globals;
91 /** Pointer to global event devices data structure. */
92 extern struct rte_eventdev *rte_eventdevs;
93 /** The pool of rte_eventdev structures. */
94
95 /**
96  * Get the rte_eventdev structure device pointer for the named device.
97  *
98  * @param name
99  *   device name to select the device structure.
100  *
101  * @return
102  *   - The rte_eventdev structure pointer for the given device ID.
103  */
104 static inline struct rte_eventdev *
105 rte_event_pmd_get_named_dev(const char *name)
106 {
107         struct rte_eventdev *dev;
108         unsigned int i;
109
110         if (name == NULL)
111                 return NULL;
112
113         for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
114                 dev = &rte_eventdevs[i];
115                 if ((dev->attached == RTE_EVENTDEV_ATTACHED) &&
116                                 (strcmp(dev->data->name, name) == 0))
117                         return dev;
118         }
119
120         return NULL;
121 }
122
123 /**
124  * Validate if the event device index is valid attached event device.
125  *
126  * @param dev_id
127  *   Event device index.
128  *
129  * @return
130  *   - If the device index is valid (1) or not (0).
131  */
132 static inline unsigned
133 rte_event_pmd_is_valid_dev(uint8_t dev_id)
134 {
135         struct rte_eventdev *dev;
136
137         if (dev_id >= RTE_EVENT_MAX_DEVS)
138                 return 0;
139
140         dev = &rte_eventdevs[dev_id];
141         if (dev->attached != RTE_EVENTDEV_ATTACHED)
142                 return 0;
143         else
144                 return 1;
145 }
146
147 /**
148  * Definitions of all functions exported by a driver through the
149  * the generic structure of type *event_dev_ops* supplied in the
150  * *rte_eventdev* structure associated with a device.
151  */
152
153 /**
154  * Get device information of a device.
155  *
156  * @param dev
157  *   Event device pointer
158  * @param dev_info
159  *   Event device information structure
160  *
161  * @return
162  *   Returns 0 on success
163  */
164 typedef void (*eventdev_info_get_t)(struct rte_eventdev *dev,
165                 struct rte_event_dev_info *dev_info);
166
167 /**
168  * Configure a device.
169  *
170  * @param dev
171  *   Event device pointer
172  *
173  * @return
174  *   Returns 0 on success
175  */
176 typedef int (*eventdev_configure_t)(const struct rte_eventdev *dev);
177
178 /**
179  * Start a configured device.
180  *
181  * @param dev
182  *   Event device pointer
183  *
184  * @return
185  *   Returns 0 on success
186  */
187 typedef int (*eventdev_start_t)(struct rte_eventdev *dev);
188
189 /**
190  * Stop a configured device.
191  *
192  * @param dev
193  *   Event device pointer
194  */
195 typedef void (*eventdev_stop_t)(struct rte_eventdev *dev);
196
197 /**
198  * Close a configured device.
199  *
200  * @param dev
201  *   Event device pointer
202  *
203  * @return
204  * - 0 on success
205  * - (-EAGAIN) if can't close as device is busy
206  */
207 typedef int (*eventdev_close_t)(struct rte_eventdev *dev);
208
209 /**
210  * Retrieve the default event queue configuration.
211  *
212  * @param dev
213  *   Event device pointer
214  * @param queue_id
215  *   Event queue index
216  * @param[out] queue_conf
217  *   Event queue configuration structure
218  *
219  */
220 typedef void (*eventdev_queue_default_conf_get_t)(struct rte_eventdev *dev,
221                 uint8_t queue_id, struct rte_event_queue_conf *queue_conf);
222
223 /**
224  * Setup an event queue.
225  *
226  * @param dev
227  *   Event device pointer
228  * @param queue_id
229  *   Event queue index
230  * @param queue_conf
231  *   Event queue configuration structure
232  *
233  * @return
234  *   Returns 0 on success.
235  */
236 typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
237                 uint8_t queue_id,
238                 const struct rte_event_queue_conf *queue_conf);
239
240 /**
241  * Release resources allocated by given event queue.
242  *
243  * @param dev
244  *   Event device pointer
245  * @param queue_id
246  *   Event queue index
247  *
248  */
249 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
250                 uint8_t queue_id);
251
252 /**
253  * Retrieve the default event port configuration.
254  *
255  * @param dev
256  *   Event device pointer
257  * @param port_id
258  *   Event port index
259  * @param[out] port_conf
260  *   Event port configuration structure
261  *
262  */
263 typedef void (*eventdev_port_default_conf_get_t)(struct rte_eventdev *dev,
264                 uint8_t port_id, struct rte_event_port_conf *port_conf);
265
266 /**
267  * Setup an event port.
268  *
269  * @param dev
270  *   Event device pointer
271  * @param port_id
272  *   Event port index
273  * @param port_conf
274  *   Event port configuration structure
275  *
276  * @return
277  *   Returns 0 on success.
278  */
279 typedef int (*eventdev_port_setup_t)(struct rte_eventdev *dev,
280                 uint8_t port_id,
281                 const struct rte_event_port_conf *port_conf);
282
283 /**
284  * Release memory resources allocated by given event port.
285  *
286  * @param port
287  *   Event port pointer
288  *
289  */
290 typedef void (*eventdev_port_release_t)(void *port);
291
292 /**
293  * Link multiple source event queues to destination event port.
294  *
295  * @param dev
296  *   Event device pointer
297  * @param port
298  *   Event port pointer
299  * @param link
300  *   Points to an array of *nb_links* event queues to be linked
301  *   to the event port.
302  * @param priorities
303  *   Points to an array of *nb_links* service priorities associated with each
304  *   event queue link to event port.
305  * @param nb_links
306  *   The number of links to establish
307  *
308  * @return
309  *   Returns 0 on success.
310  *
311  */
312 typedef int (*eventdev_port_link_t)(struct rte_eventdev *dev, void *port,
313                 const uint8_t queues[], const uint8_t priorities[],
314                 uint16_t nb_links);
315
316 /**
317  * Unlink multiple source event queues from destination event port.
318  *
319  * @param dev
320  *   Event device pointer
321  * @param port
322  *   Event port pointer
323  * @param queues
324  *   An array of *nb_unlinks* event queues to be unlinked from the event port.
325  * @param nb_unlinks
326  *   The number of unlinks to establish
327  *
328  * @return
329  *   Returns 0 on success.
330  *
331  */
332 typedef int (*eventdev_port_unlink_t)(struct rte_eventdev *dev, void *port,
333                 uint8_t queues[], uint16_t nb_unlinks);
334
335 /**
336  * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue()
337  *
338  * @param dev
339  *   Event device pointer
340  * @param ns
341  *   Wait time in nanosecond
342  * @param[out] timeout_ticks
343  *   Value for the *timeout_ticks* parameter in rte_event_dequeue() function
344  *
345  * @return
346  *   Returns 0 on success.
347  *
348  */
349 typedef int (*eventdev_dequeue_timeout_ticks_t)(struct rte_eventdev *dev,
350                 uint64_t ns, uint64_t *timeout_ticks);
351
352 /**
353  * Dump internal information
354  *
355  * @param dev
356  *   Event device pointer
357  * @param f
358  *   A pointer to a file for output
359  *
360  */
361 typedef void (*eventdev_dump_t)(struct rte_eventdev *dev, FILE *f);
362
363 /**
364  * Retrieve a set of statistics from device
365  *
366  * @param dev
367  *   Event device pointer
368  * @param ids
369  *   The stat ids to retrieve
370  * @param values
371  *   The returned stat values
372  * @param n
373  *   The number of id values and entries in the values array
374  * @return
375  *   The number of stat values successfully filled into the values array
376  */
377 typedef int (*eventdev_xstats_get_t)(const struct rte_eventdev *dev,
378                 enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
379                 const unsigned int ids[], uint64_t values[], unsigned int n);
380
381 /**
382  * Resets the statistic values in xstats for the device, based on mode.
383  */
384 typedef int (*eventdev_xstats_reset_t)(struct rte_eventdev *dev,
385                 enum rte_event_dev_xstats_mode mode,
386                 int16_t queue_port_id,
387                 const uint32_t ids[],
388                 uint32_t nb_ids);
389
390 /**
391  * Get names of extended stats of an event device
392  *
393  * @param dev
394  *   Event device pointer
395  * @param xstats_names
396  *   Array of name values to be filled in
397  * @param size
398  *   Number of values in the xstats_names array
399  * @return
400  *   When size >= the number of stats, return the number of stat values filled
401  *   into the array.
402  *   When size < the number of available stats, return the number of stats
403  *   values, and do not fill in any data into xstats_names.
404  */
405 typedef int (*eventdev_xstats_get_names_t)(const struct rte_eventdev *dev,
406                 enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
407                 struct rte_event_dev_xstats_name *xstats_names,
408                 unsigned int *ids, unsigned int size);
409
410 /**
411  * Get value of one stats and optionally return its id
412  *
413  * @param dev
414  *   Event device pointer
415  * @param name
416  *   The name of the stat to retrieve
417  * @param id
418  *   Pointer to an unsigned int where we store the stat-id for future reference.
419  *   This pointer may be null if the id is not required.
420  * @return
421  *   The value of the stat, or (uint64_t)-1 if the stat is not found.
422  *   If the stat is not found, the id value will be returned as (unsigned)-1,
423  *   if id pointer is non-NULL
424  */
425 typedef uint64_t (*eventdev_xstats_get_by_name)(const struct rte_eventdev *dev,
426                 const char *name, unsigned int *id);
427
428
429 /**
430  * Retrieve the event device's ethdev Rx adapter capabilities for the
431  * specified ethernet port
432  *
433  * @param dev
434  *   Event device pointer
435  *
436  * @param eth_dev
437  *   Ethernet device pointer
438  *
439  * @param[out] caps
440  *   A pointer to memory filled with Rx event adapter capabilities.
441  *
442  * @return
443  *   - 0: Success, driver provides Rx event adapter capabilities for the
444  *      ethernet device.
445  *   - <0: Error code returned by the driver function.
446  *
447  */
448 typedef int (*eventdev_eth_rx_adapter_caps_get_t)
449                                         (const struct rte_eventdev *dev,
450                                         const struct rte_eth_dev *eth_dev,
451                                         uint32_t *caps);
452
453 struct rte_event_eth_rx_adapter_queue_conf *queue_conf;
454
455 /**
456  * Retrieve the event device's timer adapter capabilities, as well as the ops
457  * structure that an event timer adapter should call through to enter the
458  * driver
459  *
460  * @param dev
461  *   Event device pointer
462  *
463  * @param flags
464  *   Flags that can be used to determine how to select an event timer
465  *   adapter ops structure
466  *
467  * @param[out] caps
468  *   A pointer to memory filled with Rx event adapter capabilities.
469  *
470  * @param[out] ops
471  *   A pointer to the ops pointer to set with the address of the desired ops
472  *   structure
473  *
474  * @return
475  *   - 0: Success, driver provides Rx event adapter capabilities for the
476  *      ethernet device.
477  *   - <0: Error code returned by the driver function.
478  *
479  */
480 typedef int (*eventdev_timer_adapter_caps_get_t)(
481                                 const struct rte_eventdev *dev,
482                                 uint64_t flags,
483                                 uint32_t *caps,
484                                 const struct rte_event_timer_adapter_ops **ops);
485
486 /**
487  * Add ethernet Rx queues to event device. This callback is invoked if
488  * the caps returned from rte_eventdev_eth_rx_adapter_caps_get(, eth_port_id)
489  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set.
490  *
491  * @param dev
492  *   Event device pointer
493  *
494  * @param eth_dev
495  *   Ethernet device pointer
496  *
497  * @param rx_queue_id
498  *   Ethernet device receive queue index
499  *
500  * @param queue_conf
501  *  Additional configuration structure
502
503  * @return
504  *   - 0: Success, ethernet receive queue added successfully.
505  *   - <0: Error code returned by the driver function.
506  *
507  */
508 typedef int (*eventdev_eth_rx_adapter_queue_add_t)(
509                 const struct rte_eventdev *dev,
510                 const struct rte_eth_dev *eth_dev,
511                 int32_t rx_queue_id,
512                 const struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
513
514 /**
515  * Delete ethernet Rx queues from event device. This callback is invoked if
516  * the caps returned from 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  * @return
529  *   - 0: Success, ethernet receive queue deleted successfully.
530  *   - <0: Error code returned by the driver function.
531  *
532  */
533 typedef int (*eventdev_eth_rx_adapter_queue_del_t)
534                                         (const struct rte_eventdev *dev,
535                                         const struct rte_eth_dev *eth_dev,
536                                         int32_t rx_queue_id);
537
538 /**
539  * Start ethernet Rx adapter. This callback is invoked if
540  * the caps returned from eventdev_eth_rx_adapter_caps_get(.., eth_port_id)
541  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues
542  * from eth_port_id have been added to the event device.
543  *
544  * @param dev
545  *   Event device pointer
546  *
547  * @param eth_dev
548  *   Ethernet device pointer
549  *
550  * @return
551  *   - 0: Success, ethernet Rx adapter started successfully.
552  *   - <0: Error code returned by the driver function.
553  */
554 typedef int (*eventdev_eth_rx_adapter_start_t)
555                                         (const struct rte_eventdev *dev,
556                                         const struct rte_eth_dev *eth_dev);
557
558 /**
559  * Stop ethernet Rx adapter. This callback is invoked if
560  * the caps returned from eventdev_eth_rx_adapter_caps_get(..,eth_port_id)
561  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues
562  * from eth_port_id have been added to the event device.
563  *
564  * @param dev
565  *   Event device pointer
566  *
567  * @param eth_dev
568  *   Ethernet device pointer
569  *
570  * @return
571  *   - 0: Success, ethernet Rx adapter stopped successfully.
572  *   - <0: Error code returned by the driver function.
573  */
574 typedef int (*eventdev_eth_rx_adapter_stop_t)
575                                         (const struct rte_eventdev *dev,
576                                         const struct rte_eth_dev *eth_dev);
577
578 struct rte_event_eth_rx_adapter_stats *stats;
579
580 /**
581  * Retrieve ethernet Rx adapter statistics.
582  *
583  * @param dev
584  *   Event device pointer
585  *
586  * @param eth_dev
587  *   Ethernet device pointer
588  *
589  * @param[out] stats
590  *   Pointer to stats structure
591  *
592  * @return
593  *   Return 0 on success.
594  */
595
596 typedef int (*eventdev_eth_rx_adapter_stats_get)
597                         (const struct rte_eventdev *dev,
598                         const struct rte_eth_dev *eth_dev,
599                         struct rte_event_eth_rx_adapter_stats *stats);
600 /**
601  * Reset ethernet Rx adapter statistics.
602  *
603  * @param dev
604  *   Event device pointer
605  *
606  * @param eth_dev
607  *   Ethernet device pointer
608  *
609  * @return
610  *   Return 0 on success.
611  */
612 typedef int (*eventdev_eth_rx_adapter_stats_reset)
613                         (const struct rte_eventdev *dev,
614                         const struct rte_eth_dev *eth_dev);
615 /**
616  * Start eventdev selftest.
617  *
618  * @return
619  *   Return 0 on success.
620  */
621 typedef int (*eventdev_selftest)(void);
622
623
624 struct rte_cryptodev;
625
626 /**
627  * This API may change without prior notice
628  *
629  * Retrieve the event device's crypto adapter capabilities for the
630  * specified cryptodev
631  *
632  * @param dev
633  *   Event device pointer
634  *
635  * @param cdev
636  *   cryptodev pointer
637  *
638  * @param[out] caps
639  *   A pointer to memory filled with event adapter capabilities.
640  *   It is expected to be pre-allocated & initialized by caller.
641  *
642  * @return
643  *   - 0: Success, driver provides event adapter capabilities for the
644  *      cryptodev.
645  *   - <0: Error code returned by the driver function.
646  *
647  */
648 typedef int (*eventdev_crypto_adapter_caps_get_t)
649                                         (const struct rte_eventdev *dev,
650                                          const struct rte_cryptodev *cdev,
651                                          uint32_t *caps);
652
653 /**
654  * This API may change without prior notice
655  *
656  * Add crypto queue pair to event device. This callback is invoked if
657  * the caps returned from rte_event_crypto_adapter_caps_get(, cdev_id)
658  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set.
659  *
660  * @param dev
661  *   Event device pointer
662  *
663  * @param cdev
664  *   cryptodev pointer
665  *
666  * @param queue_pair_id
667  *   cryptodev queue pair identifier.
668  *
669  * @param event
670  *  Event information required for binding cryptodev queue pair to event queue.
671  *  This structure will have a valid value for only those HW PMDs supporting
672  *  @see RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND capability.
673  *
674  * @return
675  *   - 0: Success, cryptodev queue pair added successfully.
676  *   - <0: Error code returned by the driver function.
677  *
678  */
679 typedef int (*eventdev_crypto_adapter_queue_pair_add_t)
680                         (const struct rte_eventdev *dev,
681                          const struct rte_cryptodev *cdev,
682                          int32_t queue_pair_id,
683                          const struct rte_event *event);
684
685
686 /**
687  * This API may change without prior notice
688  *
689  * Delete crypto queue pair to event device. This callback is invoked if
690  * the caps returned from rte_event_crypto_adapter_caps_get(, cdev_id)
691  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set.
692  *
693  * @param dev
694  *   Event device pointer
695  *
696  * @param cdev
697  *   cryptodev pointer
698  *
699  * @param queue_pair_id
700  *   cryptodev queue pair identifier.
701  *
702  * @return
703  *   - 0: Success, cryptodev queue pair deleted successfully.
704  *   - <0: Error code returned by the driver function.
705  *
706  */
707 typedef int (*eventdev_crypto_adapter_queue_pair_del_t)
708                                         (const struct rte_eventdev *dev,
709                                          const struct rte_cryptodev *cdev,
710                                          int32_t queue_pair_id);
711
712 /**
713  * Start crypto adapter. This callback is invoked if
714  * the caps returned from rte_event_crypto_adapter_caps_get(.., cdev_id)
715  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs
716  * from cdev_id have been added to the event device.
717  *
718  * @param dev
719  *   Event device pointer
720  *
721  * @param cdev
722  *   Crypto device pointer
723  *
724  * @return
725  *   - 0: Success, crypto adapter started successfully.
726  *   - <0: Error code returned by the driver function.
727  */
728 typedef int (*eventdev_crypto_adapter_start_t)
729                                         (const struct rte_eventdev *dev,
730                                          const struct rte_cryptodev *cdev);
731
732 /**
733  * Stop crypto adapter. This callback is invoked if
734  * the caps returned from rte_event_crypto_adapter_caps_get(.., cdev_id)
735  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs
736  * from cdev_id have been added to the event device.
737  *
738  * @param dev
739  *   Event device pointer
740  *
741  * @param cdev
742  *   Crypto device pointer
743  *
744  * @return
745  *   - 0: Success, crypto adapter stopped successfully.
746  *   - <0: Error code returned by the driver function.
747  */
748 typedef int (*eventdev_crypto_adapter_stop_t)
749                                         (const struct rte_eventdev *dev,
750                                          const struct rte_cryptodev *cdev);
751
752 struct rte_event_crypto_adapter_stats;
753
754 /**
755  * Retrieve crypto adapter statistics.
756  *
757  * @param dev
758  *   Event device pointer
759  *
760  * @param cdev
761  *   Crypto device pointer
762  *
763  * @param[out] stats
764  *   Pointer to stats structure
765  *
766  * @return
767  *   Return 0 on success.
768  */
769
770 typedef int (*eventdev_crypto_adapter_stats_get)
771                         (const struct rte_eventdev *dev,
772                          const struct rte_cryptodev *cdev,
773                          struct rte_event_crypto_adapter_stats *stats);
774
775 /**
776  * Reset crypto adapter statistics.
777  *
778  * @param dev
779  *   Event device pointer
780  *
781  * @param cdev
782  *   Crypto device pointer
783  *
784  * @return
785  *   Return 0 on success.
786  */
787
788 typedef int (*eventdev_crypto_adapter_stats_reset)
789                         (const struct rte_eventdev *dev,
790                          const struct rte_cryptodev *cdev);
791
792 /** Event device operations function pointer table */
793 struct rte_eventdev_ops {
794         eventdev_info_get_t dev_infos_get;      /**< Get device info. */
795         eventdev_configure_t dev_configure;     /**< Configure device. */
796         eventdev_start_t dev_start;             /**< Start device. */
797         eventdev_stop_t dev_stop;               /**< Stop device. */
798         eventdev_close_t dev_close;             /**< Close device. */
799
800         eventdev_queue_default_conf_get_t queue_def_conf;
801         /**< Get default queue configuration. */
802         eventdev_queue_setup_t queue_setup;
803         /**< Set up an event queue. */
804         eventdev_queue_release_t queue_release;
805         /**< Release an event queue. */
806
807         eventdev_port_default_conf_get_t port_def_conf;
808         /**< Get default port configuration. */
809         eventdev_port_setup_t port_setup;
810         /**< Set up an event port. */
811         eventdev_port_release_t port_release;
812         /**< Release an event port. */
813
814         eventdev_port_link_t port_link;
815         /**< Link event queues to an event port. */
816         eventdev_port_unlink_t port_unlink;
817         /**< Unlink event queues from an event port. */
818         eventdev_dequeue_timeout_ticks_t timeout_ticks;
819         /**< Converts ns to *timeout_ticks* value for rte_event_dequeue() */
820         eventdev_dump_t dump;
821         /* Dump internal information */
822
823         eventdev_xstats_get_t xstats_get;
824         /**< Get extended device statistics. */
825         eventdev_xstats_get_names_t xstats_get_names;
826         /**< Get names of extended stats. */
827         eventdev_xstats_get_by_name xstats_get_by_name;
828         /**< Get one value by name. */
829         eventdev_xstats_reset_t xstats_reset;
830         /**< Reset the statistics values in xstats. */
831
832         eventdev_eth_rx_adapter_caps_get_t eth_rx_adapter_caps_get;
833         /**< Get ethernet Rx adapter capabilities */
834         eventdev_eth_rx_adapter_queue_add_t eth_rx_adapter_queue_add;
835         /**< Add Rx queues to ethernet Rx adapter */
836         eventdev_eth_rx_adapter_queue_del_t eth_rx_adapter_queue_del;
837         /**< Delete Rx queues from ethernet Rx adapter */
838         eventdev_eth_rx_adapter_start_t eth_rx_adapter_start;
839         /**< Start ethernet Rx adapter */
840         eventdev_eth_rx_adapter_stop_t eth_rx_adapter_stop;
841         /**< Stop ethernet Rx adapter */
842         eventdev_eth_rx_adapter_stats_get eth_rx_adapter_stats_get;
843         /**< Get ethernet Rx stats */
844         eventdev_eth_rx_adapter_stats_reset eth_rx_adapter_stats_reset;
845         /**< Reset ethernet Rx stats */
846
847         eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
848         /**< Get timer adapter capabilities */
849
850         eventdev_crypto_adapter_caps_get_t crypto_adapter_caps_get;
851         /**< Get crypto adapter capabilities */
852         eventdev_crypto_adapter_queue_pair_add_t crypto_adapter_queue_pair_add;
853         /**< Add queue pair to crypto adapter */
854         eventdev_crypto_adapter_queue_pair_del_t crypto_adapter_queue_pair_del;
855         /**< Delete queue pair from crypto adapter */
856         eventdev_crypto_adapter_start_t crypto_adapter_start;
857         /**< Start crypto adapter */
858         eventdev_crypto_adapter_stop_t crypto_adapter_stop;
859         /**< Stop crypto adapter */
860         eventdev_crypto_adapter_stats_get crypto_adapter_stats_get;
861         /**< Get crypto stats */
862         eventdev_crypto_adapter_stats_reset crypto_adapter_stats_reset;
863         /**< Reset crypto stats */
864
865         eventdev_selftest dev_selftest;
866         /**< Start eventdev Selftest */
867
868         eventdev_stop_flush_t dev_stop_flush;
869         /**< User-provided event flush function */
870 };
871
872 /**
873  * Allocates a new eventdev slot for an event device and returns the pointer
874  * to that slot for the driver to use.
875  *
876  * @param name
877  *   Unique identifier name for each device
878  * @param socket_id
879  *   Socket to allocate resources on.
880  * @return
881  *   - Slot in the rte_dev_devices array for a new device;
882  */
883 struct rte_eventdev *
884 rte_event_pmd_allocate(const char *name, int socket_id);
885
886 /**
887  * Release the specified eventdev device.
888  *
889  * @param eventdev
890  * The *eventdev* pointer is the address of the *rte_eventdev* structure.
891  * @return
892  *   - 0 on success, negative on error
893  */
894 int
895 rte_event_pmd_release(struct rte_eventdev *eventdev);
896
897 #ifdef __cplusplus
898 }
899 #endif
900
901 #endif /* _RTE_EVENTDEV_PMD_H_ */