drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c- Extension
.c- Size
- 12974 bytes
- Lines
- 533
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/tc_act/tc_gact.hnet/tc_act/tc_mirred.hcxgb4.hcxgb4_filter.hcxgb4_tc_u32_parse.hcxgb4_tc_u32.h
Detected Declarations
function Copyrightfunction fill_action_fieldsfunction tcf_exts_for_each_actionfunction for_each_portfunction cxgb4_config_knodefunction specfunction cxgb4_delete_knodefunction cxgb4_cleanup_tc_u32
Annotated Snippet
if (next_header) {
/* For next headers, parse only keys with offmask */
if (!cls->knode.sel->keys[i].offmask)
continue;
} else {
/* For the remaining, parse only keys without offmask */
if (cls->knode.sel->keys[i].offmask)
continue;
}
found = false;
for (j = 0; entry[j].val; j++) {
if (off == entry[j].off) {
found = true;
err = entry[j].val(fs, val, mask);
if (err)
return err;
break;
}
}
if (!found)
return -EINVAL;
}
return 0;
}
/* Fill ch_filter_specification with parsed action. */
static int fill_action_fields(struct adapter *adap,
struct ch_filter_specification *fs,
struct tc_cls_u32_offload *cls)
{
unsigned int num_actions = 0;
const struct tc_action *a;
struct tcf_exts *exts;
int i;
exts = cls->knode.exts;
if (!tcf_exts_has_actions(exts))
return -EINVAL;
tcf_exts_for_each_action(i, a, exts) {
/* Don't allow more than one action per rule. */
if (num_actions)
return -EINVAL;
/* Drop in hardware. */
if (is_tcf_gact_shot(a)) {
fs->action = FILTER_DROP;
num_actions++;
continue;
}
/* Re-direct to specified port in hardware. */
if (is_tcf_mirred_egress_redirect(a)) {
struct net_device *n_dev, *target_dev;
bool found = false;
unsigned int i;
target_dev = tcf_mirred_dev(a);
for_each_port(adap, i) {
n_dev = adap->port[i];
if (target_dev == n_dev) {
fs->action = FILTER_SWITCH;
fs->eport = i;
found = true;
break;
}
}
/* Interface doesn't belong to any port of
* the underlying hardware.
*/
if (!found)
return -EINVAL;
num_actions++;
continue;
}
/* Un-supported action. */
return -EINVAL;
}
return 0;
}
int cxgb4_config_knode(struct net_device *dev, struct tc_cls_u32_offload *cls)
Annotation
- Immediate include surface: `net/tc_act/tc_gact.h`, `net/tc_act/tc_mirred.h`, `cxgb4.h`, `cxgb4_filter.h`, `cxgb4_tc_u32_parse.h`, `cxgb4_tc_u32.h`.
- Detected declarations: `function Copyright`, `function fill_action_fields`, `function tcf_exts_for_each_action`, `function for_each_port`, `function cxgb4_config_knode`, `function spec`, `function cxgb4_delete_knode`, `function cxgb4_cleanup_tc_u32`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.