drivers/net/ethernet/microchip/lan966x/lan966x_cbs.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/lan966x/lan966x_cbs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/lan966x/lan966x_cbs.c- Extension
.c- Size
- 1726 bytes
- Lines
- 71
- 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
lan966x_main.h
Detected Declarations
function lan966x_cbs_addfunction lan966x_cbs_del
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
#include "lan966x_main.h"
int lan966x_cbs_add(struct lan966x_port *port,
struct tc_cbs_qopt_offload *qopt)
{
struct lan966x *lan966x = port->lan966x;
u32 cir, cbs;
u8 se_idx;
/* Check for invalid values */
if (qopt->idleslope <= 0 ||
qopt->sendslope >= 0 ||
qopt->locredit >= qopt->hicredit)
return -EINVAL;
se_idx = SE_IDX_QUEUE + port->chip_port * NUM_PRIO_QUEUES + qopt->queue;
cir = qopt->idleslope;
cbs = (qopt->idleslope - qopt->sendslope) *
(qopt->hicredit - qopt->locredit) /
-qopt->sendslope;
/* Rate unit is 100 kbps */
cir = DIV_ROUND_UP(cir, 100);
/* Avoid using zero rate */
cir = cir ?: 1;
/* Burst unit is 4kB */
cbs = DIV_ROUND_UP(cbs, 4096);
/* Avoid using zero burst */
cbs = cbs ?: 1;
/* Check that actually the result can be written */
if (cir > GENMASK(15, 0) ||
cbs > GENMASK(6, 0))
return -EINVAL;
lan_rmw(QSYS_SE_CFG_SE_AVB_ENA_SET(1) |
QSYS_SE_CFG_SE_FRM_MODE_SET(1),
QSYS_SE_CFG_SE_AVB_ENA |
QSYS_SE_CFG_SE_FRM_MODE,
lan966x, QSYS_SE_CFG(se_idx));
lan_wr(QSYS_CIR_CFG_CIR_RATE_SET(cir) |
QSYS_CIR_CFG_CIR_BURST_SET(cbs),
lan966x, QSYS_CIR_CFG(se_idx));
return 0;
}
int lan966x_cbs_del(struct lan966x_port *port,
struct tc_cbs_qopt_offload *qopt)
{
struct lan966x *lan966x = port->lan966x;
u8 se_idx;
se_idx = SE_IDX_QUEUE + port->chip_port * NUM_PRIO_QUEUES + qopt->queue;
lan_rmw(QSYS_SE_CFG_SE_AVB_ENA_SET(1) |
QSYS_SE_CFG_SE_FRM_MODE_SET(0),
QSYS_SE_CFG_SE_AVB_ENA |
QSYS_SE_CFG_SE_FRM_MODE,
lan966x, QSYS_SE_CFG(se_idx));
lan_wr(QSYS_CIR_CFG_CIR_RATE_SET(0) |
QSYS_CIR_CFG_CIR_BURST_SET(0),
lan966x, QSYS_CIR_CFG(se_idx));
return 0;
}
Annotation
- Immediate include surface: `lan966x_main.h`.
- Detected declarations: `function lan966x_cbs_add`, `function lan966x_cbs_del`.
- 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.