From 1698203f620179691d4ed4893d057f90ef6d11bf Mon Sep 17 00:00:00 2001 From: Keunhong Lee Date: Mon, 19 Feb 2024 14:57:26 +0900 Subject: [PATCH] Enable github runner (#64) * Add github actions workflow * Fix build error when avx512 is enabled --- .github/workflows/build.yaml | 45 +++++++++++++ Cargo.toml | 1 + Dockerfile | 37 ----------- INSTALL-DOCKER.md | 121 ----------------------------------- Jenkinsfile | 37 ----------- README.md | 5 +- bors.toml | 3 - dpdk-sys/build.rs | 12 ++-- 8 files changed, 54 insertions(+), 207 deletions(-) create mode 100644 .github/workflows/build.yaml delete mode 100644 Dockerfile delete mode 100644 INSTALL-DOCKER.md delete mode 100644 Jenkinsfile delete mode 100644 bors.toml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..c02b928 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,45 @@ +name: Rust + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + DPDK_VERSION: 22.11.4 + +jobs: + build: + runs-on: self-hosted + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + sudo apt update && sudo apt install -y linux-headers-generic build-essential libnuma-dev git meson python3-pyelftools curl libclang-dev clang llvm-dev libbsd-dev + - name: Install DPDK + run: | + wget -O dpdk.tar.xz https://fast.dpdk.org/rel/dpdk-${DPDK_VERSION}.tar.xz + mkdir dpdk-src + tar -xvJf dpdk.tar.xz -C dpdk-src --strip-components=1 + cd dpdk-src + meson setup build + ninja -C build + sudo ninja -C build install + sudo ldconfig + rm -rf dpdk-src + - name: Install minimal Rust with clippy and rustfmt + run: | + curl -f -sSf https://sh.rustup.rs | bash -s -- -y --profile minimal --component clippy rustfmt + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + - name: Check + run: | + clang --version + llvm-config --version + cargo --version + gcc --version + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose diff --git a/Cargo.toml b/Cargo.toml index cf20eb4..fd5f0d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "dpdk-sys" diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 61f99f4..0000000 --- a/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM debian:latest - -ENV RTE_SDK=/usr/local/share/dpdk - -RUN echo "APT last updated: 2023/05/01" - -RUN apt-get update -y && apt-get dist-upgrade -y && apt-get autoremove -y && apt-get autoclean -y -RUN apt-get install -y linux-headers-amd64 -#RUN apt-get install -y linux-headers-$(uname -r)-all -RUN apt-get install -y build-essential libnuma-dev git meson python3-pyelftools -RUN apt-get install -y curl -RUN apt-get install -y libclang-dev clang llvm-dev - -RUN git clone -b v22.11 "http://dpdk.org/git/dpdk" /dpdk - -WORKDIR /dpdk - -RUN meson build -RUN ninja -C build -RUN ninja -C build install -RUN ldconfig - -WORKDIR / -RUN rm -rf /dpdk - -# For rustup -ENV USER_NAME jenkins -RUN useradd -ms /bin/bash $USER_NAME - -# Beginning of rust user install -RUN su -c "curl -f --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y --profile default" - $USER_NAME -# End of rust user install - -ADD ./rust-toolchain / -RUN chmod 444 /rust-toolchain -RUN su -c "rustup toolchain install `cat /rust-toolchain | tr -d ' \n'`" - $USER_NAME -RUN rm /rust-toolchain diff --git a/INSTALL-DOCKER.md b/INSTALL-DOCKER.md deleted file mode 100644 index f8f2924..0000000 --- a/INSTALL-DOCKER.md +++ /dev/null @@ -1,121 +0,0 @@ -# DPDK NIC in Docker - -## Installation - -- Install packages. - - ``` - apt update && apt install -yy build-essential libnuma-dev linux-headers-generic libhugetlbfs0 - - # `librdmacm-dev`, `librdmacm1` are additionally neccessary for Mellanox NICs. - # `libmnl-dev`: was neccessary in Azure? - ``` - -- Install DPDK. - - ```sh - wget http://fast.dpdk.org/rel/dpdk-20.02.tar.xz - tar xf dpdk-20.02.tar.xz - mv dpdk-20.02 dpdk - cd dpdk - DPDK=${DPDK:="$PWD"} - ``` - -- Configure DPDK. - - ```sh - echo "CONFIG_RTE_EAL_IGB_UIO=y" >> config/common_linux - echo "CONFIG_RTE_KNI_KMOD=y" >> config/common_linux - ``` - -- Build DPDK. - - ```sh - make config T=x86_64-native-linux-clang - make -j # build target: `./build` - - # make defconfig --> Makes target x86_64-native-linux-gcc - # but gcc suffers segmentation fault, while clang doesn't (Not sure why...) - ``` - -- Allow `docker` to access huge pages. The script requires `root` privileges. - - ```sh - DOCKER_GID=`getent group docker | cut -d: -f3` - NR_HUGE=${NR_HUGE:="8192"} - - sysctl -w vm.hugetlb_shm_group=${DOCKER_GID} - sysctl -w vm.nr_hugepages=${NR_HUGE} - - # Create hugepage mount location on /mnt with non-default directory - mkdir -p /mnt/dpdk-hugepage - chgrp docker /mnt/dpdk-hugepage - mount -t hugetlbfs -o gid=${DOCKER_GID},mode=1770 none /mnt/dpdk-hugepage - ``` - - + TODO: make it persistent at `/etc/sysctl.conf` - -- Install DPDK drivers. The script requires `root` privileges. - - ```sh - modprobe uio - insmod ${DPDK}/build/kmod/igb_uio.ko - insmod ${DPDK}/build/kmod/rte_kni.ko - ``` - -- Check the two PCIe addresses of the "Intel Corporation Ethernet Controller XL710 for 40GbE QSFP+ (rev 02)". - - ```sh - lspci | grep XL710 - # `81:00.0` and `81:00.1` in this example - - IFACE_LIST=${IFACE_LIST:="81:00.0 81:00.1"} - ``` - -- Bind and grant permissions for devices. The script requires `root` privileges. - - ```sh - ${DPDK}/usertools/dpdk-devbind.py -b igb_uio ${IFACE_LIST} - - chgrp docker /dev/uio* /dev/hpet - chmod g+rwx /dev/uio* - chmod g+rw /dev/hpet - ``` - -- Check if everything is okay by running a test docker image. - - ```sh - docker run --rm -it --privileged -v /mnt/dpdk-hugepage:/mnt/huge anlabkaist/rust-dpdk:latest ${DPDK}/build/app/testpmd - ``` - - + Remove `--privileged`. - -- TODO: Run the dev docker image. - - ```sh - docker run -it --privileged -v /mnt/dpdk-hugepage:/mnt/huge ubuntu:latest bash - ``` -= - ```sh - # Build Container Image - git clone https://{personal_token}@github.com/ANLAB-KAIST/FPS.git - docker build -t dpdk-fps:20.02 ./FPS - - # 현재 서버에서 실행되고 있는 형태를 반영하는게 필요할 듯 - # Volume Mount를 하는 것으로 - docker run --rm -it --privileged -v /sys/bus/pci/devices:/sys/bus/pci/devices -v /sys/kernel/mm/hugepages:/sys/kernel/mm/hugepages -v /sys/devices/system/node:/sys/devices/system/node -v /mnt/huge:/mnt/huge -v /dev:/dev dpdk-fps:20.02 - ``` - -- TODO: rebuild when kernel is updated. - - ```sh - uname -r > ${DPDK}/CURRENT - diff -q ${DPDK}/CURRENT ${DPDK}/RECENT - if [ $? -ne 0 ] - then - echo "Rebuilding DPDK for a new kernel..." - make -C ${DPDK} clean - make -C ${DPDK} -j`nproc` - cp ${DPDK}/CURRENT ${DPDK}/RECENT - fi - ``` diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 0a0e6ea..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,37 +0,0 @@ -pipeline { - agent { dockerfile true } - environment { - CARGO="$HOME/.cargo/bin/cargo --locked" - RUSTC="$HOME/.cargo/bin/rustc" - } - stages { - stage ("Version") { - steps { - sh "$CARGO --version" - sh "$RUSTC --version" - } - } - stage ("Build") { - steps { - sh "$CARGO build" - } - } - stage ("Check") { - steps { - sh "$CARGO check" - sh "$CARGO fmt --all -- --check" - sh "$CARGO clippy -- -D warnings" - } - } - stage ("Test (common)") { - steps { - sh "$CARGO test --lib" - } - } - stage ("Test (dpdk-sys)") { - steps { - sh "$CARGO run -p rust-dpdk-sys -- --no-pci --no-huge" - } - } - } -} diff --git a/README.md b/README.md index 36fd377..9e91951 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # rust-dpdk -[![Build Status](https://jenkins.redwit.io/buildStatus/icon?job=ANLAB-KAIST%2Frust-dpdk%2Fmain)](https://jenkins.redwit.io/job/ANLAB-KAIST/job/rust-dpdk/job/main/) +[![Build Status](https://github.com/ANLAB-KAIST/rust-dpdk/actions/workflows/build.yml/badge.svg)](https://github.com/ANLAB-KAIST/rust-dpdk/actions/workflows/build.yml) -Tested with v0.65. Tested with v22.11. ## Goals @@ -48,5 +47,5 @@ If your NIC requires kernel drivers, they are found at the above link. Now add `rust-dpdk` to your project's `Cargo.toml` and use it! ```{.toml} [dependencies] -rust-dpdk = { git = "https://github.com/ANLAB-KAIST/rust-dpdk.git" } +rust-dpdk-sys = { git = "https://github.com/ANLAB-KAIST/rust-dpdk", branch = "main" } ``` diff --git a/bors.toml b/bors.toml deleted file mode 100644 index b1d2a37..0000000 --- a/bors.toml +++ /dev/null @@ -1,3 +0,0 @@ -block-labels = [ "S-do-not-merge-yet" ] -status = [ "continuous-integration/jenkins/branch" ] -delete_merged_branches = true diff --git a/dpdk-sys/build.rs b/dpdk-sys/build.rs index 595d5bc..2c250ca 100644 --- a/dpdk-sys/build.rs +++ b/dpdk-sys/build.rs @@ -301,8 +301,9 @@ impl State { // Heuristically remove platform-specific headers let platform_set = vec![ - "x86", "x86_64", "x64", "arm", "arm32", "arm64", "amd64", "generic", + "x86", "x86_64", "x64", "arm", "arm32", "arm64", "amd64", "generic", "gfni", "32", "64", ]; + // Remove blacklist headers let blacklist_prefix = vec!["rte_acc_"]; let mut name_set: Vec = vec![]; @@ -328,6 +329,7 @@ impl State { continue 'outer; } } + // println!("cargo:warning=header-name: {}", file_name); new_vec.push(file.clone()); } new_vec.sort_by(|left, right| { @@ -420,7 +422,6 @@ impl State { let storage = some_or!(f.get_storage_class(), continue); let return_type = some_or!(f.get_result_type(), continue); let is_decl = f.is_declaration(); - let is_def = f.is_definition(); let is_inline_fn = f.is_inline_function(); let comment = f @@ -436,10 +437,7 @@ impl State { // Skip hidden implementations continue; } - if clang::StorageClass::Static == storage && !(is_decl && is_inline_fn) { - continue; - } - if clang::StorageClass::None == storage && !is_def { + if clang::StorageClass::Static != storage || !(is_decl && is_inline_fn) { continue; } // println!("cargo:warning={} {} {} {:?}", name, is_decl, f.is_inline_function(), storage); @@ -845,10 +843,12 @@ impl State { .clang_arg(dpdk_config_path.to_str().unwrap()) .clang_arg("-march=native") .clang_arg("-Wno-everything") + .clang_arg("-DALLOW_INTERNAL_API") // We will not use internal API, but it is necessary to generate bindings. .opaque_type("vmbus_bufring") .opaque_type("rte_avp_desc") .opaque_type("rte_.*_hdr") .opaque_type("rte_arp_ipv4") + .opaque_type("__*") .generate() .unwrap() .write_to_file(target_path)