DPDK  17.11.10
rte_eventdev_pmd.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright(c) 2016 Cavium, Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * * Neither the name of Cavium, Inc nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _RTE_EVENTDEV_PMD_H_
33 #define _RTE_EVENTDEV_PMD_H_
34 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #include <string.h>
48 
49 #include <rte_common.h>
50 #include <rte_config.h>
51 #include <rte_dev.h>
52 #include <rte_log.h>
53 #include <rte_malloc.h>
54 
55 #include "rte_eventdev.h"
56 
57 /* Logging Macros */
58 #define RTE_EDEV_LOG_ERR(...) \
59  RTE_LOG(ERR, EVENTDEV, \
60  RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
61  __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
62 
63 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
64 #define RTE_EDEV_LOG_DEBUG(...) \
65  RTE_LOG(DEBUG, EVENTDEV, \
66  RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
67  __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
68 #else
69 #define RTE_EDEV_LOG_DEBUG(...) (void)0
70 #endif
71 
72 /* Macros to check for valid device */
73 #define RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, retval) do { \
74  if (!rte_event_pmd_is_valid_dev((dev_id))) { \
75  RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
76  return retval; \
77  } \
78 } while (0)
79 
80 #define RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, errno, retval) do { \
81  if (!rte_event_pmd_is_valid_dev((dev_id))) { \
82  RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
83  rte_errno = errno; \
84  return retval; \
85  } \
86 } while (0)
87 
88 #define RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id) do { \
89  if (!rte_event_pmd_is_valid_dev((dev_id))) { \
90  RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
91  return; \
92  } \
93 } while (0)
94 
95 #define RTE_EVENT_ETH_RX_ADAPTER_SW_CAP \
96  ((RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID) | \
97  (RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ))
98 
103 #define RTE_EVENTDEV_DETACHED (0)
104 #define RTE_EVENTDEV_ATTACHED (1)
105 
106 struct rte_eth_dev;
107 
110  uint8_t nb_devs;
111 };
112 
113 extern struct rte_eventdev_global *rte_eventdev_globals;
115 extern struct rte_eventdev *rte_eventdevs;
127 static inline struct rte_eventdev *
129 {
130  struct rte_eventdev *dev;
131  unsigned int i;
132 
133  if (name == NULL)
134  return NULL;
135 
136  for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
137  dev = &rte_eventdevs[i];
138  if ((dev->attached == RTE_EVENTDEV_ATTACHED) &&
139  (strcmp(dev->data->name, name) == 0))
140  return dev;
141  }
142 
143  return NULL;
144 }
145 
155 static inline unsigned
157 {
158  struct rte_eventdev *dev;
159 
160  if (dev_id >= RTE_EVENT_MAX_DEVS)
161  return 0;
162 
163  dev = &rte_eventdevs[dev_id];
164  if (dev->attached != RTE_EVENTDEV_ATTACHED)
165  return 0;
166  else
167  return 1;
168 }
169 
187 typedef void (*eventdev_info_get_t)(struct rte_eventdev *dev,
188  struct rte_event_dev_info *dev_info);
189 
199 typedef int (*eventdev_configure_t)(const struct rte_eventdev *dev);
200 
210 typedef int (*eventdev_start_t)(struct rte_eventdev *dev);
211 
218 typedef void (*eventdev_stop_t)(struct rte_eventdev *dev);
219 
230 typedef int (*eventdev_close_t)(struct rte_eventdev *dev);
231 
243 typedef void (*eventdev_queue_default_conf_get_t)(struct rte_eventdev *dev,
244  uint8_t queue_id, struct rte_event_queue_conf *queue_conf);
245 
259 typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
260  uint8_t queue_id,
261  const struct rte_event_queue_conf *queue_conf);
262 
272 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
273  uint8_t queue_id);
274 
286 typedef void (*eventdev_port_default_conf_get_t)(struct rte_eventdev *dev,
287  uint8_t port_id, struct rte_event_port_conf *port_conf);
288 
302 typedef int (*eventdev_port_setup_t)(struct rte_eventdev *dev,
303  uint8_t port_id,
304  const struct rte_event_port_conf *port_conf);
305 
313 typedef void (*eventdev_port_release_t)(void *port);
314 
335 typedef int (*eventdev_port_link_t)(struct rte_eventdev *dev, void *port,
336  const uint8_t queues[], const uint8_t priorities[],
337  uint16_t nb_links);
338 
355 typedef int (*eventdev_port_unlink_t)(struct rte_eventdev *dev, void *port,
356  uint8_t queues[], uint16_t nb_unlinks);
357 
372 typedef int (*eventdev_dequeue_timeout_ticks_t)(struct rte_eventdev *dev,
373  uint64_t ns, uint64_t *timeout_ticks);
374 
384 typedef void (*eventdev_dump_t)(struct rte_eventdev *dev, FILE *f);
385 
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 
428 typedef int (*eventdev_xstats_get_names_t)(const struct rte_eventdev *dev,
429  enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
430  struct rte_event_dev_xstats_name *xstats_names,
431  unsigned int *ids, unsigned int size);
432 
448 typedef uint64_t (*eventdev_xstats_get_by_name)(const struct rte_eventdev *dev,
449  const char *name, unsigned int *id);
450 
451 
472  (const struct rte_eventdev *dev,
473  const struct rte_eth_dev *eth_dev,
474  uint32_t *caps);
475 
476 struct rte_event_eth_rx_adapter_queue_conf *queue_conf;
477 
501  const struct rte_eventdev *dev,
502  const struct rte_eth_dev *eth_dev,
503  int32_t rx_queue_id,
504  const struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
505 
526  (const struct rte_eventdev *dev,
527  const struct rte_eth_dev *eth_dev,
528  int32_t rx_queue_id);
529 
546 typedef int (*eventdev_eth_rx_adapter_start_t)
547  (const struct rte_eventdev *dev,
548  const struct rte_eth_dev *eth_dev);
549 
566 typedef int (*eventdev_eth_rx_adapter_stop_t)
567  (const struct rte_eventdev *dev,
568  const struct rte_eth_dev *eth_dev);
569 
570 struct rte_event_eth_rx_adapter_stats *stats;
571 
589  (const struct rte_eventdev *dev,
590  const struct rte_eth_dev *eth_dev,
591  struct rte_event_eth_rx_adapter_stats *stats);
605  (const struct rte_eventdev *dev,
606  const struct rte_eth_dev *eth_dev);
607 
636  eventdev_dump_t dump;
637  /* Dump internal information */
638 
662 };
663 
675 struct rte_eventdev *
676 rte_event_pmd_allocate(const char *name, int socket_id);
677 
686 int
687 rte_event_pmd_release(struct rte_eventdev *eventdev);
688 
689 #ifdef __cplusplus
690 }
691 #endif
692 
693 #endif /* _RTE_EVENTDEV_PMD_H_ */
eventdev_stop_t dev_stop
eventdev_port_release_t port_release
struct rte_eventdev * rte_eventdevs
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
int(* eventdev_close_t)(struct rte_eventdev *dev)
eventdev_eth_rx_adapter_caps_get_t eth_rx_adapter_caps_get
eventdev_queue_release_t queue_release
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_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)
eventdev_eth_rx_adapter_queue_add_t eth_rx_adapter_queue_add
void(* eventdev_queue_release_t)(struct rte_eventdev *dev, uint8_t queue_id)
eventdev_eth_rx_adapter_queue_del_t eth_rx_adapter_queue_del
void(* eventdev_port_release_t)(void *port)
eventdev_queue_setup_t queue_setup
void(* eventdev_stop_t)(struct rte_eventdev *dev)
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)
eventdev_start_t dev_start
int(* eventdev_start_t)(struct rte_eventdev *dev)
eventdev_dequeue_timeout_ticks_t timeout_ticks
eventdev_xstats_reset_t xstats_reset
int(* eventdev_eth_rx_adapter_caps_get_t)(const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev, uint32_t *caps)
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)
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)
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_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_rx_adapter_stop_t eth_rx_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)
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)