DPDK  19.11.14
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 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #include <string.h>
25 
26 #include <rte_config.h>
27 #include <rte_debug.h>
28 #include <rte_eal.h>
29 #include <rte_bus_vdev.h>
30 
31 #include "rte_eventdev_pmd.h"
32 
48 static inline struct rte_eventdev *
49 rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
50  int socket_id)
51 {
52 
53  struct rte_eventdev *eventdev;
54 
55  /* Allocate device structure */
56  eventdev = rte_event_pmd_allocate(name, socket_id);
57  if (eventdev == NULL)
58  return NULL;
59 
60  /* Allocate private device structure */
61  if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
62  eventdev->data->dev_private =
63  rte_zmalloc_socket("eventdev device private",
64  dev_private_size,
65  RTE_CACHE_LINE_SIZE,
66  socket_id);
67 
68  if (eventdev->data->dev_private == NULL)
69  rte_panic("Cannot allocate memzone for private device"
70  " data");
71  }
72 
73  return eventdev;
74 }
75 
85 static inline int
86 rte_event_pmd_vdev_uninit(const char *name)
87 {
88  int ret;
89  struct rte_eventdev *eventdev;
90 
91  if (name == NULL)
92  return -EINVAL;
93 
94  eventdev = rte_event_pmd_get_named_dev(name);
95  if (eventdev == NULL)
96  return -ENODEV;
97 
98  ret = rte_event_dev_close(eventdev->data->dev_id);
99  if (ret < 0)
100  return ret;
101 
102  /* Free the event device */
103  rte_event_pmd_release(eventdev);
104 
105  return 0;
106 }
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #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)