diff options
author | Martin KaFai Lau <kafai@fb.com> | 2020-01-23 02:36:58 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-01-23 03:30:10 +0300 |
commit | 6de4a9c430b57c6ebbccd2a1725f42e9be75f592 (patch) | |
tree | 0632f77c714898a1ae96619361d986f706979535 /tools/testing/selftests/bpf/bpf_tcp_helpers.h | |
parent | 0a49c1a8e26266ad505704f54f9fdaf2ae14cbdb (diff) | |
download | linux-6de4a9c430b57c6ebbccd2a1725f42e9be75f592.tar.xz |
bpf: tcp: Add bpf_cubic example
This patch adds a bpf_cubic example. Some highlights:
1. CONFIG_HZ .kconfig map is used.
2. In bictcp_update(), calculation is changed to use usec
resolution (i.e. USEC_PER_JIFFY) instead of using jiffies.
Thus, usecs_to_jiffies() is not used in the bpf_cubic.c.
3. In bitctcp_update() [under tcp_friendliness], the original
"while (ca->ack_cnt > delta)" loop is changed to the equivalent
"ca->ack_cnt / delta" operation.
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200122233658.903774-1-kafai@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/bpf_tcp_helpers.h')
-rw-r--r-- | tools/testing/selftests/bpf/bpf_tcp_helpers.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/bpf_tcp_helpers.h b/tools/testing/selftests/bpf/bpf_tcp_helpers.h index 6fee732f0297..8f21965ffc6c 100644 --- a/tools/testing/selftests/bpf/bpf_tcp_helpers.h +++ b/tools/testing/selftests/bpf/bpf_tcp_helpers.h @@ -6,13 +6,28 @@ #include <linux/types.h> #include <bpf/bpf_helpers.h> #include <bpf/bpf_core_read.h> +#include "bpf_trace_helpers.h" + +#define BPF_STRUCT_OPS(name, args...) \ +SEC("struct_ops/"#name) \ +BPF_PROG(name, args) + +#define tcp_jiffies32 ((__u32)bpf_jiffies64()) struct sock_common { unsigned char skc_state; } __attribute__((preserve_access_index)); +enum sk_pacing { + SK_PACING_NONE = 0, + SK_PACING_NEEDED = 1, + SK_PACING_FQ = 2, +}; + struct sock { struct sock_common __sk_common; + unsigned long sk_pacing_rate; + __u32 sk_pacing_status; /* see enum sk_pacing */ } __attribute__((preserve_access_index)); struct inet_sock { @@ -54,6 +69,7 @@ struct tcp_sock { __u32 max_packets_out; __u32 lsndtime; __u32 prior_cwnd; + __u64 tcp_mstamp; /* most recent packet received/sent */ } __attribute__((preserve_access_index)); static __always_inline struct inet_connection_sock *inet_csk(const struct sock *sk) |