drivers/net/ethernet/microchip/lan966x/lan966x_ets.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/lan966x/lan966x_ets.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/lan966x/lan966x_ets.c- Extension
.c- Size
- 2143 bytes
- Lines
- 97
- 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_ets_hw_costfunction lan966x_ets_addfunction lan966x_ets_del
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
#include "lan966x_main.h"
#define DWRR_COST_BIT_WIDTH BIT(5)
static u32 lan966x_ets_hw_cost(u32 w_min, u32 weight)
{
u32 res;
/* Round half up: Multiply with 16 before division,
* add 8 and divide result with 16 again
*/
res = (((DWRR_COST_BIT_WIDTH << 4) * w_min / weight) + 8) >> 4;
return max_t(u32, 1, res) - 1;
}
int lan966x_ets_add(struct lan966x_port *port,
struct tc_ets_qopt_offload *qopt)
{
struct tc_ets_qopt_offload_replace_params *params;
struct lan966x *lan966x = port->lan966x;
u32 w_min = 100;
u8 count = 0;
u32 se_idx;
u8 i;
/* Check the input */
if (qopt->parent != TC_H_ROOT)
return -EINVAL;
params = &qopt->replace_params;
if (params->bands != NUM_PRIO_QUEUES)
return -EINVAL;
for (i = 0; i < params->bands; ++i) {
/* In the switch the DWRR is always on the lowest consecutive
* priorities. Due to this, the first priority must map to the
* first DWRR band.
*/
if (params->priomap[i] != (7 - i))
return -EINVAL;
if (params->quanta[i] && params->weights[i] == 0)
return -EINVAL;
}
se_idx = SE_IDX_PORT + port->chip_port;
/* Find minimum weight */
for (i = 0; i < params->bands; ++i) {
if (params->quanta[i] == 0)
continue;
w_min = min(w_min, params->weights[i]);
}
for (i = 0; i < params->bands; ++i) {
if (params->quanta[i] == 0)
continue;
++count;
lan_wr(lan966x_ets_hw_cost(w_min, params->weights[i]),
lan966x, QSYS_SE_DWRR_CFG(se_idx, 7 - i));
}
lan_rmw(QSYS_SE_CFG_SE_DWRR_CNT_SET(count) |
QSYS_SE_CFG_SE_RR_ENA_SET(0),
QSYS_SE_CFG_SE_DWRR_CNT |
QSYS_SE_CFG_SE_RR_ENA,
lan966x, QSYS_SE_CFG(se_idx));
return 0;
}
int lan966x_ets_del(struct lan966x_port *port,
struct tc_ets_qopt_offload *qopt)
{
struct lan966x *lan966x = port->lan966x;
u32 se_idx;
int i;
se_idx = SE_IDX_PORT + port->chip_port;
for (i = 0; i < NUM_PRIO_QUEUES; ++i)
lan_wr(0, lan966x, QSYS_SE_DWRR_CFG(se_idx, i));
lan_rmw(QSYS_SE_CFG_SE_DWRR_CNT_SET(0) |
QSYS_SE_CFG_SE_RR_ENA_SET(0),
Annotation
- Immediate include surface: `lan966x_main.h`.
- Detected declarations: `function lan966x_ets_hw_cost`, `function lan966x_ets_add`, `function lan966x_ets_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.