compress/mlx5: support out-of-space status
[dpdk.git] / lib / eventdev / 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 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 /** @file
13  * RTE Event PMD APIs
14  *
15  * @note
16  * These API are from event PMD only and user applications should not call
17  * them directly.
18  */
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 "event_timer_adapter_pmd.h"
32 #include "rte_eventdev.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          (RTE_EVENT_ETH_RX_ADAPTER_CAP_EVENT_VECTOR))
76
77 #define RTE_EVENT_CRYPTO_ADAPTER_SW_CAP \
78                 RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA
79
80 /**< Ethernet Rx adapter cap to return If the packet transfers from
81  * the ethdev to eventdev use a SW service function
82  */
83
84 #define RTE_EVENTDEV_DETACHED  (0)
85 #define RTE_EVENTDEV_ATTACHED  (1)
86
87 #define RTE_EVENTDEV_NAME_MAX_LEN (64)
88 /**< @internal Max length of name of event PMD */
89
90 struct rte_eth_dev;
91
92 /** Global structure used for maintaining state of allocated event devices */
93 struct rte_eventdev_global {
94         uint8_t nb_devs;        /**< Number of devices found */
95 };
96
97 /**
98  * @internal
99  * The data part, with no function pointers, associated with each device.
100  *
101  * This structure is safe to place in shared memory to be common among
102  * different processes in a multi-process configuration.
103  */
104 struct rte_eventdev_data {
105         int socket_id;
106         /**< Socket ID where memory is allocated */
107         uint8_t dev_id;
108         /**< Device ID for this instance */
109         uint8_t nb_queues;
110         /**< Number of event queues. */
111         uint8_t nb_ports;
112         /**< Number of event ports. */
113         void *ports[RTE_EVENT_MAX_PORTS_PER_DEV];
114         /**< Array of pointers to ports. */
115         struct rte_event_port_conf ports_cfg[RTE_EVENT_MAX_PORTS_PER_DEV];
116         /**< Array of port configuration structures. */
117         struct rte_event_queue_conf queues_cfg[RTE_EVENT_MAX_QUEUES_PER_DEV];
118         /**< Array of queue configuration structures. */
119         uint16_t links_map[RTE_EVENT_MAX_PORTS_PER_DEV *
120                            RTE_EVENT_MAX_QUEUES_PER_DEV];
121         /**< Memory to store queues to port connections. */
122         void *dev_private;
123         /**< PMD-specific private data */
124         uint32_t event_dev_cap;
125         /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/
126         struct rte_event_dev_config dev_conf;
127         /**< Configuration applied to device. */
128         uint8_t service_inited;
129         /* Service initialization state */
130         uint32_t service_id;
131         /* Service ID*/
132         void *dev_stop_flush_arg;
133         /**< User-provided argument for event flush function */
134
135         RTE_STD_C11
136         uint8_t dev_started : 1;
137         /**< Device state: STARTED(1)/STOPPED(0) */
138
139         char name[RTE_EVENTDEV_NAME_MAX_LEN];
140         /**< Unique identifier name */
141
142         uint64_t reserved_64s[4]; /**< Reserved for future fields */
143         void *reserved_ptrs[4];   /**< Reserved for future fields */
144 } __rte_cache_aligned;
145
146 /** @internal The data structure associated with each event device. */
147 struct rte_eventdev {
148         struct rte_eventdev_data *data;
149         /**< Pointer to device data */
150         struct eventdev_ops *dev_ops;
151         /**< Functions exported by PMD */
152         struct rte_device *dev;
153         /**< Device info. supplied by probing */
154
155         RTE_STD_C11
156         uint8_t attached : 1;
157         /**< Flag indicating the device is attached */
158
159         event_enqueue_t enqueue;
160         /**< Pointer to PMD enqueue function. */
161         event_enqueue_burst_t enqueue_burst;
162         /**< Pointer to PMD enqueue burst function. */
163         event_enqueue_burst_t enqueue_new_burst;
164         /**< Pointer to PMD enqueue burst function(op new variant) */
165         event_enqueue_burst_t enqueue_forward_burst;
166         /**< Pointer to PMD enqueue burst function(op forward variant) */
167         event_dequeue_t dequeue;
168         /**< Pointer to PMD dequeue function. */
169         event_dequeue_burst_t dequeue_burst;
170         /**< Pointer to PMD dequeue burst function. */
171         event_maintain_t maintain;
172         /**< Pointer to PMD port maintenance function. */
173         event_tx_adapter_enqueue_t txa_enqueue_same_dest;
174         /**< Pointer to PMD eth Tx adapter burst enqueue function with
175          * events destined to same Eth port & Tx queue.
176          */
177         event_tx_adapter_enqueue_t txa_enqueue;
178         /**< Pointer to PMD eth Tx adapter enqueue function. */
179         event_crypto_adapter_enqueue_t ca_enqueue;
180
181         uint64_t reserved_64s[4]; /**< Reserved for future fields */
182         void *reserved_ptrs[3];   /**< Reserved for future fields */
183 } __rte_cache_aligned;
184
185 extern struct rte_eventdev *rte_eventdevs;
186 /** @internal The pool of rte_eventdev structures. */
187
188 /**
189  * Get the rte_eventdev structure device pointer for the named device.
190  *
191  * @param name
192  *   device name to select the device structure.
193  *
194  * @return
195  *   - The rte_eventdev structure pointer for the given device ID.
196  */
197 __rte_internal
198 static inline struct rte_eventdev *
199 rte_event_pmd_get_named_dev(const char *name)
200 {
201         struct rte_eventdev *dev;
202         unsigned int i;
203
204         if (name == NULL)
205                 return NULL;
206
207         for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
208                 dev = &rte_eventdevs[i];
209                 if ((dev->attached == RTE_EVENTDEV_ATTACHED) &&
210                                 (strcmp(dev->data->name, name) == 0))
211                         return dev;
212         }
213
214         return NULL;
215 }
216
217 /**
218  * Validate if the event device index is valid attached event device.
219  *
220  * @param dev_id
221  *   Event device index.
222  *
223  * @return
224  *   - If the device index is valid (1) or not (0).
225  */
226 __rte_internal
227 static inline unsigned
228 rte_event_pmd_is_valid_dev(uint8_t dev_id)
229 {
230         struct rte_eventdev *dev;
231
232         if (dev_id >= RTE_EVENT_MAX_DEVS)
233                 return 0;
234
235         dev = &rte_eventdevs[dev_id];
236         if (dev->attached != RTE_EVENTDEV_ATTACHED)
237                 return 0;
238         else
239                 return 1;
240 }
241
242 /**
243  * Definitions of all functions exported by a driver through the
244  * generic structure of type *event_dev_ops* supplied in the
245  * *rte_eventdev* structure associated with a device.
246  */
247
248 /**
249  * Get device information of a device.
250  *
251  * @param dev
252  *   Event device pointer
253  * @param dev_info
254  *   Event device information structure
255  */
256 typedef void (*eventdev_info_get_t)(struct rte_eventdev *dev,
257                 struct rte_event_dev_info *dev_info);
258
259 /**
260  * Configure a device.
261  *
262  * @param dev
263  *   Event device pointer
264  *
265  * @return
266  *   Returns 0 on success
267  */
268 typedef int (*eventdev_configure_t)(const struct rte_eventdev *dev);
269
270 /**
271  * Start a configured device.
272  *
273  * @param dev
274  *   Event device pointer
275  *
276  * @return
277  *   Returns 0 on success
278  */
279 typedef int (*eventdev_start_t)(struct rte_eventdev *dev);
280
281 /**
282  * Stop a configured device.
283  *
284  * @param dev
285  *   Event device pointer
286  */
287 typedef void (*eventdev_stop_t)(struct rte_eventdev *dev);
288
289 /**
290  * Close a configured device.
291  *
292  * @param dev
293  *   Event device pointer
294  *
295  * @return
296  * - 0 on success
297  * - (-EAGAIN) if can't close as device is busy
298  */
299 typedef int (*eventdev_close_t)(struct rte_eventdev *dev);
300
301 /**
302  * Retrieve the default event queue configuration.
303  *
304  * @param dev
305  *   Event device pointer
306  * @param queue_id
307  *   Event queue index
308  * @param[out] queue_conf
309  *   Event queue configuration structure
310  *
311  */
312 typedef void (*eventdev_queue_default_conf_get_t)(struct rte_eventdev *dev,
313                 uint8_t queue_id, struct rte_event_queue_conf *queue_conf);
314
315 /**
316  * Setup an event queue.
317  *
318  * @param dev
319  *   Event device pointer
320  * @param queue_id
321  *   Event queue index
322  * @param queue_conf
323  *   Event queue configuration structure
324  *
325  * @return
326  *   Returns 0 on success.
327  */
328 typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
329                 uint8_t queue_id,
330                 const struct rte_event_queue_conf *queue_conf);
331
332 /**
333  * Release resources allocated by given event queue.
334  *
335  * @param dev
336  *   Event device pointer
337  * @param queue_id
338  *   Event queue index
339  *
340  */
341 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
342                 uint8_t queue_id);
343
344 /**
345  * Retrieve the default event port configuration.
346  *
347  * @param dev
348  *   Event device pointer
349  * @param port_id
350  *   Event port index
351  * @param[out] port_conf
352  *   Event port configuration structure
353  *
354  */
355 typedef void (*eventdev_port_default_conf_get_t)(struct rte_eventdev *dev,
356                 uint8_t port_id, struct rte_event_port_conf *port_conf);
357
358 /**
359  * Setup an event port.
360  *
361  * @param dev
362  *   Event device pointer
363  * @param port_id
364  *   Event port index
365  * @param port_conf
366  *   Event port configuration structure
367  *
368  * @return
369  *   Returns 0 on success.
370  */
371 typedef int (*eventdev_port_setup_t)(struct rte_eventdev *dev,
372                 uint8_t port_id,
373                 const struct rte_event_port_conf *port_conf);
374
375 /**
376  * Release memory resources allocated by given event port.
377  *
378  * @param port
379  *   Event port pointer
380  *
381  */
382 typedef void (*eventdev_port_release_t)(void *port);
383
384 /**
385  * Link multiple source event queues to destination event port.
386  *
387  * @param dev
388  *   Event device pointer
389  * @param port
390  *   Event port pointer
391  * @param queues
392  *   Points to an array of *nb_links* event queues to be linked
393  *   to the event port.
394  * @param priorities
395  *   Points to an array of *nb_links* service priorities associated with each
396  *   event queue link to event port.
397  * @param nb_links
398  *   The number of links to establish
399  *
400  * @return
401  *   Returns 0 on success.
402  *
403  */
404 typedef int (*eventdev_port_link_t)(struct rte_eventdev *dev, void *port,
405                 const uint8_t queues[], const uint8_t priorities[],
406                 uint16_t nb_links);
407
408 /**
409  * Unlink multiple source event queues from destination event port.
410  *
411  * @param dev
412  *   Event device pointer
413  * @param port
414  *   Event port pointer
415  * @param queues
416  *   An array of *nb_unlinks* event queues to be unlinked from the event port.
417  * @param nb_unlinks
418  *   The number of unlinks to establish
419  *
420  * @return
421  *   Returns 0 on success.
422  *
423  */
424 typedef int (*eventdev_port_unlink_t)(struct rte_eventdev *dev, void *port,
425                 uint8_t queues[], uint16_t nb_unlinks);
426
427 /**
428  * Unlinks in progress. Returns number of unlinks that the PMD is currently
429  * performing, but have not yet been completed.
430  *
431  * @param dev
432  *   Event device pointer
433  *
434  * @param port
435  *   Event port pointer
436  *
437  * @return
438  *   Returns the number of in-progress unlinks. Zero is returned if none are
439  *   in progress.
440  */
441 typedef int (*eventdev_port_unlinks_in_progress_t)(struct rte_eventdev *dev,
442                 void *port);
443
444 /**
445  * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue()
446  *
447  * @param dev
448  *   Event device pointer
449  * @param ns
450  *   Wait time in nanosecond
451  * @param[out] timeout_ticks
452  *   Value for the *timeout_ticks* parameter in rte_event_dequeue() function
453  *
454  * @return
455  *   Returns 0 on success.
456  *
457  */
458 typedef int (*eventdev_dequeue_timeout_ticks_t)(struct rte_eventdev *dev,
459                 uint64_t ns, uint64_t *timeout_ticks);
460
461 /**
462  * Dump internal information
463  *
464  * @param dev
465  *   Event device pointer
466  * @param f
467  *   A pointer to a file for output
468  *
469  */
470 typedef void (*eventdev_dump_t)(struct rte_eventdev *dev, FILE *f);
471
472 /**
473  * Retrieve a set of statistics from device
474  *
475  * @param dev
476  *   Event device pointer
477  * @param mode
478  *   Level (device, port or queue)
479  * @param queue_port_id
480  *   Queue or port number depending on mode
481  * @param ids
482  *   The stat ids to retrieve
483  * @param values
484  *   The returned stat values
485  * @param n
486  *   The number of id values and entries in the values array
487  * @return
488  *   The number of stat values successfully filled into the values array
489  */
490 typedef int (*eventdev_xstats_get_t)(const struct rte_eventdev *dev,
491                 enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
492                 const unsigned int ids[], uint64_t values[], unsigned int n);
493
494 /**
495  * Resets the statistic values in xstats for the device, based on mode.
496  */
497 typedef int (*eventdev_xstats_reset_t)(struct rte_eventdev *dev,
498                 enum rte_event_dev_xstats_mode mode,
499                 int16_t queue_port_id,
500                 const uint32_t ids[],
501                 uint32_t nb_ids);
502
503 /**
504  * Get names of extended stats of an event device
505  *
506  * @param dev
507  *   Event device pointer
508  * @param mode
509  *   Level (device, port or queue)
510  * @param queue_port_id
511  *   Queue or port number depending on mode
512  * @param xstats_names
513  *   Array of name values to be filled in
514  * @param ids
515  *   The stat ids to retrieve
516  * @param size
517  *   Number of values in the xstats_names array
518  * @return
519  *   When size >= the number of stats, return the number of stat values filled
520  *   into the array.
521  *   When size < the number of available stats, return the number of stats
522  *   values, and do not fill in any data into xstats_names.
523  */
524 typedef int (*eventdev_xstats_get_names_t)(const struct rte_eventdev *dev,
525                 enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
526                 struct rte_event_dev_xstats_name *xstats_names,
527                 unsigned int *ids, unsigned int size);
528
529 /**
530  * Get value of one stats and optionally return its id
531  *
532  * @param dev
533  *   Event device pointer
534  * @param name
535  *   The name of the stat to retrieve
536  * @param id
537  *   Pointer to an unsigned int where we store the stat-id for future reference.
538  *   This pointer may be null if the id is not required.
539  * @return
540  *   The value of the stat, or (uint64_t)-1 if the stat is not found.
541  *   If the stat is not found, the id value will be returned as (unsigned)-1,
542  *   if id pointer is non-NULL
543  */
544 typedef uint64_t (*eventdev_xstats_get_by_name)(const struct rte_eventdev *dev,
545                 const char *name, unsigned int *id);
546
547
548 /**
549  * Retrieve the event device's ethdev Rx adapter capabilities for the
550  * specified ethernet port
551  *
552  * @param dev
553  *   Event device pointer
554  *
555  * @param eth_dev
556  *   Ethernet device pointer
557  *
558  * @param[out] caps
559  *   A pointer to memory filled with Rx event adapter capabilities.
560  *
561  * @return
562  *   - 0: Success, driver provides Rx event adapter capabilities for the
563  *      ethernet device.
564  *   - <0: Error code returned by the driver function.
565  *
566  */
567 typedef int (*eventdev_eth_rx_adapter_caps_get_t)
568                                         (const struct rte_eventdev *dev,
569                                         const struct rte_eth_dev *eth_dev,
570                                         uint32_t *caps);
571
572 struct rte_event_eth_rx_adapter_queue_conf;
573
574 /**
575  * Retrieve the event device's timer adapter capabilities, as well as the ops
576  * structure that an event timer adapter should call through to enter the
577  * driver
578  *
579  * @param dev
580  *   Event device pointer
581  *
582  * @param flags
583  *   Flags that can be used to determine how to select an event timer
584  *   adapter ops structure
585  *
586  * @param[out] caps
587  *   A pointer to memory filled with Rx event adapter capabilities.
588  *
589  * @param[out] ops
590  *   A pointer to the ops pointer to set with the address of the desired ops
591  *   structure
592  *
593  * @return
594  *   - 0: Success, driver provides Rx event adapter capabilities for the
595  *      ethernet device.
596  *   - <0: Error code returned by the driver function.
597  *
598  */
599 typedef int (*eventdev_timer_adapter_caps_get_t)(
600         const struct rte_eventdev *dev, uint64_t flags, uint32_t *caps,
601         const struct event_timer_adapter_ops **ops);
602
603 /**
604  * Add ethernet Rx queues to event device. This callback is invoked if
605  * the caps returned from rte_eventdev_eth_rx_adapter_caps_get(, eth_port_id)
606  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set.
607  *
608  * @param dev
609  *   Event device pointer
610  *
611  * @param eth_dev
612  *   Ethernet device pointer
613  *
614  * @param rx_queue_id
615  *   Ethernet device receive queue index
616  *
617  * @param queue_conf
618  *  Additional configuration structure
619
620  * @return
621  *   - 0: Success, ethernet receive queue added successfully.
622  *   - <0: Error code returned by the driver function.
623  *
624  */
625 typedef int (*eventdev_eth_rx_adapter_queue_add_t)(
626                 const struct rte_eventdev *dev,
627                 const struct rte_eth_dev *eth_dev,
628                 int32_t rx_queue_id,
629                 const struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
630
631 /**
632  * Delete ethernet Rx queues from event device. This callback is invoked if
633  * the caps returned from eventdev_eth_rx_adapter_caps_get(, eth_port_id)
634  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set.
635  *
636  * @param dev
637  *   Event device pointer
638  *
639  * @param eth_dev
640  *   Ethernet device pointer
641  *
642  * @param rx_queue_id
643  *   Ethernet device receive queue index
644  *
645  * @return
646  *   - 0: Success, ethernet receive queue deleted successfully.
647  *   - <0: Error code returned by the driver function.
648  *
649  */
650 typedef int (*eventdev_eth_rx_adapter_queue_del_t)
651                                         (const struct rte_eventdev *dev,
652                                         const struct rte_eth_dev *eth_dev,
653                                         int32_t rx_queue_id);
654
655 /**
656  * Retrieve Rx adapter queue config information for the specified
657  * rx queue ID.
658  *
659  * @param dev
660  *  Event device pointer
661  *
662  * @param eth_dev
663  *  Ethernet device pointer
664  *
665  * @param rx_queue_id
666  *  Ethernet device receive queue index.
667  *
668  * @param[out] queue_conf
669  *  Pointer to rte_event_eth_rx_adapter_queue_conf structure
670  *
671  * @return
672  *  - 0: Success
673  *  - <0: Error code on failure.
674  */
675 typedef int (*eventdev_eth_rx_adapter_queue_conf_get_t)
676                         (const struct rte_eventdev *dev,
677                         const struct rte_eth_dev *eth_dev,
678                         uint16_t rx_queue_id,
679                         struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
680
681 /**
682  * Start ethernet Rx adapter. This callback is invoked if
683  * the caps returned from eventdev_eth_rx_adapter_caps_get(.., eth_port_id)
684  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues
685  * from eth_port_id have been added to the event device.
686  *
687  * @param dev
688  *   Event device pointer
689  *
690  * @param eth_dev
691  *   Ethernet device pointer
692  *
693  * @return
694  *   - 0: Success, ethernet Rx adapter started successfully.
695  *   - <0: Error code returned by the driver function.
696  */
697 typedef int (*eventdev_eth_rx_adapter_start_t)
698                                         (const struct rte_eventdev *dev,
699                                         const struct rte_eth_dev *eth_dev);
700
701 /**
702  * Stop ethernet Rx adapter. This callback is invoked if
703  * the caps returned from eventdev_eth_rx_adapter_caps_get(..,eth_port_id)
704  * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues
705  * from eth_port_id have been added to the event device.
706  *
707  * @param dev
708  *   Event device pointer
709  *
710  * @param eth_dev
711  *   Ethernet device pointer
712  *
713  * @return
714  *   - 0: Success, ethernet Rx adapter stopped successfully.
715  *   - <0: Error code returned by the driver function.
716  */
717 typedef int (*eventdev_eth_rx_adapter_stop_t)
718                                         (const struct rte_eventdev *dev,
719                                         const struct rte_eth_dev *eth_dev);
720
721 struct rte_event_eth_rx_adapter_stats;
722
723 /**
724  * Retrieve ethernet Rx adapter statistics.
725  *
726  * @param dev
727  *   Event device pointer
728  *
729  * @param eth_dev
730  *   Ethernet device pointer
731  *
732  * @param[out] stats
733  *   Pointer to stats structure
734  *
735  * @return
736  *   Return 0 on success.
737  */
738
739 typedef int (*eventdev_eth_rx_adapter_stats_get)
740                         (const struct rte_eventdev *dev,
741                         const struct rte_eth_dev *eth_dev,
742                         struct rte_event_eth_rx_adapter_stats *stats);
743 /**
744  * Reset ethernet Rx adapter statistics.
745  *
746  * @param dev
747  *   Event device pointer
748  *
749  * @param eth_dev
750  *   Ethernet device pointer
751  *
752  * @return
753  *   Return 0 on success.
754  */
755 typedef int (*eventdev_eth_rx_adapter_stats_reset)
756                         (const struct rte_eventdev *dev,
757                         const struct rte_eth_dev *eth_dev);
758
759 struct rte_event_eth_rx_adapter_queue_stats;
760
761 /**
762  * Retrieve ethernet Rx adapter queue statistics.
763  *
764  * @param dev
765  *   Event device pointer
766  *
767  * @param eth_dev
768  *   Ethernet device pointer
769  *
770  * @param rx_queue_id
771  *  Ethernet device receive queue index.
772  *
773  * @param[out] q_stats
774  *   Pointer to queue stats structure
775  *
776  * @return
777  *   Return 0 on success.
778  */
779 typedef int (*eventdev_eth_rx_adapter_q_stats_get)
780                         (const struct rte_eventdev *dev,
781                          const struct rte_eth_dev *eth_dev,
782                          uint16_t rx_queue_id,
783                          struct rte_event_eth_rx_adapter_queue_stats *q_stats);
784
785 /**
786  * Reset ethernet Rx adapter queue statistics.
787  *
788  * @param dev
789  *   Event device pointer
790  *
791  * @param eth_dev
792  *   Ethernet device pointer
793  *
794  * @param rx_queue_id
795  *  Ethernet device receive queue index.
796  *
797  * @return
798  *   Return 0 on success.
799  */
800 typedef int (*eventdev_eth_rx_adapter_q_stats_reset)
801                         (const struct rte_eventdev *dev,
802                          const struct rte_eth_dev *eth_dev,
803                          uint16_t rx_queue_id);
804
805 /**
806  * Start eventdev selftest.
807  *
808  * @return
809  *   Return 0 on success.
810  */
811 typedef int (*eventdev_selftest)(void);
812
813 struct rte_event_eth_rx_adapter_vector_limits;
814 /**
815  * Get event vector limits for a given event, ethernet device pair.
816  *
817  * @param dev
818  *   Event device pointer
819  *
820  * @param eth_dev
821  *   Ethernet device pointer
822  *
823  * @param[out] limits
824  *   Pointer to the limits structure to be filled.
825  *
826  * @return
827  *   - 0: Success.
828  *   - <0: Error code returned by the driver function.
829  */
830 typedef int (*eventdev_eth_rx_adapter_vector_limits_get_t)(
831         const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
832         struct rte_event_eth_rx_adapter_vector_limits *limits);
833
834 typedef uint32_t rte_event_pmd_selftest_seqn_t;
835 extern int rte_event_pmd_selftest_seqn_dynfield_offset;
836
837 /**
838  * Read test sequence number from mbuf.
839  *
840  * @param mbuf Structure to read from.
841  * @return pointer to test sequence number.
842  */
843 __rte_internal
844 static inline rte_event_pmd_selftest_seqn_t *
845 rte_event_pmd_selftest_seqn(struct rte_mbuf *mbuf)
846 {
847         return RTE_MBUF_DYNFIELD(mbuf,
848                 rte_event_pmd_selftest_seqn_dynfield_offset,
849                 rte_event_pmd_selftest_seqn_t *);
850 }
851
852 struct rte_cryptodev;
853
854 /**
855  * This API may change without prior notice
856  *
857  * Retrieve the event device's crypto adapter capabilities for the
858  * specified cryptodev
859  *
860  * @param dev
861  *   Event device pointer
862  *
863  * @param cdev
864  *   cryptodev pointer
865  *
866  * @param[out] caps
867  *   A pointer to memory filled with event adapter capabilities.
868  *   It is expected to be pre-allocated & initialized by caller.
869  *
870  * @return
871  *   - 0: Success, driver provides event adapter capabilities for the
872  *      cryptodev.
873  *   - <0: Error code returned by the driver function.
874  *
875  */
876 typedef int (*eventdev_crypto_adapter_caps_get_t)
877                                         (const struct rte_eventdev *dev,
878                                          const struct rte_cryptodev *cdev,
879                                          uint32_t *caps);
880
881 /**
882  * This API may change without prior notice
883  *
884  * Add crypto queue pair to event device. This callback is invoked if
885  * the caps returned from rte_event_crypto_adapter_caps_get(, cdev_id)
886  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set.
887  *
888  * @param dev
889  *   Event device pointer
890  *
891  * @param cdev
892  *   cryptodev pointer
893  *
894  * @param queue_pair_id
895  *   cryptodev queue pair identifier.
896  *
897  * @param event
898  *  Event information required for binding cryptodev queue pair to event queue.
899  *  This structure will have a valid value for only those HW PMDs supporting
900  *  @see RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND capability.
901  *
902  * @return
903  *   - 0: Success, cryptodev queue pair added successfully.
904  *   - <0: Error code returned by the driver function.
905  *
906  */
907 typedef int (*eventdev_crypto_adapter_queue_pair_add_t)
908                         (const struct rte_eventdev *dev,
909                          const struct rte_cryptodev *cdev,
910                          int32_t queue_pair_id,
911                          const struct rte_event *event);
912
913
914 /**
915  * This API may change without prior notice
916  *
917  * Delete crypto queue pair to event device. This callback is invoked if
918  * the caps returned from rte_event_crypto_adapter_caps_get(, cdev_id)
919  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set.
920  *
921  * @param dev
922  *   Event device pointer
923  *
924  * @param cdev
925  *   cryptodev pointer
926  *
927  * @param queue_pair_id
928  *   cryptodev queue pair identifier.
929  *
930  * @return
931  *   - 0: Success, cryptodev queue pair deleted successfully.
932  *   - <0: Error code returned by the driver function.
933  *
934  */
935 typedef int (*eventdev_crypto_adapter_queue_pair_del_t)
936                                         (const struct rte_eventdev *dev,
937                                          const struct rte_cryptodev *cdev,
938                                          int32_t queue_pair_id);
939
940 /**
941  * Start crypto adapter. This callback is invoked if
942  * the caps returned from rte_event_crypto_adapter_caps_get(.., cdev_id)
943  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs
944  * from cdev_id have been added to the event device.
945  *
946  * @param dev
947  *   Event device pointer
948  *
949  * @param cdev
950  *   Crypto device pointer
951  *
952  * @return
953  *   - 0: Success, crypto adapter started successfully.
954  *   - <0: Error code returned by the driver function.
955  */
956 typedef int (*eventdev_crypto_adapter_start_t)
957                                         (const struct rte_eventdev *dev,
958                                          const struct rte_cryptodev *cdev);
959
960 /**
961  * Stop crypto adapter. This callback is invoked if
962  * the caps returned from rte_event_crypto_adapter_caps_get(.., cdev_id)
963  * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs
964  * from cdev_id have been added to the event device.
965  *
966  * @param dev
967  *   Event device pointer
968  *
969  * @param cdev
970  *   Crypto device pointer
971  *
972  * @return
973  *   - 0: Success, crypto adapter stopped successfully.
974  *   - <0: Error code returned by the driver function.
975  */
976 typedef int (*eventdev_crypto_adapter_stop_t)
977                                         (const struct rte_eventdev *dev,
978                                          const struct rte_cryptodev *cdev);
979
980 struct rte_event_crypto_adapter_stats;
981
982 /**
983  * Retrieve crypto adapter statistics.
984  *
985  * @param dev
986  *   Event device pointer
987  *
988  * @param cdev
989  *   Crypto device pointer
990  *
991  * @param[out] stats
992  *   Pointer to stats structure
993  *
994  * @return
995  *   Return 0 on success.
996  */
997
998 typedef int (*eventdev_crypto_adapter_stats_get)
999                         (const struct rte_eventdev *dev,
1000                          const struct rte_cryptodev *cdev,
1001                          struct rte_event_crypto_adapter_stats *stats);
1002
1003 /**
1004  * Reset crypto adapter statistics.
1005  *
1006  * @param dev
1007  *   Event device pointer
1008  *
1009  * @param cdev
1010  *   Crypto device pointer
1011  *
1012  * @return
1013  *   Return 0 on success.
1014  */
1015
1016 typedef int (*eventdev_crypto_adapter_stats_reset)
1017                         (const struct rte_eventdev *dev,
1018                          const struct rte_cryptodev *cdev);
1019
1020 /**
1021  * Retrieve the event device's eth Tx adapter capabilities.
1022  *
1023  * @param dev
1024  *   Event device pointer
1025  *
1026  * @param eth_dev
1027  *   Ethernet device pointer
1028  *
1029  * @param[out] caps
1030  *   A pointer to memory filled with eth Tx adapter capabilities.
1031  *
1032  * @return
1033  *   - 0: Success, driver provides eth Tx adapter capabilities
1034  *   - <0: Error code returned by the driver function.
1035  *
1036  */
1037 typedef int (*eventdev_eth_tx_adapter_caps_get_t)
1038                                         (const struct rte_eventdev *dev,
1039                                         const struct rte_eth_dev *eth_dev,
1040                                         uint32_t *caps);
1041
1042 /**
1043  * Create adapter callback.
1044  *
1045  * @param id
1046  *   Adapter identifier
1047  *
1048  * @param dev
1049  *   Event device pointer
1050  *
1051  * @return
1052  *   - 0: Success.
1053  *   - <0: Error code on failure.
1054  */
1055 typedef int (*eventdev_eth_tx_adapter_create_t)(uint8_t id,
1056                                         const struct rte_eventdev *dev);
1057
1058 /**
1059  * Free adapter callback.
1060  *
1061  * @param id
1062  *   Adapter identifier
1063  *
1064  * @param dev
1065  *   Event device pointer
1066  *
1067  * @return
1068  *   - 0: Success.
1069  *   - <0: Error code on failure.
1070  */
1071 typedef int (*eventdev_eth_tx_adapter_free_t)(uint8_t id,
1072                                         const struct rte_eventdev *dev);
1073
1074 /**
1075  * Add a Tx queue to the adapter.
1076  * A queue value of -1 is used to indicate all
1077  * queues within the device.
1078  *
1079  * @param id
1080  *   Adapter identifier
1081  *
1082  * @param dev
1083  *   Event device pointer
1084  *
1085  * @param eth_dev
1086  *   Ethernet device pointer
1087  *
1088  * @param tx_queue_id
1089  *   Transmit queue index
1090  *
1091  * @return
1092  *   - 0: Success.
1093  *   - <0: Error code on failure.
1094  */
1095 typedef int (*eventdev_eth_tx_adapter_queue_add_t)(
1096                                         uint8_t id,
1097                                         const struct rte_eventdev *dev,
1098                                         const struct rte_eth_dev *eth_dev,
1099                                         int32_t tx_queue_id);
1100
1101 /**
1102  * Delete a Tx queue from the adapter.
1103  * A queue value of -1 is used to indicate all
1104  * queues within the device, that have been added to this
1105  * adapter.
1106  *
1107  * @param id
1108  *   Adapter identifier
1109  *
1110  * @param dev
1111  *   Event device pointer
1112  *
1113  * @param eth_dev
1114  *   Ethernet device pointer
1115  *
1116  * @param tx_queue_id
1117  *   Transmit queue index
1118  *
1119  * @return
1120  *  - 0: Success, Queues deleted successfully.
1121  *  - <0: Error code on failure.
1122  */
1123 typedef int (*eventdev_eth_tx_adapter_queue_del_t)(
1124                                         uint8_t id,
1125                                         const struct rte_eventdev *dev,
1126                                         const struct rte_eth_dev *eth_dev,
1127                                         int32_t tx_queue_id);
1128
1129 /**
1130  * Start the adapter.
1131  *
1132  * @param id
1133  *   Adapter identifier
1134  *
1135  * @param dev
1136  *   Event device pointer
1137  *
1138  * @return
1139  *  - 0: Success, Adapter started correctly.
1140  *  - <0: Error code on failure.
1141  */
1142 typedef int (*eventdev_eth_tx_adapter_start_t)(uint8_t id,
1143                                         const struct rte_eventdev *dev);
1144
1145 /**
1146  * Stop the adapter.
1147  *
1148  * @param id
1149  *  Adapter identifier
1150  *
1151  * @param dev
1152  *   Event device pointer
1153  *
1154  * @return
1155  *  - 0: Success.
1156  *  - <0: Error code on failure.
1157  */
1158 typedef int (*eventdev_eth_tx_adapter_stop_t)(uint8_t id,
1159                                         const struct rte_eventdev *dev);
1160
1161 struct rte_event_eth_tx_adapter_stats;
1162
1163 /**
1164  * Retrieve statistics for an adapter
1165  *
1166  * @param id
1167  *  Adapter identifier
1168  *
1169  * @param dev
1170  *   Event device pointer
1171  *
1172  * @param [out] stats
1173  *  A pointer to structure used to retrieve statistics for an adapter
1174  *
1175  * @return
1176  *  - 0: Success, statistics retrieved successfully.
1177  *  - <0: Error code on failure.
1178  */
1179 typedef int (*eventdev_eth_tx_adapter_stats_get_t)(
1180                                 uint8_t id,
1181                                 const struct rte_eventdev *dev,
1182                                 struct rte_event_eth_tx_adapter_stats *stats);
1183
1184 /**
1185  * Reset statistics for an adapter
1186  *
1187  * @param id
1188  *  Adapter identifier
1189  *
1190  * @param dev
1191  *   Event device pointer
1192  *
1193  * @return
1194  *  - 0: Success, statistics retrieved successfully.
1195  *  - <0: Error code on failure.
1196  */
1197 typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
1198                                         const struct rte_eventdev *dev);
1199
1200 /** Event device operations function pointer table */
1201 struct eventdev_ops {
1202         eventdev_info_get_t dev_infos_get;      /**< Get device info. */
1203         eventdev_configure_t dev_configure;     /**< Configure device. */
1204         eventdev_start_t dev_start;             /**< Start device. */
1205         eventdev_stop_t dev_stop;               /**< Stop device. */
1206         eventdev_close_t dev_close;             /**< Close device. */
1207
1208         eventdev_queue_default_conf_get_t queue_def_conf;
1209         /**< Get default queue configuration. */
1210         eventdev_queue_setup_t queue_setup;
1211         /**< Set up an event queue. */
1212         eventdev_queue_release_t queue_release;
1213         /**< Release an event queue. */
1214
1215         eventdev_port_default_conf_get_t port_def_conf;
1216         /**< Get default port configuration. */
1217         eventdev_port_setup_t port_setup;
1218         /**< Set up an event port. */
1219         eventdev_port_release_t port_release;
1220         /**< Release an event port. */
1221
1222         eventdev_port_link_t port_link;
1223         /**< Link event queues to an event port. */
1224         eventdev_port_unlink_t port_unlink;
1225         /**< Unlink event queues from an event port. */
1226         eventdev_port_unlinks_in_progress_t port_unlinks_in_progress;
1227         /**< Unlinks in progress on an event port. */
1228         eventdev_dequeue_timeout_ticks_t timeout_ticks;
1229         /**< Converts ns to *timeout_ticks* value for rte_event_dequeue() */
1230         eventdev_dump_t dump;
1231         /* Dump internal information */
1232
1233         eventdev_xstats_get_t xstats_get;
1234         /**< Get extended device statistics. */
1235         eventdev_xstats_get_names_t xstats_get_names;
1236         /**< Get names of extended stats. */
1237         eventdev_xstats_get_by_name xstats_get_by_name;
1238         /**< Get one value by name. */
1239         eventdev_xstats_reset_t xstats_reset;
1240         /**< Reset the statistics values in xstats. */
1241
1242         eventdev_eth_rx_adapter_caps_get_t eth_rx_adapter_caps_get;
1243         /**< Get ethernet Rx adapter capabilities */
1244         eventdev_eth_rx_adapter_queue_add_t eth_rx_adapter_queue_add;
1245         /**< Add Rx queues to ethernet Rx adapter */
1246         eventdev_eth_rx_adapter_queue_del_t eth_rx_adapter_queue_del;
1247         /**< Delete Rx queues from ethernet Rx adapter */
1248         eventdev_eth_rx_adapter_queue_conf_get_t eth_rx_adapter_queue_conf_get;
1249         /**< Get Rx adapter queue info */
1250         eventdev_eth_rx_adapter_start_t eth_rx_adapter_start;
1251         /**< Start ethernet Rx adapter */
1252         eventdev_eth_rx_adapter_stop_t eth_rx_adapter_stop;
1253         /**< Stop ethernet Rx adapter */
1254         eventdev_eth_rx_adapter_stats_get eth_rx_adapter_stats_get;
1255         /**< Get ethernet Rx stats */
1256         eventdev_eth_rx_adapter_stats_reset eth_rx_adapter_stats_reset;
1257         /**< Reset ethernet Rx stats */
1258         eventdev_eth_rx_adapter_vector_limits_get_t
1259                 eth_rx_adapter_vector_limits_get;
1260         /**< Get event vector limits for the Rx adapter */
1261
1262         eventdev_timer_adapter_caps_get_t timer_adapter_caps_get;
1263         /**< Get timer adapter capabilities */
1264
1265         eventdev_crypto_adapter_caps_get_t crypto_adapter_caps_get;
1266         /**< Get crypto adapter capabilities */
1267         eventdev_crypto_adapter_queue_pair_add_t crypto_adapter_queue_pair_add;
1268         /**< Add queue pair to crypto adapter */
1269         eventdev_crypto_adapter_queue_pair_del_t crypto_adapter_queue_pair_del;
1270         /**< Delete queue pair from crypto adapter */
1271         eventdev_crypto_adapter_start_t crypto_adapter_start;
1272         /**< Start crypto adapter */
1273         eventdev_crypto_adapter_stop_t crypto_adapter_stop;
1274         /**< Stop crypto adapter */
1275         eventdev_crypto_adapter_stats_get crypto_adapter_stats_get;
1276         /**< Get crypto stats */
1277         eventdev_crypto_adapter_stats_reset crypto_adapter_stats_reset;
1278         /**< Reset crypto stats */
1279
1280         eventdev_eth_rx_adapter_q_stats_get eth_rx_adapter_queue_stats_get;
1281         /**< Get ethernet Rx queue stats */
1282         eventdev_eth_rx_adapter_q_stats_reset eth_rx_adapter_queue_stats_reset;
1283         /**< Reset ethernet Rx queue stats */
1284
1285         eventdev_eth_tx_adapter_caps_get_t eth_tx_adapter_caps_get;
1286         /**< Get ethernet Tx adapter capabilities */
1287
1288         eventdev_eth_tx_adapter_create_t eth_tx_adapter_create;
1289         /**< Create adapter callback */
1290         eventdev_eth_tx_adapter_free_t eth_tx_adapter_free;
1291         /**< Free adapter callback */
1292         eventdev_eth_tx_adapter_queue_add_t eth_tx_adapter_queue_add;
1293         /**< Add Tx queues to the eth Tx adapter */
1294         eventdev_eth_tx_adapter_queue_del_t eth_tx_adapter_queue_del;
1295         /**< Delete Tx queues from the eth Tx adapter */
1296         eventdev_eth_tx_adapter_start_t eth_tx_adapter_start;
1297         /**< Start eth Tx adapter */
1298         eventdev_eth_tx_adapter_stop_t eth_tx_adapter_stop;
1299         /**< Stop eth Tx adapter */
1300         eventdev_eth_tx_adapter_stats_get_t eth_tx_adapter_stats_get;
1301         /**< Get eth Tx adapter statistics */
1302         eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset;
1303         /**< Reset eth Tx adapter statistics */
1304
1305         eventdev_selftest dev_selftest;
1306         /**< Start eventdev Selftest */
1307
1308         eventdev_stop_flush_t dev_stop_flush;
1309         /**< User-provided event flush function */
1310 };
1311
1312 /**
1313  * Allocates a new eventdev slot for an event device and returns the pointer
1314  * to that slot for the driver to use.
1315  *
1316  * @param name
1317  *   Unique identifier name for each device
1318  * @param socket_id
1319  *   Socket to allocate resources on.
1320  * @return
1321  *   - Slot in the rte_dev_devices array for a new device;
1322  */
1323 __rte_internal
1324 struct rte_eventdev *
1325 rte_event_pmd_allocate(const char *name, int socket_id);
1326
1327 /**
1328  * Release the specified eventdev device.
1329  *
1330  * @param eventdev
1331  * The *eventdev* pointer is the address of the *rte_eventdev* structure.
1332  * @return
1333  *   - 0 on success, negative on error
1334  */
1335 __rte_internal
1336 int
1337 rte_event_pmd_release(struct rte_eventdev *eventdev);
1338
1339 /**
1340  *
1341  * @internal
1342  * This is the last step of device probing.
1343  * It must be called after a port is allocated and initialized successfully.
1344  *
1345  * @param eventdev
1346  *  New event device.
1347  */
1348 __rte_internal
1349 void
1350 event_dev_probing_finish(struct rte_eventdev *eventdev);
1351
1352 /**
1353  * Reset eventdevice fastpath APIs to dummy values.
1354  *
1355  * @param fp_ops
1356  * The *fp_ops* pointer to reset.
1357  */
1358 __rte_internal
1359 void
1360 event_dev_fp_ops_reset(struct rte_event_fp_ops *fp_op);
1361
1362 /**
1363  * Set eventdevice fastpath APIs to event device values.
1364  *
1365  * @param fp_ops
1366  * The *fp_ops* pointer to set.
1367  */
1368 __rte_internal
1369 void
1370 event_dev_fp_ops_set(struct rte_event_fp_ops *fp_ops,
1371                      const struct rte_eventdev *dev);
1372
1373 #ifdef __cplusplus
1374 }
1375 #endif
1376
1377 #endif /* _RTE_EVENTDEV_PMD_H_ */