drivers/net/ethernet/microchip/sparx5/sparx5_qos.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/sparx5/sparx5_qos.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/sparx5/sparx5_qos.c- Extension
.c- Size
- 14379 bytes
- Lines
- 584
- 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
net/pkt_cls.hsparx5_main.hsparx5_qos.h
Detected Declarations
function Copyrightfunction sparx5_get_hsch_max_group_ratefunction sparx5_lg_get_leak_timefunction sparx5_lg_set_leak_timefunction sparx5_lg_get_firstfunction sparx5_lg_get_nextfunction sparx5_lg_get_lastfunction sparx5_lg_is_lastfunction sparx5_lg_is_firstfunction sparx5_lg_is_emptyfunction sparx5_lg_is_singularfunction sparx5_lg_enablefunction sparx5_lg_disablefunction sparx5_lg_get_group_by_indexfunction sparx5_lg_get_group_by_ratefunction sparx5_lg_get_adjacentfunction sparx5_lg_conf_setfunction sparx5_lg_delfunction sparx5_lg_addfunction sparx5_shaper_conf_setfunction sparx5_weight_to_hw_costfunction sparx5_dwrr_conf_setfunction sparx5_leak_groups_initfunction sparx5_qos_initfunction sparx5_tc_mqprio_addfunction sparx5_tc_mqprio_delfunction sparx5_tc_tbf_addfunction sparx5_tc_tbf_delfunction sparx5_tc_ets_addfunction sparx5_tc_ets_del
Annotated Snippet
if (new_time < threshold_time) {
new_time += cycle_time * nr_of_cycles_p2;
while (new_time < threshold_time)
new_time += cycle_time * nr_of_cycles_p2;
new_time -= cycle_time * nr_of_cycles_p2;
}
nr_of_cycles_p2 >>= 1; /* Next (lower) power of 2 */
}
new_time += cycle_time;
*new_base_time = new_time;
}
/* Max rates for leak groups */
static const u32 spx5_hsch_max_group_rate[SPX5_HSCH_LEAK_GRP_CNT] = {
1048568, /* 1.049 Gbps */
2621420, /* 2.621 Gbps */
10485680, /* 10.486 Gbps */
26214200 /* 26.214 Gbps */
};
u32 sparx5_get_hsch_max_group_rate(int grp)
{
return spx5_hsch_max_group_rate[grp];
}
static struct sparx5_layer layers[SPX5_HSCH_LAYER_CNT];
static u32 sparx5_lg_get_leak_time(struct sparx5 *sparx5, u32 layer, u32 group)
{
u32 value;
value = spx5_rd(sparx5, HSCH_HSCH_TIMER_CFG(layer, group));
return HSCH_HSCH_TIMER_CFG_LEAK_TIME_GET(value);
}
static void sparx5_lg_set_leak_time(struct sparx5 *sparx5, u32 layer, u32 group,
u32 leak_time)
{
spx5_wr(HSCH_HSCH_TIMER_CFG_LEAK_TIME_SET(leak_time), sparx5,
HSCH_HSCH_TIMER_CFG(layer, group));
}
static u32 sparx5_lg_get_first(struct sparx5 *sparx5, u32 layer, u32 group)
{
u32 value;
value = spx5_rd(sparx5, HSCH_HSCH_LEAK_CFG(layer, group));
return HSCH_HSCH_LEAK_CFG_LEAK_FIRST_GET(value);
}
static u32 sparx5_lg_get_next(struct sparx5 *sparx5, u32 layer, u32 group,
u32 idx)
{
u32 value;
value = spx5_rd(sparx5, HSCH_SE_CONNECT(idx));
return HSCH_SE_CONNECT_SE_LEAK_LINK_GET(value);
}
static u32 sparx5_lg_get_last(struct sparx5 *sparx5, u32 layer, u32 group)
{
u32 itr, next;
itr = sparx5_lg_get_first(sparx5, layer, group);
for (;;) {
next = sparx5_lg_get_next(sparx5, layer, group, itr);
if (itr == next)
return itr;
itr = next;
}
}
static bool sparx5_lg_is_last(struct sparx5 *sparx5, u32 layer, u32 group,
u32 idx)
{
return idx == sparx5_lg_get_next(sparx5, layer, group, idx);
}
static bool sparx5_lg_is_first(struct sparx5 *sparx5, u32 layer, u32 group,
u32 idx)
{
return idx == sparx5_lg_get_first(sparx5, layer, group);
}
static bool sparx5_lg_is_empty(struct sparx5 *sparx5, u32 layer, u32 group)
{
return sparx5_lg_get_leak_time(sparx5, layer, group) == 0;
Annotation
- Immediate include surface: `net/pkt_cls.h`, `sparx5_main.h`, `sparx5_qos.h`.
- Detected declarations: `function Copyright`, `function sparx5_get_hsch_max_group_rate`, `function sparx5_lg_get_leak_time`, `function sparx5_lg_set_leak_time`, `function sparx5_lg_get_first`, `function sparx5_lg_get_next`, `function sparx5_lg_get_last`, `function sparx5_lg_is_last`, `function sparx5_lg_is_first`, `function sparx5_lg_is_empty`.
- 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.