tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c- Extension
.c- Size
- 17817 bytes
- Lines
- 752
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- 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
vmlinux.herrno.hbpf/bpf_helpers.hbpf_experimental.hbpf_qdisc_common.h
Detected Declarations
struct fq_bpf_datastruct skb_nodestruct fq_flow_nodestruct dequeue_nonprio_ctxstruct remove_flows_ctxstruct unset_throttled_flows_ctxstruct fq_stashed_flowfunction bpf_kptr_xchg_backfunction skbn_tstamp_lessfunction fn_time_next_packet_lessfunction fq_flows_add_headfunction fq_flows_add_tailfunction fq_flows_remove_frontfunction fq_flows_is_emptyfunction fq_flow_set_detachedfunction fq_flow_is_detachedfunction sk_listenerfunction fq_new_flowfunction fq_classifyfunction fq_packet_beyond_horizonfunction BPF_PROGfunction fq_unset_throttled_flowsfunction fq_flow_set_throttledfunction fq_check_throttledfunction fq_dequeue_nonprio_flowsfunction fq_remove_flows_in_listfunction fq_gc_candidatefunction fq_remove_flowsfunction fq_gcfunction BPF_PROGfunction BPF_PROGfunction BPF_PROG
Annotated Snippet
struct fq_bpf_data {
u32 quantum;
u32 initial_quantum;
u32 flow_refill_delay;
u32 flow_plimit;
u64 horizon;
u32 orphan_mask;
u32 timer_slack;
u64 time_next_delayed_flow;
u64 unthrottle_latency_ns;
u8 horizon_drop;
u32 new_flow_cnt;
u32 old_flow_cnt;
u64 ktime_cache;
};
enum {
CLS_RET_PRIO = 0,
CLS_RET_NONPRIO = 1,
CLS_RET_ERR = 2,
};
struct skb_node {
u64 tstamp;
struct sk_buff __kptr * skb;
struct bpf_rb_node node;
};
struct fq_flow_node {
int credit;
u32 qlen;
u64 age;
u64 time_next_packet;
struct bpf_list_node list_node;
struct bpf_rb_node rb_node;
struct bpf_rb_root queue __contains(skb_node, node);
struct bpf_spin_lock lock;
struct bpf_refcount refcount;
};
struct dequeue_nonprio_ctx {
bool stop_iter;
u64 expire;
u64 now;
};
struct remove_flows_ctx {
bool gc_only;
u32 reset_cnt;
u32 reset_max;
};
struct unset_throttled_flows_ctx {
bool unset_all;
u64 now;
};
struct fq_stashed_flow {
struct fq_flow_node __kptr * flow;
};
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__type(key, __u64);
__type(value, struct fq_stashed_flow);
__uint(max_entries, NUM_QUEUE);
} fq_nonprio_flows SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__type(key, __u64);
__type(value, struct fq_stashed_flow);
__uint(max_entries, 1);
} fq_prio_flows SEC(".maps");
private(A) struct bpf_spin_lock fq_delayed_lock;
private(A) struct bpf_rb_root fq_delayed __contains(fq_flow_node, rb_node);
private(B) struct bpf_spin_lock fq_new_flows_lock;
private(B) struct bpf_list_head fq_new_flows __contains(fq_flow_node, list_node);
private(C) struct bpf_spin_lock fq_old_flows_lock;
private(C) struct bpf_list_head fq_old_flows __contains(fq_flow_node, list_node);
private(D) struct fq_bpf_data q;
/* Wrapper for bpf_kptr_xchg that expects NULL dst */
static void bpf_kptr_xchg_back(void *map_val, void *ptr)
{
void *ret;
Annotation
- Immediate include surface: `vmlinux.h`, `errno.h`, `bpf/bpf_helpers.h`, `bpf_experimental.h`, `bpf_qdisc_common.h`.
- Detected declarations: `struct fq_bpf_data`, `struct skb_node`, `struct fq_flow_node`, `struct dequeue_nonprio_ctx`, `struct remove_flows_ctx`, `struct unset_throttled_flows_ctx`, `struct fq_stashed_flow`, `function bpf_kptr_xchg_back`, `function skbn_tstamp_less`, `function fn_time_next_packet_less`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.