DPDK  18.11.11
rte_eventdev_pmd_vdev.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2017 Cavium, Inc
3  */
4 
5 #ifndef _RTE_EVENTDEV_PMD_VDEV_H_
6 #define _RTE_EVENTDEV_PMD_VDEV_H_
7 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include <string.h>
21 
22 #include <rte_config.h>
23 #include <rte_debug.h>
24 #include <rte_eal.h>
25 #include <rte_bus_vdev.h>
26 
27 #include "rte_eventdev_pmd.h"
28 
44 static inline struct rte_eventdev *
45 rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
46  int socket_id)
47 {
48 
49  struct rte_eventdev *eventdev;
50 
51  /* Allocate device structure */
52  eventdev = rte_event_pmd_allocate(name, socket_id);
53  if (eventdev == NULL)
54  return NULL;
55 
56  /* Allocate private device structure */
57  if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
58  eventdev->data->dev_private =
59  rte_zmalloc_socket("eventdev device private",
60  dev_private_size,
61  RTE_CACHE_LINE_SIZE,
62  socket_id);
63 
64  if (eventdev->data->dev_private == NULL)
65  rte_panic("Cannot allocate memzone for private device"
66  " data");
67  }
68 
69  return eventdev;
70 }
71 
81 static inline int
82 rte_event_pmd_vdev_uninit(const char *name)
83 {
84  int ret;
85  struct rte_eventdev *eventdev;
86 
87  if (name == NULL)
88  return -EINVAL;
89 
90  eventdev = rte_event_pmd_get_named_dev(name);
91  if (eventdev == NULL)
92  return -ENODEV;
93 
94  ret = rte_event_dev_close(eventdev->data->dev_id);
95  if (ret < 0)
96  return ret;
97 
98  /* Free the event device */
99  rte_event_pmd_release(eventdev);
100 
101  return 0;
102 }
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif /* _RTE_EVENTDEV_PMD_VDEV_H_ */
enum rte_proc_type_t rte_eal_process_type(void)
int rte_event_pmd_release(struct rte_eventdev *eventdev)
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)
#define rte_panic(...)
Definition: rte_debug.h:50
void * rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket)
int rte_event_dev_close(uint8_t dev_id)