Content-Type: multipart/mixed; boundary="===============6479825425689137754==" MIME-Version: 1.0 From: Li Zhang Subject: [Accel-config] [PATCH v1 08/11] accel-config/test: Add algorithm to do Zdecompress16 Date: Tue, 17 May 2022 18:48:30 +0800 Message-ID: <20220517104833.1085245-9-li4.zhang@intel.com> In-Reply-To: 20220517104833.1085245-1-li4.zhang@intel.com To: accel-config@lists.01.org List-ID: --===============6479825425689137754== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add an algorithm to implement Zdecompress16, it is used to generate a reference data for comparing with the result from IAA hardware. Signed-off-by: Li Zhang --- test/algorithms/iaa_zcompress.c | 34 +++++++++++++++++++++++++++++++++ test/algorithms/iaa_zcompress.h | 1 + 2 files changed, 35 insertions(+) diff --git a/test/algorithms/iaa_zcompress.c b/test/algorithms/iaa_zcompres= s.c index a560918..b58a6e6 100644 --- a/test/algorithms/iaa_zcompress.c +++ b/test/algorithms/iaa_zcompress.c @@ -85,3 +85,37 @@ int iaa_do_zcompress16(void *dst, void *src, int src_len) = return dst_len; } + +int iaa_do_zdecompress16(void *dst, void *src, int src_len) +{ + int i, j, dst_len =3D 0; + uint64_t tags; + int remainder_len =3D src_len; + uint16_t *src_ptr =3D (uint16_t *)src; + uint16_t *dst_ptr =3D (uint16_t *)dst; + + for (i =3D 0; i < (src_len / 2); i++) { + tags =3D (((uint64_t)src_ptr[3]) << 48) | (((uint64_t)src_ptr[2]) << 32)= | + (((uint64_t)src_ptr[1]) << 16) | ((uint64_t)src_ptr[0]); + src_ptr +=3D 4; + remainder_len -=3D 8; + + for (j =3D 0; j < 64; j++) { + if (tags & ((uint64_t)1 << j)) { + if (remainder_len <=3D 0) + break; + *dst_ptr++ =3D *src_ptr++; + remainder_len -=3D 2; + } else { + *dst_ptr++ =3D 0; + } + + dst_len +=3D 2; + } + + if (remainder_len <=3D 0) + break; + } + + return dst_len; +} diff --git a/test/algorithms/iaa_zcompress.h b/test/algorithms/iaa_zcompres= s.h index 00b3685..eb47278 100644 --- a/test/algorithms/iaa_zcompress.h +++ b/test/algorithms/iaa_zcompress.h @@ -7,5 +7,6 @@ = void iaa_zcompress16_randomize_input(void *dst, uint64_t pattern, int len); int iaa_do_zcompress16(void *dst, void *src, int src_len); +int iaa_do_zdecompress16(void *dst, void *src, int src_len); = #endif -- = 2.25.1 --===============6479825425689137754==--