1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright(c) 2007-2025 Intel Corporation */ 3 4 /* 5 ***************************************************************************** 6 * Doxygen group definitions 7 ****************************************************************************/ 8 9 /** 10 ***************************************************************************** 11 * @file cpa_dc.h 12 * 13 * @defgroup cpaDc Data Compression API 14 * 15 * @ingroup cpa 16 * 17 * @description 18 * These functions specify the API for Data Compression operations. 19 * 20 * The Data Compression API has the following: 21 * 1) Session based API functions 22 * These functions require a session to be created before performing any 23 * DC operations. Subsequent DC API functions make use of the returned 24 * Session Handle within their structures or function prototypes. 25 * 2) Session-less or No-Session (Ns) based API functions. 26 * These functions do not require a session to be initialized before 27 * performing DC operations. They are "one-shot" API function calls 28 * that submit DC requests directly using the supplied parameters. 29 * 30 * @remarks 31 * 32 * 33 *****************************************************************************/ 34 35 #ifndef CPA_DC_H 36 #define CPA_DC_H 37 38 #ifdef __cplusplus 39 extern"C" { 40 #endif 41 42 43 #ifndef CPA_H 44 #include "cpa.h" 45 #endif 46 47 /** 48 ***************************************************************************** 49 * @ingroup cpaDc 50 * CPA Dc Major Version Number 51 * @description 52 * The CPA_DC API major version number. This number will be incremented 53 * when significant churn to the API has occurred. The combination of the 54 * major and minor number definitions represent the complete version number 55 * for this interface. 56 * 57 *****************************************************************************/ 58 #define CPA_DC_API_VERSION_NUM_MAJOR (3) 59 60 /** 61 ***************************************************************************** 62 * @ingroup cpaDc 63 * CPA DC Minor Version Number 64 * @description 65 * The CPA_DC API minor version number. This number will be incremented 66 * when minor changes to the API has occurred. The combination of the major 67 * and minor number definitions represent the complete version number for 68 * this interface. 69 * 70 *****************************************************************************/ 71 #define CPA_DC_API_VERSION_NUM_MINOR (2) 72 73 /** 74 ***************************************************************************** 75 * @file cpa_dc.h 76 * @ingroup cpaDc 77 * CPA DC API version at least 78 * @description 79 * The minimal supported CPA_DC API version. Allow to check if the API 80 * version is equal or above some version to avoid compilation issues 81 * with an older API version. 82 * 83 *****************************************************************************/ 84 #define CPA_DC_API_VERSION_AT_LEAST(major, minor) \ 85 (CPA_DC_API_VERSION_NUM_MAJOR > major || \ 86 (CPA_DC_API_VERSION_NUM_MAJOR == major && \ 87 CPA_DC_API_VERSION_NUM_MINOR >= minor)) 88 89 /** 90 ***************************************************************************** 91 * @file cpa_dc.h 92 * @ingroup cpaDc 93 * CPA DC API version less than 94 * @description 95 * The maximum supported CPA_DC API version. Allow to check if the API 96 * version is below some version to avoid compilation issues with a newer 97 * API version. 98 * 99 *****************************************************************************/ 100 #define CPA_DC_API_VERSION_LESS_THAN(major, minor) \ 101 (CPA_DC_API_VERSION_NUM_MAJOR < major || \ 102 (CPA_DC_API_VERSION_NUM_MAJOR == major && \ 103 CPA_DC_API_VERSION_NUM_MINOR < minor)) 104 105 106 /** 107 ***************************************************************************** 108 * @ingroup cpaDc 109 * Size of bitmap needed for compression chaining capabilities. 110 * 111 * @description 112 * Defines the number of bits in the bitmap to represent supported 113 * chaining capabilities @ref dcChainCapInfo. Should be set to 114 * at least one greater than the largest value in the enumerated type 115 * @ref CpaDcChainOperations, so that the value of the enum constant 116 * can also be used as the bit position in the bitmap. 117 * 118 * A larger value was chosen to allow for extensibility without the need 119 * to change the size of the bitmap (to ease backwards compatibility in 120 * future versions of the API). 121 * 122 *****************************************************************************/ 123 #define CPA_DC_CHAIN_CAP_BITMAP_SIZE (32) 124 125 /** 126 ***************************************************************************** 127 * @ingroup cpaDc 128 * Compression API session handle type 129 * 130 * @description 131 * Handle used to uniquely identify a Compression API session handle. This 132 * handle is established upon registration with the API using 133 * cpaDcInitSession(). 134 * 135 * 136 * 137 *****************************************************************************/ 138 typedef void * CpaDcSessionHandle; 139 140 141 /** 142 ***************************************************************************** 143 * @ingroup cpaDc 144 * Supported flush flags 145 * 146 * @description 147 * This enumerated list identifies the types of flush that can be 148 * specified for stateful and stateless cpaDcCompressData and 149 * cpaDcDecompressData functions. 150 * 151 *****************************************************************************/ 152 typedef enum _CpaDcFlush 153 { 154 CPA_DC_FLUSH_NONE = 0, 155 /**< No flush request. */ 156 CPA_DC_FLUSH_FINAL, 157 /**< Indicates that the input buffer contains all of the data for 158 the compression session allowing any buffered data to be released. 159 For Deflate, BFINAL is set in the compression header.*/ 160 CPA_DC_FLUSH_SYNC, 161 /**< Used for stateful deflate compression to indicate that all pending 162 output is flushed, byte aligned, to the output buffer. The session state 163 is not reset.*/ 164 CPA_DC_FLUSH_FULL 165 /**< Used for deflate compression to indicate that all pending output is 166 flushed to the output buffer and the session state is reset.*/ 167 } CpaDcFlush; 168 /** 169 ***************************************************************************** 170 * @ingroup cpaDc 171 * Supported Huffman Tree types 172 * 173 * @description 174 * This enumeration lists support for Huffman Tree types. 175 * Selecting Static Huffman trees generates compressed blocks with an RFC 176 * 1951 header specifying "compressed with fixed Huffman trees". 177 * 178 * Selecting Full Dynamic Huffman trees generates compressed blocks with 179 * an RFC 1951 header specifying "compressed with dynamic Huffman codes". 180 * The headers are calculated on the data being compressed, requiring two 181 * passes. 182 * 183 * Selecting Precompiled Huffman Trees generates blocks with RFC 1951 184 * dynamic headers. The headers are pre-calculated and are specified by 185 * the file type. 186 * 187 *****************************************************************************/ 188 typedef enum _CpaDcHuffType 189 { 190 CPA_DC_HT_STATIC = 0, 191 /**< Static Huffman Trees */ 192 CPA_DC_HT_PRECOMP, 193 /**< Precompiled Huffman Trees */ 194 CPA_DC_HT_FULL_DYNAMIC 195 /**< Full Dynamic Huffman Trees */ 196 } CpaDcHuffType; 197 198 /** 199 ***************************************************************************** 200 * @ingroup cpaDc 201 * Supported compression types 202 * 203 * @description 204 * This enumeration lists the supported data compression algorithms. 205 * In combination with CpaDcChecksum it is used to decide on the file 206 * header and footer format. 207 * 208 *****************************************************************************/ 209 typedef enum _CpaDcCompType 210 { 211 CPA_DC_DEFLATE = 3, 212 /**< Deflate Compression */ 213 CPA_DC_LZ4, 214 /**< LZ4 Compression */ 215 CPA_DC_LZ4S 216 /**< LZ4S Compression */ 217 } CpaDcCompType; 218 219 /** 220 ***************************************************************************** 221 * @ingroup cpaDc 222 * Support for defined algorithm window sizes 223 * 224 * @description 225 * This enumerated list defines the valid window sizes that can be 226 * used with the supported algorithms 227 *****************************************************************************/ 228 typedef enum _CpaDcCompWindowSize 229 { 230 CPA_DC_WINSIZE_4K = 0, 231 /**< Window size of 4KB */ 232 CPA_DC_WINSIZE_8K, 233 /**< Window size of 8KB */ 234 CPA_DC_WINSIZE_16K, 235 /**< Window size of 16KB */ 236 CPA_DC_WINSIZE_32K 237 /**< Window size of 32KB */ 238 } CpaDcCompWindowSize; 239 240 /** 241 ***************************************************************************** 242 * @ingroup cpaDc 243 * Min match size in bytes 244 * @description 245 * This is the min match size that will be used for the search algorithm. 246 * It is only configurable for LZ4S. 247 *****************************************************************************/ 248 typedef enum _CpaDcCompMinMatch 249 { 250 CPA_DC_MIN_3_BYTE_MATCH = 0, 251 /**< Min Match of 3 bytes */ 252 CPA_DC_MIN_4_BYTE_MATCH 253 /**< Min Match of 4 bytes */ 254 } CpaDcCompMinMatch; 255 256 /** 257 ***************************************************************************** 258 * @ingroup cpaDc 259 * Maximum LZ4 output block size 260 * @description 261 * Maximum LZ4 output block size 262 *****************************************************************************/ 263 typedef enum _CpaDcCompLZ4BlockMaxSize 264 { 265 CPA_DC_LZ4_MAX_BLOCK_SIZE_64K = 0, 266 /**< Maximum block size 64K */ 267 CPA_DC_LZ4_MAX_BLOCK_SIZE_256K, 268 /**< Maximum block size 256K */ 269 CPA_DC_LZ4_MAX_BLOCK_SIZE_1M, 270 /**< Maximum block size 1M */ 271 CPA_DC_LZ4_MAX_BLOCK_SIZE_4M, 272 /**< Maximum block size 4M */ 273 } CpaDcCompLZ4BlockMaxSize; 274 275 /** 276 ***************************************************************************** 277 * @ingroup cpaDc 278 * Supported checksum algorithms 279 * 280 * @description 281 * This enumeration lists the supported checksum algorithms 282 * Used to decide on file header and footer specifics. 283 * 284 *****************************************************************************/ 285 typedef enum _CpaDcChecksum 286 { 287 CPA_DC_NONE = 0, 288 /**< No checksum required */ 289 CPA_DC_CRC32, 290 /**< Application requires a CRC32 checksum */ 291 CPA_DC_ADLER32, 292 /**< Application requires Adler-32 checksum */ 293 CPA_DC_CRC32_ADLER32, 294 /**< Application requires both CRC32 and Adler-32 checksums */ 295 CPA_DC_XXHASH32, 296 /**< Application requires xxHash-32 checksum */ 297 } CpaDcChecksum; 298 299 300 /** 301 ***************************************************************************** 302 * @ingroup cpaDc 303 * Supported session directions 304 * 305 * @description 306 * This enumerated list identifies the direction of a session. 307 * A session can be compress, decompress or both. 308 * 309 *****************************************************************************/ 310 typedef enum _CpaDcSessionDir 311 { 312 CPA_DC_DIR_COMPRESS = 0, 313 /**< Session will be used for compression */ 314 CPA_DC_DIR_DECOMPRESS, 315 /**< Session will be used for decompression */ 316 CPA_DC_DIR_COMBINED 317 /**< Session will be used for both compression and decompression */ 318 } CpaDcSessionDir; 319 320 typedef CpaDcSessionDir CpaDcDir; 321 322 /** 323 ***************************************************************************** 324 * @ingroup cpaDc 325 * Supported session state settings 326 * 327 * @description 328 * This enumerated list identifies the stateful setting of a session. 329 * A session can be either stateful or stateless. 330 * 331 * Stateful sessions are limited to have only one in-flight message per 332 * session. This means a compress or decompress request must be complete 333 * before a new request can be started. This applies equally to sessions 334 * that are uni-directional in nature and sessions that are combined 335 * compress and decompress. Completion occurs when the synchronous function 336 * returns, or when the asynchronous callback function has completed. 337 * 338 *****************************************************************************/ 339 typedef enum _CpaDcSessionState 340 { 341 CPA_DC_STATEFUL = 0, 342 /**< Session will be stateful, implying that state may need to be 343 saved in some situations */ 344 CPA_DC_STATELESS 345 /**< Session will be stateless, implying no state will be stored*/ 346 } CpaDcSessionState; 347 348 typedef CpaDcSessionState CpaDcState; 349 350 /** 351 ***************************************************************************** 352 * @ingroup cpaDc 353 * Supported compression levels 354 * 355 * @description 356 * This enumerated lists the supported compressed levels. 357 * Lower values will result in less compressibility in less time. 358 * 359 * 360 *****************************************************************************/ 361 typedef enum _CpaDcCompLvl 362 { 363 CPA_DC_L1 = 1, 364 /**< Compression level 1 */ 365 CPA_DC_L2, 366 /**< Compression level 2 */ 367 CPA_DC_L3, 368 /**< Compression level 3 */ 369 CPA_DC_L4, 370 /**< Compression level 4 */ 371 CPA_DC_L5, 372 /**< Compression level 5 */ 373 CPA_DC_L6, 374 /**< Compression level 6 */ 375 CPA_DC_L7, 376 /**< Compression level 7 */ 377 CPA_DC_L8, 378 /**< Compression level 8 */ 379 CPA_DC_L9, 380 /**< Compression level 9 */ 381 CPA_DC_L10, 382 /**< Compression level 10 */ 383 CPA_DC_L11, 384 /**< Compression level 11 */ 385 CPA_DC_L12 386 /**< Compression level 12 */ 387 } CpaDcCompLvl; 388 389 /** 390 ***************************************************************************** 391 * @ingroup cpaDc 392 * Supported additional details from accelerator 393 * 394 * @description 395 * This enumeration lists the supported additional details from the 396 * accelerator. These may be useful in determining the best way to 397 * recover from a failure. 398 * 399 * 400 *****************************************************************************/ 401 typedef enum _CpaDcReqStatus 402 { 403 CPA_DC_OK = 0, 404 /**< No error detected by compression slice */ 405 CPA_DC_INVALID_BLOCK_TYPE = -1, 406 /**< Invalid block type (type == 3) */ 407 CPA_DC_BAD_STORED_BLOCK_LEN = -2, 408 /**< Stored block length did not match one's complement */ 409 CPA_DC_TOO_MANY_CODES = -3, 410 /**< Too many length or distance codes */ 411 CPA_DC_INCOMPLETE_CODE_LENS = -4, 412 /**< Code length codes incomplete */ 413 CPA_DC_REPEATED_LENS = -5, 414 /**< Repeated lengths with no first length */ 415 CPA_DC_MORE_REPEAT = -6, 416 /**< Repeat more than specified lengths */ 417 CPA_DC_BAD_LITLEN_CODES = -7, 418 /**< Invalid literal/length code lengths */ 419 CPA_DC_BAD_DIST_CODES = -8, 420 /**< Invalid distance code lengths */ 421 CPA_DC_INVALID_CODE = -9, 422 /**< Invalid literal/length or distance code in fixed or dynamic block */ 423 CPA_DC_INVALID_DIST = -10, 424 /**< Distance is too far back in fixed or dynamic block */ 425 CPA_DC_OVERFLOW = -11, 426 /**< Overflow detected. This is an indication that output buffer has overflowed. 427 * For stateful sessions, this is a warning (the input can be adjusted and 428 * resubmitted). 429 * For stateless sessions this is an error condition */ 430 CPA_DC_SOFTERR = -12, 431 /**< Other non-fatal detected */ 432 CPA_DC_FATALERR = -13, 433 /**< Fatal error detected */ 434 CPA_DC_MAX_RESUBITERR = -14, 435 /**< On an error being detected, the firmware attempted to correct and resubmitted the 436 * request, however, the maximum resubmit value was exceeded */ 437 CPA_DC_INCOMPLETE_FILE_ERR = -15, 438 /**< The input file is incomplete. Note this is an indication that the request was 439 * submitted with a CPA_DC_FLUSH_FINAL, however, a BFINAL bit was not found in the 440 * request */ 441 CPA_DC_WDOG_TIMER_ERR = -16, 442 /**< The request was not completed as a watchdog timer hardware event occurred */ 443 CPA_DC_EP_HARDWARE_ERR = -17, 444 /**< Request was not completed as an end point hardware error occurred (for 445 * example, a parity error) */ 446 CPA_DC_VERIFY_ERROR = -18, 447 /**< Error detected during "compress and verify" operation */ 448 CPA_DC_EMPTY_DYM_BLK = -19, 449 /**< Decompression request contained an empty dynamic stored block 450 * (not supported) */ 451 CPA_DC_CRC_INTEG_ERR = -20, 452 /**< A data integrity CRC error was detected */ 453 CPA_DC_REGION_OUT_OF_BOUNDS = -21, 454 /**< Error returned when decompression ends before the specified partial 455 * decompression region was produced */ 456 CPA_DC_LZ4_MAX_BLOCK_SIZE_EXCEEDED = -93, 457 /**< LZ4 max block size exceeded */ 458 CPA_DC_LZ4_BLOCK_OVERFLOW_ERR = -95, 459 /**< LZ4 Block Overflow Error */ 460 CPA_DC_LZ4_TOKEN_IS_ZERO_ERR = -98, 461 /**< LZ4 Decoded token offset or token length is zero */ 462 CPA_DC_LZ4_DISTANCE_OUT_OF_RANGE_ERR = -100, 463 /**< LZ4 Distance out of range for len/distance pair */ 464 } CpaDcReqStatus; 465 466 /** 467 ***************************************************************************** 468 * @ingroup cpaDc 469 * Supported modes for automatically selecting the best compression type. 470 * 471 * @description 472 * This enumeration lists the supported modes for automatically selecting 473 * the best encoding which would lead to the best compression results. 474 * 475 * When CPA_DC_ASB_ENABLED is used the output will be a format compliant 476 * block, whether the data is compressed or not. 477 * 478 * The following values are deprecated and should not be used. They 479 * will be removed in a future version of this file. 480 * - CPA_DC_ASB_STATIC_DYNAMIC 481 * - CPA_DC_ASB_UNCOMP_STATIC_DYNAMIC_WITH_STORED_HDRS 482 * - CPA_DC_ASB_UNCOMP_STATIC_DYNAMIC_WITH_NO_HDRS 483 * 484 *****************************************************************************/ 485 typedef enum _CpaDcAutoSelectBest 486 { 487 CPA_DC_ASB_DISABLED = 0, 488 /**< Auto select best mode is disabled */ 489 CPA_DC_ASB_STATIC_DYNAMIC = 1, 490 /**< Auto select between static and dynamic compression */ 491 CPA_DC_ASB_UNCOMP_STATIC_DYNAMIC_WITH_STORED_HDRS = 2, 492 /**< Auto select between uncompressed, static and dynamic compression, 493 * using stored block deflate headers if uncompressed is selected */ 494 CPA_DC_ASB_UNCOMP_STATIC_DYNAMIC_WITH_NO_HDRS = 3, 495 /**< Auto select between uncompressed, static and dynamic compression, 496 * using no deflate headers if uncompressed is selected */ 497 CPA_DC_ASB_ENABLED = 4, 498 /**< Auto select best mode is enabled */ 499 } CpaDcAutoSelectBest; 500 501 /** 502 ***************************************************************************** 503 * @ingroup cpaDc 504 * Supported modes for skipping regions of input or output buffers. 505 * 506 * @description 507 * This enumeration lists the supported modes for skipping regions of 508 * input or output buffers. 509 * 510 *****************************************************************************/ 511 typedef enum _CpaDcSkipMode 512 { 513 CPA_DC_SKIP_DISABLED = 0, 514 /**< Skip mode is disabled */ 515 CPA_DC_SKIP_AT_START = 1, 516 /**< Skip region is at the start of the buffer. */ 517 CPA_DC_SKIP_AT_END = 2, 518 /**< Skip region is at the end of the buffer. */ 519 CPA_DC_SKIP_STRIDE = 3 520 /**< Skip region occurs at regular intervals within the buffer. 521 CpaDcSkipData.strideLength specifies the number of bytes between each 522 skip region. */ 523 } CpaDcSkipMode; 524 525 /** 526 ***************************************************************************** 527 * @ingroup cpaDc 528 * Service specific return codes 529 * 530 * @description 531 * Compression specific return codes 532 * 533 * 534 *****************************************************************************/ 535 536 #define CPA_DC_BAD_DATA (-100) 537 /**<Input data in invalid */ 538 539 /** 540 ***************************************************************************** 541 * @ingroup cpaDc 542 * Definition of callback function invoked for asynchronous cpaDc 543 * requests. 544 * 545 * @description 546 * This is the prototype for the cpaDc compression callback functions. 547 * The callback function is registered by the application using the 548 * cpaDcInitSession() function call. 549 * 550 * @context 551 * This callback function can be executed in a context that DOES NOT 552 * permit sleeping to occur. 553 * @assumptions 554 * None 555 * @sideEffects 556 * None 557 * @reentrant 558 * No 559 * @threadSafe 560 * Yes 561 * 562 * @param callbackTag User-supplied value to help identify request. 563 * @param status Status of the operation. Valid values are 564 * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and 565 * CPA_STATUS_UNSUPPORTED. 566 * 567 * @retval 568 * None 569 * @pre 570 * Component has been initialized. 571 * @post 572 * None 573 * @note 574 * None 575 * @see 576 * None 577 * 578 *****************************************************************************/ 579 typedef void (*CpaDcCallbackFn)( 580 void *callbackTag, 581 CpaStatus status); 582 583 584 /** 585 ***************************************************************************** 586 * @ingroup cpaDc 587 * Implementation Capabilities Structure 588 * @description 589 * This structure contains data relating to the capabilities of an 590 * implementation. The capabilities include supported compression 591 * algorithms, RFC 1951 options and whether the implementation supports 592 * both stateful and stateless compress and decompress sessions. 593 * 594 ****************************************************************************/ 595 typedef struct _CpaDcInstanceCapabilities { 596 CpaBoolean statefulLZSCompression; 597 /**<True if the Instance supports Stateful LZS compression */ 598 CpaBoolean statefulLZSDecompression; 599 /**<True if the Instance supports Stateful LZS decompression */ 600 CpaBoolean statelessLZSCompression; 601 /**<True if the Instance supports Stateless LZS compression */ 602 CpaBoolean statelessLZSDecompression; 603 /**<True if the Instance supports Stateless LZS decompression */ 604 CpaBoolean statefulLZSSCompression; 605 /**<True if the Instance supports Stateful LZSS compression */ 606 CpaBoolean statefulLZSSDecompression; 607 /**<True if the Instance supports Stateful LZSS decompression */ 608 CpaBoolean statelessLZSSCompression; 609 /**<True if the Instance supports Stateless LZSS compression */ 610 CpaBoolean statelessLZSSDecompression; 611 /**<True if the Instance supports Stateless LZSS decompression */ 612 CpaBoolean statefulELZSCompression; 613 /**<True if the Instance supports Stateful Extended LZS 614 compression */ 615 CpaBoolean statefulELZSDecompression; 616 /**<True if the Instance supports Stateful Extended LZS 617 decompression */ 618 CpaBoolean statelessELZSCompression; 619 /**<True if the Instance supports Stateless Extended LZS 620 compression */ 621 CpaBoolean statelessELZSDecompression; 622 /**<True if the Instance supports Stateless Extended LZS 623 decompression */ 624 CpaBoolean statefulDeflateCompression; 625 /**<True if the Instance supports Stateful Deflate compression */ 626 CpaBoolean statefulDeflateDecompression; 627 /**<True if the Instance supports Stateful Deflate 628 decompression */ 629 CpaBoolean statelessDeflateCompression; 630 /**<True if the Instance supports Stateless Deflate compression */ 631 CpaBoolean statelessDeflateDecompression; 632 /**<True if the Instance supports Stateless Deflate 633 decompression */ 634 CpaBoolean statelessLZ4Compression; 635 /**<True if the Instance supports Stateless LZ4 compression */ 636 CpaBoolean statelessLZ4Decompression; 637 /**<True if the Instance supports Stateless LZ4 decompression */ 638 CpaBoolean statefulLZ4Decompression; 639 /**<True if the Instance supports Stateful LZ4 decompression */ 640 CpaBoolean statelessLZ4SCompression; 641 /**<True if the Instance supports Stateless LZ4S compression */ 642 CpaBoolean checksumCRC32; 643 /**<True if the Instance can calculate a CRC32 checksum over 644 the uncompressed data. This value is only calculated when 645 CPA_DC_DEFLATE is configured as the algorithm for 646 CpaDcCompType */ 647 CpaBoolean checksumAdler32; 648 /**<True if the Instance can calculate an Adler-32 checksum over 649 the uncompressed data. This value is only calculated when 650 CPA_DC_DEFLATE is configured as the algorithm for 651 CpaDcCompType */ 652 CpaBoolean checksumXXHash32; 653 /**<True if the Instance can calculate an xxHash-32 hash over 654 the uncompressed data. This value is only calculated when 655 CPA_DC_LZ4 or CPA_DC_LZ4S is configured as the algorithm for 656 CpaDcCompType */ 657 CpaBoolean dynamicHuffman; 658 /**<True if the Instance supports dynamic Huffman trees in deflate 659 blocks */ 660 CpaBoolean dynamicHuffmanBufferReq; 661 /**<True if an Instance specific buffer is required to perform 662 a dynamic Huffman tree deflate request */ 663 CpaBoolean precompiledHuffman; 664 /**<True if the Instance supports precompiled Huffman trees in 665 deflate blocks */ 666 CpaBoolean autoSelectBestHuffmanTree; 667 /**<True if the Instance has the ability to automatically select 668 between different Huffman encoding schemes for better 669 compression ratios */ 670 Cpa8U validWindowSizeMaskCompression; 671 /**<Bits set to '1' for each valid window size supported by 672 the compression implementation */ 673 Cpa8U validWindowSizeMaskDecompression; 674 /**<Bits set to '1' for each valid window size supported by 675 the decompression implementation */ 676 Cpa32U internalHuffmanMem; 677 /**<Number of bytes internally available to be used when 678 constructing dynamic Huffman trees. */ 679 CpaBoolean endOfLastBlock; 680 /**< True if the Instance supports stopping at the end of the last 681 * block in a deflate stream during a decompression operation and 682 * reporting that the end of the last block has been reached as 683 * part of the CpaDcReqStatus data. */ 684 CpaBoolean reportParityError; 685 /**<True if the instance supports parity error reporting. */ 686 CpaBoolean batchAndPack; 687 /**< True if the instance supports 'batch and pack' compression */ 688 CpaBoolean compressAndVerify; 689 /**<True if the instance supports checking that compressed data, 690 * generated as part of a compression operation, can be 691 * successfully decompressed. */ 692 CpaBoolean compressAndVerifyStrict; 693 /**< True if compressAndVerify is 'strictly' enabled for the 694 * instance. If strictly enabled, compressAndVerify will be enabled 695 * by default for compression operations and cannot be disabled by 696 * setting opData.compressAndVerify=0 with cpaDcCompressData2(). 697 * Compression operations with opData.compressAndVerify=0 will 698 * return a CPA_STATUS_INVALID_PARAM error status when in 699 * compressAndVerify strict mode. 700 */ 701 CpaBoolean compressAndVerifyAndRecover; 702 /**<True if the instance supports recovering from errors detected 703 * by compressAndVerify by generating a stored block in the 704 * compressed output data buffer. This stored block replaces any 705 * compressed content that resulted in a compressAndVerify error. 706 */ 707 CpaBoolean integrityCrcs; 708 /**<True if the instance supports 32 bit integrity CRC checking in 709 * the compression/decompression datapath. Refer to 710 * @ref CpaDcOpData for more details on integrity checking. */ 711 CPA_BITMAP(dcChainCapInfo, CPA_DC_CHAIN_CAP_BITMAP_SIZE); 712 /**< Bitmap representing which chaining capabilities are supported 713 * by the instance. 714 * Bits can be tested using the macro @ref CPA_BITMAP_BIT_TEST. 715 * The bit positions are those specified in the enumerated type 716 * @ref CpaDcChainOperations in cpa_dc_chain.h. */ 717 CpaBoolean integrityCrcs64b; 718 /**<True if the instance supports 64 bit integrity CRC checking in 719 * the compression / decompression datapath. Refer to 720 * @ref CpaDcOpData for more details on integrity checking. */ 721 } CpaDcInstanceCapabilities; 722 723 /** 724 ***************************************************************************** 725 * @ingroup cpaDc 726 * Session Setup Data. 727 * @description 728 * This structure contains data relating to setting up a session. The 729 * client needs to complete the information in this structure in order to 730 * setup a session. 731 * 732 ****************************************************************************/ 733 typedef struct _CpaDcSessionSetupData { 734 CpaDcCompLvl compLevel; 735 /**<Compression Level from CpaDcCompLvl */ 736 CpaDcCompType compType; 737 /**<Compression type from CpaDcCompType */ 738 CpaDcHuffType huffType; 739 /**<Huffman type from CpaDcHuffType */ 740 CpaDcAutoSelectBest autoSelectBestHuffmanTree; 741 /**<Indicates if and how the implementation should select the best 742 * Huffman encoding. */ 743 CpaDcSessionDir sessDirection; 744 /**<Session direction indicating whether session is used for 745 compression, decompression or both */ 746 CpaDcSessionState sessState; 747 /**<Session state indicating whether the session should be configured 748 as stateless or stateful */ 749 CpaDcCompWindowSize windowSize; 750 /**<Window size from CpaDcCompWindowSize */ 751 CpaDcCompMinMatch minMatch; 752 /**<Min Match size from CpaDcCompMinMatch */ 753 CpaDcCompLZ4BlockMaxSize lz4BlockMaxSize; 754 /**<Window size from CpaDcCompLZ4BlockMaxSize */ 755 CpaBoolean lz4BlockChecksum; 756 /**<LZ4 Block Checksum setting for the LZ4 request. 757 For LZ4 decompression operations, this setting must be set based 758 on the B.Checksum flag originating from the LZ4 frame header. 759 For LZ4 compression operations, this setting will be ignored as 760 the implementation does not support generation of Data Block 761 checksums. */ 762 CpaBoolean lz4BlockIndependence; 763 /**<LZ4 Block Independence Flag setting. 764 For LZ4 compression operations, this setting must be set based on 765 the Block Independence Flag originating from the LZ4 frame header. 766 For LZ4 decompression operations, this setting is ignored. 767 For data compressed with lz4BlockIndependence set to CPA_FALSE, 768 it is not possible to perform parallel decompression on the 769 compressed blocks. It is also not possible to access the produced 770 LZ4 blocks randomly. 771 */ 772 CpaDcChecksum checksum; 773 /**<Desired checksum required for the session */ 774 CpaBoolean accumulateXXHash; 775 /**<If TRUE the xxHash calculation for LZ4 requests using the session 776 based API, cpaDcCompressData2 and cpaDcCompressData, will be 777 accumulated across requests, with a valid xxHash being written to 778 CpaDcRqResults.checksum for the request which specifies 779 CPA_DC_FLUSH_FINAL in CpaDcOpData.flushFlag. When the 780 CPA_DC_FLUSH_FINAL is received, the internal XXHash state will be 781 reset for this session. 782 One exception is if a CPA_DC_OVERFLOW error is returned, the xxHash 783 value in the checksum field will be valid for requests up to that 784 point and the internal XXHash state will not be reset. This will 785 allow a user to either create an LZ4 frame based off the data at the 786 time of overflow, or correct the overflow condition and continue 787 submitting requests until specifying CPA_DC_FLUSH_FINAL. 788 Additionally the user can force the internal XXHash state to reset 789 (even on overflow) by calling cpaDcResetXXHashState on this session. 790 For the sessionless API, cpaDcNsCompressData, this flag will have 791 no effect */ 792 } CpaDcSessionSetupData; 793 794 typedef CpaDcSessionSetupData CpaDcNsSetupData; 795 796 /** 797 ***************************************************************************** 798 * @ingroup cpaDc 799 * Session Update Data. 800 * @description 801 * This structure contains data relating to updating up a session. The 802 * client needs to complete the information in this structure in order to 803 * update a session. 804 * 805 ****************************************************************************/ 806 typedef struct _CpaDcSessionUpdateData { 807 CpaDcCompLvl compLevel; 808 /**<Compression Level from CpaDcCompLvl */ 809 CpaDcHuffType huffType; 810 /**<Huffman type from CpaDcHuffType */ 811 CpaBoolean enableDmm; 812 /**<Desired DMM required for the session */ 813 } CpaDcSessionUpdateData ; 814 815 /** 816 ***************************************************************************** 817 * @ingroup cpaDc 818 * Compression Statistics Data. 819 * @description 820 * This structure contains data elements corresponding to statistics. 821 * Statistics are collected on a per instance basis and include: 822 * jobs submitted and completed for both compression and decompression. 823 * 824 ****************************************************************************/ 825 typedef struct _CpaDcStats { 826 Cpa64U numCompRequests; 827 /**< Number of successful compression requests */ 828 Cpa64U numCompRequestsErrors; 829 /**< Number of compression requests that had errors and 830 could not be processed */ 831 Cpa64U numCompCompleted; 832 /**< Compression requests completed */ 833 Cpa64U numCompCompletedErrors; 834 /**< Compression requests not completed due to errors */ 835 Cpa64U numCompCnvErrorsRecovered; 836 /**< Compression CNV errors that have been recovered */ 837 838 Cpa64U numDecompRequests; 839 /**< Number of successful decompression requests */ 840 Cpa64U numDecompRequestsErrors; 841 /**< Number of decompression requests that had errors and 842 could not be processed */ 843 Cpa64U numDecompCompleted; 844 /**< Decompression requests completed */ 845 Cpa64U numDecompCompletedErrors; 846 /**< Decompression requests not completed due to errors */ 847 848 } CpaDcStats; 849 850 /** 851 ***************************************************************************** 852 * @ingroup cpaDc 853 * Request results data 854 * @description 855 * This structure contains the request results. 856 * 857 * For stateful sessions the status, produced, consumed and 858 * endOfLastBlock results are per request values while the checksum 859 * value is cumulative across all requests on the session so far. 860 * In this case the checksum value is not guaranteed to be correct 861 * until the final compressed data has been processed. 862 * 863 * For stateless sessions, an initial checksum value is passed into 864 * the stateless operation. Once the stateless operation completes, 865 * the checksum value will contain checksum produced by the operation. 866 * 867 ****************************************************************************/ 868 typedef struct _CpaDcRqResults { 869 CpaDcReqStatus status; 870 /**< Additional status details from accelerator */ 871 Cpa32U produced; 872 /**< Octets produced by the operation. 873 * For Data Plane "partial read" operations, the size of the produced 874 * data should be equal to the sum of the data offset and length of 875 * the requested decompressed data chunk. 876 * See ref @CpaDcDpPartialReadData. */ 877 Cpa32U consumed; 878 /**< Octets consumed by the operation */ 879 Cpa32U checksum; 880 /**< The checksum produced by the operation. For some checksum 881 * algorithms, setting this field on the input to a stateless 882 * compression/decompression request can be used to pass in an initial 883 * checksum value that will be used to seed the checksums produced by 884 * the stateless operation. 885 * 886 * The checksum algorithm CPA_DC_XXHASH32 does not support passing an 887 * input value in this parameter. Any initial value passed will be 888 * ignored by the compression/decompression operation when this 889 * checksum algorithm is used. 890 * 891 * For Data Plane "partial read" operations, the checksum is computed 892 * from the beginning of the decompressed data to the end of the 893 * requested chunk. See ref @CpaDcDpPartialReadData. */ 894 CpaBoolean endOfLastBlock; 895 /**< Decompression operation has stopped at the end of the last 896 * block in a deflate stream. */ 897 CpaBoolean dataUncompressed; 898 /**< If TRUE the output data for this request is uncompressed and 899 * in the format setup for the request. This value is only valid 900 * for CPA_DC_ASB_ENABLED or if compressAndVerifyAndRecover is set to 901 * TRUE in the CpaDcOpData structure for a request. */ 902 } CpaDcRqResults; 903 904 /** 905 ***************************************************************************** 906 * @ingroup cpaDc 907 * Integrity CRC Size 908 * @description 909 * Enum of possible integrity CRC sizes. 910 * 911 ****************************************************************************/ 912 typedef enum _CpaDcIntegrityCrcSize 913 { 914 CPA_DC_INTEGRITY_CRC32 = 0, 915 /**< 32-bit Integrity CRCs */ 916 CPA_DC_INTEGRITY_CRC64, 917 /**< 64-bit integrity CRCs */ 918 } CpaDcIntegrityCrcSize; 919 920 /** 921 ***************************************************************************** 922 * @ingroup cpaDc 923 * Integrity CRC calculation details 924 * @description 925 * This structure contains information about resulting integrity CRC 926 * calculations performed for a single request. 927 * 928 ****************************************************************************/ 929 typedef struct _CpaIntegrityCrc { 930 Cpa32U iCrc; /**< CRC calculated on request's input buffer */ 931 Cpa32U oCrc; /**< CRC calculated on request's output buffer */ 932 } CpaIntegrityCrc; 933 934 /** 935 ***************************************************************************** 936 * @ingroup cpaDc 937 * Integrity CRC64 calculation details 938 * @description 939 * This structure contains information about resulting integrity CRC64 940 * calculations performed for a single request. 941 * 942 ****************************************************************************/ 943 typedef struct _CpaIntegrityCrc64b { 944 Cpa64U iCrc; /**< CRC calculated on request's input buffer */ 945 Cpa64U oCrc; /**< CRC calculated on request's output buffer */ 946 } CpaIntegrityCrc64b; 947 948 /** 949 ***************************************************************************** 950 * @ingroup cpaDc 951 * Collection of CRC related data 952 * @description 953 * This structure contains data facilitating CRC calculations. 954 * After successful request, this structure will contain 955 * all resulting CRCs. 956 * Integrity specific CRCs (when enabled/supported) are located in 957 * 'CpaIntegrityCrc integrityCrc' field for 32bit values and in 958 * 'CpaIntegrityCrc64b integrityCrC64b' field for 64 bit values. 959 * Integrity CRCs cannot be accumulated across multiple requests and 960 * do not provide seeding capabilities. 961 * @note 962 * this structure must be allocated in physical contiguous memory 963 * 964 ****************************************************************************/ 965 typedef struct _CpaCrcData { 966 Cpa32U crc32; 967 /**< CRC32 calculated on the input buffer during compression 968 * requests and on the output buffer during decompression requests. */ 969 Cpa32U adler32; 970 /**< Adler32 calculated on the input buffer during compression 971 * requests and on the output buffer during decompression requests. */ 972 CpaIntegrityCrc integrityCrc; 973 /**< 32bit Integrity CRCs */ 974 CpaIntegrityCrc64b integrityCrc64b; 975 /**< 64bit Integrity CRCs */ 976 } CpaCrcData; 977 978 /** 979 ***************************************************************************** 980 * @ingroup cpaDc 981 * Skip Region Data. 982 * @description 983 * This structure contains data relating to configuring skip region 984 * behaviour. A skip region is a region of an input buffer that 985 * should be omitted from processing or a region that should be inserted 986 * into the output buffer. 987 * 988 ****************************************************************************/ 989 typedef struct _CpaDcSkipData { 990 CpaDcSkipMode skipMode; 991 /**<Skip mode from CpaDcSkipMode for buffer processing */ 992 Cpa32U skipLength; 993 /**<Number of bytes to skip when skip mode is enabled */ 994 Cpa32U strideLength; 995 /**<Size of the stride between skip regions when skip mode is 996 * set to CPA_DC_SKIP_STRIDE. */ 997 Cpa32U firstSkipOffset; 998 /**< Number of bytes to skip in a buffer before reading/writing the 999 * input/output data. */ 1000 } CpaDcSkipData; 1001 1002 /** 1003 ***************************************************************************** 1004 * @ingroup cpaDc 1005 * (De)Compression request input parameters. 1006 * @description 1007 * This structure contains the request information for use with 1008 * compression operations. 1009 * 1010 ****************************************************************************/ 1011 typedef struct _CpaDcOpData { 1012 CpaDcFlush flushFlag; 1013 /**< Indicates the type of flush to be performed. */ 1014 CpaBoolean compressAndVerify; 1015 /**< If set to true, for compression operations, the implementation 1016 * will verify that compressed data, generated by the compression 1017 * operation, can be successfully decompressed. 1018 * This behavior is only supported for stateless compression. 1019 * This behavior is only supported on instances that support the 1020 * compressAndVerify capability. */ 1021 CpaBoolean compressAndVerifyAndRecover; 1022 /**< If set to true, for compression operations, the implementation 1023 * will automatically recover from a compressAndVerify error. 1024 * This behavior is only supported for stateless compression. 1025 * This behavior is only supported on instances that support the 1026 * compressAndVerifyAndRecover capability. 1027 * The compressAndVerify field in CpaDcOpData MUST be set to CPA_TRUE 1028 * if compressAndVerifyAndRecover is set to CPA_TRUE. */ 1029 CpaBoolean integrityCrcCheck; 1030 /**< If set to true, the implementation will verify that data 1031 * integrity is preserved through the processing pipeline. 1032 * 1033 * Integrity CRC checking is not supported for decompression operations 1034 * over data that contains multiple gzip headers. */ 1035 CpaBoolean verifyHwIntegrityCrcs; 1036 /**< If set to true, software calculated CRCs will be compared 1037 * against hardware generated integrity CRCs to ensure that data 1038 * integrity is maintained when transferring data to and from the 1039 * hardware accelerator. */ 1040 CpaDcIntegrityCrcSize integrityCrcSize; 1041 /**< This option specifies the size of the CRC to be used for data 1042 * integrity checking. As such it is only valid if this request is 1043 * configured for data integrity checks. */ 1044 CpaDcSkipData inputSkipData; 1045 /**< Optional skip regions in the input buffers */ 1046 CpaDcSkipData outputSkipData; 1047 /**< Optional skip regions in the output buffers */ 1048 CpaCrcData *pCrcData; 1049 /**< Pointer to CRCs for this operation, when integrity checks 1050 * are enabled. */ 1051 } CpaDcOpData; 1052 1053 /** 1054 ***************************************************************************** 1055 * @ingroup cpaDc 1056 * Retrieve Instance Capabilities 1057 * 1058 * @description 1059 * This function is used to retrieve the capabilities matrix of 1060 * an instance. 1061 * 1062 * @context 1063 * This function shall not be called in an interrupt context. 1064 * @assumptions 1065 * None 1066 * @sideEffects 1067 * None 1068 * @blocking 1069 * Yes 1070 * @reentrant 1071 * No 1072 * @threadSafe 1073 * Yes 1074 * 1075 * @param[in] dcInstance Instance handle derived from discovery 1076 * functions 1077 * @param[in,out] pInstanceCapabilities Pointer to a capabilities struct 1078 * 1079 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1080 * @retval CPA_STATUS_FAIL Function failed. 1081 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1082 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1083 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1084 * the request. 1085 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1086 * 1087 * @pre 1088 * None 1089 * @post 1090 * None 1091 * @note 1092 * Only a synchronous version of this function is provided. 1093 * 1094 * @see 1095 * None 1096 * 1097 *****************************************************************************/ 1098 CpaStatus 1099 cpaDcQueryCapabilities( CpaInstanceHandle dcInstance, 1100 CpaDcInstanceCapabilities *pInstanceCapabilities ); 1101 1102 /** 1103 ***************************************************************************** 1104 * @ingroup cpaDc 1105 * Initialize compression decompression session 1106 * 1107 * @description 1108 * This function is used to initialize a compression/decompression 1109 * session. 1110 * This function specifies a BufferList for context data. 1111 * A single session can be used for both compression and decompression 1112 * requests. Clients MAY register a callback 1113 * function for the compression service using this function. 1114 * This function returns a unique session handle each time this function 1115 * is invoked. 1116 * If the session has been configured with a callback function, then 1117 * the order of the callbacks are guaranteed to be in the same order the 1118 * compression or decompression requests were submitted for each session, 1119 * so long as a single thread of execution is used for job submission. 1120 * 1121 * @context 1122 * This is a synchronous function and it cannot sleep. It can be executed in 1123 * a context that does not permit sleeping. 1124 * @assumptions 1125 * None 1126 * @sideEffects 1127 * None 1128 * @blocking 1129 * No 1130 * @reentrant 1131 * No 1132 * @threadSafe 1133 * Yes 1134 * 1135 * @param[in] dcInstance Instance handle derived from discovery 1136 * functions. 1137 * @param[in,out] pSessionHandle Pointer to a session handle. 1138 * @param[in,out] pSessionData Pointer to a user instantiated structure 1139 * containing session data. 1140 * @param[in] pContextBuffer pointer to context buffer. This is not 1141 * required for stateless operations. 1142 * The total size of the buffer list must 1143 * be equal to or larger than the specified 1144 * contextSize retrieved from the 1145 * cpaDcGetSessionSize() function. 1146 * @param[in] callbackFn For synchronous operation this callback 1147 * shall be a null pointer. 1148 * 1149 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1150 * @retval CPA_STATUS_FAIL Function failed. 1151 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1152 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1153 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1154 * the request. 1155 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1156 * 1157 * @pre 1158 * dcInstance has been started using cpaDcStartInstance. 1159 * @post 1160 * None 1161 * @note 1162 * Only a synchronous version of this function is provided. 1163 * 1164 * This initializes opaque data structures in the session handle. Data 1165 * compressed under this session will be compressed to the level 1166 * specified in the pSessionData structure. Lower compression level 1167 * numbers indicate a request for faster compression at the 1168 * expense of compression ratio. Higher compression level numbers 1169 * indicate a request for higher compression ratios at the expense of 1170 * execution time. 1171 * 1172 * The session is opaque to the user application and the session handle 1173 * contains job specific data. 1174 * 1175 * The pointer to the ContextBuffer will be stored in session specific 1176 * data if required by the implementation. 1177 * 1178 * It is not permitted to have multiple 1179 * outstanding asynchronous compression requests for stateful sessions. 1180 * It is possible to add 1181 * parallelization to compression by using multiple sessions. 1182 * 1183 * The window size specified in the pSessionData must be match exactly 1184 * one of the supported window sizes specified in the capabilities 1185 * structure. If a bi-directional session is being initialized, then 1186 * the window size must be valid for both compress and decompress. 1187 * 1188 * @see 1189 * None 1190 * 1191 *****************************************************************************/ 1192 CpaStatus 1193 cpaDcInitSession( CpaInstanceHandle dcInstance, 1194 CpaDcSessionHandle pSessionHandle, 1195 CpaDcSessionSetupData *pSessionData, 1196 CpaBufferList *pContextBuffer, 1197 CpaDcCallbackFn callbackFn ); 1198 1199 1200 /** 1201 ***************************************************************************** 1202 * @ingroup cpaDc 1203 * Compression Session Reset Function. 1204 * 1205 * @description 1206 * This function will reset a previously initialized session handle 1207 * Reset will fail if outstanding calls still exist for the initialized 1208 * session handle. 1209 * The client needs to retry the reset function at a later time. 1210 * 1211 * @context 1212 * This is a synchronous function that cannot sleep. It can be 1213 * executed in a context that does not permit sleeping. 1214 * @assumptions 1215 * None 1216 * @sideEffects 1217 * None 1218 * @blocking 1219 * No. 1220 * @reentrant 1221 * No 1222 * @threadSafe 1223 * Yes 1224 * 1225 * @param[in] dcInstance Instance handle. 1226 * @param[in,out] pSessionHandle Session handle. 1227 * 1228 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1229 * @retval CPA_STATUS_FAIL Function failed. 1230 * @retval CPA_STATUS_RETRY Resubmit the request. 1231 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1232 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1233 * 1234 * @pre 1235 * The component has been initialized via cpaDcStartInstance function. 1236 * The session has been initialized via cpaDcInitSession function. 1237 * @post 1238 * None 1239 * @note 1240 * This is a synchronous function and has no completion callback 1241 * associated with it. 1242 * 1243 * @see 1244 * cpaDcInitSession() 1245 * 1246 *****************************************************************************/ 1247 CpaStatus 1248 cpaDcResetSession(const CpaInstanceHandle dcInstance, 1249 CpaDcSessionHandle pSessionHandle ); 1250 1251 /** 1252 ***************************************************************************** 1253 * @ingroup cpaDc 1254 * Reset of the xxHash internal state on a session. 1255 * 1256 * @description 1257 * This function will reset the internal xxHash state maintained within a 1258 * session. This would be used in conjunction with the 1259 * CpaDcSessionSetupData.accumulateXXHash flag being set to TRUE for this 1260 * session. It will enable resetting (reinitialising) just the xxHash 1261 * calculation back to the state when the session was first initialised. 1262 * 1263 * @context 1264 * This is a synchronous function that cannot sleep. It can be 1265 * executed in a context that does not permit sleeping. 1266 * @assumptions 1267 * None 1268 * @sideEffects 1269 * None 1270 * @blocking 1271 * No. 1272 * @reentrant 1273 * No 1274 * @threadSafe 1275 * Yes 1276 * 1277 * @param[in] dcInstance Instance handle. 1278 * @param[in,out] pSessionHandle Session handle. 1279 * 1280 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1281 * @retval CPA_STATUS_FAIL Function failed. 1282 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1283 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1284 * 1285 * @pre 1286 * The component has been initialized via cpaDcStartInstance function. 1287 * The session has been initialized via cpaDcInitSession function. 1288 * @post 1289 * None 1290 * @note 1291 * This is a synchronous function and has no completion callback 1292 * associated with it. 1293 * 1294 * @see 1295 * 1296 *****************************************************************************/ 1297 CpaStatus 1298 cpaDcResetXXHashState(const CpaInstanceHandle dcInstance, 1299 CpaDcSessionHandle pSessionHandle ); 1300 1301 /** 1302 ***************************************************************************** 1303 * @ingroup cpaDc 1304 * Compression Session Update Function. 1305 * 1306 * @description 1307 * This function is used to modify some select compression parameters 1308 * of a previously initialized session handle. 1309 * Th update will fail if resources required for the new session settings 1310 * are not available. Specifically, this function may fail if no 1311 * intermediate buffers are associated with the instance, and the 1312 * intended change would require these buffers. 1313 * This function can be called at any time after a successful call of 1314 * cpaDcDpInitSession(). 1315 * This function does not change the parameters to compression request 1316 * already in flight. 1317 * 1318 * @context 1319 * This is a synchronous function that cannot sleep. It can be 1320 * executed in a context that does not permit sleeping. 1321 * @assumptions 1322 * None 1323 * @sideEffects 1324 * None 1325 * @blocking 1326 * No. 1327 * @reentrant 1328 * No 1329 * @threadSafe 1330 * Yes 1331 * 1332 * @param[in] dcInstance Instance handle. 1333 * @param[in,out] pSessionHandle Session handle. 1334 * @param[in] pSessionUpdateData Session Data. 1335 * 1336 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1337 * @retval CPA_STATUS_FAIL Function failed. 1338 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1339 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1340 * @retval CPA_STATUS_RESTARTING API implementation is restarting. 1341 * Resubmit the request 1342 * 1343 * 1344 * @pre 1345 * The component has been initialized via cpaDcStartInstance function. 1346 * The session has been initialized via cpaDcInitSession function. 1347 * @post 1348 * None 1349 * @note 1350 * This is a synchronous function and has no completion callback 1351 * associated with it. 1352 * 1353 * @see 1354 * cpaDcInitSession() 1355 * 1356 *****************************************************************************/ 1357 CpaStatus cpaDcUpdateSession(const CpaInstanceHandle dcInstance, 1358 CpaDcSessionHandle pSessionHandle, 1359 CpaDcSessionUpdateData *pSessionUpdateData ); 1360 1361 /** 1362 ***************************************************************************** 1363 * @ingroup cpaDc 1364 * Compression Session Remove Function. 1365 * 1366 * @description 1367 * This function will remove a previously initialized session handle 1368 * and the installed callback handler function. Removal will fail if 1369 * outstanding calls still exist for the initialized session handle. 1370 * The client needs to retry the remove function at a later time. 1371 * The memory for the session handle MUST not be freed until this call 1372 * has completed successfully. 1373 * 1374 * @context 1375 * This is a synchronous function that cannot sleep. It can be 1376 * executed in a context that does not permit sleeping. 1377 * @assumptions 1378 * None 1379 * @sideEffects 1380 * None 1381 * @blocking 1382 * No. 1383 * @reentrant 1384 * No 1385 * @threadSafe 1386 * Yes 1387 * 1388 * @param[in] dcInstance Instance handle. 1389 * @param[in,out] pSessionHandle Session handle. 1390 * 1391 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1392 * @retval CPA_STATUS_FAIL Function failed. 1393 * @retval CPA_STATUS_RETRY Resubmit the request. 1394 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1395 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1396 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1397 * the request. 1398 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1399 * 1400 * @pre 1401 * The component has been initialized via cpaDcStartInstance function. 1402 * @post 1403 * None 1404 * @note 1405 * This is a synchronous function and has no completion callback 1406 * associated with it. 1407 * 1408 * @see 1409 * cpaDcInitSession() 1410 * 1411 *****************************************************************************/ 1412 CpaStatus 1413 cpaDcRemoveSession(const CpaInstanceHandle dcInstance, 1414 CpaDcSessionHandle pSessionHandle ); 1415 1416 /** 1417 ***************************************************************************** 1418 * @ingroup cpaDc 1419 * Deflate Compression Bound API 1420 * 1421 * @description 1422 * This function provides the maximum output buffer size for a Deflate 1423 * compression operation in the "worst case" (non-compressible) scenario. 1424 * It's primary purpose is for output buffer memory allocation. 1425 * 1426 * @context 1427 * This is a synchronous function that will not sleep. It can be 1428 * executed in a context that does not permit sleeping. 1429 * @assumptions 1430 * None 1431 * @sideEffects 1432 * None 1433 * @blocking 1434 * No. 1435 * @reentrant 1436 * No 1437 * @threadSafe 1438 * Yes 1439 * 1440 * @param[in] dcInstance Instance handle. 1441 * @param[in] huffType CpaDcHuffType to be used with this operation. 1442 * @param[in] inputSize Input Buffer size. 1443 * @param[out] outputSize Maximum output buffer size. 1444 * 1445 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1446 * @retval CPA_STATUS_FAIL Function failed. 1447 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1448 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1449 * 1450 * @pre 1451 * The component has been initialized via cpaDcStartInstance function. 1452 * @post 1453 * None 1454 * @note 1455 * This is a synchronous function and has no completion callback 1456 * associated with it. 1457 * The cpaDcDeflateCompressBound() API is intended to reduce the likelihood 1458 * of overflow occurring during compression operations. An overflow may 1459 * occur in some exception cases. 1460 * 1461 * @see 1462 * None 1463 * 1464 *****************************************************************************/ 1465 CpaStatus 1466 cpaDcDeflateCompressBound(const CpaInstanceHandle dcInstance, 1467 CpaDcHuffType huffType, 1468 Cpa32U inputSize, 1469 Cpa32U *outputSize ); 1470 1471 /** 1472 ***************************************************************************** 1473 * @ingroup cpaDc 1474 * LZ4 Compression Bound API 1475 * 1476 * @description 1477 * This function provides the maximum output buffer size for a LZ4 1478 * compression operation in the "worst case" (non-compressible) scenario. 1479 * It's primary purpose is for output buffer memory allocation. 1480 * 1481 * @context 1482 * This is a synchronous function that will not sleep. It can be 1483 * executed in a context that does not permit sleeping. 1484 * @assumptions 1485 * None 1486 * @sideEffects 1487 * None 1488 * @blocking 1489 * No. 1490 * @reentrant 1491 * No 1492 * @threadSafe 1493 * Yes 1494 * 1495 * @param[in] dcInstance Instance handle. 1496 * @param[in] inputSize Input Buffer size. 1497 * @param[out] outputSize Maximum output buffer size. 1498 * 1499 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1500 * @retval CPA_STATUS_FAIL Function failed. 1501 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1502 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1503 * 1504 * @pre 1505 * The component has been initialized via cpaDcStartInstance function. 1506 * @post 1507 * None 1508 * @note 1509 * This is a synchronous function and has no completion callback 1510 * associated with it. 1511 * 1512 * @see 1513 * None 1514 * 1515 *****************************************************************************/ 1516 CpaStatus 1517 cpaDcLZ4CompressBound(const CpaInstanceHandle dcInstance, 1518 Cpa32U inputSize, 1519 Cpa32U *outputSize ); 1520 1521 /** 1522 ***************************************************************************** 1523 * @ingroup cpaDc 1524 * LZ4S Compression Bound API 1525 * 1526 * @description 1527 * This function provides the maximum output buffer size for a LZ4S 1528 * compression operation in the "worst case" (non-compressible) scenario. 1529 * It's primary purpose is for output buffer memory allocation. 1530 * 1531 * @context 1532 * This is a synchronous function that will not sleep. It can be 1533 * executed in a context that does not permit sleeping. 1534 * @assumptions 1535 * None 1536 * @sideEffects 1537 * None 1538 * @blocking 1539 * No. 1540 * @reentrant 1541 * No 1542 * @threadSafe 1543 * Yes 1544 * 1545 * @param[in] dcInstance Instance handle. 1546 * @param[in] inputSize Input Buffer size. 1547 * @param[out] outputSize Maximum output buffer size. 1548 * 1549 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1550 * @retval CPA_STATUS_FAIL Function failed. 1551 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1552 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1553 * 1554 * @pre 1555 * The component has been initialized via cpaDcStartInstance function. 1556 * @post 1557 * None 1558 * @note 1559 * This is a synchronous function and has no completion callback 1560 * associated with it. 1561 * 1562 * @see 1563 * None 1564 * 1565 *****************************************************************************/ 1566 CpaStatus 1567 cpaDcLZ4SCompressBound(const CpaInstanceHandle dcInstance, 1568 Cpa32U inputSize, 1569 Cpa32U *outputSize ); 1570 1571 /** 1572 ***************************************************************************** 1573 * @ingroup cpaDc 1574 * Submit a request to compress a buffer of data. 1575 * 1576 * @description 1577 * This API consumes data from the input buffer and generates compressed 1578 * data in the output buffer. 1579 * 1580 * @context 1581 * When called as an asynchronous function it cannot sleep. It can be 1582 * executed in a context that does not permit sleeping. 1583 * When called as a synchronous function it may sleep. It MUST NOT be 1584 * executed in a context that DOES NOT permit sleeping. 1585 * @assumptions 1586 * None 1587 * @sideEffects 1588 * None 1589 * @blocking 1590 * Yes when configured to operate in synchronous mode. 1591 * @reentrant 1592 * No 1593 * @threadSafe 1594 * Yes 1595 * 1596 * @param[in] dcInstance Target service instance. 1597 * @param[in,out] pSessionHandle Session handle. 1598 * @param[in] pSrcBuff Pointer to data buffer for compression. 1599 * @param[in] pDestBuff Pointer to buffer space for data after 1600 * compression. 1601 * @param[in,out] pResults Pointer to results structure 1602 * @param[in] flushFlag Indicates the type of flush to be 1603 * performed. 1604 * @param[in] callbackTag User supplied value to help correlate 1605 * the callback with its associated 1606 * request. 1607 * 1608 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1609 * @retval CPA_STATUS_FAIL Function failed. 1610 * @retval CPA_STATUS_RETRY Resubmit the request. 1611 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1612 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1613 * @retval CPA_DC_BAD_DATA The input data was not properly formed. 1614 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1615 * the request. 1616 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1617 * 1618 * @pre 1619 * pSessionHandle has been setup using cpaDcInitSession() 1620 * @post 1621 * pSessionHandle has session related state information 1622 * @note 1623 * This function passes control to the compression service for processing 1624 * 1625 * In synchronous mode the function returns the error status returned from the 1626 * service. In asynchronous mode the status is returned by the callback 1627 * function. 1628 * 1629 * This function may be called repetitively with input until all of the 1630 * input has been consumed by the compression service and all the output 1631 * has been produced. 1632 * 1633 * When this function returns, it may be that all of the available data 1634 * in the input buffer has not been compressed. This situation will 1635 * occur when there is insufficient space in the output buffer. The 1636 * calling application should note the amount of data processed, and clear 1637 * the output buffer and then submit the request again, with the input 1638 * buffer pointer to the data that was not previously compressed. 1639 * 1640 * Relationship between input buffers and results buffers. 1641 * -# Implementations of this API must not modify the individual 1642 * flat buffers of the input buffer list. 1643 * -# The implementation communicates the amount of data 1644 * consumed from the source buffer list via pResults->consumed arg. 1645 * -# The implementation communicates the amount of data in the 1646 * destination buffer list via pResults->produced arg. 1647 * 1648 * Source Buffer Setup Rules 1649 * -# The buffer list must have the correct number of flat buffers. This 1650 * is specified by the numBuffers element of the CpaBufferList. 1651 * -# Each flat buffer must have a pointer to contiguous memory that has 1652 * been allocated by the calling application. The 1653 * number of octets to be compressed or decompressed must be stored 1654 * in the dataLenInBytes element of the flat buffer. 1655 * -# It is permissible to have one or more flat buffers with a zero length 1656 * data store. This function will process all flat buffers until the 1657 * destination buffer is full or all source data has been processed. 1658 * If a buffer has zero length, then no data will be processed from 1659 * that buffer. 1660 * 1661 * Source Buffer Processing Rules. 1662 * -# The buffer list is processed in index order - SrcBuff->pBuffers[0] 1663 * will be completely processed before SrcBuff->pBuffers[1] begins to 1664 * be processed. 1665 * -# The application must drain the destination buffers. 1666 * If the source data was not completely consumed, the application 1667 * must resubmit the request. 1668 * -# On return, the pResults->consumed will indicate the number of bytes 1669 * consumed from the input buffers. 1670 * 1671 * Destination Buffer Setup Rules 1672 * -# The destination buffer list must have storage for processed data. 1673 * This implies at least one flat buffer must exist in the buffer list. 1674 * -# For each flat buffer in the buffer list, the dataLenInBytes element 1675 * must be set to the size of the buffer space. 1676 * -# It is permissible to have one or more flat buffers with a zero length 1677 * data store. 1678 * If a buffer has zero length, then no data will be added to 1679 * that buffer. 1680 * 1681 * Destination Buffer Processing Rules. 1682 * -# The buffer list is processed in index order - DestBuff->pBuffers[0] 1683 * will be completely processed before DestBuff->pBuffers[1] begins to 1684 * be processed. 1685 * -# On return, the pResults->produced will indicate the number of bytes 1686 * written to the output buffers. 1687 * -# If processing has not been completed, the application must drain the 1688 * destination buffers and resubmit the request. The application must 1689 * reset the dataLenInBytes for each flat buffer in the destination 1690 * buffer list. 1691 * 1692 * Checksum rules. 1693 * If a checksum is specified in the session setup data, then: 1694 * -# For the first request for a particular data segment the checksum 1695 * is initialised internally by the implementation. 1696 * -# The checksum is maintained by the implementation between calls 1697 * until the flushFlag is set to CPA_DC_FLUSH_FINAL indicating the 1698 * end of a particular data segment. 1699 * -# Intermediate checksum values are returned to the application, 1700 * via the CpaDcRqResults structure, in response to each request. 1701 * However these checksum values are not guaranteed to the valid 1702 * until the call with flushFlag set to CPA_DC_FLUSH_FINAL 1703 * completes successfully. 1704 * 1705 * The application should set flushFlag to 1706 * CPA_DC_FLUSH_FINAL to indicate processing a particular data segment 1707 * is complete. It should be noted that this function may have to be 1708 * called more than once to process data after the flushFlag parameter has 1709 * been set to CPA_DC_FLUSH_FINAL if the destination buffer fills. Refer 1710 * to buffer processing rules. 1711 * 1712 * For stateful operations, when the function is invoked with flushFlag 1713 * set to CPA_DC_FLUSH_NONE or CPA_DC_FLUSH_SYNC, indicating more data 1714 * is yet to come, the function may or may not retain data. When the 1715 * function is invoked with flushFlag set to CPA_DC_FLUSH_FULL or 1716 * CPA_DC_FLUSH_FINAL, the function will process all buffered data. 1717 * 1718 * For stateless operations, CPA_DC_FLUSH_FINAL will cause the BFINAL 1719 * bit to be set for deflate compression. The initial checksum for the 1720 * stateless operation should be set to 0. CPA_DC_FLUSH_NONE and 1721 * CPA_DC_FLUSH_SYNC should not be used for stateless operations. 1722 * 1723 * It is possible to maintain checksum and length information across 1724 * cpaDcCompressData() calls with a stateless session without maintaining 1725 * the full history state that is maintained by a stateful session. In this 1726 * mode of operation, an initial checksum value of 0 is passed into the 1727 * first cpaDcCompressData() call with the flush flag set to 1728 * CPA_DC_FLUSH_FULL. On subsequent calls to cpaDcCompressData() for this 1729 * session, the checksum passed to cpaDcCompressData should be set to the 1730 * checksum value produced by the previous call to cpaDcCompressData(). 1731 * When the last block of input data is passed to cpaDcCompressData(), the 1732 * flush flag should be set to CPA_DC_FLUSH_FINAL. This will cause the BFINAL 1733 * bit to be set in a deflate stream. It is the responsibility of the calling 1734 * application to maintain overall lengths across the stateless requests 1735 * and to pass the checksum produced by one request into the next request. 1736 * 1737 * When an instance supports compressAndVerifyAndRecover, it is enabled by 1738 * default when using cpaDcCompressData(). If this feature needs to be 1739 * disabled, cpaDcCompressData2() must be used. 1740 * 1741 * Synchronous or Asynchronous operation of the API is determined by 1742 * the value of the callbackFn parameter passed to cpaDcInitSession() 1743 * when the sessionHandle was setup. If a non-NULL value was specified 1744 * then the supplied callback function will be invoked asynchronously 1745 * with the response of this request. 1746 * 1747 * Response ordering: 1748 * For each session, the implementation must maintain the order of 1749 * responses. That is, if in asynchronous mode, the order of the callback 1750 * functions must match the order of jobs submitted by this function. 1751 * In a simple synchronous mode implementation, the practice of submitting 1752 * a request and blocking on its completion ensure ordering is preserved. 1753 * 1754 * This limitation does not apply if the application employs multiple 1755 * threads to service a single session. 1756 * 1757 * If this API is invoked asynchronous, the return code represents 1758 * the success or not of asynchronously scheduling the request. 1759 * The results of the operation, along with the amount of data consumed 1760 * and produced become available when the callback function is invoked. 1761 * As such, pResults->consumed and pResults->produced are available 1762 * only when the operation is complete. 1763 * 1764 * The application must not use either the source or destination buffers 1765 * until the callback has completed. 1766 * 1767 * @see 1768 * None 1769 * 1770 *****************************************************************************/ 1771 CpaStatus 1772 cpaDcCompressData( CpaInstanceHandle dcInstance, 1773 CpaDcSessionHandle pSessionHandle, 1774 CpaBufferList *pSrcBuff, 1775 CpaBufferList *pDestBuff, 1776 CpaDcRqResults *pResults, 1777 CpaDcFlush flushFlag, 1778 void *callbackTag ); 1779 1780 /** 1781 ***************************************************************************** 1782 * @ingroup cpaDc 1783 * Submit a request to compress a buffer of data. 1784 * 1785 * @description 1786 * This API consumes data from the input buffer and generates compressed 1787 * data in the output buffer. This API is very similar to 1788 * cpaDcCompressData() except it provides a CpaDcOpData structure for 1789 * passing additional input parameters not covered in cpaDcCompressData(). 1790 * 1791 * @context 1792 * When called as an asynchronous function it cannot sleep. It can be 1793 * executed in a context that does not permit sleeping. 1794 * When called as a synchronous function it may sleep. It MUST NOT be 1795 * executed in a context that DOES NOT permit sleeping. 1796 * @assumptions 1797 * None 1798 * @sideEffects 1799 * None 1800 * @blocking 1801 * Yes when configured to operate in synchronous mode. 1802 * @reentrant 1803 * No 1804 * @threadSafe 1805 * Yes 1806 * 1807 * @param[in] dcInstance Target service instance. 1808 * @param[in,out] pSessionHandle Session handle. 1809 * @param[in] pSrcBuff Pointer to data buffer for compression. 1810 * @param[in] pDestBuff Pointer to buffer space for data after 1811 * compression. 1812 * @param[in,out] pOpData Additional parameters. 1813 * @param[in,out] pResults Pointer to results structure 1814 * @param[in] callbackTag User supplied value to help correlate 1815 * the callback with its associated 1816 * request. 1817 * 1818 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1819 * @retval CPA_STATUS_FAIL Function failed. 1820 * @retval CPA_STATUS_RETRY Resubmit the request. 1821 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1822 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1823 * @retval CPA_DC_BAD_DATA The input data was not properly formed. 1824 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1825 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1826 * the request. 1827 * 1828 * @pre 1829 * pSessionHandle has been setup using cpaDcInitSession() 1830 * @post 1831 * pSessionHandle has session related state information 1832 * @note 1833 * This function passes control to the compression service for processing 1834 * 1835 * @see 1836 * cpaDcCompressData() 1837 * 1838 *****************************************************************************/ 1839 CpaStatus 1840 cpaDcCompressData2( CpaInstanceHandle dcInstance, 1841 CpaDcSessionHandle pSessionHandle, 1842 CpaBufferList *pSrcBuff, 1843 CpaBufferList *pDestBuff, 1844 CpaDcOpData *pOpData, 1845 CpaDcRqResults *pResults, 1846 void *callbackTag ); 1847 1848 /** 1849 ***************************************************************************** 1850 * @ingroup cpaDc 1851 * Submit a request to compress a buffer of data without requiring a 1852 * session to be created. This is a No-Session (Ns) variant of the 1853 * cpaDcCompressData function. 1854 * 1855 * @description 1856 * This API consumes data from the input buffer and generates compressed 1857 * data in the output buffer. Unlike the other compression APIs this 1858 * does not use a previously created session. This is a "one-shot" API 1859 * that requests can be directly submitted to. 1860 * 1861 * @context 1862 * When called as an asynchronous function it cannot sleep. It can be 1863 * executed in a context that does not permit sleeping. 1864 * When called as a synchronous function it may sleep. It MUST NOT be 1865 * executed in a context that DOES NOT permit sleeping. 1866 * @assumptions 1867 * None 1868 * @sideEffects 1869 * None 1870 * @blocking 1871 * Yes when configured to operate in synchronous mode. 1872 * @reentrant 1873 * No 1874 * @threadSafe 1875 * Yes 1876 * 1877 * @param[in] dcInstance Target service instance. 1878 * @param[in] pSetupData Configuration structure for compression. 1879 * @param[in] pSrcBuff Pointer to data buffer for compression. 1880 * @param[in] pDestBuff Pointer to buffer space for data after 1881 * compression. 1882 * @param[in] pOpData Additional input parameters. 1883 * @param[in,out] pResults Pointer to results structure 1884 * @param[in] callbackFn For synchronous operation this callback 1885 * shall be a null pointer. 1886 * @param[in] callbackTag User supplied value to help correlate 1887 * the callback with its associated 1888 * request. 1889 * 1890 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1891 * @retval CPA_STATUS_FAIL Function failed. 1892 * @retval CPA_STATUS_RETRY Resubmit the request. 1893 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1894 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1895 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1896 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1897 * the request. 1898 * 1899 * @pre 1900 * None 1901 * @post 1902 * None 1903 * @note 1904 * This function passes control to the compression service for processing 1905 * 1906 * Checksum rules. 1907 * The checksum rules are the same as those for the session based APIs 1908 * (cpaDcCompressData or cpaDcCompressData2) with the following exception. 1909 * -# If the algorithm specified is CPA_DC_LZ4 or CPA_DC_LZ4S the xxHash32 1910 * checksum will not be maintained across calls to the API. The 1911 * implication is that the xxHash32 value will only be valid for the 1912 * output of a single request, no state will be saved. If an LZ4 frame is 1913 * required, even in recoverable error scenarios such as CPA_DC_OVERFLOW, 1914 * the checksum will not be continued. If that is required the session 1915 * based API must be used. 1916 * 1917 * @see 1918 * None 1919 * 1920 *****************************************************************************/ 1921 CpaStatus 1922 cpaDcNsCompressData( CpaInstanceHandle dcInstance, 1923 CpaDcNsSetupData *pSetupData, 1924 CpaBufferList *pSrcBuff, 1925 CpaBufferList *pDestBuff, 1926 CpaDcOpData *pOpData, 1927 CpaDcRqResults *pResults, 1928 CpaDcCallbackFn callbackFn, 1929 void *callbackTag ); 1930 /** 1931 ***************************************************************************** 1932 * @ingroup cpaDc 1933 * Submit a request to decompress a buffer of data. 1934 * 1935 * @description 1936 * This API consumes compressed data from the input buffer and generates 1937 * uncompressed data in the output buffer. 1938 * 1939 * @context 1940 * When called as an asynchronous function it cannot sleep. It can be 1941 * executed in a context that does not permit sleeping. 1942 * When called as a synchronous function it may sleep. It MUST NOT be 1943 * executed in a context that DOES NOT permit sleeping. 1944 * @assumptions 1945 * None 1946 * @sideEffects 1947 * None 1948 * @blocking 1949 * Yes when configured to operate in synchronous mode. 1950 * @reentrant 1951 * No 1952 * @threadSafe 1953 * Yes 1954 * 1955 * @param[in] dcInstance Target service instance. 1956 * @param[in,out] pSessionHandle Session handle. 1957 * @param[in] pSrcBuff Pointer to data buffer for compression. 1958 * @param[in] pDestBuff Pointer to buffer space for data 1959 * after decompression. 1960 * @param[in,out] pResults Pointer to results structure 1961 * @param[in] flushFlag When set to CPA_DC_FLUSH_FINAL, indicates 1962 * that the input buffer contains all of 1963 * the data for the compression session, 1964 * allowing the function to release 1965 * history data. 1966 * @param[in] callbackTag User supplied value to help correlate 1967 * the callback with its associated 1968 * request. 1969 * 1970 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1971 * @retval CPA_STATUS_FAIL Function failed. 1972 * @retval CPA_STATUS_RETRY Resubmit the request. 1973 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1974 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1975 * @retval CPA_DC_BAD_DATA The input data was not properly formed. 1976 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1977 * the request. 1978 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1979 * 1980 * @pre 1981 * pSessionHandle has been setup using cpaDcInitSession() 1982 * @post 1983 * pSessionHandle has session related state information 1984 * @note 1985 * This function passes control to the compression service for 1986 * decompression. The function returns the status from the service. 1987 * 1988 * This function may be called repetitively with input until all of the 1989 * input has been provided and all the output has been consumed. 1990 * 1991 * This function has identical buffer processing rules as 1992 * cpaDcCompressData(). 1993 * 1994 * This function has identical checksum processing rules as 1995 * cpaDcCompressData(). 1996 * 1997 * The application should set flushFlag to 1998 * CPA_DC_FLUSH_FINAL to indicate processing a particular compressed 1999 * data segment is complete. It should be noted that this function may 2000 * have to be called more than once to process data after flushFlag 2001 * has been set if the destination buffer fills. Refer to 2002 * buffer processing rules in cpaDcCompressData(). 2003 * 2004 * Synchronous or Asynchronous operation of the API is determined by 2005 * the value of the callbackFn parameter passed to cpaDcInitSession() 2006 * when the sessionHandle was setup. If a non-NULL value was specified 2007 * then the supplied callback function will be invoked asynchronously 2008 * with the response of this request, along with the callbackTag 2009 * specified in the function. 2010 * 2011 * The same response ordering constraints identified in the 2012 * cpaDcCompressData API apply to this function. 2013 * 2014 * @see 2015 * cpaDcCompressData() 2016 * 2017 *****************************************************************************/ 2018 CpaStatus 2019 cpaDcDecompressData( CpaInstanceHandle dcInstance, 2020 CpaDcSessionHandle pSessionHandle, 2021 CpaBufferList *pSrcBuff, 2022 CpaBufferList *pDestBuff, 2023 CpaDcRqResults *pResults, 2024 CpaDcFlush flushFlag, 2025 void *callbackTag ); 2026 2027 2028 /** 2029 ***************************************************************************** 2030 * @ingroup cpaDc 2031 * Submit a request to decompress a buffer of data. 2032 * 2033 * @description 2034 * This API consumes compressed data from the input buffer and generates 2035 * uncompressed data in the output buffer. This API is very similar to 2036 * cpaDcDecompressData() except it provides a CpaDcOpData structure for 2037 * passing additional input parameters not covered in cpaDcDecompressData(). 2038 * 2039 * @context 2040 * When called as an asynchronous function it cannot sleep. It can be 2041 * executed in a context that does not permit sleeping. 2042 * When called as a synchronous function it may sleep. It MUST NOT be 2043 * executed in a context that DOES NOT permit sleeping. 2044 * @assumptions 2045 * None 2046 * @sideEffects 2047 * None 2048 * @blocking 2049 * Yes when configured to operate in synchronous mode. 2050 * @reentrant 2051 * No 2052 * @threadSafe 2053 * Yes 2054 * 2055 * @param[in] dcInstance Target service instance. 2056 * @param[in,out] pSessionHandle Session handle. 2057 * @param[in] pSrcBuff Pointer to data buffer for compression. 2058 * @param[in] pDestBuff Pointer to buffer space for data 2059 * after decompression. 2060 * @param[in] pOpData Additional input parameters. 2061 * @param[in,out] pResults Pointer to results structure 2062 * @param[in] callbackTag User supplied value to help correlate 2063 * the callback with its associated 2064 * request. 2065 * 2066 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2067 * @retval CPA_STATUS_FAIL Function failed. 2068 * @retval CPA_STATUS_RETRY Resubmit the request. 2069 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 2070 * @retval CPA_STATUS_RESOURCE Error related to system resources. 2071 * @retval CPA_DC_BAD_DATA The input data was not properly formed. 2072 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2073 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 2074 * the request. 2075 * 2076 * @pre 2077 * pSessionHandle has been setup using cpaDcInitSession() 2078 * @post 2079 * pSessionHandle has session related state information 2080 * @note 2081 * This function passes control to the compression service for 2082 * decompression. The function returns the status from the service. 2083 * 2084 * @see 2085 * cpaDcDecompressData() 2086 * cpaDcCompressData2() 2087 * cpaDcCompressData() 2088 * 2089 *****************************************************************************/ 2090 CpaStatus 2091 cpaDcDecompressData2( CpaInstanceHandle dcInstance, 2092 CpaDcSessionHandle pSessionHandle, 2093 CpaBufferList *pSrcBuff, 2094 CpaBufferList *pDestBuff, 2095 CpaDcOpData *pOpData, 2096 CpaDcRqResults *pResults, 2097 void *callbackTag ); 2098 2099 /** 2100 ***************************************************************************** 2101 * @ingroup cpaDc 2102 * Submit a request to decompress a buffer of data without requiring a 2103 * session to be created. This is a No-Session (Ns) variant of the 2104 * cpaDcDecompressData function. 2105 * 2106 * @description 2107 * This API consumes data from the input buffer and generates decompressed 2108 * data in the output buffer. Unlike the other decompression APIs this 2109 * does not use a previously created session. This is a "one-shot" API 2110 * that requests can be directly submitted to. 2111 * 2112 * @context 2113 * When called as an asynchronous function it cannot sleep. It can be 2114 * executed in a context that does not permit sleeping. 2115 * When called as a synchronous function it may sleep. It MUST NOT be 2116 * executed in a context that DOES NOT permit sleeping. 2117 * @assumptions 2118 * None 2119 * @sideEffects 2120 * None 2121 * @blocking 2122 * Yes when configured to operate in synchronous mode. 2123 * @reentrant 2124 * No 2125 * @threadSafe 2126 * Yes 2127 * 2128 * @param[in] dcInstance Target service instance. 2129 * @param[in] pSetupData Configuration structure for decompression.. 2130 * @param[in] pSrcBuff Pointer to data buffer for decompression. 2131 * @param[in] pDestBuff Pointer to buffer space for data 2132 * after decompression. 2133 * @param[in] pOpData Additional input parameters. 2134 * @param[in,out] pResults Pointer to results structure 2135 * @param[in] callbackFn For synchronous operation this callback 2136 * shall be a null pointer. 2137 * @param[in] callbackTag User supplied value to help correlate 2138 * the callback with its associated 2139 * request. 2140 * 2141 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2142 * @retval CPA_STATUS_FAIL Function failed. 2143 * @retval CPA_STATUS_RETRY Resubmit the request. 2144 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 2145 * @retval CPA_STATUS_RESOURCE Error related to system resources. 2146 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2147 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 2148 * the request. 2149 * 2150 * @pre 2151 * None 2152 * @post 2153 * None 2154 * @note 2155 * This function passes control to the decompression service. The function 2156 * returns the status from the service. 2157 * 2158 * @see 2159 * cpaDcDecompressData() 2160 * cpaDcCompressData2() 2161 * cpaDcCompressData() 2162 * 2163 *****************************************************************************/ 2164 CpaStatus 2165 cpaDcNsDecompressData( CpaInstanceHandle dcInstance, 2166 CpaDcNsSetupData *pSetupData, 2167 CpaBufferList *pSrcBuff, 2168 CpaBufferList *pDestBuff, 2169 CpaDcOpData *pOpData, 2170 CpaDcRqResults *pResults, 2171 CpaDcCallbackFn callbackFn, 2172 void *callbackTag ); 2173 2174 /** 2175 ***************************************************************************** 2176 * @ingroup cpaDc 2177 * Generate compression header. 2178 * 2179 * @description 2180 * This function generates the gzip header, zlib header or LZ4 frame 2181 * header and stores it in the destination buffer. The type of header 2182 * created is determined using the compression algorithm selected using 2183 * CpaDcSessionSetupData.compType, for the session associated with the 2184 * session handle. 2185 * 2186 * @context 2187 * This function may be call from any context. 2188 * @assumptions 2189 * None 2190 * @sideEffects 2191 * None 2192 * @blocking 2193 * No 2194 * @reentrant 2195 * No 2196 * @threadSafe 2197 * Yes 2198 * 2199 * @param[in] pSessionHandle Session handle. 2200 * @param[in] pDestBuff Pointer to data buffer where the 2201 * compression header will go. 2202 * @param[out] count Pointer to counter filled in with 2203 * header size. 2204 * 2205 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2206 * @retval CPA_STATUS_FAIL Function failed. 2207 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 2208 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 2209 * the request. 2210 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2211 * 2212 * @pre 2213 * pSessionHandle has been setup using cpaDcInitSession() 2214 * 2215 * @note 2216 * When the deflate compression algorithm is used, this function can output 2217 * a 10 byte gzip header or 2 byte zlib header to the destination buffer. 2218 * The session properties are used to determine the header type. To 2219 * output a Gzip or a Zlib header the session must have been initialized 2220 * with CpaDcCompType CPA_DC_DEFLATE. 2221 * To output a gzip header the session must have been initialized with 2222 * CpaDcChecksum CPA_DC_CRC32. To output a zlib header the session must 2223 * have been initialized with CpaDcChecksum CPA_DC_ADLER32. 2224 * For CpaDcChecksum CPA_DC_NONE no header is output. 2225 * 2226 * If the compression requires a gzip header, then this header requires 2227 * at a minimum the following fields, defined in RFC1952: 2228 * ID1: 0x1f 2229 * ID2: 0x8b 2230 * CM: Compression method = 8 for deflate 2231 * 2232 * The zlib header is defined in RFC1950 and this function must implement 2233 * as a minimum: 2234 * CM: four bit compression method - 8 is deflate with window size to 2235 * 32k 2236 * CINFO: four bit window size (see RFC1950 for details), 7 is 32k 2237 * window 2238 * FLG: defined as: 2239 * - Bits 0 - 4: check bits for CM, CINFO and FLG (see RFC1950) 2240 * - Bit 5: FDICT 0 = default, 1 is preset dictionary 2241 * - Bits 6 - 7: FLEVEL, compression level (see RFC 1950) 2242 * 2243 * When LZ4 algorithm is used, this function can output a 7 byte frame 2244 * header. This function will set the LZ4 frame header with: 2245 * - Magic number 0x184D2204 2246 * - The LZ4 max block size defined in the CpaDcSessionSetupData 2247 * - Flag byte as: 2248 * * Version = 1 2249 * * Block independence = 0 2250 * * Block checksum = 0 2251 * * Content size present = 0 2252 * * Content checksum present = 1 2253 * * Dictionary ID present = 0 2254 * - Content size = 0 2255 * - Dictionary ID = 0 2256 * - Header checksum = 1 byte representing the second byte of the 2257 * XXH32 of the frame descriptor field. 2258 * 2259 * The counter parameter will be set to the number of bytes added to the 2260 * buffer. The pData will be not be changed. 2261 * 2262 * For any of the compression algorithms used, the application is 2263 * responsible to offset the pData pointer in CpaBufferList by the length 2264 * of the header before calling the CpaDcCompressData() or 2265 * CpaDcCompressData2() functions. 2266 * @see 2267 * None 2268 * 2269 *****************************************************************************/ 2270 CpaStatus 2271 cpaDcGenerateHeader( CpaDcSessionHandle pSessionHandle, 2272 CpaFlatBuffer *pDestBuff, Cpa32U *count ); 2273 2274 /** 2275 ***************************************************************************** 2276 * @ingroup cpaDc 2277 * Generate compression footer. 2278 * 2279 * @description 2280 * This function generates the footer for gzip, zlib or LZ4. 2281 * The generated footer is stored it in the destination buffer. 2282 * The type of footer created is determined using the compression 2283 * algorithm selected for the session associated with the session handle. 2284 * 2285 * @context 2286 * This function may be call from any context. 2287 * @assumptions 2288 * None 2289 * @sideEffects 2290 * All session variables are reset 2291 * @blocking 2292 * No 2293 * @reentrant 2294 * No 2295 * @threadSafe 2296 * Yes 2297 * 2298 * @param[in,out] pSessionHandle Session handle. 2299 * @param[in] pDestBuff Pointer to data buffer where the 2300 * compression footer will go. 2301 * @param[in,out] pResults Pointer to results structure filled by 2302 * CpaDcCompressData. Updated with the 2303 * results of this API call 2304 * 2305 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2306 * @retval CPA_STATUS_FAIL Function failed. 2307 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2308 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 2309 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 2310 * the request. 2311 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2312 * 2313 * @pre 2314 * pSessionHandle has been setup using cpaDcInitSession() 2315 * pResults structure has been filled by CpaDcCompressData(). 2316 * 2317 * @note 2318 * Depending on the session variables, this function can add the 2319 * alder32 footer to the zlib compressed data as defined in RFC1950. 2320 * If required, it can also add the gzip footer, which is the crc32 of the 2321 * uncompressed data and the length of the uncompressed data. 2322 * This section is defined in RFC1952. The session variables used to 2323 * determine the header type are CpaDcCompType and CpaDcChecksum, see 2324 * cpaDcGenerateHeader for more details. 2325 * 2326 * For LZ4 compression, this function adds the LZ4 frame footer 2327 * using XXH32 algorithm of the uncompressed data. The XXH32 checksum is 2328 * added after the end mark. This section is defined in the documentation 2329 * of the LZ4 frame format at: 2330 * https://github.com/lz4/lz4/blob/dev/doc/lz4_Frame_format.md 2331 * 2332 * An artifact of invoking this function for writing the footer data is 2333 * that all opaque session specific data is re-initialized. If the 2334 * compression level and file types are consistent, the upper level 2335 * application can continue processing compression requests using the 2336 * same session handle. 2337 * 2338 * The produced element of the pResults structure will be incremented by 2339 * the numbers bytes added to the buffer. The pointer to the buffer will 2340 * not be modified. It is necessary for the application to ensure that 2341 * there is always sufficient memory in the destination buffer to append 2342 * the footer. In the event that the destination buffer would be too small 2343 * to accept the footer, overflow will not be reported. 2344 * 2345 * @see 2346 * None 2347 * 2348 *****************************************************************************/ 2349 CpaStatus 2350 cpaDcGenerateFooter( CpaDcSessionHandle pSessionHandle, 2351 CpaFlatBuffer *pDestBuff, 2352 CpaDcRqResults *pResults ); 2353 2354 2355 /** 2356 ***************************************************************************** 2357 * @ingroup cpaDc 2358 * Generate compression header without requiring a session to be created. 2359 * This is a No-Session (Ns) variant of the cpaDcGenerateHeader function. 2360 * 2361 * @description 2362 * This API generates the required compression format header and stores it 2363 * in the output buffer. 2364 * 2365 * @context 2366 * This function may be called from any context. 2367 * @assumptions 2368 * None 2369 * @sideEffects 2370 * None 2371 * @blocking 2372 * No 2373 * @reentrant 2374 * No 2375 * @threadSafe 2376 * Yes 2377 * 2378 * @param[in] pSetupData Pointer to Ns Configuration structure. 2379 * @param[in] pDestBuff Pointer to data buffer where the 2380 * compression header will go. 2381 * @param[out] count Pointer to counter filled in with 2382 * header size. 2383 * 2384 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2385 * @retval CPA_STATUS_FAIL Function failed. 2386 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 2387 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 2388 * the request. 2389 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2390 * 2391 * @pre 2392 * None 2393 * 2394 * @note 2395 * This function outputs the required compression format header to 2396 * the destination buffer. The CpaDcNsSetupData structure fields are used to 2397 * determine the header type. 2398 * 2399 * To output an LZ4 header the structure must have been initialized with 2400 * with CpaDcCompType CPA_DC_LZ4. 2401 * To output a gzip or zlib header the structure must have been initialized 2402 * with CpaDcCompType CPA_DC_DEFLATE. 2403 * To output a gzip header the structure must have been initialized with 2404 * CpaDcChecksum CPA_DC_CRC32. 2405 * To output a zlib header the structure must have been initialized with 2406 * CpaDcChecksum CPA_DC_ADLER32. 2407 * For CpaDcChecksum CPA_DC_NONE no header is output. 2408 * 2409 * The counter parameter will be set to the number of bytes added to the 2410 * buffer. 2411 * 2412 * @see 2413 * cpaDcGenerateHeader 2414 * 2415 *****************************************************************************/ 2416 CpaStatus 2417 cpaDcNsGenerateHeader( CpaDcNsSetupData *pSetupData, 2418 CpaFlatBuffer *pDestBuff, 2419 Cpa32U *count ); 2420 2421 /** 2422 ***************************************************************************** 2423 * @ingroup cpaDc 2424 * Generate compression footer without requiring a session to be created. 2425 * This is a No-Session (Ns) variant of the cpaDcGenerateFooter function. 2426 * 2427 * @description 2428 * This API generates the footer for the required format and stores it in 2429 * the destination buffer. 2430 * @context 2431 * This function may be call from any context. 2432 * @assumptions 2433 * None 2434 * @sideEffects 2435 * All session variables are reset 2436 * @blocking 2437 * No 2438 * @reentrant 2439 * No 2440 * @threadSafe 2441 * Yes 2442 * 2443 * @param[in] pSetupData Pointer to Ns Configuration structure. 2444 * @param[in] totalLength Total accumulated length of input data 2445 * processed. See description for formats 2446 * that make use of this parameter. 2447 * @param[in] pDestBuff Pointer to data buffer where the 2448 * compression footer will go. 2449 * @param[in,out] pResults Pointer to results structure filled by 2450 * CpaDcNsCompressData. Updated with the 2451 * results of this API call 2452 * 2453 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2454 * @retval CPA_STATUS_FAIL Function failed. 2455 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2456 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 2457 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 2458 * the request. 2459 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2460 * 2461 * @pre 2462 * pResults structure has been filled by CpaDcNsCompressData(). 2463 * 2464 * @note 2465 * This function outputs the required compression format footer to 2466 * the destination buffer. The CpaDcNsSetupData structure fields are used to 2467 * determine the footer type created. 2468 * 2469 * To output an LZ4 footer the structure must have been initialized with 2470 * with CpaDcCompType CPA_DC_LZ4. 2471 * To output a gzip or zlib footer the structure must have been initialized 2472 * with CpaDcCompType CPA_DC_DEFLATE. 2473 * To output a gzip footer the structure must have been initialized with 2474 * CpaDcChecksum CPA_DC_CRC32 and the totalLength parameter initialized to 2475 * the total accumulated length of data processed. 2476 * To output a zlib footer the structure must have been initialized with 2477 * CpaDcChecksum CPA_DC_ADLER32. 2478 * For CpaDcChecksum CPA_DC_NONE no footer is output. 2479 * 2480 * The produced element of the pResults structure will be incremented by the 2481 * number of bytes added to the buffer. The pointer to the buffer 2482 * will not be modified. 2483 * 2484 * @see 2485 * CpaDcNsSetupData 2486 * cpaDcNsGenerateHeader 2487 * cpaDcGenerateFooter 2488 * 2489 *****************************************************************************/ 2490 CpaStatus 2491 cpaDcNsGenerateFooter( CpaDcNsSetupData *pSetupData, 2492 Cpa64U totalLength, 2493 CpaFlatBuffer *pDestBuff, 2494 CpaDcRqResults *pResults ); 2495 2496 2497 /** 2498 ***************************************************************************** 2499 * @ingroup cpaDc 2500 * Retrieve statistics 2501 * 2502 * @description 2503 * This API retrieves the current statistics for a compression instance. 2504 * 2505 * @context 2506 * This function may be call from any context. 2507 * @assumptions 2508 * None 2509 * @sideEffects 2510 * None 2511 * @blocking 2512 * Yes 2513 * @reentrant 2514 * No 2515 * @threadSafe 2516 * Yes 2517 * 2518 * @param[in] dcInstance Instance handle. 2519 * @param[out] pStatistics Pointer to statistics structure. 2520 * 2521 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2522 * @retval CPA_STATUS_FAIL Function failed. 2523 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 2524 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 2525 * the request. 2526 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2527 * 2528 * @pre 2529 * None 2530 * @post 2531 * None 2532 * 2533 * @see 2534 * None 2535 * 2536 *****************************************************************************/ 2537 CpaStatus 2538 cpaDcGetStats( CpaInstanceHandle dcInstance, 2539 CpaDcStats *pStatistics ); 2540 2541 /*****************************************************************************/ 2542 /* Instance Discovery Functions */ 2543 2544 /** 2545 ***************************************************************************** 2546 * @ingroup cpaDc 2547 * Get the number of device instances that are supported by the API 2548 * implementation. 2549 * 2550 * @description 2551 * 2552 * This function will get the number of device instances that are supported 2553 * by an implementation of the compression API. This number is then used to 2554 * determine the size of the array that must be passed to 2555 * cpaDcGetInstances(). 2556 * 2557 * @context 2558 * This function MUST NOT be called from an interrupt context as it MAY 2559 * sleep. 2560 * @assumptions 2561 * None 2562 * @sideEffects 2563 * None 2564 * @blocking 2565 * This function is synchronous and blocking. 2566 * @reentrant 2567 * No 2568 * @threadSafe 2569 * Yes 2570 * 2571 * @param[out] pNumInstances Pointer to where the number of 2572 * instances will be written. 2573 * 2574 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2575 * @retval CPA_STATUS_FAIL Function failed. 2576 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 2577 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2578 * 2579 * @pre 2580 * None 2581 * @post 2582 * None 2583 * @note 2584 * This function operates in a synchronous manner and no asynchronous 2585 * callback will be generated 2586 * 2587 * @see 2588 * cpaDcGetInstances 2589 * 2590 *****************************************************************************/ 2591 CpaStatus 2592 cpaDcGetNumInstances(Cpa16U* pNumInstances); 2593 2594 /** 2595 ***************************************************************************** 2596 * @ingroup cpaDc 2597 * Get the handles to the device instances that are supported by the 2598 * API implementation. 2599 * 2600 * @description 2601 * 2602 * This function will return handles to the device instances that are 2603 * supported by an implementation of the compression API. These instance 2604 * handles can then be used as input parameters with other compression API 2605 * functions. 2606 * 2607 * This function will populate an array that has been allocated by the 2608 * caller. The size of this API is determined by the 2609 * cpaDcGetNumInstances() function. 2610 * 2611 * @context 2612 * This function MUST NOT be called from an interrupt context as it MAY 2613 * sleep. 2614 * @assumptions 2615 * None 2616 * @sideEffects 2617 * None 2618 * @blocking 2619 * This function is synchronous and blocking. 2620 * @reentrant 2621 * No 2622 * @threadSafe 2623 * Yes 2624 * 2625 * @param[in] numInstances Size of the array. 2626 * @param[out] dcInstances Pointer to where the instance 2627 * handles will be written. 2628 * 2629 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2630 * @retval CPA_STATUS_FAIL Function failed. 2631 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 2632 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2633 * 2634 * @pre 2635 * None 2636 * @post 2637 * None 2638 * @note 2639 * This function operates in a synchronous manner and no asynchronous 2640 * callback will be generated 2641 * 2642 * @see 2643 * cpaDcGetInstances 2644 * 2645 *****************************************************************************/ 2646 CpaStatus 2647 cpaDcGetInstances(Cpa16U numInstances, 2648 CpaInstanceHandle* dcInstances); 2649 2650 /** 2651 ***************************************************************************** 2652 * @ingroup cpaDc 2653 * Compression Component utility function to determine the number of 2654 * intermediate buffers required by an implementation. 2655 * 2656 * @description 2657 * This function will determine the number of intermediate buffer lists 2658 * required by an implementation for a compression instance. These buffers 2659 * should then be allocated and provided when calling @ref cpaDcStartInstance() 2660 * to start a compression instance that will use dynamic compression. 2661 * 2662 * @context 2663 * This function may sleep, and MUST NOT be called in interrupt context. 2664 * @assumptions 2665 * None 2666 * @sideEffects 2667 * None 2668 * @blocking 2669 * This function is synchronous and blocking. 2670 * @reentrant 2671 * No 2672 * @threadSafe 2673 * Yes 2674 * @param[in,out] instanceHandle Handle to an instance of this API to be 2675 * initialized. 2676 * @param[out] pNumBuffers When the function returns, this will 2677 * specify the number of buffer lists that 2678 * should be used as intermediate buffers 2679 * when calling cpaDcStartInstance(). 2680 * 2681 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2682 * @retval CPA_STATUS_FAIL Function failed. Suggested course of action 2683 * is to shutdown and restart. 2684 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2685 * 2686 * @pre 2687 * None 2688 * @post 2689 * None 2690 * @note 2691 * Note that this is a synchronous function and has no completion callback 2692 * associated with it. 2693 * 2694 * @see 2695 * cpaDcStartInstance() 2696 * 2697 *****************************************************************************/ 2698 CpaStatus 2699 cpaDcGetNumIntermediateBuffers(CpaInstanceHandle instanceHandle, 2700 Cpa16U *pNumBuffers); 2701 2702 /** 2703 ***************************************************************************** 2704 * @ingroup cpaDc 2705 * Compression Component Initialization and Start function. 2706 * 2707 * @description 2708 * This function will initialize and start the compression component. 2709 * It MUST be called before any other compress function is called. This 2710 * function SHOULD be called only once (either for the very first time, 2711 * or after an cpaDcStopInstance call which succeeded) per instance. 2712 * Subsequent calls will have no effect. 2713 * 2714 * If required by an implementation, this function can be provided with 2715 * instance specific intermediate buffers. The intent is to provide an 2716 * instance specific location to store intermediate results during dynamic 2717 * instance Huffman tree compression requests. The memory should be 2718 * accessible by the compression engine. The buffers are to support 2719 * deflate compression with dynamic Huffman Trees. Each buffer list 2720 * should be similar in size to twice the destination buffer size passed 2721 * to the compress API. The number of intermediate buffer lists may vary 2722 * between implementations and so @ref cpaDcGetNumIntermediateBuffers() 2723 * should be called first to determine the number of intermediate 2724 * buffers required by the implementation. 2725 * 2726 * If not required, this parameter can be passed in as NULL. 2727 * 2728 * @context 2729 * This function may sleep, and MUST NOT be called in interrupt context. 2730 * @assumptions 2731 * None 2732 * @sideEffects 2733 * None 2734 * @blocking 2735 * This function is synchronous and blocking. 2736 * @reentrant 2737 * No 2738 * @threadSafe 2739 * Yes 2740 * @param[in,out] instanceHandle Handle to an instance of this API to be 2741 * initialized. 2742 * @param[in] numBuffers Number of buffer lists represented by 2743 * the pIntermediateBuffers parameter. 2744 * Note: @ref cpaDcGetNumIntermediateBuffers() 2745 * can be used to determine the number of 2746 * intermediate buffers that an implementation 2747 * requires. 2748 * @param[in] pIntermediateBuffers Optional pointer to Instance specific 2749 * DRAM buffer. 2750 * 2751 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2752 * @retval CPA_STATUS_FAIL Function failed. Suggested course of action 2753 * is to shutdown and restart. 2754 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2755 * 2756 * @pre 2757 * None 2758 * @post 2759 * None 2760 * @note 2761 * Note that this is a synchronous function and has no completion callback 2762 * associated with it. 2763 * 2764 * @see 2765 * cpaDcStopInstance() 2766 * cpaDcGetNumIntermediateBuffers() 2767 * 2768 *****************************************************************************/ 2769 CpaStatus 2770 cpaDcStartInstance(CpaInstanceHandle instanceHandle, 2771 Cpa16U numBuffers, 2772 CpaBufferList **pIntermediateBuffers); 2773 2774 /** 2775 ***************************************************************************** 2776 * @ingroup cpaDc 2777 * Compress Component Stop function. 2778 * 2779 * @description 2780 * This function will stop the Compression component and free 2781 * all system resources associated with it. The client MUST ensure that 2782 * all outstanding operations have completed before calling this function. 2783 * The recommended approach to ensure this is to deregister all session or 2784 * callback handles before calling this function. If outstanding 2785 * operations still exist when this function is invoked, the callback 2786 * function for each of those operations will NOT be invoked and the 2787 * shutdown will continue. If the component is to be restarted, then a 2788 * call to cpaDcStartInstance is required. 2789 * 2790 * @context 2791 * This function may sleep, and so MUST NOT be called in interrupt 2792 * context. 2793 * @assumptions 2794 * None 2795 * @sideEffects 2796 * None 2797 * @blocking 2798 * This function is synchronous and blocking. 2799 * @reentrant 2800 * No 2801 * @threadSafe 2802 * Yes 2803 * @param[in] instanceHandle Handle to an instance of this API to be 2804 * shutdown. 2805 * 2806 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2807 * @retval CPA_STATUS_FAIL Function failed. Suggested course of action 2808 * is to ensure requests are not still being 2809 * submitted and that all sessions are 2810 * deregistered. If this does not help, then 2811 * forcefully remove the component from the 2812 * system. 2813 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2814 * 2815 * @pre 2816 * The component has been initialized via cpaDcStartInstance 2817 * @post 2818 * None 2819 * @note 2820 * Note that this is a synchronous function and has no completion callback 2821 * associated with it. 2822 * 2823 * @see 2824 * cpaDcStartInstance() 2825 * 2826 *****************************************************************************/ 2827 CpaStatus 2828 cpaDcStopInstance(CpaInstanceHandle instanceHandle); 2829 2830 2831 /** 2832 ***************************************************************************** 2833 * @ingroup cpaDc 2834 * Function to get information on a particular instance. 2835 * 2836 * @description 2837 * This function will provide instance specific information through a 2838 * @ref CpaInstanceInfo2 structure. 2839 * 2840 * @context 2841 * This function will be executed in a context that requires that sleeping 2842 * MUST NOT be permitted. 2843 * @assumptions 2844 * None 2845 * @sideEffects 2846 * None 2847 * @blocking 2848 * Yes 2849 * @reentrant 2850 * No 2851 * @threadSafe 2852 * Yes 2853 * 2854 * @param[in] instanceHandle Handle to an instance of this API to be 2855 * initialized. 2856 * @param[out] pInstanceInfo2 Pointer to the memory location allocated by 2857 * the client into which the CpaInstanceInfo2 2858 * structure will be written. 2859 * 2860 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2861 * @retval CPA_STATUS_FAIL Function failed. 2862 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 2863 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2864 * 2865 * @pre 2866 * The client has retrieved an instanceHandle from successive calls to 2867 * @ref cpaDcGetNumInstances and @ref cpaDcGetInstances. 2868 * @post 2869 * None 2870 * @note 2871 * None 2872 * @see 2873 * cpaDcGetNumInstances, 2874 * cpaDcGetInstances, 2875 * CpaInstanceInfo2 2876 * 2877 *****************************************************************************/ 2878 CpaStatus 2879 cpaDcInstanceGetInfo2(const CpaInstanceHandle instanceHandle, 2880 CpaInstanceInfo2 * pInstanceInfo2); 2881 2882 /*****************************************************************************/ 2883 /* Instance Notification Functions */ 2884 /*****************************************************************************/ 2885 /** 2886 ***************************************************************************** 2887 * @ingroup cpaDc 2888 * Callback function for instance notification support. 2889 * 2890 * @description 2891 * This is the prototype for the instance notification callback function. 2892 * The callback function is passed in as a parameter to the 2893 * @ref cpaDcInstanceSetNotificationCb function. 2894 * 2895 * @context 2896 * This function will be executed in a context that requires that sleeping 2897 * MUST NOT be permitted. 2898 * @assumptions 2899 * None 2900 * @sideEffects 2901 * None 2902 * @blocking 2903 * No 2904 * @reentrant 2905 * No 2906 * @threadSafe 2907 * Yes 2908 * 2909 * @param[in] instanceHandle Instance handle. 2910 * @param[in] pCallbackTag Opaque value provided by user while making 2911 * individual function calls. 2912 * @param[in] instanceEvent The event that will trigger this function to 2913 * get invoked. 2914 * 2915 * @retval 2916 * None 2917 * @pre 2918 * Component has been initialized and the notification function has been 2919 * set via the cpaDcInstanceSetNotificationCb function. 2920 * @post 2921 * None 2922 * @note 2923 * None 2924 * @see 2925 * cpaDcInstanceSetNotificationCb(), 2926 * 2927 *****************************************************************************/ 2928 typedef void (*CpaDcInstanceNotificationCbFunc)( 2929 const CpaInstanceHandle instanceHandle, 2930 void * pCallbackTag, 2931 const CpaInstanceEvent instanceEvent); 2932 2933 /** 2934 ***************************************************************************** 2935 * @ingroup cpaDc 2936 * Subscribe for instance notifications. 2937 * 2938 * @description 2939 * Clients of the CpaDc interface can subscribe for instance notifications 2940 * by registering a @ref CpaDcInstanceNotificationCbFunc function. 2941 * 2942 * @context 2943 * This function may be called from any context. 2944 * @assumptions 2945 * None 2946 * @sideEffects 2947 * None 2948 * @blocking 2949 * No 2950 * @reentrant 2951 * No 2952 * @threadSafe 2953 * Yes 2954 * 2955 * @param[in] instanceHandle Instance handle. 2956 * @param[in] pInstanceNotificationCb Instance notification callback 2957 * function pointer. 2958 * @param[in] pCallbackTag Opaque value provided by user while 2959 * making individual function calls. 2960 * 2961 * @retval CPA_STATUS_SUCCESS Function executed successfully. 2962 * @retval CPA_STATUS_FAIL Function failed. 2963 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 2964 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 2965 * 2966 * @pre 2967 * Instance has been initialized. 2968 * @post 2969 * None 2970 * @note 2971 * None 2972 * @see 2973 * CpaDcInstanceNotificationCbFunc 2974 * 2975 *****************************************************************************/ 2976 CpaStatus 2977 cpaDcInstanceSetNotificationCb( 2978 const CpaInstanceHandle instanceHandle, 2979 const CpaDcInstanceNotificationCbFunc pInstanceNotificationCb, 2980 void *pCallbackTag); 2981 2982 2983 /** 2984 ***************************************************************************** 2985 * @ingroup cpaDc 2986 * Get the size of the memory required to hold the session information. 2987 * 2988 * @description 2989 * 2990 * The client of the Data Compression API is responsible for 2991 * allocating sufficient memory to hold session information and the context 2992 * data. This function provides a means for determining the size of the 2993 * session information and the size of the context data. 2994 * 2995 * @context 2996 * No restrictions 2997 * @assumptions 2998 * None 2999 * @sideEffects 3000 * None 3001 * @blocking 3002 * No 3003 * @reentrant 3004 * No 3005 * @threadSafe 3006 * Yes 3007 * 3008 * @param[in] dcInstance Instance handle. 3009 * @param[in] pSessionData Pointer to a user instantiated structure 3010 * containing session data. 3011 * @param[out] pSessionSize On return, this parameter will be the size 3012 * of the memory that will be 3013 * required by cpaDcInitSession() for session 3014 * data. 3015 * @param[out] pContextSize On return, this parameter will be the size 3016 * of the memory that will be required 3017 * for context data. Context data is 3018 * save/restore data including history and 3019 * any implementation specific data that is 3020 * required for a save/restore operation. 3021 * 3022 * @retval CPA_STATUS_SUCCESS Function executed successfully. 3023 * @retval CPA_STATUS_FAIL Function failed. 3024 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 3025 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 3026 * 3027 * @pre 3028 * None 3029 * @post 3030 * None 3031 * @note 3032 * Only a synchronous version of this function is provided. 3033 * 3034 * It is expected that context data is comprised of the history and 3035 * any data stores that are specific to the history such as linked 3036 * lists or hash tables. 3037 * For stateless sessions the context size returned from this function 3038 * will be zero. For stateful sessions the context size returned will 3039 * depend on the session setup data and may be zero. 3040 * 3041 * Session data is expected to include interim checksum values, various 3042 * counters and other session related data that needs to persist 3043 * between invocations. 3044 * For a given implementation of this API, it is safe to assume that 3045 * cpaDcGetSessionSize() will always return the same session size and 3046 * that the size will not be different for different setup data 3047 * parameters. However, it should be noted that the size may change: 3048 * (1) between different implementations of the API (e.g. between software 3049 * and hardware implementations or between different hardware 3050 * implementations) 3051 * (2) between different releases of the same API implementation. 3052 * 3053 * @see 3054 * cpaDcInitSession() 3055 * 3056 *****************************************************************************/ 3057 CpaStatus 3058 cpaDcGetSessionSize(CpaInstanceHandle dcInstance, 3059 CpaDcSessionSetupData* pSessionData, 3060 Cpa32U* pSessionSize, Cpa32U* pContextSize ); 3061 3062 /** 3063 ***************************************************************************** 3064 * @ingroup cpaDc 3065 * Function to return the size of the memory which must be allocated for 3066 * the pPrivateMetaData member of CpaBufferList. 3067 * 3068 * @description 3069 * This function is used to obtain the size (in bytes) required to allocate 3070 * a buffer descriptor for the pPrivateMetaData member in the 3071 * CpaBufferList structure. 3072 * Should the function return zero then no meta data is required for the 3073 * buffer list. 3074 * 3075 * @context 3076 * This function may be called from any context. 3077 * @assumptions 3078 * None 3079 * @sideEffects 3080 * None 3081 * @blocking 3082 * No 3083 * @reentrant 3084 * No 3085 * @threadSafe 3086 * Yes 3087 * 3088 * @param[in] instanceHandle Handle to an instance of this API. 3089 * @param[in] numBuffers The number of pointers in the CpaBufferList. 3090 * This is the maximum number of CpaFlatBuffers 3091 * which may be contained in this CpaBufferList. 3092 * @param[out] pSizeInBytes Pointer to the size in bytes of memory to be 3093 * allocated when the client wishes to allocate 3094 * a cpaFlatBuffer. 3095 * 3096 * @retval CPA_STATUS_SUCCESS Function executed successfully. 3097 * @retval CPA_STATUS_FAIL Function failed. 3098 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 3099 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 3100 * 3101 * @pre 3102 * None 3103 * @post 3104 * None 3105 * @note 3106 * None 3107 * @see 3108 * cpaDcGetInstances() 3109 * 3110 *****************************************************************************/ 3111 CpaStatus 3112 cpaDcBufferListGetMetaSize(const CpaInstanceHandle instanceHandle, 3113 Cpa32U numBuffers, 3114 Cpa32U *pSizeInBytes); 3115 3116 3117 /** 3118 ***************************************************************************** 3119 * @ingroup cpaDc 3120 * Function to return a string indicating the specific error that occurred 3121 * within the system. 3122 * 3123 * @description 3124 * When a function returns any error including CPA_STATUS_SUCCESS, the 3125 * client can invoke this function to get a string which describes the 3126 * general error condition, and if available additional information on 3127 * the specific error. 3128 * The Client MUST allocate CPA_STATUS_MAX_STR_LENGTH_IN_BYTES bytes for the buffer 3129 * string. 3130 * 3131 * @context 3132 * This function may be called from any context. 3133 * @assumptions 3134 * None 3135 * @sideEffects 3136 * None 3137 * @blocking 3138 * No 3139 * @reentrant 3140 * No 3141 * @threadSafe 3142 * Yes 3143 * 3144 * @param[in] dcInstance Handle to an instance of this API. 3145 * @param[in] errStatus The error condition that occurred. 3146 * @param[in,out] pStatusText Pointer to the string buffer that will 3147 * be updated with the status text. The invoking 3148 * application MUST allocate this buffer to be 3149 * exactly CPA_STATUS_MAX_STR_LENGTH_IN_BYTES. 3150 * 3151 * @retval CPA_STATUS_SUCCESS Function executed successfully. 3152 * @retval CPA_STATUS_FAIL Function failed. Note, in this scenario 3153 * it is INVALID to call this function a 3154 * second time. 3155 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 3156 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 3157 * 3158 * @pre 3159 * None 3160 * @post 3161 * None 3162 * @note 3163 * None 3164 * @see 3165 * CpaStatus 3166 * 3167 *****************************************************************************/ 3168 3169 CpaStatus 3170 cpaDcGetStatusText(const CpaInstanceHandle dcInstance, 3171 const CpaStatus errStatus, 3172 Cpa8S * pStatusText); 3173 3174 3175 /** 3176 ***************************************************************************** 3177 * @ingroup cpaDc 3178 * Set Address Translation function 3179 * 3180 * @description 3181 * This function is used to set the virtual to physical address 3182 * translation routine for the instance. The specified routine 3183 * is used by the instance to perform any required translation of 3184 * a virtual address to a physical address. If the application 3185 * does not invoke this function, then the instance will use its 3186 * default method, such as virt2phys, for address translation. 3187 * 3188 * @assumptions 3189 * None 3190 * @sideEffects 3191 * None 3192 * @blocking 3193 * This function is synchronous and blocking. 3194 * @reentrant 3195 * No 3196 * @threadSafe 3197 * Yes 3198 * 3199 * @param[in] instanceHandle Data Compression API instance handle. 3200 * @param[in] virtual2Physical Routine that performs virtual to 3201 * physical address translation. 3202 * @retval CPA_STATUS_SUCCESS Function executed successfully. 3203 * @retval CPA_STATUS_FAIL Function failed. 3204 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 3205 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 3206 * 3207 * @pre 3208 * None 3209 * @post 3210 * None 3211 * @see 3212 * None 3213 * 3214 *****************************************************************************/ 3215 CpaStatus 3216 cpaDcSetAddressTranslation(const CpaInstanceHandle instanceHandle, 3217 CpaVirtualToPhysical virtual2Physical); 3218 #ifdef __cplusplus 3219 } /* close the extern "C" { */ 3220 #endif 3221 3222 #endif /* CPA_DC_H */ 3223