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);
128 /** comp device operations function pointer table */
129 struct rte_compressdev_ops {
130 compressdev_configure_t dev_configure; /**< Configure device. */
131 compressdev_start_t dev_start; /**< Start device. */
132 compressdev_stop_t dev_stop; /**< Stop device. */
133 compressdev_close_t dev_close; /**< Close device. */
135 compressdev_info_get_t dev_infos_get; /**< Get device info. */
141 * Function for internal use by dummy drivers primarily, e.g. ring-based
143 * Allocates a new compressdev slot for an comp device and returns the pointer
144 * to that slot for the driver to use.
147 * Unique identifier name for each device
149 * Socket to allocate resources on
151 * - Slot in the rte_dev_devices array for a new device;
153 struct rte_compressdev * __rte_experimental
154 rte_compressdev_pmd_allocate(const char *name, int socket_id);
159 * Function for internal use by dummy drivers primarily, e.g. ring-based
161 * Release the specified compressdev device.
166 * - 0 on success, negative on error
168 int __rte_experimental
169 rte_compressdev_pmd_release_device(struct rte_compressdev *dev);
175 * PMD assist function to parse initialisation arguments for comp driver
176 * when creating a new comp PMD device instance.
178 * PMD driver should set default values for that PMD before calling function,
179 * these default values will be over-written with successfully parsed values
183 * Parsed PMD initialisation parameters
185 * Input argument string to parse
190 int __rte_experimental
191 rte_compressdev_pmd_parse_input_args(
192 struct rte_compressdev_pmd_init_params *params,
198 * PMD assist function to provide boiler plate code for comp driver to create
199 * and allocate resources for a new comp PMD device instance.
202 * Compress device name
204 * Base device instance
206 * PMD initialisation parameters
208 * - comp device instance on success
209 * - NULL on creation failure
211 struct rte_compressdev * __rte_experimental
212 rte_compressdev_pmd_create(const char *name,
213 struct rte_device *device,
214 size_t private_data_size,
215 struct rte_compressdev_pmd_init_params *params);
220 * PMD assist function to provide boiler plate code for comp driver to
221 * destroy and free resources associated with a comp PMD device instance.
229 int __rte_experimental
230 rte_compressdev_pmd_destroy(struct rte_compressdev *dev);
236 #endif /* _RTE_COMPRESSDEV_PMD_H_ */