DPDK  19.08.2
rte_eventdev.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016 Cavium, Inc.
3  * Copyright(c) 2016-2018 Intel Corporation.
4  * Copyright 2016 NXP
5  * All rights reserved.
6  */
7 
8 #ifndef _RTE_EVENTDEV_H_
9 #define _RTE_EVENTDEV_H_
10 
209 #ifdef __cplusplus
210 extern "C" {
211 #endif
212 
213 #include <rte_common.h>
214 #include <rte_config.h>
215 #include <rte_memory.h>
216 #include <rte_errno.h>
217 
218 struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
219 struct rte_event;
220 
221 /* Event device capability bitmap flags */
222 #define RTE_EVENT_DEV_CAP_QUEUE_QOS (1ULL << 0)
223 
228 #define RTE_EVENT_DEV_CAP_EVENT_QOS (1ULL << 1)
229 
235 #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED (1ULL << 2)
236 
244 #define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES (1ULL << 3)
245 
251 #define RTE_EVENT_DEV_CAP_BURST_MODE (1ULL << 4)
252 
259 #define RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE (1ULL << 5)
260 
270 #define RTE_EVENT_DEV_CAP_NONSEQ_MODE (1ULL << 6)
271 
280 #define RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK (1ULL << 7)
281 
286 #define RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT (1ULL << 8)
287 
292 /* Event device priority levels */
293 #define RTE_EVENT_DEV_PRIORITY_HIGHEST 0
294 
298 #define RTE_EVENT_DEV_PRIORITY_NORMAL 128
299 
303 #define RTE_EVENT_DEV_PRIORITY_LOWEST 255
304 
316 uint8_t
317 rte_event_dev_count(void);
318 
329 int
330 rte_event_dev_get_dev_id(const char *name);
331 
342 int
343 rte_event_dev_socket_id(uint8_t dev_id);
344 
349  const char *driver_name;
350  struct rte_device *dev;
381  int32_t max_num_events;
386  uint32_t event_dev_cap;
388 };
389 
405 int
406 rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
407 
411 #define RTE_EVENT_DEV_ATTR_PORT_COUNT 0
412 
415 #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1
416 
419 #define RTE_EVENT_DEV_ATTR_STARTED 2
420 
433 int
434 rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
435  uint32_t *attr_value);
436 
437 
438 /* Event device configuration bitmap flags */
439 #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
440 
467  uint8_t nb_event_ports;
493  uint32_t event_dev_cfg;
495 };
496 
516 int
517 rte_event_dev_configure(uint8_t dev_id,
518  const struct rte_event_dev_config *dev_conf);
519 
520 
521 /* Event queue specific APIs */
522 
523 /* Event queue configuration bitmap flags */
524 #define RTE_EVENT_QUEUE_CFG_ALL_TYPES (1ULL << 0)
525 
530 #define RTE_EVENT_QUEUE_CFG_SINGLE_LINK (1ULL << 1)
531 
538  uint32_t nb_atomic_flows;
560  uint32_t event_queue_cfg;
562  uint8_t schedule_type;
567  uint8_t priority;
575 };
576 
599 int
600 rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
601  struct rte_event_queue_conf *queue_conf);
602 
621 int
622 rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
623  const struct rte_event_queue_conf *queue_conf);
624 
628 #define RTE_EVENT_QUEUE_ATTR_PRIORITY 0
629 
632 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS 1
633 
636 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES 2
637 
640 #define RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG 3
641 
644 #define RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE 4
645 
666 int
667 rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
668  uint32_t *attr_value);
669 
670 /* Event port specific APIs */
671 
687  uint16_t dequeue_depth;
693  uint16_t enqueue_depth;
706 };
707 
730 int
731 rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
732  struct rte_event_port_conf *port_conf);
733 
754 int
755 rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
756  const struct rte_event_port_conf *port_conf);
757 
761 #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0
762 
765 #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1
766 
769 #define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2
770 
787 int
788 rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
789  uint32_t *attr_value);
790 
807 int
808 rte_event_dev_start(uint8_t dev_id);
809 
828 void
829 rte_event_dev_stop(uint8_t dev_id);
830 
831 typedef void (*eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event,
832  void *arg);
861 int
863  eventdev_stop_flush_t callback, void *userdata);
864 
876 int
877 rte_event_dev_close(uint8_t dev_id);
878 
879 /* Scheduler type definitions */
880 #define RTE_SCHED_TYPE_ORDERED 0
881 
907 #define RTE_SCHED_TYPE_ATOMIC 1
908 
926 #define RTE_SCHED_TYPE_PARALLEL 2
927 
939 /* Event types to classify the event source */
940 #define RTE_EVENT_TYPE_ETHDEV 0x0
941 
942 #define RTE_EVENT_TYPE_CRYPTODEV 0x1
943 
944 #define RTE_EVENT_TYPE_TIMER 0x2
945 
946 #define RTE_EVENT_TYPE_CPU 0x3
947 
950 #define RTE_EVENT_TYPE_ETH_RX_ADAPTER 0x4
951 
952 #define RTE_EVENT_TYPE_MAX 0x10
953 
955 /* Event enqueue operations */
956 #define RTE_EVENT_OP_NEW 0
957 
960 #define RTE_EVENT_OP_FORWARD 1
961 
968 #define RTE_EVENT_OP_RELEASE 2
969 
1006 struct rte_event {
1008  union {
1009  uint64_t event;
1011  struct {
1012  uint32_t flow_id:20;
1019  uint32_t sub_event_type:8;
1023  uint32_t event_type:4;
1027  uint8_t op:2;
1033  uint8_t rsvd:4;
1035  uint8_t sched_type:2;
1040  uint8_t queue_id;
1047  uint8_t priority;
1057  uint8_t impl_opaque;
1064  };
1065  };
1067  union {
1068  uint64_t u64;
1070  void *event_ptr;
1072  struct rte_mbuf *mbuf;
1074  };
1075 };
1076 
1077 /* Ethdev Rx adapter capability bitmap flags */
1078 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT 0x1
1079 
1082 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ 0x2
1083 
1086 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID 0x4
1087 
1113 int
1114 rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
1115  uint32_t *caps);
1116 
1117 #define RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT (1ULL << 0)
1118 
1133 int
1134 rte_event_timer_adapter_caps_get(uint8_t dev_id, uint32_t *caps);
1135 
1136 /* Crypto adapter capability bitmap flag */
1137 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW 0x1
1138 
1144 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD 0x2
1145 
1151 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND 0x4
1152 
1156 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA 0x8
1157 
1181 int
1182 rte_event_crypto_adapter_caps_get(uint8_t dev_id, uint8_t cdev_id,
1183  uint32_t *caps);
1184 
1185 /* Ethdev Tx adapter capability bitmap flags */
1186 #define RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT 0x1
1187 
1207 int
1208 rte_event_eth_tx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
1209  uint32_t *caps);
1210 
1211 struct rte_eventdev_ops;
1212 struct rte_eventdev;
1213 
1214 typedef uint16_t (*event_enqueue_t)(void *port, const struct rte_event *ev);
1217 typedef uint16_t (*event_enqueue_burst_t)(void *port,
1218  const struct rte_event ev[], uint16_t nb_events);
1221 typedef uint16_t (*event_dequeue_t)(void *port, struct rte_event *ev,
1222  uint64_t timeout_ticks);
1225 typedef uint16_t (*event_dequeue_burst_t)(void *port, struct rte_event ev[],
1226  uint16_t nb_events, uint64_t timeout_ticks);
1229 typedef uint16_t (*event_tx_adapter_enqueue)(void *port,
1230  struct rte_event ev[], uint16_t nb_events);
1233 #define RTE_EVENTDEV_NAME_MAX_LEN (64)
1234 
1243 struct rte_eventdev_data {
1244  int socket_id;
1246  uint8_t dev_id;
1248  uint8_t nb_queues;
1250  uint8_t nb_ports;
1252  void **ports;
1254  struct rte_event_port_conf *ports_cfg;
1256  struct rte_event_queue_conf *queues_cfg;
1258  uint16_t *links_map;
1260  void *dev_private;
1262  uint32_t event_dev_cap;
1264  struct rte_event_dev_config dev_conf;
1266  uint8_t service_inited;
1267  /* Service initialization state */
1268  uint32_t service_id;
1269  /* Service ID*/
1270  void *dev_stop_flush_arg;
1273  RTE_STD_C11
1274  uint8_t dev_started : 1;
1277  char name[RTE_EVENTDEV_NAME_MAX_LEN];
1280 
1282 struct rte_eventdev {
1283  event_enqueue_t enqueue;
1285  event_enqueue_burst_t enqueue_burst;
1287  event_enqueue_burst_t enqueue_new_burst;
1289  event_enqueue_burst_t enqueue_forward_burst;
1291  event_dequeue_t dequeue;
1293  event_dequeue_burst_t dequeue_burst;
1295  event_tx_adapter_enqueue txa_enqueue;
1297  struct rte_eventdev_data *data;
1299  struct rte_eventdev_ops *dev_ops;
1301  struct rte_device *dev;
1304  RTE_STD_C11
1305  uint8_t attached : 1;
1308 
1309 extern struct rte_eventdev *rte_eventdevs;
1312 static __rte_always_inline uint16_t
1313 __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1314  const struct rte_event ev[], uint16_t nb_events,
1315  const event_enqueue_burst_t fn)
1316 {
1317  const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1318 
1319 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1320  if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1321  rte_errno = EINVAL;
1322  return 0;
1323  }
1324 
1325  if (port_id >= dev->data->nb_ports) {
1326  rte_errno = EINVAL;
1327  return 0;
1328  }
1329 #endif
1330  /*
1331  * Allow zero cost non burst mode routine invocation if application
1332  * requests nb_events as const one
1333  */
1334  if (nb_events == 1)
1335  return (*dev->enqueue)(dev->data->ports[port_id], ev);
1336  else
1337  return fn(dev->data->ports[port_id], ev, nb_events);
1338 }
1339 
1383 static inline uint16_t
1384 rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1385  const struct rte_event ev[], uint16_t nb_events)
1386 {
1387  const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1388 
1389  return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1390  dev->enqueue_burst);
1391 }
1392 
1434 static inline uint16_t
1435 rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,
1436  const struct rte_event ev[], uint16_t nb_events)
1437 {
1438  const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1439 
1440  return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1441  dev->enqueue_new_burst);
1442 }
1443 
1485 static inline uint16_t
1486 rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id,
1487  const struct rte_event ev[], uint16_t nb_events)
1488 {
1489  const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1490 
1491  return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1492  dev->enqueue_forward_burst);
1493 }
1494 
1520 int
1521 rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
1522  uint64_t *timeout_ticks);
1523 
1590 static inline uint16_t
1591 rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
1592  uint16_t nb_events, uint64_t timeout_ticks)
1593 {
1594  struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1595 
1596 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1597  if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1598  rte_errno = EINVAL;
1599  return 0;
1600  }
1601 
1602  if (port_id >= dev->data->nb_ports) {
1603  rte_errno = EINVAL;
1604  return 0;
1605  }
1606 #endif
1607 
1608  /*
1609  * Allow zero cost non burst mode routine invocation if application
1610  * requests nb_events as const one
1611  */
1612  if (nb_events == 1)
1613  return (*dev->dequeue)(
1614  dev->data->ports[port_id], ev, timeout_ticks);
1615  else
1616  return (*dev->dequeue_burst)(
1617  dev->data->ports[port_id], ev, nb_events,
1618  timeout_ticks);
1619 }
1620 
1681 int
1682 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
1683  const uint8_t queues[], const uint8_t priorities[],
1684  uint16_t nb_links);
1685 
1725 int
1726 rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
1727  uint8_t queues[], uint16_t nb_unlinks);
1728 
1750 int
1751 rte_event_port_unlinks_in_progress(uint8_t dev_id, uint8_t port_id);
1752 
1780 int
1781 rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
1782  uint8_t queues[], uint8_t priorities[]);
1783 
1799 int
1800 rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id);
1801 
1815 int
1816 rte_event_dev_dump(uint8_t dev_id, FILE *f);
1817 
1819 #define RTE_EVENT_DEV_XSTATS_NAME_SIZE 64
1820 
1825  RTE_EVENT_DEV_XSTATS_DEVICE,
1826  RTE_EVENT_DEV_XSTATS_PORT,
1827  RTE_EVENT_DEV_XSTATS_QUEUE,
1828 };
1829 
1837  char name[RTE_EVENT_DEV_XSTATS_NAME_SIZE];
1838 };
1839 
1872 int
1873 rte_event_dev_xstats_names_get(uint8_t dev_id,
1874  enum rte_event_dev_xstats_mode mode,
1875  uint8_t queue_port_id,
1876  struct rte_event_dev_xstats_name *xstats_names,
1877  unsigned int *ids,
1878  unsigned int size);
1879 
1906 int
1907 rte_event_dev_xstats_get(uint8_t dev_id,
1908  enum rte_event_dev_xstats_mode mode,
1909  uint8_t queue_port_id,
1910  const unsigned int ids[],
1911  uint64_t values[], unsigned int n);
1912 
1929 uint64_t
1930 rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
1931  unsigned int *id);
1932 
1953 int
1954 rte_event_dev_xstats_reset(uint8_t dev_id,
1955  enum rte_event_dev_xstats_mode mode,
1956  int16_t queue_port_id,
1957  const uint32_t ids[],
1958  uint32_t nb_ids);
1959 
1970 int rte_event_dev_selftest(uint8_t dev_id);
1971 
1972 #ifdef __cplusplus
1973 }
1974 #endif
1975 
1976 #endif /* _RTE_EVENTDEV_H_ */
void rte_event_dev_stop(uint8_t dev_id)
uint32_t min_dequeue_timeout_ns
Definition: rte_eventdev.h:351
int rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns, uint64_t *timeout_ticks)
static uint16_t rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id, const struct rte_event ev[], uint16_t nb_events)
#define __rte_always_inline
Definition: rte_common.h:153
#define RTE_EVENT_DEV_XSTATS_NAME_SIZE
uint64_t u64
int rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, uint32_t *attr_value)
uint32_t flow_id
int rte_event_eth_tx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id, uint32_t *caps)
int rte_event_dev_stop_flush_callback_register(uint8_t dev_id, eventdev_stop_flush_t callback, void *userdata)
uint8_t priority
struct rte_device * dev
Definition: rte_eventdev.h:350
int rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, const struct rte_event_queue_conf *queue_conf)
int rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id, struct rte_event_queue_conf *queue_conf)
int rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id, struct rte_event_port_conf *port_conf)
uint32_t dequeue_timeout_ns
Definition: rte_eventdev.h:355
#define rte_errno
Definition: rte_errno.h:29
uint32_t event_type
uint32_t event_dev_cap
Definition: rte_eventdev.h:386
int rte_event_dev_socket_id(uint8_t dev_id)
uint32_t max_event_port_enqueue_depth
Definition: rte_eventdev.h:376
uint64_t rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name, unsigned int *id)
int rte_event_timer_adapter_caps_get(uint8_t dev_id, uint32_t *caps)
int rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
uint32_t nb_atomic_order_sequences
Definition: rte_eventdev.h:546
uint32_t nb_event_port_dequeue_depth
Definition: rte_eventdev.h:477
int rte_event_port_unlinks_in_progress(uint8_t dev_id, uint8_t port_id)
void * event_ptr
int rte_event_port_link(uint8_t dev_id, uint8_t port_id, const uint8_t queues[], const uint8_t priorities[], uint16_t nb_links)
int rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, uint32_t *attr_value)
uint8_t disable_implicit_release
Definition: rte_eventdev.h:699
rte_event_dev_xstats_mode
int rte_event_port_links_get(uint8_t dev_id, uint8_t port_id, uint8_t queues[], uint8_t priorities[])
int rte_event_dev_selftest(uint8_t dev_id)
static uint16_t rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id, const struct rte_event ev[], uint16_t nb_events)
int rte_event_dev_start(uint8_t dev_id)
int rte_event_port_setup(uint8_t dev_id, uint8_t port_id, const struct rte_event_port_conf *port_conf)
uint8_t max_event_port_dequeue_depth
Definition: rte_eventdev.h:371
int rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, uint32_t *attr_value)
uint32_t nb_event_port_enqueue_depth
Definition: rte_eventdev.h:485
const char * driver_name
Definition: rte_eventdev.h:349
uint8_t impl_opaque
uint8_t queue_id
static uint16_t rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[], uint16_t nb_events, uint64_t timeout_ticks)
int rte_event_dev_get_dev_id(const char *name)
uint8_t rte_event_dev_count(void)
int rte_event_dev_close(uint8_t dev_id)
int rte_event_dev_xstats_get(uint8_t dev_id, enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id, const unsigned int ids[], uint64_t values[], unsigned int n)
int rte_event_dev_xstats_reset(uint8_t dev_id, enum rte_event_dev_xstats_mode mode, int16_t queue_port_id, const uint32_t ids[], uint32_t nb_ids)
#define __rte_cache_aligned
Definition: rte_memory.h:64
#define RTE_STD_C11
Definition: rte_common.h:40
int rte_event_crypto_adapter_caps_get(uint8_t dev_id, uint8_t cdev_id, uint32_t *caps)
uint32_t dequeue_timeout_ns
Definition: rte_eventdev.h:446
int rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id)
static uint16_t rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id, const struct rte_event ev[], uint16_t nb_events)
int rte_event_dev_dump(uint8_t dev_id, FILE *f)
uint8_t rsvd
uint8_t op
int32_t new_event_threshold
Definition: rte_eventdev.h:674
uint8_t max_event_priority_levels
Definition: rte_eventdev.h:365
struct rte_mbuf * mbuf
uint32_t max_dequeue_timeout_ns
Definition: rte_eventdev.h:353
uint32_t max_event_queue_flows
Definition: rte_eventdev.h:359
int rte_event_dev_configure(uint8_t dev_id, const struct rte_event_dev_config *dev_conf)
void(* eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event, void *arg)
Definition: rte_eventdev.h:831
uint32_t sub_event_type
uint8_t sched_type
uint8_t max_event_queues
Definition: rte_eventdev.h:357
uint8_t max_event_queue_priority_levels
Definition: rte_eventdev.h:361
int rte_event_port_unlink(uint8_t dev_id, uint8_t port_id, uint8_t queues[], uint16_t nb_unlinks)
int rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id, uint32_t *caps)
int rte_event_dev_xstats_names_get(uint8_t dev_id, 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)
uint32_t nb_event_queue_flows
Definition: rte_eventdev.h:472