DPDK  20.11.10
rte_eventdev_pmd.h
Go to the documentation of this file.
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 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #include <string.h>
25 
26 #include <rte_common.h>
27 #include <rte_compat.h>
28 #include <rte_config.h>
29 #include <rte_dev.h>
30 #include <rte_log.h>
31 #include <rte_malloc.h>
32 #include <rte_mbuf.h>
33 #include <rte_mbuf_dyn.h>
34 
35 #include "rte_eventdev.h"
37 
38 /* Logging Macros */
39 #define RTE_EDEV_LOG_ERR(...) \
40  RTE_LOG(ERR, EVENTDEV, \
41  RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
42  __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
43 
44 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
45 #define RTE_EDEV_LOG_DEBUG(...) \
46  RTE_LOG(DEBUG, EVENTDEV, \
47  RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
48  __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
49 #else
50 #define RTE_EDEV_LOG_DEBUG(...) (void)0
51 #endif
52 
53 /* Macros to check for valid device */
54 #define RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, 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  return retval; \
58  } \
59 } while (0)
60 
61 #define RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, errno, retval) do { \
62  if (!rte_event_pmd_is_valid_dev((dev_id))) { \
63  RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
64  rte_errno = errno; \
65  return retval; \
66  } \
67 } while (0)
68 
69 #define RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id) do { \
70  if (!rte_event_pmd_is_valid_dev((dev_id))) { \
71  RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
72  return; \
73  } \
74 } while (0)
75 
76 #define RTE_EVENT_ETH_RX_ADAPTER_SW_CAP \
77  ((RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID) | \
78  (RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ))
79 
80 #define RTE_EVENT_CRYPTO_ADAPTER_SW_CAP \
81  RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA
82 
87 #define RTE_EVENTDEV_DETACHED (0)
88 #define RTE_EVENTDEV_ATTACHED (1)
89 
90 struct rte_eth_dev;
91 
94  uint8_t nb_devs;
95 };
96 
97 extern struct rte_eventdev *rte_eventdevs;
109 static inline struct rte_eventdev *
111 {
112  struct rte_eventdev *dev;
113  unsigned int i;
114 
115  if (name == NULL)
116  return NULL;
117 
118  for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
119  dev = &rte_eventdevs[i];
120  if ((dev->attached == RTE_EVENTDEV_ATTACHED) &&
121  (strcmp(dev->data->name, name) == 0))
122  return dev;
123  }
124 
125  return NULL;
126 }
127 
137 static inline unsigned
139 {
140  struct rte_eventdev *dev;
141 
142  if (dev_id >= RTE_EVENT_MAX_DEVS)
143  return 0;
144 
145  dev = &rte_eventdevs[dev_id];
146  if (dev->attached != RTE_EVENTDEV_ATTACHED)
147  return 0;
148  else
149  return 1;
150 }
151 
166 typedef void (*eventdev_info_get_t)(struct rte_eventdev *dev,
167  struct rte_event_dev_info *dev_info);
168 
178 typedef int (*eventdev_configure_t)(const struct rte_eventdev *dev);
179 
189 typedef int (*eventdev_start_t)(struct rte_eventdev *dev);
190 
197 typedef void (*eventdev_stop_t)(struct rte_eventdev *dev);
198 
209 typedef int (*eventdev_close_t)(struct rte_eventdev *dev);
210 
222 typedef void (*eventdev_queue_default_conf_get_t)(struct rte_eventdev *dev,
223  uint8_t queue_id, struct rte_event_queue_conf *queue_conf);
224 
238 typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
239  uint8_t queue_id,
240  const struct rte_event_queue_conf *queue_conf);
241 
251 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
252  uint8_t queue_id);
253 
265 typedef void (*eventdev_port_default_conf_get_t)(struct rte_eventdev *dev,
266  uint8_t port_id, struct rte_event_port_conf *port_conf);
267 
281 typedef int (*eventdev_port_setup_t)(struct rte_eventdev *dev,
282  uint8_t port_id,
283  const struct rte_event_port_conf *port_conf);
284 
292 typedef void (*eventdev_port_release_t)(void *port);
293 
314 typedef int (*eventdev_port_link_t)(struct rte_eventdev *dev, void *port,
315  const uint8_t queues[], const uint8_t priorities[],
316  uint16_t nb_links);
317 
334 typedef int (*eventdev_port_unlink_t)(struct rte_eventdev *dev, void *port,
335  uint8_t queues[], uint16_t nb_unlinks);
336 
351 typedef int (*eventdev_port_unlinks_in_progress_t)(struct rte_eventdev *dev,
352  void *port);
353 
368 typedef int (*eventdev_dequeue_timeout_ticks_t)(struct rte_eventdev *dev,
369  uint64_t ns, uint64_t *timeout_ticks);
370 
380 typedef void (*eventdev_dump_t)(struct rte_eventdev *dev, FILE *f);
381 
400 typedef int (*eventdev_xstats_get_t)(const struct rte_eventdev *dev,
401  enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
402  const unsigned int ids[], uint64_t values[], unsigned int n);
403 
407 typedef int (*eventdev_xstats_reset_t)(struct rte_eventdev *dev,
408  enum rte_event_dev_xstats_mode mode,
409  int16_t queue_port_id,
410  const uint32_t ids[],
411  uint32_t nb_ids);
412 
434 typedef int (*eventdev_xstats_get_names_t)(const struct rte_eventdev *dev,
435  enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
436  struct rte_event_dev_xstats_name *xstats_names,
437  unsigned int *ids, unsigned int size);
438 
454 typedef uint64_t (*eventdev_xstats_get_by_name)(const struct rte_eventdev *dev,
455  const char *name, unsigned int *id);
456 
457 
478  (const struct rte_eventdev *dev,
479  const struct rte_eth_dev *eth_dev,
480  uint32_t *caps);
481 
483 
510  const struct rte_eventdev *dev,
511  uint64_t flags,
512  uint32_t *caps,
513  const struct rte_event_timer_adapter_ops **ops);
514 
538  const struct rte_eventdev *dev,
539  const struct rte_eth_dev *eth_dev,
540  int32_t rx_queue_id,
541  const struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
542 
563  (const struct rte_eventdev *dev,
564  const struct rte_eth_dev *eth_dev,
565  int32_t rx_queue_id);
566 
583 typedef int (*eventdev_eth_rx_adapter_start_t)
584  (const struct rte_eventdev *dev,
585  const struct rte_eth_dev *eth_dev);
586 
603 typedef int (*eventdev_eth_rx_adapter_stop_t)
604  (const struct rte_eventdev *dev,
605  const struct rte_eth_dev *eth_dev);
606 
608 
626  (const struct rte_eventdev *dev,
627  const struct rte_eth_dev *eth_dev,
628  struct rte_event_eth_rx_adapter_stats *stats);
642  (const struct rte_eventdev *dev,
643  const struct rte_eth_dev *eth_dev);
650 typedef int (*eventdev_selftest)(void);
651 
652 typedef uint32_t rte_event_pmd_selftest_seqn_t;
653 extern int rte_event_pmd_selftest_seqn_dynfield_offset;
654 
661 __rte_internal
662 static inline rte_event_pmd_selftest_seqn_t *
664 {
665  return RTE_MBUF_DYNFIELD(mbuf,
666  rte_event_pmd_selftest_seqn_dynfield_offset,
667  rte_event_pmd_selftest_seqn_t *);
668 }
669 
670 struct rte_cryptodev;
671 
695  (const struct rte_eventdev *dev,
696  const struct rte_cryptodev *cdev,
697  uint32_t *caps);
698 
726  (const struct rte_eventdev *dev,
727  const struct rte_cryptodev *cdev,
728  int32_t queue_pair_id,
729  const struct rte_event *event);
730 
731 
754  (const struct rte_eventdev *dev,
755  const struct rte_cryptodev *cdev,
756  int32_t queue_pair_id);
757 
774 typedef int (*eventdev_crypto_adapter_start_t)
775  (const struct rte_eventdev *dev,
776  const struct rte_cryptodev *cdev);
777 
794 typedef int (*eventdev_crypto_adapter_stop_t)
795  (const struct rte_eventdev *dev,
796  const struct rte_cryptodev *cdev);
797 
799 
817  (const struct rte_eventdev *dev,
818  const struct rte_cryptodev *cdev,
819  struct rte_event_crypto_adapter_stats *stats);
820 
835  (const struct rte_eventdev *dev,
836  const struct rte_cryptodev *cdev);
837 
856  (const struct rte_eventdev *dev,
857  const struct rte_eth_dev *eth_dev,
858  uint32_t *caps);
859 
873 typedef int (*eventdev_eth_tx_adapter_create_t)(uint8_t id,
874  const struct rte_eventdev *dev);
875 
889 typedef int (*eventdev_eth_tx_adapter_free_t)(uint8_t id,
890  const struct rte_eventdev *dev);
891 
914  uint8_t id,
915  const struct rte_eventdev *dev,
916  const struct rte_eth_dev *eth_dev,
917  int32_t tx_queue_id);
918 
942  uint8_t id,
943  const struct rte_eventdev *dev,
944  const struct rte_eth_dev *eth_dev,
945  int32_t tx_queue_id);
946 
960 typedef int (*eventdev_eth_tx_adapter_start_t)(uint8_t id,
961  const struct rte_eventdev *dev);
962 
976 typedef int (*eventdev_eth_tx_adapter_stop_t)(uint8_t id,
977  const struct rte_eventdev *dev);
978 
980 
998  uint8_t id,
999  const struct rte_eventdev *dev,
1000  struct rte_event_eth_tx_adapter_stats *stats);
1001 
1015 typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id,
1016  const struct rte_eventdev *dev);
1017 
1048  eventdev_dump_t dump;
1049  /* Dump internal information */
1050 
1118 };
1119 
1131 struct rte_eventdev *
1132 rte_event_pmd_allocate(const char *name, int socket_id);
1133 
1142 int
1143 rte_event_pmd_release(struct rte_eventdev *eventdev);
1144 
1145 #ifdef __cplusplus
1146 }
1147 #endif
1148 
1149 #ifdef __cplusplus
1150 }
1151 #endif
1152 
1153 #endif /* _RTE_EVENTDEV_PMD_H_ */
eventdev_stop_t dev_stop
eventdev_port_release_t port_release
eventdev_eth_rx_adapter_stats_reset eth_rx_adapter_stats_reset
eventdev_port_default_conf_get_t port_def_conf
eventdev_configure_t dev_configure
eventdev_selftest dev_selftest
int(* eventdev_close_t)(struct rte_eventdev *dev)
eventdev_eth_tx_adapter_queue_add_t eth_tx_adapter_queue_add
int(* eventdev_crypto_adapter_start_t)(const struct rte_eventdev *dev, const struct rte_cryptodev *cdev)
eventdev_eth_rx_adapter_caps_get_t eth_rx_adapter_caps_get
eventdev_queue_release_t queue_release
eventdev_crypto_adapter_stats_reset crypto_adapter_stats_reset
eventdev_eth_rx_adapter_start_t eth_rx_adapter_start
eventdev_port_link_t port_link
eventdev_info_get_t dev_infos_get
eventdev_port_setup_t port_setup
void(* eventdev_port_default_conf_get_t)(struct rte_eventdev *dev, uint8_t port_id, struct rte_event_port_conf *port_conf)
static unsigned rte_event_pmd_is_valid_dev(uint8_t dev_id)
int(* eventdev_timer_adapter_caps_get_t)(const struct rte_eventdev *dev, uint64_t flags, uint32_t *caps, const struct rte_event_timer_adapter_ops **ops)
int(* eventdev_xstats_reset_t)(struct rte_eventdev *dev, enum rte_event_dev_xstats_mode mode, int16_t queue_port_id, const uint32_t ids[], uint32_t nb_ids)
int(* eventdev_port_setup_t)(struct rte_eventdev *dev, uint8_t port_id, const struct rte_event_port_conf *port_conf)
int(* eventdev_configure_t)(const struct rte_eventdev *dev)
int(* eventdev_crypto_adapter_stop_t)(const struct rte_eventdev *dev, const struct rte_cryptodev *cdev)
eventdev_eth_rx_adapter_queue_add_t eth_rx_adapter_queue_add
eventdev_eth_tx_adapter_queue_del_t eth_tx_adapter_queue_del
int(* eventdev_eth_tx_adapter_queue_del_t)(uint8_t id, const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev, int32_t tx_queue_id)
void(* eventdev_queue_release_t)(struct rte_eventdev *dev, uint8_t queue_id)
int(* eventdev_crypto_adapter_queue_pair_add_t)(const struct rte_eventdev *dev, const struct rte_cryptodev *cdev, int32_t queue_pair_id, const struct rte_event *event)
eventdev_eth_rx_adapter_queue_del_t eth_rx_adapter_queue_del
int(* eventdev_eth_tx_adapter_stats_get_t)(uint8_t id, const struct rte_eventdev *dev, struct rte_event_eth_tx_adapter_stats *stats)
void(* eventdev_port_release_t)(void *port)
static __rte_internal rte_event_pmd_selftest_seqn_t * rte_event_pmd_selftest_seqn(struct rte_mbuf *mbuf)
eventdev_queue_setup_t queue_setup
int(* eventdev_eth_tx_adapter_caps_get_t)(const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev, uint32_t *caps)
void(* eventdev_stop_t)(struct rte_eventdev *dev)
int(* eventdev_crypto_adapter_stats_get)(const struct rte_eventdev *dev, const struct rte_cryptodev *cdev, struct rte_event_crypto_adapter_stats *stats)
#define RTE_MBUF_DYNFIELD(m, offset, type)
Definition: rte_mbuf_dyn.h:235
eventdev_crypto_adapter_queue_pair_add_t crypto_adapter_queue_pair_add
eventdev_xstats_get_by_name xstats_get_by_name
eventdev_queue_default_conf_get_t queue_def_conf
eventdev_eth_rx_adapter_stats_get eth_rx_adapter_stats_get
eventdev_port_unlink_t port_unlink
int(* eventdev_eth_rx_adapter_stats_reset)(const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev)
int(* eventdev_queue_setup_t)(struct rte_eventdev *dev, uint8_t queue_id, const struct rte_event_queue_conf *queue_conf)
int rte_event_pmd_release(struct rte_eventdev *eventdev)
rte_event_dev_xstats_mode
int(* eventdev_eth_rx_adapter_stop_t)(const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev)
int(* eventdev_eth_rx_adapter_queue_del_t)(const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev, int32_t rx_queue_id)
int(* eventdev_port_unlink_t)(struct rte_eventdev *dev, void *port, uint8_t queues[], uint16_t nb_unlinks)
int(* eventdev_eth_rx_adapter_start_t)(const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev)
struct rte_eventdev * rte_event_pmd_allocate(const char *name, int socket_id)
static struct rte_eventdev * rte_event_pmd_get_named_dev(const char *name)
int(* eventdev_port_unlinks_in_progress_t)(struct rte_eventdev *dev, void *port)
int(* eventdev_selftest)(void)
eventdev_crypto_adapter_start_t crypto_adapter_start
eventdev_start_t dev_start
int(* eventdev_start_t)(struct rte_eventdev *dev)
eventdev_dequeue_timeout_ticks_t timeout_ticks
int(* eventdev_crypto_adapter_queue_pair_del_t)(const struct rte_eventdev *dev, const struct rte_cryptodev *cdev, int32_t queue_pair_id)
eventdev_eth_tx_adapter_stop_t eth_tx_adapter_stop
eventdev_xstats_reset_t xstats_reset
eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset
int(* eventdev_eth_rx_adapter_caps_get_t)(const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev, uint32_t *caps)
eventdev_stop_flush_t dev_stop_flush
eventdev_eth_tx_adapter_caps_get_t eth_tx_adapter_caps_get
int(* eventdev_eth_tx_adapter_create_t)(uint8_t id, const struct rte_eventdev *dev)
int(* eventdev_xstats_get_names_t)(const struct rte_eventdev *dev, enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id, struct rte_event_dev_xstats_name *xstats_names, unsigned int *ids, unsigned int size)
eventdev_eth_tx_adapter_stats_get_t eth_tx_adapter_stats_get
eventdev_eth_tx_adapter_free_t eth_tx_adapter_free
int(* eventdev_eth_tx_adapter_stop_t)(uint8_t id, const struct rte_eventdev *dev)
int(* eventdev_eth_rx_adapter_queue_add_t)(const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev, int32_t rx_queue_id, const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
int(* eventdev_xstats_get_t)(const struct rte_eventdev *dev, enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id, const unsigned int ids[], uint64_t values[], unsigned int n)
eventdev_eth_tx_adapter_create_t eth_tx_adapter_create
void(* eventdev_info_get_t)(struct rte_eventdev *dev, struct rte_event_dev_info *dev_info)
void(* eventdev_queue_default_conf_get_t)(struct rte_eventdev *dev, uint8_t queue_id, struct rte_event_queue_conf *queue_conf)
eventdev_port_unlinks_in_progress_t port_unlinks_in_progress
eventdev_crypto_adapter_queue_pair_del_t crypto_adapter_queue_pair_del
eventdev_xstats_get_names_t xstats_get_names
uint64_t(* eventdev_xstats_get_by_name)(const struct rte_eventdev *dev, const char *name, unsigned int *id)
eventdev_eth_tx_adapter_start_t eth_tx_adapter_start
eventdev_eth_rx_adapter_stop_t eth_rx_adapter_stop
eventdev_crypto_adapter_stop_t crypto_adapter_stop
eventdev_close_t dev_close
int(* eventdev_dequeue_timeout_ticks_t)(struct rte_eventdev *dev, uint64_t ns, uint64_t *timeout_ticks)
eventdev_xstats_get_t xstats_get
int(* eventdev_port_link_t)(struct rte_eventdev *dev, void *port, const uint8_t queues[], const uint8_t priorities[], uint16_t nb_links)
void(* eventdev_dump_t)(struct rte_eventdev *dev, FILE *f)
eventdev_crypto_adapter_stats_get crypto_adapter_stats_get
int(* eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id, const struct rte_eventdev *dev)
int(* eventdev_eth_tx_adapter_queue_add_t)(uint8_t id, const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev, int32_t tx_queue_id)
eventdev_crypto_adapter_caps_get_t crypto_adapter_caps_get
void(* eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event, void *arg)
Definition: rte_eventdev.h:868
eventdev_timer_adapter_caps_get_t timer_adapter_caps_get
int(* eventdev_eth_tx_adapter_free_t)(uint8_t id, const struct rte_eventdev *dev)
int(* eventdev_eth_tx_adapter_start_t)(uint8_t id, const struct rte_eventdev *dev)
int(* eventdev_eth_rx_adapter_stats_get)(const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev, struct rte_event_eth_rx_adapter_stats *stats)
int(* eventdev_crypto_adapter_caps_get_t)(const struct rte_eventdev *dev, const struct rte_cryptodev *cdev, uint32_t *caps)
int(* eventdev_crypto_adapter_stats_reset)(const struct rte_eventdev *dev, const struct rte_cryptodev *cdev)