1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017-2018 Intel Corporation
5 #ifndef _RTE_COMPRESSDEV_H_
6 #define _RTE_COMPRESSDEV_H_
9 * @file rte_compressdev.h
11 * RTE Compression Device APIs
13 * Defines comp device APIs for the provisioning of compression operations.
20 #include <rte_common.h>
24 /** comp device information */
25 struct rte_compressdev_info {
26 const char *driver_name; /**< Driver name. */
27 uint16_t max_nb_queue_pairs;
28 /**< Maximum number of queues pairs supported by device.
29 * (If 0, there is no limit in maximum number of queue pairs)
34 * Get the compress device name given a device identifier.
37 * Compress device identifier
39 * - Returns compress device name.
40 * - Returns NULL if compress device is not present.
42 const char * __rte_experimental
43 rte_compressdev_name_get(uint8_t dev_id);
46 * Get the total number of compress devices that have been successfully
50 * - The total number of usable compress devices.
52 uint8_t __rte_experimental
53 rte_compressdev_count(void);
56 * Get number and identifiers of attached comp devices that
57 * use the same compress driver.
62 * Output devices identifiers
64 * Maximal number of devices
67 * Returns number of attached compress devices.
69 uint8_t __rte_experimental
70 rte_compressdev_devices_get(const char *driver_name, uint8_t *devices,
74 * Return the NUMA socket to which a device is connected.
77 * Compress device identifier
79 * The NUMA socket id to which the device is connected or
80 * a default of zero if the socket could not be determined.
81 * -1 if returned is the dev_id value is out of range.
83 int __rte_experimental
84 rte_compressdev_socket_id(uint8_t dev_id);
86 /** Compress device configuration structure */
87 struct rte_compressdev_config {
89 /**< Socket on which to allocate resources */
90 uint16_t nb_queue_pairs;
91 /**< Total number of queue pairs to configure on a device */
97 * This function must be invoked first before any other function in the
98 * API. This function can also be re-invoked when a device is in the
102 * Compress device identifier
104 * The compress device configuration
106 * - 0: Success, device configured.
107 * - <0: Error code returned by the driver configuration function.
109 int __rte_experimental
110 rte_compressdev_configure(uint8_t dev_id,
111 struct rte_compressdev_config *config);
116 * The device start step is called after configuring the device and setting up
118 * On success, data-path functions exported by the API (enqueue/dequeue, etc)
122 * Compress device identifier
124 * - 0: Success, device started.
125 * - <0: Error code of the driver device start function.
127 int __rte_experimental
128 rte_compressdev_start(uint8_t dev_id);
131 * Stop a device. The device can be restarted with a call to
132 * rte_compressdev_start()
135 * Compress device identifier
137 void __rte_experimental
138 rte_compressdev_stop(uint8_t dev_id);
142 * The memory allocated in the device gets freed.
143 * After calling this function, in order to use
144 * the device again, it is required to
145 * configure the device again.
148 * Compress device identifier
151 * - 0 on successfully closing device
152 * - <0 on failure to close device
154 int __rte_experimental
155 rte_compressdev_close(uint8_t dev_id);
158 * Allocate and set up a receive queue pair for a device.
159 * This should only be called when the device is stopped.
163 * Compress device identifier
164 * @param queue_pair_id
165 * The index of the queue pairs to set up. The
166 * value must be in the range [0, nb_queue_pair - 1]
167 * previously supplied to rte_compressdev_configure()
168 * @param max_inflight_ops
169 * Max number of ops which the qp will have to
170 * accommodate simultaneously
172 * The *socket_id* argument is the socket identifier
173 * in case of NUMA. The value can be *SOCKET_ID_ANY*
174 * if there is no NUMA constraint for the DMA memory
175 * allocated for the receive queue pair
177 * - 0: Success, queue pair correctly set up.
178 * - <0: Queue pair configuration failed
180 int __rte_experimental
181 rte_compressdev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
182 uint32_t max_inflight_ops, int socket_id);
185 * Get the number of queue pairs on a specific comp device
188 * Compress device identifier
190 * - The number of configured queue pairs.
192 uint16_t __rte_experimental
193 rte_compressdev_queue_pair_count(uint8_t dev_id);
196 * Retrieve the contextual information of a device.
199 * Compress device identifier
201 * A pointer to a structure of type *rte_compressdev_info*
202 * to be filled with the contextual information of the device
204 * @note The capabilities field of dev_info is set to point to the first
205 * element of an array of struct rte_compressdev_capabilities.
206 * The element after the last valid element has it's op field set to
207 * RTE_COMP_ALGO_LIST_END.
209 void __rte_experimental
210 rte_compressdev_info_get(uint8_t dev_id, struct rte_compressdev_info *dev_info);
214 * Dequeue a burst of processed compression operations from a queue on the comp
215 * device. The dequeued operation are stored in *rte_comp_op* structures
216 * whose pointers are supplied in the *ops* array.
218 * The rte_compressdev_dequeue_burst() function returns the number of ops
219 * actually dequeued, which is the number of *rte_comp_op* data structures
220 * effectively supplied into the *ops* array.
222 * A return value equal to *nb_ops* indicates that the queue contained
223 * at least *nb_ops* operations, and this is likely to signify that other
224 * processed operations remain in the devices output queue. Applications
225 * implementing a "retrieve as many processed operations as possible" policy
226 * can check this specific case and keep invoking the
227 * rte_compressdev_dequeue_burst() function until a value less than
228 * *nb_ops* is returned.
230 * The rte_compressdev_dequeue_burst() function does not provide any error
231 * notification to avoid the corresponding overhead.
233 * @note: operation ordering is not maintained within the queue pair.
235 * @note: In case op status = OUT_OF_SPACE_TERMINATED, op.consumed=0 and the
236 * op must be resubmitted with the same input data and a larger output buffer.
237 * op.produced is usually 0, but in decompression cases a PMD may return > 0
238 * and the application may find it useful to inspect that data.
239 * This status is only returned on STATELESS ops.
241 * @note: In case op status = OUT_OF_SPACE_RECOVERABLE, op.produced can be used
242 * and next op in stream should continue on from op.consumed+1 with a fresh
244 * Consumed=0, produced=0 is an unusual but allowed case. There may be useful
245 * state/history stored in the PMD, even though no output was produced yet.
249 * Compress device identifier
251 * The index of the queue pair from which to retrieve
252 * processed operations. The value must be in the range
253 * [0, nb_queue_pair - 1] previously supplied to
254 * rte_compressdev_configure()
256 * The address of an array of pointers to
257 * *rte_comp_op* structures that must be
258 * large enough to store *nb_ops* pointers in it
260 * The maximum number of operations to dequeue
262 * - The number of operations actually dequeued, which is the number
263 * of pointers to *rte_comp_op* structures effectively supplied to the
266 uint16_t __rte_experimental
267 rte_compressdev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
268 struct rte_comp_op **ops, uint16_t nb_ops);
271 * Enqueue a burst of operations for processing on a compression device.
273 * The rte_compressdev_enqueue_burst() function is invoked to place
274 * comp operations on the queue *qp_id* of the device designated by
277 * The *nb_ops* parameter is the number of operations to process which are
278 * supplied in the *ops* array of *rte_comp_op* structures.
280 * The rte_compressdev_enqueue_burst() function returns the number of
281 * operations it actually enqueued for processing. A return value equal to
282 * *nb_ops* means that all packets have been enqueued.
284 * @note All compression operations are Out-of-place (OOP) operations,
285 * as the size of the output data is different to the size of the input data.
287 * @note The flush flag only applies to operations which return SUCCESS.
288 * In OUT_OF_SPACE cases whether STATEFUL or STATELESS, data in dest buffer
289 * is as if flush flag was FLUSH_NONE.
290 * @note flush flag only applies in compression direction. It has no meaning
292 * @note: operation ordering is not maintained within the queue pair.
295 * Compress device identifier
297 * The index of the queue pair on which operations
298 * are to be enqueued for processing. The value
299 * must be in the range [0, nb_queue_pairs - 1]
300 * previously supplied to *rte_compressdev_configure*
302 * The address of an array of *nb_ops* pointers
303 * to *rte_comp_op* structures which contain
304 * the operations to be processed
306 * The number of operations to process
308 * The number of operations actually enqueued on the device. The return
309 * value can be less than the value of the *nb_ops* parameter when the
310 * comp devices queue is full or if invalid parameters are specified in
313 uint16_t __rte_experimental
314 rte_compressdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
315 struct rte_comp_op **ops, uint16_t nb_ops);
321 #endif /* _RTE_COMPRESSDEV_H_ */