tools/testing/selftests/bpf/progs/bpf_cubic.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/bpf_cubic.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/bpf_cubic.c- Extension
.c- Size
- 15078 bytes
- Lines
- 555
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
bpf_tracing_net.hbpf/bpf_tracing.herrno.h
Detected Declarations
struct bpf_bictcpfunction bictcp_resetfunction div64_u64function fls64function bictcp_clock_usfunction bictcp_hystart_resetfunction BPF_PROGfunction BPF_PROGfunction cubic_rootfunction bictcp_updatefunction BPF_PROGfunction BPF_PROGfunction BPF_PROGfunction hystart_ack_delayfunction hystart_updatefunction BPF_PROGfunction BPF_PROG
Annotated Snippet
struct bpf_bictcp {
__u32 cnt; /* increase cwnd by 1 after ACKs */
__u32 last_max_cwnd; /* last maximum snd_cwnd */
__u32 last_cwnd; /* the last snd_cwnd */
__u32 last_time; /* time when updated last_cwnd */
__u32 bic_origin_point;/* origin point of bic function */
__u32 bic_K; /* time to origin point
from the beginning of the current epoch */
__u32 delay_min; /* min delay (usec) */
__u32 epoch_start; /* beginning of an epoch */
__u32 ack_cnt; /* number of acks */
__u32 tcp_cwnd; /* estimated tcp cwnd */
__u16 unused;
__u8 sample_cnt; /* number of samples to decide curr_rtt */
__u8 found; /* the exit point is found? */
__u32 round_start; /* beginning of each round */
__u32 end_seq; /* end_seq of the round */
__u32 last_ack; /* last time when the ACK spacing is close */
__u32 curr_rtt; /* the minimum rtt of current round */
};
static void bictcp_reset(struct bpf_bictcp *ca)
{
ca->cnt = 0;
ca->last_max_cwnd = 0;
ca->last_cwnd = 0;
ca->last_time = 0;
ca->bic_origin_point = 0;
ca->bic_K = 0;
ca->delay_min = 0;
ca->epoch_start = 0;
ca->ack_cnt = 0;
ca->tcp_cwnd = 0;
ca->found = 0;
}
extern unsigned long CONFIG_HZ __kconfig;
#define HZ CONFIG_HZ
#define USEC_PER_MSEC 1000UL
#define USEC_PER_SEC 1000000UL
#define USEC_PER_JIFFY (USEC_PER_SEC / HZ)
static __u64 div64_u64(__u64 dividend, __u64 divisor)
{
return dividend / divisor;
}
#define div64_ul div64_u64
#define BITS_PER_U64 (sizeof(__u64) * 8)
static int fls64(__u64 x)
{
int num = BITS_PER_U64 - 1;
if (x == 0)
return 0;
if (!(x & (~0ull << (BITS_PER_U64-32)))) {
num -= 32;
x <<= 32;
}
if (!(x & (~0ull << (BITS_PER_U64-16)))) {
num -= 16;
x <<= 16;
}
if (!(x & (~0ull << (BITS_PER_U64-8)))) {
num -= 8;
x <<= 8;
}
if (!(x & (~0ull << (BITS_PER_U64-4)))) {
num -= 4;
x <<= 4;
}
if (!(x & (~0ull << (BITS_PER_U64-2)))) {
num -= 2;
x <<= 2;
}
if (!(x & (~0ull << (BITS_PER_U64-1))))
num -= 1;
return num + 1;
}
static __u32 bictcp_clock_us(const struct sock *sk)
{
return tcp_sk(sk)->tcp_mstamp;
}
static void bictcp_hystart_reset(struct sock *sk)
{
Annotation
- Immediate include surface: `bpf_tracing_net.h`, `bpf/bpf_tracing.h`, `errno.h`.
- Detected declarations: `struct bpf_bictcp`, `function bictcp_reset`, `function div64_u64`, `function fls64`, `function bictcp_clock_us`, `function bictcp_hystart_reset`, `function BPF_PROG`, `function BPF_PROG`, `function cubic_root`, `function bictcp_update`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.