Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,23 @@ they take artifacts associated with P4 as inputs.
The building of drivers produces a set of libraries that need to be
loaded (or linked to) the application.

Note: SDE is the top level directory with this p4-dpdk-target, syslibs and utils repo cloned in next step
You can install and build in two ways:

1. Using the Installation script
2. Manually

**Note:** `SDE` is the top-level directory containing the `p4-dpdk-target`, `syslibs`, and `utils` repositories (cloned in the next step).

## Installation via Script

To install P4-DPDK using the provided script, run:

```bash
./install_p4_dpdk.sh
```
The script installs P4-DPDK and prompts you to configure hugepages and the required permissions to access them.

## Manual Installation

#### Create install directory under SDE
```
Expand All @@ -116,13 +132,14 @@ To set environment variables for SDE, see below :-
```
Ensure SDE, SDE_INSTALL and LD_LIBRARY_PATH environment variables are set correctly

#### Installing P4-DPDK directly from the Installation script
To install P4-DPDK you can run the below command it will install `P4-DPDK` and all other necessary libraries required to run `P4-DPDK` or you can follow steps below this section to install it manually

#### Install dependent packages
To Install the dependencies for p4-driver on the platform Fedora 33, see below:-
Note:- Make sure that your yum repository proxy and environment proxies are set properly and you have sudo access.
```bash
./install_dpdk.sh
pip3 install distro (dependency)
cd p4-dpdk-target/tools/setup
python3 install_dep.py
```

#### Building P4 DPDK target
```
cd $SDE/p4-dpdk-target
Expand Down
139 changes: 0 additions & 139 deletions install_dpdk.sh

This file was deleted.

137 changes: 137 additions & 0 deletions install_p4_dpdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#!/usr/bin/env bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the version of install_p4_dpdk.sh as of commit 2 on 2026-Feb-01 from this PR's diff to a freshly installed Ubuntu 24.04 system running on an x86_64 processor.

The first problem encountered was that no Python module distutils was found:

$ ./install_p4_dpdk.sh |& tee log-try1.txt
=== P4 DPDK Target Installation Script ===

==> 1/5 Cloning p4-dpdk-target...
Cloning into 'p4-dpdk-target'...

==> 2/5 Installing system dependencies...

Updated Environment Variables ...
SDE: /home/p4/sde
SDE_INSTALL: /home/p4/sde/install
LD_LIBRARY_PATH: /home/p4/sde/install/lib:/home/p4/sde/install/lib64:/home/p4/sde/install/lib/x86_64-linux-gnu/:/usr/local/lib64:/usr/local/lib

./install_p4_dpdk.sh: line 40: pip3: command not found
Traceback (most recent call last):
  File "/home/p4/sde/p4-dpdk-target/tools/setup/install_dep.py", line 16, in <module>
    from sysutils import Platforms
  File "/home/p4/sde/p4-dpdk-target/tools/setup/sysutils.py", line 20, in <module>
    from distutils.version import LooseVersion
ModuleNotFoundError: No module named 'distutils'

The second problem occurred during this step: "==> 3/5 Building p4-dpdk-target...". It could not find the command autoreconf:

./autogen.sh: 3: exec: autoreconf: not found

The README.md changes proposed in this PR do not mention any prerequisites or other commands that should be run before .install_p4_dpdk.sh, so it seems best if install_p4_dpdk.sh installs any packages that it requires. If these installation steps require a particular distribution of Linux, it seems reasonable to document what distributions the script has been tested on in the README.md file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll run it on Ubuntu 24.04 and I'll fix it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the issues I found are not a difference between Ubuntu 22.04 and Ubuntu 24.04, but between a fresh minimal install of Ubuntu vs. many packages already installed. If you have an easy way to create a fresh minimal install of Ubuntu 22.04 (or 24.04), I suspect you should experience the same issues.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have address your comment, but I have to test it on Ubuntu 24.04 and 22.04

set -e

# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
BOLD='\033[1m'
NC='\033[0m' # No Color

print_step() {
echo -e "\n${BOLD}${BLUE}==>${NC} ${BOLD}$1${NC}"
}

echo -e "${BOLD}${BLUE}=== P4 DPDK Target Installation Script ===${NC}"

check_and_install() {
local cmd=$1
local pkgs=$2

# Check if command exists (for executables)
if ! command -v "$cmd" >/dev/null 2>&1; then
echo -e "${YELLOW}$cmd not found.${NC}"
sudo apt update
sudo apt install -y $pkgs
fi
}

check_and_install_pkgs() {
local pkgs=$1
if dpkg-query -l "$pkgs" >/dev/null 2>&1; then
echo -e "${GREEN}$pkgs is already installed.${NC}"
else
echo -e "${YELLOW}$pkgs not found. Installing...${NC}"
sudo apt update
sudo apt install -y "$pkgs"
fi
}


# ------------------------------------------------------------
# 1. Base directories
# ------------------------------------------------------------
export SDE=$(pwd)/sde
export SDE_INSTALL=$SDE/install

mkdir -p "$SDE"
mkdir -p "$SDE_INSTALL"

# ------------------------------------------------------------
# 0. Check Dependencies (install if missing)
# ------------------------------------------------------------
print_step "0/5 Checking dependencies..."
# Install Wireshark and tshark on Ubuntu system without having to
# answer _any_ questions interactively, except perhaps providing your
# password when prompted by 'sudo'.
# https://askubuntu.com/questions/1275842/install-wireshark-without-confirm
echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install wireshark tshark
check_and_install "pip3" "python3-pip"
check_and_install "pip3" "python3-pip"
check_and_install "autoreconf" "autoconf automake libtool pkg-config autoconf-archive automake"
check_and_install "cmake" "cmake"
check_and_install "doxygen" "doxygen"
check_and_install "dpdk-testpmd" "dpdk dpdk-dev libdpdk-dev"
check_and_install_pkgs "libcjson-dev"
check_and_install_pkgs "libedit-dev"
check_and_install_pkgs "libffi-dev"

# ------------------------------------------------------------
# 1. Cloning p4-dpdk-target
# ------------------------------------------------------------
print_step "1/5 Cloning p4-dpdk-target..."
cd $SDE
git clone https://github.com/p4lang/p4-dpdk-target.git

# ------------------------------------------------------------
# 2. System dependencies
# ------------------------------------------------------------
print_step "2/5 Installing system dependencies..."

sudo apt update && sudo apt upgrade && sudo apt install -y python3-venv python3-full
python3 -m venv "$SDE/.venv"
source "$SDE/.venv/bin/activate"

cd "$SDE/p4-dpdk-target/tools/setup"
source ./p4sde_env_setup.sh "$SDE"
pip3 install distro
python3 install_dep.py

# ------------------------------------------------------------
# 3. Build p4-dpdk-target
# ------------------------------------------------------------
print_step "3/5 Building p4-dpdk-target..."

cd $SDE/p4-dpdk-target
git submodule update --init --recursive --force
./autogen.sh
read -p "Build for TDI only? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
./configure --prefix=$SDE_INSTALL --with-generic-flags=yes #For TDI build
else
./configure --prefix=$SDE_INSTALL #For both bfrt and TDI build
fi
make -j
make install

# ------------------------------------------------------------
# 4. Hugepages (required for DPDK)
# ------------------------------------------------------------
print_step "4/5 Configuring hugepages..."
read -p "Configure hugepages? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo sysctl -w vm.nr_hugepages=1024 || true
sudo mkdir -p /mnt/huge || true
mount | grep hugetlbfs || sudo mount -t hugetlbfs nodev /mnt/huge || true
else
echo "Skipping hugepages configuration."
fi

# ------------------------------------------------------------
# 5. Hugepages permissions
# ------------------------------------------------------------
print_step "5/5 Configuring hugepages permissions..."
read -p "Configure hugepages permissions? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo chown $(id -u):$(id -g) /dev/hugepages
sudo chmod 700 /dev/hugepages
else
echo "Skipping hugepages permissions configuration."
fi

echo -e "${BOLD}${GREEN}DONE ✔${NC}"