drivers/net/ipa/ipa_resource.c
Source file repositories/reference/linux-study-clean/drivers/net/ipa/ipa_resource.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ipa/ipa_resource.c- Extension
.c- Size
- 5358 bytes
- Lines
- 178
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hipa.hipa_data.hipa_reg.hipa_resource.h
Detected Declarations
function Copyrightfunction ipa_resource_config_commonfunction ipa_resource_config_srcfunction ipa_resource_config_dstfunction ipa_resource_config
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
* Copyright (C) 2018-2024 Linaro Ltd.
*/
#include <linux/types.h>
#include "ipa.h"
#include "ipa_data.h"
#include "ipa_reg.h"
#include "ipa_resource.h"
/**
* DOC: IPA Resources
*
* The IPA manages a set of resources internally for various purposes.
* A given IPA version has a fixed number of resource types, and a fixed
* total number of resources of each type. "Source" resource types
* are separate from "destination" resource types.
*
* Each version of IPA also has some number of resource groups. Each
* endpoint is assigned to a resource group, and all endpoints in the
* same group share pools of each type of resource. A subset of the
* total resources of each type is assigned for use by each group.
*/
static bool ipa_resource_limits_valid(struct ipa *ipa,
const struct ipa_resource_data *data)
{
u32 group_count;
u32 i;
u32 j;
/* We program at most 8 source or destination resource group limits */
BUILD_BUG_ON(IPA_RESOURCE_GROUP_MAX > 8);
group_count = data->rsrc_group_src_count;
if (!group_count || group_count > IPA_RESOURCE_GROUP_MAX)
return false;
/* Return an error if a non-zero resource limit is specified
* for a resource group not supported by hardware.
*/
for (i = 0; i < data->resource_src_count; i++) {
const struct ipa_resource *resource;
resource = &data->resource_src[i];
for (j = group_count; j < IPA_RESOURCE_GROUP_MAX; j++)
if (resource->limits[j].min || resource->limits[j].max)
return false;
}
group_count = data->rsrc_group_dst_count;
if (!group_count || group_count > IPA_RESOURCE_GROUP_MAX)
return false;
for (i = 0; i < data->resource_dst_count; i++) {
const struct ipa_resource *resource;
resource = &data->resource_dst[i];
for (j = group_count; j < IPA_RESOURCE_GROUP_MAX; j++)
if (resource->limits[j].min || resource->limits[j].max)
return false;
}
return true;
}
static void
ipa_resource_config_common(struct ipa *ipa, u32 resource_type,
const struct reg *reg,
const struct ipa_resource_limits *xlimits,
const struct ipa_resource_limits *ylimits)
{
u32 val;
val = reg_encode(reg, X_MIN_LIM, xlimits->min);
val |= reg_encode(reg, X_MAX_LIM, xlimits->max);
if (ylimits) {
val |= reg_encode(reg, Y_MIN_LIM, ylimits->min);
val |= reg_encode(reg, Y_MAX_LIM, ylimits->max);
}
iowrite32(val, ipa->reg_virt + reg_n_offset(reg, resource_type));
}
static void ipa_resource_config_src(struct ipa *ipa, u32 resource_type,
const struct ipa_resource_data *data)
{
Annotation
- Immediate include surface: `linux/types.h`, `ipa.h`, `ipa_data.h`, `ipa_reg.h`, `ipa_resource.h`.
- Detected declarations: `function Copyright`, `function ipa_resource_config_common`, `function ipa_resource_config_src`, `function ipa_resource_config_dst`, `function ipa_resource_config`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.