DPDK  17.11.10
rte_eventdev.h
Go to the documentation of this file.
1 /*
2  * BSD LICENSE
3  *
4  * Copyright 2016 Cavium, Inc.
5  * Copyright 2016 Intel Corporation.
6  * Copyright 2016 NXP.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in
16  * the documentation and/or other materials provided with the
17  * distribution.
18  * * Neither the name of Cavium, Inc nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef _RTE_EVENTDEV_H_
36 #define _RTE_EVENTDEV_H_
37 
237 #ifdef __cplusplus
238 extern "C" {
239 #endif
240 
241 #include <rte_common.h>
242 #include <rte_config.h>
243 #include <rte_memory.h>
244 #include <rte_errno.h>
245 
246 struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */
247 
248 /* Event device capability bitmap flags */
249 #define RTE_EVENT_DEV_CAP_QUEUE_QOS (1ULL << 0)
250 
255 #define RTE_EVENT_DEV_CAP_EVENT_QOS (1ULL << 1)
256 
262 #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED (1ULL << 2)
263 
271 #define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES (1ULL << 3)
272 
278 #define RTE_EVENT_DEV_CAP_BURST_MODE (1ULL << 4)
279 
287 /* Event device priority levels */
288 #define RTE_EVENT_DEV_PRIORITY_HIGHEST 0
289 
293 #define RTE_EVENT_DEV_PRIORITY_NORMAL 128
294 
298 #define RTE_EVENT_DEV_PRIORITY_LOWEST 255
299 
311 uint8_t
312 rte_event_dev_count(void);
313 
324 int
325 rte_event_dev_get_dev_id(const char *name);
326 
337 int
338 rte_event_dev_socket_id(uint8_t dev_id);
339 
344  const char *driver_name;
345  struct rte_device *dev;
376  int32_t max_num_events;
381  uint32_t event_dev_cap;
383 };
384 
400 int
401 rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info);
402 
406 #define RTE_EVENT_DEV_ATTR_PORT_COUNT 0
407 
410 #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1
411 
414 #define RTE_EVENT_DEV_ATTR_STARTED 2
415 
428 int
429 rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
430  uint32_t *attr_value);
431 
432 
433 /* Event device configuration bitmap flags */
434 #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0)
435 
462  uint8_t nb_event_ports;
488  uint32_t event_dev_cfg;
490 };
491 
511 int
512 rte_event_dev_configure(uint8_t dev_id,
513  const struct rte_event_dev_config *dev_conf);
514 
515 
516 /* Event queue specific APIs */
517 
518 /* Event queue configuration bitmap flags */
519 #define RTE_EVENT_QUEUE_CFG_ALL_TYPES (1ULL << 0)
520 
525 #define RTE_EVENT_QUEUE_CFG_SINGLE_LINK (1ULL << 1)
526 
533  uint32_t nb_atomic_flows;
555  uint32_t event_queue_cfg;
557  uint8_t schedule_type;
562  uint8_t priority;
570 };
571 
594 int
595 rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
596  struct rte_event_queue_conf *queue_conf);
597 
616 int
617 rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
618  const struct rte_event_queue_conf *queue_conf);
619 
623 #define RTE_EVENT_QUEUE_ATTR_PRIORITY 0
624 
627 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS 1
628 
631 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES 2
632 
635 #define RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG 3
636 
639 #define RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE 4
640 
661 int
662 rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
663  uint32_t *attr_value);
664 
665 /* Event port specific APIs */
666 
682  uint16_t dequeue_depth;
688  uint16_t enqueue_depth;
694 };
695 
718 int
719 rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
720  struct rte_event_port_conf *port_conf);
721 
742 int
743 rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
744  const struct rte_event_port_conf *port_conf);
745 
749 #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0
750 
753 #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1
754 
757 #define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2
758 
775 int
776 rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
777  uint32_t *attr_value);
778 
795 int
796 rte_event_dev_start(uint8_t dev_id);
797 
805 void
806 rte_event_dev_stop(uint8_t dev_id);
807 
819 int
820 rte_event_dev_close(uint8_t dev_id);
821 
822 /* Scheduler type definitions */
823 #define RTE_SCHED_TYPE_ORDERED 0
824 
850 #define RTE_SCHED_TYPE_ATOMIC 1
851 
869 #define RTE_SCHED_TYPE_PARALLEL 2
870 
882 /* Event types to classify the event source */
883 #define RTE_EVENT_TYPE_ETHDEV 0x0
884 
885 #define RTE_EVENT_TYPE_CRYPTODEV 0x1
886 
887 #define RTE_EVENT_TYPE_TIMERDEV 0x2
888 
889 #define RTE_EVENT_TYPE_CPU 0x3
890 
893 #define RTE_EVENT_TYPE_ETH_RX_ADAPTER 0x4
894 
895 #define RTE_EVENT_TYPE_MAX 0x10
896 
898 /* Event enqueue operations */
899 #define RTE_EVENT_OP_NEW 0
900 
903 #define RTE_EVENT_OP_FORWARD 1
904 
911 #define RTE_EVENT_OP_RELEASE 2
912 
949 struct rte_event {
951  union {
952  uint64_t event;
954  struct {
955  uint32_t flow_id:20;
962  uint32_t sub_event_type:8;
966  uint32_t event_type:4;
970  uint8_t op:2;
976  uint8_t rsvd:4;
978  uint8_t sched_type:2;
983  uint8_t queue_id;
990  uint8_t priority;
1000  uint8_t impl_opaque;
1007  };
1008  };
1010  union {
1011  uint64_t u64;
1013  void *event_ptr;
1015  struct rte_mbuf *mbuf;
1017  };
1018 };
1019 
1020 /* Ethdev Rx adapter capability bitmap flags */
1021 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT 0x1
1022 
1025 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ 0x2
1026 
1029 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID 0x4
1030 
1056 int
1057 rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint8_t eth_port_id,
1058  uint32_t *caps);
1059 
1060 struct rte_eventdev_driver;
1061 struct rte_eventdev_ops;
1062 struct rte_eventdev;
1063 
1064 typedef uint16_t (*event_enqueue_t)(void *port, const struct rte_event *ev);
1067 typedef uint16_t (*event_enqueue_burst_t)(void *port,
1068  const struct rte_event ev[], uint16_t nb_events);
1071 typedef uint16_t (*event_dequeue_t)(void *port, struct rte_event *ev,
1072  uint64_t timeout_ticks);
1075 typedef uint16_t (*event_dequeue_burst_t)(void *port, struct rte_event ev[],
1076  uint16_t nb_events, uint64_t timeout_ticks);
1079 #define RTE_EVENTDEV_NAME_MAX_LEN (64)
1080 
1089 struct rte_eventdev_data {
1090  int socket_id;
1092  uint8_t dev_id;
1094  uint8_t nb_queues;
1096  uint8_t nb_ports;
1098  void **ports;
1100  struct rte_event_port_conf *ports_cfg;
1102  struct rte_event_queue_conf *queues_cfg;
1104  uint16_t *links_map;
1106  void *dev_private;
1108  uint32_t event_dev_cap;
1110  struct rte_event_dev_config dev_conf;
1112  uint8_t service_inited;
1113  /* Service initialization state */
1114  uint32_t service_id;
1115  /* Service ID*/
1116 
1117  RTE_STD_C11
1118  uint8_t dev_started : 1;
1121  char name[RTE_EVENTDEV_NAME_MAX_LEN];
1124 
1126 struct rte_eventdev {
1127  event_enqueue_t enqueue;
1129  event_enqueue_burst_t enqueue_burst;
1131  event_enqueue_burst_t enqueue_new_burst;
1133  event_enqueue_burst_t enqueue_forward_burst;
1135  event_dequeue_t dequeue;
1137  event_dequeue_burst_t dequeue_burst;
1140  struct rte_eventdev_data *data;
1142  const struct rte_eventdev_ops *dev_ops;
1144  struct rte_device *dev;
1147  RTE_STD_C11
1148  uint8_t attached : 1;
1151 
1152 extern struct rte_eventdev *rte_eventdevs;
1155 static __rte_always_inline uint16_t
1156 __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1157  const struct rte_event ev[], uint16_t nb_events,
1158  const event_enqueue_burst_t fn)
1159 {
1160  const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1161 
1162 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1163  if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1164  rte_errno = -EINVAL;
1165  return 0;
1166  }
1167 
1168  if (port_id >= dev->data->nb_ports) {
1169  rte_errno = -EINVAL;
1170  return 0;
1171  }
1172 #endif
1173  /*
1174  * Allow zero cost non burst mode routine invocation if application
1175  * requests nb_events as const one
1176  */
1177  if (nb_events == 1)
1178  return (*dev->enqueue)(dev->data->ports[port_id], ev);
1179  else
1180  return fn(dev->data->ports[port_id], ev, nb_events);
1181 }
1182 
1225 static inline uint16_t
1226 rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
1227  const struct rte_event ev[], uint16_t nb_events)
1228 {
1229  const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1230 
1231  return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1232  dev->enqueue_burst);
1233 }
1234 
1274 static inline uint16_t
1275 rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,
1276  const struct rte_event ev[], uint16_t nb_events)
1277 {
1278  const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1279 
1280  return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1281  dev->enqueue_new_burst);
1282 }
1283 
1323 static inline uint16_t
1324 rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id,
1325  const struct rte_event ev[], uint16_t nb_events)
1326 {
1327  const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1328 
1329  return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events,
1330  dev->enqueue_forward_burst);
1331 }
1332 
1358 int
1359 rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
1360  uint64_t *timeout_ticks);
1361 
1428 static inline uint16_t
1429 rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
1430  uint16_t nb_events, uint64_t timeout_ticks)
1431 {
1432  struct rte_eventdev *dev = &rte_eventdevs[dev_id];
1433 
1434 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
1435  if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) {
1436  rte_errno = -EINVAL;
1437  return 0;
1438  }
1439 
1440  if (port_id >= dev->data->nb_ports) {
1441  rte_errno = -EINVAL;
1442  return 0;
1443  }
1444 #endif
1445 
1446  /*
1447  * Allow zero cost non burst mode routine invocation if application
1448  * requests nb_events as const one
1449  */
1450  if (nb_events == 1)
1451  return (*dev->dequeue)(
1452  dev->data->ports[port_id], ev, timeout_ticks);
1453  else
1454  return (*dev->dequeue_burst)(
1455  dev->data->ports[port_id], ev, nb_events,
1456  timeout_ticks);
1457 }
1458 
1519 int
1520 rte_event_port_link(uint8_t dev_id, uint8_t port_id,
1521  const uint8_t queues[], const uint8_t priorities[],
1522  uint16_t nb_links);
1523 
1563 int
1564 rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
1565  uint8_t queues[], uint16_t nb_unlinks);
1566 
1594 int
1595 rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
1596  uint8_t queues[], uint8_t priorities[]);
1597 
1613 int
1614 rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id);
1615 
1629 int
1630 rte_event_dev_dump(uint8_t dev_id, FILE *f);
1631 
1633 #define RTE_EVENT_DEV_XSTATS_NAME_SIZE 64
1634 
1639  RTE_EVENT_DEV_XSTATS_DEVICE,
1640  RTE_EVENT_DEV_XSTATS_PORT,
1641  RTE_EVENT_DEV_XSTATS_QUEUE,
1642 };
1643 
1651  char name[RTE_EVENT_DEV_XSTATS_NAME_SIZE];
1652 };
1653 
1686 int
1687 rte_event_dev_xstats_names_get(uint8_t dev_id,
1688  enum rte_event_dev_xstats_mode mode,
1689  uint8_t queue_port_id,
1690  struct rte_event_dev_xstats_name *xstats_names,
1691  unsigned int *ids,
1692  unsigned int size);
1693 
1720 int
1721 rte_event_dev_xstats_get(uint8_t dev_id,
1722  enum rte_event_dev_xstats_mode mode,
1723  uint8_t queue_port_id,
1724  const unsigned int ids[],
1725  uint64_t values[], unsigned int n);
1726 
1743 uint64_t
1744 rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
1745  unsigned int *id);
1746 
1767 int
1768 rte_event_dev_xstats_reset(uint8_t dev_id,
1769  enum rte_event_dev_xstats_mode mode,
1770  int16_t queue_port_id,
1771  const uint32_t ids[],
1772  uint32_t nb_ids);
1773 
1774 #ifdef __cplusplus
1775 }
1776 #endif
1777 
1778 #endif /* _RTE_EVENTDEV_H_ */
void rte_event_dev_stop(uint8_t dev_id)
uint32_t min_dequeue_timeout_ns
Definition: rte_eventdev.h:346
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:139
#define RTE_EVENT_DEV_XSTATS_NAME_SIZE
int rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint8_t eth_port_id, uint32_t *caps)
struct rte_eventdev * rte_eventdevs
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
Definition: rte_eventdev.h:955
uint8_t priority
Definition: rte_eventdev.h:990
struct rte_device * dev
Definition: rte_eventdev.h:345
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:350
#define rte_errno
Definition: rte_errno.h:58
uint32_t event_type
Definition: rte_eventdev.h:966
uint32_t event_dev_cap
Definition: rte_eventdev.h:381
int rte_event_dev_socket_id(uint8_t dev_id)
uint32_t max_event_port_enqueue_depth
Definition: rte_eventdev.h:371
struct rte_mbuf __rte_cache_aligned
uint64_t rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name, unsigned int *id)
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:541
uint32_t nb_event_port_dequeue_depth
Definition: rte_eventdev.h:472
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)
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[])
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:366
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:480
const char * driver_name
Definition: rte_eventdev.h:344
uint8_t impl_opaque
uint8_t queue_id
Definition: rte_eventdev.h:983
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_STD_C11
Definition: rte_common.h:66
uint32_t dequeue_timeout_ns
Definition: rte_eventdev.h:441
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
Definition: rte_eventdev.h:976
uint8_t op
Definition: rte_eventdev.h:970
int32_t new_event_threshold
Definition: rte_eventdev.h:669
uint8_t max_event_priority_levels
Definition: rte_eventdev.h:360
struct rte_mbuf * mbuf
uint32_t max_dequeue_timeout_ns
Definition: rte_eventdev.h:348
uint32_t max_event_queue_flows
Definition: rte_eventdev.h:354
int rte_event_dev_configure(uint8_t dev_id, const struct rte_event_dev_config *dev_conf)
uint32_t sub_event_type
Definition: rte_eventdev.h:962
uint8_t sched_type
Definition: rte_eventdev.h:978
uint8_t max_event_queues
Definition: rte_eventdev.h:352
uint8_t max_event_queue_priority_levels
Definition: rte_eventdev.h:356
int rte_event_port_unlink(uint8_t dev_id, uint8_t port_id, uint8_t queues[], uint16_t nb_unlinks)
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:467