drivers/crypto/intel/qat/qat_common/adf_rl.c
Source file repositories/reference/linux-study-clean/drivers/crypto/intel/qat/qat_common/adf_rl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/intel/qat/qat_common/adf_rl.c- Extension
.c- Size
- 29769 bytes
- Lines
- 1156
- 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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/errno.hasm/div64.hlinux/dev_printk.hlinux/kernel.hlinux/pci.hlinux/slab.hlinux/units.hadf_accel_devices.hadf_cfg_services.hadf_common_drv.hadf_rl_admin.hadf_rl.hadf_sysfs_rl.h
Detected Declarations
function validate_user_inputfunction for_each_set_bitfunction validate_sla_idfunction find_parentfunction adf_rl_get_sla_arr_of_typefunction prepare_rp_idsfunction for_each_set_bitfunction mark_rps_usagefunction assign_rps_to_leaffunction assign_leaf_to_clusterfunction assign_cluster_to_rootfunction assign_node_to_parentfunction can_parent_afford_slafunction can_node_afford_updatefunction is_enough_budgetfunction update_budgetfunction get_next_free_sla_idfunction get_next_free_node_idfunction adf_rl_calculate_slice_tokensfunction adf_rl_get_num_svc_aesfunction adf_rl_calculate_ae_cyclesfunction adf_rl_calculate_pci_bwfunction add_new_sla_entryfunction initialize_default_nodesfunction clear_slafunction free_all_slafunction add_update_slafunction adf_rl_add_slafunction adf_rl_update_slafunction adf_rl_get_slafunction adf_rl_get_capability_remainingfunction adf_rl_remove_slafunction adf_rl_remove_sla_allfunction adf_rl_initfunction RL_VALIDATE_NON_ZEROfunction adf_rl_startfunction adf_rl_stopfunction adf_rl_exit
Annotated Snippet
for_each_set_bit(i, &rp_mask, rp_mask_size) {
if (++cnt > RL_RP_CNT_PER_LEAF_MAX) {
dev_notice(&GET_DEV(accel_dev),
"Too many ring pairs selected for this SLA\n");
return -EINVAL;
}
}
if (sla_in->srv >= SVC_BASE_COUNT) {
dev_notice(&GET_DEV(accel_dev),
"Wrong service type\n");
return -EINVAL;
}
if (sla_in->type > RL_LEAF) {
dev_notice(&GET_DEV(accel_dev),
"Wrong node type\n");
return -EINVAL;
}
if (sla_in->parent_id < RL_PARENT_DEFAULT_ID ||
sla_in->parent_id >= RL_NODES_CNT_MAX) {
dev_notice(&GET_DEV(accel_dev),
"Wrong parent ID\n");
return -EINVAL;
}
}
return 0;
}
static int validate_sla_id(struct adf_accel_dev *accel_dev, int sla_id)
{
struct rl_sla *sla;
if (sla_id <= RL_SLA_EMPTY_ID || sla_id >= RL_NODES_CNT_MAX) {
dev_notice(&GET_DEV(accel_dev), "Provided ID is out of bounds\n");
return -EINVAL;
}
sla = accel_dev->rate_limiting->sla[sla_id];
if (!sla) {
dev_notice(&GET_DEV(accel_dev), "SLA with provided ID does not exist\n");
return -EINVAL;
}
if (sla->type != RL_LEAF) {
dev_notice(&GET_DEV(accel_dev), "This ID is reserved for internal use\n");
return -EINVAL;
}
return 0;
}
/**
* find_parent() - Find the parent for a new SLA
* @rl_data: pointer to ratelimiting data
* @sla_in: pointer to user input data for a new SLA
*
* Function returns a pointer to the parent SLA. If the parent ID is provided
* as input in the user data, then such ID is validated and the parent SLA
* is returned.
* Otherwise, it returns the default parent SLA (root or cluster) for
* the new object.
*
* Return:
* * Pointer to the parent SLA object
* * NULL - when parent cannot be found
*/
static struct rl_sla *find_parent(struct adf_rl *rl_data,
struct adf_rl_sla_input_data *sla_in)
{
int input_parent_id = sla_in->parent_id;
struct rl_sla *root = NULL;
struct rl_sla *parent_sla;
int i;
if (sla_in->type == RL_ROOT)
return NULL;
if (input_parent_id > RL_PARENT_DEFAULT_ID) {
parent_sla = rl_data->sla[input_parent_id];
/*
* SLA can be a parent if it has the same service as the child
* and its type is higher in the hierarchy,
* for example the parent type of a LEAF must be a CLUSTER.
*/
if (parent_sla && parent_sla->srv == sla_in->srv &&
parent_sla->type == sla_in->type - 1)
Annotation
- Immediate include surface: `asm/errno.h`, `asm/div64.h`, `linux/dev_printk.h`, `linux/kernel.h`, `linux/pci.h`, `linux/slab.h`, `linux/units.h`, `adf_accel_devices.h`.
- Detected declarations: `function validate_user_input`, `function for_each_set_bit`, `function validate_sla_id`, `function find_parent`, `function adf_rl_get_sla_arr_of_type`, `function prepare_rp_ids`, `function for_each_set_bit`, `function mark_rps_usage`, `function assign_rps_to_leaf`, `function assign_leaf_to_cluster`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.