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