Skip to content

Commit 2a3e1e6

Browse files
committed
Support upstream DPDK in Dockerfile
1 parent 19a457b commit 2a3e1e6

File tree

5 files changed

+157
-80
lines changed

5 files changed

+157
-80
lines changed

operators/advanced_network/Dockerfile

Lines changed: 111 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -75,45 +75,26 @@ RUN --mount=type=bind,source=${HOLOSCAN_DEB_LOCAL_PATH},target=/tmp/holoscan.deb
7575
FROM hsdk-${HOLOSCAN_DEB_SRC} AS hsdk-installed
7676

7777
# ==============================================================
78-
# common-deps: common dependencies for the advanced network lib
78+
# base-deps: base dependencies for the advanced network lib
7979
# ==============================================================
80-
FROM hsdk-installed AS common-deps
80+
FROM hsdk-installed AS base-deps
8181

8282
ARG TARGETARCH
83-
ARG DOCA_VERSION=2.8.0
8483
ARG CACHEBUST=1
8584
ARG DEBIAN_FRONTEND=noninteractive
8685

8786
WORKDIR /opt
8887

89-
# Configure the DOCA APT repository
90-
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
91-
DOCA_ARCH="x86_64"; \
92-
elif [ "$TARGETARCH" = "arm64" ]; then \
93-
DOCA_ARCH="arm64-sbsa"; \
94-
else \
95-
echo "Unknown architecture: $TARGETARCH"; \
96-
exit 1; \
97-
fi \
98-
&& DISTRO=$(. /etc/os-release && echo ${ID}${VERSION_ID}) \
99-
&& DOCA_REPO_LINK=https://linux.mellanox.com/public/repo/doca/${DOCA_VERSION}/${DISTRO}/${DOCA_ARCH} \
100-
&& echo "Using DOCA_REPO_LINK=${DOCA_REPO_LINK}" \
101-
&& LOCAL_GPG_KEY_PATH="/usr/share/keyrings/mellanox-archive-keyring.gpg" \
102-
&& curl -fsSL ${DOCA_REPO_LINK}/GPG-KEY-Mellanox.pub | gpg --dearmor | tee ${LOCAL_GPG_KEY_PATH} > /dev/null \
103-
&& echo "deb [signed-by=${LOCAL_GPG_KEY_PATH}] ${DOCA_REPO_LINK} ./" | tee /etc/apt/sources.list.d/mellanox.list
104-
105-
# APT installs
88+
# APT installs for base dependencies (no DOCA/GPUNetIO packages)
10689
# - cublas, cufft, cusolver, curand dev libs: for matx
10790
# - ninja-build: for cmake build
108-
# - pkgconf: to import dpdk and doca in CMake
109-
# - mlnx-dpdk-dev: for dpdk and gpunetio backends
110-
# - libdoca-sdk-dma-dev: for gpunetio backend (dependency of doca-gpunetio module)
111-
# - libdoca-sdk-gpunetio-dev: for gpunetio backend (doca-gpunetio module)
112-
# - libdoca-sdk-eth-dev: for gpunetio backend (doca-eth module)
113-
# - libdoca-sdk-flow-dev: for gpunetio backend (doca-flow module)
114-
# - mlnx-ofed-kernel-utils: utilities, including ibdev2netdev used by tune_system.py
91+
# - pkgconf: to import dpdk in CMake
92+
# - meson: for building DPDK
93+
# - python3-pyelftools: required for DPDK build
94+
# - libnuma-dev: NUMA support for DPDK
95+
# - libibverbs-dev, librdmacm-dev: RDMA/ibverbs support for Mellanox NICs
96+
# - libmlx5-1: Mellanox ConnectX driver
11597
# - ibverbs-utils: utilities
116-
# - python3-pyelftools: used by some mlnx tools
11798
# - python3-dev: for building python bindings
11899
RUN apt-get update && apt-get install -y --no-install-recommends \
119100
libcublas-dev-12-6 \
@@ -122,14 +103,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
122103
libcurand-dev-12-6 \
123104
ninja-build \
124105
pkgconf \
125-
mlnx-dpdk-dev \
126-
libdoca-sdk-dma-dev \
127-
libdoca-sdk-gpunetio-dev \
128-
libdoca-sdk-eth-dev \
129-
libdoca-sdk-flow-dev \
130-
mlnx-ofed-kernel-utils \
131-
ibverbs-utils \
106+
meson \
132107
python3-pyelftools \
108+
libnuma-dev \
109+
libibverbs-dev \
110+
librdmacm-dev \
111+
libmlx5-1 \
112+
ibverbs-utils \
133113
python3-dev \
134114
&& rm -rf /var/lib/apt/lists/*
135115

@@ -142,25 +122,107 @@ RUN python3 -m pip install --no-cache-dir \
142122
pyyaml \
143123
scapy
144124

125+
# ==============================================================
126+
# dpdk-build: Build upstream DPDK from source
127+
# ==============================================================
128+
FROM base-deps AS dpdk-build
129+
130+
ARG TARGETARCH
131+
# DPDK version to download and build
132+
ARG DPDK_VERSION=24.11.3
133+
ARG DPDK_BUILD_DIR=/opt/dpdk-build
134+
ARG DPDK_INSTALL_PREFIX=/usr/local
135+
ARG DOCA_VERSION=2.8.0
136+
ARG DEBIAN_FRONTEND=noninteractive
137+
138+
WORKDIR /tmp
139+
140+
# Download DPDK source from official repository
141+
ADD https://fast.dpdk.org/rel/dpdk-${DPDK_VERSION}.tar.xz /tmp/
142+
RUN tar xf dpdk-${DPDK_VERSION}.tar.xz
143+
144+
# Build and install DPDK using meson/ninja
145+
WORKDIR /tmp/dpdk-stable-${DPDK_VERSION}
146+
RUN meson setup ${DPDK_BUILD_DIR} \
147+
--prefix=${DPDK_INSTALL_PREFIX} \
148+
-Denable_kmods=false \
149+
-Dtests=false \
150+
-Denable_docs=false \
151+
-Ddisable_drivers=baseband/*,bus/ifpga/*,common/cpt,common/dpaax,common/iavf,common/octeontx,common/octeontx2,crypto/nitrox,net/ark,net/atlantic,net/avp,net/axgbe,net/bnx2x,net/bnxt,net/cxgbe,net/e1000,net/ena,net/enic,net/fm10k,net/hinic,net/hns3,net/i40e,net/ixgbe,vdpa/ifc,net/igc,net/liquidio,net/netvsc,net/nfp,net/qede,net/sfc,net/thunderx,net/vdev_netvsc,net/vmxnet3,regex/octeontx2 \
152+
&& cd ${DPDK_BUILD_DIR} \
153+
&& ninja \
154+
&& meson install \
155+
&& ldconfig \
156+
&& rm -rf /tmp/dpdk-stable-${DPDK_VERSION} /tmp/dpdk-stable-${DPDK_VERSION}.tar.xz ${DPDK_BUILD_DIR} /tmp/dpdk_patches
157+
158+
# Configure the DOCA APT repository for mlnx-ofed-kernel-utils
159+
# (needed for ibdev2netdev utility used by tune_system.py)
160+
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
161+
DOCA_ARCH="x86_64"; \
162+
elif [ "$TARGETARCH" = "arm64" ]; then \
163+
DOCA_ARCH="arm64-sbsa"; \
164+
else \
165+
echo "Unknown architecture: $TARGETARCH"; \
166+
exit 1; \
167+
fi \
168+
&& DISTRO=$(. /etc/os-release && echo ${ID}${VERSION_ID}) \
169+
&& DOCA_REPO_LINK=https://linux.mellanox.com/public/repo/doca/${DOCA_VERSION}/${DISTRO}/${DOCA_ARCH} \
170+
&& echo "Using DOCA_REPO_LINK=${DOCA_REPO_LINK}" \
171+
&& LOCAL_GPG_KEY_PATH="/usr/share/keyrings/mellanox-archive-keyring.gpg" \
172+
&& curl -fsSL ${DOCA_REPO_LINK}/GPG-KEY-Mellanox.pub | gpg --dearmor | tee ${LOCAL_GPG_KEY_PATH} > /dev/null \
173+
&& echo "deb [signed-by=${LOCAL_GPG_KEY_PATH}] ${DOCA_REPO_LINK} ./" | tee /etc/apt/sources.list.d/mellanox.list
174+
175+
# Install mlnx-ofed-kernel-utils (utilities including ibdev2netdev used by tune_system.py)
176+
RUN apt-get update && apt-get install -y --no-install-recommends \
177+
mlnx-ofed-kernel-utils \
178+
&& rm -rf /var/lib/apt/lists/*
179+
180+
WORKDIR /opt
181+
145182
# ==============================
146-
# DOCA Target
147-
# This stage is only built when --target doca is specified. It contains any DOCA-specific configurations.
183+
# DPDK Target (Default)
184+
# This is the default target for users who only need DPDK support.
185+
# GPUNetIO/DOCA is NOT included.
148186
# ==============================
149-
FROM common-deps AS doca
150-
# DOCA-specific installation or steps (if needed)
187+
FROM dpdk-build AS dpdk
188+
# DPDK is ready to use, no additional steps needed
189+
190+
# ==============================================================
191+
# gpunetio-deps: Add DOCA SDK packages for GPUNetIO support
192+
# ==============================================================
193+
FROM dpdk-build AS gpunetio-deps
194+
195+
ARG DEBIAN_FRONTEND=noninteractive
196+
197+
# Install DOCA SDK packages required for GPUNetIO
198+
# (DOCA repo is already configured in dpdk-build stage)
199+
# - libdoca-sdk-dma-dev: for gpunetio backend (dependency of doca-gpunetio module)
200+
# - libdoca-sdk-gpunetio-dev: for gpunetio backend (doca-gpunetio module)
201+
# - libdoca-sdk-eth-dev: for gpunetio backend (doca-eth module)
202+
# - libdoca-sdk-flow-dev: for gpunetio backend (doca-flow module)
203+
RUN apt-get update && apt-get install -y --no-install-recommends \
204+
libdoca-sdk-dma-dev \
205+
libdoca-sdk-gpunetio-dev \
206+
libdoca-sdk-eth-dev \
207+
libdoca-sdk-flow-dev \
208+
&& rm -rf /var/lib/apt/lists/*
151209

152210
# ==============================
153-
# DPDK Target
154-
# This stage is only built when --target dpdk is specified. It contains any DPDK-specific configurations.
211+
# GPUNetIO Target
212+
# This stage is built when --target gpunetio is specified.
213+
# It includes DOCA packages required for GPUNetIO support.
155214
# ==============================
156-
FROM common-deps AS dpdk
157-
# DPDK-specific installation or steps (if needed)
215+
FROM gpunetio-deps AS gpunetio
216+
# GPUNetIO is ready to use with DOCA support
158217

159218
# ==============================
160219
# Rivermax Target
161220
# This stage is only built when --target rivermax is specified. It installs and configures Rivermax SDK.
221+
# Note: Rivermax does not require DPDK - extends from base-deps directly.
162222
# ==============================
163-
FROM common-deps AS rivermax
223+
FROM base-deps AS rivermax
224+
225+
ARG TARGETARCH
164226

165227
# Define Rivermax-specific build arguments and environment variables
166228
ARG RIVERMAX_VERSION=1.70.32
@@ -227,7 +289,9 @@ RUN cd rivermax-dev-kit && \
227289
cmake --build build -j $(nproc)
228290

229291
# ==============================
230-
# Default stage: common-deps
231-
# If no target is specified, the common-deps stage will be built by default.
292+
# Default stage: dpdk
293+
# If no target is specified, the dpdk stage will be built by default.
294+
# This provides upstream DPDK support without DOCA dependencies.
295+
# Use --target gpunetio if you need DOCA GPUNetIO support.
232296
# ==============================
233-
FROM common-deps
297+
FROM dpdk

operators/advanced_network/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ is available in userspace, thus bypassing the kernel's networking stack entirely
2626
- Linux
2727
- An NVIDIA NIC with a ConnectX-6 or later chip
2828
- System tuning as described [here](/tutorials/high_performance_networking/README.md)
29-
- DPDK 22.11
30-
- MOFED 5.8-1.0.1.1 or later
31-
- DOCA 2.7 or later
29+
- DPDK 24.11.3 or higher
30+
- MOFED 5.8-1.0.1.1 or later (included with DOCA package)
31+
- DOCA 2.8 or later if using GPUNetIO
3232

3333
#### Features
3434

operators/advanced_network/advanced_network/CMakeLists.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ find_package(holoscan 2.6 REQUIRED CONFIG
2020
PATHS "/opt/nvidia/holoscan" "/workspace/holoscan-sdk/install") # Remove if holoscan logger dependency removed
2121

2222
find_package(PkgConfig)
23+
find_package(CUDAToolkit REQUIRED)
2324

2425
enable_language(CUDA)
2526

@@ -31,9 +32,16 @@ add_compile_definitions(DOCA_ALLOW_EXPERIMENTAL_API)
3132

3233
execute_process(COMMAND arch OUTPUT_VARIABLE ARCH)
3334
string(STRIP ${ARCH} ARCH)
34-
set(DPDK_PATH /opt/mellanox/dpdk)
35+
36+
# Path configurations for DPDK and DOCA
37+
# Upstream DPDK (installed via meson) uses /usr/local by default
38+
# DOCA/mlnx-dpdk uses /opt/mellanox paths
39+
set(DPDK_PATH_UPSTREAM /usr/local)
40+
set(DPDK_PATH_MLNX /opt/mellanox/dpdk)
3541
set(DOCA_PATH /opt/mellanox/doca)
36-
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${DPDK_PATH}/lib/${ARCH}-linux-gnu/pkgconfig:${DOCA_PATH}/lib/${ARCH}-linux-gnu/pkgconfig:/opt/mellanox/flexio/lib/pkgconfig:/opt/mellanox/collectx/lib/${ARCH}-linux-gnu/pkgconfig")
42+
43+
# Set PKG_CONFIG_PATH to find DPDK (upstream first, then mlnx) and DOCA
44+
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${DPDK_PATH_UPSTREAM}/lib/${ARCH}-linux-gnu/pkgconfig:${DPDK_PATH_UPSTREAM}/lib/pkgconfig:${DPDK_PATH_MLNX}/lib/${ARCH}-linux-gnu/pkgconfig:${DOCA_PATH}/lib/${ARCH}-linux-gnu/pkgconfig:/opt/mellanox/flexio/lib/pkgconfig:/opt/mellanox/collectx/lib/${ARCH}-linux-gnu/pkgconfig")
3745

3846
# Common library
3947
add_library(advanced_network_common SHARED
@@ -71,8 +79,10 @@ install(
7179
# Backend libraries
7280
if(NOT DEFINED ANO_MGR)
7381
# Initialize ANO_MGR with a default if not provided
74-
# Note: rivermax not added to the default list yet since it requires licensing
75-
set(ANO_MGR "dpdk gpunetio" CACHE STRING "Manager type(s) list")
82+
# Default: dpdk only (no DOCA dependency)
83+
# Add "gpunetio" to enable GPU-accelerated networking (requires DOCA)
84+
# Note: rivermax not added to the default list since it requires licensing
85+
set(ANO_MGR "dpdk" CACHE STRING "Manager type(s) list")
7686
endif()
7787
separate_arguments(ANO_MGR_LIST UNIX_COMMAND ${ANO_MGR})
7888

operators/advanced_network/advanced_network/managers/dpdk/CMakeLists.txt

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,39 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
2020

2121
target_sources(${PROJECT_NAME} PRIVATE adv_network_dpdk_mgr.cpp adv_network_dpdk_stats.cpp)
2222

23+
# Try to find DPDK via pkg-config
24+
# This will find upstream DPDK (installed to /usr/local) or mlnx-dpdk (via PKG_CONFIG_PATH set in parent CMakeLists.txt)
2325
pkg_check_modules(DPDK QUIET libdpdk)
2426

2527
if(NOT DPDK_FOUND)
26-
message(STATUS "Looking for DPDK in alternative directories")
27-
set(ENV{PKG_CONFIG_PATH} /opt/mellanox/dpdk/lib/x86_64-linux-gnu/pkgconfig/)
28+
# Fallback: try to find mlnx-dpdk in standard Mellanox installation paths
29+
message(STATUS "Looking for DPDK in Mellanox installation directories")
30+
execute_process(COMMAND arch OUTPUT_VARIABLE ARCH)
31+
string(STRIP ${ARCH} ARCH)
32+
set(ENV{PKG_CONFIG_PATH} "/opt/mellanox/dpdk/lib/${ARCH}-linux-gnu/pkgconfig/")
2833
pkg_check_modules(DPDK REQUIRED libdpdk)
29-
30-
target_link_directories(${PROJECT_NAME} PUBLIC ${DPDK_LIBRARY_DIRS})
31-
target_include_directories(${PROJECT_NAME} PUBLIC ${DPDK_INCLUDE_DIRS})
32-
target_compile_options(${PROJECT_NAME} PUBLIC ${DPDK_CFLAGS_OTHER})
33-
target_link_libraries(${PROJECT_NAME}
34-
PUBLIC
35-
${DPDK_LDFLAGS_OTHER}
36-
${DPDK_LIBRARIES}
37-
PRIVATE
38-
holoscan::core
39-
CUDA::cudart
40-
)
41-
else() # Upstream DPDK
42-
set(DPDK_EXTRA_LIBS -Wl,--no-whole-archive -lmlx5 -libverbs -pthread -lnuma -ldl)
43-
target_link_directories(${PROJECT_NAME} PUBLIC ${DPDK_LIBRARY_DIRS})
44-
target_link_libraries(${PROJECT_NAME}
45-
PUBLIC
46-
${DPDK_LDFLAGS_OTHER}
47-
${DPDK_LIBRARIES}
48-
${DPDK_EXTRA_LIBS}
49-
PRIVATE
50-
holoscan::core
51-
CUDA::cudart
52-
)
5334
endif()
5435

36+
message(STATUS "Found DPDK: ${DPDK_VERSION} in ${DPDK_LIBRARY_DIRS}")
37+
38+
# Common DPDK configuration
39+
target_link_directories(${PROJECT_NAME} PUBLIC ${DPDK_LIBRARY_DIRS})
40+
target_include_directories(${PROJECT_NAME} PUBLIC ${DPDK_INCLUDE_DIRS})
41+
target_compile_options(${PROJECT_NAME} PUBLIC ${DPDK_CFLAGS_OTHER})
42+
43+
# Link libraries - add extra libs for Mellanox NIC support
44+
set(DPDK_EXTRA_LIBS -Wl,--no-whole-archive -lmlx5 -libverbs -pthread -lnuma -ldl)
45+
target_link_libraries(${PROJECT_NAME}
46+
PUBLIC
47+
${DPDK_LDFLAGS_OTHER}
48+
${DPDK_LIBRARIES}
49+
${DPDK_EXTRA_LIBS}
50+
PRIVATE
51+
holoscan::core
52+
CUDA::cudart
53+
CUDA::cuda_driver
54+
)
55+
5556
set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
5657
set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
5758
set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES "80;90")

operators/advanced_network/advanced_network/managers/gpunetio/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ target_link_directories(${PROJECT_NAME} PUBLIC ${DOCA_LIBRARY_DIRS})
6464
target_link_libraries(${PROJECT_NAME}
6565
PRIVATE
6666
holoscan::core
67+
CUDA::cudart
68+
CUDA::cuda_driver
6769
-ldoca_gpunetio
6870
-ldoca_gpunetio_device # static
6971
-ldoca_eth

0 commit comments

Comments
 (0)