Message ID | 20210401021117.13360-1-boon.leong.ong@intel.com (mailing list archive) |
---|---|
Headers | show |
Series | stmmac: Add XDP support | expand |
> Hi, > > This is the v4 patch series for adding XDP native support to stmmac. > > Changes in v4: > 5/6: Move TX clean timer setup to the end of NAPI RX process and > group it under stmmac_finalize_xdp_rx(). > Also, fixed stmmac_xdp_xmit_back() returns STMMAC_XDP_CONSUMED > if XDP buffer conversion to XDP frame fails. > > 6/6: Move xdp_do_flush(0 into stmmac_finalize_xdp_rx() and combine > the XDP verdict of XDP TX and XDP REDIRECT together. > > I retested the patch series on the 'xdp2' and 'xdp_redirect' related to changes > above and found the result to be satisfactory. > > History of previous patch series: > v3: > https://patchwork.kernel.org/project/netdevbpf/cover/20210331154135.850 > 7-1-boon.leong.ong@intel.com/ > v2: https://patchwork.kernel.org/project/netdevbpf/list/?series=457757 > v1: https://patchwork.kernel.org/project/netdevbpf/list/?series=457139 > > It will be great if community can help to test or review the v4 series and > provide me any input if any. > > Thank you very much, > Boon Leong > > Ong Boon Leong (6): > net: stmmac: set IRQ affinity hint for multi MSI vectors > net: stmmac: make SPH enable/disable to be configurable > net: stmmac: arrange Tx tail pointer update to > stmmac_flush_tx_descriptors > net: stmmac: Add initial XDP support > net: stmmac: Add support for XDP_TX action > net: stmmac: Add support for XDP_REDIRECT action > > drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + > drivers/net/ethernet/stmicro/stmmac/stmmac.h | 35 +- > .../net/ethernet/stmicro/stmmac/stmmac_main.c | 539 +++++++++++++++--- > .../net/ethernet/stmicro/stmmac/stmmac_xdp.c | 40 ++ > .../net/ethernet/stmicro/stmmac/stmmac_xdp.h | 12 + > 5 files changed, 547 insertions(+), 80 deletions(-) create mode 100644 > drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c > create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.h > > -- > 2.25.1 I tested these patches on my Intel ADL platform using xdp1, xdp2, xdp-redirect, xdp-redirect-cpu and xdp-adjust-tail apps in samples/bpf. Samples/pktgen/pktgen_sample03_burst_single_flow.sh script is used to send burst traffics from link partner (LP) to ADL platform. Thev result looked good and satisfying. Following shows the test steps and results that are obtained using Intel mGbE controller under preempt-rt environment. Board Setup ########### ___________________ ___________________ | | | | | enp0s30f4 | <---------> | enp0s30f4 | | ADL | LP | | enp0s30f5 | <---------> | enp0s30f5 | |___________________| |___________________| XDP_DROP Native mode #################### ADL:~# taskset -c 1 ./xdp1 enp0s30f4 libbpf: elf: skipping unrecognized data section(16) .eh_frame libbpf: elf: skipping relo section(17) .rel.eh_frame for section(16) .eh_frame proto 17: 0 pkt/s proto 17: 6 pkt/s proto 17: 658310 pkt/s proto 17: 679719 pkt/s proto 17: 681285 pkt/s proto 17: 681035 pkt/s proto 17: 680345 pkt/s proto 17: 678550 pkt/s proto 17: 680796 pkt/s proto 17: 681186 pkt/s XDP_DROP skb mode ################# ADL:~# taskset -c 1 ./xdp -S enp0s30f4 libbpf: elf: skipping unrecognized data section(16) .eh_frame libbpf: elf: skipping relo section(17) .rel.eh_frame for section(16) .eh_frame proto 17: 0 pkt/s proto 17: 0 pkt/s proto 17: 113288 pkt/s proto 17: 244100 pkt/s proto 17: 222234 pkt/s proto 17: 246207 pkt/s proto 17: 245042 pkt/s proto 17: 228392 pkt/s proto 17: 243027 pkt/s proto 17: 195756 pkt/s XDP_REDIRECT (CPU 0 -> CPU 0) ############################# ADL:~# ./xdp_redirect_cpu-dev enp0s30f4 --cpu 0 libbpf: elf: skipping unrecognized data section(39) .eh_frame libbpf: elf: skipping relo section(40) .rel.eh_frame for section(39) .eh_frame libbpf: elf: skipping unrecognized data section(20) .eh_frame libbpf: elf: skipping relo section(21) .rel.eh_frame for section(20) .eh_frame Add-new CPU:0 as idx:0 qsize:192 prog_fd: 33 (cpus_count:1) Running XDP/eBPF prog_name:xdp_cpu_map5_lb_hash_ip_pairs XDP-cpumap CPU:to pps drop-pps extra-info XDP-RX total 0 0 cpumap_kthread total 0 0 0 redirect_err total 0 0 xdp_exception total 0 0 2nd remote XDP/eBPF prog_name: xdp_redirect_dummy XDP-cpumap CPU:to xdp-pass xdp-drop xdp-redir xdp-in-kthread total 0 0 0 Running XDP/eBPF prog_name:xdp_cpu_map5_lb_hash_ip_pairs XDP-cpumap CPU:to pps drop-pps extra-info XDP-RX 0 345,419 0 0 XDP-RX total 345,419 0 cpumap-enqueue 0:0 345,437 221,150 7.82 bulk-average cpumap-enqueue sum:0 345,437 221,150 7.82 bulk-average cpumap_kthread 0 124,204 0 0 cpumap_kthread total 124,204 0 0 redirect_err total 0 0 xdp_exception total 0 0 2nd remote XDP/eBPF prog_name: xdp_redirect_dummy XDP-cpumap CPU:to xdp-pass xdp-drop xdp-redir xdp-in-kthread 0 124,204 0 0 xdp-in-kthread total 124,204 0 0 Running XDP/eBPF prog_name:xdp_cpu_map5_lb_hash_ip_pairs XDP-cpumap CPU:to pps drop-pps extra-info XDP-RX 0 670,172 0 0 XDP-RX total 670,172 0 cpumap-enqueue 0:0 670,156 387,270 7.81 bulk-average cpumap-enqueue sum:0 670,156 387,270 7.81 bulk-average cpumap_kthread 0 282,904 0 0 cpumap_kthread total 282,904 0 0 redirect_err total 0 0 xdp_exception total 0 0 2nd remote XDP/eBPF prog_name: xdp_redirect_dummy XDP-cpumap CPU:to xdp-pass xdp-drop xdp-redir xdp-in-kthread 0 282,904 0 0 xdp-in-kthread total 282,904 0 0 Running XDP/eBPF prog_name:xdp_cpu_map5_lb_hash_ip_pairs XDP-cpumap CPU:to pps drop-pps extra-info XDP-RX 0 660,924 0 0 XDP-RX total 660,924 0 cpumap-enqueue 0:0 660,931 393,566 7.81 bulk-average cpumap-enqueue sum:0 660,931 393,566 7.81 bulk-average cpumap_kthread 0 267,350 0 0 cpumap_kthread total 267,350 0 0 redirect_err total 0 0 xdp_exception total 0 0 2nd remote XDP/eBPF prog_name: xdp_redirect_dummy XDP-cpumap CPU:to xdp-pass xdp-drop xdp-redir xdp-in-kthread 0 267,351 0 0 xdp-in-kthread total 267,351 0 0 Running XDP/eBPF prog_name:xdp_cpu_map5_lb_hash_ip_pairs XDP-cpumap CPU:to pps drop-pps extra-info XDP-RX 0 671,898 0 0 XDP-RX total 671,898 0 cpumap-enqueue 0:0 671,890 398,465 7.81 bulk-average cpumap-enqueue sum:0 671,890 398,465 7.81 bulk-average cpumap_kthread 0 273,429 0 0 cpumap_kthread total 273,429 0 0 redirect_err total 0 0 xdp_exception total 0 0 2nd remote XDP/eBPF prog_name: xdp_redirect_dummy XDP-cpumap CPU:to xdp-pass xdp-drop xdp-redir xdp-in-kthread 0 273,429 0 0 xdp-in-kthread total 273,429 0 0 XDP_REDIRECT (CPU 0 -> CPU 1) ############################# ADL:~# ./xdp_redirect_cpu --dev enp0s30f4 --cpu 1 libbpf: elf: skipping unrecognized data section(39) .eh_frame libbpf: elf: skipping relo section(40) .rel.eh_frame for section(39) .eh_frame libbpf: elf: skipping unrecognized data section(20) .eh_frame libbpf: elf: skipping relo section(21) .rel.eh_frame for section(20) .eh_frame Add-new CPU:1 as idx:0 qsize:192 prog_fd: 33 (cpus_count:1) Running XDP/eBPF prog_name:xdp_cpu_map5_lb_hash_ip_pairs XDP-cpumap CPU:to pps drop-pps extra-info XDP-RX total 0 0 cpumap_kthread total 0 0 0 redirect_err total 0 0 xdp_exception total 0 0 2nd remote XDP/eBPF prog_name: xdp_redirect_dummy XDP-cpumap CPU:to xdp-pass xdp-drop xdp-redir xdp-in-kthread total 0 0 0 Running XDP/eBPF prog_name:xdp_cpu_map5_lb_hash_ip_pairs XDP-cpumap CPU:to pps drop-pps extra-info XDP-RX 0 427,639 0 0 XDP-RX total 427,639 0 cpumap-enqueue 0:1 427,642 202,047 7.81 bulk-average cpumap-enqueue sum:1 427,642 202,047 7.81 bulk-average cpumap_kthread 1 225,528 0 0 cpumap_kthread total 225,528 0 0 redirect_err total 0 0 xdp_exception total 0 0 2nd remote XDP/eBPF prog_name: xdp_redirect_dummy XDP-cpumap CPU:to xdp-pass xdp-drop xdp-redir xdp-in-kthread 1 225,528 0 0 xdp-in-kthread total 225,528 0 0 Running XDP/eBPF prog_name:xdp_cpu_map5_lb_hash_ip_pairs XDP-cpumap CPU:to pps drop-pps extra-info XDP-RX 0 666,549 0 0 XDP-RX total 666,549 0 cpumap-enqueue 0:1 666,569 315,294 7.81 bulk-average cpumap-enqueue sum:1 666,569 315,294 7.81 bulk-average cpumap_kthread 1 351,251 0 0 cpumap_kthread total 351,251 0 0 redirect_err total 0 0 xdp_exception total 0 0 2nd remote XDP/eBPF prog_name: xdp_redirect_dummy XDP-cpumap CPU:to xdp-pass xdp-drop xdp-redir xdp-in-kthread 1 351,252 0 0 xdp-in-kthread total 351,252 0 0 Running XDP/eBPF prog_name:xdp_cpu_map5_lb_hash_ip_pairs XDP-cpumap CPU:to pps drop-pps extra-info XDP-RX 0 671,218 0 0 XDP-RX total 671,218 0 cpumap-enqueue 0:1 671,198 322,057 7.81 bulk-average cpumap-enqueue sum:1 671,198 322,057 7.81 bulk-average cpumap_kthread 1 349,168 0 0 cpumap_kthread total 349,168 0 0 redirect_err total 0 0 xdp_exception total 0 0 2nd remote XDP/eBPF prog_name: xdp_redirect_dummy XDP-cpumap CPU:to xdp-pass xdp-drop xdp-redir xdp-in-kthread 1 349,169 0 0 xdp-in-kthread total 349,169 0 0 Running XDP/eBPF prog_name:xdp_cpu_map5_lb_hash_ip_pairs XDP-cpumap CPU:to pps drop-pps extra-info XDP-RX 0 663,667 0 0 XDP-RX total 663,667 0 cpumap-enqueue 0:1 663,682 317,167 7.81 bulk-average cpumap-enqueue sum:1 663,682 317,167 7.81 bulk-average cpumap_kthread 1 346,498 0 0 cpumap_kthread total 346,498 0 0 redirect_err total 0 0 xdp_exception total 0 0 2nd remote XDP/eBPF prog_name: xdp_redirect_dummy XDP-cpumap CPU:to xdp-pass xdp-drop xdp-redir xdp-in-kthread 1 346,498 0 0 xdp-in-kthread total 346,498 0 0 XDP_TX Native mode ################## ADL:~# taskset -c 1 ./xdp2 enp0s30f4 libbpf: elf: skipping unrecognized data section(16) .eh_frame libbpf: elf: skipping relo section(17) .rel.eh_frame for section(16) .eh_frame proto 17: 0 pkt/s proto 17: 53032 pkt/s proto 17: 710618 pkt/s proto 17: 711055 pkt/s proto 17: 711740 pkt/s proto 17: 711797 pkt/s proto 17: 707434 pkt/s proto 17: 684045 pkt/s proto 17: 707764 pkt/s proto 17: 712372 pkt/s LP:~# tcpdump -nei enp0s30f4 udp port 5100 -Q in 20:49:18.963638 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:49:18.963638 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:49:18.963638 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:49:18.963638 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:49:18.963638 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 XDP_TX skb mode ############### ADL:~# taskset -c 1 ./xdp2 -S enp0s30f4 libbpf: elf: skipping unrecognized data section(16) .eh_frame libbpf: elf: skipping relo section(17) .rel.eh_frame for section(16) .eh_frame proto 17: 0 pkt/s proto 17: 0 pkt/s proto 17: 128325 pkt/s proto 17: 179723 pkt/s proto 17: 185476 pkt/s proto 17: 182408 pkt/s proto 17: 185688 pkt/s proto 17: 172516 pkt/s proto 17: 185351 pkt/s proto 17: 184617 pkt/s LP:~# tcpdump -nei enp0s30f4 udp port 5100 -Q in 20:51:39.613069 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:51:39.613373 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:51:39.613486 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:51:39.613581 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:51:39.613684 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 XDP_REDIRECT Native mode (enp0s30f4 Rx -> enp0s30f5 Tx) ####################################################### ADL:~# ./xdp_redirect enp0s30f4 enp0s30f5 input: 5 output: 6 libbpf: elf: skipping unrecognized data section(20) .eh_frame libbpf: elf: skipping relo section(21) .rel.eh_frame for section(20) .eh_frame ifindex 6: 0 pkt/s ifindex 6: 136241 pkt/s ifindex 6: 702588 pkt/s ifindex 6: 703771 pkt/s ifindex 6: 702328 pkt/s ifindex 6: 703372 pkt/s ifindex 6: 700253 pkt/s ifindex 6: 702647 pkt/s LP:~# tcpdump -nei enp0s30f5 udp port 5100 -Q in 20:59:49.846614 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:59:49.846614 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:59:49.846614 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:59:49.846634 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 20:59:49.846634 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 XDP_REDIRECT skb mode (enp0s30f4 Rx -> enp0s30f5 Tx) #################################################### ADL:~/# ./xdp_redirect -S enp0s30f4 enp0s30f5 input: 5 output: 6 libbpf: elf: skipping unrecognized data section(20) .eh_frame libbpf: elf: skipping relo section(21) .rel.eh_frame for section(20) .eh_frame ifindex 6: 0 pkt/s ifindex 6: 166041 pkt/s ifindex 6: 186639 pkt/s ifindex 6: 176872 pkt/s ifindex 6: 184643 pkt/s ifindex 6: 188171 pkt/s ifindex 6: 183235 pkt/s LP:~# tcpdump -nei enp0s30f5 udp port 5100 -Q in 21:10:09.650126 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 21:10:09.650144 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 21:10:09.650145 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 21:10:09.650145 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 21:10:09.650146 88:ab:cd:00:ef:5c > 88:ab:cd:11:01:23, ethertype IPv4 (0x0800), length 60: 169.254.1.22.9 > 169.254.1.11.5100: UDP, length 18 XDP_ADJUST_TAIL skb mode ######################## ADL:~# ./xdp_adjust_tail -i enp0s30f4 -P 400 -S libbpf: elf: skipping unrecognized data section(18) .eh_frame libbpf: elf: skipping relo section(19) .rel.eh_frame for section(18) .eh_frame icmp "packet too big" sent: 0 pkts icmp "packet too big" sent: 0 pkts icmp "packet too big" sent: 0 pkts icmp "packet too big" sent: 10 pkts icmp "packet too big" sent: 10 pkts icmp "packet too big" sent: 10 pkts icmp "packet too big" sent: 10 pkts icmp "packet too big" sent: 10 pkts icmp "packet too big" sent: 10 pkts icmp "packet too big" sent: 10 pkts LP:~# ping 169.254.1.11 -s 300 -i 0.1 -c 10 PING 169.254.1.11 (169.254.1.11) 300(328) bytes of data. 308 bytes from 169.254.1.11: icmp_seq=1 ttl=64 time=0.943 ms 308 bytes from 169.254.1.11: icmp_seq=2 ttl=64 time=1.04 ms 308 bytes from 169.254.1.11: icmp_seq=3 ttl=64 time=1.13 ms 308 bytes from 169.254.1.11: icmp_seq=4 ttl=64 time=0.974 ms 308 bytes from 169.254.1.11: icmp_seq=5 ttl=64 time=1.08 ms 308 bytes from 169.254.1.11: icmp_seq=6 ttl=64 time=0.951 ms 308 bytes from 169.254.1.11: icmp_seq=7 ttl=64 time=1.10 ms 308 bytes from 169.254.1.11: icmp_seq=8 ttl=64 time=0.878 ms 308 bytes from 169.254.1.11: icmp_seq=9 ttl=64 time=1.34 ms 308 bytes from 169.254.1.11: icmp_seq=10 ttl=64 time=1.20 ms --- 169.254.1.11 ping statistics --- 10 packets transmitted, 10 received, 0% packet loss, time 907ms rtt min/avg/max/mdev = 0.878/1.063/1.340/0.131 ms LP:~# ping 169.254.1.11 -s 500 -i 0.1 -c 10 PING 169.254.1.11 (169.254.1.11) 500(528) bytes of data. --- 169.254.1.11 ping statistics --- 10 packets transmitted, 0 received, 100% packet loss, time 933ms XDP_ADJUST_TAIL Native mode ########################### ADL:~# ./xdp_adjust_tail -i enp0s30f4 -P 400 -N libbpf: elf: skipping unrecognized data section(18) .eh_frame libbpf: elf: skipping relo section(19) .rel.eh_frame for section(18) .eh_frame icmp "packet too big" sent: 0 pkts icmp "packet too big" sent: 0 pkts icmp "packet too big" sent: 1 pkts icmp "packet too big" sent: 1 pkts icmp "packet too big" sent: 2 pkts icmp "packet too big" sent: 2 pkts icmp "packet too big" sent: 2 pkts icmp "packet too big" sent: 12 pkts icmp "packet too big" sent: 13 pkts icmp "packet too big" sent: 14 pkts LP:~# ping 169.254.1.11 -s 300 -i 0.1 -c 10 PING 169.254.1.11 (169.254.1.11) 300(328) bytes of data. 308 bytes from 169.254.1.11: icmp_seq=1 ttl=64 time=1.00 ms 308 bytes from 169.254.1.11: icmp_seq=2 ttl=64 time=0.829 ms 308 bytes from 169.254.1.11: icmp_seq=3 ttl=64 time=1.12 ms 308 bytes from 169.254.1.11: icmp_seq=4 ttl=64 time=1.06 ms 308 bytes from 169.254.1.11: icmp_seq=5 ttl=64 time=0.946 ms 308 bytes from 169.254.1.11: icmp_seq=6 ttl=64 time=1.14 ms 308 bytes from 169.254.1.11: icmp_seq=7 ttl=64 time=1.10 ms 308 bytes from 169.254.1.11: icmp_seq=8 ttl=64 time=1.10 ms 308 bytes from 169.254.1.11: icmp_seq=9 ttl=64 time=1.04 ms 308 bytes from 169.254.1.11: icmp_seq=10 ttl=64 time=0.870 ms --- 169.254.1.11 ping statistics --- 10 packets transmitted, 10 received, 0% packet loss, time 909ms rtt min/avg/max/mdev = 0.829/1.020/1.136/0.101 ms LP:~# ping 169.254.1.11 -s 500 -i 0.1 -c 10 PING 169.254.1.11 (169.254.1.11) 500(528) bytes of data. From 169.254.1.11 icmp_seq=7 Frag needed and DF set (mtu = 386) From 169.254.1.11 icmp_seq=9 Frag needed and DF set (mtu = 386) --- 169.254.1.11 ping statistics --- 10 packets transmitted, 0 received, +2 errors, 100% packet loss, time 930ms Regards Song, Yoong Siang