xdp-project / xdp-tutorial

XDP tutorial
2.49k stars 579 forks source link

arm 32 bit support? #82

Open Que0Le opened 5 years ago

Que0Le commented 5 years ago

Hi,

I am working on a Beagle Board and try to compile xdp example but encountered error. I followed setup_dependencies.org, all installed but bpftool:

# debian@beaglebone:/var/lib/cloud9/xdp-tutorial$ file /usr/sbin/bpftool
/usr/sbin/bpftool: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=d016afa7c9be4e163fb29184fd8323e23ca57fba, not stripped

My system: Debian.

# uname -a
Linux beaglebone 4.14.108-ti-r119 #1 SMP PREEMPT Mon Sep 30 02:30:24 UTC 2019 armv7l GNU/Linux

When I make basic01 program I got this:

# debian@beaglebone:/var/lib/cloud9/xdp-tutorial/basic01-xdp-pass$ make
make[1]: Entering directory '/var/lib/cloud9/xdp-tutorial/libbpf/src'
cc -I. -I../include -I../include/uapi -DCOMPAT_NEED_REALLOCARRAY -fPIC -fvisibility=hidden -g -O2 -Werror -Wall   -c xsk.c -o xsk.o
In file included from xsk.c:22:0:
xsk.c: In function ‘xsk_umem__create’:
../include/uapi/linux/if_xdp.h:87:34: error: overflow in implicit constant conversion [-Werror=overflow]
 #define XDP_UMEM_PGOFF_FILL_RING 0x100000000ULL
                                  ^
xsk.c:198:6: note: in expansion of macro ‘XDP_UMEM_PGOFF_FILL_RING’
      XDP_UMEM_PGOFF_FILL_RING);
      ^~~~~~~~~~~~~~~~~~~~~~~~
../include/uapi/linux/if_xdp.h:88:40: error: overflow in implicit constant conversion [-Werror=overflow]
 #define XDP_UMEM_PGOFF_COMPLETION_RING 0x180000000ULL
                                        ^
xsk.c:215:6: note: in expansion of macro ‘XDP_UMEM_PGOFF_COMPLETION_RING’
      XDP_UMEM_PGOFF_COMPLETION_RING);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Makefile:91: recipe for target 'xsk.o' failed
make[1]: *** [xsk.o] Error 1
make[1]: Leaving directory '/var/lib/cloud9/xdp-tutorial/libbpf/src'
make[1]: Entering directory '/var/lib/cloud9/xdp-tutorial/libbpf/src'
if [ ! -d 'build/usr/include/bpf' ]; then install -d -m 755 'build/usr/include/bpf'; fi; install bpf.h libbpf.h btf.h xsk.h libbpf_util.h -m 644 'build/usr/include/bpf'
make[1]: Leaving directory '/var/lib/cloud9/xdp-tutorial/libbpf/src'
gcc -Wall -I../libbpf/src//build/usr/include/ -g -I/usr/include/x86_64-linux-gnu -I../headers/ -L../libbpf/src/ -o xdp_pass_user ../common//common_params.o \
 xdp_pass_user.c -l:libbpf.a -lelf
/usr/bin/ld: cannot find -l:libbpf.a
collect2: error: ld returned 1 exit status
../common//common.mk:107: recipe for target 'xdp_pass_user' failed
make: *** [xdp_pass_user] Error 1
tohojo commented 5 years ago

@magnus-karlsson is the xsk API not supposed to work on 32bit?

magnus-karlsson commented 5 years ago

32-bit support for ARM was not working until this patch made it into the kernel:

commit 76f34950779f3d7847c94615232dff2cdc2f9844 Author: Ivan Khoronzhuk ivan.khoronzhuk@linaro.org Date: Mon Sep 23 15:39:28 2019 -0700

mm: mmap: increase sockets maximum memory size pgoff for 32bits

It should be in linux-next. Ivan is your man here :-).

Que0Le commented 5 years ago

32-bit support for ARM was not working until this patch made it into the kernel: It should be in linux-next. Ivan is your man here :-).

So did I understand: XDP (as well BPF I suppose) does not work on ARM 32bit system ( ARM 64bit?). What about Intel/AMD platforms?

magnus-karlsson commented 5 years ago

If you use 5.3 or older, it works on ARM 64-bit and x86 with a 64-bit kernel for both 32 and 64 bit user space. It only works for 32-bit kernels from 5.4 (or any of the release candidates of 5.4) and onward.

magnus-karlsson commented 5 years ago

And the previous comment is only valid for AF_XDP. As for XDP, I do not know.

jt416 commented 4 years ago

I was able to get all the basic lessons to run on 32-bit ARM (on kernel 4.19). I had to tweak the Makefiles for cross-tool support and add large file defines.

I did not need the mmap kernel fix until trying AF_XDP. I ported it back to my 4.19, and I am still failing to load, so I'll try 5.4.

I think the problem here is largefile defines in common.mk

CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64

tohojo commented 4 years ago

jt416 notifications@github.com writes:

I was able to get all the basic lessons to run on 32-bit ARM (on kernel 4.19). I had to tweak the Makefiles for cross-tool support and add large file defines.

Feel free to open a pull request with those changes :)