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

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

File Facts

System
Linux kernel
Corpus path
drivers/crypto/intel/qat/qat_common/qat_compression.c
Extension
.c
Size
7659 bytes
Lines
317
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 (alg == QAT_ZSTD || alg == QAT_LZ4S) {
			hw_data = tmp_dev->hw_device;
			caps = hw_data->accel_capabilities_ext_mask;
			mask = ADF_ACCEL_CAPABILITIES_EXT_ZSTD |
			       ADF_ACCEL_CAPABILITIES_EXT_ZSTD_LZ4S;
			if (!(caps & mask))
				continue;
		}

		if ((node == tmp_dev_node || tmp_dev_node < 0) &&
		    adf_dev_started(tmp_dev) && !list_empty(&tmp_dev->compression_list)) {
			ctr = atomic_read(&tmp_dev->ref_count);
			if (best > ctr) {
				accel_dev = tmp_dev;
				best = ctr;
			}
		}
	}

	if (!accel_dev) {
		pr_debug_ratelimited("QAT: Could not find a device on node %d\n", node);
		/* Get any started device */
		list_for_each(itr, adf_devmgr_get_head()) {
			struct adf_accel_dev *tmp_dev;

			tmp_dev = list_entry(itr, struct adf_accel_dev, list);

			if (alg == QAT_ZSTD || alg == QAT_LZ4S) {
				hw_data = tmp_dev->hw_device;
				caps = hw_data->accel_capabilities_ext_mask;
				mask = ADF_ACCEL_CAPABILITIES_EXT_ZSTD |
				       ADF_ACCEL_CAPABILITIES_EXT_ZSTD_LZ4S;
				if (!(caps & mask))
					continue;
			}

			if (adf_dev_started(tmp_dev) &&
			    !list_empty(&tmp_dev->compression_list)) {
				accel_dev = tmp_dev;
				break;
			}
		}
	}

	if (!accel_dev)
		return NULL;

	best = ~0;
	list_for_each(itr, &accel_dev->compression_list) {
		struct qat_compression_instance *tmp_inst;
		unsigned long ctr;

		tmp_inst = list_entry(itr, struct qat_compression_instance, list);
		ctr = atomic_read(&tmp_inst->refctr);
		if (best > ctr) {
			inst = tmp_inst;
			best = ctr;
		}
	}
	if (inst) {
		if (adf_dev_get(accel_dev)) {
			dev_err(&GET_DEV(accel_dev), "Could not increment dev refctr\n");
			return NULL;
		}
		atomic_inc(&inst->refctr);
	}
	return inst;
}

static int qat_compression_create_instances(struct adf_accel_dev *accel_dev)
{
	struct qat_compression_instance *inst;
	char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES];
	char val[ADF_CFG_MAX_VAL_LEN_IN_BYTES];
	unsigned long num_inst, num_msg_dc;
	unsigned long bank;
	int msg_size;
	int ret;
	int i;

	INIT_LIST_HEAD(&accel_dev->compression_list);
	strscpy(key, ADF_NUM_DC, sizeof(key));
	ret = adf_cfg_get_param_value(accel_dev, SEC, key, val);
	if (ret)
		return ret;

	ret = kstrtoul(val, 10, &num_inst);
	if (ret)
		return ret;

Annotation

Implementation Notes