Commit Graph

547 Commits

Author SHA1 Message Date
2465e3e0df pping: Refactor cleanup code
Add cleanup code to load_attach_bpfprogs function, so it should always
unpin tc program, and additionally detach the tc and xdp programs in
case of any failure.

Also unpin tc program directly after attaching it (rather than on
program shutdown), so that multiple instances of pping can be run
simultaneously (on different interfaces).

Finally, rename some of the functions for attaching/detaching tc
programs to be more consistent with the xdp ones.

Note: Still need to keep a copy of most of the cleanup code in main as
well, as the tc and xdp programs also need to be detached on program
shutdown or if later functions fail.

Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
2022-01-17 14:02:19 +01:00
c04f6934cf Update headers/linux/btf.h
Newer libbpf uses constants from the newer kernel header file, so
compilation breaks unless we have the newest version of the kernel header.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2022-01-17 13:12:53 +01:00
d36c5f9254 lsm-nobpf: Stop using deprecated helper
The bpf_program__next() helper was deprecated in favour of
bpf_object__next_program(), so switch to that.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2022-01-17 13:11:27 +01:00
8e9fc89bec libbpf: Update submodule version
Update the libbpf submodule to the latest version, and update the configure
script so we check for the newer bpf_object__next_program() helper (to fix
deprecation warnings).

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2022-01-17 13:11:27 +01:00
86b76f564f AF_XDP-interaction: workaround for detecting when AF_XDP is read for TX
I hope there exist a better API for determining when AF_XDP
is ready for transmitting packets.

This workaround keeps trying to send a single packet, and
check return value seen from sendto() syscall, until it
doesn't return an error.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2022-01-14 16:48:13 +01:00
6d6ac23f3b AF_XDP-interaction: warning if code completed more than possible
Give a print WARN if code/AF_XDP somehow have MORE packets to
complete from CQ than our counter for xsk->outstanding_tx packets.
This should not happen, but currently hunting for a TX issue.

The code (below) reset xsk->outstanding_tx, which were introduced
via a discussion on xdp-tutorial:
 https://github.com/xdp-project/xdp-tutorial/issues/180

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2022-01-14 14:33:11 +01:00
49c1efadf8 AF_XDP-interaction: Report warning when TX-kick via sendto fails
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2022-01-14 13:26:24 +01:00
b1b465a32f AF_XDP-interaction: Remove hack that started tv_nsec as zero
When interval goes below 1 sec this hack screwup first clock_nanosleep.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2022-01-14 11:30:50 +01:00
6367e82069 AF_XDP-interaction: Add param to adjust TX-cyclic interval
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2022-01-14 11:12:24 +01:00
2d86845b02 AF_XDP-interaction: Add option for debugging time
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2022-01-07 17:38:19 +01:00
42ea6e7938 AF_XDP-interaction: Hack to start next interval with nsec as zero
This is done to easier visually see the time difference
when debug printing the timespec's (via print_timespec).

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2022-01-07 17:38:19 +01:00
37e650cd72 AF_XDP-interaction: Handle if adjusting next_adj goes negative
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2022-01-07 17:38:19 +01:00
f53b5670a5 AF_XDP-interaction: Adjust for inaccuracy of clock_nanosleep
Measurements show that on test systems, clock_nanosleep fairly
consistently wakeup later (or after) the requested sleep time.

It is fairly trivial to simply adjust the sleep/wakeup time
with the measure inaccuracy of clock_nanosleep, and "ask"
clock_nanosleep to wakeup a bit earlier.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2022-01-07 17:38:19 +01:00
3d66217586 AF_XDP-interaction: Debug TX issue
Calling tx_pkt() before the link is ready, result in no packets
transmitted, but xsk_ring_prod__reserve() still succeeds.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2022-01-07 17:38:19 +01:00
9ba52af3b4 AF_XDP-interaction: Enable libbpf pr_debug via --debug
Like described in guide:
 https://facebookmicrosites.github.io/bpf/blog/2020/02/20/bcc-to-libbpf-howto-guide.html#libbpf-log

Enable extra libbpf debug printing when --debug gets
specified as option to our program.

This is acheived via setting a custom log handler via
libbpf API call libbpf_set_print().

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2022-01-07 17:30:53 +01:00
303e6f59c3 Merge pull request #35 from xdp-project/vestas03_AF_XDP_example
AF_XDP-interaction: Implement TX-cyclic sending
2022-01-04 17:49:47 +01:00
f3d5d3ca93 AF_XDP-interaction: cmdline options for MAC-addresses
Change Ethernet MAC in transmitted frames
 via cmdline options (-G|--tx-dmac) or (-H|--tx-smac)

Based on suggestion from: Ong Boon Leong <boon.leong.ong@intel.com>
 https://lore.kernel.org/all/20211124091821.3916046-3-boon.leong.ong@intel.com/

Suggested-by: Ong Boon Leong <boon.leong.ong@intel.com>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-14 13:52:27 +01:00
b71f7f8cac AF_XDP-interaction: Add cmdline option for enable/disabling busy-poll mode
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-14 12:26:12 +01:00
3685d5ea93 AF_XDP-interaction: Try preferred busy-polling trick
The apply_setsockopt() was taken from samples/bpf/xdpsock_user.c

Testing with --zero-copy this unfortunately doesn't solve
the issue of 8 packets bulks when requesting 4.
Notice this test was with driver igc and chip i225.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-13 23:01:09 +01:00
842c707c4e AF_XDP-interaction: Try adding XDP_USE_NEED_WAKEUP
Measurements on a receiver shows that TX doesn't happen immediately.
Even when calling sendto() for doing TX kick.

Added bind flag XDP_USE_NEED_WAKEUP, but this didn't help.

TX burst 4 packets, but in --zero-copy mode we often observe
8 packets arriving in a burst.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-13 21:34:14 +01:00
185431e6d8 AF_XDP-interaction: convert to tx_cyclic_and_rx_process
Function now also RX process packet after cyclic TX.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-13 20:45:11 +01:00
95a5a31c90 AF_XDP-interaction: add tx_cyclic_batch
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-13 20:03:39 +01:00
1750679402 AF_XDP-interaction: Move invent_tx_pkts() out of tx_batch_pkts
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-13 18:25:58 +01:00
56ba3a10df AF_XDP-interaction: Implement a TX batching function
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-07 18:12:11 +01:00
8b02218dde AF_XDP-interaction: Move function tx_pkt
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-07 15:55:30 +01:00
bd49ff6ca8 AF_XDP-interaction: Issue with XDP link down/up
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-07 15:35:51 +01:00
bb86dc7f1b AF_XDP-interaction: Adjust error msg
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-07 15:29:39 +01:00
709607bfdd AF_XDP-interaction: Fix pointer to UDP data area for memset
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-03 23:12:20 +01:00
1e8ad22fe0 AF_XDP-interaction: Limit FQ refill size
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-03 22:56:19 +01:00
37d4f466dd AF_XDP-interaction: Fix bug in mem_frame_allocator
The assumption was that our simple memory allocator for umem
frames return an addr that point to the start of the frame.

When a frame addr is freed/returned via mem_free_umem_frame()
this frame addr doesn't necessary point to the start of the
frame.  Often this is not the case.  As the kernel RX process
will add some headroom.  Our userspace TX process can also choose
to add headroom, resulting in frames returned in Completion Queue
will also have this headroom offset in the addr.

Fix by removing headroom offset when freeing/returning the
frame addr in mem_free_umem_frame().

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-03 22:30:30 +01:00
ea8b2df6aa AF_XDP-interaction: packet TX test
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-03 21:35:02 +01:00
25e8873f2f AF_XDP-interaction: Packet fill helpers
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-03 18:06:39 +01:00
c3ca3a6ffc AF_XDP-interaction: Add debug function pr_addr_info()
The packet umem addr can be an offset into the packet.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-12-03 17:44:13 +01:00
76af06aaab AF_XDP-interaction: Start on new tx and rx batch process code
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-29 16:02:57 +01:00
fcb6ef74f3 Merge pull request #30 from xdp-project/vestas02_AF_XDP_example
AF_XDP example added some results
2021-11-24 18:01:52 +01:00
021d262a0b AF_XDP-interaction: Debug RX-batch processing
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-24 17:54:52 +01:00
9584e53e57 AF_XDP-interaction: Record NIC chip used
As drivers supports multiple chips.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-24 17:10:20 +01:00
457a7a5e1e AF_XDP-interaction: Add results from system with RT kernel
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-24 17:06:25 +01:00
46cc148a03 AF_XDP-interaction: Add spin results from system B
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-19 16:21:33 +01:00
d5ff1ac505 AF_XDP-interaction: Adjust formatting#2, test GitHub rendering
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-19 16:12:14 +01:00
5a45bcbb16 AF_XDP-interaction: Adjust formatting, test GitHub rendering
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-19 16:07:18 +01:00
ff01e2a300 AF_XDP-interaction: Collect interesting data-points
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-19 15:43:45 +01:00
987dd6a15d AF_XDP-interaction: Crude stats on time-delay
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-19 15:10:43 +01:00
5e31a04734 AF_XDP-interaction: Update results table
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-19 14:49:21 +01:00
d22c08c231 AF_XDP-interaction: Add some time-delay XDP to AF_XDP results
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-19 14:41:58 +01:00
1bb141e9e3 Extend xdp_hints_rx_time with xdp_rx_cpu
The latency or time-delay between XDP and AF_XDP depend highly
on whether the XDP and AF_XDP runs on same CPU or remote CPU.

Extend xdp_hints_rx_time, without worrying about the layout
as BTF will adjust, so we can determine case of same CPU or
remote CPU.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-19 14:33:58 +01:00
1ba7209fd4 AF_XDP-interaction: README why RX-ktime matters
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-19 13:41:27 +01:00
ac95a4b498 Merge pull request #29 from xdp-project/vestas01_AF_XDP_example
Adding AF_XDP example that implement local XDP-hints via BTF
2021-11-17 09:07:33 +01:00
01aa47c814 AF_XDP-interaction: Disable stats poll as it is broken
The stats poll doesn't take into account multiple XSK sockets.
Simply disable until there is time to fix it.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-16 20:46:46 +01:00
446653f4b4 AF_XDP-interaction: Add option for real-time priority
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2021-11-16 20:12:04 +01:00