Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (c) 2024 Facebook */
3
4#include "vmlinux.h"
5#include <bpf/bpf_tracing.h>
6
7extern void bbr_init(struct sock *sk) __ksym;
8extern void bbr_main(struct sock *sk, u32 ack, int flag, const struct rate_sample *rs) __ksym;
9extern u32 bbr_sndbuf_expand(struct sock *sk) __ksym;
10extern u32 bbr_undo_cwnd(struct sock *sk) __ksym;
11extern void bbr_cwnd_event_tx_start(struct sock *sk) __ksym;
12extern u32 bbr_ssthresh(struct sock *sk) __ksym;
13extern u32 bbr_min_tso_segs(struct sock *sk) __ksym;
14extern void bbr_set_state(struct sock *sk, u8 new_state) __ksym;
15
16extern void dctcp_init(struct sock *sk) __ksym;
17extern void dctcp_update_alpha(struct sock *sk, u32 flags) __ksym;
18extern void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev) __ksym;
19extern void dctcp_cwnd_event_tx_start(struct sock *sk) __ksym;
20extern u32 dctcp_ssthresh(struct sock *sk) __ksym;
21extern u32 dctcp_cwnd_undo(struct sock *sk) __ksym;
22extern void dctcp_state(struct sock *sk, u8 new_state) __ksym;
23
24extern void cubictcp_init(struct sock *sk) __ksym;
25extern u32 cubictcp_recalc_ssthresh(struct sock *sk) __ksym;
26extern void cubictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked) __ksym;
27extern void cubictcp_state(struct sock *sk, u8 new_state) __ksym;
28extern void cubictcp_cwnd_event_tx_start(struct sock *sk) __ksym;
29extern void cubictcp_acked(struct sock *sk, const struct ack_sample *sample) __ksym;
30
31SEC("struct_ops")
32void BPF_PROG(init, struct sock *sk)
33{
34 bbr_init(sk);
35 dctcp_init(sk);
36 cubictcp_init(sk);
37}
38
39SEC("struct_ops")
40void BPF_PROG(in_ack_event, struct sock *sk, u32 flags)
41{
42 dctcp_update_alpha(sk, flags);
43}
44
45SEC("struct_ops")
46void BPF_PROG(cong_control, struct sock *sk, u32 ack, int flag, const struct rate_sample *rs)
47{
48 bbr_main(sk, ack, flag, rs);
49}
50
51SEC("struct_ops")
52void BPF_PROG(cong_avoid, struct sock *sk, u32 ack, u32 acked)
53{
54 cubictcp_cong_avoid(sk, ack, acked);
55}
56
57SEC("struct_ops")
58u32 BPF_PROG(sndbuf_expand, struct sock *sk)
59{
60 return bbr_sndbuf_expand(sk);
61}
62
63SEC("struct_ops")
64u32 BPF_PROG(undo_cwnd, struct sock *sk)
65{
66 bbr_undo_cwnd(sk);
67 return dctcp_cwnd_undo(sk);
68}
69
70SEC("struct_ops")
71void BPF_PROG(cwnd_event, struct sock *sk, enum tcp_ca_event event)
72{
73 dctcp_cwnd_event(sk, event);
74}
75
76SEC("struct_ops")
77void BPF_PROG(cwnd_event_tx_start, struct sock *sk)
78{
79 bbr_cwnd_event_tx_start(sk);
80 dctcp_cwnd_event_tx_start(sk);
81 cubictcp_cwnd_event_tx_start(sk);
82}
83
84SEC("struct_ops")
85u32 BPF_PROG(ssthresh, struct sock *sk)
86{
87 bbr_ssthresh(sk);
88 dctcp_ssthresh(sk);
89 return cubictcp_recalc_ssthresh(sk);
90}
91
92SEC("struct_ops")
93u32 BPF_PROG(min_tso_segs, struct sock *sk)
94{
95 return bbr_min_tso_segs(sk);
96}
97
98SEC("struct_ops")
99void BPF_PROG(set_state, struct sock *sk, u8 new_state)
100{
101 bbr_set_state(sk, new_state);
102 dctcp_state(sk, new_state);
103 cubictcp_state(sk, new_state);
104}
105
106SEC("struct_ops")
107void BPF_PROG(pkts_acked, struct sock *sk, const struct ack_sample *sample)
108{
109 cubictcp_acked(sk, sample);
110}
111
112SEC(".struct_ops")
113struct tcp_congestion_ops tcp_ca_kfunc = {
114 .init = (void *)init,
115 .in_ack_event = (void *)in_ack_event,
116 .cong_control = (void *)cong_control,
117 .cong_avoid = (void *)cong_avoid,
118 .sndbuf_expand = (void *)sndbuf_expand,
119 .undo_cwnd = (void *)undo_cwnd,
120 .cwnd_event = (void *)cwnd_event,
121 .cwnd_event_tx_start = (void *)cwnd_event_tx_start,
122 .ssthresh = (void *)ssthresh,
123 .min_tso_segs = (void *)min_tso_segs,
124 .set_state = (void *)set_state,
125 .pkts_acked = (void *)pkts_acked,
126 .name = "tcp_ca_kfunc",
127};
128
129char _license[] SEC("license") = "GPL";