drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c- Extension
.c- Size
- 15256 bytes
- Lines
- 570
- 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.
- 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
cxgb4.hcxgb4_tc_matchall.hsched.hcxgb4_uld.hcxgb4_filter.hcxgb4_tc_flower.h
Detected Declarations
function cxgb4_policer_validatefunction cxgb4_matchall_egress_validatefunction flow_action_for_eachfunction cxgb4_matchall_tc_bind_queuesfunction cxgb4_matchall_tc_unbind_queuesfunction cxgb4_matchall_alloc_tcfunction cxgb4_matchall_free_tcfunction cxgb4_matchall_mirror_allocfunction cxgb4_matchall_mirror_freefunction cxgb4_matchall_del_filterfunction cxgb4_matchall_add_filterfunction cxgb4_matchall_alloc_filterfunction cxgb4_matchall_free_filterfunction cxgb4_tc_matchall_replacefunction cxgb4_tc_matchall_destroyfunction cxgb4_tc_matchall_statsfunction cxgb4_matchall_disable_offloadfunction cxgb4_init_tc_matchallfunction cxgb4_cleanup_tc_matchall
Annotated Snippet
switch (entry->id) {
case FLOW_ACTION_POLICE:
ret = cxgb4_policer_validate(actions, entry, extack);
if (ret)
return ret;
/* Convert bytes per second to bits per second */
if (entry->police.rate_bytes_ps * 8 > max_link_rate) {
NL_SET_ERR_MSG_MOD(extack,
"Specified policing max rate is larger than underlying link speed");
return -ERANGE;
}
break;
default:
NL_SET_ERR_MSG_MOD(extack,
"Only policing action supported with Egress MATCHALL offload");
return -EOPNOTSUPP;
}
}
for (i = 0; i < pi->nqsets; i++) {
memset(&qe, 0, sizeof(qe));
qe.queue = i;
e = cxgb4_sched_queue_lookup(dev, &qe);
if (e && e->info.u.params.level != SCHED_CLASS_LEVEL_CH_RL) {
NL_SET_ERR_MSG_MOD(extack,
"Some queues are already bound to different class");
return -EBUSY;
}
}
return 0;
}
static int cxgb4_matchall_tc_bind_queues(struct net_device *dev, u32 tc)
{
struct port_info *pi = netdev2pinfo(dev);
struct ch_sched_queue qe;
int ret;
u32 i;
for (i = 0; i < pi->nqsets; i++) {
qe.queue = i;
qe.class = tc;
ret = cxgb4_sched_class_bind(dev, &qe, SCHED_QUEUE);
if (ret)
goto out_free;
}
return 0;
out_free:
while (i--) {
qe.queue = i;
qe.class = SCHED_CLS_NONE;
cxgb4_sched_class_unbind(dev, &qe, SCHED_QUEUE);
}
return ret;
}
static void cxgb4_matchall_tc_unbind_queues(struct net_device *dev)
{
struct port_info *pi = netdev2pinfo(dev);
struct ch_sched_queue qe;
u32 i;
for (i = 0; i < pi->nqsets; i++) {
qe.queue = i;
qe.class = SCHED_CLS_NONE;
cxgb4_sched_class_unbind(dev, &qe, SCHED_QUEUE);
}
}
static int cxgb4_matchall_alloc_tc(struct net_device *dev,
struct tc_cls_matchall_offload *cls)
{
struct ch_sched_params p = {
.type = SCHED_CLASS_TYPE_PACKET,
.u.params.level = SCHED_CLASS_LEVEL_CH_RL,
.u.params.mode = SCHED_CLASS_MODE_CLASS,
.u.params.rateunit = SCHED_CLASS_RATEUNIT_BITS,
.u.params.ratemode = SCHED_CLASS_RATEMODE_ABS,
.u.params.class = SCHED_CLS_NONE,
.u.params.minrate = 0,
.u.params.weight = 0,
.u.params.pktsize = dev->mtu,
};
struct netlink_ext_ack *extack = cls->common.extack;
Annotation
- Immediate include surface: `cxgb4.h`, `cxgb4_tc_matchall.h`, `sched.h`, `cxgb4_uld.h`, `cxgb4_filter.h`, `cxgb4_tc_flower.h`.
- Detected declarations: `function cxgb4_policer_validate`, `function cxgb4_matchall_egress_validate`, `function flow_action_for_each`, `function cxgb4_matchall_tc_bind_queues`, `function cxgb4_matchall_tc_unbind_queues`, `function cxgb4_matchall_alloc_tc`, `function cxgb4_matchall_free_tc`, `function cxgb4_matchall_mirror_alloc`, `function cxgb4_matchall_mirror_free`, `function cxgb4_matchall_del_filter`.
- 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.