1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017-2018 Intel Corporation
5 #ifndef _RTE_COMPRESSDEV_PMD_H_
6 #define _RTE_COMPRESSDEV_PMD_H_
12 * These APIs are for comp PMDs only and user applications should not call
23 #include <rte_common.h>
25 #include "rte_compressdev.h"
26 #include "rte_compressdev_internal.h"
28 #define RTE_COMPRESSDEV_PMD_NAME_ARG ("name")
29 #define RTE_COMPRESSDEV_PMD_SOCKET_ID_ARG ("socket_id")
31 static const char * const compressdev_pmd_valid_params[] = {
32 RTE_COMPRESSDEV_PMD_NAME_ARG,
33 RTE_COMPRESSDEV_PMD_SOCKET_ID_ARG
38 * Initialisation parameters for comp devices
40 struct rte_compressdev_pmd_init_params {
41 char name[RTE_COMPRESSDEV_NAME_MAX_LEN];
45 /** Global structure used for maintaining state of allocated comp devices */
46 struct rte_compressdev_global {
47 struct rte_compressdev *devs; /**< Device information array */
48 struct rte_compressdev_data *data[RTE_COMPRESS_MAX_DEVS];
49 /**< Device private data */
50 uint8_t nb_devs; /**< Number of devices found */
51 uint8_t max_devs; /**< Max number of devices */
55 * Get the rte_compressdev structure device pointer for the named device.
58 * Compress device name
60 * - The rte_compressdev structure pointer for the given device identifier.
63 struct rte_compressdev *
64 rte_compressdev_pmd_get_named_dev(const char *name);
67 * Definitions of all functions exported by a driver through the
68 * the generic structure of type *comp_dev_ops* supplied in the
69 * *rte_compressdev* structure associated with a device.
73 * Function used to configure device.
78 * Compress device configurations
80 * Returns 0 on success
82 typedef int (*compressdev_configure_t)(struct rte_compressdev *dev,
83 struct rte_compressdev_config *config);
86 * Function used to start a configured device.
91 * Returns 0 on success
93 typedef int (*compressdev_start_t)(struct rte_compressdev *dev);
96 * Function used to stop a configured device.
101 typedef void (*compressdev_stop_t)(struct rte_compressdev *dev);
104 * Function used to close a configured device.
110 * - EAGAIN if can't close as device is busy
112 typedef int (*compressdev_close_t)(struct rte_compressdev *dev);
116 * Function used to get statistics of a device.
121 * Compress device stats to populate
123 typedef void (*compressdev_stats_get_t)(struct rte_compressdev *dev,
124 struct rte_compressdev_stats *stats);
128 * Function used to reset statistics of a device.
133 typedef void (*compressdev_stats_reset_t)(struct rte_compressdev *dev);
137 * Function used to get specific information of a device.
142 * Compress device information to populate
144 typedef void (*compressdev_info_get_t)(struct rte_compressdev *dev,
145 struct rte_compressdev_info *dev_info);
148 * Setup a queue pair for a device.
153 * Queue pair identifier
154 * @param max_inflight_ops
155 * Max inflight ops which qp must accommodate
159 * Returns 0 on success.
161 typedef int (*compressdev_queue_pair_setup_t)(struct rte_compressdev *dev,
162 uint16_t qp_id, uint32_t max_inflight_ops, int socket_id);
165 * Release memory resources allocated by given queue pair.
170 * Queue pair identifier
173 * - EAGAIN if can't close as device is busy
175 typedef int (*compressdev_queue_pair_release_t)(struct rte_compressdev *dev,
179 * Create driver private stream data.
186 * ptr where handle of pmd's private stream data should be stored
188 * - Returns 0 if private stream structure has been created successfully.
189 * - Returns -EINVAL if input parameters are invalid.
190 * - Returns -ENOTSUP if comp device does not support STATEFUL operations.
191 * - Returns -ENOTSUP if comp device does not support the comp transform.
192 * - Returns -ENOMEM if the private stream could not be allocated.
194 typedef int (*compressdev_stream_create_t)(struct rte_compressdev *dev,
195 const struct rte_comp_xform *xform, void **stream);
198 * Free driver private stream data.
203 * handle of pmd's private stream data
206 * - <0 in error cases
207 * - Returns -EINVAL if input parameters are invalid.
208 * - Returns -ENOTSUP if comp device does not support STATEFUL operations.
209 * - Returns -EBUSY if can't free stream as there are inflight operations
211 typedef int (*compressdev_stream_free_t)(struct rte_compressdev *dev,
215 * Create driver private_xform data.
221 * @param private_xform
222 * ptr where handle of pmd's private_xform data should be stored
224 * - if successful returns 0
225 * and valid private_xform handle
226 * - <0 in error cases
227 * - Returns -EINVAL if input parameters are invalid.
228 * - Returns -ENOTSUP if comp device does not support the comp transform.
229 * - Returns -ENOMEM if the private_xform could not be allocated.
231 typedef int (*compressdev_private_xform_create_t)(struct rte_compressdev *dev,
232 const struct rte_comp_xform *xform, void **private_xform);
235 * Free driver private_xform data.
239 * @param private_xform
240 * handle of pmd's private_xform data
243 * - <0 in error cases
244 * - Returns -EINVAL if input parameters are invalid.
245 * - Returns -EBUSY if can't free private_xform due to inflight operations
247 typedef int (*compressdev_private_xform_free_t)(struct rte_compressdev *dev,
248 void *private_xform);
250 /** comp device operations function pointer table */
251 struct rte_compressdev_ops {
252 compressdev_configure_t dev_configure; /**< Configure device. */
253 compressdev_start_t dev_start; /**< Start device. */
254 compressdev_stop_t dev_stop; /**< Stop device. */
255 compressdev_close_t dev_close; /**< Close device. */
257 compressdev_info_get_t dev_infos_get; /**< Get device info. */
259 compressdev_stats_get_t stats_get;
260 /**< Get device statistics. */
261 compressdev_stats_reset_t stats_reset;
262 /**< Reset device statistics. */
264 compressdev_queue_pair_setup_t queue_pair_setup;
265 /**< Set up a device queue pair. */
266 compressdev_queue_pair_release_t queue_pair_release;
267 /**< Release a queue pair. */
269 compressdev_stream_create_t stream_create;
270 /**< Create a comp stream and initialise its private data. */
271 compressdev_stream_free_t stream_free;
272 /**< Free a comp stream's private data. */
274 compressdev_private_xform_create_t private_xform_create;
275 /**< Create a comp private_xform and initialise its private data. */
276 compressdev_private_xform_free_t private_xform_free;
277 /**< Free a comp private_xform's data. */
283 * Function for internal use by dummy drivers primarily, e.g. ring-based
285 * Allocates a new compressdev slot for an comp device and returns the pointer
286 * to that slot for the driver to use.
289 * Unique identifier name for each device
291 * Socket to allocate resources on
293 * - Slot in the rte_dev_devices array for a new device;
296 struct rte_compressdev *
297 rte_compressdev_pmd_allocate(const char *name, int socket_id);
302 * Function for internal use by dummy drivers primarily, e.g. ring-based
304 * Release the specified compressdev device.
309 * - 0 on success, negative on error
313 rte_compressdev_pmd_release_device(struct rte_compressdev *dev);
319 * PMD assist function to parse initialisation arguments for comp driver
320 * when creating a new comp PMD device instance.
322 * PMD driver should set default values for that PMD before calling function,
323 * these default values will be over-written with successfully parsed values
327 * Parsed PMD initialisation parameters
329 * Input argument string to parse
336 rte_compressdev_pmd_parse_input_args(
337 struct rte_compressdev_pmd_init_params *params,
343 * PMD assist function to provide boiler plate code for comp driver to create
344 * and allocate resources for a new comp PMD device instance.
347 * Compress device name
349 * Base device instance
351 * PMD initialisation parameters
353 * - comp device instance on success
354 * - NULL on creation failure
357 struct rte_compressdev *
358 rte_compressdev_pmd_create(const char *name,
359 struct rte_device *device,
360 size_t private_data_size,
361 struct rte_compressdev_pmd_init_params *params);
366 * PMD assist function to provide boiler plate code for comp driver to
367 * destroy and free resources associated with a comp PMD device instance.
377 rte_compressdev_pmd_destroy(struct rte_compressdev *dev);
383 #endif /* _RTE_COMPRESSDEV_PMD_H_ */