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