1d30ea906Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause 2d30ea906Sjfb8856606 * Copyright(c) 2017-2018 Intel Corporation 3d30ea906Sjfb8856606 */ 4d30ea906Sjfb8856606 5d30ea906Sjfb8856606 #ifndef _RTE_COMPRESSDEV_H_ 6d30ea906Sjfb8856606 #define _RTE_COMPRESSDEV_H_ 7d30ea906Sjfb8856606 8d30ea906Sjfb8856606 /** 9d30ea906Sjfb8856606 * @file rte_compressdev.h 10d30ea906Sjfb8856606 * 11*0c6bd470Sfengbojiang * RTE Compression Device APIs. 12*0c6bd470Sfengbojiang * 13*0c6bd470Sfengbojiang * @warning 14*0c6bd470Sfengbojiang * @b EXPERIMENTAL: 15*0c6bd470Sfengbojiang * All functions in this file may be changed or removed without prior notice. 16d30ea906Sjfb8856606 * 17d30ea906Sjfb8856606 * Defines comp device APIs for the provisioning of compression operations. 18d30ea906Sjfb8856606 */ 19d30ea906Sjfb8856606 20d30ea906Sjfb8856606 #ifdef __cplusplus 21d30ea906Sjfb8856606 extern "C" { 22d30ea906Sjfb8856606 #endif 23d30ea906Sjfb8856606 24d30ea906Sjfb8856606 #include <rte_common.h> 25d30ea906Sjfb8856606 26d30ea906Sjfb8856606 #include "rte_comp.h" 27d30ea906Sjfb8856606 28d30ea906Sjfb8856606 /** 29d30ea906Sjfb8856606 * Parameter log base 2 range description. 30d30ea906Sjfb8856606 * Final value will be 2^value. 31d30ea906Sjfb8856606 */ 32d30ea906Sjfb8856606 struct rte_param_log2_range { 33d30ea906Sjfb8856606 uint8_t min; /**< Minimum log2 value */ 34d30ea906Sjfb8856606 uint8_t max; /**< Maximum log2 value */ 35d30ea906Sjfb8856606 uint8_t increment; 36d30ea906Sjfb8856606 /**< If a range of sizes are supported, 37d30ea906Sjfb8856606 * this parameter is used to indicate 38d30ea906Sjfb8856606 * increments in base 2 log byte value 39d30ea906Sjfb8856606 * that are supported between the minimum and maximum 40d30ea906Sjfb8856606 */ 41d30ea906Sjfb8856606 }; 42d30ea906Sjfb8856606 43d30ea906Sjfb8856606 /** Structure used to capture a capability of a comp device */ 44d30ea906Sjfb8856606 struct rte_compressdev_capabilities { 45d30ea906Sjfb8856606 enum rte_comp_algorithm algo; 46d30ea906Sjfb8856606 /* Compression algorithm */ 47d30ea906Sjfb8856606 uint64_t comp_feature_flags; 48d30ea906Sjfb8856606 /**< Bitmask of flags for compression service features */ 49d30ea906Sjfb8856606 struct rte_param_log2_range window_size; 50d30ea906Sjfb8856606 /**< Window size range in base two log byte values */ 51d30ea906Sjfb8856606 }; 52d30ea906Sjfb8856606 53d30ea906Sjfb8856606 /** Macro used at end of comp PMD list */ 54d30ea906Sjfb8856606 #define RTE_COMP_END_OF_CAPABILITIES_LIST() \ 55d30ea906Sjfb8856606 { RTE_COMP_ALGO_UNSPECIFIED } 56d30ea906Sjfb8856606 574418919fSjohnjiang __rte_experimental 584418919fSjohnjiang const struct rte_compressdev_capabilities * 59d30ea906Sjfb8856606 rte_compressdev_capability_get(uint8_t dev_id, 60d30ea906Sjfb8856606 enum rte_comp_algorithm algo); 61d30ea906Sjfb8856606 62d30ea906Sjfb8856606 /** 63d30ea906Sjfb8856606 * compression device supported feature flags 64d30ea906Sjfb8856606 * 65d30ea906Sjfb8856606 * @note New features flags should be added to the end of the list 66d30ea906Sjfb8856606 * 67d30ea906Sjfb8856606 * Keep these flags synchronised with rte_compressdev_get_feature_name() 68d30ea906Sjfb8856606 */ 69d30ea906Sjfb8856606 #define RTE_COMPDEV_FF_HW_ACCELERATED (1ULL << 0) 70d30ea906Sjfb8856606 /**< Operations are off-loaded to an external hardware accelerator */ 71d30ea906Sjfb8856606 #define RTE_COMPDEV_FF_CPU_SSE (1ULL << 1) 72d30ea906Sjfb8856606 /**< Utilises CPU SIMD SSE instructions */ 73d30ea906Sjfb8856606 #define RTE_COMPDEV_FF_CPU_AVX (1ULL << 2) 74d30ea906Sjfb8856606 /**< Utilises CPU SIMD AVX instructions */ 75d30ea906Sjfb8856606 #define RTE_COMPDEV_FF_CPU_AVX2 (1ULL << 3) 76d30ea906Sjfb8856606 /**< Utilises CPU SIMD AVX2 instructions */ 77d30ea906Sjfb8856606 #define RTE_COMPDEV_FF_CPU_AVX512 (1ULL << 4) 78d30ea906Sjfb8856606 /**< Utilises CPU SIMD AVX512 instructions */ 79d30ea906Sjfb8856606 #define RTE_COMPDEV_FF_CPU_NEON (1ULL << 5) 80d30ea906Sjfb8856606 /**< Utilises CPU NEON instructions */ 814418919fSjohnjiang #define RTE_COMPDEV_FF_OP_DONE_IN_DEQUEUE (1ULL << 6) 824418919fSjohnjiang /**< A PMD should set this if the bulk of the 834418919fSjohnjiang * processing is done during the dequeue. It should leave it 844418919fSjohnjiang * cleared if the processing is done during the enqueue (default). 854418919fSjohnjiang * Applications can use this as a hint for tuning. 864418919fSjohnjiang */ 87d30ea906Sjfb8856606 88d30ea906Sjfb8856606 /** 89d30ea906Sjfb8856606 * Get the name of a compress device feature flag. 90d30ea906Sjfb8856606 * 91d30ea906Sjfb8856606 * @param flag 92d30ea906Sjfb8856606 * The mask describing the flag 93d30ea906Sjfb8856606 * 94d30ea906Sjfb8856606 * @return 95d30ea906Sjfb8856606 * The name of this flag, or NULL if it's not a valid feature flag. 96d30ea906Sjfb8856606 */ 974418919fSjohnjiang __rte_experimental 984418919fSjohnjiang const char * 99d30ea906Sjfb8856606 rte_compressdev_get_feature_name(uint64_t flag); 100d30ea906Sjfb8856606 101d30ea906Sjfb8856606 /** comp device information */ 102d30ea906Sjfb8856606 struct rte_compressdev_info { 103d30ea906Sjfb8856606 const char *driver_name; /**< Driver name. */ 104d30ea906Sjfb8856606 uint64_t feature_flags; /**< Feature flags */ 105d30ea906Sjfb8856606 const struct rte_compressdev_capabilities *capabilities; 106d30ea906Sjfb8856606 /**< Array of devices supported capabilities */ 107d30ea906Sjfb8856606 uint16_t max_nb_queue_pairs; 108d30ea906Sjfb8856606 /**< Maximum number of queues pairs supported by device. 109d30ea906Sjfb8856606 * (If 0, there is no limit in maximum number of queue pairs) 110d30ea906Sjfb8856606 */ 111d30ea906Sjfb8856606 }; 112d30ea906Sjfb8856606 113d30ea906Sjfb8856606 /** comp device statistics */ 114d30ea906Sjfb8856606 struct rte_compressdev_stats { 115d30ea906Sjfb8856606 uint64_t enqueued_count; 116d30ea906Sjfb8856606 /**< Count of all operations enqueued */ 117d30ea906Sjfb8856606 uint64_t dequeued_count; 118d30ea906Sjfb8856606 /**< Count of all operations dequeued */ 119d30ea906Sjfb8856606 120d30ea906Sjfb8856606 uint64_t enqueue_err_count; 121d30ea906Sjfb8856606 /**< Total error count on operations enqueued */ 122d30ea906Sjfb8856606 uint64_t dequeue_err_count; 123d30ea906Sjfb8856606 /**< Total error count on operations dequeued */ 124d30ea906Sjfb8856606 }; 125d30ea906Sjfb8856606 126d30ea906Sjfb8856606 127d30ea906Sjfb8856606 /** 128d30ea906Sjfb8856606 * Get the device identifier for the named compress device. 129d30ea906Sjfb8856606 * 130d30ea906Sjfb8856606 * @param name 131d30ea906Sjfb8856606 * Device name to select the device structure 132d30ea906Sjfb8856606 * @return 133d30ea906Sjfb8856606 * - Returns compress device identifier on success. 134d30ea906Sjfb8856606 * - Return -1 on failure to find named compress device. 135d30ea906Sjfb8856606 */ 1364418919fSjohnjiang __rte_experimental 1374418919fSjohnjiang int 138d30ea906Sjfb8856606 rte_compressdev_get_dev_id(const char *name); 139d30ea906Sjfb8856606 140d30ea906Sjfb8856606 /** 141d30ea906Sjfb8856606 * Get the compress device name given a device identifier. 142d30ea906Sjfb8856606 * 143d30ea906Sjfb8856606 * @param dev_id 144d30ea906Sjfb8856606 * Compress device identifier 145d30ea906Sjfb8856606 * @return 146d30ea906Sjfb8856606 * - Returns compress device name. 147d30ea906Sjfb8856606 * - Returns NULL if compress device is not present. 148d30ea906Sjfb8856606 */ 1494418919fSjohnjiang __rte_experimental 1504418919fSjohnjiang const char * 151d30ea906Sjfb8856606 rte_compressdev_name_get(uint8_t dev_id); 152d30ea906Sjfb8856606 153d30ea906Sjfb8856606 /** 154d30ea906Sjfb8856606 * Get the total number of compress devices that have been successfully 155d30ea906Sjfb8856606 * initialised. 156d30ea906Sjfb8856606 * 157d30ea906Sjfb8856606 * @return 158d30ea906Sjfb8856606 * - The total number of usable compress devices. 159d30ea906Sjfb8856606 */ 1604418919fSjohnjiang __rte_experimental 1614418919fSjohnjiang uint8_t 162d30ea906Sjfb8856606 rte_compressdev_count(void); 163d30ea906Sjfb8856606 164d30ea906Sjfb8856606 /** 165d30ea906Sjfb8856606 * Get number and identifiers of attached comp devices that 166d30ea906Sjfb8856606 * use the same compress driver. 167d30ea906Sjfb8856606 * 168d30ea906Sjfb8856606 * @param driver_name 169d30ea906Sjfb8856606 * Driver name 170d30ea906Sjfb8856606 * @param devices 171d30ea906Sjfb8856606 * Output devices identifiers 172d30ea906Sjfb8856606 * @param nb_devices 173d30ea906Sjfb8856606 * Maximal number of devices 174d30ea906Sjfb8856606 * 175d30ea906Sjfb8856606 * @return 176d30ea906Sjfb8856606 * Returns number of attached compress devices. 177d30ea906Sjfb8856606 */ 1784418919fSjohnjiang __rte_experimental 1794418919fSjohnjiang uint8_t 180d30ea906Sjfb8856606 rte_compressdev_devices_get(const char *driver_name, uint8_t *devices, 181d30ea906Sjfb8856606 uint8_t nb_devices); 182d30ea906Sjfb8856606 183d30ea906Sjfb8856606 /* 184d30ea906Sjfb8856606 * Return the NUMA socket to which a device is connected. 185d30ea906Sjfb8856606 * 186d30ea906Sjfb8856606 * @param dev_id 187d30ea906Sjfb8856606 * Compress device identifier 188d30ea906Sjfb8856606 * @return 189d30ea906Sjfb8856606 * The NUMA socket id to which the device is connected or 190d30ea906Sjfb8856606 * a default of zero if the socket could not be determined. 191d30ea906Sjfb8856606 * -1 if returned is the dev_id value is out of range. 192d30ea906Sjfb8856606 */ 1934418919fSjohnjiang __rte_experimental 1944418919fSjohnjiang int 195d30ea906Sjfb8856606 rte_compressdev_socket_id(uint8_t dev_id); 196d30ea906Sjfb8856606 197d30ea906Sjfb8856606 /** Compress device configuration structure */ 198d30ea906Sjfb8856606 struct rte_compressdev_config { 199d30ea906Sjfb8856606 int socket_id; 200d30ea906Sjfb8856606 /**< Socket on which to allocate resources */ 201d30ea906Sjfb8856606 uint16_t nb_queue_pairs; 202d30ea906Sjfb8856606 /**< Total number of queue pairs to configure on a device */ 203d30ea906Sjfb8856606 uint16_t max_nb_priv_xforms; 204d30ea906Sjfb8856606 /**< Max number of private_xforms which will be created on the device */ 205d30ea906Sjfb8856606 uint16_t max_nb_streams; 206d30ea906Sjfb8856606 /**< Max number of streams which will be created on the device */ 207d30ea906Sjfb8856606 }; 208d30ea906Sjfb8856606 209d30ea906Sjfb8856606 /** 210d30ea906Sjfb8856606 * Configure a device. 211d30ea906Sjfb8856606 * 212d30ea906Sjfb8856606 * This function must be invoked first before any other function in the 213d30ea906Sjfb8856606 * API. This function can also be re-invoked when a device is in the 214d30ea906Sjfb8856606 * stopped state. 215d30ea906Sjfb8856606 * 216d30ea906Sjfb8856606 * @param dev_id 217d30ea906Sjfb8856606 * Compress device identifier 218d30ea906Sjfb8856606 * @param config 219d30ea906Sjfb8856606 * The compress device configuration 220d30ea906Sjfb8856606 * @return 221d30ea906Sjfb8856606 * - 0: Success, device configured. 222d30ea906Sjfb8856606 * - <0: Error code returned by the driver configuration function. 223d30ea906Sjfb8856606 */ 2244418919fSjohnjiang __rte_experimental 2254418919fSjohnjiang int 226d30ea906Sjfb8856606 rte_compressdev_configure(uint8_t dev_id, 227d30ea906Sjfb8856606 struct rte_compressdev_config *config); 228d30ea906Sjfb8856606 229d30ea906Sjfb8856606 /** 230d30ea906Sjfb8856606 * Start a device. 231d30ea906Sjfb8856606 * 232d30ea906Sjfb8856606 * The device start step is called after configuring the device and setting up 233d30ea906Sjfb8856606 * its queue pairs. 234d30ea906Sjfb8856606 * On success, data-path functions exported by the API (enqueue/dequeue, etc) 235d30ea906Sjfb8856606 * can be invoked. 236d30ea906Sjfb8856606 * 237d30ea906Sjfb8856606 * @param dev_id 238d30ea906Sjfb8856606 * Compress device identifier 239d30ea906Sjfb8856606 * @return 240d30ea906Sjfb8856606 * - 0: Success, device started. 241d30ea906Sjfb8856606 * - <0: Error code of the driver device start function. 242d30ea906Sjfb8856606 */ 2434418919fSjohnjiang __rte_experimental 2444418919fSjohnjiang int 245d30ea906Sjfb8856606 rte_compressdev_start(uint8_t dev_id); 246d30ea906Sjfb8856606 247d30ea906Sjfb8856606 /** 248d30ea906Sjfb8856606 * Stop a device. The device can be restarted with a call to 249d30ea906Sjfb8856606 * rte_compressdev_start() 250d30ea906Sjfb8856606 * 251d30ea906Sjfb8856606 * @param dev_id 252d30ea906Sjfb8856606 * Compress device identifier 253d30ea906Sjfb8856606 */ 2544418919fSjohnjiang __rte_experimental 2554418919fSjohnjiang void 256d30ea906Sjfb8856606 rte_compressdev_stop(uint8_t dev_id); 257d30ea906Sjfb8856606 258d30ea906Sjfb8856606 /** 259d30ea906Sjfb8856606 * Close an device. 260d30ea906Sjfb8856606 * The memory allocated in the device gets freed. 261d30ea906Sjfb8856606 * After calling this function, in order to use 262d30ea906Sjfb8856606 * the device again, it is required to 263d30ea906Sjfb8856606 * configure the device again. 264d30ea906Sjfb8856606 * 265d30ea906Sjfb8856606 * @param dev_id 266d30ea906Sjfb8856606 * Compress device identifier 267d30ea906Sjfb8856606 * 268d30ea906Sjfb8856606 * @return 269d30ea906Sjfb8856606 * - 0 on successfully closing device 270d30ea906Sjfb8856606 * - <0 on failure to close device 271d30ea906Sjfb8856606 */ 2724418919fSjohnjiang __rte_experimental 2734418919fSjohnjiang int 274d30ea906Sjfb8856606 rte_compressdev_close(uint8_t dev_id); 275d30ea906Sjfb8856606 276d30ea906Sjfb8856606 /** 277d30ea906Sjfb8856606 * Allocate and set up a receive queue pair for a device. 278d30ea906Sjfb8856606 * This should only be called when the device is stopped. 279d30ea906Sjfb8856606 * 280d30ea906Sjfb8856606 * 281d30ea906Sjfb8856606 * @param dev_id 282d30ea906Sjfb8856606 * Compress device identifier 283d30ea906Sjfb8856606 * @param queue_pair_id 284d30ea906Sjfb8856606 * The index of the queue pairs to set up. The 285d30ea906Sjfb8856606 * value must be in the range [0, nb_queue_pair - 1] 286d30ea906Sjfb8856606 * previously supplied to rte_compressdev_configure() 287d30ea906Sjfb8856606 * @param max_inflight_ops 288d30ea906Sjfb8856606 * Max number of ops which the qp will have to 289d30ea906Sjfb8856606 * accommodate simultaneously 290d30ea906Sjfb8856606 * @param socket_id 291d30ea906Sjfb8856606 * The *socket_id* argument is the socket identifier 292d30ea906Sjfb8856606 * in case of NUMA. The value can be *SOCKET_ID_ANY* 293d30ea906Sjfb8856606 * if there is no NUMA constraint for the DMA memory 294d30ea906Sjfb8856606 * allocated for the receive queue pair 295d30ea906Sjfb8856606 * @return 296d30ea906Sjfb8856606 * - 0: Success, queue pair correctly set up. 297d30ea906Sjfb8856606 * - <0: Queue pair configuration failed 298d30ea906Sjfb8856606 */ 2994418919fSjohnjiang __rte_experimental 3004418919fSjohnjiang int 301d30ea906Sjfb8856606 rte_compressdev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, 302d30ea906Sjfb8856606 uint32_t max_inflight_ops, int socket_id); 303d30ea906Sjfb8856606 304d30ea906Sjfb8856606 /** 305d30ea906Sjfb8856606 * Get the number of queue pairs on a specific comp device 306d30ea906Sjfb8856606 * 307d30ea906Sjfb8856606 * @param dev_id 308d30ea906Sjfb8856606 * Compress device identifier 309d30ea906Sjfb8856606 * @return 310d30ea906Sjfb8856606 * - The number of configured queue pairs. 311d30ea906Sjfb8856606 */ 3124418919fSjohnjiang __rte_experimental 3134418919fSjohnjiang uint16_t 314d30ea906Sjfb8856606 rte_compressdev_queue_pair_count(uint8_t dev_id); 315d30ea906Sjfb8856606 316d30ea906Sjfb8856606 317d30ea906Sjfb8856606 /** 318d30ea906Sjfb8856606 * Retrieve the general I/O statistics of a device. 319d30ea906Sjfb8856606 * 320d30ea906Sjfb8856606 * @param dev_id 321d30ea906Sjfb8856606 * The identifier of the device 322d30ea906Sjfb8856606 * @param stats 323d30ea906Sjfb8856606 * A pointer to a structure of type 324d30ea906Sjfb8856606 * *rte_compressdev_stats* to be filled with the 325d30ea906Sjfb8856606 * values of device counters 326d30ea906Sjfb8856606 * @return 327d30ea906Sjfb8856606 * - Zero if successful. 328d30ea906Sjfb8856606 * - Non-zero otherwise. 329d30ea906Sjfb8856606 */ 3304418919fSjohnjiang __rte_experimental 3314418919fSjohnjiang int 332d30ea906Sjfb8856606 rte_compressdev_stats_get(uint8_t dev_id, struct rte_compressdev_stats *stats); 333d30ea906Sjfb8856606 334d30ea906Sjfb8856606 /** 335d30ea906Sjfb8856606 * Reset the general I/O statistics of a device. 336d30ea906Sjfb8856606 * 337d30ea906Sjfb8856606 * @param dev_id 338d30ea906Sjfb8856606 * The identifier of the device. 339d30ea906Sjfb8856606 */ 3404418919fSjohnjiang __rte_experimental 3414418919fSjohnjiang void 342d30ea906Sjfb8856606 rte_compressdev_stats_reset(uint8_t dev_id); 343d30ea906Sjfb8856606 344d30ea906Sjfb8856606 /** 345d30ea906Sjfb8856606 * Retrieve the contextual information of a device. 346d30ea906Sjfb8856606 * 347d30ea906Sjfb8856606 * @param dev_id 348d30ea906Sjfb8856606 * Compress device identifier 349d30ea906Sjfb8856606 * @param dev_info 350d30ea906Sjfb8856606 * A pointer to a structure of type *rte_compressdev_info* 351d30ea906Sjfb8856606 * to be filled with the contextual information of the device 352d30ea906Sjfb8856606 * 353d30ea906Sjfb8856606 * @note The capabilities field of dev_info is set to point to the first 354d30ea906Sjfb8856606 * element of an array of struct rte_compressdev_capabilities. 355d30ea906Sjfb8856606 * The element after the last valid element has it's op field set to 356d30ea906Sjfb8856606 * RTE_COMP_ALGO_LIST_END. 357d30ea906Sjfb8856606 */ 3584418919fSjohnjiang __rte_experimental 3594418919fSjohnjiang void 360d30ea906Sjfb8856606 rte_compressdev_info_get(uint8_t dev_id, struct rte_compressdev_info *dev_info); 361d30ea906Sjfb8856606 362d30ea906Sjfb8856606 /** 363d30ea906Sjfb8856606 * 364d30ea906Sjfb8856606 * Dequeue a burst of processed compression operations from a queue on the comp 365d30ea906Sjfb8856606 * device. The dequeued operation are stored in *rte_comp_op* structures 366d30ea906Sjfb8856606 * whose pointers are supplied in the *ops* array. 367d30ea906Sjfb8856606 * 368d30ea906Sjfb8856606 * The rte_compressdev_dequeue_burst() function returns the number of ops 369d30ea906Sjfb8856606 * actually dequeued, which is the number of *rte_comp_op* data structures 370d30ea906Sjfb8856606 * effectively supplied into the *ops* array. 371d30ea906Sjfb8856606 * 372d30ea906Sjfb8856606 * A return value equal to *nb_ops* indicates that the queue contained 373d30ea906Sjfb8856606 * at least *nb_ops* operations, and this is likely to signify that other 374d30ea906Sjfb8856606 * processed operations remain in the devices output queue. Applications 375d30ea906Sjfb8856606 * implementing a "retrieve as many processed operations as possible" policy 376d30ea906Sjfb8856606 * can check this specific case and keep invoking the 377d30ea906Sjfb8856606 * rte_compressdev_dequeue_burst() function until a value less than 378d30ea906Sjfb8856606 * *nb_ops* is returned. 379d30ea906Sjfb8856606 * 380d30ea906Sjfb8856606 * The rte_compressdev_dequeue_burst() function does not provide any error 381d30ea906Sjfb8856606 * notification to avoid the corresponding overhead. 382d30ea906Sjfb8856606 * 383d30ea906Sjfb8856606 * @note: operation ordering is not maintained within the queue pair. 384d30ea906Sjfb8856606 * 385d30ea906Sjfb8856606 * @note: In case op status = OUT_OF_SPACE_TERMINATED, op.consumed=0 and the 386d30ea906Sjfb8856606 * op must be resubmitted with the same input data and a larger output buffer. 387d30ea906Sjfb8856606 * op.produced is usually 0, but in decompression cases a PMD may return > 0 388d30ea906Sjfb8856606 * and the application may find it useful to inspect that data. 389d30ea906Sjfb8856606 * This status is only returned on STATELESS ops. 390d30ea906Sjfb8856606 * 391d30ea906Sjfb8856606 * @note: In case op status = OUT_OF_SPACE_RECOVERABLE, op.produced can be used 392d30ea906Sjfb8856606 * and next op in stream should continue on from op.consumed+1 with a fresh 393d30ea906Sjfb8856606 * output buffer. 394d30ea906Sjfb8856606 * Consumed=0, produced=0 is an unusual but allowed case. There may be useful 395d30ea906Sjfb8856606 * state/history stored in the PMD, even though no output was produced yet. 396d30ea906Sjfb8856606 * 397d30ea906Sjfb8856606 * 398d30ea906Sjfb8856606 * @param dev_id 399d30ea906Sjfb8856606 * Compress device identifier 400d30ea906Sjfb8856606 * @param qp_id 401d30ea906Sjfb8856606 * The index of the queue pair from which to retrieve 402d30ea906Sjfb8856606 * processed operations. The value must be in the range 403d30ea906Sjfb8856606 * [0, nb_queue_pair - 1] previously supplied to 404d30ea906Sjfb8856606 * rte_compressdev_configure() 405d30ea906Sjfb8856606 * @param ops 406d30ea906Sjfb8856606 * The address of an array of pointers to 407d30ea906Sjfb8856606 * *rte_comp_op* structures that must be 408d30ea906Sjfb8856606 * large enough to store *nb_ops* pointers in it 409d30ea906Sjfb8856606 * @param nb_ops 410d30ea906Sjfb8856606 * The maximum number of operations to dequeue 411d30ea906Sjfb8856606 * @return 412d30ea906Sjfb8856606 * - The number of operations actually dequeued, which is the number 413d30ea906Sjfb8856606 * of pointers to *rte_comp_op* structures effectively supplied to the 414d30ea906Sjfb8856606 * *ops* array. 415d30ea906Sjfb8856606 */ 4164418919fSjohnjiang __rte_experimental 4174418919fSjohnjiang uint16_t 418d30ea906Sjfb8856606 rte_compressdev_dequeue_burst(uint8_t dev_id, uint16_t qp_id, 419d30ea906Sjfb8856606 struct rte_comp_op **ops, uint16_t nb_ops); 420d30ea906Sjfb8856606 421d30ea906Sjfb8856606 /** 422d30ea906Sjfb8856606 * Enqueue a burst of operations for processing on a compression device. 423d30ea906Sjfb8856606 * 424d30ea906Sjfb8856606 * The rte_compressdev_enqueue_burst() function is invoked to place 425d30ea906Sjfb8856606 * comp operations on the queue *qp_id* of the device designated by 426d30ea906Sjfb8856606 * its *dev_id*. 427d30ea906Sjfb8856606 * 428d30ea906Sjfb8856606 * The *nb_ops* parameter is the number of operations to process which are 429d30ea906Sjfb8856606 * supplied in the *ops* array of *rte_comp_op* structures. 430d30ea906Sjfb8856606 * 431d30ea906Sjfb8856606 * The rte_compressdev_enqueue_burst() function returns the number of 432d30ea906Sjfb8856606 * operations it actually enqueued for processing. A return value equal to 433d30ea906Sjfb8856606 * *nb_ops* means that all packets have been enqueued. 434d30ea906Sjfb8856606 * 435d30ea906Sjfb8856606 * @note All compression operations are Out-of-place (OOP) operations, 436d30ea906Sjfb8856606 * as the size of the output data is different to the size of the input data. 437d30ea906Sjfb8856606 * 438d30ea906Sjfb8856606 * @note The rte_comp_op contains both input and output parameters and is the 439d30ea906Sjfb8856606 * vehicle for the application to pass data into and out of the PMD. While an 440d30ea906Sjfb8856606 * op is inflight, i.e. once it has been enqueued, the private_xform or stream 441d30ea906Sjfb8856606 * attached to it and any mbufs or memory referenced by it should not be altered 442d30ea906Sjfb8856606 * or freed by the application. The PMD may use or change some of this data at 443d30ea906Sjfb8856606 * any time until it has been returned in a dequeue operation. 444d30ea906Sjfb8856606 * 445d30ea906Sjfb8856606 * @note The flush flag only applies to operations which return SUCCESS. 446d30ea906Sjfb8856606 * In OUT_OF_SPACE cases whether STATEFUL or STATELESS, data in dest buffer 447d30ea906Sjfb8856606 * is as if flush flag was FLUSH_NONE. 448d30ea906Sjfb8856606 * @note flush flag only applies in compression direction. It has no meaning 449d30ea906Sjfb8856606 * for decompression. 450d30ea906Sjfb8856606 * @note: operation ordering is not maintained within the queue pair. 451d30ea906Sjfb8856606 * 452d30ea906Sjfb8856606 * @param dev_id 453d30ea906Sjfb8856606 * Compress device identifier 454d30ea906Sjfb8856606 * @param qp_id 455d30ea906Sjfb8856606 * The index of the queue pair on which operations 456d30ea906Sjfb8856606 * are to be enqueued for processing. The value 457d30ea906Sjfb8856606 * must be in the range [0, nb_queue_pairs - 1] 458d30ea906Sjfb8856606 * previously supplied to *rte_compressdev_configure* 459d30ea906Sjfb8856606 * @param ops 460d30ea906Sjfb8856606 * The address of an array of *nb_ops* pointers 461d30ea906Sjfb8856606 * to *rte_comp_op* structures which contain 462d30ea906Sjfb8856606 * the operations to be processed 463d30ea906Sjfb8856606 * @param nb_ops 464d30ea906Sjfb8856606 * The number of operations to process 465d30ea906Sjfb8856606 * @return 466d30ea906Sjfb8856606 * The number of operations actually enqueued on the device. The return 467d30ea906Sjfb8856606 * value can be less than the value of the *nb_ops* parameter when the 468d30ea906Sjfb8856606 * comp devices queue is full or if invalid parameters are specified in 469d30ea906Sjfb8856606 * a *rte_comp_op*. 470d30ea906Sjfb8856606 */ 4714418919fSjohnjiang __rte_experimental 4724418919fSjohnjiang uint16_t 473d30ea906Sjfb8856606 rte_compressdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id, 474d30ea906Sjfb8856606 struct rte_comp_op **ops, uint16_t nb_ops); 475d30ea906Sjfb8856606 476d30ea906Sjfb8856606 /** 477d30ea906Sjfb8856606 * This should alloc a stream from the device's mempool and initialise it. 478d30ea906Sjfb8856606 * The application should call this API when setting up for the stateful 479d30ea906Sjfb8856606 * processing of a set of data on a device. The API can be called multiple 480d30ea906Sjfb8856606 * times to set up a stream for each data set. The handle returned is only for 481d30ea906Sjfb8856606 * use with ops of op_type STATEFUL and must be passed to the PMD 482d30ea906Sjfb8856606 * with every op in the data stream 483d30ea906Sjfb8856606 * 484d30ea906Sjfb8856606 * @param dev_id 485d30ea906Sjfb8856606 * Compress device identifier 486d30ea906Sjfb8856606 * @param xform 487d30ea906Sjfb8856606 * xform data 488d30ea906Sjfb8856606 * @param stream 489d30ea906Sjfb8856606 * Pointer to where PMD's private stream handle should be stored 490d30ea906Sjfb8856606 * 491d30ea906Sjfb8856606 * @return 492d30ea906Sjfb8856606 * - 0 if successful and valid stream handle 493d30ea906Sjfb8856606 * - <0 in error cases 494d30ea906Sjfb8856606 * - Returns -EINVAL if input parameters are invalid. 495d30ea906Sjfb8856606 * - Returns -ENOTSUP if comp device does not support STATEFUL operations. 496d30ea906Sjfb8856606 * - Returns -ENOTSUP if comp device does not support the comp transform. 497d30ea906Sjfb8856606 * - Returns -ENOMEM if the private stream could not be allocated. 498d30ea906Sjfb8856606 * 499d30ea906Sjfb8856606 */ 5004418919fSjohnjiang __rte_experimental 5014418919fSjohnjiang int 502d30ea906Sjfb8856606 rte_compressdev_stream_create(uint8_t dev_id, 503d30ea906Sjfb8856606 const struct rte_comp_xform *xform, 504d30ea906Sjfb8856606 void **stream); 505d30ea906Sjfb8856606 506d30ea906Sjfb8856606 /** 507d30ea906Sjfb8856606 * This should clear the stream and return it to the device's mempool. 508d30ea906Sjfb8856606 * 509d30ea906Sjfb8856606 * @param dev_id 510d30ea906Sjfb8856606 * Compress device identifier 511d30ea906Sjfb8856606 * 512d30ea906Sjfb8856606 * @param stream 513d30ea906Sjfb8856606 * PMD's private stream data 514d30ea906Sjfb8856606 * 515d30ea906Sjfb8856606 * @return 516d30ea906Sjfb8856606 * - 0 if successful 517d30ea906Sjfb8856606 * - <0 in error cases 518d30ea906Sjfb8856606 * - Returns -EINVAL if input parameters are invalid. 519d30ea906Sjfb8856606 * - Returns -ENOTSUP if comp device does not support STATEFUL operations. 520d30ea906Sjfb8856606 * - Returns -EBUSY if can't free stream as there are inflight operations 521d30ea906Sjfb8856606 */ 5224418919fSjohnjiang __rte_experimental 5234418919fSjohnjiang int 524d30ea906Sjfb8856606 rte_compressdev_stream_free(uint8_t dev_id, void *stream); 525d30ea906Sjfb8856606 526d30ea906Sjfb8856606 /** 527d30ea906Sjfb8856606 * This should alloc a private_xform from the device's mempool and initialise 528d30ea906Sjfb8856606 * it. The application should call this API when setting up for stateless 529d30ea906Sjfb8856606 * processing on a device. If it returns non-shareable, then the appl cannot 530d30ea906Sjfb8856606 * share this handle with multiple in-flight ops and should call this API again 531d30ea906Sjfb8856606 * to get a separate handle for every in-flight op. 532d30ea906Sjfb8856606 * The handle returned is only valid for use with ops of op_type STATELESS. 533d30ea906Sjfb8856606 * 534d30ea906Sjfb8856606 * @param dev_id 535d30ea906Sjfb8856606 * Compress device identifier 536d30ea906Sjfb8856606 * @param xform 537d30ea906Sjfb8856606 * xform data 538d30ea906Sjfb8856606 * @param private_xform 539d30ea906Sjfb8856606 * Pointer to where PMD's private_xform handle should be stored 540d30ea906Sjfb8856606 * 541d30ea906Sjfb8856606 * @return 542d30ea906Sjfb8856606 * - if successful returns 0 543d30ea906Sjfb8856606 * and valid private_xform handle 544d30ea906Sjfb8856606 * - <0 in error cases 545d30ea906Sjfb8856606 * - Returns -EINVAL if input parameters are invalid. 546d30ea906Sjfb8856606 * - Returns -ENOTSUP if comp device does not support the comp transform. 547d30ea906Sjfb8856606 * - Returns -ENOMEM if the private_xform could not be allocated. 548d30ea906Sjfb8856606 */ 5494418919fSjohnjiang __rte_experimental 5504418919fSjohnjiang int 551d30ea906Sjfb8856606 rte_compressdev_private_xform_create(uint8_t dev_id, 552d30ea906Sjfb8856606 const struct rte_comp_xform *xform, 553d30ea906Sjfb8856606 void **private_xform); 554d30ea906Sjfb8856606 555d30ea906Sjfb8856606 /** 556d30ea906Sjfb8856606 * This should clear the private_xform and return it to the device's mempool. 557d30ea906Sjfb8856606 * It is the application's responsibility to ensure that private_xform data 558d30ea906Sjfb8856606 * is not cleared while there are still in-flight operations using it. 559d30ea906Sjfb8856606 * 560d30ea906Sjfb8856606 * @param dev_id 561d30ea906Sjfb8856606 * Compress device identifier 562d30ea906Sjfb8856606 * 563d30ea906Sjfb8856606 * @param private_xform 564d30ea906Sjfb8856606 * PMD's private_xform data 565d30ea906Sjfb8856606 * 566d30ea906Sjfb8856606 * @return 567d30ea906Sjfb8856606 * - 0 if successful 568d30ea906Sjfb8856606 * - <0 in error cases 569d30ea906Sjfb8856606 * - Returns -EINVAL if input parameters are invalid. 570d30ea906Sjfb8856606 */ 5714418919fSjohnjiang __rte_experimental 5724418919fSjohnjiang int 573d30ea906Sjfb8856606 rte_compressdev_private_xform_free(uint8_t dev_id, void *private_xform); 574d30ea906Sjfb8856606 575d30ea906Sjfb8856606 #ifdef __cplusplus 576d30ea906Sjfb8856606 } 577d30ea906Sjfb8856606 #endif 578d30ea906Sjfb8856606 579d30ea906Sjfb8856606 #endif /* _RTE_COMPRESSDEV_H_ */ 580