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 */
54 /** Pointer to global array of comp devices */
55 extern struct rte_compressdev *rte_compressdevs;
56 /** Pointer to global comp devices data structure */
57 extern struct rte_compressdev_global *rte_compressdev_globals;
60 * Get the rte_compressdev structure device pointer for the named device.
63 * Compress device name
65 * - The rte_compressdev structure pointer for the given device identifier.
67 struct rte_compressdev * __rte_experimental
68 rte_compressdev_pmd_get_named_dev(const char *name);
71 * Definitions of all functions exported by a driver through the
72 * the generic structure of type *comp_dev_ops* supplied in the
73 * *rte_compressdev* structure associated with a device.
77 * Function used to configure device.
82 * Compress device configurations
84 * Returns 0 on success
86 typedef int (*compressdev_configure_t)(struct rte_compressdev *dev,
87 struct rte_compressdev_config *config);
90 * Function used to start a configured device.
95 * Returns 0 on success
97 typedef int (*compressdev_start_t)(struct rte_compressdev *dev);
100 * Function used to stop a configured device.
105 typedef void (*compressdev_stop_t)(struct rte_compressdev *dev);
108 * Function used to close a configured device.
114 * - EAGAIN if can't close as device is busy
116 typedef int (*compressdev_close_t)(struct rte_compressdev *dev);
120 * Function used to get specific information of a device.
125 typedef void (*compressdev_info_get_t)(struct rte_compressdev *dev,
126 struct rte_compressdev_info *dev_info);
129 * Setup a queue pair for a device.
134 * Queue pair identifier
135 * @param max_inflight_ops
136 * Max inflight ops which qp must accommodate
140 * Returns 0 on success.
142 typedef int (*compressdev_queue_pair_setup_t)(struct rte_compressdev *dev,
143 uint16_t qp_id, uint32_t max_inflight_ops, int socket_id);
146 * Release memory resources allocated by given queue pair.
151 * Queue pair identifier
154 * - EAGAIN if can't close as device is busy
156 typedef int (*compressdev_queue_pair_release_t)(struct rte_compressdev *dev,
160 * Get number of available queue pairs of a device.
165 * Returns number of queue pairs on success.
167 typedef uint32_t (*compressdev_queue_pair_count_t)(struct rte_compressdev *dev);
170 * Create driver private_xform data.
176 * @param private_xform
177 * ptr where handle of pmd's private_xform data should be stored
179 * - if successful returns 0
180 * and valid private_xform handle
181 * - <0 in error cases
182 * - Returns -EINVAL if input parameters are invalid.
183 * - Returns -ENOTSUP if comp device does not support the comp transform.
184 * - Returns -ENOMEM if the private_xform could not be allocated.
186 typedef int (*compressdev_private_xform_create_t)(struct rte_compressdev *dev,
187 const struct rte_comp_xform *xform, void **private_xform);
190 * Free driver private_xform data.
194 * @param private_xform
195 * handle of pmd's private_xform data
198 * - <0 in error cases
199 * - Returns -EINVAL if input parameters are invalid.
200 * - Returns -EBUSY if can't free private_xform due to inflight operations
202 typedef int (*compressdev_private_xform_free_t)(struct rte_compressdev *dev,
203 void *private_xform);
205 /** comp device operations function pointer table */
206 struct rte_compressdev_ops {
207 compressdev_configure_t dev_configure; /**< Configure device. */
208 compressdev_start_t dev_start; /**< Start device. */
209 compressdev_stop_t dev_stop; /**< Stop device. */
210 compressdev_close_t dev_close; /**< Close device. */
212 compressdev_info_get_t dev_infos_get; /**< Get device info. */
214 compressdev_queue_pair_setup_t queue_pair_setup;
215 /**< Set up a device queue pair. */
216 compressdev_queue_pair_release_t queue_pair_release;
217 /**< Release a queue pair. */
219 compressdev_private_xform_create_t private_xform_create;
220 /**< Create a comp private_xform and initialise its private data. */
221 compressdev_private_xform_free_t private_xform_free;
222 /**< Free a comp private_xform's data. */
228 * Function for internal use by dummy drivers primarily, e.g. ring-based
230 * Allocates a new compressdev slot for an comp device and returns the pointer
231 * to that slot for the driver to use.
234 * Unique identifier name for each device
236 * Socket to allocate resources on
238 * - Slot in the rte_dev_devices array for a new device;
240 struct rte_compressdev * __rte_experimental
241 rte_compressdev_pmd_allocate(const char *name, int socket_id);
246 * Function for internal use by dummy drivers primarily, e.g. ring-based
248 * Release the specified compressdev device.
253 * - 0 on success, negative on error
255 int __rte_experimental
256 rte_compressdev_pmd_release_device(struct rte_compressdev *dev);
262 * PMD assist function to parse initialisation arguments for comp driver
263 * when creating a new comp PMD device instance.
265 * PMD driver should set default values for that PMD before calling function,
266 * these default values will be over-written with successfully parsed values
270 * Parsed PMD initialisation parameters
272 * Input argument string to parse
277 int __rte_experimental
278 rte_compressdev_pmd_parse_input_args(
279 struct rte_compressdev_pmd_init_params *params,
285 * PMD assist function to provide boiler plate code for comp driver to create
286 * and allocate resources for a new comp PMD device instance.
289 * Compress device name
291 * Base device instance
293 * PMD initialisation parameters
295 * - comp device instance on success
296 * - NULL on creation failure
298 struct rte_compressdev * __rte_experimental
299 rte_compressdev_pmd_create(const char *name,
300 struct rte_device *device,
301 size_t private_data_size,
302 struct rte_compressdev_pmd_init_params *params);
307 * PMD assist function to provide boiler plate code for comp driver to
308 * destroy and free resources associated with a comp PMD device instance.
316 int __rte_experimental
317 rte_compressdev_pmd_destroy(struct rte_compressdev *dev);
323 #endif /* _RTE_COMPRESSDEV_PMD_H_ */