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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sysfs.hlinux/types.hadf_cfg.hadf_cfg_services.hadf_common_drv.hadf_kpt.hadf_sysfs_kpt.h
Detected Declarations
function enable_showfunction enable_storefunction swk_shared_showfunction swk_shared_storefunction swk_max_ttl_showfunction swk_max_ttl_storefunction swk_cnt_per_fn_showfunction swk_cnt_per_fn_storefunction swk_cnt_per_pasid_showfunction swk_cnt_per_pasid_storefunction adf_sysfs_init_kptexport adf_sysfs_init_kpt
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
- Immediate include surface: `linux/sysfs.h`, `linux/types.h`, `adf_cfg.h`, `adf_cfg_services.h`, `adf_common_drv.h`, `adf_kpt.h`, `adf_sysfs_kpt.h`.
- Detected declarations: `function enable_show`, `function enable_store`, `function swk_shared_show`, `function swk_shared_store`, `function swk_max_ttl_show`, `function swk_max_ttl_store`, `function swk_cnt_per_fn_show`, `function swk_cnt_per_fn_store`, `function swk_cnt_per_pasid_show`, `function swk_cnt_per_pasid_store`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.