New upstream version 18.02
[deb_dpdk.git] / lib / librte_bbdev / rte_bbdev_pmd.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4
5 #ifndef _RTE_BBDEV_PMD_H_
6 #define _RTE_BBDEV_PMD_H_
7
8 /**
9  * @file rte_bbdev_pmd.h
10  *
11  * Wireless base band driver-facing APIs.
12  *
13  * @warning
14  * @b EXPERIMENTAL: this API may change without prior notice
15  *
16  * This API provides the mechanism for device drivers to register with the
17  * bbdev interface. User applications should not use this API.
18  */
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #include <stdint.h>
25 #include <rte_log.h>
26
27 #include "rte_bbdev.h"
28
29 /** Suggested value for SW based devices */
30 #define RTE_BBDEV_DEFAULT_MAX_NB_QUEUES RTE_MAX_LCORE
31
32 /** Suggested value for SW based devices */
33 #define RTE_BBDEV_QUEUE_SIZE_LIMIT 16384
34
35 /**
36  * @internal
37  * Allocates a new slot for a bbdev and returns the pointer to that slot
38  * for the driver to use.
39  *
40  * @param name
41  *   Unique identifier name for each bbdev device
42  *
43  * @return
44  *   - Slot in the rte_bbdev array for a new device;
45  */
46 struct rte_bbdev * __rte_experimental
47 rte_bbdev_allocate(const char *name);
48
49 /**
50  * @internal
51  * Release the specified bbdev.
52  *
53  * @param bbdev
54  *   The *bbdev* pointer is the address of the *rte_bbdev* structure.
55  * @return
56  *   - 0 on success, negative on error
57  */
58 int __rte_experimental
59 rte_bbdev_release(struct rte_bbdev *bbdev);
60
61 /**
62  * Get the device structure for a named device.
63  *
64  * @param name
65  *   Name of the device
66  *
67  * @return
68  *   - The device structure pointer, or
69  *   - NULL otherwise
70  *
71  */
72 struct rte_bbdev * __rte_experimental
73 rte_bbdev_get_named_dev(const char *name);
74
75 /**
76  * Definitions of all functions exported by a driver through the the generic
77  * structure of type *rte_bbdev_ops* supplied in the *rte_bbdev* structure
78  * associated with a device.
79  */
80
81 /** @internal Function used to configure device memory. */
82 typedef int (*rte_bbdev_setup_queues_t)(struct rte_bbdev *dev,
83                 uint16_t num_queues, int socket_id);
84
85 /** @internal Function used to configure interrupts for a device. */
86 typedef int (*rte_bbdev_intr_enable_t)(struct rte_bbdev *dev);
87
88 /** @internal Function to allocate and configure a device queue. */
89 typedef int (*rte_bbdev_queue_setup_t)(struct rte_bbdev *dev,
90                 uint16_t queue_id, const struct rte_bbdev_queue_conf *conf);
91
92 /*
93  * @internal
94  * Function to release memory resources allocated for a device queue.
95  */
96 typedef int (*rte_bbdev_queue_release_t)(struct rte_bbdev *dev,
97                 uint16_t queue_id);
98
99 /** @internal Function to start a configured device. */
100 typedef int (*rte_bbdev_start_t)(struct rte_bbdev *dev);
101
102 /** @internal Function to stop a device. */
103 typedef void (*rte_bbdev_stop_t)(struct rte_bbdev *dev);
104
105 /** @internal Function to close a device. */
106 typedef int (*rte_bbdev_close_t)(struct rte_bbdev *dev);
107
108 /** @internal Function to start a device queue. */
109 typedef int (*rte_bbdev_queue_start_t)(struct rte_bbdev *dev,
110                 uint16_t queue_id);
111
112 /** @internal Function to stop a device queue. */
113 typedef int (*rte_bbdev_queue_stop_t)(struct rte_bbdev *dev, uint16_t queue_id);
114
115 /** @internal Function to read stats from a device. */
116 typedef void (*rte_bbdev_stats_get_t)(struct rte_bbdev *dev,
117                 struct rte_bbdev_stats *stats);
118
119 /** @internal Function to reset stats on a device. */
120 typedef void (*rte_bbdev_stats_reset_t)(struct rte_bbdev *dev);
121
122 /** @internal Function to retrieve specific information of a device. */
123 typedef void (*rte_bbdev_info_get_t)(struct rte_bbdev *dev,
124                 struct rte_bbdev_driver_info *dev_info);
125
126 /*
127  * @internal
128  * Function to enable interrupt for next op on a queue of a device.
129  */
130 typedef int (*rte_bbdev_queue_intr_enable_t)(struct rte_bbdev *dev,
131                                     uint16_t queue_id);
132
133 /*
134  * @internal
135  * Function to disable interrupt for next op on a queue of a device.
136  */
137 typedef int (*rte_bbdev_queue_intr_disable_t)(struct rte_bbdev *dev,
138                                     uint16_t queue_id);
139
140 /**
141  * Operations implemented by drivers. Fields marked as "Required" must be
142  * provided by a driver for a device to have basic functionality. "Optional"
143  * fields are for non-vital operations
144  */
145 struct rte_bbdev_ops {
146         /**< Allocate and configure device memory. Optional. */
147         rte_bbdev_setup_queues_t setup_queues;
148         /**< Configure interrupts. Optional. */
149         rte_bbdev_intr_enable_t intr_enable;
150         /**< Start device. Optional. */
151         rte_bbdev_start_t start;
152         /**< Stop device. Optional. */
153         rte_bbdev_stop_t stop;
154         /**< Close device. Optional. */
155         rte_bbdev_close_t close;
156
157         /**< Get device info. Required. */
158         rte_bbdev_info_get_t info_get;
159         /** Get device statistics. Optional. */
160         rte_bbdev_stats_get_t stats_get;
161         /** Reset device statistics. Optional. */
162         rte_bbdev_stats_reset_t stats_reset;
163
164         /** Set up a device queue. Required. */
165         rte_bbdev_queue_setup_t queue_setup;
166         /** Release a queue. Required. */
167         rte_bbdev_queue_release_t queue_release;
168         /** Start a queue. Optional. */
169         rte_bbdev_queue_start_t queue_start;
170         /**< Stop a queue pair. Optional. */
171         rte_bbdev_queue_stop_t queue_stop;
172
173         /** Enable queue interrupt. Optional */
174         rte_bbdev_queue_intr_enable_t queue_intr_enable;
175         /** Disable queue interrupt. Optional */
176         rte_bbdev_queue_intr_disable_t queue_intr_disable;
177 };
178
179 /**
180  * Executes all the user application registered callbacks for the specific
181  * device and event type.
182  *
183  * @param dev
184  *   Pointer to the device structure.
185  * @param event
186  *   Event type.
187  * @param ret_param
188  *   To pass data back to user application.
189  */
190 void __rte_experimental
191 rte_bbdev_pmd_callback_process(struct rte_bbdev *dev,
192         enum rte_bbdev_event_type event, void *ret_param);
193
194 #ifdef __cplusplus
195 }
196 #endif
197
198 #endif /* _RTE_BBDEV_PMD_H_ */