DPDK  17.05.2
rte_eventdev_pmd.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright(c) 2016 Cavium networks. 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 networks 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_dev.h>
50 #include <rte_pci.h>
51 #include <rte_malloc.h>
52 #include <rte_log.h>
53 #include <rte_common.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_RET(dev_id) do { \
81  if (!rte_event_pmd_is_valid_dev((dev_id))) { \
82  RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \
83  return; \
84  } \
85 } while (0)
86 
87 #define RTE_EVENTDEV_DETACHED (0)
88 #define RTE_EVENTDEV_ATTACHED (1)
89 
105 typedef int (*eventdev_init_t)(struct rte_eventdev *dev);
106 
122 typedef int (*eventdev_uninit_t)(struct rte_eventdev *dev);
123 
138  unsigned int dev_private_size;
142 };
143 
146  uint8_t nb_devs;
147 };
148 
149 extern struct rte_eventdev_global *rte_eventdev_globals;
151 extern struct rte_eventdev *rte_eventdevs;
163 static inline struct rte_eventdev *
165 {
166  struct rte_eventdev *dev;
167  unsigned int i;
168 
169  if (name == NULL)
170  return NULL;
171 
172  for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
173  dev = &rte_eventdevs[i];
174  if ((dev->attached == RTE_EVENTDEV_ATTACHED) &&
175  (strcmp(dev->data->name, name) == 0))
176  return dev;
177  }
178 
179  return NULL;
180 }
181 
191 static inline unsigned
193 {
194  struct rte_eventdev *dev;
195 
196  if (dev_id >= RTE_EVENT_MAX_DEVS)
197  return 0;
198 
199  dev = &rte_eventdevs[dev_id];
200  if (dev->attached != RTE_EVENTDEV_ATTACHED)
201  return 0;
202  else
203  return 1;
204 }
205 
223 typedef void (*eventdev_info_get_t)(struct rte_eventdev *dev,
224  struct rte_event_dev_info *dev_info);
225 
235 typedef int (*eventdev_configure_t)(const struct rte_eventdev *dev);
236 
246 typedef int (*eventdev_start_t)(struct rte_eventdev *dev);
247 
254 typedef void (*eventdev_stop_t)(struct rte_eventdev *dev);
255 
266 typedef int (*eventdev_close_t)(struct rte_eventdev *dev);
267 
279 typedef void (*eventdev_queue_default_conf_get_t)(struct rte_eventdev *dev,
280  uint8_t queue_id, struct rte_event_queue_conf *queue_conf);
281 
295 typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
296  uint8_t queue_id,
297  const struct rte_event_queue_conf *queue_conf);
298 
308 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
309  uint8_t queue_id);
310 
322 typedef void (*eventdev_port_default_conf_get_t)(struct rte_eventdev *dev,
323  uint8_t port_id, struct rte_event_port_conf *port_conf);
324 
338 typedef int (*eventdev_port_setup_t)(struct rte_eventdev *dev,
339  uint8_t port_id,
340  const struct rte_event_port_conf *port_conf);
341 
349 typedef void (*eventdev_port_release_t)(void *port);
350 
371 typedef int (*eventdev_port_link_t)(struct rte_eventdev *dev, void *port,
372  const uint8_t queues[], const uint8_t priorities[],
373  uint16_t nb_links);
374 
391 typedef int (*eventdev_port_unlink_t)(struct rte_eventdev *dev, void *port,
392  uint8_t queues[], uint16_t nb_unlinks);
393 
408 typedef int (*eventdev_dequeue_timeout_ticks_t)(struct rte_eventdev *dev,
409  uint64_t ns, uint64_t *timeout_ticks);
410 
420 typedef void (*eventdev_dump_t)(struct rte_eventdev *dev, FILE *f);
421 
436 typedef int (*eventdev_xstats_get_t)(const struct rte_eventdev *dev,
437  enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
438  const unsigned int ids[], uint64_t values[], unsigned int n);
439 
443 typedef int (*eventdev_xstats_reset_t)(struct rte_eventdev *dev,
444  enum rte_event_dev_xstats_mode mode,
445  int16_t queue_port_id,
446  const uint32_t ids[],
447  uint32_t nb_ids);
448 
464 typedef int (*eventdev_xstats_get_names_t)(const struct rte_eventdev *dev,
465  enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
466  struct rte_event_dev_xstats_name *xstats_names,
467  unsigned int *ids, unsigned int size);
468 
484 typedef uint64_t (*eventdev_xstats_get_by_name)(const struct rte_eventdev *dev,
485  const char *name, unsigned int *id);
486 
515  eventdev_dump_t dump;
516  /* Dump internal information */
517 
526 };
527 
539 struct rte_eventdev *
540 rte_event_pmd_allocate(const char *name, int socket_id);
541 
550 int
551 rte_event_pmd_release(struct rte_eventdev *eventdev);
552 
567 struct rte_eventdev *
568 rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
569  int socket_id);
570 
579 int
580 rte_event_pmd_vdev_uninit(const char *name);
581 
586 int rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
587  struct rte_pci_device *pci_dev);
588 
593 int rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev);
594 
595 #ifdef __cplusplus
596 }
597 #endif
598 
599 #endif /* _RTE_EVENTDEV_PMD_H_ */