From 488ef842fd0818002c880e857b568b21fd8e9d55 Mon Sep 17 00:00:00 2001 From: "Wesierski, Dawid" Date: Mon, 20 Oct 2025 08:56:23 -0400 Subject: [PATCH 1/2] Fix: DPDK build script undefined behavior The DPDK build script was using git to patch the DPDK repo inside the MTL repository, which was causing undefined behavior. Switch to patch to ensure this always works and add help for UX. --- .github/scripts/setup_environment.sh | 2 +- .gitignore | 3 +- script/build_dpdk.sh | 69 ++++++++++++++++++++++------ 3 files changed, 57 insertions(+), 17 deletions(-) diff --git a/.github/scripts/setup_environment.sh b/.github/scripts/setup_environment.sh index a784962b9..e706f945a 100755 --- a/.github/scripts/setup_environment.sh +++ b/.github/scripts/setup_environment.sh @@ -303,7 +303,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then if [ "${SETUP_BUILD_AND_INSTALL_DPDK}" == "1" ]; then echo "$STEP DPDK build and install" - bash "${root_folder}/script/build_dpdk.sh" + bash "${root_folder}/script/build_dpdk.sh" -f STEP=$((STEP + 1)) fi diff --git a/.gitignore b/.gitignore index fb4d21ae9..ee0a9f2e0 100644 --- a/.gitignore +++ b/.gitignore @@ -85,7 +85,8 @@ mtl_system_status_* *.pcm *.wav script/ice-* -script/dpdk +script/dpdk-* +script/*.zip* script/xdp-tools #Generated documentation diff --git a/script/build_dpdk.sh b/script/build_dpdk.sh index 14323c400..eb967194f 100755 --- a/script/build_dpdk.sh +++ b/script/build_dpdk.sh @@ -12,34 +12,73 @@ script_folder=${script_path/$script_name/} . "${script_folder}/common.sh" cd "${script_folder}" || exit 1 -set -x +show_help() { + cat </dev/null) && sourced=1 || sourced=0 if [ "$sourced" -eq 0 ]; then echo "DPDK version: $DPDK_VER" + if [ $FORCE -eq 1 ] && [ -d "$dpdk_folder" ]; then + echo "Force rebuild enabled. Removing existing '$dpdk_folder' directory." + rm -rf "$dpdk_folder" + fi + if [ ! -d "$dpdk_folder" ]; then - # check out dpdk code echo "Clone DPDK source code" - git clone https://github.com/DPDK/dpdk.git "$dpdk_folder" - fi + wget https://github.com/DPDK/dpdk/archive/refs/tags/v"${DPDK_VER}".zip + unzip v"${DPDK_VER}".zip - cd "$dpdk_folder" || exit 1 - git checkout v"$DPDK_VER" - if git switch -c v"$DPDK_VER"_kahawai_build 2>/dev/null; then - git am ../../patches/dpdk/"$DPDK_VER"/*.patch + cd "$dpdk_folder" || exit 1 + for patch_file in ../../patches/dpdk/"$DPDK_VER"/*.patch; do + patch -p1 -i "$patch_file" + done else - echo "Branch v${DPDK_VER}_kahawai_build already exists." - echo "Skipping patch application assuming it has been applied before." + echo "DPDK source code already exists." + echo "To rebuild, please remove the '$dpdk_folder' directory and run this script again." + exit 0 fi - # build and install dpdk now + echo "Build and install DPDK now" meson build ninja -C build cd build From 89fa969968e3e8f3f4f30e2229b32288ff5f3d7e Mon Sep 17 00:00:00 2001 From: "Wesierski, Dawid" Date: Mon, 3 Nov 2025 10:49:25 -0500 Subject: [PATCH 2/2] Add: DPDK patch validation check Implement DPDK version verification to ensure MTL compatibility. This prevents runtime crashes by validating that users are running properly patched DPDK versions. Known limitation: Mixed environments (e.g., patched DPDK in Docker with unpatched system drivers) can still cause crashes, as driver-level patches cannot be detected. --- lib/meson.build | 8 ++++- lib/src/mt_main.c | 7 +++++ ...ig-add-mtl-version-to-version-string.patch | 31 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 patches/dpdk/25.07/0006-config-add-mtl-version-to-version-string.patch diff --git a/lib/meson.build b/lib/meson.build index 3e21dc18f..a3d7aed09 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -7,12 +7,18 @@ toolchain = cc.get_id() # allow experimental api add_global_arguments('-DALLOW_EXPERIMENTAL_API', language : 'c') +# check dpdk version +versions_file = files('../versions.env') +versions_content = run_command('cat', versions_file, check: true).stdout() +dpdk_version_cmd = run_command('sh', '-c', 'grep "^DPDK_VER" ../versions.env | cut -d= -f2', check: true) +dpdk_version = dpdk_version_cmd.stdout().strip() + # add dependencies libm_dep = cc.find_library('m', required : true) libpthread_dep = cc.find_library('pthread', required : true) libdl_dep = cc.find_library('dl', required : true) if not is_windows - dpdk_dep = dependency('libdpdk', version: '>=25.03', required: true) + dpdk_dep = dependency('libdpdk', version: '>=' + dpdk_version, required: true) libnuma_dep = cc.find_library('numa', required : true) ws2_32_dep = [] # add this when the code uses hton/ntoh endif diff --git a/lib/src/mt_main.c b/lib/src/mt_main.c index 637f6dd12..4769fa175 100644 --- a/lib/src/mt_main.c +++ b/lib/src/mt_main.c @@ -414,6 +414,13 @@ mtl_handle mtl_init(struct mtl_init_params* p) { err("%s, mt_dev_eal_init fail %d\n", __func__, ret); return NULL; } + + const char* rte_ver = rte_version(); + if (!strstr(rte_ver, "mtl")) { + err("%s, unpatched dpdk please use supported dpdk version: %s\n", __func__, rte_ver); + goto err_exit; + } + notice("%s, MTL version: %s, dpdk version: %s\n", __func__, mtl_version(), rte_version()); #ifdef MTL_HAS_USDT diff --git a/patches/dpdk/25.07/0006-config-add-mtl-version-to-version-string.patch b/patches/dpdk/25.07/0006-config-add-mtl-version-to-version-string.patch new file mode 100644 index 000000000..0402bf18c --- /dev/null +++ b/patches/dpdk/25.07/0006-config-add-mtl-version-to-version-string.patch @@ -0,0 +1,31 @@ +From bfd22ef915c550775275e52f851a1e98e99978b7 Mon Sep 17 00:00:00 2001 +From: "Wesierski, Dawid" +Date: Mon, 3 Nov 2025 10:27:50 -0500 +Subject: [PATCH 6/6] config: add mtl version to version string + +add verision string to tag the dpdk patched version +and allow mtl to recognize if driver is patched. +--- + config/meson.build | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/config/meson.build b/config/meson.build +index f31fef216c..4781122ce4 100644 +--- a/config/meson.build ++++ b/config/meson.build +@@ -78,10 +78,10 @@ if pver.get(2).contains('-rc') + dpdk_conf.set('RTE_VER_RELEASE', rc_ver.get(1).to_int()) + else + dpdk_conf.set('RTE_VER_MINOR', pver.get(2).to_int()) +- dpdk_conf.set_quoted('RTE_VER_SUFFIX', '') ++ dpdk_conf.set_quoted('RTE_VER_SUFFIX', '_mtl_') + # for actual, non-rc releases, set the release value to 99 to ensure releases + # have higher version numbers than their respective release candidates +- dpdk_conf.set('RTE_VER_RELEASE', 99) ++ dpdk_conf.set('RTE_VER_RELEASE', 0) + endif + + pmd_subdir_opt = get_option('drivers_install_subdir') +-- +2.47.3 +