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 typedef void (*compressdev_info_get_t)(struct rte_compressdev *dev,
143 struct rte_compressdev_info *dev_info);
146 * Setup a queue pair for a device.
151 * Queue pair identifier
152 * @param max_inflight_ops
153 * Max inflight ops which qp must accommodate
157 * Returns 0 on success.
159 typedef int (*compressdev_queue_pair_setup_t)(struct rte_compressdev *dev,
160 uint16_t qp_id, uint32_t max_inflight_ops, int socket_id);
163 * Release memory resources allocated by given queue pair.
168 * Queue pair identifier
171 * - EAGAIN if can't close as device is busy
173 typedef int (*compressdev_queue_pair_release_t)(struct rte_compressdev *dev,
177 * Create driver private stream data.
184 * ptr where handle of pmd's private stream data should be stored
186 * - Returns 0 if private stream structure has been created successfully.
187 * - Returns -EINVAL if input parameters are invalid.
188 * - Returns -ENOTSUP if comp device does not support STATEFUL operations.
189 * - Returns -ENOTSUP if comp device does not support the comp transform.
190 * - Returns -ENOMEM if the private stream could not be allocated.
192 typedef int (*compressdev_stream_create_t)(struct rte_compressdev *dev,
193 const struct rte_comp_xform *xform, void **stream);
196 * Free driver private stream data.
201 * handle of pmd's private stream data
204 * - <0 in error cases
205 * - Returns -EINVAL if input parameters are invalid.
206 * - Returns -ENOTSUP if comp device does not support STATEFUL operations.
207 * - Returns -EBUSY if can't free stream as there are inflight operations
209 typedef int (*compressdev_stream_free_t)(struct rte_compressdev *dev,
213 * Create driver private_xform data.
219 * @param private_xform
220 * ptr where handle of pmd's private_xform data should be stored
222 * - if successful returns 0
223 * and valid private_xform handle
224 * - <0 in error cases
225 * - Returns -EINVAL if input parameters are invalid.
226 * - Returns -ENOTSUP if comp device does not support the comp transform.
227 * - Returns -ENOMEM if the private_xform could not be allocated.
229 typedef int (*compressdev_private_xform_create_t)(struct rte_compressdev *dev,
230 const struct rte_comp_xform *xform, void **private_xform);
233 * Free driver private_xform data.
237 * @param private_xform
238 * handle of pmd's private_xform data
241 * - <0 in error cases
242 * - Returns -EINVAL if input parameters are invalid.
243 * - Returns -EBUSY if can't free private_xform due to inflight operations
245 typedef int (*compressdev_private_xform_free_t)(struct rte_compressdev *dev,
246 void *private_xform);
248 /** comp device operations function pointer table */
249 struct rte_compressdev_ops {
250 compressdev_configure_t dev_configure; /**< Configure device. */
251 compressdev_start_t dev_start; /**< Start device. */
252 compressdev_stop_t dev_stop; /**< Stop device. */
253 compressdev_close_t dev_close; /**< Close device. */
255 compressdev_info_get_t dev_infos_get; /**< Get device info. */
257 compressdev_stats_get_t stats_get;
258 /**< Get device statistics. */
259 compressdev_stats_reset_t stats_reset;
260 /**< Reset device statistics. */
262 compressdev_queue_pair_setup_t queue_pair_setup;
263 /**< Set up a device queue pair. */
264 compressdev_queue_pair_release_t queue_pair_release;
265 /**< Release a queue pair. */
267 compressdev_stream_create_t stream_create;
268 /**< Create a comp stream and initialise its private data. */
269 compressdev_stream_free_t stream_free;
270 /**< Free a comp stream's private data. */
272 compressdev_private_xform_create_t private_xform_create;
273 /**< Create a comp private_xform and initialise its private data. */
274 compressdev_private_xform_free_t private_xform_free;
275 /**< Free a comp private_xform's data. */
281 * Function for internal use by dummy drivers primarily, e.g. ring-based
283 * Allocates a new compressdev slot for an comp device and returns the pointer
284 * to that slot for the driver to use.
287 * Unique identifier name for each device
289 * Socket to allocate resources on
291 * - Slot in the rte_dev_devices array for a new device;
294 struct rte_compressdev *
295 rte_compressdev_pmd_allocate(const char *name, int socket_id);
300 * Function for internal use by dummy drivers primarily, e.g. ring-based
302 * Release the specified compressdev device.
307 * - 0 on success, negative on error
311 rte_compressdev_pmd_release_device(struct rte_compressdev *dev);
317 * PMD assist function to parse initialisation arguments for comp driver
318 * when creating a new comp PMD device instance.
320 * PMD driver should set default values for that PMD before calling function,
321 * these default values will be over-written with successfully parsed values
325 * Parsed PMD initialisation parameters
327 * Input argument string to parse
334 rte_compressdev_pmd_parse_input_args(
335 struct rte_compressdev_pmd_init_params *params,
341 * PMD assist function to provide boiler plate code for comp driver to create
342 * and allocate resources for a new comp PMD device instance.
345 * Compress device name
347 * Base device instance
349 * PMD initialisation parameters
351 * - comp device instance on success
352 * - NULL on creation failure
355 struct rte_compressdev *
356 rte_compressdev_pmd_create(const char *name,
357 struct rte_device *device,
358 size_t private_data_size,
359 struct rte_compressdev_pmd_init_params *params);
364 * PMD assist function to provide boiler plate code for comp driver to
365 * destroy and free resources associated with a comp PMD device instance.
375 rte_compressdev_pmd_destroy(struct rte_compressdev *dev);
381 #endif /* _RTE_COMPRESSDEV_PMD_H_ */