xref: /dpdk/lib/compressdev/rte_compressdev.h (revision 30a1de10)
1*99a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2*99a2dd95SBruce Richardson  * Copyright(c) 2017-2018 Intel Corporation
3*99a2dd95SBruce Richardson  */
4*99a2dd95SBruce Richardson 
5*99a2dd95SBruce Richardson #ifndef _RTE_COMPRESSDEV_H_
6*99a2dd95SBruce Richardson #define _RTE_COMPRESSDEV_H_
7*99a2dd95SBruce Richardson 
8*99a2dd95SBruce Richardson /**
9*99a2dd95SBruce Richardson  * @file rte_compressdev.h
10*99a2dd95SBruce Richardson  *
11*99a2dd95SBruce Richardson  * RTE Compression Device APIs.
12*99a2dd95SBruce Richardson  *
13*99a2dd95SBruce Richardson  * @warning
14*99a2dd95SBruce Richardson  * @b EXPERIMENTAL:
15*99a2dd95SBruce Richardson  * All functions in this file may be changed or removed without prior notice.
16*99a2dd95SBruce Richardson  *
17*99a2dd95SBruce Richardson  * Defines comp device APIs for the provisioning of compression operations.
18*99a2dd95SBruce Richardson  */
19*99a2dd95SBruce Richardson 
20*99a2dd95SBruce Richardson #ifdef __cplusplus
21*99a2dd95SBruce Richardson extern "C" {
22*99a2dd95SBruce Richardson #endif
23*99a2dd95SBruce Richardson 
24*99a2dd95SBruce Richardson 
25*99a2dd95SBruce Richardson #include "rte_comp.h"
26*99a2dd95SBruce Richardson 
27*99a2dd95SBruce Richardson /**
28*99a2dd95SBruce Richardson  * Parameter log base 2 range description.
29*99a2dd95SBruce Richardson  * Final value will be 2^value.
30*99a2dd95SBruce Richardson  */
31*99a2dd95SBruce Richardson struct rte_param_log2_range {
32*99a2dd95SBruce Richardson 	uint8_t min;	/**< Minimum log2 value */
33*99a2dd95SBruce Richardson 	uint8_t max;	/**< Maximum log2 value */
34*99a2dd95SBruce Richardson 	uint8_t increment;
35*99a2dd95SBruce Richardson 	/**< If a range of sizes are supported,
36*99a2dd95SBruce Richardson 	 * this parameter is used to indicate
37*99a2dd95SBruce Richardson 	 * increments in base 2 log byte value
38*99a2dd95SBruce Richardson 	 * that are supported between the minimum and maximum
39*99a2dd95SBruce Richardson 	 */
40*99a2dd95SBruce Richardson };
41*99a2dd95SBruce Richardson 
42*99a2dd95SBruce Richardson /** Structure used to capture a capability of a comp device */
43*99a2dd95SBruce Richardson struct rte_compressdev_capabilities {
44*99a2dd95SBruce Richardson 	enum rte_comp_algorithm algo;
45*99a2dd95SBruce Richardson 	/* Compression algorithm */
46*99a2dd95SBruce Richardson 	uint64_t comp_feature_flags;
47*99a2dd95SBruce Richardson 	/**< Bitmask of flags for compression service features */
48*99a2dd95SBruce Richardson 	struct rte_param_log2_range window_size;
49*99a2dd95SBruce Richardson 	/**< Window size range in base two log byte values */
50*99a2dd95SBruce Richardson };
51*99a2dd95SBruce Richardson 
52*99a2dd95SBruce Richardson /** Macro used at end of comp PMD list */
53*99a2dd95SBruce Richardson #define RTE_COMP_END_OF_CAPABILITIES_LIST() \
54*99a2dd95SBruce Richardson 	{ RTE_COMP_ALGO_UNSPECIFIED }
55*99a2dd95SBruce Richardson 
56*99a2dd95SBruce Richardson __rte_experimental
57*99a2dd95SBruce Richardson const struct rte_compressdev_capabilities *
58*99a2dd95SBruce Richardson rte_compressdev_capability_get(uint8_t dev_id,
59*99a2dd95SBruce Richardson 			enum rte_comp_algorithm algo);
60*99a2dd95SBruce Richardson 
61*99a2dd95SBruce Richardson /**
62*99a2dd95SBruce Richardson  * compression device supported feature flags
63*99a2dd95SBruce Richardson  *
64*99a2dd95SBruce Richardson  * @note New features flags should be added to the end of the list
65*99a2dd95SBruce Richardson  *
66*99a2dd95SBruce Richardson  * Keep these flags synchronised with rte_compressdev_get_feature_name()
67*99a2dd95SBruce Richardson  */
68*99a2dd95SBruce Richardson #define	RTE_COMPDEV_FF_HW_ACCELERATED		(1ULL << 0)
69*99a2dd95SBruce Richardson /**< Operations are off-loaded to an external hardware accelerator */
70*99a2dd95SBruce Richardson #define	RTE_COMPDEV_FF_CPU_SSE			(1ULL << 1)
71*99a2dd95SBruce Richardson /**< Utilises CPU SIMD SSE instructions */
72*99a2dd95SBruce Richardson #define	RTE_COMPDEV_FF_CPU_AVX			(1ULL << 2)
73*99a2dd95SBruce Richardson /**< Utilises CPU SIMD AVX instructions */
74*99a2dd95SBruce Richardson #define	RTE_COMPDEV_FF_CPU_AVX2			(1ULL << 3)
75*99a2dd95SBruce Richardson /**< Utilises CPU SIMD AVX2 instructions */
76*99a2dd95SBruce Richardson #define	RTE_COMPDEV_FF_CPU_AVX512		(1ULL << 4)
77*99a2dd95SBruce Richardson /**< Utilises CPU SIMD AVX512 instructions */
78*99a2dd95SBruce Richardson #define	RTE_COMPDEV_FF_CPU_NEON			(1ULL << 5)
79*99a2dd95SBruce Richardson /**< Utilises CPU NEON instructions */
80*99a2dd95SBruce Richardson #define RTE_COMPDEV_FF_OP_DONE_IN_DEQUEUE	(1ULL << 6)
81*99a2dd95SBruce Richardson /**< A PMD should set this if the bulk of the
82*99a2dd95SBruce Richardson  * processing is done during the dequeue. It should leave it
83*99a2dd95SBruce Richardson  * cleared if the processing is done during the enqueue (default).
84*99a2dd95SBruce Richardson  * Applications can use this as a hint for tuning.
85*99a2dd95SBruce Richardson  */
86*99a2dd95SBruce Richardson 
87*99a2dd95SBruce Richardson /**
88*99a2dd95SBruce Richardson  * Get the name of a compress device feature flag.
89*99a2dd95SBruce Richardson  *
90*99a2dd95SBruce Richardson  * @param flag
91*99a2dd95SBruce Richardson  *   The mask describing the flag
92*99a2dd95SBruce Richardson  *
93*99a2dd95SBruce Richardson  * @return
94*99a2dd95SBruce Richardson  *   The name of this flag, or NULL if it's not a valid feature flag.
95*99a2dd95SBruce Richardson  */
96*99a2dd95SBruce Richardson __rte_experimental
97*99a2dd95SBruce Richardson const char *
98*99a2dd95SBruce Richardson rte_compressdev_get_feature_name(uint64_t flag);
99*99a2dd95SBruce Richardson 
100*99a2dd95SBruce Richardson /**  comp device information */
101*99a2dd95SBruce Richardson struct rte_compressdev_info {
102*99a2dd95SBruce Richardson 	const char *driver_name;		/**< Driver name. */
103*99a2dd95SBruce Richardson 	uint64_t feature_flags;			/**< Feature flags */
104*99a2dd95SBruce Richardson 	const struct rte_compressdev_capabilities *capabilities;
105*99a2dd95SBruce Richardson 	/**< Array of devices supported capabilities */
106*99a2dd95SBruce Richardson 	uint16_t max_nb_queue_pairs;
107*99a2dd95SBruce Richardson 	/**< Maximum number of queues pairs supported by device.
108*99a2dd95SBruce Richardson 	 * (If 0, there is no limit in maximum number of queue pairs)
109*99a2dd95SBruce Richardson 	 */
110*99a2dd95SBruce Richardson };
111*99a2dd95SBruce Richardson 
112*99a2dd95SBruce Richardson /** comp device statistics */
113*99a2dd95SBruce Richardson struct rte_compressdev_stats {
114*99a2dd95SBruce Richardson 	uint64_t enqueued_count;
115*99a2dd95SBruce Richardson 	/**< Count of all operations enqueued */
116*99a2dd95SBruce Richardson 	uint64_t dequeued_count;
117*99a2dd95SBruce Richardson 	/**< Count of all operations dequeued */
118*99a2dd95SBruce Richardson 
119*99a2dd95SBruce Richardson 	uint64_t enqueue_err_count;
120*99a2dd95SBruce Richardson 	/**< Total error count on operations enqueued */
121*99a2dd95SBruce Richardson 	uint64_t dequeue_err_count;
122*99a2dd95SBruce Richardson 	/**< Total error count on operations dequeued */
123*99a2dd95SBruce Richardson };
124*99a2dd95SBruce Richardson 
125*99a2dd95SBruce Richardson 
126*99a2dd95SBruce Richardson /**
127*99a2dd95SBruce Richardson  * Get the device identifier for the named compress device.
128*99a2dd95SBruce Richardson  *
129*99a2dd95SBruce Richardson  * @param name
130*99a2dd95SBruce Richardson  *   Device name to select the device structure
131*99a2dd95SBruce Richardson  * @return
132*99a2dd95SBruce Richardson  *   - Returns compress device identifier on success.
133*99a2dd95SBruce Richardson  *   - Return -1 on failure to find named compress device.
134*99a2dd95SBruce Richardson  */
135*99a2dd95SBruce Richardson __rte_experimental
136*99a2dd95SBruce Richardson int
137*99a2dd95SBruce Richardson rte_compressdev_get_dev_id(const char *name);
138*99a2dd95SBruce Richardson 
139*99a2dd95SBruce Richardson /**
140*99a2dd95SBruce Richardson  * Get the compress device name given a device identifier.
141*99a2dd95SBruce Richardson  *
142*99a2dd95SBruce Richardson  * @param dev_id
143*99a2dd95SBruce Richardson  *   Compress device identifier
144*99a2dd95SBruce Richardson  * @return
145*99a2dd95SBruce Richardson  *   - Returns compress device name.
146*99a2dd95SBruce Richardson  *   - Returns NULL if compress device is not present.
147*99a2dd95SBruce Richardson  */
148*99a2dd95SBruce Richardson __rte_experimental
149*99a2dd95SBruce Richardson const char *
150*99a2dd95SBruce Richardson rte_compressdev_name_get(uint8_t dev_id);
151*99a2dd95SBruce Richardson 
152*99a2dd95SBruce Richardson /**
153*99a2dd95SBruce Richardson  * Get the total number of compress devices that have been successfully
154*99a2dd95SBruce Richardson  * initialised.
155*99a2dd95SBruce Richardson  *
156*99a2dd95SBruce Richardson  * @return
157*99a2dd95SBruce Richardson  *   - The total number of usable compress devices.
158*99a2dd95SBruce Richardson  */
159*99a2dd95SBruce Richardson __rte_experimental
160*99a2dd95SBruce Richardson uint8_t
161*99a2dd95SBruce Richardson rte_compressdev_count(void);
162*99a2dd95SBruce Richardson 
163*99a2dd95SBruce Richardson /**
164*99a2dd95SBruce Richardson  * Get number and identifiers of attached comp devices that
165*99a2dd95SBruce Richardson  * use the same compress driver.
166*99a2dd95SBruce Richardson  *
167*99a2dd95SBruce Richardson  * @param driver_name
168*99a2dd95SBruce Richardson  *   Driver name
169*99a2dd95SBruce Richardson  * @param devices
170*99a2dd95SBruce Richardson  *   Output devices identifiers
171*99a2dd95SBruce Richardson  * @param nb_devices
172*99a2dd95SBruce Richardson  *   Maximal number of devices
173*99a2dd95SBruce Richardson  *
174*99a2dd95SBruce Richardson  * @return
175*99a2dd95SBruce Richardson  *   Returns number of attached compress devices.
176*99a2dd95SBruce Richardson  */
177*99a2dd95SBruce Richardson __rte_experimental
178*99a2dd95SBruce Richardson uint8_t
179*99a2dd95SBruce Richardson rte_compressdev_devices_get(const char *driver_name, uint8_t *devices,
180*99a2dd95SBruce Richardson 		uint8_t nb_devices);
181*99a2dd95SBruce Richardson 
182*99a2dd95SBruce Richardson /*
183*99a2dd95SBruce Richardson  * Return the NUMA socket to which a device is connected.
184*99a2dd95SBruce Richardson  *
185*99a2dd95SBruce Richardson  * @param dev_id
186*99a2dd95SBruce Richardson  *   Compress device identifier
187*99a2dd95SBruce Richardson  * @return
188*99a2dd95SBruce Richardson  *   The NUMA socket id to which the device is connected or
189*99a2dd95SBruce Richardson  *   a default of zero if the socket could not be determined.
190*99a2dd95SBruce Richardson  *   -1 if returned is the dev_id value is out of range.
191*99a2dd95SBruce Richardson  */
192*99a2dd95SBruce Richardson __rte_experimental
193*99a2dd95SBruce Richardson int
194*99a2dd95SBruce Richardson rte_compressdev_socket_id(uint8_t dev_id);
195*99a2dd95SBruce Richardson 
196*99a2dd95SBruce Richardson /** Compress device configuration structure */
197*99a2dd95SBruce Richardson struct rte_compressdev_config {
198*99a2dd95SBruce Richardson 	int socket_id;
199*99a2dd95SBruce Richardson 	/**< Socket on which to allocate resources */
200*99a2dd95SBruce Richardson 	uint16_t nb_queue_pairs;
201*99a2dd95SBruce Richardson 	/**< Total number of queue pairs to configure on a device */
202*99a2dd95SBruce Richardson 	uint16_t max_nb_priv_xforms;
203*99a2dd95SBruce Richardson 	/**< Max number of private_xforms which will be created on the device */
204*99a2dd95SBruce Richardson 	uint16_t max_nb_streams;
205*99a2dd95SBruce Richardson 	/**< Max number of streams which will be created on the device */
206*99a2dd95SBruce Richardson };
207*99a2dd95SBruce Richardson 
208*99a2dd95SBruce Richardson /**
209*99a2dd95SBruce Richardson  * Configure a device.
210*99a2dd95SBruce Richardson  *
211*99a2dd95SBruce Richardson  * This function must be invoked first before any other function in the
212*99a2dd95SBruce Richardson  * API. This function can also be re-invoked when a device is in the
213*99a2dd95SBruce Richardson  * stopped state.
214*99a2dd95SBruce Richardson  *
215*99a2dd95SBruce Richardson  * @param dev_id
216*99a2dd95SBruce Richardson  *   Compress device identifier
217*99a2dd95SBruce Richardson  * @param config
218*99a2dd95SBruce Richardson  *   The compress device configuration
219*99a2dd95SBruce Richardson  * @return
220*99a2dd95SBruce Richardson  *   - 0: Success, device configured.
221*99a2dd95SBruce Richardson  *   - <0: Error code returned by the driver configuration function.
222*99a2dd95SBruce Richardson  */
223*99a2dd95SBruce Richardson __rte_experimental
224*99a2dd95SBruce Richardson int
225*99a2dd95SBruce Richardson rte_compressdev_configure(uint8_t dev_id,
226*99a2dd95SBruce Richardson 			struct rte_compressdev_config *config);
227*99a2dd95SBruce Richardson 
228*99a2dd95SBruce Richardson /**
229*99a2dd95SBruce Richardson  * Start a device.
230*99a2dd95SBruce Richardson  *
231*99a2dd95SBruce Richardson  * The device start step is called after configuring the device and setting up
232*99a2dd95SBruce Richardson  * its queue pairs.
233*99a2dd95SBruce Richardson  * On success, data-path functions exported by the API (enqueue/dequeue, etc)
234*99a2dd95SBruce Richardson  * can be invoked.
235*99a2dd95SBruce Richardson  *
236*99a2dd95SBruce Richardson  * @param dev_id
237*99a2dd95SBruce Richardson  *   Compress device identifier
238*99a2dd95SBruce Richardson  * @return
239*99a2dd95SBruce Richardson  *   - 0: Success, device started.
240*99a2dd95SBruce Richardson  *   - <0: Error code of the driver device start function.
241*99a2dd95SBruce Richardson  */
242*99a2dd95SBruce Richardson __rte_experimental
243*99a2dd95SBruce Richardson int
244*99a2dd95SBruce Richardson rte_compressdev_start(uint8_t dev_id);
245*99a2dd95SBruce Richardson 
246*99a2dd95SBruce Richardson /**
247*99a2dd95SBruce Richardson  * Stop a device. The device can be restarted with a call to
248*99a2dd95SBruce Richardson  * rte_compressdev_start()
249*99a2dd95SBruce Richardson  *
250*99a2dd95SBruce Richardson  * @param dev_id
251*99a2dd95SBruce Richardson  *   Compress device identifier
252*99a2dd95SBruce Richardson  */
253*99a2dd95SBruce Richardson __rte_experimental
254*99a2dd95SBruce Richardson void
255*99a2dd95SBruce Richardson rte_compressdev_stop(uint8_t dev_id);
256*99a2dd95SBruce Richardson 
257*99a2dd95SBruce Richardson /**
258*99a2dd95SBruce Richardson  * Close an device.
259*99a2dd95SBruce Richardson  * The memory allocated in the device gets freed.
260*99a2dd95SBruce Richardson  * After calling this function, in order to use
261*99a2dd95SBruce Richardson  * the device again, it is required to
262*99a2dd95SBruce Richardson  * configure the device again.
263*99a2dd95SBruce Richardson  *
264*99a2dd95SBruce Richardson  * @param dev_id
265*99a2dd95SBruce Richardson  *   Compress device identifier
266*99a2dd95SBruce Richardson  *
267*99a2dd95SBruce Richardson  * @return
268*99a2dd95SBruce Richardson  *  - 0 on successfully closing device
269*99a2dd95SBruce Richardson  *  - <0 on failure to close device
270*99a2dd95SBruce Richardson  */
271*99a2dd95SBruce Richardson __rte_experimental
272*99a2dd95SBruce Richardson int
273*99a2dd95SBruce Richardson rte_compressdev_close(uint8_t dev_id);
274*99a2dd95SBruce Richardson 
275*99a2dd95SBruce Richardson /**
276*99a2dd95SBruce Richardson  * Allocate and set up a receive queue pair for a device.
277*99a2dd95SBruce Richardson  * This should only be called when the device is stopped.
278*99a2dd95SBruce Richardson  *
279*99a2dd95SBruce Richardson  *
280*99a2dd95SBruce Richardson  * @param dev_id
281*99a2dd95SBruce Richardson  *   Compress device identifier
282*99a2dd95SBruce Richardson  * @param queue_pair_id
283*99a2dd95SBruce Richardson  *   The index of the queue pairs to set up. The
284*99a2dd95SBruce Richardson  *   value must be in the range [0, nb_queue_pair - 1]
285*99a2dd95SBruce Richardson  *   previously supplied to rte_compressdev_configure()
286*99a2dd95SBruce Richardson  * @param max_inflight_ops
287*99a2dd95SBruce Richardson  *   Max number of ops which the qp will have to
288*99a2dd95SBruce Richardson  *   accommodate simultaneously
289*99a2dd95SBruce Richardson  * @param socket_id
290*99a2dd95SBruce Richardson  *   The *socket_id* argument is the socket identifier
291*99a2dd95SBruce Richardson  *   in case of NUMA. The value can be *SOCKET_ID_ANY*
292*99a2dd95SBruce Richardson  *   if there is no NUMA constraint for the DMA memory
293*99a2dd95SBruce Richardson  *   allocated for the receive queue pair
294*99a2dd95SBruce Richardson  * @return
295*99a2dd95SBruce Richardson  *   - 0: Success, queue pair correctly set up.
296*99a2dd95SBruce Richardson  *   - <0: Queue pair configuration failed
297*99a2dd95SBruce Richardson  */
298*99a2dd95SBruce Richardson __rte_experimental
299*99a2dd95SBruce Richardson int
300*99a2dd95SBruce Richardson rte_compressdev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
301*99a2dd95SBruce Richardson 		uint32_t max_inflight_ops, int socket_id);
302*99a2dd95SBruce Richardson 
303*99a2dd95SBruce Richardson /**
304*99a2dd95SBruce Richardson  * Get the number of queue pairs on a specific comp device
305*99a2dd95SBruce Richardson  *
306*99a2dd95SBruce Richardson  * @param dev_id
307*99a2dd95SBruce Richardson  *   Compress device identifier
308*99a2dd95SBruce Richardson  * @return
309*99a2dd95SBruce Richardson  *   - The number of configured queue pairs.
310*99a2dd95SBruce Richardson  */
311*99a2dd95SBruce Richardson __rte_experimental
312*99a2dd95SBruce Richardson uint16_t
313*99a2dd95SBruce Richardson rte_compressdev_queue_pair_count(uint8_t dev_id);
314*99a2dd95SBruce Richardson 
315*99a2dd95SBruce Richardson 
316*99a2dd95SBruce Richardson /**
317*99a2dd95SBruce Richardson  * Retrieve the general I/O statistics of a device.
318*99a2dd95SBruce Richardson  *
319*99a2dd95SBruce Richardson  * @param dev_id
320*99a2dd95SBruce Richardson  *   The identifier of the device
321*99a2dd95SBruce Richardson  * @param stats
322*99a2dd95SBruce Richardson  *   A pointer to a structure of type
323*99a2dd95SBruce Richardson  *   *rte_compressdev_stats* to be filled with the
324*99a2dd95SBruce Richardson  *   values of device counters
325*99a2dd95SBruce Richardson  * @return
326*99a2dd95SBruce Richardson  *   - Zero if successful.
327*99a2dd95SBruce Richardson  *   - Non-zero otherwise.
328*99a2dd95SBruce Richardson  */
329*99a2dd95SBruce Richardson __rte_experimental
330*99a2dd95SBruce Richardson int
331*99a2dd95SBruce Richardson rte_compressdev_stats_get(uint8_t dev_id, struct rte_compressdev_stats *stats);
332*99a2dd95SBruce Richardson 
333*99a2dd95SBruce Richardson /**
334*99a2dd95SBruce Richardson  * Reset the general I/O statistics of a device.
335*99a2dd95SBruce Richardson  *
336*99a2dd95SBruce Richardson  * @param dev_id
337*99a2dd95SBruce Richardson  *   The identifier of the device.
338*99a2dd95SBruce Richardson  */
339*99a2dd95SBruce Richardson __rte_experimental
340*99a2dd95SBruce Richardson void
341*99a2dd95SBruce Richardson rte_compressdev_stats_reset(uint8_t dev_id);
342*99a2dd95SBruce Richardson 
343*99a2dd95SBruce Richardson /**
344*99a2dd95SBruce Richardson  * Retrieve the contextual information of a device.
345*99a2dd95SBruce Richardson  *
346*99a2dd95SBruce Richardson  * @param dev_id
347*99a2dd95SBruce Richardson  *   Compress device identifier
348*99a2dd95SBruce Richardson  * @param dev_info
349*99a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_compressdev_info*
350*99a2dd95SBruce Richardson  *   to be filled with the contextual information of the device
351*99a2dd95SBruce Richardson  *
352*99a2dd95SBruce Richardson  * @note The capabilities field of dev_info is set to point to the first
353*99a2dd95SBruce Richardson  * element of an array of struct rte_compressdev_capabilities.
354*99a2dd95SBruce Richardson  * The element after the last valid element has it's op field set to
355*99a2dd95SBruce Richardson  * RTE_COMP_ALGO_LIST_END.
356*99a2dd95SBruce Richardson  */
357*99a2dd95SBruce Richardson __rte_experimental
358*99a2dd95SBruce Richardson void
359*99a2dd95SBruce Richardson rte_compressdev_info_get(uint8_t dev_id, struct rte_compressdev_info *dev_info);
360*99a2dd95SBruce Richardson 
361*99a2dd95SBruce Richardson /**
362*99a2dd95SBruce Richardson  *
363*99a2dd95SBruce Richardson  * Dequeue a burst of processed compression operations from a queue on the comp
364*99a2dd95SBruce Richardson  * device. The dequeued operation are stored in *rte_comp_op* structures
365*99a2dd95SBruce Richardson  * whose pointers are supplied in the *ops* array.
366*99a2dd95SBruce Richardson  *
367*99a2dd95SBruce Richardson  * The rte_compressdev_dequeue_burst() function returns the number of ops
368*99a2dd95SBruce Richardson  * actually dequeued, which is the number of *rte_comp_op* data structures
369*99a2dd95SBruce Richardson  * effectively supplied into the *ops* array.
370*99a2dd95SBruce Richardson  *
371*99a2dd95SBruce Richardson  * A return value equal to *nb_ops* indicates that the queue contained
372*99a2dd95SBruce Richardson  * at least *nb_ops* operations, and this is likely to signify that other
373*99a2dd95SBruce Richardson  * processed operations remain in the devices output queue. Applications
374*99a2dd95SBruce Richardson  * implementing a "retrieve as many processed operations as possible" policy
375*99a2dd95SBruce Richardson  * can check this specific case and keep invoking the
376*99a2dd95SBruce Richardson  * rte_compressdev_dequeue_burst() function until a value less than
377*99a2dd95SBruce Richardson  * *nb_ops* is returned.
378*99a2dd95SBruce Richardson  *
379*99a2dd95SBruce Richardson  * The rte_compressdev_dequeue_burst() function does not provide any error
380*99a2dd95SBruce Richardson  * notification to avoid the corresponding overhead.
381*99a2dd95SBruce Richardson  *
382*99a2dd95SBruce Richardson  * @note: operation ordering is not maintained within the queue pair.
383*99a2dd95SBruce Richardson  *
384*99a2dd95SBruce Richardson  * @note: In case op status = OUT_OF_SPACE_TERMINATED, op.consumed=0 and the
385*99a2dd95SBruce Richardson  * op must be resubmitted with the same input data and a larger output buffer.
386*99a2dd95SBruce Richardson  * op.produced is usually 0, but in decompression cases a PMD may return > 0
387*99a2dd95SBruce Richardson  * and the application may find it useful to inspect that data.
388*99a2dd95SBruce Richardson  * This status is only returned on STATELESS ops.
389*99a2dd95SBruce Richardson  *
390*99a2dd95SBruce Richardson  * @note: In case op status = OUT_OF_SPACE_RECOVERABLE, op.produced can be used
391*99a2dd95SBruce Richardson  * and next op in stream should continue on from op.consumed+1 with a fresh
392*99a2dd95SBruce Richardson  * output buffer.
393*99a2dd95SBruce Richardson  * Consumed=0, produced=0 is an unusual but allowed case. There may be useful
394*99a2dd95SBruce Richardson  * state/history stored in the PMD, even though no output was produced yet.
395*99a2dd95SBruce Richardson  *
396*99a2dd95SBruce Richardson  *
397*99a2dd95SBruce Richardson  * @param dev_id
398*99a2dd95SBruce Richardson  *   Compress device identifier
399*99a2dd95SBruce Richardson  * @param qp_id
400*99a2dd95SBruce Richardson  *   The index of the queue pair from which to retrieve
401*99a2dd95SBruce Richardson  *   processed operations. The value must be in the range
402*99a2dd95SBruce Richardson  *   [0, nb_queue_pair - 1] previously supplied to
403*99a2dd95SBruce Richardson  *   rte_compressdev_configure()
404*99a2dd95SBruce Richardson  * @param ops
405*99a2dd95SBruce Richardson  *   The address of an array of pointers to
406*99a2dd95SBruce Richardson  *   *rte_comp_op* structures that must be
407*99a2dd95SBruce Richardson  *   large enough to store *nb_ops* pointers in it
408*99a2dd95SBruce Richardson  * @param nb_ops
409*99a2dd95SBruce Richardson  *   The maximum number of operations to dequeue
410*99a2dd95SBruce Richardson  * @return
411*99a2dd95SBruce Richardson  *   - The number of operations actually dequeued, which is the number
412*99a2dd95SBruce Richardson  *   of pointers to *rte_comp_op* structures effectively supplied to the
413*99a2dd95SBruce Richardson  *   *ops* array.
414*99a2dd95SBruce Richardson  */
415*99a2dd95SBruce Richardson __rte_experimental
416*99a2dd95SBruce Richardson uint16_t
417*99a2dd95SBruce Richardson rte_compressdev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
418*99a2dd95SBruce Richardson 		struct rte_comp_op **ops, uint16_t nb_ops);
419*99a2dd95SBruce Richardson 
420*99a2dd95SBruce Richardson /**
421*99a2dd95SBruce Richardson  * Enqueue a burst of operations for processing on a compression device.
422*99a2dd95SBruce Richardson  *
423*99a2dd95SBruce Richardson  * The rte_compressdev_enqueue_burst() function is invoked to place
424*99a2dd95SBruce Richardson  * comp operations on the queue *qp_id* of the device designated by
425*99a2dd95SBruce Richardson  * its *dev_id*.
426*99a2dd95SBruce Richardson  *
427*99a2dd95SBruce Richardson  * The *nb_ops* parameter is the number of operations to process which are
428*99a2dd95SBruce Richardson  * supplied in the *ops* array of *rte_comp_op* structures.
429*99a2dd95SBruce Richardson  *
430*99a2dd95SBruce Richardson  * The rte_compressdev_enqueue_burst() function returns the number of
431*99a2dd95SBruce Richardson  * operations it actually enqueued for processing. A return value equal to
432*99a2dd95SBruce Richardson  * *nb_ops* means that all packets have been enqueued.
433*99a2dd95SBruce Richardson  *
434*99a2dd95SBruce Richardson  * @note All compression operations are Out-of-place (OOP) operations,
435*99a2dd95SBruce Richardson  * as the size of the output data is different to the size of the input data.
436*99a2dd95SBruce Richardson  *
437*99a2dd95SBruce Richardson  * @note The rte_comp_op contains both input and output parameters and is the
438*99a2dd95SBruce Richardson  * vehicle for the application to pass data into and out of the PMD. While an
439*99a2dd95SBruce Richardson  * op is inflight, i.e. once it has been enqueued, the private_xform or stream
440*99a2dd95SBruce Richardson  * attached to it and any mbufs or memory referenced by it should not be altered
441*99a2dd95SBruce Richardson  * or freed by the application. The PMD may use or change some of this data at
442*99a2dd95SBruce Richardson  * any time until it has been returned in a dequeue operation.
443*99a2dd95SBruce Richardson  *
444*99a2dd95SBruce Richardson  * @note The flush flag only applies to operations which return SUCCESS.
445*99a2dd95SBruce Richardson  * In OUT_OF_SPACE cases whether STATEFUL or STATELESS, data in dest buffer
446*99a2dd95SBruce Richardson  * is as if flush flag was FLUSH_NONE.
447*99a2dd95SBruce Richardson  * @note flush flag only applies in compression direction. It has no meaning
448*99a2dd95SBruce Richardson  * for decompression.
449*99a2dd95SBruce Richardson  * @note: operation ordering is not maintained within the queue pair.
450*99a2dd95SBruce Richardson  *
451*99a2dd95SBruce Richardson  * @param dev_id
452*99a2dd95SBruce Richardson  *   Compress device identifier
453*99a2dd95SBruce Richardson  * @param qp_id
454*99a2dd95SBruce Richardson  *   The index of the queue pair on which operations
455*99a2dd95SBruce Richardson  *   are to be enqueued for processing. The value
456*99a2dd95SBruce Richardson  *   must be in the range [0, nb_queue_pairs - 1]
457*99a2dd95SBruce Richardson  *   previously supplied to *rte_compressdev_configure*
458*99a2dd95SBruce Richardson  * @param ops
459*99a2dd95SBruce Richardson  *   The address of an array of *nb_ops* pointers
460*99a2dd95SBruce Richardson  *   to *rte_comp_op* structures which contain
461*99a2dd95SBruce Richardson  *   the operations to be processed
462*99a2dd95SBruce Richardson  * @param nb_ops
463*99a2dd95SBruce Richardson  *   The number of operations to process
464*99a2dd95SBruce Richardson  * @return
465*99a2dd95SBruce Richardson  *   The number of operations actually enqueued on the device. The return
466*99a2dd95SBruce Richardson  *   value can be less than the value of the *nb_ops* parameter when the
467*99a2dd95SBruce Richardson  *   comp devices queue is full or if invalid parameters are specified in
468*99a2dd95SBruce Richardson  *   a *rte_comp_op*.
469*99a2dd95SBruce Richardson  */
470*99a2dd95SBruce Richardson __rte_experimental
471*99a2dd95SBruce Richardson uint16_t
472*99a2dd95SBruce Richardson rte_compressdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
473*99a2dd95SBruce Richardson 		struct rte_comp_op **ops, uint16_t nb_ops);
474*99a2dd95SBruce Richardson 
475*99a2dd95SBruce Richardson /**
476*99a2dd95SBruce Richardson  * This should alloc a stream from the device's mempool and initialise it.
477*99a2dd95SBruce Richardson  * The application should call this API when setting up for the stateful
478*99a2dd95SBruce Richardson  * processing of a set of data on a device. The API can be called multiple
479*99a2dd95SBruce Richardson  * times to set up a stream for each data set. The handle returned is only for
480*99a2dd95SBruce Richardson  * use with ops of op_type STATEFUL and must be passed to the PMD
481*99a2dd95SBruce Richardson  * with every op in the data stream
482*99a2dd95SBruce Richardson  *
483*99a2dd95SBruce Richardson  * @param dev_id
484*99a2dd95SBruce Richardson  *   Compress device identifier
485*99a2dd95SBruce Richardson  * @param xform
486*99a2dd95SBruce Richardson  *   xform data
487*99a2dd95SBruce Richardson  * @param stream
488*99a2dd95SBruce Richardson  *   Pointer to where PMD's private stream handle should be stored
489*99a2dd95SBruce Richardson  *
490*99a2dd95SBruce Richardson  * @return
491*99a2dd95SBruce Richardson  *  - 0 if successful and valid stream handle
492*99a2dd95SBruce Richardson  *  - <0 in error cases
493*99a2dd95SBruce Richardson  *  - Returns -EINVAL if input parameters are invalid.
494*99a2dd95SBruce Richardson  *  - Returns -ENOTSUP if comp device does not support STATEFUL operations.
495*99a2dd95SBruce Richardson  *  - Returns -ENOTSUP if comp device does not support the comp transform.
496*99a2dd95SBruce Richardson  *  - Returns -ENOMEM if the private stream could not be allocated.
497*99a2dd95SBruce Richardson  *
498*99a2dd95SBruce Richardson  */
499*99a2dd95SBruce Richardson __rte_experimental
500*99a2dd95SBruce Richardson int
501*99a2dd95SBruce Richardson rte_compressdev_stream_create(uint8_t dev_id,
502*99a2dd95SBruce Richardson 		const struct rte_comp_xform *xform,
503*99a2dd95SBruce Richardson 		void **stream);
504*99a2dd95SBruce Richardson 
505*99a2dd95SBruce Richardson /**
506*99a2dd95SBruce Richardson  * This should clear the stream and return it to the device's mempool.
507*99a2dd95SBruce Richardson  *
508*99a2dd95SBruce Richardson  * @param dev_id
509*99a2dd95SBruce Richardson  *   Compress device identifier
510*99a2dd95SBruce Richardson  *
511*99a2dd95SBruce Richardson  * @param stream
512*99a2dd95SBruce Richardson  *   PMD's private stream data
513*99a2dd95SBruce Richardson  *
514*99a2dd95SBruce Richardson  * @return
515*99a2dd95SBruce Richardson  *  - 0 if successful
516*99a2dd95SBruce Richardson  *  - <0 in error cases
517*99a2dd95SBruce Richardson  *  - Returns -EINVAL if input parameters are invalid.
518*99a2dd95SBruce Richardson  *  - Returns -ENOTSUP if comp device does not support STATEFUL operations.
519*99a2dd95SBruce Richardson  *  - Returns -EBUSY if can't free stream as there are inflight operations
520*99a2dd95SBruce Richardson  */
521*99a2dd95SBruce Richardson __rte_experimental
522*99a2dd95SBruce Richardson int
523*99a2dd95SBruce Richardson rte_compressdev_stream_free(uint8_t dev_id, void *stream);
524*99a2dd95SBruce Richardson 
525*99a2dd95SBruce Richardson /**
526*99a2dd95SBruce Richardson  * This should alloc a private_xform from the device's mempool and initialise
527*99a2dd95SBruce Richardson  * it. The application should call this API when setting up for stateless
528*99a2dd95SBruce Richardson  * processing on a device. If it returns non-shareable, then the appl cannot
529*99a2dd95SBruce Richardson  * share this handle with multiple in-flight ops and should call this API again
530*99a2dd95SBruce Richardson  * to get a separate handle for every in-flight op.
531*99a2dd95SBruce Richardson  * The handle returned is only valid for use with ops of op_type STATELESS.
532*99a2dd95SBruce Richardson  *
533*99a2dd95SBruce Richardson  * @param dev_id
534*99a2dd95SBruce Richardson  *   Compress device identifier
535*99a2dd95SBruce Richardson  * @param xform
536*99a2dd95SBruce Richardson  *   xform data
537*99a2dd95SBruce Richardson  * @param private_xform
538*99a2dd95SBruce Richardson  *   Pointer to where PMD's private_xform handle should be stored
539*99a2dd95SBruce Richardson  *
540*99a2dd95SBruce Richardson  * @return
541*99a2dd95SBruce Richardson  *  - if successful returns 0
542*99a2dd95SBruce Richardson  *    and valid private_xform handle
543*99a2dd95SBruce Richardson  *  - <0 in error cases
544*99a2dd95SBruce Richardson  *  - Returns -EINVAL if input parameters are invalid.
545*99a2dd95SBruce Richardson  *  - Returns -ENOTSUP if comp device does not support the comp transform.
546*99a2dd95SBruce Richardson  *  - Returns -ENOMEM if the private_xform could not be allocated.
547*99a2dd95SBruce Richardson  */
548*99a2dd95SBruce Richardson __rte_experimental
549*99a2dd95SBruce Richardson int
550*99a2dd95SBruce Richardson rte_compressdev_private_xform_create(uint8_t dev_id,
551*99a2dd95SBruce Richardson 		const struct rte_comp_xform *xform,
552*99a2dd95SBruce Richardson 		void **private_xform);
553*99a2dd95SBruce Richardson 
554*99a2dd95SBruce Richardson /**
555*99a2dd95SBruce Richardson  * This should clear the private_xform and return it to the device's mempool.
556*99a2dd95SBruce Richardson  * It is the application's responsibility to ensure that private_xform data
557*99a2dd95SBruce Richardson  * is not cleared while there are still in-flight operations using it.
558*99a2dd95SBruce Richardson  *
559*99a2dd95SBruce Richardson  * @param dev_id
560*99a2dd95SBruce Richardson  *   Compress device identifier
561*99a2dd95SBruce Richardson  *
562*99a2dd95SBruce Richardson  * @param private_xform
563*99a2dd95SBruce Richardson  *   PMD's private_xform data
564*99a2dd95SBruce Richardson  *
565*99a2dd95SBruce Richardson  * @return
566*99a2dd95SBruce Richardson  *  - 0 if successful
567*99a2dd95SBruce Richardson  *  - <0 in error cases
568*99a2dd95SBruce Richardson  *  - Returns -EINVAL if input parameters are invalid.
569*99a2dd95SBruce Richardson  */
570*99a2dd95SBruce Richardson __rte_experimental
571*99a2dd95SBruce Richardson int
572*99a2dd95SBruce Richardson rte_compressdev_private_xform_free(uint8_t dev_id, void *private_xform);
573*99a2dd95SBruce Richardson 
574*99a2dd95SBruce Richardson #ifdef __cplusplus
575*99a2dd95SBruce Richardson }
576*99a2dd95SBruce Richardson #endif
577*99a2dd95SBruce Richardson 
578*99a2dd95SBruce Richardson #endif /* _RTE_COMPRESSDEV_H_ */
579