1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2024 Facebook */
5 #include <bpf/bpf_tracing.h>
7 extern void bbr_init(struct sock *sk) __ksym;
8 extern void bbr_main(struct sock *sk, u32 ack, int flag, const struct rate_sample *rs) __ksym;
9 extern u32 bbr_sndbuf_expand(struct sock *sk) __ksym;
10 extern u32 bbr_undo_cwnd(struct sock *sk) __ksym;
11 extern void bbr_cwnd_event(struct sock *sk, enum tcp_ca_event event) __ksym;
12 extern u32 bbr_ssthresh(struct sock *sk) __ksym;
13 extern u32 bbr_min_tso_segs(struct sock *sk) __ksym;
14 extern void bbr_set_state(struct sock *sk, u8 new_state) __ksym;
16 extern void dctcp_init(struct sock *sk) __ksym;
17 extern void dctcp_update_alpha(struct sock *sk, u32 flags) __ksym;
18 extern void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev) __ksym;
19 extern u32 dctcp_ssthresh(struct sock *sk) __ksym;
20 extern u32 dctcp_cwnd_undo(struct sock *sk) __ksym;
21 extern void dctcp_state(struct sock *sk, u8 new_state) __ksym;
23 extern void cubictcp_init(struct sock *sk) __ksym;
24 extern u32 cubictcp_recalc_ssthresh(struct sock *sk) __ksym;
25 extern void cubictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked) __ksym;
26 extern void cubictcp_state(struct sock *sk, u8 new_state) __ksym;
27 extern void cubictcp_cwnd_event(struct sock *sk, enum tcp_ca_event event) __ksym;
28 extern void cubictcp_acked(struct sock *sk, const struct ack_sample *sample) __ksym;
31 void BPF_PROG(init, struct sock *sk)
39 void BPF_PROG(in_ack_event, struct sock *sk, u32 flags)
41 dctcp_update_alpha(sk, flags);
45 void BPF_PROG(cong_control, struct sock *sk, u32 ack, int flag, const struct rate_sample *rs)
47 bbr_main(sk, ack, flag, rs);
51 void BPF_PROG(cong_avoid, struct sock *sk, u32 ack, u32 acked)
53 cubictcp_cong_avoid(sk, ack, acked);
57 u32 BPF_PROG(sndbuf_expand, struct sock *sk)
59 return bbr_sndbuf_expand(sk);
63 u32 BPF_PROG(undo_cwnd, struct sock *sk)
66 return dctcp_cwnd_undo(sk);
70 void BPF_PROG(cwnd_event, struct sock *sk, enum tcp_ca_event event)
72 bbr_cwnd_event(sk, event);
73 dctcp_cwnd_event(sk, event);
74 cubictcp_cwnd_event(sk, event);
78 u32 BPF_PROG(ssthresh, struct sock *sk)
82 return cubictcp_recalc_ssthresh(sk);
86 u32 BPF_PROG(min_tso_segs, struct sock *sk)
88 return bbr_min_tso_segs(sk);
92 void BPF_PROG(set_state, struct sock *sk, u8 new_state)
94 bbr_set_state(sk, new_state);
95 dctcp_state(sk, new_state);
96 cubictcp_state(sk, new_state);
100 void BPF_PROG(pkts_acked, struct sock *sk, const struct ack_sample *sample)
102 cubictcp_acked(sk, sample);
106 struct tcp_congestion_ops tcp_ca_kfunc = {
107 .init = (void *)init,
108 .in_ack_event = (void *)in_ack_event,
109 .cong_control = (void *)cong_control,
110 .cong_avoid = (void *)cong_avoid,
111 .sndbuf_expand = (void *)sndbuf_expand,
112 .undo_cwnd = (void *)undo_cwnd,
113 .cwnd_event = (void *)cwnd_event,
114 .ssthresh = (void *)ssthresh,
115 .min_tso_segs = (void *)min_tso_segs,
116 .set_state = (void *)set_state,
117 .pkts_acked = (void *)pkts_acked,
118 .name = "tcp_ca_kfunc",
121 char _license[] SEC("license") = "GPL";