DPDK  17.08.2
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_dev.h>
51 #include <rte_log.h>
52 #include <rte_malloc.h>
53 
54 #include "rte_eventdev.h"
55 
56 /* Logging Macros */
57 #define RTE_EDEV_LOG_ERR(...) \
58  RTE_LOG(ERR, EVENTDEV, \
59  RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
60  __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
61 
62 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
63 #define RTE_EDEV_LOG_DEBUG(...) \
64  RTE_LOG(DEBUG, EVENTDEV, \
65  RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
66  __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
67 #else
68 #define RTE_EDEV_LOG_DEBUG(...) (void)0
69 #endif
70 
71 /* Macros to check for valid device */
72 #define RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, retval) do { \
73  if (!rte_event_pmd_is_valid_dev((dev_id))) { \
74  RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
75  return retval; \
76  } \
77 } while (0)
78 
79 #define RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id) do { \
80  if (!rte_event_pmd_is_valid_dev((dev_id))) { \
81  RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
82  return; \
83  } \
84 } while (0)
85 
86 #define RTE_EVENTDEV_DETACHED (0)
87 #define RTE_EVENTDEV_ATTACHED (1)
88 
91  uint8_t nb_devs;
92 };
93 
94 extern struct rte_eventdev_global *rte_eventdev_globals;
96 extern struct rte_eventdev *rte_eventdevs;
108 static inline struct rte_eventdev *
110 {
111  struct rte_eventdev *dev;
112  unsigned int i;
113 
114  if (name == NULL)
115  return NULL;
116 
117  for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
118  dev = &rte_eventdevs[i];
119  if ((dev->attached == RTE_EVENTDEV_ATTACHED) &&
120  (strcmp(dev->data->name, name) == 0))
121  return dev;
122  }
123 
124  return NULL;
125 }
126 
136 static inline unsigned
138 {
139  struct rte_eventdev *dev;
140 
141  if (dev_id >= RTE_EVENT_MAX_DEVS)
142  return 0;
143 
144  dev = &rte_eventdevs[dev_id];
145  if (dev->attached != RTE_EVENTDEV_ATTACHED)
146  return 0;
147  else
148  return 1;
149 }
150 
168 typedef void (*eventdev_info_get_t)(struct rte_eventdev *dev,
169  struct rte_event_dev_info *dev_info);
170 
180 typedef int (*eventdev_configure_t)(const struct rte_eventdev *dev);
181 
191 typedef int (*eventdev_start_t)(struct rte_eventdev *dev);
192 
199 typedef void (*eventdev_stop_t)(struct rte_eventdev *dev);
200 
211 typedef int (*eventdev_close_t)(struct rte_eventdev *dev);
212 
224 typedef void (*eventdev_queue_default_conf_get_t)(struct rte_eventdev *dev,
225  uint8_t queue_id, struct rte_event_queue_conf *queue_conf);
226 
240 typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
241  uint8_t queue_id,
242  const struct rte_event_queue_conf *queue_conf);
243 
253 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
254  uint8_t queue_id);
255 
267 typedef void (*eventdev_port_default_conf_get_t)(struct rte_eventdev *dev,
268  uint8_t port_id, struct rte_event_port_conf *port_conf);
269 
283 typedef int (*eventdev_port_setup_t)(struct rte_eventdev *dev,
284  uint8_t port_id,
285  const struct rte_event_port_conf *port_conf);
286 
294 typedef void (*eventdev_port_release_t)(void *port);
295 
316 typedef int (*eventdev_port_link_t)(struct rte_eventdev *dev, void *port,
317  const uint8_t queues[], const uint8_t priorities[],
318  uint16_t nb_links);
319 
336 typedef int (*eventdev_port_unlink_t)(struct rte_eventdev *dev, void *port,
337  uint8_t queues[], uint16_t nb_unlinks);
338 
353 typedef int (*eventdev_dequeue_timeout_ticks_t)(struct rte_eventdev *dev,
354  uint64_t ns, uint64_t *timeout_ticks);
355 
365 typedef void (*eventdev_dump_t)(struct rte_eventdev *dev, FILE *f);
366 
381 typedef int (*eventdev_xstats_get_t)(const struct rte_eventdev *dev,
382  enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
383  const unsigned int ids[], uint64_t values[], unsigned int n);
384 
388 typedef int (*eventdev_xstats_reset_t)(struct rte_eventdev *dev,
389  enum rte_event_dev_xstats_mode mode,
390  int16_t queue_port_id,
391  const uint32_t ids[],
392  uint32_t nb_ids);
393 
409 typedef int (*eventdev_xstats_get_names_t)(const struct rte_eventdev *dev,
410  enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
411  struct rte_event_dev_xstats_name *xstats_names,
412  unsigned int *ids, unsigned int size);
413 
429 typedef uint64_t (*eventdev_xstats_get_by_name)(const struct rte_eventdev *dev,
430  const char *name, unsigned int *id);
431 
460  eventdev_dump_t dump;
461  /* Dump internal information */
462 
471 };
472 
484 struct rte_eventdev *
485 rte_event_pmd_allocate(const char *name, int socket_id);
486 
495 int
496 rte_event_pmd_release(struct rte_eventdev *eventdev);
497 
498 #ifdef __cplusplus
499 }
500 #endif
501 
502 #endif /* _RTE_EVENTDEV_PMD_H_ */