From 1b805ef96a933bf78172dc64e1bd7618db995e5f Mon Sep 17 00:00:00 2001 From: Milosz Linkiewicz Date: Tue, 26 Nov 2024 10:49:36 +0000 Subject: [PATCH] Build baremetal ubuntu updated Build baremetal ubuntu updated Fixed to use script instead of custom build steps Minor naming convention changes Signed-off-by: Milosz Linkiewicz --- .github/workflows/codeql.yml | 8 +- .github/workflows/coverity.yml | 84 ++++++-------- .github/workflows/dependency-review.yml | 21 ++++ .github/workflows/docker-cached-build.yml | 2 +- .github/workflows/github_pages_update.yml | 3 +- .github/workflows/scorecard.yml | 41 ++----- .github/workflows/trivy.yml | 6 +- .github/workflows/ubuntu-build.yml | 95 ++++++---------- build.sh | 5 +- docs/README.md | 4 +- docs/setup-mcm-with-k8s.md | 4 +- media-proxy/build.sh | 4 +- scripts/common.sh | 60 +++++----- scripts/setup_build_env.sh | 96 ++++------------ scripts/setup_ice_irdma.sh | 103 ++++++++++++++++++ scripts/setup_rdma_env.sh | 7 +- sdk/build.sh | 6 +- .../test-rdma-latency.sh | 3 +- tests/single-node-sample-apps/test-rdma.sh | 3 +- tests/single-node-sample-apps/test.sh | 3 +- versions.env | 1 - 21 files changed, 279 insertions(+), 280 deletions(-) create mode 100644 .github/workflows/dependency-review.yml create mode 100755 scripts/setup_ice_irdma.sh diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 5aa417fe..a5e9aade 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,4 +1,4 @@ -name: Scan CodeQL +name: scan-codeql-workflow on: push: @@ -59,6 +59,12 @@ jobs: if: steps.load-local-dependencies-cache.outputs.cache-hit != 'true' run: eval 'source scripts/setup_build_env.sh && get_download_unpack_dependencies' + - name: 'Clone and patch ffmpeg 6.1 and 7.0' + if: steps.load-local-dependencies-cache.outputs.cache-hit != 'true' + run: | + ffmpeg-plugin/clone-and-patch-ffmpeg.sh "6.1" + ffmpeg-plugin/clone-and-patch-ffmpeg.sh "7.0" + - name: 'Build and Install xdp and libbpf' run: eval 'source scripts/setup_build_env.sh && lib_install_xdp_bpf_tools' diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 39787a72..12f31fa4 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -1,4 +1,4 @@ -name: Scan Coverity Ubuntu Scan +name: scan-coverity-baremetal on: schedule: @@ -12,13 +12,9 @@ on: env: BUILD_TYPE: Release + BUILD_DIR: "${{ github.workspace }}/_build" + PREFIX_DIR: "${{ github.workspace }}/_install" MTL_BUILD_DISABLE_PCAPNG: true - LIBFABRIC_DIR: /tmp/libfabric - XDP_VERSION: 5c88569dd15e55db678b897b8ea2a73aeaf956f4 - XDP_DIR: /tmp/xdp - GRPC_VERSION: v1.58.0 - GRPC_DIR: /tmp/grpc - PREFIX_DIR: /usr/local DEBIAN_FRONTEND: noninteractive permissions: @@ -42,58 +38,43 @@ jobs: - name: 'Install OS level dependencies' run: eval 'source scripts/setup_build_env.sh && install_package_dependencies' - - name: 'Build and Install xdp and libbpf' + - name: 'Check local dependencies build cache' + id: load-local-dependencies-cache + uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + with: + path: ${{ env.BUILD_DIR }} + key: ${{ runner.os }}-${{ hashFiles('versions.env') }}-${{ hashFiles('scripts/setup*.sh') }} + + - name: 'Download, unpack and patch build dependencies' + if: steps.load-local-dependencies-cache.outputs.cache-hit != 'true' + run: eval 'source scripts/setup_build_env.sh && get_download_unpack_dependencies' + + - name: 'Clone and patch ffmpeg 6.1 and 7.0' + if: steps.load-local-dependencies-cache.outputs.cache-hit != 'true' run: | - git clone --recurse-submodules https://github.com/xdp-project/xdp-tools.git "${XDP_DIR}" && \ - pushd "${XDP_DIR}" && \ - ./configure && \ - make -j$(nproc) && \ - sudo make install && \ - make -j$(nproc) -C "${XDP_DIR}/lib/libbpf/src" && \ - sudo make -C "${XDP_DIR}/lib/libbpf/src" install && popd + ffmpeg-plugin/clone-and-patch-ffmpeg.sh "6.1" + ffmpeg-plugin/clone-and-patch-ffmpeg.sh "7.0" + + - name: 'Build and Install xdp and libbpf' + run: eval 'source scripts/setup_build_env.sh && lib_install_xdp_bpf_tools' - name: 'Build and Install libfabric' - run: | - git clone --depth 1 --branch v1.22.0 https://github.com/ofiwg/libfabric "${LIBFABRIC_DIR}" && \ - pushd "${LIBFABRIC_DIR}" && \ - ./autogen.sh && ./configure && \ - make -j$(nproc) && \ - sudo make install && popd + run: eval 'source scripts/setup_build_env.sh && lib_install_fabrics' - - name: 'Install MTL' - run: | - git clone --depth 1 https://github.com/OpenVisualCloud/Media-Transport-Library.git imtl - pushd imtl && ./build.sh && popd + - name: 'Build and Install the DPDK' + run: eval 'source scripts/setup_build_env.sh && lib_install_dpdk' - - name: 'Restore cached for gRPC build' - id: grpc-cache-restore - uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: ${{ env.GRPC_DIR }} - key: Linux-grpc${{ env.GRPC_VERSION }} + - name: 'Build and Install the MTL' + run: eval 'source scripts/setup_build_env.sh && lib_install_mtl' - - name: 'Build gRPC' - if: steps.grpc-cache-restore.outputs.cache-hit != 'true' - run: | - git clone --branch ${GRPC_VERSION} --recurse-submodules --depth 1 --shallow-submodules https://github.com/grpc/grpc "${GRPC_DIR}" && \ - cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=${PREFIX_DIR} \ - -B "${GRPC_DIR}/cmake/build" -S "${GRPC_DIR}" && \ - cmake --build "${GRPC_DIR}/cmake/build" -j `nproc` - - - name: 'Save cache for gRPC build' - id: grpc-cache-save - if: steps.grpc-cache-restore.outputs.cache-hit != 'true' - uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: ${{ env.GRPC_DIR }} - key: ${{ steps.grpc-cache-restore.outputs.cache-primary-key }} + - name: 'Build and Install JPEG XS' + run: eval 'source scripts/setup_build_env.sh && lib_install_jpeg_xs' - - name: 'Install gRPC' - run: sudo cmake --install "${GRPC_DIR}/cmake/build" + - name: 'Build and Install JPEG XS ffmpeg plugin' + run: eval 'source scripts/setup_build_env.sh && lib_install_mtl_jpeg_xs_plugin' - - name: 'Patch and configure MCM FFmpeg plugin' - working-directory: ${{ github.workspace }}/ffmpeg-plugin - run: ./clone-and-patch-ffmpeg.sh + - name: 'Build gRPC and dependencies' + run: eval 'source scripts/setup_build_env.sh && lib_install_grpc' - name: 'Run coverity' uses: vapier/coverity-scan-action@2068473c7bdf8c2fb984a6a40ae76ee7facd7a85 # v1.8.0 @@ -107,6 +88,7 @@ jobs: ${{ github.workspace }}/build.sh && \ ${{ github.workspace }}/ffmpeg-plugin/configure-ffmpeg.sh && \ ${{ github.workspace }}/ffmpeg-plugin/build-ffmpeg.sh + - uses: actions/upload-artifact@v4 with: name: coverity-reports diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 00000000..10a3959c --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,21 @@ +# Source repository: https://github.com/actions/dependency-review-action +name: scan-dependency-review +on: [pull_request] + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: 'Harden Runner' + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + + - name: 'Checkout Repository' + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: 'Dependency Review' + uses: actions/dependency-review-action@72eb03d02c7872a771aacd928f3123ac62ad6d3a # v4.3.3 diff --git a/.github/workflows/docker-cached-build.yml b/.github/workflows/docker-cached-build.yml index ab383a96..baac955b 100644 --- a/.github/workflows/docker-cached-build.yml +++ b/.github/workflows/docker-cached-build.yml @@ -1,4 +1,4 @@ -name: Build Docker Images +name: build-docker-images on: pull_request: diff --git a/.github/workflows/github_pages_update.yml b/.github/workflows/github_pages_update.yml index 624bc3b0..742f745f 100644 --- a/.github/workflows/github_pages_update.yml +++ b/.github/workflows/github_pages_update.yml @@ -1,5 +1,4 @@ - -name: Documentation Build and Publish +name: documentation-build-and-publish on: workflow_call: workflow_dispatch: diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index f5c93fd3..d78cd941 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -1,17 +1,16 @@ name: scan-scorecard-security on: - pull_request: - branches: [ "main" ] + # For Branch-Protection check. Only the default branch is supported. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection branch_protection_rule: - + # To guarantee Maintained check is occasionally updated. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained + schedule: + - cron: '0 18 * * *' workflow_dispatch: push: branches: [ "main" ] -env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - INSIDE_REPO_PUSH: ${{ github.event_name == 'push' && github.repository == 'openvisualcloud/media-communications-mesh' }} - permissions: contents: read @@ -20,13 +19,10 @@ concurrency: cancel-in-progress: true jobs: - scorecard-analysis: - name: "scorecard-analysis" - runs-on: ubuntu-22.04 - if: | - github.event_name == 'push' && - github.repository == 'openvisualcloud/media-communications-mesh' && - '${{ github.head_ref || github.ref_name }}' == 'main' + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + if: ${{ github.repository == 'OpenVisualCloud/Media-Communications-Mesh' }} permissions: security-events: write id-token: write @@ -51,6 +47,7 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} publish_results: true + # Upload the results as artifacts (optional). - name: "scorecard: Upload results artifact" uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: @@ -62,19 +59,3 @@ jobs: uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 with: sarif_file: "scorecard-scan-results-${{ github.event.pull_request.number || github.ref }}.sarif" - - dependency-review: - name: "dependency-review" - runs-on: ubuntu-22.04 - if: ${{ github.repository == 'openvisualcloud/media-communications-mesh' }} - steps: - - name: "dependency-review: Harden Runner security" - uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 - with: - egress-policy: audit - - - name: 'dependency-review: Checkout Repository' - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - - name: 'dependency-review: Review dependencies' - uses: actions/dependency-review-action@72eb03d02c7872a771aacd928f3123ac62ad6d3a # v4.3.3 diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index 68e6f578..6058325c 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -1,4 +1,4 @@ -name: scaner-trivy-workflow +name: scan-trivy-workflow on: push: branches: [ "main", "master", "dev", "devel", "develop", "maint-*" ] @@ -39,7 +39,7 @@ jobs: uses: aquasecurity/trivy-action@7c2007bcb556501da015201bcba5aa14069b74e2 # v0.23.0 with: scan-type: config - skip-dirs: deployment #helm charts not supported + skip-dirs: deployment #helm charts not supported exit-code: '0' format: 'sarif' output: "trivy-config-scan-results-${{ github.event.pull_request.number || github.ref }}.sarif" @@ -49,7 +49,7 @@ jobs: uses: aquasecurity/trivy-action@7c2007bcb556501da015201bcba5aa14069b74e2 # v0.23.0 with: scan-type: config - skip-dirs: deployment #helm charts not supported + skip-dirs: deployment #helm charts not supported exit-code: '0' format: 'table' output: "trivy-config-scan-results-${{ github.event.pull_request.number || github.ref }}.txt" diff --git a/.github/workflows/ubuntu-build.yml b/.github/workflows/ubuntu-build.yml index 8ba560dd..be1486f7 100644 --- a/.github/workflows/ubuntu-build.yml +++ b/.github/workflows/ubuntu-build.yml @@ -1,4 +1,4 @@ -name: Build Baremetal Ubuntu +name: build-baremetal-ubuntu on: push: @@ -9,14 +9,10 @@ on: env: BUILD_TYPE: Release - MTL_BUILD_DISABLE_PCAPNG: true - LIBFABRIC_DIR: /tmp/libfabric - XDP_VERSION: 5c88569dd15e55db678b897b8ea2a73aeaf956f4 - XDP_DIR: /tmp/xdp - GRPC_VERSION: v1.58.0 - GRPC_DIR: /tmp/grpc - PREFIX_DIR: /usr/local + BUILD_DIR: "${{ github.workspace }}/_build" DEBIAN_FRONTEND: noninteractive + MTL_BUILD_DISABLE_PCAPNG: true + PREFIX_DIR: "${{ github.workspace }}/_install" permissions: contents: read @@ -45,59 +41,43 @@ jobs: - name: 'Install OS level dependencies' run: eval 'source scripts/setup_build_env.sh && install_package_dependencies' - - name: 'Build and Install xdp and libbpf' + - name: 'Check local dependencies build cache' + id: load-local-dependencies-cache + uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + with: + path: ${{ env.BUILD_DIR }} + key: ${{ runner.os }}-${{ hashFiles('versions.env') }}-${{ hashFiles('scripts/setup*.sh') }} + + - name: 'Download, unpack and patch build dependencies' + if: steps.load-local-dependencies-cache.outputs.cache-hit != 'true' + run: eval 'source scripts/setup_build_env.sh && get_download_unpack_dependencies' + + - name: 'Clone and patch ffmpeg 6.1 and 7.0' + if: steps.load-local-dependencies-cache.outputs.cache-hit != 'true' run: | - git clone --recurse-submodules https://github.com/xdp-project/xdp-tools.git "${XDP_DIR}" && \ - pushd "${XDP_DIR}" && \ - ./configure && \ - make -j$(nproc) && \ - sudo make install && \ - make -j$(nproc) -C "${XDP_DIR}/lib/libbpf/src" && \ - sudo make -C "${XDP_DIR}/lib/libbpf/src" install && popd + ffmpeg-plugin/clone-and-patch-ffmpeg.sh "6.1" + ffmpeg-plugin/clone-and-patch-ffmpeg.sh "7.0" + + - name: 'Build and Install xdp and libbpf' + run: eval 'source scripts/setup_build_env.sh && lib_install_xdp_bpf_tools' - name: 'Build and Install libfabric' - run: | - git clone --depth 1 --branch v1.22.0 https://github.com/ofiwg/libfabric "${LIBFABRIC_DIR}" && \ - pushd "${LIBFABRIC_DIR}" && \ - ./autogen.sh && ./configure && \ - make -j$(nproc) && \ - sudo make install && popd + run: eval 'source scripts/setup_build_env.sh && lib_install_fabrics' - - name: 'Install MTL' - run: | - git clone --depth 1 https://github.com/OpenVisualCloud/Media-Transport-Library.git imtl - pushd imtl && ./build.sh && popd + - name: 'Build and Install the DPDK' + run: eval 'source scripts/setup_build_env.sh && lib_install_dpdk' - - name: 'Restore cached for gRPC build' - id: grpc-cache-restore - uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: ${{ env.GRPC_DIR }} - key: Linux-grpc${{ env.GRPC_VERSION }} + - name: 'Build and Install the MTL' + run: eval 'source scripts/setup_build_env.sh && lib_install_mtl' - - name: 'Build gRPC' - if: steps.grpc-cache-restore.outputs.cache-hit != 'true' - run: | - git clone --branch ${GRPC_VERSION} --recurse-submodules --depth 1 --shallow-submodules https://github.com/grpc/grpc "${GRPC_DIR}" && \ - cmake -DgRPC_INSTALL=ON \ - -DgRPC_BUILD_TESTS=OFF \ - -DCMAKE_INSTALL_PREFIX=${PREFIX_DIR} \ - -B "${GRPC_DIR}/cmake/build" - -S "${GRPC_DIR}" && \ - cmake --build "${GRPC_DIR}/cmake/build" -j `nproc` - - - name: 'Save cache for gRPC build' - if: steps.grpc-cache-restore.outputs.cache-hit != 'true' - id: grpc-cache-save - uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: ${{ env.GRPC_DIR }} - key: ${{ steps.grpc-cache-restore.outputs.cache-primary-key }} + - name: 'Build and Install JPEG XS' + run: eval 'source scripts/setup_build_env.sh && lib_install_jpeg_xs' - - name: 'Install gRPC' - run: | - sudo cmake --install "${GRPC_DIR}/cmake/build" && \ - rm -rf "${GRPC_DIR}" + - name: 'Build and Install JPEG XS ffmpeg plugin' + run: eval 'source scripts/setup_build_env.sh && lib_install_mtl_jpeg_xs_plugin' + + - name: 'Build gRPC and dependencies' + run: eval 'source scripts/setup_build_env.sh && lib_install_grpc' - name: 'Build MCM SDK and Media Proxy' run: ./build.sh @@ -105,8 +85,5 @@ jobs: - name: 'Build MCM FFmpeg plugin' working-directory: ${{ github.workspace }}/ffmpeg-plugin run: | - git config --global user.email "you@intel.com" - git config --global user.name "Your Name" - ./clone-and-patch-ffmpeg.sh && \ - ./configure-ffmpeg.sh && \ - ./build-ffmpeg.sh + ./configure-ffmpeg.sh && \ + ./build-ffmpeg.sh diff --git a/build.sh b/build.sh index 8a01bead..1bfd76e6 100755 --- a/build.sh +++ b/build.sh @@ -7,10 +7,7 @@ # SDK in to default path and the one pointed as $1 set -eo pipefail - SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" -BUILD_DIR="${BUILD_DIR:-${SCRIPT_DIR}/_build}" -MCM_BUILD_DIR="${MCM_BUILD_DIR:-${BUILD_DIR}/mcm}" # shellcheck source="scripts/common.sh" . "${SCRIPT_DIR}/scripts/common.sh" @@ -18,6 +15,7 @@ MCM_BUILD_DIR="${MCM_BUILD_DIR:-${BUILD_DIR}/mcm}" # Set build type. ("Debug" or "Release") # To disable the building of unit tests, set the value to "OFF". +MCM_BUILD_DIR="${MCM_BUILD_DIR:-${BUILD_DIR}/mcm}" BUILD_TYPE="${BUILD_TYPE:-Release}" BUILD_UNIT_TESTS="${BUILD_UNIT_TESTS:-ON}" INSTALL_PREFIX="${INSTALL_PREFIX:-/usr/local}" @@ -40,5 +38,6 @@ as_root ldconfig export LD_LIBRARY_PATH="${PREFIX_DIR}/usr/local/lib:/usr/local/lib64" "${MCM_BUILD_DIR}/bin/sdk_unit_tests" "${MCM_BUILD_DIR}/bin/media_proxy_unit_tests" +ln -s "${MCM_BUILD_DIR}" "${SCRIPT_DIR}/build" log_info "Build Succeeded" diff --git a/docs/README.md b/docs/README.md index fa61ab78..5bc9ef4d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -156,7 +156,7 @@ This will start the media proxy in blocking mode and confirm that build was succ > [!WARNING] > Depending on your docker installation, this step may require being run as `root`. - run bellow command from the root directory of the repository to build all of the Dockerfiles: + run below command from the root directory of the repository to build all of the Dockerfiles: ```bash $ ./build_docker.sh @@ -170,7 +170,7 @@ After running the `build_docker.sh` the following docker images will be availabl - `mcm/ffmpeg:latest` - `mcm/ffmpeg:6.1-latest` -Now the "Media Proxy" can be run inside the container. To check it, execute bellow command: +Now the "Media Proxy" can be run inside the container. To check it, execute below command: ```bash $ docker run --privileged -it -v /var/run/mcm:/run/mcm -v /dev/hugepages:/dev/hugepages mcm/media-proxy:latest diff --git a/docs/setup-mcm-with-k8s.md b/docs/setup-mcm-with-k8s.md index 7ef32bb8..df0f3e9f 100644 --- a/docs/setup-mcm-with-k8s.md +++ b/docs/setup-mcm-with-k8s.md @@ -14,7 +14,7 @@ To set up your Minikube cluster and deploy resources, please ensure that the fol To build Dockerfiles Media-Proxy, FFmpeg and SDK follow the guide [](./README.md#build-the-docker-images). Sample applications will be available inside `mcm/SDK:latest` Docker image at `/opt/mcm` path. For more information refer to [sample applications](../sdk/README.md#sample-applications). For more advanced and/or production environment usage, we encourage use the FFmpeg based workflow, either minimalistic [MCM FFmpeg plugin](../ffmpeg-plugin/README.md) version or full-capabilities all-in-one [Intel® Tiber™ Broadcast Suite](https://github.com/OpenVisualCloud/Intel-Tiber-Broadcast-Suite). ```bash -# Bellow script accept all docker build parameters, for example fresh rebuild: +# below script accept all docker build parameters, for example fresh rebuild: # ./build_docker.sh --no-cache # This depending on your Docker installation type may require using sudo: # sudo ./build_docker.sh @@ -37,7 +37,7 @@ docker build --build-arg=http_proxy --build-arg=https_proxy --build-arg=no_proxy ### MTL Manager build: -To build MTL Manager you need to fetch and build MTL Library from the source, this can be done by following bellow commands: +To build MTL Manager you need to fetch and build MTL Library from the source, this can be done by following below commands: ```bash git clone https://github.com/OpenVisualCloud/Media-Transport-Library.git diff --git a/media-proxy/build.sh b/media-proxy/build.sh index 5964d937..2cf3fd22 100755 --- a/media-proxy/build.sh +++ b/media-proxy/build.sh @@ -9,12 +9,11 @@ set -eo pipefail SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" REPO_DIR="$(readlink -f "${SCRIPT_DIR}/..")" -BUILD_DIR="${BUILD_DIR:-${REPO_DIR}/_build}" -MCM_MEDIA_PROXY_DIR="${MCM_MEDIA_PROXY_DIR:-${BUILD_DIR}/mcm-media-proxy}" # shellcheck source="../scripts/common.sh" . "${REPO_DIR}/scripts/common.sh" +MCM_MEDIA_PROXY_DIR="${MCM_MEDIA_PROXY_DIR:-${BUILD_DIR}/mcm-media-proxy}" # Set build type. ("Debug" or "Release") BUILD_TYPE="${BUILD_TYPE:-Release}" INSTALL_PREFIX="${INSTALL_PREFIX:-/usr/local}" @@ -26,3 +25,4 @@ as_root make -C "${MCM_MEDIA_PROXY_DIR}" install if [[ $# -ne 0 ]]; then DESTDIR="${1:-$DESTDIR}" make -C "${MCM_MEDIA_PROXY_DIR}" install fi +ln -s "${MCM_MEDIA_PROXY_DIR}" "${SCRIPT_DIR}/build" diff --git a/scripts/common.sh b/scripts/common.sh index a89d5ce8..a8747343 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -3,14 +3,32 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2024 Intel Corporation -COMMON_SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" -REPOSITORY_DIR="$(readlink -f "${COMMON_SCRIPT_DIR}/..")" -VERSIONS_FILE_PATH="$(readlink -f "${VERSIONS_FILE_PATH:-${REPOSITORY_DIR}/versions.env}")" +export REPO_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")/..")" +export BUILD_DIR="${BUILD_DIR:-${REPO_DIR}/_build}" +export DRIVERS_DIR="${DRIVERS_DIR:-/opt/intel/drivers}" +export PREFIX_DIR="${PREFIX_DIR:-${REPO_DIR}/_install}" + +VERSIONS_FILE_PATH="$(readlink -f "${VERSIONS_FILE:-${REPO_DIR}/versions.env}")" export VERSIONS_FILE_PATH # shellcheck source="versions.env" . "${VERSIONS_FILE_PATH}" +export MTL_DIR="${BUILD_DIR}/mtl" +export DPDK_DIR="${BUILD_DIR}/dpdk" +export XDP_DIR="${BUILD_DIR}/xdp" +export BPF_DIR="${XDP_DIR}/lib/libbpf" +export GRPC_DIR="${BUILD_DIR}/grpc" +export JPEGXS_DIR="${BUILD_DIR}/jpegxs" +export LIBFABRIC_DIR="${BUILD_DIR}/libfabric" +export LIBFDT_DIR="${BUILD_DIR}/libfdt" +export JSONC_DIR="${BUILD_DIR}/json-c" +export NASM_DIR="${BUILD_DIR}/nasm" + +export ICE_DIR="${DRIVERS_DIR}/ice/${ICE_VER}" +export IAVF_DIR="${DRIVERS_DIR}/iavf/${IAVF_VER}" +export IRDMA_DIR="${DRIVERS_DIR}/irdma/${IRDMA_VER}" + PM="${PM:-apt-get}" KERNEL_VERSION="${KERNEL_VERSION:-$(uname -r)}" export TZ="${TZ:-Europe/Warsaw}" @@ -262,6 +280,7 @@ function print_logo() function print_logo_sequence() { + set +x local wait_between_frames="${1:-0}" local wait_cmd="" if [ ! "${wait_between_frames}" = "0" ]; then @@ -289,6 +308,7 @@ function print_logo_sequence() function print_logo_anim() { + set +x local number_of_sequences="${1:-2}" local wait_between_frames="${2:-0.025}" clear @@ -298,7 +318,8 @@ function print_logo_anim() done } -function catch_error_print_debug() { +function catch_error_print_debug() +{ local _last_command_height="" local -n _lineno="${1:-LINENO}" local -n _bash_lineno="${2:-BASH_LINENO}" @@ -382,37 +403,6 @@ function wget_download_strip_unpack() rm -f "${dest_dir}/${filename}.tar.gz" } -function config_intel_rdma_driver() { - # \s - single (s)pace or tabulator - # \d - single (d)igit - # ^\s* - starts with zero or more space/tabulators - # \s\+ - at least one or more space/tabulators - local PREFIX_REGEX='^\s*options\s\+irdma\s\+' - local PREFIX_NORM_ROCE='options irdma roce_ena=1' - local PREFIX_NORM_SEL='options irdma limits_sel=5' - - log_info "Configuration of iRDMA starting." - touch "/etc/modprobe.d/irdma.conf" - - log_info "Enabling RoCE." - if grep -e "${PREFIX_REGEX}roce_ena=" /etc/modprobe.d/irdma.conf 1>/dev/null 2>&1; then - sudo sed -i "s/${PREFIX_REGEX}roce_ena=\d/${PREFIX_NORM_ROCE}/g" /etc/modprobe.d/irdma.conf - else - echo "${PREFIX_NORM_ROCE}" | sudo tee -a /etc/modprobe.d/irdma.conf - fi - log_info "RoCE enabled." - - log_info "Increasing Queue Pair limit." - if grep -e "${PREFIX_REGEX}limits_sel=" /etc/modprobe.d/irdma.conf 1>/dev/null 2>&1; then - sudo sed -i "s/${PREFIX_REGEX}limits_sel=\d/${PREFIX_NORM_SEL}/g" /etc/modprobe.d/irdma.conf - else - echo "${PREFIX_NORM_SEL}" | sudo tee -a /etc/modprobe.d/irdma.conf - fi - sudo dracut -f - log_info "Queue Pair limits_sel set to 5." - log_info "Configuration of iRDMA finished." -} - # Example usage: # PM="$(setup_package_manager)" && \ # $PM install python3 diff --git a/scripts/setup_build_env.sh b/scripts/setup_build_env.sh index db2bc1cf..e9171574 100755 --- a/scripts/setup_build_env.sh +++ b/scripts/setup_build_env.sh @@ -1,20 +1,10 @@ #!/bin/bash set -eEo pipefail -set +x SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" -REPO_DIR="$(readlink -f "${SCRIPT_DIR}/..")" -BUILD_DIR="${BUILD_DIR:-${REPO_DIR}/_build}" -PREFIX_DIR="${PREFIX_DIR:-${REPO_DIR}/_install}" -DRIVERS_DIR="${DRIVERS_DIR:-/opt/intel/drivers}" - . "${SCRIPT_DIR}/common.sh" -ICE_DIR="${DRIVERS_DIR}/ice/${ICE_VER}" -IAVF_DIR="${DRIVERS_DIR}/iavf/${IAVF_VER}" -IRDMA_DIR="${DRIVERS_DIR}/irdma/${IRDMA_VER}" - export PM="${PM:-apt-get}" export DEBIAN_FRONTEND="noninteractive" @@ -31,28 +21,24 @@ mkdir -p "${PREFIX_DIR}/usr/lib/x86_64-linux-gnu" \ "${PREFIX_DIR}/usr/local/include" \ "${PREFIX_DIR}/usr/include" -MTL_DIR="${BUILD_DIR}/mtl" -DPDK_DIR="${BUILD_DIR}/dpdk" -XDP_DIR="${BUILD_DIR}/xdp" -BPF_DIR="${XDP_DIR}/lib/libbpf" -GRPC_DIR="${BUILD_DIR}/grpc" -JPEGXS_DIR="${BUILD_DIR}/jpegxs" -LIBFABRIC_DIR="${BUILD_DIR}/libfabric" -LIBFDT_DIR="${BUILD_DIR}/libfdt" -JSONC_DIR="${BUILD_DIR}/json-c" -NASM_DIR="${BUILD_DIR}/nasm" - function install_package_dependencies() { + log_info Starting: OS packages installation. + log_info Starting: OS package manager auto-detection. setup_package_manager "apt-get" if [[ "${PM}" == "apt" || "${PM}" == "apt-get" ]]; then + log_success "Found ${PM}. Using Ubuntu package dependencies approach" install_ubuntu_package_dependencies elif [[ "${PM}" == "yum" || "${PM}" == "dnf" ]]; then + log_success "Found ${PM}. Using CentOS package dependencies approach" install_yum_package_dependencies else - log_error No supported package manager found + log_error "Exiting: No supported package manager found. Contact support" exit 1 fi + log_info "Finished: Successful OS packages installation." + log_warning OS reboot is required for all of the changes to take place. + return 0 } function install_ubuntu_package_dependencies() { @@ -163,6 +149,7 @@ function install_yum_package_dependencies() lib_build_and_install_jsonc && \ return 0 || return 1 } + # Download and unpack dependencies from source code. function get_download_unpack_dependencies() { @@ -179,44 +166,6 @@ function get_download_unpack_dependencies() patch -d "${DPDK_DIR}" -p1 -i <(cat "${MTL_DIR}/patches/dpdk/${DPDK_VER}/"*.patch) } -function get_and_patch_intel_drivers() -{ - log_info "Intel drivers: Starting download and patching actions." - if [ ! -d "${MTL_DIR}/patches/ice_drv/${ICE_VER}/" ]; then - log_error "MTL patch for ICE=v${ICE_VER} could not be found: ${MTL_DIR}/patches/ice_drv/${ICE_VER}" - return 1 - fi - wget_download_strip_unpack "${IRDMA_REPO}" "${IRDMA_DIR}" - git_download_strip_unpack "intel/ethernet-linux-iavf" "refs/tags/v${IAVF_VER}" "${IAVF_DIR}" && \ - git_download_strip_unpack "intel/ethernet-linux-ice" "refs/tags/v${ICE_VER}" "${ICE_DIR}" && \ - pushd "${ICE_DIR}" && \ - patch -p1 -i <(cat "${MTL_DIR}/patches/ice_drv/${ICE_VER}/"*.patch) && \ - popd && \ - { log_success "Intel drivers: Finished download and patching actions." && return 0; } || - { log_error "Intel drivers: Failed to download or patch." && return 1; } -} - -function build_install_and_config_intel_drivers() -{ - log_info "Intel IAVF: Driver starting the build and install workflow." && \ - as_root make "-j${NPROC}" -C "${IAVF_DIR}/src" install && \ - log_info "Intel ICE: Driver starting the build and install workflow." && \ - as_root make "-j${NPROC}" -C "${ICE_DIR}/src" install && \ - { log_success "Intel IAVF and ICE: Drivers finished install process." && return 0; } || - { log_error "Intel IAVF and ICE: Failed to build and install drivers" && return 1; } -} - -function build_install_and_config_irdma_drivers() -{ - pushd "${IRDMA_DIR}" && \ - as_root ./build.sh && \ - popd && \ - as_root config_intel_rdma_driver && \ - as_root modprobe irdma && \ - { log_success "Intel irdma: Finished configuration and installation successfully." && return 0; } || \ - { log_error "Intel irdma: Error while performing configuration/installation." && return 1; } -} - # Download and install rpm repo for nasm function lib_install_nasm_from_rpm() { @@ -347,10 +296,14 @@ function full_build_and_install_workflow() lib_install_dpdk && \ lib_install_mtl && \ lib_install_jpeg_xs && \ - lib_install_mtl_jpeg_xs_plugin && \ - chmod -R a+r "${BUILD_DIR}" && \ - { log_success "Finished: Dependencies build, install and configation." && return 0; } || - { log_error "Dependencies build, install and configation failed." && return 1; } + lib_install_mtl_jpeg_xs_plugin + return_code="$?" + if [[ "${return_code}" != "0" ]]; then + log_error "Dependencies build, install and configation failed." + else + log_success "Finished: Dependencies build, install and configation." + fi + return "${return_code}" } # cp -f "${REPO_DIR}/media-proxy/imtl.json" "/usr/local/etc/imtl.json" # export KAHAWAI_CFG_PATH="/usr/local/etc/imtl.json" @@ -359,7 +312,7 @@ function full_build_and_install_workflow() if [[ "${BASH_SOURCE[0]}" == "${0}" ]] then if [ "${EUID}" != "0" ]; then - log_error "Must be run as root. Try running bellow command:" + log_error "Must be run as root. Try running below command:" log_error "sudo \"${BASH_SOURCE[0]}\"" exit 3 fi @@ -368,20 +321,9 @@ then sleep 2 fi trap_error_print_debug - set -x - log_info Starting: OS packages installation, MTL and DPDK download. install_package_dependencies get_download_unpack_dependencies - log_info Finished: OS packages installation, MTL and DPDK download. - get_and_patch_intel_drivers full_build_and_install_workflow - build_install_and_config_irdma_drivers - build_install_and_config_intel_drivers || \ - { log_error Intel drivers configuration/installation failed. && exit 1; } - log_success Finished: Build, install and configuration of Intel drivers. - log_success All tasks compleated. Reboot required. - log_warning "" - log_warning OS reboot is required for all of the changes to take place. - set +x + log_success "All tasks compleated successfuly. Happy MCM'ing ;-)" exit 0 fi diff --git a/scripts/setup_ice_irdma.sh b/scripts/setup_ice_irdma.sh new file mode 100755 index 00000000..09a1cc8c --- /dev/null +++ b/scripts/setup_ice_irdma.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash + +set -eEo pipefail +set +x + +SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" +WORKING_DIR="${BUILD_DIR:-${REPO_DIR}/build/rdma}" +PERF_DIR="${DRIVERS_DIR}/perftest" + +. "${SCRIPT_DIR}/common.sh" + +function get_and_patch_intel_drivers() +{ + log_info "Intel drivers: Starting download and patching actions." + if [ ! -d "${MTL_DIR}/patches/ice_drv/${ICE_VER}/" ]; then + log_error "MTL patch for ICE=v${ICE_VER} could not be found: ${MTL_DIR}/patches/ice_drv/${ICE_VER}" + return 1 + fi + wget_download_strip_unpack "${IRDMA_REPO}" "${IRDMA_DIR}" && \ + git_download_strip_unpack "intel/ethernet-linux-iavf" "refs/tags/v${IAVF_VER}" "${IAVF_DIR}" && \ + git_download_strip_unpack "intel/ethernet-linux-ice" "refs/tags/v${ICE_VER}" "${ICE_DIR}" + + if [[ ! -d "${MTL_DIR}" ]]; then + git_download_strip_unpack "OpenVisualCloud/Media-Transport-Library" "${MTL_VER}" "${MTL_DIR}" + fi + pushd "${ICE_DIR}" && \ + patch -p1 -i <(cat "${MTL_DIR}/patches/ice_drv/${ICE_VER}/"*.patch) && \ + popd && \ + { log_success "Intel drivers: Finished download and patching actions." && return 0; } || + { log_error "Intel drivers: Failed to download or patch." && return 1; } +} + +function build_install_and_config_intel_drivers() +{ + log_info "Intel IAVF: Driver starting the build and install workflow." + if as_root make "-j${NPROC}" -C "${IAVF_DIR}/src" install; then + log_info "Intel ICE: Driver starting the build and install workflow." + if as_root make "-j${NPROC}" -C "${ICE_DIR}/src" install; then + log_success "Intel IAVF and ICE: Drivers finished install process." + return 0 + fi + fi + log_error "Intel IAVF and ICE: Failed to build and install drivers" + return 1 +} + +function build_install_and_config_irdma_drivers() +{ + if pushd "${IRDMA_DIR}" && as_root ./build.sh && as_root modprobe irdma && popd; then + log_success "Intel irdma: Finished configuration and installation successfully." + return 0 + fi + log_error "Intel irdma: Error while performing configuration/installation." + return 1 +} + +function config_intel_rdma_driver() +{ + # \s - single (s)pace or tabulator + # \d - single (d)igit + # ^\s* - starts with zero or more space/tabulators + # \s\+ - at least one or more space/tabulators + local PREFIX_REGEX='^\s*options\s\+irdma\s\+' + local PREFIX_NORM_ROCE='options\ irdma\ roce_ena=1' + local PREFIX_NORM_SEL='options\ irdma\ limits_sel=5' + + log_info "Configuration of iRDMA starting." + as_root mkdir -p "/etc/modprobe.d" + as_root touch "/etc/modprobe.d/irdma.conf" + + log_info "Enabling RoCE." + if grep -e "${PREFIX_REGEX}roce_ena=" /etc/modprobe.d/irdma.conf 1>/dev/null 2>&1; then + as_root sed -i "s/${PREFIX_REGEX}roce_ena=\d/${PREFIX_NORM_ROCE}/g" /etc/modprobe.d/irdma.conf + else + echo "${PREFIX_NORM_ROCE}" | as_root tee -a /etc/modprobe.d/irdma.conf + fi + log_success "RoCE enabled." + + log_info "Increasing Queue Pair limit." + if grep -e "${PREFIX_REGEX}limits_sel=" /etc/modprobe.d/irdma.conf 1>/dev/null 2>&1; then + as_root sed -i "s/${PREFIX_REGEX}limits_sel=\d/${PREFIX_NORM_SEL}/g" /etc/modprobe.d/irdma.conf + else + echo "${PREFIX_NORM_SEL}" | as_root tee -a /etc/modprobe.d/irdma.conf + fi + as_root dracut -f + log_success "Queue Pair limits_sel set to 5." + log_success "Configuration of iRDMA finished." +} + + +# Allow sourcing of the script. +if [[ "${BASH_SOURCE[0]}" == "${0}" ]] +then + get_and_patch_intel_drivers && \ + build_install_and_config_irdma_drivers && \ + build_install_and_config_intel_drivers && \ + config_intel_rdma_driver + return_code="$?" + [[ "${return_code}" == "0" ]] && { log_success "Finished: Build, install and configuration of Intel drivers."; exit 0; } + + log_error "Intel drivers configuration/installation failed." + exit "${return_code}" +fi diff --git a/scripts/setup_rdma_env.sh b/scripts/setup_rdma_env.sh index 9be9fdf2..1e34be18 100755 --- a/scripts/setup_rdma_env.sh +++ b/scripts/setup_rdma_env.sh @@ -4,13 +4,10 @@ set -eEo pipefail set +x SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" -REPO_DIR="$(readlink -f "${SCRIPT_DIR}/..")" -BUILD_DIR="${BUILD_DIR:-${REPO_DIR}/_build}" -DRIVERS_DIR="${DRIVERS_DIR:-/opt/intel/drivers}" WORKING_DIR="${BUILD_DIR:-${REPO_DIR}/build/rdma}" PERF_DIR="${DRIVERS_DIR}/perftest" -. "${SCRIPT_DIR}/setup_build_env.sh" +. "${SCRIPT_DIR}/common.sh" function install_perftest() { log_info "Start of install_perftest method. Installing apt packages." @@ -92,7 +89,7 @@ function run_perftest() { if [[ "${BASH_SOURCE[0]}" == "${0}" ]] then if [ "${EUID}" != "0" ]; then - log_error "Must be run as root. Try running bellow command:" + log_error "Must be run as root. Try running below command:" log_error "sudo \"${BASH_SOURCE[0]}\"" exit 1 fi diff --git a/sdk/build.sh b/sdk/build.sh index d13bbf7f..03d12fca 100755 --- a/sdk/build.sh +++ b/sdk/build.sh @@ -10,13 +10,12 @@ set -eo pipefail SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" REPO_DIR="$(readlink -f "${SCRIPT_DIR}/..")" -BUILD_DIR="${BUILD_DIR:-${REPO_DIR}/_build}" -MCM_SDK_DIR="${MCM_SDK_DIR:-${BUILD_DIR}/mcm-sdk}" # shellcheck source="../scripts/common.sh" -. "${SCRIPT_DIR}/../scripts/common.sh" +. "${REPO_DIR}/scripts/common.sh" # Set build type. ("Debug" or "Release") +MCM_SDK_DIR="${MCM_SDK_DIR:-${BUILD_DIR}/mcm-sdk}" BUILD_TYPE="${BUILD_TYPE:-Release}" INSTALL_PREFIX="${INSTALL_PREFIX:-/usr/local}" @@ -27,3 +26,4 @@ as_root make -C "${MCM_SDK_DIR}" install if [[ $# -ne 0 ]]; then DESTDIR="${1:-$DESTDIR}" make -C "${MCM_SDK_DIR}" install fi +ln -s "${MCM_SDK_DIR}" "${SCRIPT_DIR}/build" diff --git a/tests/single-node-sample-apps/test-rdma-latency.sh b/tests/single-node-sample-apps/test-rdma-latency.sh index f0756ca6..3d8a02cb 100755 --- a/tests/single-node-sample-apps/test-rdma-latency.sh +++ b/tests/single-node-sample-apps/test-rdma-latency.sh @@ -5,7 +5,8 @@ # Directories script_dir="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" -bin_dir="$script_dir/../../_build/bin" +repository_dir="$(readlink -f "${script_dir}/../..")" +bin_dir="$repository_dir/build/bin" out_dir="$script_dir/out" # Media file names diff --git a/tests/single-node-sample-apps/test-rdma.sh b/tests/single-node-sample-apps/test-rdma.sh index fe436149..824b1c4d 100755 --- a/tests/single-node-sample-apps/test-rdma.sh +++ b/tests/single-node-sample-apps/test-rdma.sh @@ -5,7 +5,8 @@ # Directories script_dir="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" -bin_dir="$script_dir/../../_build/bin" +repository_dir="$(readlink -f "${script_dir}/../..")" +bin_dir="$repository_dir/build/bin" out_dir="$script_dir/out" # Media file names diff --git a/tests/single-node-sample-apps/test.sh b/tests/single-node-sample-apps/test.sh index 6746d1b3..e2c137a4 100755 --- a/tests/single-node-sample-apps/test.sh +++ b/tests/single-node-sample-apps/test.sh @@ -5,9 +5,10 @@ # Directories script_dir="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")" +repository_dir="$(readlink -f "${script_dir}/../..")" . "${script_dir}/test_memif.sh" . "${script_dir}/test_af_xdp.sh" -bin_dir="$(readlink -f "${script_dir}/../../out/bin")" +bin_dir="$(readlink -f "${repository_dir}/build/bin")" out_dir="$(readlink -f "${script_dir}/out")" # Colors enablement diff --git a/versions.env b/versions.env index 0cf90e7b..bfd311a1 100644 --- a/versions.env +++ b/versions.env @@ -1,4 +1,3 @@ - BPF_VER=42065ea6627ff6e1ab4c65e51042a70fbf30ff7c DPDK_VER=23.11 GPRC_VER=v1.58.0