compressdev: add compression specific data
[dpdk.git] / lib / librte_compressdev / rte_compressdev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017-2018 Intel Corporation
3  */
4
5 #ifndef _RTE_COMPRESSDEV_H_
6 #define _RTE_COMPRESSDEV_H_
7
8 /**
9  * @file rte_compressdev.h
10  *
11  * RTE Compression Device APIs
12  *
13  * Defines comp device APIs for the provisioning of compression operations.
14  */
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 #include <rte_common.h>
21
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)
28          */
29 };
30
31 /**
32  * Get the compress device name given a device identifier.
33  *
34  * @param dev_id
35  *   Compress device identifier
36  * @return
37  *   - Returns compress device name.
38  *   - Returns NULL if compress device is not present.
39  */
40 const char * __rte_experimental
41 rte_compressdev_name_get(uint8_t dev_id);
42
43 /**
44  * Get the total number of compress devices that have been successfully
45  * initialised.
46  *
47  * @return
48  *   - The total number of usable compress devices.
49  */
50 uint8_t __rte_experimental
51 rte_compressdev_count(void);
52
53 /**
54  * Get number and identifiers of attached comp devices that
55  * use the same compress driver.
56  *
57  * @param driver_name
58  *   Driver name
59  * @param devices
60  *   Output devices identifiers
61  * @param nb_devices
62  *   Maximal number of devices
63  *
64  * @return
65  *   Returns number of attached compress devices.
66  */
67 uint8_t __rte_experimental
68 rte_compressdev_devices_get(const char *driver_name, uint8_t *devices,
69                 uint8_t nb_devices);
70
71 /*
72  * Return the NUMA socket to which a device is connected.
73  *
74  * @param dev_id
75  *   Compress device identifier
76  * @return
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.
80  */
81 int __rte_experimental
82 rte_compressdev_socket_id(uint8_t dev_id);
83
84 /** Compress device configuration structure */
85 struct rte_compressdev_config {
86         int socket_id;
87         /**< Socket on which to allocate resources */
88         uint16_t nb_queue_pairs;
89         /**< Total number of queue pairs to configure on a device */
90 };
91
92 /**
93  * Configure a device.
94  *
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
97  * stopped state.
98  *
99  * @param dev_id
100  *   Compress device identifier
101  * @param config
102  *   The compress device configuration
103  * @return
104  *   - 0: Success, device configured.
105  *   - <0: Error code returned by the driver configuration function.
106  */
107 int __rte_experimental
108 rte_compressdev_configure(uint8_t dev_id,
109                         struct rte_compressdev_config *config);
110
111 /**
112  * Start a device.
113  *
114  * The device start step is called after configuring the device and setting up
115  * its queue pairs.
116  * On success, data-path functions exported by the API (enqueue/dequeue, etc)
117  * can be invoked.
118  *
119  * @param dev_id
120  *   Compress device identifier
121  * @return
122  *   - 0: Success, device started.
123  *   - <0: Error code of the driver device start function.
124  */
125 int __rte_experimental
126 rte_compressdev_start(uint8_t dev_id);
127
128 /**
129  * Stop a device. The device can be restarted with a call to
130  * rte_compressdev_start()
131  *
132  * @param dev_id
133  *   Compress device identifier
134  */
135 void __rte_experimental
136 rte_compressdev_stop(uint8_t dev_id);
137
138 /**
139  * Close an device.
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.
144  *
145  * @param dev_id
146  *   Compress device identifier
147  *
148  * @return
149  *  - 0 on successfully closing device
150  *  - <0 on failure to close device
151  */
152 int __rte_experimental
153 rte_compressdev_close(uint8_t dev_id);
154
155 /**
156  * Allocate and set up a receive queue pair for a device.
157  * This should only be called when the device is stopped.
158  *
159  *
160  * @param dev_id
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
169  * @param socket_id
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
174  * @return
175  *   - 0: Success, queue pair correctly set up.
176  *   - <0: Queue pair configuration failed
177  */
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);
181
182 /**
183  * Get the number of queue pairs on a specific comp device
184  *
185  * @param dev_id
186  *   Compress device identifier
187  * @return
188  *   - The number of configured queue pairs.
189  */
190 uint16_t __rte_experimental
191 rte_compressdev_queue_pair_count(uint8_t dev_id);
192
193 /**
194  * Retrieve the contextual information of a device.
195  *
196  * @param dev_id
197  *   Compress device identifier
198  * @param dev_info
199  *   A pointer to a structure of type *rte_compressdev_info*
200  *   to be filled with the contextual information of the device
201  *
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.
206  */
207 void __rte_experimental
208 rte_compressdev_info_get(uint8_t dev_id, struct rte_compressdev_info *dev_info);
209
210 #ifdef __cplusplus
211 }
212 #endif
213
214 #endif /* _RTE_COMPRESSDEV_H_ */