40552aa71e071c79923ded415571b4868aff270a
[dpdk.git] / lib / librte_eventdev / rte_eventdev_pmd.h
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
35 /** @file
36  * RTE Event PMD APIs
37  *
38  * @note
39  * These API are from event PMD only and user applications should not call
40  * them directly.
41  */
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 #include "rte_eventdev.h"
48
49 /**
50  * Definitions of all functions exported by a driver through the
51  * the generic structure of type *event_dev_ops* supplied in the
52  * *rte_eventdev* structure associated with a device.
53  */
54
55 /**
56  * Get device information of a device.
57  *
58  * @param dev
59  *   Event device pointer
60  * @param dev_info
61  *   Event device information structure
62  *
63  * @return
64  *   Returns 0 on success
65  */
66 typedef void (*eventdev_info_get_t)(struct rte_eventdev *dev,
67                 struct rte_event_dev_info *dev_info);
68
69 /**
70  * Configure a device.
71  *
72  * @param dev
73  *   Event device pointer
74  *
75  * @return
76  *   Returns 0 on success
77  */
78 typedef int (*eventdev_configure_t)(const struct rte_eventdev *dev);
79
80 /**
81  * Start a configured device.
82  *
83  * @param dev
84  *   Event device pointer
85  *
86  * @return
87  *   Returns 0 on success
88  */
89 typedef int (*eventdev_start_t)(struct rte_eventdev *dev);
90
91 /**
92  * Stop a configured device.
93  *
94  * @param dev
95  *   Event device pointer
96  */
97 typedef void (*eventdev_stop_t)(struct rte_eventdev *dev);
98
99 /**
100  * Close a configured device.
101  *
102  * @param dev
103  *   Event device pointer
104  *
105  * @return
106  * - 0 on success
107  * - (-EAGAIN) if can't close as device is busy
108  */
109 typedef int (*eventdev_close_t)(struct rte_eventdev *dev);
110
111 /**
112  * Retrieve the default event queue configuration.
113  *
114  * @param dev
115  *   Event device pointer
116  * @param queue_id
117  *   Event queue index
118  * @param[out] queue_conf
119  *   Event queue configuration structure
120  *
121  */
122 typedef void (*eventdev_queue_default_conf_get_t)(struct rte_eventdev *dev,
123                 uint8_t queue_id, struct rte_event_queue_conf *queue_conf);
124
125 /**
126  * Setup an event queue.
127  *
128  * @param dev
129  *   Event device pointer
130  * @param queue_id
131  *   Event queue index
132  * @param queue_conf
133  *   Event queue configuration structure
134  *
135  * @return
136  *   Returns 0 on success.
137  */
138 typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev,
139                 uint8_t queue_id,
140                 const struct rte_event_queue_conf *queue_conf);
141
142 /**
143  * Release resources allocated by given event queue.
144  *
145  * @param dev
146  *   Event device pointer
147  * @param queue_id
148  *   Event queue index
149  *
150  */
151 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev,
152                 uint8_t queue_id);
153
154 /**
155  * Retrieve the default event port configuration.
156  *
157  * @param dev
158  *   Event device pointer
159  * @param port_id
160  *   Event port index
161  * @param[out] port_conf
162  *   Event port configuration structure
163  *
164  */
165 typedef void (*eventdev_port_default_conf_get_t)(struct rte_eventdev *dev,
166                 uint8_t port_id, struct rte_event_port_conf *port_conf);
167
168 /**
169  * Setup an event port.
170  *
171  * @param dev
172  *   Event device pointer
173  * @param port_id
174  *   Event port index
175  * @param port_conf
176  *   Event port configuration structure
177  *
178  * @return
179  *   Returns 0 on success.
180  */
181 typedef int (*eventdev_port_setup_t)(struct rte_eventdev *dev,
182                 uint8_t port_id,
183                 const struct rte_event_port_conf *port_conf);
184
185 /**
186  * Release memory resources allocated by given event port.
187  *
188  * @param port
189  *   Event port pointer
190  *
191  */
192 typedef void (*eventdev_port_release_t)(void *port);
193
194 /**
195  * Link multiple source event queues to destination event port.
196  *
197  * @param port
198  *   Event port pointer
199  * @param link
200  *   Points to an array of *nb_links* event queues to be linked
201  *   to the event port.
202  * @param priorities
203  *   Points to an array of *nb_links* service priorities associated with each
204  *   event queue link to event port.
205  * @param nb_links
206  *   The number of links to establish
207  *
208  * @return
209  *   Returns 0 on success.
210  *
211  */
212 typedef int (*eventdev_port_link_t)(void *port,
213                 const uint8_t queues[], const uint8_t priorities[],
214                 uint16_t nb_links);
215
216 /**
217  * Unlink multiple source event queues from destination event port.
218  *
219  * @param port
220  *   Event port pointer
221  * @param queues
222  *   An array of *nb_unlinks* event queues to be unlinked from the event port.
223  * @param nb_unlinks
224  *   The number of unlinks to establish
225  *
226  * @return
227  *   Returns 0 on success.
228  *
229  */
230 typedef int (*eventdev_port_unlink_t)(void *port,
231                 uint8_t queues[], uint16_t nb_unlinks);
232
233 /**
234  * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue()
235  *
236  * @param dev
237  *   Event device pointer
238  * @param ns
239  *   Wait time in nanosecond
240  * @param[out] timeout_ticks
241  *   Value for the *timeout_ticks* parameter in rte_event_dequeue() function
242  *
243  */
244 typedef void (*eventdev_dequeue_timeout_ticks_t)(struct rte_eventdev *dev,
245                 uint64_t ns, uint64_t *timeout_ticks);
246
247 /**
248  * Dump internal information
249  *
250  * @param dev
251  *   Event device pointer
252  * @param f
253  *   A pointer to a file for output
254  *
255  */
256 typedef void (*eventdev_dump_t)(struct rte_eventdev *dev, FILE *f);
257
258 /** Event device operations function pointer table */
259 struct rte_eventdev_ops {
260         eventdev_info_get_t dev_infos_get;      /**< Get device info. */
261         eventdev_configure_t dev_configure;     /**< Configure device. */
262         eventdev_start_t dev_start;             /**< Start device. */
263         eventdev_stop_t dev_stop;               /**< Stop device. */
264         eventdev_close_t dev_close;             /**< Close device. */
265
266         eventdev_queue_default_conf_get_t queue_def_conf;
267         /**< Get default queue configuration. */
268         eventdev_queue_setup_t queue_setup;
269         /**< Set up an event queue. */
270         eventdev_queue_release_t queue_release;
271         /**< Release an event queue. */
272
273         eventdev_port_default_conf_get_t port_def_conf;
274         /**< Get default port configuration. */
275         eventdev_port_setup_t port_setup;
276         /**< Set up an event port. */
277         eventdev_port_release_t port_release;
278         /**< Release an event port. */
279
280         eventdev_port_link_t port_link;
281         /**< Link event queues to an event port. */
282         eventdev_port_unlink_t port_unlink;
283         /**< Unlink event queues from an event port. */
284         eventdev_dequeue_timeout_ticks_t timeout_ticks;
285         /**< Converts ns to *timeout_ticks* value for rte_event_dequeue() */
286         eventdev_dump_t dump;
287         /* Dump internal information */
288 };
289
290 #ifdef __cplusplus
291 }
292 #endif
293
294 #endif /* _RTE_EVENTDEV_PMD_H_ */