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

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

File Facts

System
Linux kernel
Corpus path
drivers/crypto/intel/qat/qat_common/adf_sysfs_kpt.c
Extension
.c
Size
7370 bytes
Lines
297
Domain
Driver Families
Bucket
drivers/crypto
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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

// SPDX-License-Identifier: GPL-2.0-only
/* Copyright(c) 2026 Intel Corporation */
#include <linux/sysfs.h>
#include <linux/types.h>

#include "adf_cfg.h"
#include "adf_cfg_services.h"
#include "adf_common_drv.h"
#include "adf_kpt.h"
#include "adf_sysfs_kpt.h"

static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{
	struct adf_kpt_interface_data *user_data;
	struct adf_accel_dev *accel_dev;

	accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
	if (!accel_dev)
		return -EINVAL;

	user_data = GET_KPT_USER_DATA(accel_dev);

	return sysfs_emit(buf, "%d\n", user_data->enable);
}

static ssize_t enable_store(struct device *dev, struct device_attribute *attr,
			    const char *buf, size_t count)
{
	struct adf_kpt_interface_data *user_data;
	struct adf_hw_device_data *hw_data;
	struct adf_accel_dev *accel_dev;
	bool enable;
	int ret;

	accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
	if (!accel_dev)
		return -EINVAL;

	if (adf_dev_started(accel_dev)) {
		dev_info(dev, "Device qat_dev%d must be down before enabling KPT\n",
			 accel_dev->accel_id);
		return -EINVAL;
	}

	if (adf_get_service_enabled(accel_dev) != SVC_ASYM) {
		dev_info(dev, "KPT can only be enabled when the asymmetric service is enabled\n");
		return -EINVAL;
	}

	hw_data = GET_HW_DATA(accel_dev);

	/*
	 * Restore the KPT capability bit in the device's capabilities mask
	 * before processing user input, as the bit may have been cleared if
	 * KPT was previously disabled by the user.
	 */
	hw_data->accel_capabilities_mask = hw_data->get_accel_cap(accel_dev);
	if (!hw_data->accel_capabilities_mask)
		return -EINVAL;

	ret = kstrtobool(buf, &enable);
	if (ret)
		return ret;

	user_data = GET_KPT_USER_DATA(accel_dev);
	user_data->enable = enable;

	return count;
}
static DEVICE_ATTR_RW(enable);

static ssize_t swk_shared_show(struct device *dev,
			       struct device_attribute *attr, char *buf)
{
	struct adf_kpt_interface_data *user_data;
	struct adf_accel_dev *accel_dev;

	accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
	if (!accel_dev)
		return -EINVAL;

	user_data = GET_KPT_USER_DATA(accel_dev);

	return sysfs_emit(buf, "%d\n", user_data->swk_shared);
}

static ssize_t swk_shared_store(struct device *dev, struct device_attribute *attr,
				const char *buf, size_t count)
{

Annotation

Implementation Notes