1d30ea906Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause 2d30ea906Sjfb8856606 * Copyright(c) 2017-2018 Intel Corporation 3d30ea906Sjfb8856606 */ 4d30ea906Sjfb8856606 5d30ea906Sjfb8856606 #ifndef _RTE_COMP_H_ 6d30ea906Sjfb8856606 #define _RTE_COMP_H_ 7d30ea906Sjfb8856606 8d30ea906Sjfb8856606 /** 9d30ea906Sjfb8856606 * @file rte_comp.h 10d30ea906Sjfb8856606 * 11d30ea906Sjfb8856606 * RTE definitions for Data Compression Service 12d30ea906Sjfb8856606 * 13d30ea906Sjfb8856606 */ 14d30ea906Sjfb8856606 15d30ea906Sjfb8856606 #ifdef __cplusplus 16d30ea906Sjfb8856606 extern "C" { 17d30ea906Sjfb8856606 #endif 18d30ea906Sjfb8856606 19d30ea906Sjfb8856606 #include <rte_mempool.h> 20d30ea906Sjfb8856606 #include <rte_mbuf.h> 21d30ea906Sjfb8856606 22d30ea906Sjfb8856606 /** 23d30ea906Sjfb8856606 * compression service feature flags 24d30ea906Sjfb8856606 * 25d30ea906Sjfb8856606 * @note New features flags should be added to the end of the list 26d30ea906Sjfb8856606 * 27d30ea906Sjfb8856606 * Keep these flags synchronised with rte_comp_get_feature_name() 28d30ea906Sjfb8856606 */ 29d30ea906Sjfb8856606 #define RTE_COMP_FF_STATEFUL_COMPRESSION (1ULL << 0) 30d30ea906Sjfb8856606 /**< Stateful compression is supported */ 31d30ea906Sjfb8856606 #define RTE_COMP_FF_STATEFUL_DECOMPRESSION (1ULL << 1) 32d30ea906Sjfb8856606 /**< Stateful decompression is supported */ 33d30ea906Sjfb8856606 #define RTE_COMP_FF_OOP_SGL_IN_SGL_OUT (1ULL << 2) 34d30ea906Sjfb8856606 /**< Out-of-place Scatter-gather (SGL) buffers, 35d30ea906Sjfb8856606 * with multiple segments, are supported in input and output 36d30ea906Sjfb8856606 */ 37d30ea906Sjfb8856606 #define RTE_COMP_FF_OOP_SGL_IN_LB_OUT (1ULL << 3) 38d30ea906Sjfb8856606 /**< Out-of-place Scatter-gather (SGL) buffers are supported 39d30ea906Sjfb8856606 * in input, combined with linear buffers (LB), with a 40d30ea906Sjfb8856606 * single segment, in output 41d30ea906Sjfb8856606 */ 42d30ea906Sjfb8856606 #define RTE_COMP_FF_OOP_LB_IN_SGL_OUT (1ULL << 4) 43d30ea906Sjfb8856606 /**< Out-of-place Scatter-gather (SGL) buffers are supported 44d30ea906Sjfb8856606 * in output, combined with linear buffers (LB) in input 45d30ea906Sjfb8856606 */ 46d30ea906Sjfb8856606 #define RTE_COMP_FF_ADLER32_CHECKSUM (1ULL << 5) 47d30ea906Sjfb8856606 /**< Adler-32 Checksum is supported */ 48d30ea906Sjfb8856606 #define RTE_COMP_FF_CRC32_CHECKSUM (1ULL << 6) 49d30ea906Sjfb8856606 /**< CRC32 Checksum is supported */ 50d30ea906Sjfb8856606 #define RTE_COMP_FF_CRC32_ADLER32_CHECKSUM (1ULL << 7) 51d30ea906Sjfb8856606 /**< Adler-32/CRC32 Checksum is supported */ 52d30ea906Sjfb8856606 #define RTE_COMP_FF_MULTI_PKT_CHECKSUM (1ULL << 8) 53d30ea906Sjfb8856606 /**< Generation of checksum across multiple stateless packets is supported */ 54d30ea906Sjfb8856606 #define RTE_COMP_FF_SHA1_HASH (1ULL << 9) 55d30ea906Sjfb8856606 /**< SHA1 Hash is supported */ 56d30ea906Sjfb8856606 #define RTE_COMP_FF_SHA2_SHA256_HASH (1ULL << 10) 57d30ea906Sjfb8856606 /**< SHA256 Hash of SHA2 family is supported */ 58d30ea906Sjfb8856606 #define RTE_COMP_FF_NONCOMPRESSED_BLOCKS (1ULL << 11) 59d30ea906Sjfb8856606 /**< Creation of non-compressed blocks using RTE_COMP_LEVEL_NONE is supported */ 60d30ea906Sjfb8856606 #define RTE_COMP_FF_SHAREABLE_PRIV_XFORM (1ULL << 12) 61d30ea906Sjfb8856606 /**< Private xforms created by the PMD can be shared 62d30ea906Sjfb8856606 * across multiple stateless operations. If not set, then app needs 63d30ea906Sjfb8856606 * to create as many priv_xforms as it expects to have stateless 64d30ea906Sjfb8856606 * operations in-flight. 65d30ea906Sjfb8856606 */ 66d30ea906Sjfb8856606 #define RTE_COMP_FF_HUFFMAN_FIXED (1ULL << 13) 67d30ea906Sjfb8856606 /**< Fixed huffman encoding is supported */ 68d30ea906Sjfb8856606 #define RTE_COMP_FF_HUFFMAN_DYNAMIC (1ULL << 14) 69d30ea906Sjfb8856606 /**< Dynamic huffman encoding is supported */ 70d30ea906Sjfb8856606 71d30ea906Sjfb8856606 /** Status of comp operation */ 72d30ea906Sjfb8856606 enum rte_comp_op_status { 73d30ea906Sjfb8856606 RTE_COMP_OP_STATUS_SUCCESS = 0, 74d30ea906Sjfb8856606 /**< Operation completed successfully */ 75d30ea906Sjfb8856606 RTE_COMP_OP_STATUS_NOT_PROCESSED, 76d30ea906Sjfb8856606 /**< Operation has not yet been processed by the device */ 77d30ea906Sjfb8856606 RTE_COMP_OP_STATUS_INVALID_ARGS, 78d30ea906Sjfb8856606 /**< Operation failed due to invalid arguments in request */ 79d30ea906Sjfb8856606 RTE_COMP_OP_STATUS_ERROR, 80d30ea906Sjfb8856606 /**< Error handling operation */ 81d30ea906Sjfb8856606 RTE_COMP_OP_STATUS_INVALID_STATE, 82d30ea906Sjfb8856606 /**< Operation is invoked in invalid state */ 83d30ea906Sjfb8856606 RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED, 84d30ea906Sjfb8856606 /**< Output buffer ran out of space before operation completed. 85d30ea906Sjfb8856606 * Error case. Application must resubmit all data with a larger 86d30ea906Sjfb8856606 * output buffer. 87d30ea906Sjfb8856606 */ 88d30ea906Sjfb8856606 RTE_COMP_OP_STATUS_OUT_OF_SPACE_RECOVERABLE, 89d30ea906Sjfb8856606 /**< Output buffer ran out of space before operation completed, but this 90d30ea906Sjfb8856606 * is not an error case. Output data up to op.produced can be used and 91d30ea906Sjfb8856606 * next op in the stream should continue on from op.consumed+1. 92d30ea906Sjfb8856606 */ 93d30ea906Sjfb8856606 }; 94d30ea906Sjfb8856606 95d30ea906Sjfb8856606 /** Compression Algorithms */ 96d30ea906Sjfb8856606 enum rte_comp_algorithm { 97d30ea906Sjfb8856606 RTE_COMP_ALGO_UNSPECIFIED = 0, 98d30ea906Sjfb8856606 /** No Compression algorithm */ 99d30ea906Sjfb8856606 RTE_COMP_ALGO_NULL, 100d30ea906Sjfb8856606 /**< No compression. 101d30ea906Sjfb8856606 * Pass-through, data is copied unchanged from source buffer to 102d30ea906Sjfb8856606 * destination buffer. 103d30ea906Sjfb8856606 */ 104d30ea906Sjfb8856606 RTE_COMP_ALGO_DEFLATE, 105d30ea906Sjfb8856606 /**< DEFLATE compression algorithm 106d30ea906Sjfb8856606 * https://tools.ietf.org/html/rfc1951 107d30ea906Sjfb8856606 */ 108d30ea906Sjfb8856606 RTE_COMP_ALGO_LZS, 109d30ea906Sjfb8856606 /**< LZS compression algorithm 110d30ea906Sjfb8856606 * https://tools.ietf.org/html/rfc2395 111d30ea906Sjfb8856606 */ 112d30ea906Sjfb8856606 RTE_COMP_ALGO_LIST_END 113d30ea906Sjfb8856606 }; 114d30ea906Sjfb8856606 115d30ea906Sjfb8856606 /** Compression Hash Algorithms */ 116d30ea906Sjfb8856606 enum rte_comp_hash_algorithm { 117d30ea906Sjfb8856606 RTE_COMP_HASH_ALGO_NONE = 0, 118d30ea906Sjfb8856606 /**< No hash */ 119d30ea906Sjfb8856606 RTE_COMP_HASH_ALGO_SHA1, 120d30ea906Sjfb8856606 /**< SHA1 hash algorithm */ 121d30ea906Sjfb8856606 RTE_COMP_HASH_ALGO_SHA2_256, 122d30ea906Sjfb8856606 /**< SHA256 hash algorithm of SHA2 family */ 123d30ea906Sjfb8856606 RTE_COMP_HASH_ALGO_LIST_END 124d30ea906Sjfb8856606 }; 125d30ea906Sjfb8856606 126d30ea906Sjfb8856606 /**< Compression Level. 127d30ea906Sjfb8856606 * The number is interpreted by each PMD differently. However, lower numbers 128d30ea906Sjfb8856606 * give fastest compression, at the expense of compression ratio while 129d30ea906Sjfb8856606 * higher numbers may give better compression ratios but are likely slower. 130d30ea906Sjfb8856606 */ 131d30ea906Sjfb8856606 #define RTE_COMP_LEVEL_PMD_DEFAULT (-1) 132d30ea906Sjfb8856606 /** Use PMD Default */ 133d30ea906Sjfb8856606 #define RTE_COMP_LEVEL_NONE (0) 134d30ea906Sjfb8856606 /** Output uncompressed blocks if supported by the specified algorithm */ 135d30ea906Sjfb8856606 #define RTE_COMP_LEVEL_MIN (1) 136d30ea906Sjfb8856606 /** Use minimum compression level supported by the PMD */ 137d30ea906Sjfb8856606 #define RTE_COMP_LEVEL_MAX (9) 138d30ea906Sjfb8856606 /** Use maximum compression level supported by the PMD */ 139d30ea906Sjfb8856606 140d30ea906Sjfb8856606 /** Compression checksum types */ 141d30ea906Sjfb8856606 enum rte_comp_checksum_type { 142d30ea906Sjfb8856606 RTE_COMP_CHECKSUM_NONE, 143d30ea906Sjfb8856606 /**< No checksum generated */ 144d30ea906Sjfb8856606 RTE_COMP_CHECKSUM_CRC32, 145d30ea906Sjfb8856606 /**< Generates a CRC32 checksum, as used by gzip */ 146d30ea906Sjfb8856606 RTE_COMP_CHECKSUM_ADLER32, 147d30ea906Sjfb8856606 /**< Generates an Adler-32 checksum, as used by zlib */ 148d30ea906Sjfb8856606 RTE_COMP_CHECKSUM_CRC32_ADLER32, 149d30ea906Sjfb8856606 /**< Generates both Adler-32 and CRC32 checksums, concatenated. 150d30ea906Sjfb8856606 * CRC32 is in the lower 32bits, Adler-32 in the upper 32 bits. 151d30ea906Sjfb8856606 */ 152d30ea906Sjfb8856606 }; 153d30ea906Sjfb8856606 154d30ea906Sjfb8856606 155d30ea906Sjfb8856606 /** Compression Huffman Type - used by DEFLATE algorithm */ 156d30ea906Sjfb8856606 enum rte_comp_huffman { 157d30ea906Sjfb8856606 RTE_COMP_HUFFMAN_DEFAULT, 158d30ea906Sjfb8856606 /**< PMD may choose which Huffman codes to use */ 159d30ea906Sjfb8856606 RTE_COMP_HUFFMAN_FIXED, 160d30ea906Sjfb8856606 /**< Use Fixed Huffman codes */ 161d30ea906Sjfb8856606 RTE_COMP_HUFFMAN_DYNAMIC, 162d30ea906Sjfb8856606 /**< Use Dynamic Huffman codes */ 163d30ea906Sjfb8856606 }; 164d30ea906Sjfb8856606 165d30ea906Sjfb8856606 /** Compression flush flags */ 166d30ea906Sjfb8856606 enum rte_comp_flush_flag { 167d30ea906Sjfb8856606 RTE_COMP_FLUSH_NONE, 168d30ea906Sjfb8856606 /**< Data is not flushed. Output may remain in the compressor and be 169d30ea906Sjfb8856606 * processed during a following op. It may not be possible to decompress 170d30ea906Sjfb8856606 * output until a later op with some other flush flag has been sent. 171d30ea906Sjfb8856606 */ 172d30ea906Sjfb8856606 RTE_COMP_FLUSH_SYNC, 173d30ea906Sjfb8856606 /**< All data should be flushed to output buffer. Output data can be 174d30ea906Sjfb8856606 * decompressed. However state and history is not cleared, so future 175d30ea906Sjfb8856606 * operations may use history from this operation. 176d30ea906Sjfb8856606 */ 177d30ea906Sjfb8856606 RTE_COMP_FLUSH_FULL, 178d30ea906Sjfb8856606 /**< All data should be flushed to output buffer. Output data can be 179d30ea906Sjfb8856606 * decompressed. State and history data is cleared, so future 180d30ea906Sjfb8856606 * ops will be independent of ops processed before this. 181d30ea906Sjfb8856606 */ 182d30ea906Sjfb8856606 RTE_COMP_FLUSH_FINAL 183d30ea906Sjfb8856606 /**< Same as RTE_COMP_FLUSH_FULL but if op.algo is RTE_COMP_ALGO_DEFLATE 184d30ea906Sjfb8856606 * then bfinal bit is set in the last block. 185d30ea906Sjfb8856606 */ 186d30ea906Sjfb8856606 }; 187d30ea906Sjfb8856606 188d30ea906Sjfb8856606 /** Compression transform types */ 189d30ea906Sjfb8856606 enum rte_comp_xform_type { 190d30ea906Sjfb8856606 RTE_COMP_COMPRESS, 191d30ea906Sjfb8856606 /**< Compression service - compress */ 192d30ea906Sjfb8856606 RTE_COMP_DECOMPRESS, 193d30ea906Sjfb8856606 /**< Compression service - decompress */ 194d30ea906Sjfb8856606 }; 195d30ea906Sjfb8856606 196d30ea906Sjfb8856606 /** Compression operation type */ 197d30ea906Sjfb8856606 enum rte_comp_op_type { 198d30ea906Sjfb8856606 RTE_COMP_OP_STATELESS, 199d30ea906Sjfb8856606 /**< All data to be processed is submitted in the op, no state or 200d30ea906Sjfb8856606 * history from previous ops is used and none will be stored for future 201d30ea906Sjfb8856606 * ops. Flush flag must be set to either FLUSH_FULL or FLUSH_FINAL. 202d30ea906Sjfb8856606 */ 203d30ea906Sjfb8856606 RTE_COMP_OP_STATEFUL 204d30ea906Sjfb8856606 /**< There may be more data to be processed after this op, it's part of 205d30ea906Sjfb8856606 * a stream of data. State and history from previous ops can be used 206d30ea906Sjfb8856606 * and resulting state and history can be stored for future ops, 207d30ea906Sjfb8856606 * depending on flush flag. 208d30ea906Sjfb8856606 */ 209d30ea906Sjfb8856606 }; 210d30ea906Sjfb8856606 211d30ea906Sjfb8856606 212d30ea906Sjfb8856606 /** Parameters specific to the deflate algorithm */ 213d30ea906Sjfb8856606 struct rte_comp_deflate_params { 214d30ea906Sjfb8856606 enum rte_comp_huffman huffman; 215d30ea906Sjfb8856606 /**< Compression huffman encoding type */ 216d30ea906Sjfb8856606 }; 217d30ea906Sjfb8856606 218d30ea906Sjfb8856606 /** Setup Data for compression */ 219d30ea906Sjfb8856606 struct rte_comp_compress_xform { 220d30ea906Sjfb8856606 enum rte_comp_algorithm algo; 221d30ea906Sjfb8856606 /**< Algorithm to use for compress operation */ 222d30ea906Sjfb8856606 union { 223d30ea906Sjfb8856606 struct rte_comp_deflate_params deflate; 224d30ea906Sjfb8856606 /**< Parameters specific to the deflate algorithm */ 225d30ea906Sjfb8856606 }; /**< Algorithm specific parameters */ 226d30ea906Sjfb8856606 int level; 227d30ea906Sjfb8856606 /**< Compression level */ 228d30ea906Sjfb8856606 uint8_t window_size; 229d30ea906Sjfb8856606 /**< Base two log value of sliding window to be used. If window size 230d30ea906Sjfb8856606 * can't be supported by the PMD then it may fall back to a smaller 231d30ea906Sjfb8856606 * size. This is likely to result in a worse compression ratio. 232d30ea906Sjfb8856606 */ 233d30ea906Sjfb8856606 enum rte_comp_checksum_type chksum; 234d30ea906Sjfb8856606 /**< Type of checksum to generate on the uncompressed data */ 235d30ea906Sjfb8856606 enum rte_comp_hash_algorithm hash_algo; 236d30ea906Sjfb8856606 /**< Hash algorithm to be used with compress operation. Hash is always 237d30ea906Sjfb8856606 * done on plaintext. 238d30ea906Sjfb8856606 */ 239d30ea906Sjfb8856606 }; 240d30ea906Sjfb8856606 241d30ea906Sjfb8856606 /** 242d30ea906Sjfb8856606 * Setup Data for decompression. 243d30ea906Sjfb8856606 */ 244d30ea906Sjfb8856606 struct rte_comp_decompress_xform { 245d30ea906Sjfb8856606 enum rte_comp_algorithm algo; 246d30ea906Sjfb8856606 /**< Algorithm to use for decompression */ 247d30ea906Sjfb8856606 enum rte_comp_checksum_type chksum; 248d30ea906Sjfb8856606 /**< Type of checksum to generate on the decompressed data */ 249d30ea906Sjfb8856606 uint8_t window_size; 250d30ea906Sjfb8856606 /**< Base two log value of sliding window which was used to generate 251d30ea906Sjfb8856606 * compressed data. If window size can't be supported by the PMD then 252d30ea906Sjfb8856606 * setup of stream or private_xform should fail. 253d30ea906Sjfb8856606 */ 254d30ea906Sjfb8856606 enum rte_comp_hash_algorithm hash_algo; 255d30ea906Sjfb8856606 /**< Hash algorithm to be used with decompress operation. Hash is always 256d30ea906Sjfb8856606 * done on plaintext. 257d30ea906Sjfb8856606 */ 258d30ea906Sjfb8856606 }; 259d30ea906Sjfb8856606 260d30ea906Sjfb8856606 /** 261d30ea906Sjfb8856606 * Compression transform structure. 262d30ea906Sjfb8856606 * 263d30ea906Sjfb8856606 * This is used to specify the compression transforms required. 264d30ea906Sjfb8856606 * Each transform structure can hold a single transform, the type field is 265d30ea906Sjfb8856606 * used to specify which transform is contained within the union. 266d30ea906Sjfb8856606 */ 267d30ea906Sjfb8856606 struct rte_comp_xform { 268d30ea906Sjfb8856606 enum rte_comp_xform_type type; 269d30ea906Sjfb8856606 /**< xform type */ 270d30ea906Sjfb8856606 union { 271d30ea906Sjfb8856606 struct rte_comp_compress_xform compress; 272d30ea906Sjfb8856606 /**< xform for compress operation */ 273d30ea906Sjfb8856606 struct rte_comp_decompress_xform decompress; 274d30ea906Sjfb8856606 /**< decompress xform */ 275d30ea906Sjfb8856606 }; 276d30ea906Sjfb8856606 }; 277d30ea906Sjfb8856606 278d30ea906Sjfb8856606 /** 279d30ea906Sjfb8856606 * Compression Operation. 280d30ea906Sjfb8856606 * 281d30ea906Sjfb8856606 * This structure contains data relating to performing a compression 282d30ea906Sjfb8856606 * operation on the referenced mbuf data buffers. 283d30ea906Sjfb8856606 * 284d30ea906Sjfb8856606 * Comp operations are enqueued and dequeued in comp PMDs using the 285d30ea906Sjfb8856606 * rte_compressdev_enqueue_burst() / rte_compressdev_dequeue_burst() APIs 286d30ea906Sjfb8856606 */ 287d30ea906Sjfb8856606 struct rte_comp_op { 288d30ea906Sjfb8856606 enum rte_comp_op_type op_type; 289d30ea906Sjfb8856606 union { 290d30ea906Sjfb8856606 void *private_xform; 291d30ea906Sjfb8856606 /**< Stateless private PMD data derived from an rte_comp_xform. 292d30ea906Sjfb8856606 * A handle returned by rte_compressdev_private_xform_create() 293d30ea906Sjfb8856606 * must be attached to operations of op_type RTE_COMP_STATELESS. 294d30ea906Sjfb8856606 */ 295d30ea906Sjfb8856606 void *stream; 296d30ea906Sjfb8856606 /**< Private PMD data derived initially from an rte_comp_xform, 297d30ea906Sjfb8856606 * which holds state and history data and evolves as operations 298d30ea906Sjfb8856606 * are processed. rte_compressdev_stream_create() must be called 299d30ea906Sjfb8856606 * on a device for all STATEFUL data streams and the resulting 300d30ea906Sjfb8856606 * stream attached to the one or more operations associated 301d30ea906Sjfb8856606 * with the data stream. 302d30ea906Sjfb8856606 * All operations in a stream must be sent to the same device. 303d30ea906Sjfb8856606 */ 304d30ea906Sjfb8856606 }; 305d30ea906Sjfb8856606 306d30ea906Sjfb8856606 struct rte_mempool *mempool; 307d30ea906Sjfb8856606 /**< Pool from which operation is allocated */ 308d30ea906Sjfb8856606 rte_iova_t iova_addr; 309d30ea906Sjfb8856606 /**< IOVA address of this operation */ 310d30ea906Sjfb8856606 struct rte_mbuf *m_src; 311d30ea906Sjfb8856606 /**< source mbuf 312d30ea906Sjfb8856606 * The total size of the input buffer(s) can be retrieved using 3131646932aSjfb8856606 * rte_pktmbuf_pkt_len(m_src). The max data size which can fit in a 314d30ea906Sjfb8856606 * single mbuf is limited by the uint16_t rte_mbuf.data_len to 64k-1. 315d30ea906Sjfb8856606 * If the input data is bigger than this it can be passed to the PMD in 316d30ea906Sjfb8856606 * a chain of mbufs if the PMD's capabilities indicate it supports this. 317d30ea906Sjfb8856606 */ 318d30ea906Sjfb8856606 struct rte_mbuf *m_dst; 319d30ea906Sjfb8856606 /**< destination mbuf 320d30ea906Sjfb8856606 * The total size of the output buffer(s) can be retrieved using 3211646932aSjfb8856606 * rte_pktmbuf_pkt_len(m_dst). The max data size which can fit in a 322d30ea906Sjfb8856606 * single mbuf is limited by the uint16_t rte_mbuf.data_len to 64k-1. 323d30ea906Sjfb8856606 * If the output data is expected to be bigger than this a chain of 324d30ea906Sjfb8856606 * mbufs can be passed to the PMD if the PMD's capabilities indicate 325d30ea906Sjfb8856606 * it supports this. 326*4418919fSjohnjiang * 327*4418919fSjohnjiang * @note, if incompressible data is passed to an engine for compression 328*4418919fSjohnjiang * using RTE_COMP_ALGO_DEFLATE, it's possible for the output data 329*4418919fSjohnjiang * to be larger than the uncompressed data, due to the inclusion 330*4418919fSjohnjiang * of the DEFLATE header blocks. The size of m_dst should accommodate 331*4418919fSjohnjiang * this, else OUT_OF_SPACE errors can be expected in this case. 332d30ea906Sjfb8856606 */ 333d30ea906Sjfb8856606 334d30ea906Sjfb8856606 struct { 335d30ea906Sjfb8856606 uint32_t offset; 336d30ea906Sjfb8856606 /**< Starting point for compression or decompression, 337d30ea906Sjfb8856606 * specified as number of bytes from start of packet in 338d30ea906Sjfb8856606 * source buffer. 339d30ea906Sjfb8856606 * This offset starts from the first segment 340d30ea906Sjfb8856606 * of the buffer, in case the m_src is a chain of mbufs. 341d30ea906Sjfb8856606 * Starting point for checksum generation in compress direction. 342d30ea906Sjfb8856606 */ 343d30ea906Sjfb8856606 uint32_t length; 344d30ea906Sjfb8856606 /**< The length, in bytes, of the data in source buffer 345d30ea906Sjfb8856606 * to be compressed or decompressed. 346d30ea906Sjfb8856606 * Also the length of the data over which the checksum 347d30ea906Sjfb8856606 * should be generated in compress direction 348d30ea906Sjfb8856606 */ 349d30ea906Sjfb8856606 } src; 350d30ea906Sjfb8856606 struct { 351d30ea906Sjfb8856606 uint32_t offset; 352d30ea906Sjfb8856606 /**< Starting point for writing output data, specified as 353d30ea906Sjfb8856606 * number of bytes from start of packet in dest 354d30ea906Sjfb8856606 * buffer. 355d30ea906Sjfb8856606 * This offset starts from the first segment 356d30ea906Sjfb8856606 * of the buffer, in case the m_dst is a chain of mbufs. 357d30ea906Sjfb8856606 * Starting point for checksum generation in 358d30ea906Sjfb8856606 * decompress direction. 359d30ea906Sjfb8856606 */ 360d30ea906Sjfb8856606 } dst; 361d30ea906Sjfb8856606 struct { 362d30ea906Sjfb8856606 uint8_t *digest; 363d30ea906Sjfb8856606 /**< Output buffer to store hash output, if enabled in xform. 364d30ea906Sjfb8856606 * Buffer would contain valid value only after an op with 365d30ea906Sjfb8856606 * flush flag = RTE_COMP_FLUSH_FULL/FLUSH_FINAL is processed 366d30ea906Sjfb8856606 * successfully. 367d30ea906Sjfb8856606 * 368d30ea906Sjfb8856606 * Length of buffer should be contiguous and large enough to 369d30ea906Sjfb8856606 * accommodate digest produced by specific hash algo. 370d30ea906Sjfb8856606 */ 371d30ea906Sjfb8856606 rte_iova_t iova_addr; 372d30ea906Sjfb8856606 /**< IO address of the buffer */ 373d30ea906Sjfb8856606 } hash; 374d30ea906Sjfb8856606 enum rte_comp_flush_flag flush_flag; 375d30ea906Sjfb8856606 /**< Defines flush characteristics for the output data. 376d30ea906Sjfb8856606 * Only applicable in compress direction 377d30ea906Sjfb8856606 */ 378d30ea906Sjfb8856606 uint64_t input_chksum; 379d30ea906Sjfb8856606 /**< An input checksum can be provided to generate a 380d30ea906Sjfb8856606 * cumulative checksum across sequential blocks in a STATELESS stream. 381d30ea906Sjfb8856606 * Checksum type is as specified in xform chksum_type 382d30ea906Sjfb8856606 */ 383d30ea906Sjfb8856606 uint64_t output_chksum; 384d30ea906Sjfb8856606 /**< If a checksum is generated it will be written in here. 385d30ea906Sjfb8856606 * Checksum type is as specified in xform chksum_type. 386d30ea906Sjfb8856606 */ 387d30ea906Sjfb8856606 uint32_t consumed; 388d30ea906Sjfb8856606 /**< The number of bytes from the source buffer 389d30ea906Sjfb8856606 * which were compressed/decompressed. 390d30ea906Sjfb8856606 */ 391d30ea906Sjfb8856606 uint32_t produced; 392d30ea906Sjfb8856606 /**< The number of bytes written to the destination buffer 393d30ea906Sjfb8856606 * which were compressed/decompressed. 394d30ea906Sjfb8856606 */ 395d30ea906Sjfb8856606 uint64_t debug_status; 396d30ea906Sjfb8856606 /**< 397d30ea906Sjfb8856606 * Status of the operation is returned in the status param. 398d30ea906Sjfb8856606 * This field allows the PMD to pass back extra 399d30ea906Sjfb8856606 * pmd-specific debug information. Value is not defined on the API. 400d30ea906Sjfb8856606 */ 401d30ea906Sjfb8856606 uint8_t status; 402d30ea906Sjfb8856606 /**< 403d30ea906Sjfb8856606 * Operation status - use values from enum rte_comp_status. 404d30ea906Sjfb8856606 * This is reset to 405d30ea906Sjfb8856606 * RTE_COMP_OP_STATUS_NOT_PROCESSED on allocation from mempool and 406d30ea906Sjfb8856606 * will be set to RTE_COMP_OP_STATUS_SUCCESS after operation 407d30ea906Sjfb8856606 * is successfully processed by a PMD 408d30ea906Sjfb8856606 */ 409d30ea906Sjfb8856606 } __rte_cache_aligned; 410d30ea906Sjfb8856606 411d30ea906Sjfb8856606 /** 412d30ea906Sjfb8856606 * Creates an operation pool 413d30ea906Sjfb8856606 * 414d30ea906Sjfb8856606 * @param name 415d30ea906Sjfb8856606 * Compress pool name 416d30ea906Sjfb8856606 * @param nb_elts 417d30ea906Sjfb8856606 * Number of elements in pool 418d30ea906Sjfb8856606 * @param cache_size 419d30ea906Sjfb8856606 * Number of elements to cache on lcore, see 420d30ea906Sjfb8856606 * *rte_mempool_create* for further details about cache size 421d30ea906Sjfb8856606 * @param user_size 422d30ea906Sjfb8856606 * Size of private data to allocate for user with each operation 423d30ea906Sjfb8856606 * @param socket_id 424d30ea906Sjfb8856606 * Socket to identifier allocate memory on 425d30ea906Sjfb8856606 * @return 426d30ea906Sjfb8856606 * - On success pointer to mempool 427d30ea906Sjfb8856606 * - On failure NULL 428d30ea906Sjfb8856606 */ 429*4418919fSjohnjiang __rte_experimental 430*4418919fSjohnjiang struct rte_mempool * 431d30ea906Sjfb8856606 rte_comp_op_pool_create(const char *name, 432d30ea906Sjfb8856606 unsigned int nb_elts, unsigned int cache_size, 433d30ea906Sjfb8856606 uint16_t user_size, int socket_id); 434d30ea906Sjfb8856606 435d30ea906Sjfb8856606 /** 436d30ea906Sjfb8856606 * Allocate an operation from a mempool with default parameters set 437d30ea906Sjfb8856606 * 438d30ea906Sjfb8856606 * @param mempool 439d30ea906Sjfb8856606 * Compress operation mempool 440d30ea906Sjfb8856606 * 441d30ea906Sjfb8856606 * @return 442d30ea906Sjfb8856606 * - On success returns a valid rte_comp_op structure 443d30ea906Sjfb8856606 * - On failure returns NULL 444d30ea906Sjfb8856606 */ 445*4418919fSjohnjiang __rte_experimental 446*4418919fSjohnjiang struct rte_comp_op * 447d30ea906Sjfb8856606 rte_comp_op_alloc(struct rte_mempool *mempool); 448d30ea906Sjfb8856606 449d30ea906Sjfb8856606 /** 450d30ea906Sjfb8856606 * Bulk allocate operations from a mempool with default parameters set 451d30ea906Sjfb8856606 * 452d30ea906Sjfb8856606 * @param mempool 453d30ea906Sjfb8856606 * Compress operation mempool 454d30ea906Sjfb8856606 * @param ops 455d30ea906Sjfb8856606 * Array to place allocated operations 456d30ea906Sjfb8856606 * @param nb_ops 457d30ea906Sjfb8856606 * Number of operations to allocate 458d30ea906Sjfb8856606 * @return 459d30ea906Sjfb8856606 * - nb_ops: Success, the nb_ops requested was allocated 460d30ea906Sjfb8856606 * - 0: Not enough entries in the mempool; no ops are retrieved. 461d30ea906Sjfb8856606 */ 462*4418919fSjohnjiang __rte_experimental 463*4418919fSjohnjiang int 464d30ea906Sjfb8856606 rte_comp_op_bulk_alloc(struct rte_mempool *mempool, 465d30ea906Sjfb8856606 struct rte_comp_op **ops, uint16_t nb_ops); 466d30ea906Sjfb8856606 467d30ea906Sjfb8856606 /** 468d30ea906Sjfb8856606 * Free operation structure 469d30ea906Sjfb8856606 * If operation has been allocate from a rte_mempool, then the operation will 470d30ea906Sjfb8856606 * be returned to the mempool. 471d30ea906Sjfb8856606 * 472d30ea906Sjfb8856606 * @param op 473d30ea906Sjfb8856606 * Compress operation 474d30ea906Sjfb8856606 */ 475*4418919fSjohnjiang __rte_experimental 476*4418919fSjohnjiang void 477d30ea906Sjfb8856606 rte_comp_op_free(struct rte_comp_op *op); 478d30ea906Sjfb8856606 479d30ea906Sjfb8856606 /** 480*4418919fSjohnjiang * Bulk free operation structures 481*4418919fSjohnjiang * If operations have been allocated from an rte_mempool, then the operations 482*4418919fSjohnjiang * will be returned to the mempool. 483*4418919fSjohnjiang * The array entry will be cleared. 484*4418919fSjohnjiang * 485*4418919fSjohnjiang * @param ops 486*4418919fSjohnjiang * Array of Compress operations 487*4418919fSjohnjiang * @param nb_ops 488*4418919fSjohnjiang * Number of operations to free 489*4418919fSjohnjiang */ 490*4418919fSjohnjiang __rte_experimental 491*4418919fSjohnjiang void 492*4418919fSjohnjiang rte_comp_op_bulk_free(struct rte_comp_op **ops, uint16_t nb_ops); 493*4418919fSjohnjiang 494*4418919fSjohnjiang /** 495d30ea906Sjfb8856606 * Get the name of a compress service feature flag 496d30ea906Sjfb8856606 * 497d30ea906Sjfb8856606 * @param flag 498d30ea906Sjfb8856606 * The mask describing the flag 499d30ea906Sjfb8856606 * 500d30ea906Sjfb8856606 * @return 501d30ea906Sjfb8856606 * The name of this flag, or NULL if it's not a valid feature flag. 502d30ea906Sjfb8856606 */ 503*4418919fSjohnjiang __rte_experimental 504*4418919fSjohnjiang const char * 505d30ea906Sjfb8856606 rte_comp_get_feature_name(uint64_t flag); 506d30ea906Sjfb8856606 507d30ea906Sjfb8856606 #ifdef __cplusplus 508d30ea906Sjfb8856606 } 509d30ea906Sjfb8856606 #endif 510d30ea906Sjfb8856606 511d30ea906Sjfb8856606 #endif /* _RTE_COMP_H_ */ 512