Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.8.
  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(struct sock *sk, enum tcp_ca_event event) __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 u32 dctcp_ssthresh(struct sock *sk) __ksym;
 20extern u32 dctcp_cwnd_undo(struct sock *sk) __ksym;
 21extern void dctcp_state(struct sock *sk, u8 new_state) __ksym;
 22
 23extern void cubictcp_init(struct sock *sk) __ksym;
 24extern u32 cubictcp_recalc_ssthresh(struct sock *sk) __ksym;
 25extern void cubictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked) __ksym;
 26extern void cubictcp_state(struct sock *sk, u8 new_state) __ksym;
 27extern void cubictcp_cwnd_event(struct sock *sk, enum tcp_ca_event event) __ksym;
 28extern void cubictcp_acked(struct sock *sk, const struct ack_sample *sample) __ksym;
 29
 30SEC("struct_ops")
 31void BPF_PROG(init, struct sock *sk)
 32{
 33	bbr_init(sk);
 34	dctcp_init(sk);
 35	cubictcp_init(sk);
 36}
 37
 38SEC("struct_ops")
 39void BPF_PROG(in_ack_event, struct sock *sk, u32 flags)
 40{
 41	dctcp_update_alpha(sk, flags);
 42}
 43
 44SEC("struct_ops")
 45void 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
 50SEC("struct_ops")
 51void BPF_PROG(cong_avoid, struct sock *sk, u32 ack, u32 acked)
 52{
 53	cubictcp_cong_avoid(sk, ack, acked);
 54}
 55
 56SEC("struct_ops")
 57u32 BPF_PROG(sndbuf_expand, struct sock *sk)
 58{
 59	return bbr_sndbuf_expand(sk);
 60}
 61
 62SEC("struct_ops")
 63u32 BPF_PROG(undo_cwnd, struct sock *sk)
 64{
 65	bbr_undo_cwnd(sk);
 66	return dctcp_cwnd_undo(sk);
 67}
 68
 69SEC("struct_ops")
 70void 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
 77SEC("struct_ops")
 78u32 BPF_PROG(ssthresh, struct sock *sk)
 79{
 80	bbr_ssthresh(sk);
 81	dctcp_ssthresh(sk);
 82	return cubictcp_recalc_ssthresh(sk);
 83}
 84
 85SEC("struct_ops")
 86u32 BPF_PROG(min_tso_segs, struct sock *sk)
 87{
 88	return bbr_min_tso_segs(sk);
 89}
 90
 91SEC("struct_ops")
 92void 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
 99SEC("struct_ops")
100void BPF_PROG(pkts_acked, struct sock *sk, const struct ack_sample *sample)
101{
102	cubictcp_acked(sk, sample);
103}
104
105SEC(".struct_ops")
106struct 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
121char _license[] SEC("license") = "GPL";