X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_compressdev%2Frte_comp.h;h=95306c5d036494f740b3225be2c206d6dc99bb5c;hb=f7e861e21c469b54123f7601eab9155291b93c9b;hp=9f35c37c56bf681a8f93d709d0f97133bb317811;hpb=f87bdc1ddcf4d1217665aea4d6dab41c72d8a212;p=dpdk.git diff --git a/lib/librte_compressdev/rte_comp.h b/lib/librte_compressdev/rte_comp.h index 9f35c37c56..95306c5d03 100644 --- a/lib/librte_compressdev/rte_comp.h +++ b/lib/librte_compressdev/rte_comp.h @@ -19,6 +19,55 @@ extern "C" { #include #include +/** + * compression service feature flags + * + * @note New features flags should be added to the end of the list + * + * Keep these flags synchronised with rte_comp_get_feature_name() + */ +#define RTE_COMP_FF_STATEFUL_COMPRESSION (1ULL << 0) +/**< Stateful compression is supported */ +#define RTE_COMP_FF_STATEFUL_DECOMPRESSION (1ULL << 1) +/**< Stateful decompression is supported */ +#define RTE_COMP_FF_OOP_SGL_IN_SGL_OUT (1ULL << 2) +/**< Out-of-place Scatter-gather (SGL) buffers, + * with multiple segments, are supported in input and output + */ +#define RTE_COMP_FF_OOP_SGL_IN_LB_OUT (1ULL << 3) +/**< Out-of-place Scatter-gather (SGL) buffers are supported + * in input, combined with linear buffers (LB), with a + * single segment, in output + */ +#define RTE_COMP_FF_OOP_LB_IN_SGL_OUT (1ULL << 4) +/**< Out-of-place Scatter-gather (SGL) buffers are supported + * in output, combined with linear buffers (LB) in input + */ +#define RTE_COMP_FF_ADLER32_CHECKSUM (1ULL << 5) +/**< Adler-32 Checksum is supported */ +#define RTE_COMP_FF_CRC32_CHECKSUM (1ULL << 6) +/**< CRC32 Checksum is supported */ +#define RTE_COMP_FF_CRC32_ADLER32_CHECKSUM (1ULL << 7) +/**< Adler-32/CRC32 Checksum is supported */ +#define RTE_COMP_FF_MULTI_PKT_CHECKSUM (1ULL << 8) +/**< Generation of checksum across multiple stateless packets is supported */ +#define RTE_COMP_FF_SHA1_HASH (1ULL << 9) +/**< SHA1 Hash is supported */ +#define RTE_COMP_FF_SHA2_SHA256_HASH (1ULL << 10) +/**< SHA256 Hash of SHA2 family is supported */ +#define RTE_COMP_FF_NONCOMPRESSED_BLOCKS (1ULL << 11) +/**< Creation of non-compressed blocks using RTE_COMP_LEVEL_NONE is supported */ +#define RTE_COMP_FF_SHAREABLE_PRIV_XFORM (1ULL << 12) +/**< Private xforms created by the PMD can be shared + * across multiple stateless operations. If not set, then app needs + * to create as many priv_xforms as it expects to have stateless + * operations in-flight. + */ +#define RTE_COMP_FF_HUFFMAN_FIXED (1ULL << 13) +/**< Fixed huffman encoding is supported */ +#define RTE_COMP_FF_HUFFMAN_DYNAMIC (1ULL << 14) +/**< Dynamic huffman encoding is supported */ + /** Status of comp operation */ enum rte_comp_op_status { RTE_COMP_OP_STATUS_SUCCESS = 0, @@ -63,6 +112,17 @@ enum rte_comp_algorithm { RTE_COMP_ALGO_LIST_END }; +/** Compression Hash Algorithms */ +enum rte_comp_hash_algorithm { + RTE_COMP_HASH_ALGO_NONE = 0, + /**< No hash */ + RTE_COMP_HASH_ALGO_SHA1, + /**< SHA1 hash algorithm */ + RTE_COMP_HASH_ALGO_SHA2_256, + /**< SHA256 hash algorithm of SHA2 family */ + RTE_COMP_HASH_ALGO_LIST_END +}; + /**< Compression Level. * The number is interpreted by each PMD differently. However, lower numbers * give fastest compression, at the expense of compression ratio while @@ -172,6 +232,10 @@ struct rte_comp_compress_xform { */ enum rte_comp_checksum_type chksum; /**< Type of checksum to generate on the uncompressed data */ + enum rte_comp_hash_algorithm hash_algo; + /**< Hash algorithm to be used with compress operation. Hash is always + * done on plaintext. + */ }; /** @@ -187,6 +251,10 @@ struct rte_comp_decompress_xform { * compressed data. If window size can't be supported by the PMD then * setup of stream or private_xform should fail. */ + enum rte_comp_hash_algorithm hash_algo; + /**< Hash algorithm to be used with decompress operation. Hash is always + * done on plaintext. + */ }; /** @@ -242,12 +310,25 @@ struct rte_comp_op { struct rte_mbuf *m_src; /**< source mbuf * The total size of the input buffer(s) can be retrieved using - * rte_pktmbuf_data_len(m_src) + * rte_pktmbuf_pkt_len(m_src). The max data size which can fit in a + * single mbuf is limited by the uint16_t rte_mbuf.data_len to 64k-1. + * If the input data is bigger than this it can be passed to the PMD in + * a chain of mbufs if the PMD's capabilities indicate it supports this. */ struct rte_mbuf *m_dst; /**< destination mbuf * The total size of the output buffer(s) can be retrieved using - * rte_pktmbuf_data_len(m_dst) + * rte_pktmbuf_pkt_len(m_dst). The max data size which can fit in a + * single mbuf is limited by the uint16_t rte_mbuf.data_len to 64k-1. + * If the output data is expected to be bigger than this a chain of + * mbufs can be passed to the PMD if the PMD's capabilities indicate + * it supports this. + * + * @note, if incompressible data is passed to an engine for compression + * using RTE_COMP_ALGO_DEFLATE, it's possible for the output data + * to be larger than the uncompressed data, due to the inclusion + * of the DEFLATE header blocks. The size of m_dst should accommodate + * this, else OUT_OF_SPACE errors can be expected in this case. */ struct { @@ -255,6 +336,8 @@ struct rte_comp_op { /**< Starting point for compression or decompression, * specified as number of bytes from start of packet in * source buffer. + * This offset starts from the first segment + * of the buffer, in case the m_src is a chain of mbufs. * Starting point for checksum generation in compress direction. */ uint32_t length; @@ -268,10 +351,26 @@ struct rte_comp_op { uint32_t offset; /**< Starting point for writing output data, specified as * number of bytes from start of packet in dest - * buffer. Starting point for checksum generation in + * buffer. + * This offset starts from the first segment + * of the buffer, in case the m_dst is a chain of mbufs. + * Starting point for checksum generation in * decompress direction. */ } dst; + struct { + uint8_t *digest; + /**< Output buffer to store hash output, if enabled in xform. + * Buffer would contain valid value only after an op with + * flush flag = RTE_COMP_FLUSH_FULL/FLUSH_FINAL is processed + * successfully. + * + * Length of buffer should be contiguous and large enough to + * accommodate digest produced by specific hash algo. + */ + rte_iova_t iova_addr; + /**< IO address of the buffer */ + } hash; enum rte_comp_flush_flag flush_flag; /**< Defines flush characteristics for the output data. * Only applicable in compress direction @@ -309,6 +408,102 @@ struct rte_comp_op { */ } __rte_cache_aligned; +/** + * Creates an operation pool + * + * @param name + * Compress pool name + * @param nb_elts + * Number of elements in pool + * @param cache_size + * Number of elements to cache on lcore, see + * *rte_mempool_create* for further details about cache size + * @param user_size + * Size of private data to allocate for user with each operation + * @param socket_id + * Socket to identifier allocate memory on + * @return + * - On success pointer to mempool + * - On failure NULL + */ +__rte_experimental +struct rte_mempool * +rte_comp_op_pool_create(const char *name, + unsigned int nb_elts, unsigned int cache_size, + uint16_t user_size, int socket_id); + +/** + * Allocate an operation from a mempool with default parameters set + * + * @param mempool + * Compress operation mempool + * + * @return + * - On success returns a valid rte_comp_op structure + * - On failure returns NULL + */ +__rte_experimental +struct rte_comp_op * +rte_comp_op_alloc(struct rte_mempool *mempool); + +/** + * Bulk allocate operations from a mempool with default parameters set + * + * @param mempool + * Compress operation mempool + * @param ops + * Array to place allocated operations + * @param nb_ops + * Number of operations to allocate + * @return + * - nb_ops: Success, the nb_ops requested was allocated + * - 0: Not enough entries in the mempool; no ops are retrieved. + */ +__rte_experimental +int +rte_comp_op_bulk_alloc(struct rte_mempool *mempool, + struct rte_comp_op **ops, uint16_t nb_ops); + +/** + * Free operation structure + * If operation has been allocate from a rte_mempool, then the operation will + * be returned to the mempool. + * + * @param op + * Compress operation + */ +__rte_experimental +void +rte_comp_op_free(struct rte_comp_op *op); + +/** + * Bulk free operation structures + * If operations have been allocated from an rte_mempool, then the operations + * will be returned to the mempool. + * The array entry will be cleared. + * + * @param ops + * Array of Compress operations + * @param nb_ops + * Number of operations to free + */ +__rte_experimental +void +rte_comp_op_bulk_free(struct rte_comp_op **ops, uint16_t nb_ops); + +/** + * Get the name of a compress service feature flag + * + * @param flag + * The mask describing the flag + * + * @return + * The name of this flag, or NULL if it's not a valid feature flag. + */ +__rte_experimental +const char * +rte_comp_get_feature_name(uint64_t flag); + #ifdef __cplusplus } #endif