1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017-2018 Intel Corporation
5 #ifndef _RTE_COMPRESSDEV_H_
6 #define _RTE_COMPRESSDEV_H_
9 * @file rte_compressdev.h
11 * RTE Compression Device APIs
13 * Defines comp device APIs for the provisioning of compression operations.
20 #include <rte_common.h>
22 /** comp device information */
23 struct rte_compressdev_info {
24 const char *driver_name; /**< Driver name. */
25 uint16_t max_nb_queue_pairs;
26 /**< Maximum number of queues pairs supported by device.
27 * (If 0, there is no limit in maximum number of queue pairs)
32 * Get the compress device name given a device identifier.
35 * Compress device identifier
37 * - Returns compress device name.
38 * - Returns NULL if compress device is not present.
40 const char * __rte_experimental
41 rte_compressdev_name_get(uint8_t dev_id);
44 * Get the total number of compress devices that have been successfully
48 * - The total number of usable compress devices.
50 uint8_t __rte_experimental
51 rte_compressdev_count(void);
54 * Get number and identifiers of attached comp devices that
55 * use the same compress driver.
60 * Output devices identifiers
62 * Maximal number of devices
65 * Returns number of attached compress devices.
67 uint8_t __rte_experimental
68 rte_compressdev_devices_get(const char *driver_name, uint8_t *devices,
72 * Return the NUMA socket to which a device is connected.
75 * Compress device identifier
77 * The NUMA socket id to which the device is connected or
78 * a default of zero if the socket could not be determined.
79 * -1 if returned is the dev_id value is out of range.
81 int __rte_experimental
82 rte_compressdev_socket_id(uint8_t dev_id);
84 /** Compress device configuration structure */
85 struct rte_compressdev_config {
87 /**< Socket on which to allocate resources */
88 uint16_t nb_queue_pairs;
89 /**< Total number of queue pairs to configure on a device */
95 * This function must be invoked first before any other function in the
96 * API. This function can also be re-invoked when a device is in the
100 * Compress device identifier
102 * The compress device configuration
104 * - 0: Success, device configured.
105 * - <0: Error code returned by the driver configuration function.
107 int __rte_experimental
108 rte_compressdev_configure(uint8_t dev_id,
109 struct rte_compressdev_config *config);
114 * The device start step is called after configuring the device and setting up
116 * On success, data-path functions exported by the API (enqueue/dequeue, etc)
120 * Compress device identifier
122 * - 0: Success, device started.
123 * - <0: Error code of the driver device start function.
125 int __rte_experimental
126 rte_compressdev_start(uint8_t dev_id);
129 * Stop a device. The device can be restarted with a call to
130 * rte_compressdev_start()
133 * Compress device identifier
135 void __rte_experimental
136 rte_compressdev_stop(uint8_t dev_id);
140 * The memory allocated in the device gets freed.
141 * After calling this function, in order to use
142 * the device again, it is required to
143 * configure the device again.
146 * Compress device identifier
149 * - 0 on successfully closing device
150 * - <0 on failure to close device
152 int __rte_experimental
153 rte_compressdev_close(uint8_t dev_id);
156 * Allocate and set up a receive queue pair for a device.
157 * This should only be called when the device is stopped.
161 * Compress device identifier
162 * @param queue_pair_id
163 * The index of the queue pairs to set up. The
164 * value must be in the range [0, nb_queue_pair - 1]
165 * previously supplied to rte_compressdev_configure()
166 * @param max_inflight_ops
167 * Max number of ops which the qp will have to
168 * accommodate simultaneously
170 * The *socket_id* argument is the socket identifier
171 * in case of NUMA. The value can be *SOCKET_ID_ANY*
172 * if there is no NUMA constraint for the DMA memory
173 * allocated for the receive queue pair
175 * - 0: Success, queue pair correctly set up.
176 * - <0: Queue pair configuration failed
178 int __rte_experimental
179 rte_compressdev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
180 uint32_t max_inflight_ops, int socket_id);
183 * Get the number of queue pairs on a specific comp device
186 * Compress device identifier
188 * - The number of configured queue pairs.
190 uint16_t __rte_experimental
191 rte_compressdev_queue_pair_count(uint8_t dev_id);
194 * Retrieve the contextual information of a device.
197 * Compress device identifier
199 * A pointer to a structure of type *rte_compressdev_info*
200 * to be filled with the contextual information of the device
202 * @note The capabilities field of dev_info is set to point to the first
203 * element of an array of struct rte_compressdev_capabilities.
204 * The element after the last valid element has it's op field set to
205 * RTE_COMP_ALGO_LIST_END.
207 void __rte_experimental
208 rte_compressdev_info_get(uint8_t dev_id, struct rte_compressdev_info *dev_info);
214 #endif /* _RTE_COMPRESSDEV_H_ */