drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.c

Source file repositories/reference/linux-study-clean/drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.c

File Facts

System
Linux kernel
Corpus path
drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.c
Extension
.c
Size
4051 bytes
Lines
166
Domain
Driver Families
Bucket
drivers/crypto
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (length == RUN_MASK) {
			unsigned int s;

			do {
				s = *ip++;
				length += s;
			} while (s == 255);
		}

		literal_len = length;

		start = ip;
		dest = literals;
		dest_end = literals + length;

		do {
			memcpy(dest, start, QAT_ZSTD_LIT_COPY_LEN);
			dest += QAT_ZSTD_LIT_COPY_LEN;
			start += QAT_ZSTD_LIT_COPY_LEN;
		} while (dest < dest_end);

		literals += length;
		*lit_len += length;

		ip += length;
		if (ip == end_ip) {
			literal_len += hist_literal_len;
			/*
			 * If adding trailing literals would overflow the
			 * current block, close it first.
			 */
			if (block_decomp_size + literal_len > QAT_ZSTD_BLOCK_MAX) {
				ret = emit_delimiter(out_seqs, &seqs_idx,
						     out_seqs_capacity,
						     lz4s_buff_size);
				if (ret)
					return ret;
			}
			out_seqs[seqs_idx].litLength = literal_len;
			out_seqs[seqs_idx].offset = offset;
			out_seqs[seqs_idx].matchLength = match_len;
			break;
		}

		offset = get_unaligned_le16(ip);
		ip += 2;

		length = token & ML_MASK;
		if (length == ML_MASK) {
			unsigned int s;

			do {
				s = *ip++;
				length += s;
			} while (s == 255);
		}
		if (length != 0) {
			length += LZ4S_MINMATCH;
			match_len = (unsigned short)length;
			literal_len += hist_literal_len;

			/*
			 * If this sequence would push the current block past
			 * the ZSTD maximum, close the block first.
			 */
			if (block_decomp_size + literal_len + match_len > QAT_ZSTD_BLOCK_MAX) {
				ret = emit_delimiter(out_seqs, &seqs_idx,
						     out_seqs_capacity,
						     lz4s_buff_size);
				if (ret)
					return ret;

				block_decomp_size = 0;
			}

			out_seqs[seqs_idx].offset = offset;
			out_seqs[seqs_idx].litLength = literal_len;
			out_seqs[seqs_idx].matchLength = match_len;
			hist_literal_len = 0;
			seqs_idx++;
			if (seqs_idx >= out_seqs_capacity - 1) {
				pr_debug("QAT ZSTD: sequence overflow (seqs_idx:%zu, capacity:%zu, lz4s_size:%u)\n",
					 seqs_idx, out_seqs_capacity, lz4s_buff_size);
				return -EOVERFLOW;
			}

			block_decomp_size += literal_len + match_len;
		} else {
			if (literal_len > 0) {
				/*

Annotation

Implementation Notes