DPDK build: fix l3fwd build and update Meson opts
[csit.git] / resources / libraries / bash / function / dpdk.sh
index 0b148aa..ea7871b 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -86,14 +86,20 @@ function dpdk_compile () {
 
     pushd "${DPDK_DIR}" || die "Pushd failed"
 
-    # Patch ARM.
-    sed_cmd="s/'RTE_MAX_LCORE', [0-9]*/'RTE_MAX_LCORE', $(nproc --all)/"
-    sed_file="config/arm/meson.build"
-    sed -i "${sed_cmd}" "${sed_file}" || die "Patch failed"
+    # enable l3fwd
+    meson_options="-Dexamples=l3fwd "
+
+    # i40e specific options
+    meson_options="${meson_options} -Dc_args=RTE_LIBRTE_I40E_16BYTE_RX_DESC=y"
+
+    # Configure generic build - the same used by VPP
+    meson_options="${meson_options} -Dplatform=generic"
 
     # Patch L3FWD.
-    sed_rxd="s/^#define RTE_TEST_RX_DESC_DEFAULT 128/#define RTE_TEST_RX_DESC_DEFAULT 1024/g"
-    sed_txd="s/^#define RTE_TEST_TX_DESC_DEFAULT 512/#define RTE_TEST_TX_DESC_DEFAULT 1024/g"
+    sed_rxd="s/^#define RTE_TEST_RX_DESC_DEFAULT 128"
+    sed_rxd+="/#define RTE_TEST_RX_DESC_DEFAULT 1024/g"
+    sed_txd="s/^#define RTE_TEST_TX_DESC_DEFAULT 512"
+    sed_txd+="/#define RTE_TEST_TX_DESC_DEFAULT 1024/g"
     sed_file="./main.c"
     pushd examples/l3fwd || die "Pushd failed"
     sed -i "${sed_rxd}" "${sed_file}" || die "Patch failed"
@@ -101,9 +107,7 @@ function dpdk_compile () {
     popd || die "Popd failed"
 
     # Compile using Meson and Ninja.
-    export CFLAGS=""
-    CFLAGS+="-DRTE_LIBRTE_I40E_16BYTE_RX_DESC=y"
-    meson -Dexamples=l3fwd build || {
+    meson ${meson_options} build || {
         die "Failed to compile DPDK!"
     }
     ninja -C build || die "Failed to compile DPDK!"
@@ -204,8 +208,10 @@ function dpdk_l3fwd_compile () {
 
     pushd "${DPDK_DIR}" || die "Pushd failed"
     # Patch L3FWD.
-    sed_rxd="s/^#define RTE_TEST_RX_DESC_DEFAULT 128/#define RTE_TEST_RX_DESC_DEFAULT 2048/g"
-    sed_txd="s/^#define RTE_TEST_TX_DESC_DEFAULT 512/#define RTE_TEST_TX_DESC_DEFAULT 2048/g"
+    sed_rxd="s/^#define RTE_TEST_RX_DESC_DEFAULT 128"
+    sed_rxd+="/#define RTE_TEST_RX_DESC_DEFAULT 2048/g"
+    sed_txd="s/^#define RTE_TEST_TX_DESC_DEFAULT 512"
+    sed_txd+="/#define RTE_TEST_TX_DESC_DEFAULT 2048/g"
     sed_file="./main.c"
     pushd examples/l3fwd || die "Pushd failed"
     sed -i "${sed_rxd}" "${sed_file}" || die "Patch failed"