Skip to content

Commit ffc979d

Browse files
committed
experiment01-tailgrow: Move extra program to bottom
The xdp_loader will default select the first BPF program in the ELF object to attach. Move the extra test programs to bottom and mention them in readme file. Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
1 parent ac85f58 commit ffc979d

2 files changed

Lines changed: 46 additions & 34 deletions

File tree

experiment01-tailgrow/README.org

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,15 @@ implements this by parsing up-to the IP-layer, and using the
2323
IP-headers total-length field ([[https://elixir.bootlin.com/linux/v5.6.10/source/include/uapi/linux/ip.h#L97][iphdr->tot_len]]). See the code for the
2424
strange bounding checks needed to convince the verifier. Notice, this
2525
is limited to IPv4 ICMP packets for testing purposes.
26+
27+
** Side-note: extra programs
28+
29+
Side-note: [[file:xdp_prog_kern.c]] also contains some other smaller
30+
programs to test =bpf_xdp_adjust_tail= grow works, and to benchmark
31+
the overhead when doing =XDP_TX=. Selecting others BPF programs via
32+
=xdp_loader= option =--prog== like this:
33+
34+
#+begin_src sh
35+
sudo ./xdp_loader --dev mlx5p1 --force --prog xdp_tailgrow
36+
sudo ./xdp_loader --dev mlx5p1 --force --prog xdp_tailgrow_tx
37+
#+end_src

experiment01-tailgrow/xdp_prog_kern.c

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,6 @@
1212
#include "../common/xdp_stats_kern_user.h"
1313
#include "../common/xdp_stats_kern.h"
1414

15-
SEC("xdp_tailgrow")
16-
int tailgrow_pass(struct xdp_md *ctx)
17-
{
18-
int offset;
19-
20-
offset = 10;
21-
bpf_xdp_adjust_tail(ctx, offset);
22-
return xdp_stats_record_action(ctx, XDP_PASS);
23-
}
24-
25-
SEC("xdp_pass")
26-
int xdp_pass_func(struct xdp_md *ctx)
27-
{
28-
return xdp_stats_record_action(ctx, XDP_PASS);
29-
}
30-
31-
/* For benchmarking tail grow overhead (does a memset)*/
32-
SEC("xdp_tailgrow_tx")
33-
int tailgrow_tx(struct xdp_md *ctx)
34-
{
35-
int offset;
36-
37-
offset = 32;
38-
bpf_xdp_adjust_tail(ctx, offset);
39-
return xdp_stats_record_action(ctx, XDP_TX);
40-
}
41-
42-
/* Baseline benchmark of XDP_TX */
43-
SEC("xdp_tx")
44-
int xdp_tx_rec(struct xdp_md *ctx)
45-
{
46-
return xdp_stats_record_action(ctx, XDP_TX);
47-
}
48-
4915
struct my_timestamp {
5016
__u16 magic;
5117
__u64 time;
@@ -126,4 +92,38 @@ int grow_parse(struct xdp_md *ctx)
12692
return xdp_stats_record_action(ctx, action);
12793
}
12894

95+
SEC("xdp_tailgrow")
96+
int tailgrow_pass(struct xdp_md *ctx)
97+
{
98+
int offset;
99+
100+
offset = 10;
101+
bpf_xdp_adjust_tail(ctx, offset);
102+
return xdp_stats_record_action(ctx, XDP_PASS);
103+
}
104+
105+
SEC("xdp_pass")
106+
int xdp_pass_func(struct xdp_md *ctx)
107+
{
108+
return xdp_stats_record_action(ctx, XDP_PASS);
109+
}
110+
111+
/* For benchmarking tail grow overhead (does a memset)*/
112+
SEC("xdp_tailgrow_tx")
113+
int tailgrow_tx(struct xdp_md *ctx)
114+
{
115+
int offset;
116+
117+
offset = 32;
118+
bpf_xdp_adjust_tail(ctx, offset);
119+
return xdp_stats_record_action(ctx, XDP_TX);
120+
}
121+
122+
/* Baseline benchmark of XDP_TX */
123+
SEC("xdp_tx")
124+
int xdp_tx_rec(struct xdp_md *ctx)
125+
{
126+
return xdp_stats_record_action(ctx, XDP_TX);
127+
}
128+
129129
char _license[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)