1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2024 Facebook */ 3 4 #include "vmlinux.h" 5 #include <bpf/bpf_tracing.h> 6 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; 15 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; 22 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; 29 30 SEC("struct_ops") 31 void BPF_PROG(init, struct sock *sk) 32 { 33 bbr_init(sk); 34 dctcp_init(sk); 35 cubictcp_init(sk); 36 } 37 38 SEC("struct_ops") 39 void BPF_PROG(in_ack_event, struct sock *sk, u32 flags) 40 { 41 dctcp_update_alpha(sk, flags); 42 } 43 44 SEC("struct_ops") 45 void BPF_PROG(cong_control, struct sock *sk, u32 ack, int flag, const struct rate_sample *rs) 46 { 47 bbr_main(sk, ack, flag, rs); 48 } 49 50 SEC("struct_ops") 51 void BPF_PROG(cong_avoid, struct sock *sk, u32 ack, u32 acked) 52 { 53 cubictcp_cong_avoid(sk, ack, acked); 54 } 55 56 SEC("struct_ops") 57 u32 BPF_PROG(sndbuf_expand, struct sock *sk) 58 { 59 return bbr_sndbuf_expand(sk); 60 } 61 62 SEC("struct_ops") 63 u32 BPF_PROG(undo_cwnd, struct sock *sk) 64 { 65 bbr_undo_cwnd(sk); 66 return dctcp_cwnd_undo(sk); 67 } 68 69 SEC("struct_ops") 70 void BPF_PROG(cwnd_event, struct sock *sk, enum tcp_ca_event event) 71 { 72 bbr_cwnd_event(sk, event); 73 dctcp_cwnd_event(sk, event); 74 cubictcp_cwnd_event(sk, event); 75 } 76 77 SEC("struct_ops") 78 u32 BPF_PROG(ssthresh, struct sock *sk) 79 { 80 bbr_ssthresh(sk); 81 dctcp_ssthresh(sk); 82 return cubictcp_recalc_ssthresh(sk); 83 } 84 85 SEC("struct_ops") 86 u32 BPF_PROG(min_tso_segs, struct sock *sk) 87 { 88 return bbr_min_tso_segs(sk); 89 } 90 91 SEC("struct_ops") 92 void BPF_PROG(set_state, struct sock *sk, u8 new_state) 93 { 94 bbr_set_state(sk, new_state); 95 dctcp_state(sk, new_state); 96 cubictcp_state(sk, new_state); 97 } 98 99 SEC("struct_ops") 100 void BPF_PROG(pkts_acked, struct sock *sk, const struct ack_sample *sample) 101 { 102 cubictcp_acked(sk, sample); 103 } 104 105 SEC(".struct_ops") 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", 119 }; 120 121 char _license[] SEC("license") = "GPL"; 122
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.