diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 714b4e92ad..862a441ccb 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -2,7 +2,7 @@ // load pipeline functions // Requires pipeline-github-lib plugin to load library from github -@Library('github.com/Mellanox/ci-demo@stable') +@Library('github.com/Mellanox/ci-demo@stable_media') def matrix = new com.mellanox.cicd.Matrix() matrix.main() diff --git a/.ci/antivirus.sh b/.ci/antivirus.sh new file mode 100755 index 0000000000..26d90d3e78 --- /dev/null +++ b/.ci/antivirus.sh @@ -0,0 +1,37 @@ +#!/bin/bash -uxe + +echo -e "\n\n**********************************" +echo -e "\n\nStarting antivirus.sh script...\n\n" +echo -e "**********************************\n\n" + +[[ -z "${WORKSPACE:-}" ]] && { echo "ERROR: WORKSPACE variable is empty"; exit 1; } +[[ ! -d "${WORKSPACE}" ]] && { echo "ERROR: ${WORKSPACE} does not exist"; exit 1; } +[[ -z "${release_folder:-}" ]] && { echo "ERROR: release_folder variable is empty"; exit 1; } +[[ ! -d "${release_folder}" ]] && { echo "ERROR: ${release_folder} does not exist"; exit 1; } +[[ -z "${release_tag:-}" ]] && { echo "ERROR: release_tag variable is empty"; exit 1; } + +if [ -z "${revision:-}" ]; then + echo "WARN: 'revision' was not set, defaulting to 1" + revision=1 +fi + +mkdir -p "${WORKSPACE}/logs/" + +release_src_folder="${release_folder}/vma_v_${release_tag}-0/src" +pkg_name="libvma-${release_tag}-${revision}.src.rpm" +tarball_name="libvma-${release_tag}.tar.gz" +rpm_log="${WORKSPACE}/logs/${pkg_name}_antivirus.log" +tarball_log="${WORKSPACE}/logs/${tarball_name}_antivirus.log" + +[[ ! -d "${release_src_folder}" ]] && { echo "ERROR: ${release_src_folder} does not exist."; exit 1; } +[[ ! -e "${release_src_folder}/${pkg_name}" ]] && { echo "ERROR: ${release_src_folder}/${pkg_name} does not exist."; exit 1; } +[[ ! -e "${release_src_folder}/${tarball_name}" ]] && { echo "ERROR: ${release_src_folder}/${tarball_name} does not exist."; exit 1; } + +/auto/GLIT/SCRIPTS/HELPERS/antivirus-scan.sh "${release_src_folder}/${pkg_name}" |& tee "${rpm_log}" +/auto/GLIT/SCRIPTS/HELPERS/antivirus-scan.sh "${release_src_folder}/${tarball_name}" |& tee "${tarball_log}" + +if grep -q 'Possibly Infected:............. 0' "${rpm_log}" && grep -q 'Possibly Infected:............. 0' "${tarball_log}"; then + exit 0 +else + exit 1 +fi diff --git a/.ci/blackduck_source.sh b/.ci/blackduck_source.sh new file mode 100755 index 0000000000..1cc89b8d70 --- /dev/null +++ b/.ci/blackduck_source.sh @@ -0,0 +1,47 @@ +#!/bin/bash -Exel + +topdir=$(git rev-parse --show-toplevel) +cd "$topdir" + +# Check if the variables and pipeline attributes are set +[[ -z "${WORKSPACE}" ]] && { echo "Error: WORKSPACE variable is not set"; exit 1; } +[[ -z "$BLACKDUCK_API_TOKEN" ]] && { echo "Error: BLACKDUCK_API_TOKEN variable is not set"; exit 1; } +[[ ! -d "${WORKSPACE}/logs" ]] && mkdir -p "${WORKSPACE}/logs" + +# Create valid JSON for further authentication in BlackDuck server +json=$(jq -n \ + --arg token "$BLACKDUCK_API_TOKEN" \ + '{"blackduck.url": "https://blackduck.mellanox.com/", "blackduck.api.token": $token }') + +export SPRING_APPLICATION_JSON="$json" +export PROJECT_NAME=LibVMA +export PROJECT_VERSION="$sha1" +export PROJECT_SRC_PATH="$topdir"/ +echo "Running BlackDuck (SRC) on $name" +echo "CONFIG:" +echo " NAME: ${PROJECT_NAME}" +echo " VERSION: ${PROJECT_VERSION}" +echo " SRC_PATH: ${PROJECT_SRC_PATH}" + +# clone BlackDuck +[[ -d /tmp/blackduck ]] && rm -rf /tmp/blackduck +sudo -u swx-jenkins git clone -c core.sshCommand="ssh -l svc-nbu-swx-media -i ~/.ssh/id_ed25519_svc-nbu-swx-media_gerrit" -b master --single-branch --depth=1 ssh://git-nbu.nvidia.com:12023/DevOps/Tools/blackduck /tmp/blackduck +cd /tmp/blackduck + +# disable check errors +set +e +timeout 3600 ./run_bd_scan.sh signature +exit_code=$? +# enable back +set -e + +# copy run log to a place that jenkins job will archive it +REPORT_NAME="BlackDuck_source_${PROJECT_NAME}_${PROJECT_VERSION}" +cat "log/${PROJECT_NAME}_${PROJECT_VERSION}"*.log > "${WORKSPACE}/logs/${REPORT_NAME}.log" || true +cat "log/${PROJECT_NAME}_${PROJECT_VERSION}"*.log || true + +if [ "$exit_code" == "0" ]; then + cp -v /tmp/blackduck/report/*.pdf "${WORKSPACE}/logs/${REPORT_NAME}.pdf" +fi + +exit $exit_code diff --git a/.ci/do_release.sh b/.ci/do_release.sh new file mode 100755 index 0000000000..82d056c625 --- /dev/null +++ b/.ci/do_release.sh @@ -0,0 +1,92 @@ +#!/bin/bash -Exel + +echo "**********************************" +echo "Starting do_release.sh script..." +echo "**********************************" + +set -o pipefail + +print_help() { + set +xv + echo -e "\n\n" + echo "--------------------------------------------------" + echo "Usage: release_folder= release_tag= [revision=] [do_release=] $0" + echo " Where release folder is a path to NFS folder to copy the package into" + echo " Where release tag is a git tag to release (must be already tagged in the git repo)" + echo " Where revision is a number postfix to add the to package indicating which version of the tag it is - OPTIONAL, default value 1" + echo " Where do_release is a boolean value indicating if the script will copy the created package into the release folder location - OPTIONAL, default value false" + exit 1 +} + +if [ -z "${release_folder}" ]; then + echo "ERROR: 'release_folder' was not set." + print_help +fi + +if [ ! -e "${release_folder}" ] || [ ! -d "${release_folder}" ]; then + echo "ERROR: [${release_folder}] directory doesn't exist." + print_help +fi + +if [ -z "${release_tag}" ]; then + echo "ERROR: 'release_tag' was not set." + print_help +fi + +if [ -z "${revision}" ]; then + echo "WARN: 'revision' was not set, defaulting to 1" + revision=1 +fi + +if [ -z "${do_release}" ]; then + echo "WARN: 'do_release' was not set, defaulting to false (package will not be release)" + do_release=false +fi + +MAJOR_VERSION=$(grep -e "define(\[prj_ver_major\]" configure.ac | awk '{ printf $2 };' | sed 's/)//g') +MINOR_VERSION=$(grep -e "define(\[prj_ver_minor\]" configure.ac | awk '{ printf $2 };' | sed 's/)//g') +REVISION_VERSION=$(grep -e "define(\[prj_ver_revision\]" configure.ac | awk '{ printf $2 };' | sed 's/)//g') +configure_ac_version="${MAJOR_VERSION}.${MINOR_VERSION}.${REVISION_VERSION}" +pkg_folder=pkg/packages +pkg_name="libvma-${release_tag}-${revision}.src.rpm" +tarball_name="libvma-${release_tag}.tar.gz" +DST_DIR=${release_folder}/vma_v_${release_tag}-0/src +echo "FULL_VERSION from configure.ac: [${configure_ac_version}]" + +# Creating both tarball and src.rpm +env PRJ_RELEASE="${revision}" contrib/build_pkg.sh -s -t + +if [[ "${release_tag}" != "${configure_ac_version}" ]]; then + echo "ERROR: FULL_VERSION: ${configure_ac_version} from configure.ac doesn't match tag: ${release_tag} provided! Exit" + exit 1 +fi + +if [ "${do_release}" = true ] ; then + echo "do_release is set to true, will release package into ${DST_DIR}" + + if [ ! -d "${pkg_folder}" ]; then + echo "ERROR: [${pkg_folder}] directory doesn't exist. Exit" + exit 1 + fi + + if [[ -e "${DST_DIR}/${pkg_name}" || -e "${DST_DIR}/${tarball_name}" ]]; then + echo "ERROR: [${DST_DIR}/${pkg_name}] or [${DST_DIR}/${tarball_name}] file already exist. Exit" + exit 1 + fi + files_dir=$(pwd) + pushd "${release_folder}" || { echo "ERROR: Failed to pushd to ${release_folder}. Exit" ; exit 1; } + mkdir -p "$DST_DIR" + cp -v "${files_dir}/${pkg_folder}/${pkg_name}" "$DST_DIR" + cp -v "${files_dir}/${pkg_folder}/${tarball_name}" "$DST_DIR" + ln -s "${DST_DIR}/${pkg_name}" "${release_folder}/source_rpms/${pkg_name}" + popd || { echo "ERROR: Failed to popd from ${release_folder}. Exit" ; exit 1; } + + echo "INFO: Release found at $DST_DIR" +else + echo "INFO: do_release is set to false, skipping package release." +fi + +set +x +echo "**********************************" +echo "Finished do_release.sh script..." +echo "**********************************" diff --git a/.ci/dockerfiles/Dockerfile.fedora-rawhide b/.ci/dockerfiles/Dockerfile.fedora-rawhide new file mode 100644 index 0000000000..c8fe1d9fa9 --- /dev/null +++ b/.ci/dockerfiles/Dockerfile.fedora-rawhide @@ -0,0 +1,9 @@ +FROM docker.io/library/fedora:rawhide + +RUN dnf install --allowerasing -y procps-ng \ + bsdtar git-core autoconf automake \ + libtool gcc gcc-c++ make pkgconf-pkg-config \ + rdma-core-devel libnl3-devel gzip\ + && ln -sf /usr/bin/bsdtar /usr/local/bin/tar \ + && dnf clean all \ + && rm -rf /var/cache/dnf diff --git a/.ci/dockerfiles/Dockerfile.rhel8.6 b/.ci/dockerfiles/Dockerfile.rhel8.6 new file mode 100644 index 0000000000..9484fdb88e --- /dev/null +++ b/.ci/dockerfiles/Dockerfile.rhel8.6 @@ -0,0 +1,34 @@ +ARG HARBOR_URL=nbu-harbor.gtm.nvidia.com +ARG ARCH=x86_64 +FROM $HARBOR_URL/hpcx/x86_64/rhel8.6/core:latest as core +ARG WEBREPO_URL=webrepo.gtm.nvidia.com + +RUN sed -i "s/webrepo/${WEBREPO_URL}/" /etc/yum.repos.d/* && \ + sed -i 's/mirrorlist/#mirrorlist/;s!#baseurl=http://mirror.centos.org!baseurl=http://vault.centos.org!' /etc/yum.repos.d/* && \ + echo "[mlnx-opt]" > /etc/yum.repos.d/mlnx-opt.repo && \ + echo "name=RHEL 8.6 mirror" >> /etc/yum.repos.d/mlnx-opt.repo && \ + echo "baseurl=http://${WEBREPO_URL}/RH/optional/8.6/x86_64/" >> /etc/yum.repos.d/mlnx-opt.repo && \ + echo "enabled=1" >> /etc/yum.repos.d/mlnx-opt.repo && \ + echo "gpgcheck=0" >> /etc/yum.repos.d/mlnx-opt.repo && \ + yum makecache + +RUN yum install --allowerasing -y \ + java-11-openjdk jq git && \ + yum clean all && \ + rm -rf /var/cache/yum + +FROM core as bduck +ARG _UID=6213 +ARG _GID=101 +ARG _LOGIN=swx-jenkins +ARG _HOME=/var/home/$_LOGIN +RUN echo "${_LOGIN} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ + echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ + mkdir -p ${_HOME} && \ + groupadd -f -g "$_GID" "$_LOGIN" && \ + useradd -u "$_UID" -g "$_GID" -s /bin/bash -m -d ${_HOME} "${_LOGIN}" && \ + chown -R ${_LOGIN} ${_HOME} && \ + yum install --allowerasing -y \ + jq git java-11-openjdk sudo && \ + yum clean all && \ + rm -rf /var/cache/yum diff --git a/.ci/dockerfiles/Dockerfile.rhel8.6.release b/.ci/dockerfiles/Dockerfile.rhel8.6.release new file mode 100644 index 0000000000..61e4411ba4 --- /dev/null +++ b/.ci/dockerfiles/Dockerfile.rhel8.6.release @@ -0,0 +1,29 @@ +ARG HARBOR_URL=nbu-harbor.gtm.nvidia.com +FROM $HARBOR_URL/hpcx/x86_64/rhel8.6/core:latest +ARG WEBREPO_URL=webrepo.gtm.nvidia.com +ARG _UID=6213 +ARG _GID=101 +ARG _LOGIN=swx-jenkins +ARG _HOME=/var/home/$_LOGIN + +RUN sed -i "s#http://webrepo#http://${WEBREPO_URL}#" /etc/yum.repos.d/* && \ + sed -i 's/mirrorlist/#mirrorlist/;s!#baseurl=http://mirror.centos.org!baseurl=http://vault.centos.org!' /etc/yum.repos.d/* && \ + echo "[mlnx-opt]" > /etc/yum.repos.d/mlnx-opt.repo && \ + echo "name=RHEL 8.6 mirror" >> /etc/yum.repos.d/mlnx-opt.repo && \ + echo "baseurl=http://${WEBREPO_URL}/RH/optional/8.6/x86_64/" >> /etc/yum.repos.d/mlnx-opt.repo && \ + echo "enabled=1" >> /etc/yum.repos.d/mlnx-opt.repo && \ + echo "gpgcheck=0" >> /etc/yum.repos.d/mlnx-opt.repo && \ + yum makecache + +RUN echo "${_LOGIN} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ + echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ + mkdir -p ${_HOME} && \ + groupadd -f -g "$_GID" "$_LOGIN" && \ + useradd -u "$_UID" -g "$_GID" -s /bin/bash -m -d ${_HOME} "${_LOGIN}" && \ + chown -R ${_LOGIN} ${_HOME} + +RUN yum install --allowerasing -y \ + git autoconf automake libtool gcc \ + sudo gcc-c++ libibverbs-devel rdma-core \ + librdmacm unzip patch wget make \ + libnl3-devel rpm-build diff --git a/.ci/dockerfiles/Dockerfile.rhel9.4 b/.ci/dockerfiles/Dockerfile.rhel9.4 new file mode 100644 index 0000000000..7e6fb95303 --- /dev/null +++ b/.ci/dockerfiles/Dockerfile.rhel9.4 @@ -0,0 +1,37 @@ +ARG HARBOR_URL=nbu-harbor.gtm.nvidia.com +ARG ARCH=x86_64 +FROM $HARBOR_URL/swx-infra/media/$ARCH/base/rhel:9.4 +ARG WEBREPO_URL=webrepo.gtm.nvidia.com +ARG ARCH +ARG _UID=6213 +ARG _GID=101 +ARG _LOGIN=swx-jenkins +ARG _HOME=/var/home/$_LOGIN + +RUN sed -i "s#http://webrepo#http://${WEBREPO_URL}#" /etc/yum.repos.d/* && \ + sed -i 's/mirrorlist/#mirrorlist/;s!#baseurl=http://mirror.centos.org!baseurl=http://vault.centos.org!' /etc/yum.repos.d/* && \ + echo "[mlnx-9.4-BaseOS]" > /etc/yum.repos.d/mlnx-9.4-BaseOS.repo && \ + echo "name=RHEL 9.4 mirror BaseOS" >> /etc/yum.repos.d/mlnx-9.4-BaseOS.repo && \ + echo "baseurl=http://${WEBREPO_URL}/RH/9.4/$ARCH/BaseOS/" >> /etc/yum.repos.d/mlnx-9.4-BaseOS.repo && \ + echo "enabled=1" >> /etc/yum.repos.d/mlnx-9.4-BaseOS.repo && \ + echo "gpgcheck=0" >> /etc/yum.repos.d/mlnx-9.4-BaseOS.repo && \ + echo "[mlnx-9.4-AppStream]" > /etc/yum.repos.d/mlnx-9.4-AppStream.repo && \ + echo "name=RHEL 9.4 mirror AppStream" >> /etc/yum.repos.d/mlnx-9.4-AppStream.repo && \ + echo "baseurl=http://${WEBREPO_URL}/RH/9.4/$ARCH/AppStream/" >> /etc/yum.repos.d/mlnx-9.4-AppStream.repo && \ + echo "enabled=1" >> /etc/yum.repos.d/mlnx-9.4-AppStream.repo && \ + echo "gpgcheck=0" >> /etc/yum.repos.d/mlnx-9.4-AppStream.repo && \ + yum makecache + +RUN echo "${_LOGIN} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ + echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ + mkdir -p ${_HOME} && \ + groupadd -f -g "$_GID" "$_LOGIN" && \ + useradd -u "$_UID" -g "$_GID" -s /bin/bash -m -d ${_HOME} "${_LOGIN}" && \ + chown -R ${_LOGIN} ${_HOME} + +RUN dnf install --allowerasing -y \ + git autoconf automake libtool gcc \ + sudo gcc-c++ libibverbs-devel rdma-core \ + librdmacm unzip patch wget make \ + libnl3-devel rpm-build && \ + dnf clean all && rm -rf /var/cache/dnf/* diff --git a/.ci/dockerfiles/Dockerfile.rhel9.6 b/.ci/dockerfiles/Dockerfile.rhel9.6 new file mode 100644 index 0000000000..71f9393965 --- /dev/null +++ b/.ci/dockerfiles/Dockerfile.rhel9.6 @@ -0,0 +1,21 @@ +ARG HARBOR_URL=nbu-harbor.gtm.nvidia.com +ARG ARCH=x86_64 +ARG OS_VERSION=9.6 + +FROM $HARBOR_URL/swx-infra/media/$ARCH/base/rhel:$OS_VERSION +ARG _UID=6213 +ARG _GID=101 +ARG _LOGIN=swx-jenkins +ARG _HOME=/var/home/$_LOGIN +RUN echo "${_LOGIN} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ + echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ + mkdir -p ${_HOME} && \ + groupadd -f -g "$_GID" "$_LOGIN" && \ + useradd -u "$_UID" -g "$_GID" -s /bin/bash -m -d ${_HOME} "${_LOGIN}" && \ + chown -R ${_LOGIN} ${_HOME} + +RUN dnf install --allowerasing -y json-c-devel curl \ + autoconf automake make libtool \ + gcc-c++ diffutils rpm-build \ + && dnf clean all \ + && rm -rf /var/cache/dnf diff --git a/.ci/fedora_matrix_job.yaml b/.ci/fedora_matrix_job.yaml new file mode 100644 index 0000000000..c5a4b8f591 --- /dev/null +++ b/.ci/fedora_matrix_job.yaml @@ -0,0 +1,37 @@ +--- +job: LIBVMA + +timeout_minutes: 30 + +registry_host: nbu-harbor.gtm.nvidia.com +registry_auth: swx-infra_harbor_credentials +registry_path: /swx-infra/media + +kubernetes: + privileged: true + cloud: il-ipp-blossom-prod + namespace: swx-media + nodeSelector: 'beta.kubernetes.io/os=linux' + limits: '{memory: 8Gi, cpu: 8000m}' + requests: '{memory: 8Gi, cpu: 8000m}' + arch_table: + x86_64: + nodeSelector: 'kubernetes.io/arch=amd64' + jnlpImage: '${registry_host}/toolbox/c3po-jnlp:latest' + +runs_on_dockers: + - {name: 'fedora-rawhide', file: '.ci/dockerfiles/Dockerfile.fedora-rawhide', uri: 'vma/$arch/$name', arch: 'x86_64', tag: '20260420', build_args: '--no-cache --pull'} + +matrix: + axes: + flags: + - default + +steps: + - name: Build + run: | + env WORKSPACE=$PWD TARGET=${flags} jenkins_test_build=yes ./contrib/test_jenkins.sh + onfail: | + ./.ci/artifacts.sh + archiveArtifacts-onfail: | + jenkins/**/arch-*.tar.gz diff --git a/.ci/matrix_job.yaml b/.ci/matrix_job.yaml index 74911e972e..13578059c0 100644 --- a/.ci/matrix_job.yaml +++ b/.ci/matrix_job.yaml @@ -3,16 +3,24 @@ job: LIBVMA step_allow_single_selector: false -registry_host: harbor.mellanox.com -registry_auth: swx-storage +registry_host: nbu-harbor.gtm.nvidia.com +registry_auth: swx-infra_harbor_credentials +registry_path: /swx-infra/media kubernetes: - privileged: false - cloud: swx-k8s-spray + privileged: true + cloud: il-ipp-blossom-prod + namespace: swx-media nodeSelector: 'beta.kubernetes.io/os=linux' - limits: '{memory: 8Gi, cpu: 8000m}' requests: '{memory: 8Gi, cpu: 8000m}' + arch_table: + x86_64: + nodeSelector: 'kubernetes.io/arch=amd64' + jnlpImage: '${registry_host}/toolbox/c3po-jnlp:latest' + aarch64: + nodeSelector: 'kubernetes.io/arch=arm64' + jnlpImage: '${registry_host}/toolbox/c3po-jnlp:latest' volumes: - {mountPath: /hpc/local/bin, hostPath: /hpc/local/bin} @@ -21,43 +29,41 @@ volumes: - {mountPath: /auto/sw_tools/Commercial, hostPath: /auto/sw_tools/Commercial} - {mountPath: /hpc/local/commercial, hostPath: /hpc/local/commercial} - {mountPath: /hpc/local/etc/modulefiles, hostPath: /hpc/local/etc/modulefiles} + - {mountPath: /var/home/swx-jenkins, hostPath: /labhome/swx-jenkins} + +credentials: + - {credentialsId: 'media_coverity_credentials', usernameVariable: 'VMA_COV_USER', passwordVariable: 'VMA_COV_PASSWORD'} + - {credentialsId: 'mellanox_github_credentials', usernameVariable: 'MELLANOX_GH_USER', passwordVariable: 'MELLANOX_GH_TOKEN'} + - {credentialsId: 'swx-jenkins2-svc-gerrit-ssh-key', keyFileVariable: 'GERRIT_SSH_KEY', type: 'sshUserPrivateKey'} + - {credentialsId: 'blackduck_api_token', type: 'string', variable: 'BLACKDUCK_API_TOKEN'} env: build_dockers: false runs_on_dockers: -# mofed - - {name: 'rhel8.3-mofed-x86_64', url: 'harbor.mellanox.com/hpcx/x86_64/rhel8.3/builder:mofed-5.2-0.5.3.0', category: 'base', arch: 'x86_64'} - - {name: 'sl15sp2-mofed-x86_64', url: 'harbor.mellanox.com/swx-infra/x86_64/sles15sp2/builder:mofed-5.2-2.2.0.0', category: 'base', arch: 'x86_64'} - - {name: 'fc31-mofed-x86_64', url: 'harbor.mellanox.com/swx-infra/x86_64/fedora31/builder:mofed-5.1-1.0.7.0', category: 'base', arch: 'x86_64'} - - {name: 'ub20.04-mofed-x86_64', url: 'harbor.mellanox.com/swx-infra/x86_64/ubuntu20.04/builder:mofed-5.2-2.2.0.0', category: 'base', arch: 'x86_64'} - - {name: 'ub22.04-mofed-x86_64', url: 'harbor.mellanox.com/hpcx/x86_64/ubuntu22.04/builder:mofed-5.7-0.1.1.0', category: 'base', arch: 'x86_64'} - -# - {name: 'ub20.04-mofed-aarch64', url: 'harbor.mellanox.com/swx-infra/aarch64/ubuntu20.04/builder:mofed-5.2-1.0.4.0', category: 'base', arch: 'aarch64'} -# - {name: 'ub20.04-mofed-ppc64le', url: 'harbor.mellanox.com/swx-infra/ppc64le/ubuntu20.04/builder:mofed-5.2-1.0.4.0', category: 'base', arch: 'ppc64le'} -# inbox - - {name: 'ub21.10-inbox-x86_64', url: 'harbor.mellanox.com/hpcx/x86_64/ubuntu21.10/builder:inbox', category: 'base', arch: 'x86_64'} - - {name: 'rhel8.3-inbox-x86_64', url: 'harbor.mellanox.com/hpcx/x86_64/rhel8.3/builder:inbox', category: 'base', arch: 'x86_64'} - - {name: 'rhel8.3-inbox-aarch64', url: 'harbor.mellanox.com/hpcx/aarch64/rhel8.3/builder:inbox', category: 'base', arch: 'aarch64'} -# legacy - - {name: 'rhel7.6-mofed-x86_64', url: 'harbor.mellanox.com/hpcx/x86_64/rhel7.6/builder:mofed-5.1-0.6.6.0', category: 'base', arch: 'x86_64'} - - {name: 'rhel7.6-inbox-x86_64', url: 'harbor.mellanox.com/hpcx/x86_64/rhel7.6/builder:inbox', category: 'base', arch: 'x86_64'} +# doca-host + - {name: 'rhel9.6-x86_64', file: '.ci/dockerfiles/Dockerfile.rhel9.6', uri: 'vma/$arch/$name/build', category: 'base', arch: 'x86_64', tag: '20261201', build_args: '--build-arg ARCH=x86_64 --no-cache'} + - {name: 'rhel9.0-x86_64', url: '${registry_host}/hpcx/x86_64/rhel9.0/base', category: 'base', arch: 'x86_64'} + - {name: 'rhel9.4-aarch64', file: '.ci/dockerfiles/Dockerfile.rhel9.4', category: 'base', arch: 'aarch64', tag: '20250203', uri: 'vma/$arch/$name/build', build_args: '--build-arg ARCH=aarch64 --no-cache'} + - {name: 'ub24.04-x86_64', url: '${registry_host}/hpcx/x86_64/ubuntu24.04/base', category: 'base', arch: 'x86_64'} + - {name: 'ub24.04-aarch64', url: '${registry_host}/hpcx/aarch64/ubuntu24.04/base', category: 'base', arch: 'aarch64'} + - {name: 'sl15sp4-x86_64', url: '${registry_host}/hpcx/x86_64/sles15sp4/base', category: 'base', arch: 'x86_64'} + - {name: 'rhel8.6-inbox-x86_64', url: '${registry_host}/hpcx/x86_64/rhel8.6/builder:inbox', category: 'base', arch: 'x86_64'} + - {name: 'ub22.04-x86_64', url: '${registry_host}/hpcx/x86_64/ubuntu22.04/base', category: 'base', arch: 'x86_64'} + - {name: 'ub22.04-aarch64', url: '${registry_host}/hpcx/aarch64/ubuntu22.04/base', category: 'base', arch: 'aarch64'} # tool - - {name: 'toolbox', url: 'harbor.mellanox.com/hpcx/x86_64/rhel8.3/builder:inbox', category: 'tool', arch: 'x86_64'} - - {name: 'blackduck', url: 'harbor.mellanox.com/toolbox/ngci-centos:7.9.2009.2', category: 'tool', arch: 'x86_64'} - - {name: 'header-check', url: 'harbor.mellanox.com/toolbox/header_check:0.0.14', category: 'tool', arch: 'x86_64', tag: '0.0.14'} + - {name: 'toolbox', url: '${registry_host}/hpcx/x86_64/rhel8.6/builder:inbox', category: 'tool', arch: 'x86_64'} + - {name: 'blackduck', file: '.ci/dockerfiles/Dockerfile.rhel8.6', category: 'tool', arch: 'x86_64', tag: '20250630', uri: 'vma/$arch/$name/bduck', build_args: '--no-cache --target bduck'} + - {name: 'header-check', url: '${registry_host}/toolbox/header_check:0.0.58', category: 'tool', arch: 'x86_64', tag: '0.0.58'} + - {name: 'secret-scan', url: '${registry_host}/swx-storage/tools/secret_scan:devops-stable', arch: 'x86_64', tag: 'devops-stable', category: 'tool'} runs_on_agents: - - {nodeLabel: 'r-aa-fatty09', category: 'base'} - - {nodeLabel: 'r-aa-fatty22-005', category: 'azure'} - - {nodeLabel: 'r-aa-fatty22-006', category: 'azure'} + - {nodeLabel: 'beni09', category: 'base'} matrix: axes: flags: - default - - extra - - dpcp arch: - x86_64 - aarch64 @@ -84,14 +90,45 @@ steps: - name: Copyrights enable: ${do_copyrights} - run: env WORKSPACE=$PWD ./contrib/jenkins_tests/copyrights.sh + credentialsId: 'mellanox_github_credentials' + run: env WORKSPACE=$PWD GITHUB_TOKEN=$MELLANOX_GH_TOKEN ./contrib/jenkins_tests/copyrights.sh containerSelector: - - "{name: 'header-check', category: 'tool', variant: 1}" + - "{name: 'header-check', category: 'tool'}" agentSelector: - "{nodeLabel: 'skip-agent'}" archiveArtifacts: '*.log,*.tar.gz' parallel: false + - name: Secret Scan + credentialsId: 'mellanox_github_credentials' + enable: ${do_secretscan} + containerSelector: + - "{name: 'secret-scan', category: 'tool'}" + agentSelector: + - "{nodeLabel: 'skip-agent'}" + run: | + env GITHUB_TOKEN=$MELLANOX_GH_TOKEN /opt/nvidia/secret_scan.py --path $WORKSPACE --git-repo $WORKSPACE --report-file secret_scan.html + archiveArtifacts: '*.html' + parallel: false + + - name: Install Doca-host + containerSelector: + - "{category: 'base'}" + agentSelector: + - "{nodeLabel: 'skip-agent'}" + run: | + echo "Installing DOCA: ${DOCA_VERSION} ..." + .ci/scripts/doca_install.sh + + - name: Install Doca-host on Tools + run: | + echo "Installing DOCA: ${DOCA_VERSION} ..." + .ci/scripts/doca_install.sh + containerSelector: + - "{name: 'style', category: 'tool'}" + agentSelector: + - "{nodeLabel: 'skip-agent'}" + - name: Autogen run: | ./autogen.sh -s @@ -101,14 +138,12 @@ steps: enable: ${do_build} run: | [ "x${do_build}" == "xtrue" ] && action=yes || action=no - env WORKSPACE=$PWD TARGET=${flags} jenkins_test_build=${action} ./contrib/test_jenkins.sh + env WORKSPACE=$PWD TARGET=${flags} jenkins_test_build=${action} ./contrib/test_jenkins.sh parallel: false onfail: | ./.ci/artifacts.sh archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz - archiveTap-onfail: | - jenkins/**/*.tap - name: Service enable: ${do_service} @@ -124,8 +159,6 @@ steps: ./.ci/artifacts.sh archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz - archiveTap-onfail: | - jenkins/**/*.tap - name: Package enable: ${do_package} @@ -137,15 +170,13 @@ steps: ./.ci/artifacts.sh archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz - archiveTap-onfail: | - jenkins/**/*.tap - name: Style enable: ${do_style} containerSelector: - "{name: 'skip-container'}" agentSelector: - - "{nodeLabel: 'r-aa-fatty09'}" + - "{nodeLabel: 'beni09'}" run: | [ "x${do_style}" == "xtrue" ] && action=yes || action=no env WORKSPACE=$PWD TARGET=${flags} jenkins_test_style=${action} ./contrib/test_jenkins.sh @@ -154,8 +185,6 @@ steps: ./.ci/artifacts.sh archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz - archiveTap-onfail: | - jenkins/**/*.tap - name: Compiler enable: ${do_compiler} @@ -171,11 +200,10 @@ steps: ./.ci/artifacts.sh archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz - archiveTap-onfail: | - jenkins/**/*.tap - name: Coverity enable: ${do_coverity} + credentialsId: 'media_coverity_credentials' containerSelector: - "{name: 'toolbox', category: 'tool'}" agentSelector: @@ -189,15 +217,13 @@ steps: archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz, jenkins/**/output/errors/**/*.html - archiveTap-onfail: | - jenkins/**/*.tap - name: Cppcheck enable: ${do_cppcheck} containerSelector: - "{name: 'skip-container'}" agentSelector: - - "{nodeLabel: 'r-aa-fatty09', variant:1}" + - "{nodeLabel: 'beni09', variant:1}" run: | [ "x${do_cppcheck}" == "xtrue" ] && action=yes || action=no env WORKSPACE=$PWD TARGET=${flags} jenkins_test_cppcheck=${action} ./contrib/test_jenkins.sh @@ -206,15 +232,13 @@ steps: ./.ci/artifacts.sh archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz - archiveTap-onfail: | - jenkins/**/*.tap - name: Csbuild enable: ${do_csbuild} containerSelector: - "{name: 'skip-container'}" agentSelector: - - "{nodeLabel: 'r-aa-fatty09', variant:1}" + - "{nodeLabel: 'beni09', variant:1}" run: | [ "x${do_csbuild}" == "xtrue" ] && action=yes || action=no env WORKSPACE=$PWD TARGET=${flags} jenkins_test_csbuild=${action} ./contrib/test_jenkins.sh @@ -223,15 +247,13 @@ steps: ./.ci/artifacts.sh archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz - archiveTap-onfail: | - jenkins/**/*.tap - name: Test enable: ${do_test} containerSelector: - "{name: 'skip-container'}" agentSelector: - - "{nodeLabel: 'r-aa-fatty09', variant:1}" + - "{nodeLabel: 'beni09', variant:1}" run: | [ "x${do_test}" == "xtrue" ] && action=yes || action=no env WORKSPACE=$PWD TARGET=${flags} jenkins_test_run=${action} ./contrib/test_jenkins.sh @@ -240,15 +262,13 @@ steps: ./.ci/artifacts.sh archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz - archiveTap-onfail: | - jenkins/**/*.tap - name: Gtest enable: ${do_gtest} containerSelector: - "{name: 'skip-container'}" agentSelector: - - "{nodeLabel: 'r-aa-fatty09', variant:1}" + - "{nodeLabel: 'beni09', variant:1}" run: | [ "x${do_gtest}" == "xtrue" ] && action=yes || action=no env WORKSPACE=$PWD TARGET=${flags} jenkins_test_gtest=${action} ./contrib/test_jenkins.sh @@ -257,8 +277,6 @@ steps: ./.ci/artifacts.sh archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz - archiveTap-onfail: | - jenkins/**/*.tap archiveJunit-onfail: | jenkins/**/*.xml @@ -267,7 +285,7 @@ steps: containerSelector: - "{name: 'skip-container'}" agentSelector: - - "{nodeLabel: 'r-aa-fatty09', variant:1}" + - "{nodeLabel: 'beni09', variant:1}" run: | [ "x${do_valgrind}" == "xtrue" ] && action=yes || action=no env WORKSPACE=$PWD TARGET=${flags} jenkins_test_vg=${action} ./contrib/test_jenkins.sh @@ -277,8 +295,6 @@ steps: archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz, jenkins/**/vg/*valgrind*.log - archiveTap-onfail: | - jenkins/**/*.tap - name: Commit enable: ${do_commit} @@ -294,8 +310,6 @@ steps: ./.ci/artifacts.sh archiveArtifacts-onfail: | jenkins/**/arch-*.tar.gz - archiveTap-onfail: | - jenkins/**/*.tap - name: Artifacts enable: ${do_artifact} @@ -304,8 +318,6 @@ steps: parallel: false archiveArtifacts: | jenkins/**/arch-*.tar.gz - archiveTap: | - jenkins/**/*.tap archiveJunit: | jenkins/**/*.xml @@ -315,18 +327,15 @@ steps: - "{name: 'blackduck', category:'tool', variant:1}" agentSelector: - "{nodeLabel: 'skip-agent'}" - shell: action - module: ngci - run: NGCIBlackDuckScan - args: - projectName: ${jjb_proj} - projectVersion: ${ghprbPullId} - projectSrcPath: "src" - attachArtifact: true - reportName: "BlackDuck report" - scanMode: "source" - env: - SPRING_APPLICATION_JSON: '{"blackduck.url":"https://blackduck.mellanox.com/","blackduck.api.token":"ODMwOWYwMzEtODA2ZC00MzBjLWI1ZDEtNmFiMjBkYzQzMzkwOjNmNjExN2M1LWE2ZmEtNDZlYS1hZjRiLTZlNDgwNjAwOTVjNw=="}' + run: | + # WA for possible CI-Demo bug: HPCINFRA-1614 + if ${do_blackduck} ; then + .ci/blackduck_source.sh + fi + archiveArtifacts: 'logs/' + credentialsId: + - "swx-jenkins2-svc-gerrit-ssh-key" + - "blackduck_api_token" pipeline_start: run: | @@ -341,4 +350,4 @@ failFast: false taskName: '${flags}/${name}/${axis_index}' -timeout_minutes: 120 +timeout_minutes: 150 diff --git a/.ci/pipeline/release_jjb.yaml b/.ci/pipeline/release_jjb.yaml new file mode 100644 index 0000000000..f5e30dcf59 --- /dev/null +++ b/.ci/pipeline/release_jjb.yaml @@ -0,0 +1,79 @@ +- job-template: + name: "{jjb_proj}" + project-type: pipeline + folder: "{jjb_folder}" + properties: + - github: + url: "https://github.com/Mellanox/libvma" + - build-discarder: + days-to-keep: 50 + num-to-keep: 20 + - inject: + keep-system-variables: true + properties-content: | + jjb_proj={jjb_proj} + description: Do NOT edit this job through the Web GUI ! + concurrent: false + parameters: + - string: + name: "release_tag" + default: "" + description: "Tag to release" + - string: + name: sha1 + default: '$release_tag' + description: 'commit to use, defaults to the commit tag provided under release_tag' + - string: + name: "revision" + default: "1" + description: "Release revision" + - string: + name: "release_folder" + default: "{jjb_release_folder}" + description: "Folder to release packages into" + - bool: + name: "do_release" + default: true + description: "Release build packages into the release folder, set to false for debugging" + - bool: + name: "do_antivirus" + default: true + description: "Run Antivirus scan." + - bool: + name: "do_blackduck" + default: true + description: "Run BlackDuck." + - string: + name: "notification_email" + default: "{jjb_release_email}" + description: "Email to send report to upon success/failure" + - string: + name: "conf_file" + default: ".ci/pipeline/release_matrix_job.yaml" + description: "job config file. Do not change it" + - bool: + name: "do_dr_build" + default: false + description: "Build DR weekly" + pipeline-scm: + scm: + - git: + url: "{jjb_git}" + credentials-id: 'svc-nbu-swx-media_ssh_key' + branches: ['$sha1'] + shallow-clone: false + refspec: "+refs/pull/*:refs/remotes/origin/pr/* +refs/tags/*:refs/remotes/origin/tags/*" + browser: githubweb + browser-url: "{jjb_git}" + script-path: ".ci/Jenkinsfile" +- project: + name: libvma + jjb_email: 'nwolfer@nvidia.com' + jjb_proj: 'LibVMA-release' + jjb_git: 'git@github.com:Mellanox/libvma.git' + jjb_owner: 'Nir Wolfer' + jjb_folder: 'libvma' + jjb_release_folder: '/auto/mswg/release/vma' + jjb_release_email: '55ae26f6.NVIDIA.onmicrosoft.com@amer.teams.ms' + jobs: + - "{jjb_proj}" diff --git a/.ci/pipeline/release_matrix_job.yaml b/.ci/pipeline/release_matrix_job.yaml new file mode 100644 index 0000000000..45d5f23272 --- /dev/null +++ b/.ci/pipeline/release_matrix_job.yaml @@ -0,0 +1,108 @@ +--- +job: LibVMA-release +registry_host: nbu-harbor.gtm.nvidia.com +registry_auth: swx-infra_harbor_credentials +registry_path: /swx-infra/media/libvma + +kubernetes: + privileged: true + cloud: il-ipp-blossom-prod + nodeSelector: 'beta.kubernetes.io/os=linux' + namespace: swx-media + limits: '{memory: 8Gi, cpu: 7000m}' + requests: '{memory: 8Gi, cpu: 7000m}' + arch_table: + x86_64: + nodeSelector: 'kubernetes.io/arch=amd64' + jnlpImage: 'nbu-harbor.gtm.nvidia.com/toolbox/c3po-jnlp:latest' + +credentials: + - {credentialsId: 'blackduck_api_token', type: 'string', variable: 'BLACKDUCK_API_TOKEN'} + +env: + MAIL_FROM: jenkins@nvidia.com + +volumes: + # Default release location + - {mountPath: /auto/mswg/release/vma, hostPath: /auto/mswg/release/vma} + # User profile for release + - {mountPath: /var/home/swx-jenkins, hostPath: /labhome/swx-jenkins} + # for Antivirus + - {mountPath: /auto/BACKUP/logs_of_LOGS, hostPath: /auto/BACKUP/logs_of_LOGS} + - {mountPath: /auto/GLIT/SCRIPTS/HELPERS, hostPath: /auto/GLIT/SCRIPTS/HELPERS} + +empty_volumes: + - {mountPath: /tmp/source_rpms, memory: true} + +runs_on_dockers: + - { + file: '.ci/dockerfiles/Dockerfile.rhel8.6.release', + name: 'rhel8.6', + uri: '$arch/$name/release', + build_args: '--no-cache', + arch: 'x86_64', + tag: '20250128', + runAsUser: '6213', + runAsGroup: '101' + } + - { + name: 'blackduck', + file: '.ci/dockerfiles/Dockerfile.rhel8.6', + category: 'tool', + arch: 'x86_64', + tag: '20250630', + uri: 'vma/$arch/$name/bduck', + build_args: '--no-cache --target bduck' + } + +steps: + - name: Release + containerSelector: + - "{name: 'rhel8.6', variant:1}" + run: | + if ${do_dr_build}; then + git checkout tags/${release_tag} + fi + .ci/do_release.sh + archiveArtifacts: pkg/build_pkg.log,pkg/packages/*.rpm + + - name: Antivirus + enable: ${do_antivirus} + run: | + env WORKSPACE=$PWD .ci/antivirus.sh + archiveArtifacts: 'logs/' + + - name: Blackduck + enable: ${do_blackduck} + containerSelector: + - "{name: 'blackduck', category:'tool', variant:1}" + run: | + .ci/blackduck_source.sh + archiveArtifacts: 'logs/' + credentialsId: + - "blackduck_api_token" + +pipeline_start: + shell: action + module: groovy + run: | + if (params.do_dr_build) { + env.release_tag = sh (returnStdout: true, script: "git describe --tags --abbrev=0 2>/dev/null").trim() + } + echo "Starting release process for LibVMA-${release_tag}" + currentBuild.displayName += "-${release_tag}" + +pipeline_stop: + shell: action + module: groovy + run: | + if (!params.notification_email.isEmpty()) { + mail from: "${MAIL_FROM}", + mimeType: 'text/html', + to: "${notification_email}", + subject: "${params.do_dr_build ? 'Weekly DR' : 'Release'} build ended for LibVMA - ${release_tag}", + body: """ +

Tag: ${release_tag}

+

Build url: link

+

Status: ${currentBuild.currentResult}

""" + } diff --git a/.ci/proj_jjb.yaml b/.ci/proj_jjb.yaml index 0228e8bef6..dcd2a1ee01 100644 --- a/.ci/proj_jjb.yaml +++ b/.ci/proj_jjb.yaml @@ -1,9 +1,10 @@ - job-template: name: "{jjb_proj}" project-type: pipeline + folder: libvma properties: - github: - url: "{jjb_git}" + url: "https://github.com/Mellanox/libvma" - build-discarder: days-to-keep: 50 num-to-keep: 20 @@ -30,6 +31,17 @@ name: "DEBUG" default: 0 description: "Enable debug prints and traces, valid values are 0-9." + - string: + name: "DOCA_VERSION" + default: "3.3.0" + description: "DOCA version - see https://developer.nvidia.com/doca-downloads?deployment_platform=Host-Server&deployment_package=DOCA-Host" + - choice: + name: DOCA_BRANCH + choices: + - latest + - stage + - dev + description: "On which DOCA branch to run?" - bool: name: "do_build" default: true @@ -62,6 +74,10 @@ name: "do_coverity" default: true description: "Launch coverity verification." + - bool: + name: "do_coverity_snapshot" + default: false + description: "Submit Coverity Static Analysis as a snapshot (normally it should be checked only for master branch after proper defects review)" - bool: name: "do_test" default: true @@ -84,31 +100,95 @@ description: "Collect artifacts." - bool: name: "do_blackduck" - default: true + default: false description: "Run BlackDuck." - bool: name: "do_copyrights" default: true description: "Check copyrights in source headers" + - bool: + name: "do_secretscan" + default: true + description: "Check for secrets in source code" triggers: - github-pull-request: cron: 'H/5 * * * *' trigger-phrase: '.*\bbot:retest\b.*' - status-context: "Mellanox Lab" + status-context: "{jjb_proj}" + success-status: "[PASS]" + failure-status: "[FAIL]" + error-status: "[FAIL]" + status-add-test-results: true + auth-id: 'svc-nbu-swx-media_GHPRB_ID' + org-list: ["Mellanox"] + white-list: ["swx-jenkins","mellanox-github"] + allow-whitelist-orgs-as-admins: true + cancel-builds-on-update: true + pipeline-scm: + scm: + - git: + url: "{jjb_git}" + credentials-id: 'svc-nbu-swx-media_ssh_key' + branches: ['$sha1'] + shallow-clone: true + depth: 2 + refspec: "+refs/pull/*:refs/remotes/origin/pr/*" + browser: githubweb + browser-url: "{jjb_git}" + script-path: ".ci/Jenkinsfile" + +- job-template: + name: "{jjb_proj}-fedora" + project-type: pipeline + folder: libvma + properties: + - github: + url: "https://github.com/Mellanox/libvma" + - build-discarder: + days-to-keep: 50 + num-to-keep: 20 + - inject: + keep-system-variables: true + properties-content: | + jjb_proj={jjb_proj}-fedora + description: Do NOT edit this job through the Web GUI ! + concurrent: false + parameters: + - string: + name: "sha1" + default: master + description: "Commit to be checked, set by PR" + - bool: + name: "build_dockers" + default: true + description: "Rebuild docker containers. Check this box if .ci/DockerFile* was changed" + - string: + name: "conf_file" + default: ".ci/fedora_matrix_job.yaml" + description: "Regex to select job config file. Do not change it" + - string: + name: "DEBUG" + default: 0 + description: "Enable debug prints and traces, valid values are 0-9." + triggers: + - github-pull-request: + cron: 'H/5 * * * *' + trigger-phrase: '.*\bbot:(?:fedora:)?retest\b.*' + status-context: "{jjb_proj}-fedora" success-status: "[PASS]" failure-status: "[FAIL]" error-status: "[FAIL]" status-add-test-results: true - auth-id: '549927eb-7f38-4a8f-997a-81dd63605782' + auth-id: 'svc-nbu-swx-media_GHPRB_ID' org-list: ["Mellanox"] - white-list: ["swx-jenkins","swx-jenkins2","swx-jenkins3","mellanox-github"] + white-list: ["swx-jenkins","mellanox-github"] allow-whitelist-orgs-as-admins: true cancel-builds-on-update: true pipeline-scm: scm: - git: url: "{jjb_git}" - credentials-id: 'ef94fa95-5480-41ea-863f-6525aace5bc9' + credentials-id: 'svc-nbu-swx-media_ssh_key' branches: ['$sha1'] shallow-clone: true depth: 2 @@ -117,10 +197,11 @@ browser-url: "{jjb_git}" script-path: ".ci/Jenkinsfile" - project: - name: proj_name - jjb_email: 'lennyb@nvidia.com' + name: libvma + jjb_email: 'nwolfer@nvidia.com' jjb_proj: 'LibVMA' - jjb_git: 'https://github.com/Mellanox/libvma' - jjb_owner: 'Lenny Verkhovsky' + jjb_git: 'git@github.com:Mellanox/libvma.git' + jjb_owner: 'Nir Wolfer' jobs: - "{jjb_proj}" + - "{jjb_proj}-fedora" diff --git a/.ci/redmine_jjb.yaml b/.ci/redmine_jjb.yaml new file mode 100644 index 0000000000..3f69061230 --- /dev/null +++ b/.ci/redmine_jjb.yaml @@ -0,0 +1,71 @@ +- job-template: + name: "{jjb_proj}" + project-type: pipeline + folder: libvma + properties: + - github: + url: "https://github.com/Mellanox/libvma" + - build-discarder: + days-to-keep: 30 + num-to-keep: 30 + - inject: + keep-system-variables: true + properties-content: | + jjb_proj={jjb_proj} + description: The job is checking the RM issue. Do NOT edit this job through the Web GUI ! + concurrent: true + parameters: + - string: + name: "git_repository" + default: "ssh://git@github.com/mellanox/libvma" + description: "Git repository path." + - string: + name: "conf_file" + default: ".ci/redmine_matrix_job.yaml" + description: "Regex to select job config file. Do not change it" + - string: + name: "MAIL_TO" + default: "nirni@mellanox.com" + description: "Whitespace-separated list of recipient addresses." + + wrappers: + - workspace-cleanup + - build-user-vars + - timestamps + + triggers: + - github-pull-request: + cron: 'H/5 * * * *' + trigger-phrase: '.*\bbot:(?:rm:)?retest\b.*' + status-context: "{jjb_proj}" + success-status: "[PASS]" + failure-status: "[FAIL]" + error-status: "[FAIL]" + status-add-test-results: true + auth-id: 'svc-nbu-swx-media_GHPRB_ID' + admin-list: ["Mellanox"] + org-list: ["Mellanox"] + white-list: ["Mellanox"] + allow-whitelist-orgs-as-admins: true + cancel-builds-on-update: true + + pipeline-scm: + scm: + - git: + url: "{jjb_git}" + credentials-id: 'svc-nbu-swx-media_ssh_key' + branches: ['$sha1'] + shallow-clone: true + depth: 2 + refspec: "+refs/pull/*:refs/remotes/origin/pr/*" + browser: githubweb + browser-url: "{jjb_git}" + script-path: ".ci/Jenkinsfile" +- project: + name: libvma + jjb_email: 'nwolfer@nvidia.com' + jjb_proj: 'LibVMA-redmine-issue' + jjb_git: 'git@github.com:Mellanox/libvma.git' + jjb_owner: 'Nir Wolfer' + jobs: + - "{jjb_proj}" diff --git a/.ci/redmine_matrix_job.yaml b/.ci/redmine_matrix_job.yaml new file mode 100644 index 0000000000..5d53fd717f --- /dev/null +++ b/.ci/redmine_matrix_job.yaml @@ -0,0 +1,57 @@ +--- +job: LibVMA-redmine-issue + +registry_host: harbor.mellanox.com +registry_auth: swx-storage + +kubernetes: + privileged: true + cloud: il-ipp-blossom-prod + namespace: swx-media + nodeSelector: 'beta.kubernetes.io/os=linux' + limits: '{memory: 1Gi, cpu: 1000m}' + requests: '{memory: 1Gi, cpu: 1000m}' + arch_table: + x86_64: + nodeSelector: 'kubernetes.io/arch=amd64' + jnlpImage: 'harbor.mellanox.com/toolbox/c3po-jnlp:latest' + +failFast: false +timeout_minutes: 20 +env: + MAIL_FROM: jenkins@nvidia.com + +volumes: + - {mountPath: /hpc/local/inst/hpc-internal-tools, hostPath: /hpc/local/inst/hpc-internal-tools} + +runs_on_dockers: + - {name: 'ub22.04-base', url: 'harbor.mellanox.com/hpcx/x86_64/ubuntu22.04/base', arch: 'x86_64'} + +steps: + - name: Redmine + containerSelector: + - "{name: 'ub22.04-base'}" + run: | + #!/bin/bash -eExl + env + python3 -m pip install six + python3 /hpc/local/inst/hpc-internal-tools/tools/git_tools/git_redmine/update_redmine_from_git_commit_python3.py --update --project_id=9 --on_email_mismatch=warn \ + --on_issue_not_in_project=fail --pr_url=${ghprbPullLink} --commit_id=${ghprbActualCommit} + parallel: false + +pipeline_start: + run: | + printenv + echo "Start" + +pipeline_stop: + shell: action + module: groovy + run: | + mail from: "${MAIL_FROM}", + mimeType: 'text/html', + to: "${MAIL_TO}", + subject: 'Redmine check for build ${currentBuild.number}', + body: """ +

Build url: link

""" + sh 'echo "Finish"' diff --git a/.ci/scripts/doca_install.sh b/.ci/scripts/doca_install.sh new file mode 100755 index 0000000000..1682f12248 --- /dev/null +++ b/.ci/scripts/doca_install.sh @@ -0,0 +1,110 @@ +#!/bin/bash + +set -xvEe -o pipefail + +DOCA_REPO_PATH="https://doca-repo-prod.nvidia.com/internal/repo/doca" +TARGET=${TARGET:=all} +DOCA_VERSION=${DOCA_VERSION:='3.3.0'} +DOCA_BRANCH=${DOCA_BRANCH:="latest"} +GPG_KEY="GPG-KEY-Mellanox.pub" + +function error_handler() { + bc="$BASH_COMMAND" + set +xv + echo "================================= DEBUG info start =================================" + echo "Exited with ERROR in line $1" + echo "Failed CMD: ${bc}" + echo "Current directory is ${PWD}" + echo "It took $(date -d@${SECONDS} -u +%H:%M:%S) to execute $0" + echo "================================= DEBUG info end =================================" + exit 1 +} + +trap 'error_handler $LINENO' ERR + +function map_os_and_arch { + . /etc/os-release + + ARCH=$(uname -m) + + # Determine OS and ARCH + case "$ARCH" in + x86_64) + ARCH="x86_64" + ;; + aarch64) + ARCH="arm64-sbsa" + ;; + *) + echo "Unsupported architecture for $ID: $ARCH" + return 1 + esac + + case "$ID" in + ubuntu) + if [[ "$VERSION_ID" =~ ^2[0-9]\.04$ ]]; then + OS="${ID}${VERSION_ID}" + else + echo "Unsupported Ubuntu version: $VERSION_ID" + exit 1 + fi + GPG_KEY_CMD='cat "${GPG_KEY}" | gpg --dearmor > /etc/apt/trusted.gpg.d/"${GPG_KEY}"' + REPO_CMD='echo deb [signed-by=/etc/apt/trusted.gpg.d/"${GPG_KEY}"] "${REPO_URL}" ./ >> /etc/apt/sources.list.d/doca.list' + PKG_MGR="apt" + UPDATE_CMD="update" + CURL_INSTALL="" + ;; + + rhel|ol) + # Extract major version only (e.g., 9.6 -> 9) + OS="${ID}${VERSION_ID%%.*}" + GPG_KEY_CMD='rpm --import "${GPG_KEY}"' + REPO_CMD='yum install -y yum-utils && yum-config-manager --add-repo "${REPO_URL}"' + PKG_MGR="yum --nogpgcheck" + UPDATE_CMD="makecache" + CURL_INSTALL="" + ;; + sles) + # Extract major version only (e.g., 9.6 -> 9) + OS="${ID}${VERSION_ID%%.*}" + GPG_KEY_CMD='rpm --import "${GPG_KEY}"' + REPO_CMD='zypper addrepo "${REPO_URL}" doca' + PKG_MGR="zypper --no-gpg-checks" + UPDATE_CMD="refresh" + CURL_INSTALL="zypper install -y curl" + ;; + *) + echo "Unsupported OS: $ID" + return 1 + esac + + echo "OS=${OS}" + echo "ARCH=${ARCH}" + echo "PKG_MGR=${PKG_MGR}" + echo "UPDATE_CMD=${UPDATE_CMD}" + echo "GPG_KEY_CMD=${GPG_KEY_CMD}" + echo "REPO_CMD=${REPO_CMD}" + echo "CURL_INSTALL=${CURL_INSTALL}" +} + +# Set up os-dependend variables +map_os_and_arch + +# Install DOCA repo GPG key +${CURL_INSTALL}; curl -o "${GPG_KEY}" "${DOCA_REPO_PATH}/${DOCA_VERSION}/${OS}/${ARCH}/${DOCA_BRANCH}/${GPG_KEY}" +eval "${GPG_KEY_CMD}" + +# Install DOCA repo +REPO_URL="${DOCA_REPO_PATH}/${DOCA_VERSION}/${OS}/${ARCH}/${DOCA_BRANCH}/" +eval "${REPO_CMD}" + +# Install DOCA +${PKG_MGR} ${UPDATE_CMD} + +${PKG_MGR} install -y doca-ofed-userspace + +echo "==============================================" +echo +echo "DOCA for Host has been successfully installed" +echo +echo "==============================================" diff --git a/CHANGES b/CHANGES index 59ad6c50b3..4e14ca7bd7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,132 @@ +Version 9.8.84-1: +Date + Time 2026-01-08 +============================================================= +Fixed: + - RM #4504533 Fix VMA_BF environment variable + +Version 9.8.83-1: +Date + Time 2026-01-05 +============================================================= +Fixed: + - RM #4817116 fix CQ notification return check + +Version 9.8.82-1: +Date + Time 2025-12-24 +============================================================= +Fixed: + - RM #4625338 Fix coverity issues + - RM #4751690 Fix FIN flow during SYN handshake in VMA_TCP_CTL + +Version 9.8.81-1: +Date + Time 2025-12-14 +============================================================= +Removed: + - RM #4664028 Removing IPoIB support + - RM #4664028 Removing TSO + - RM #4664028 Removing legacy defines + - RM #4664028 Removing legacy and exp verbs + +Version 9.8.80-1: +Date + Time 2025-09-07 +============================================================= +Added: + - RM #4607536 Improve VMA stability + +Version 9.8.72-1: +Date + Time 2025-05-29 +============================================================= +Fixed: + - RM #4446285 Replace linux list with BSD list + +Version 9.8.71-1: +Date + Time 2025-03-26 +============================================================= +Fixed: + - RM #4337575 Init VMA in vma_thread_offload() + - RM #4260620 infinite loop latency spec + +Version 9.8.70-1: +Date + Time 2025-02-09 +============================================================= +Added: + - RM #4251780 SocketXtreme API for external allocator + - RM #4223310 VMA support for kernel 6.10 + +Fixed: + - RM #4233101 header licensing for 2025 + +Version 9.8.60-1: +Date + Time 2024-02-28 +============================================================= +Fixed: + - RM #3749337 Fix TCP keepAlive timer when set to -1 + - RM #3749310 Fix delayed TCP keepAlive probes + +Version 9.8.51-1: +Date + Time 2024-01-11 +============================================================= +Fixed: + - RM #3723595 Update the copyright statement to 2024 + +Version 9.8.50-1: +Date + Time 2023-12-28 +============================================================= +Fixed: + - RM #3604029 Fix releasing ring flow + - RM #3623373 Fix corruption during ring release + - RM #3655436 Add full TCP_KEEPALIVE support + - RM #3697720 Fixing socket destruction race + - RM #1214066 Update some unsigned char -> uint32_t for table_id + +Version 9.8.40-1: +Date + Time 2023-09-12 +============================================================= +Removed: + - RM #3593939 DPCP dependency + +Fixed: + - RM #3591039 Wrong lwip seqno wrap around condition + - RM #3591039 Type overflow during trimming TCP seg + - RM #3591039 Ref count for mem_buf chains + - RM #3591039 GRO retransmitted TCP stream + - RM #3591039 Incorrect pbuf chain split + - RM #3604175 Fixing stuck empty rx ring cleanup + +Version 9.8.31-1: +Date + Time 2023-07-10 +============================================================= +Fixed: + - RM #3525812 Socketxtreme buffer reclaim leak + +Version 9.8.30-1: +Date + Time 2023-06-08 +============================================================= +Added: + - RM #3420360 Support for ConnectX-7 + +Version 9.8.20-1: +Date + Time 2023-03-01 +============================================================= +Fixed: + - RM #3373882 Fix compilation issue for gcc 13.0.1 + +Version 9.8.1-1: +Date + Time 2023-01-16 +============================================================= +Fixed: + - RM #3321730 Update the copyright statement to 2023 + +Version 9.8.0-1: +Date + Time 2022-12-15 +============================================================= +Bumping the version + +Version 9.7.2-1: +Date + Time 2022-11-14 +============================================================= +Fixed: + - RM #3249310 Support only systemctl for vma service setup/removal + Version 9.7.1-1: Date + Time 2022-10-24 ============================================================= diff --git a/COPYING b/COPYING new file mode 100644 index 0000000000..177e35d059 --- /dev/null +++ b/COPYING @@ -0,0 +1,50 @@ +SPDX-FileCopyrightText: Copyright (c) 2020-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +SPDX-License-Identifier: GPL-2.0-only + +GNU GENERAL PUBLIC LICENSE +Version 2, June 1991 +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. +Preamble +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. +The precise terms and conditions for copying, distribution and modification follow. +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: +a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. +b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. +c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: +a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, +b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, +c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. +NO WARRANTY +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS diff --git a/LICENSE b/LICENSE index f8707a15c5..9339c274e6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,31 +1,13 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ +SPDX-FileCopyrightText: Copyright (c) 2020-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause + +This software is available to you under a choice of one of two +licenses. You may choose to be licensed under the terms of the GNU +General Public License (GPL) Version 2, available from the file +COPYING in the main directory of this source tree, or the +BSD – 2- Clause license below: + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile.am b/Makefile.am index 5393820dcb..0f8198bde6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,21 +20,15 @@ mydocdir = $(if $(docdir),$(docdir),${datadir}/doc/$(distdir)) mydoc_DATA = README CHANGES install-exec-hook: - if systemctl >/dev/null 2>&1; then \ + if command -v systemctl >/dev/null 2>&1; then \ mkdir -p $(DESTDIR)$(prefix)/lib/systemd/system/; \ cp $(top_builddir)/contrib/scripts/vma.service $(DESTDIR)$(prefix)/lib/systemd/system/vma.service; \ chmod 644 $(DESTDIR)$(prefix)/lib/systemd/system/vma.service; \ - else \ - mkdir -p $(DESTDIR)/$(sysconfdir)/init.d; \ - cp $(top_builddir)/contrib/scripts/vma.init $(DESTDIR)$(sysconfdir)/init.d/vma; \ - chmod 755 $(DESTDIR)$(sysconfdir)/init.d/vma; \ fi uninstall-hook: - if systemctl >/dev/null 2>&1; then \ + if command -v systemctl >/dev/null 2>&1; then \ rm -rf $(DESTDIR)$(prefix)/lib/systemd/system/vma.service; \ - else \ - rm -rf $(DESTDIR)$(sysconfdir)/init.d/vma; \ fi install-all: install diff --git a/README b/README index 631af198d7..5bc5a4419f 100644 --- a/README +++ b/README @@ -115,7 +115,6 @@ Example: VMA DETAILS: TCP max syn rate 0 (no limit) [VMA_TCP_MAX_SYN_RATE] VMA DETAILS: Tx Mem Segs TCP 1000000 [VMA_TX_SEGS_TCP] VMA DETAILS: Tx Mem Bufs 200000 [VMA_TX_BUFS] - VMA DETAILS: Tx Mem Buf size 0 [VMA_TX_BUF_SIZE] VMA DETAILS: Tx QP WRE 2048 [VMA_TX_WRE] VMA DETAILS: Tx QP WRE Batching 64 [VMA_TX_WRE_BATCHING] VMA DETAILS: Tx Max QP INLINE 204 [VMA_TX_MAX_INLINE] @@ -169,7 +168,6 @@ Example: VMA DETAILS: Internal Thread Affinity -1 [VMA_INTERNAL_THREAD_AFFINITY] VMA DETAILS: Internal Thread Cpuset [VMA_INTERNAL_THREAD_CPUSET] VMA DETAILS: Internal Thread Arm CQ Disabled [VMA_INTERNAL_THREAD_ARM_CQ] - VMA DETAILS: Internal Thread TCP Handling 0 (deferred) [VMA_INTERNAL_THREAD_TCP_TIMER_HANDLING] VMA DETAILS: Thread mode Multi spin lock [VMA_THREAD_MODE] VMA DETAILS: Buffer batching mode 1 (Batch and reclaim buffers) [VMA_BUFFER_BATCHING_MODE] VMA DETAILS: Mem Allocate type 1 (Contig Pages) [VMA_MEM_ALLOC_TYPE] @@ -265,7 +263,6 @@ latency VMA_RX_WRE = 256 (default: 16000) VMA_RX_WRE_BATCHING = 4 (default: 64) VMA_RX_POLL = -1 (default: 100000) - VMA_TSO = Disable (default: Enable) VMA_RX_PREFETCH_BYTES_BEFORE_POLL = 256 (default: 0) VMA_GRO_STREAMS_MAX = 0 (default: 32) VMA_SELECT_POLL = -1 (default: 100000) @@ -355,11 +352,6 @@ VMA_TX_BUFS Number of global Tx data buffer elements allocation. Default value is 200000 -VMA_TX_BUF_SIZE -Size of Tx data buffer elements allocation. -Can not be less then MTU (Maximum Transfer Unit) and greater than 0xFF00. -Default value is calculated basing on VMA_MTU and VMA_MSS. - VMA_TX_WRE Number of Work Request Elements allocated in all transmit QP's. The number of QP's can change according to the number of network offloaded @@ -492,16 +484,6 @@ Value range is -1, 0 to 100,000,000 Where value of -1 is used for infinite polling Default value is 100000 -VMA_TSO -With Segmentation Offload, or TCP Large Send, TCP can pass a buffer to be -transmitted that is bigger than the maximum transmission unit (MTU) supported -by the medium. Intelligent adapters implement large sends by using the -prototype TCP and IP headers of the incoming send buffer to carve out segments -of required size. Copying the prototype header and options, then calculating -the sequence number and checksum fields creates TCP segment headers. -Expected benefits: Throughput increase and CPU unload. -Default value is 1 (Enable) - VMA_RX_POLL_INIT VMA maps all UDP sockets as potential offloaded capable. Only after the ADD_MEMBERSHIP does the offload start to work and the CQ polling kicks in VMA. @@ -628,8 +610,8 @@ Where value of 0 is used for no polling (interrupt driven) Default value is 100000 VMA_SELECT_POLL_OS_FORCE -This flag forces to poll the OS file descriptors while user thread calls -select(), poll() or epoll_wait() even when no offloaded sockets are mapped. +NOTE: +This is a DEPRECATED configuration parameter that will be removed from future libvma releases. Enabling this flag causes VMA to set VMA_SELECT_POLL_OS_RATIO and VMA_SELECT_SKIP_OS to 1. This will result in VMA_SELECT_POLL number of times VMA will poll the OS file descriptors, along side with offloaded @@ -813,14 +795,6 @@ The value is the path to the cpuset (for example: /dev/cpuset/my_set), or an emp string to run it on the same cpuset the process runs on. Default value is an empty string. -VMA_INTERNAL_THREAD_TCP_TIMER_HANDLING -Select the internal thread policy when handling TCP timers -Use value of 0 for deferred handling. The internal thread will not handle TCP timers upon timer -expiration (once every 100ms) in order to let application threads handling it first -Use value of 1 for immediate handling. The internal thread will try locking and handling TCP timers upon -timer expiration (once every 100ms). Application threads may be blocked till internal thread finishes handling TCP timers -Default value is 0 (deferred handling) - VMA_INTERNAL_THREAD_ARM_CQ Wakeup the internal thread for each packet that the CQ receive. Poll and process the packet and bring it to the socket layer. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000..4a8645b207 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,25 @@ +# Security + +NVIDIA is dedicated to the security and trust of our software products and services, including all source code repositories managed through our organization. + +If you need to report a security issue, please use the appropriate contact points outlined below. **Please do not report security vulnerabilities through GitHub/GitLab.** + +## Reporting Potential Security Vulnerability in an NVIDIA Product + +To report a potential security vulnerability in any NVIDIA product: + +- Web: [Security Vulnerability Submission Form](https://www.nvidia.com/object/submit-security-vulnerability.html) +- E-Mail: [psirt@nvidia.com](mailto:psirt@nvidia.com) + - We encourage you to use the following PGP key for secure email communication: [NVIDIA public PGP Key for communication](https://www.nvidia.com/en-us/security/pgp-key) + - Please include the following information: + - Product/Driver name and version/branch that contains the vulnerability + - Type of vulnerability (code execution, denial of service, buffer overflow, etc.) + - Instructions to reproduce the vulnerability + - Proof-of-concept or exploit code + - Potential impact of the vulnerability, including how an attacker could exploit the vulnerability + +While NVIDIA currently does not have a bug bounty program, we do offer acknowledgement when an externally reported security issue is addressed under our coordinated vulnerability disclosure policy. Please visit our [Product Security Incident Response Team (PSIRT)](https://www.nvidia.com/en-us/security/psirt-policies/) policies page for more information. + +## NVIDIA Product Security + +For all security-related concerns, please visit NVIDIA's Product Security portal at [https://www.nvidia.com/en-us/security](https://www.nvidia.com/en-us/security) diff --git a/config/m4/compiler.m4 b/config/m4/compiler.m4 index 014a01f1ed..6467cf8713 100644 --- a/config/m4/compiler.m4 +++ b/config/m4/compiler.m4 @@ -1,9 +1,9 @@ -# compiler.m4 - Configure compiler capabilities # -# Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# See file LICENSE for terms. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # - +# compiler.m4 - Configure compiler capabilities # Check compiler specific attributes # Usage: CHECK_COMPILER_ATTRIBUTE([attribute], [program], [definition]) @@ -143,7 +143,7 @@ case $CC in -Wno-free-nonheap-object " CXXFLAGS="$CXXFLAGS -Wshadow -Wall -Wextra -Werror -Wundef \ -ffunction-sections -fdata-sections -Wsequence-point -pipe -Winit-self -Wmissing-include-dirs \ - -Wno-free-nonheap-object " + -Wno-free-nonheap-object -Wno-overloaded-virtual " ;; icc*|icpc*) AC_MSG_RESULT([icc]) diff --git a/config/m4/dpcp.m4 b/config/m4/dpcp.m4 deleted file mode 100644 index b6089d2999..0000000000 --- a/config/m4/dpcp.m4 +++ /dev/null @@ -1,80 +0,0 @@ -# dpcp.m4 - Library to operate with DevX -# -# Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# See file LICENSE for terms. -# - -########################## -# libdpcp usage support -# -AC_DEFUN([DPCP_CAPABILITY_SETUP], -[ -AC_ARG_WITH([dpcp], - AS_HELP_STRING([--with-dpcp(=DIR)], - [Search for dpcp headers and libraries in DIR (default NO)]), - [], - [with_dpcp=no] -) - -if test "x$vma_cv_directverbs" != x3 && test "x$with_dpcp" != xno; then - AC_MSG_ERROR([dpcp can be used under RDMA-core subsystem only]) -fi - -vma_cv_dpcp=0 -AS_IF([test "x$with_dpcp" == xno], - [], - [ - if test -z "$with_dpcp" || test "$with_dpcp" = "yes"; then - with_dpcp=/usr - fi - - FUNC_CHECK_WITHDIR([dpcp], [$with_dpcp], [include/mellanox/dpcp.h]) - - vma_cv_dpcp_save_CPPFLAGS="$CPPFLAGS" - vma_cv_dpcp_save_CXXFLAGS="$CXXFLAGS" - vma_cv_dpcp_save_CFLAGS="$CFLAGS" - vma_cv_dpcp_save_LDFLAGS="$LDFLAGS" - vma_cv_dpcp_save_LIBS="$LIBS" - - vma_cv_dpcp_CPPFLAGS="-I$with_dpcp/include" - vma_cv_dpcp_LIBS="-ldpcp -lmlx5" - vma_cv_dpcp_LDFLAGS="-L$with_dpcp/lib -Wl,--rpath,$with_dpcp/lib" - if test -d "$with_dpcp/lib64"; then - vma_cv_dpcp_LDFLAGS="-L$with_dpcp/lib64 -Wl,--rpath,$with_dpcp/lib64" - fi - - CPPFLAGS="-std=c++11 $vma_cv_dpcp_CPPFLAGS $CPPFLAGS" - CXXFLAGS="-std=c++11 $CXXFLAGS" - LDFLAGS="$vma_cv_dpcp_LDFLAGS $LDFLAGS" - LIBS="$vma_cv_dpcp_LIBS $LIBS" - - AC_LANG_PUSH([C++]) - AC_CHECK_HEADER( - [mellanox/dpcp.h], - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[dpcp::provider *provider; - dpcp::provider::get_instance(provider);]])], - [vma_cv_dpcp=1]) - ]) - AC_LANG_POP() - - CPPFLAGS="$vma_cv_dpcp_save_CPPFLAGS" - CXXFLAGS="$vma_cv_dpcp_save_CXXFLAGS" - CFLAGS="$vma_cv_dpcp_save_CFLAGS" - LDFLAGS="$vma_cv_dpcp_save_LDFLAGS" - LIBS="$vma_cv_dpcp_save_LIBS" - ]) - -AC_MSG_CHECKING([for dpcp support]) -if test "$vma_cv_dpcp" -ne 0; then - CPPFLAGS="$CPPFLAGS $vma_cv_dpcp_CPPFLAGS" - LDFLAGS="$LDFLAGS $vma_cv_dpcp_LDFLAGS" - AC_SUBST([DPCP_LIBS], ["-ldpcp"]) - AC_DEFINE_UNQUOTED([DEFINED_DPCP], [1], [Define to 1 to use DPCP]) - AC_MSG_RESULT([yes]) -else - AS_IF([test "x$with_dpcp" == xno], - [AC_MSG_RESULT([no])], - [AC_MSG_ERROR([dpcp support requested but not present])]) -fi -]) diff --git a/config/m4/func.m4 b/config/m4/func.m4 index 40bfc18e98..3c90aa3c1b 100644 --- a/config/m4/func.m4 +++ b/config/m4/func.m4 @@ -1,8 +1,9 @@ -# func.m4 - Collection of functions -# -# Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# See file LICENSE for terms. # +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause +# +# func.m4 - Collection of functions ########################## # Configure functions diff --git a/config/m4/nl.m4 b/config/m4/nl.m4 index 6293956297..9ec727560c 100644 --- a/config/m4/nl.m4 +++ b/config/m4/nl.m4 @@ -1,8 +1,9 @@ -# nl.m4 - Detect nl package # -# Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# See file LICENSE for terms. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # +# nl.m4 - Detect nl package ########################## # Checking nl library diff --git a/config/m4/opt.m4 b/config/m4/opt.m4 index efc56ff39a..b54fab2430 100644 --- a/config/m4/opt.m4 +++ b/config/m4/opt.m4 @@ -1,8 +1,9 @@ -# opt.m4 - Macros to control optimization -# -# Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# See file LICENSE for terms. # +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause +# +# opt.m4 - Macros to control optimization ########################## # Logging control diff --git a/config/m4/prof.m4 b/config/m4/prof.m4 index fbb66fbd79..c42644f96a 100644 --- a/config/m4/prof.m4 +++ b/config/m4/prof.m4 @@ -1,8 +1,9 @@ -# prof.m4 - Profiling, instrumentation -# -# Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# See file LICENSE for terms. # +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause +# +# prof.m4 - Profiling, instrumentation ########################## # libibprof profiling support @@ -249,4 +250,4 @@ AS_IF([test "x$with_rdtsc_receivefrom_to_sendto" == xyes], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])] ) -]) \ No newline at end of file +]) diff --git a/config/m4/verbs.m4 b/config/m4/verbs.m4 index bc60f6271a..5f40c5a610 100644 --- a/config/m4/verbs.m4 +++ b/config/m4/verbs.m4 @@ -1,9 +1,9 @@ -# verbs.m4 - Parsing verbs capabilities # -# Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# See file LICENSE for terms. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # - +# verbs.m4 - Parsing verbs capabilities # Check attributes # Usage: CHECK_VERBS_ATTRIBUTE([attribute], [header file], [definition]) @@ -47,6 +47,9 @@ AC_CHECK_HEADERS([infiniband/verbs.h], , AC_CHECK_HEADERS([rdma/rdma_cma.h], , [AC_MSG_ERROR([Unable to find the librdmacm-devel header files])]) +AC_CHECK_HEADERS([infiniband/mlx5dv.h], , + [AC_MSG_ERROR([Unable to find the libmlx5 header files])]) + AC_CHECK_LIB(ibverbs, ibv_get_device_list, [VERBS_LIBS="$VERBS_LIBS -libverbs"], AC_MSG_ERROR([ibv_get_device_list() not found.])) @@ -55,71 +58,11 @@ AC_CHECK_LIB(rdmacm, rdma_create_id, [VERBS_LIBS="$VERBS_LIBS -lrdmacm"], AC_MSG_ERROR([rdma_create_id() not found.])) -AC_SUBST([VERBS_LIBS]) - -# Save LIBS -verbs_saved_libs=$LIBS -LIBS="$LIBS $VERBS_LIBS" - - -# Check if VERBS version -# -vma_cv_verbs=0 -vma_cv_verbs_str="None" -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -]], -[[ - int access = (int)IBV_EXP_ACCESS_ALLOCATE_MR; - access = access; -]])], -[ - vma_cv_verbs=2 - vma_cv_verbs_str="Experimental" -], -[ - AC_CHECK_HEADER([infiniband/verbs.h], - [AC_CHECK_MEMBERS([struct ibv_query_device_ex_input.comp_mask], - [vma_cv_verbs=3 vma_cv_verbs_str="Upstream"], - [vma_cv_verbs=1 vma_cv_verbs_str="Legacy"], - [[#include ]] )], - [], - [AC_MSG_ERROR([Can not detect VERBS version])] - ) -]) -AC_MSG_CHECKING([for OFED Verbs version]) -AC_MSG_RESULT([$vma_cv_verbs_str]) -AC_DEFINE_UNQUOTED([DEFINED_VERBS_VERSION], [$vma_cv_verbs], [Define found Verbs version]) - - -# Check if direct hardware operations can be used instead of VERBS API -# -vma_cv_directverbs=0 -case "$vma_cv_verbs" in - 1) - ;; - 2) - AC_CHECK_HEADER([infiniband/mlx5_hw.h], - [AC_CHECK_DECL([MLX5_ETH_INLINE_HEADER_SIZE], - [vma_cv_directverbs=$vma_cv_verbs], [], [[#include ]])]) - ;; - 3) - AC_CHECK_HEADER([infiniband/mlx5dv.h], - [AC_CHECK_LIB(mlx5, - mlx5dv_init_obj, [VERBS_LIBS="$VERBS_LIBS -lmlx5" vma_cv_directverbs=$vma_cv_verbs])]) - ;; - *) - AC_MSG_ERROR([Unrecognized parameter 'vma_cv_verbs' as $vma_cv_verbs]) - ;; -esac -AC_MSG_CHECKING([for direct verbs support]) -if test "$vma_cv_directverbs" -ne 0; then - AC_DEFINE_UNQUOTED([DEFINED_DIRECT_VERBS], [$vma_cv_directverbs], [Direct VERBS support]) - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi +AC_CHECK_LIB(mlx5, + mlx5dv_init_obj, [VERBS_LIBS="$VERBS_LIBS -lmlx5"], + AC_MSG_ERROR([mlx5dv_init_obj() not found.])) +AC_SUBST([VERBS_LIBS]) # Check # @@ -128,7 +71,6 @@ CHECK_VERBS_ATTRIBUTE([IBV_QPT_RAW_PACKET], [infiniband/verbs.h]) CHECK_VERBS_ATTRIBUTE([IBV_WC_WITH_VLAN], [infiniband/verbs.h]) CHECK_VERBS_ATTRIBUTE([IBV_ACCESS_ALLOCATE_MR], [infiniband/verbs.h]) CHECK_VERBS_ATTRIBUTE([IBV_QP_CREATE_SOURCE_QPN], [infiniband/verbs.h], [IBV_QP_INIT_SOURCE_QPN]) -CHECK_VERBS_ATTRIBUTE([IBV_FLOW_SPEC_IB], [infiniband/verbs.h], [IBV_FLOW_SPEC_IB]) CHECK_VERBS_ATTRIBUTE([IBV_DEVICE_RAW_IP_CSUM], [infiniband/verbs.h]) CHECK_VERBS_ATTRIBUTE([IBV_SEND_IP_CSUM], [infiniband/verbs.h]) CHECK_VERBS_ATTRIBUTE([IBV_FLOW_SPEC_ACTION_TAG], [infiniband/verbs.h], [IBV_FLOW_TAG]) @@ -138,57 +80,8 @@ CHECK_VERBS_MEMBER([struct ibv_alloc_dm_attr.length], [infiniband/verbs.h], [IBV CHECK_VERBS_MEMBER([struct ibv_packet_pacing_caps.qp_rate_limit_min], [infiniband/verbs.h], [IBV_PACKET_PACING_CAPS]) CHECK_VERBS_MEMBER([struct ibv_qp_rate_limit_attr.max_burst_sz], [infiniband/verbs.h], [IBV_QP_SUPPORT_BURST]) -# Check -# -if test "x$vma_cv_verbs" == x2; then - CHECK_VERBS_ATTRIBUTE([IBV_EXP_CQ_MODERATION], [infiniband/verbs_exp.h], [IBV_CQ_ATTR_MODERATE]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_WR_NOP], [infiniband/verbs_exp.h], [IBV_WR_NOP]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_ACCESS_ALLOCATE_MR], [infiniband/verbs_exp.h]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_QP_INIT_ATTR_ASSOCIATED_QPN], [infiniband/verbs_exp.h], [IBV_QP_INIT_SOURCE_QPN]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_FLOW_SPEC_IB], [infiniband/verbs_exp.h], [IBV_FLOW_SPEC_IB]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_SEND_IP_CSUM], [infiniband/verbs_exp.h]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_DEVICE_ATTR_MAX_DM_SIZE], [infiniband/verbs_exp.h], [IBV_DM]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_QP_RATE_LIMIT], [infiniband/verbs_exp.h], [IBV_PACKET_PACING_CAPS]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_QP_SUPPORT_BURST], [infiniband/verbs_exp.h], [IBV_QP_SUPPORT_BURST]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_WR_TSO], [infiniband/verbs_exp.h], [OPCODE_TSO]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_DEVICE_CROSS_CHANNEL], [infiniband/verbs_exp.h], [IBV_DEVICE_CROSS_CHANNEL]) - - # - # Experimental Verbs CQ - # - AC_ARG_ENABLE([exp-cq], - AS_HELP_STRING([--disable-exp-cq], - [Disable experimental Verbs CQ (disables UDP RX HW Timestamp, RX CSUM verification offload and Multi Packet RQ)]), - [enable_exp_cq=no], - [enable_exp_cq=yes] - ) - - AS_IF([test "x$enable_exp_cq" == xyes], - [AC_DEFINE([DEFINED_IBV_EXP_CQ], 1, [Define to 1 if Experimental Verbs CQ was enabled at configure time])] - - CHECK_VERBS_ATTRIBUTE([IBV_EXP_CQ_TIMESTAMP], [infiniband/verbs_exp.h], [IBV_CQ_TIMESTAMP]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_VALUES_CLOCK_INFO], [infiniband/verbs_exp.h], [IBV_CLOCK_INFO]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_DEVICE_RX_CSUM_L4_PKT], [infiniband/verbs_exp.h]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_DEVICE_RX_CSUM_TCP_UDP_PKT], [infiniband/verbs_exp.h]) - CHECK_VERBS_ATTRIBUTE([IBV_EXP_FLOW_SPEC_ACTION_TAG], [infiniband/verbs_exp.h], [IBV_FLOW_TAG]) - ) - - AC_CHECK_FUNCS([rdma_lib_reset]) - AC_CHECK_FUNCS([ibv_exp_get_device_list]) -fi - -# Check Upstream -# -if test "x$vma_cv_verbs" == x3; then - CHECK_VERBS_ATTRIBUTE([IBV_WR_TSO], [infiniband/verbs.h], [OPCODE_TSO]) - - if test "x$vma_cv_directverbs" == x3; then - CHECK_VERBS_ATTRIBUTE([MLX5_OPCODE_NOP], [infiniband/mlx5dv.h], [IBV_WR_NOP]) - CHECK_VERBS_MEMBER([struct mlx5dv_clock_info.last_cycles], [infiniband/mlx5dv.h], [IBV_CLOCK_INFO]) - CHECK_VERBS_MEMBER([struct mlx5dv_context.num_lag_ports], [infiniband/mlx5dv.h], [ROCE_LAG]) - fi -fi +CHECK_VERBS_ATTRIBUTE([MLX5_OPCODE_NOP], [infiniband/mlx5dv.h], [IBV_WR_NOP]) +CHECK_VERBS_MEMBER([struct mlx5dv_clock_info.last_cycles], [infiniband/mlx5dv.h], [IBV_CLOCK_INFO]) +CHECK_VERBS_MEMBER([struct mlx5dv_context.num_lag_ports], [infiniband/mlx5dv.h], [ROCE_LAG]) -# Restore LIBS -LIBS=$verbs_saved_libs ]) diff --git a/configure.ac b/configure.ac index cca99175f6..99407ad0fd 100644 --- a/configure.ac +++ b/configure.ac @@ -13,8 +13,8 @@ dnl===-----------------------------------------------------------------------=== # Update version number here: # define([prj_ver_major], 9) -define([prj_ver_minor], 7) -define([prj_ver_revision], 1) +define([prj_ver_minor], 8) +define([prj_ver_revision], 84) define([prj_ver_release], esyscmd([echo ${PRJ_RELEASE:=0}])) @@ -84,7 +84,6 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_include([config/m4/func.m4]) m4_include([config/m4/opt.m4]) m4_include([config/m4/verbs.m4]) -m4_include([config/m4/dpcp.m4]) m4_include([config/m4/nl.m4]) m4_include([config/m4/prof.m4]) m4_include([config/m4/compiler.m4]) @@ -216,7 +215,6 @@ AC_MSG_RESULT($ac_cv_ofed_path) VERBS_CAPABILITY_SETUP() OPT_VMA_LOGGING() PROF_IBPROF_SETUP() -DPCP_CAPABILITY_SETUP() # Enable internal performance counters # Note: uncomment setup to activate this ability @@ -257,20 +255,6 @@ else AC_MSG_RESULT([no]) fi -# Control TSO usage -# -AC_ARG_ENABLE([tso], - AS_HELP_STRING([--enable-tso], - [Enable TSO availability (default=no)])) -AC_MSG_CHECKING( - [for tso support]) -if test "x$enable_tso" = xyes -a "x$vma_cv_attribute_ex_OPCODE_TSO" = xyes; then - AC_DEFINE_UNQUOTED([DEFINED_TSO], [1], [Define to 1 to use TSO]) - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi - AC_MSG_CHECKING([for md5 version of VMA statistics is]) STATS_PROTOCOL_VER=`md5sum ${srcdir}/src/vma/util/vma_stats.h | awk '{ print $1}'` AC_DEFINE_UNQUOTED(STATS_PROTOCOL_VER, "${STATS_PROTOCOL_VER}", [Stats Protocol Version]) diff --git a/contrib/build_pkg.sh b/contrib/build_pkg.sh index e384363353..8b95beba8d 100755 --- a/contrib/build_pkg.sh +++ b/contrib/build_pkg.sh @@ -1,5 +1,6 @@ #!/bin/bash +opt_tarpkg=0 opt_srcpkg=0 opt_binpkg=0 opt_co="" @@ -19,6 +20,9 @@ while test "$1" != ""; do --srcpkg|-s) opt_srcpkg=1 ;; + --tarpkg|-t) + opt_tarpkg=1 + ;; --binpkg|-b) opt_binpkg=1 ;; @@ -40,6 +44,7 @@ Valid arguments: --input |-i Sources location --output |-o Packages location --srcpkg |-s Create source package +--tarpkg |-t Create release tarball with spec file at root --binpkg |-b Create binary package --checkout|-c Checkout from SCM --argument|-a Pass options into build procedure @@ -49,9 +54,9 @@ contrib/build_pkg.sh -s * Prepare source package directly from github using tag or branch contrib/build_pkg.sh -s -i /tmp/libvma-9.0.2 -c 9.0.2 * Pass none default configuration options -contrib/build_pkg.sh -b -s -a "configure_options=--enable-tso" +contrib/build_pkg.sh -b -s -a "configure_options=--enable-debug" * Create release -env PRJ_RELEASE=1 contrib/build_pkg.sh -b -s -a "configure_options=--enable-tso" +env PRJ_RELEASE=1 contrib/build_pkg.sh -b -s -a "configure_options=--enable-debug" EOF exit 1 ;; @@ -178,6 +183,37 @@ if [ $opt_binpkg -eq 1 -a "$rc" -eq 0 ]; then rc=$((rc + $?)) fi +# Create the release tarball separately after src.rpm generation +if [ $opt_tarpkg -eq 1 ]; then + echo ${pkg_label} "Creating release tarball..." + # Get version for directory name + tarball_name=$(basename ${pkg_tarball}) + tarball_root_dir=${tarball_name%.tar.gz} + + # Create a temporary directory using mktemp instead of a fixed name + tarball_tmp=$(mktemp -d -p ${pkg_dir}) >> ${pkg_log} 2>&1 + tar -xzf ${pkg_tarball} -C ${tarball_tmp} >> ${pkg_log} 2>&1 + if [ $? -ne 0 ]; then + echo "ERROR: Failed to extract tarball ${pkg_tarball}. Exit" >> ${pkg_log} + exit 1 + fi + + # Move spec file to the root directory to support rpmbuild + cp ${pkg_dir}/contrib/scripts/${pkg_spec} ${tarball_tmp}/${tarball_root_dir}/ >> ${pkg_log} 2>&1 + # Remove the duplicate spec file + rm ${tarball_tmp}/${tarball_root_dir}/contrib/scripts/${pkg_spec} >> ${pkg_log} 2>&1 + + # Create new tarball with proper structure + pushd ${tarball_tmp} >> ${pkg_log} 2>&1 + tar -czf ${pkg_outdir}/${tarball_name} ${tarball_root_dir} >> ${pkg_log} 2>&1 + popd >> ${pkg_log} 2>&1 + + echo ${pkg_label} "Release tarball created: ${pkg_outdir}/${tarball_name}" + + # Add tarball temporary directory to cleanup + pkg_cleanup="${pkg_cleanup} ${tarball_tmp}" +fi + if [ "$rc" -eq 0 ]; then echo ${pkg_label} "Cleanup ..." rm -rf ${pkg_cleanup} >> ${pkg_log} 2>&1 diff --git a/contrib/jenkins_tests/copyright-check-map.yaml b/contrib/jenkins_tests/copyright-check-map.yaml index c5cdea2337..0e8547fb5b 100644 --- a/contrib/jenkins_tests/copyright-check-map.yaml +++ b/contrib/jenkins_tests/copyright-check-map.yaml @@ -15,6 +15,7 @@ general: - ".*LICENSE" - ".*NOTICE" - ".*README" + - ".*COPYING" - ".*TODO" - ".*license" - ".*\\.md" @@ -33,7 +34,8 @@ general: - ".*src/vma/config_parser.*" - ".*src/vma/config_scanner\\.c" -nbu-open-source: +dual_gpl_2_bsd_2_no_license: + validate-spdx-license: True include: - ".*" exclude: diff --git a/contrib/jenkins_tests/copyrights.sh b/contrib/jenkins_tests/copyrights.sh index 4e7eba0fd5..286d448c97 100755 --- a/contrib/jenkins_tests/copyrights.sh +++ b/contrib/jenkins_tests/copyrights.sh @@ -1,4 +1,6 @@ -#!/bin/bash -xeEl +#!/bin/bash + +set -xvEe -o pipefail source $(dirname $0)/globals.sh @@ -12,6 +14,11 @@ if [ ! -d "$WORKSPACE" ]; then exit 1 fi +if [[ -z $GITHUB_TOKEN ]]; then + echo "ERROR: GITHUB_TOKEN variable is empty" + exit 1 +fi + cpp_files=' "extensions": [".c", ".cc", ".cpp", "c++", ".h", ".hpp", ".cs", ".inl", ".l", ".y"],' sed -i "s/.*\"extensions\": \[\"\.c\".*/$cpp_files/g" /opt/nvidia/ProjectConfig/header-types.json @@ -19,7 +26,7 @@ cat /opt/nvidia/ProjectConfig/header-types.json /opt/nvidia/header_check.py \ --config ${WORKSPACE}/contrib/jenkins_tests/copyright-check-map.yaml \ - --path ${WORKSPACE} \ + --revs HEAD \ --git-repo ${WORKSPACE} | tee copyrights.log exit_code=$? echo "exit_code=${exit_code}" @@ -32,7 +39,7 @@ if [ ${exit_code} -eq 0 ]; then echo "Please refer to https://confluence.nvidia.com/pages/viewpage.action?pageId=788418816" /opt/nvidia/header_check.py \ --config contrib/jenkins_tests/copyright-check-map.yaml \ - --path ${WORKSPACE} \ + --revs HEAD \ --repair \ --git-repo ${WORKSPACE} | tee copyrights_repair.log # create list of modified files diff --git a/contrib/jenkins_tests/cov.sh b/contrib/jenkins_tests/cov.sh index 30bc727780..3f82c756eb 100755 --- a/contrib/jenkins_tests/cov.sh +++ b/contrib/jenkins_tests/cov.sh @@ -5,7 +5,7 @@ source $(dirname $0)/globals.sh echo "Checking for coverity ..." -COVERITY_MODULE="${COVERITY_MODULE:-tools/cov-2021.12}" +COVERITY_MODULE="${COVERITY_MODULE:-tools/cov-2023.12}" do_module "${COVERITY_MODULE}" cd "$WORKSPACE" @@ -40,12 +40,23 @@ eval "cov-manage-emit --config ${cov_dir}/coverity_config.xml --dir ${cov_build} sleep 1 eval "cov-analyze --config ${cov_dir}/coverity_config.xml \ - --all --aggressiveness-level low \ + --all --aggressiveness-level medium \ --enable-fnptr --fnptr-models --paths 20000 \ --disable-parse-warnings \ --dir ${cov_build}" rc=$(($rc+$?)) +if [[ "${do_coverity_snapshot}" == true ]]; then + cov-commit-defects --ssl --on-new-cert trust \ + --url https://coverity.mellanox.com:8443 \ + --user "${VMA_COV_USER}" --password "${VMA_COV_PASSWORD}" \ + --dir "${cov_build}" \ + --stream libxlio-main \ + --strip-path "${WORKSPACE}" + rc=$(($rc+$?)) +fi + + set -eE # Excluded files for the local report generated by command "cov-format-errors": diff --git a/contrib/jenkins_tests/cppcheck.sh b/contrib/jenkins_tests/cppcheck.sh index 9d82959b67..c442602a43 100755 --- a/contrib/jenkins_tests/cppcheck.sh +++ b/contrib/jenkins_tests/cppcheck.sh @@ -13,7 +13,7 @@ if [ $(command -v ${tool_app} >/dev/null 2>&1 || echo $?) ]; then if [ $? -eq 0 ]; then eval "cd cppcheck && checkout 2.1 " > /dev/null 2>&1 if [ $? -eq 0 ]; then - eval "make -j FILESDIR=$PWD HAVE_RULES=yes " > /dev/null 2>&1 + eval "make $make_opt FILESDIR=$PWD HAVE_RULES=yes " > /dev/null 2>&1 if [ $? -eq 0 ]; then tool_app=$PWD/cppcheck fi diff --git a/contrib/jenkins_tests/globals.sh b/contrib/jenkins_tests/globals.sh index 113767ae58..22e00d1401 100755 --- a/contrib/jenkins_tests/globals.sh +++ b/contrib/jenkins_tests/globals.sh @@ -4,6 +4,7 @@ main() { WORKSPACE=${WORKSPACE:=$(pwd)} BUILD_NUMBER=${BUILD_NUMBER:=0} +HOSTNAME=${HOSTNAME:=$(uname -n 2>/dev/null)} # exit code rc=0 @@ -197,14 +198,19 @@ function do_check_result() } # Detect interface ip -# $1 - [ib|eth] to select link type or empty to select the first found -# $2 - [empty|mlx4|mlx5] +# $1 - [ib|eth|inet6] to select link type or empty to select the first found +# $2 - [empty|mlx4|mlx5|ConnectX-4|ConnectX-5|ConnectX-6|ConnectX-7] (default: ConnectX-7) # $3 - ip address not to get # function do_get_ip() { + opt1=${1:-'eth'} + opt2=${2:-'ConnectX-5'} + opt3=${3:-''} + sv_ifs=${IFS} - netdevs=$(ibdev2netdev | grep Up | grep "$2" | cut -f 5 -d ' ') + # filter by second parameter + netdevs=$(${sudo_cmd} ibdev2netdev -v | grep Up | grep "$opt2" | awk -F' ' '{ print $(NF-1) }') IFS=$'\n' read -rd '' -a netdev_ifs <<< "${netdevs}" lnkifs=$(ip -o link | awk '{print $2,$(NF-2)}') IFS=$'\n' read -rd '' -a lnk_ifs <<< "${lnkifs}" @@ -239,22 +245,19 @@ function do_get_ip() fi fi - for ip in ${ifs_array[@]}; do - if [ -n "$1" -a "$1" == "ib" -a -n "$(ip link show $ip | grep 'link/inf')" ]; then - found_ip=$(ip -4 address show $ip | grep 'inet' | sed 's/.*inet \([0-9\.]\+\).*/\1/') - if [ -n "$(ibdev2netdev | grep $ip | grep mlx5)" ]; then - local ofed_v=$(ofed_info -s | grep OFED | sed 's/.*[l|X]-\([0-9\.]\+\).*/\1/') - if [ $(echo $ofed_v | grep 4.[1-9] >/dev/null 2>&1 || echo $?) ]; then - echo "$ip is CX4 device that does not support IPoIB in OFED: $ofed_v" - unset found_ip - fi - fi - elif [ -n "$1" -a "$1" == "eth" -a -n "$(ip link show $ip | grep 'link/eth')" ]; then - found_ip=$(ip -4 address show $ip | grep 'inet' | sed 's/.*inet \([0-9\.]\+\).*/\1/') - elif [ -z "$1" ]; then - found_ip=$(ip -4 address show $ip | grep 'inet' | sed 's/.*inet \([0-9\.]\+\).*/\1/') + # collect ip addresses + for _if in ${ifs_array[@]}; do + if [ -n "$opt1" -a "$opt1" == "ib" -a -n "$(ip link show $_if | grep 'link/inf')" ]; then + found_ip=$(ip -4 address show $_if | grep 'inet' | sed 's/.*inet \([0-9\.]\+\).*/\1/') + elif [ -n "$opt1" -a "$opt1" == "inet6" -a -n "$(ip link show $_if | grep 'link/eth')" ]; then + found_ip=$(ip -6 address show $_if | grep 'inet6' | sed 's/.*inet6 \([0-9a-fA-F\:]\+\).*/\1/' | grep -v fe80 | head -n 1) + elif [ -n "$opt1" -a "$opt1" == "eth" -a -n "$(ip link show $_if | grep 'link/eth')" ]; then + found_ip=$(ip -4 address show $_if | grep 'inet' | sed 's/.*inet \([0-9\.]\+\).*/\1/' | head -n1) + elif [ -z "$opt1" ]; then + found_ip=$(ip -4 address show $_if | grep 'inet' | sed 's/.*inet \([0-9\.]\+\).*/\1/' | head -n1) fi - if [ -n "$found_ip" -a "$found_ip" != "$3" ]; then + # skip ip address passed as the third parameter + if [ -n "$found_ip" -a "$found_ip" != "$opt3" ]; then echo $found_ip break fi @@ -275,54 +278,6 @@ do_version_check() }' } -do_check_dpcp() -{ - local ret=0 - local version=$(echo "${jenkins_ofed}" | cut -f1-2 -d.) - - if do_version_check $version '<' '5.2' ; then - return - fi - echo "Checking dpcp usage" - - ret=0 - pushd $(pwd) > /dev/null 2>&1 - dpcp_dir=${WORKSPACE}/${prefix}/dpcp - mkdir -p ${dpcp_dir} > /dev/null 2>&1 - cd ${dpcp_dir} - - set +e - if [ $ret -eq 0 ]; then - eval "timeout -s SIGKILL 20s git clone git@github.com:Mellanox/dpcp.git . " > /dev/null 2>&1 - ret=$? - fi - - if [ $ret -eq 0 ]; then - last_tag=$(git tag -l --format "%(refname:short)" --sort=-version:refname | head -n1) - if [ -z "$last_tag" ]; then - ret=1 - fi - fi - - if [ $ret -eq 0 ]; then - eval "git checkout $last_tag" > /dev/null 2>&1 - ret=$? - fi - - if [ $ret -eq 0 ]; then - eval "./autogen.sh && ./configure --prefix=${dpcp_dir}/install && make $make_opt install" > /dev/null 2>&1 - ret=$? - fi - set -e - - popd > /dev/null 2>&1 - if [ $ret -eq 0 ]; then - eval "$1=${dpcp_dir}/install" - echo "dpcp: $last_tag : ${dpcp_dir}/install" - else - echo "dpcp: no" - fi -} ####################################################### # diff --git a/contrib/jenkins_tests/gtest.sh b/contrib/jenkins_tests/gtest.sh index 014d29f97e..b289efb8cc 100755 --- a/contrib/jenkins_tests/gtest.sh +++ b/contrib/jenkins_tests/gtest.sh @@ -48,13 +48,19 @@ eval "${sudo_cmd} ${install_dir}/sbin/${prj_service} --console -v5 &" # Exclude VMA EXTRA API tests eval "${sudo_cmd} $timeout_exe env GTEST_TAP=2 LD_PRELOAD=$gtest_lib $gtest_app $gtest_opt --gtest_filter=-vma_*:tcp_send_zc* --gtest_output=xml:${WORKSPACE}/${prefix}/test-basic.xml" rc=$(($rc+$?)) +eval "${sudo_cmd} $timeout_exe env GTEST_TAP=2 LD_PRELOAD=$gtest_lib $gtest_app $gtest_opt --gtest_filter=keep_alive* --gtest_output=xml:${WORKSPACE}/${prefix}/test-keepalive.xml" +rc=$(($rc+$?)) make -C tests/gtest clean make -C tests/gtest CPPFLAGS="-DEXTRA_API_ENABLED=1" rc=$(($rc+$?)) # Verify VMA EXTRA API tests -eval "${sudo_cmd} $timeout_exe env GTEST_TAP=2 LD_PRELOAD=$gtest_lib $gtest_app $gtest_opt --gtest_filter=vma_*:-vma_poll.*:vma_ring.*:vma_send_zc.* --gtest_output=xml:${WORKSPACE}/${prefix}/test-extra.xml" +eval "${sudo_cmd} $timeout_exe env GTEST_TAP=2 LD_PRELOAD=$gtest_lib $gtest_app $gtest_opt --gtest_filter=vma_*:-vma_ioctl.*:vma_poll.*:vma_ring.*:vma_send_zc.* --gtest_output=xml:${WORKSPACE}/${prefix}/test-extra.xml" +rc=$(($rc+$?)) + +# Verify VMA EXTRA API ioctl tests (should be launched alone) +eval "${sudo_cmd} $timeout_exe env GTEST_TAP=2 LD_PRELOAD=$gtest_lib $gtest_app $gtest_opt --gtest_filter=vma_ioctl.* --gtest_output=xml:${WORKSPACE}/${prefix}/test-extra.xml" rc=$(($rc+$?)) # Verify VMA EXTRA API socketxtreme mode tests diff --git a/contrib/jenkins_tests/rpm.sh b/contrib/jenkins_tests/rpm.sh index bcf0396a9d..27d7a67631 100755 --- a/contrib/jenkins_tests/rpm.sh +++ b/contrib/jenkins_tests/rpm.sh @@ -22,6 +22,8 @@ ${WORKSPACE}/configure --prefix=${rpm_dir}/install $jenkins_test_custom_configur if [ -x /usr/bin/dpkg-buildpackage ]; then echo "Build on debian" + ## To avoid "dpkg-checkbuilddeps: error: Unmet build dependencies: debhelper (>= 7)" on Ubuntu24.x + dpkg -l | grep -qw debhelper || apt-get install -y debhelper opt_rpm=0 else echo "Build rpms" @@ -46,9 +48,9 @@ test_id=0 if [ $opt_tarball -eq 1 ]; then # Automake 1.10.1 has a bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=456632 if [ -n "$(automake --version | grep 'automake (GNU automake) 1.10.1')" ]; then - test_exec='make dist' + test_exec='make $make_opt dist' else - test_exec='make dist && make distcheck' + test_exec='make $make_opt dist && make $make_opt distcheck' fi do_check_result "$test_exec" "$test_id" "tarball" "$rpm_tap" "${rpm_dir}/rpm-${test_id}" @@ -75,17 +77,50 @@ if [ $opt_binrpm -eq 1 ]; then if [ $opt_rpm -eq 1 ]; then test_exec="env RPM_BUILD_NCPUS=${NPROC} rpmbuild -bb $rpmmacros $rpmopts $rpmspec" else - test_exec="dpkg-buildpackage -us -uc -b $make_opt" + test_exec="dpkg-buildpackage -us -uc -b" fi do_check_result "$test_exec" "$test_id" "binrpm" "$rpm_tap" "${rpm_dir}/rpm-${test_id}" test_id=$((test_id+1)) fi if [ $opt_checkpkg -eq 1 ]; then - test_exec="env RPM_BUILD_NCPUS=${NPROC} VMA_RELEASE=1 ${WORKSPACE}/contrib/build_pkg.sh -b -s -i ${WORKSPACE} -o ${rpm_dir}/dist-pkg" + test_exec="env RPM_BUILD_NCPUS=${NPROC} PRJ_RELEASE=1 ${WORKSPACE}/contrib/build_pkg.sh -b -s -i ${WORKSPACE} -o ${rpm_dir}/dist-pkg" do_check_result "$test_exec" "$test_id" "checkpkg" "$rpm_tap" "${rpm_dir}/rpm-${test_id}" test_id=$((test_id+1)) fi +# check if we have email of indevidual users in the packages rpm/deb metadata Maintainer field +pacakges_location="$rpm_dir"/dist-pkg +email_log_file="$rpm_dir"/dist-pkg/email_scan.log +if [ $opt_rpm -eq 1 ]; then + search_filter="*.rpm" + test_info_exec="rpm -qpi --changelog" +else + search_filter="*.deb" + test_info_exec="apt info" +fi + +# iterate on all packages and extarct the metadata to outout file +touch "$email_log_file" +find "$pacakges_location" -type f -name "$search_filter" -exec $test_info_exec {} \; | tee -a "$email_log_file" +do_archive "$email_log_file" +set +e + +# grep email strings exclude allowed email networking-support@nvidiacom +test_output=$(grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" "$email_log_file" | grep -v "networking-support") +test_rc=$? +set -e + +# check rc - grep will return 0 if it found such mail and 1 if not +if [[ $test_rc -eq 0 ]]; then + # if we found such mail we will get return code 0 + echo "ERROR: found bad email address $test_output" + rc=$((rc + 1)) +elif [[ -n "$test_output" ]]; then + # if we got rc not 0 and we have output it means something else failed + echo "ERROR: could not find bad email but something else failed: $test_output" + rc=$((rc + 1)) +fi + echo "[${0##*/}]..................exit code = $rc" exit $rc diff --git a/contrib/jenkins_tests/test.sh b/contrib/jenkins_tests/test.sh index 9fd987ec57..74abc461c3 100755 --- a/contrib/jenkins_tests/test.sh +++ b/contrib/jenkins_tests/test.sh @@ -19,17 +19,27 @@ rm -rf $test_dir mkdir -p $test_dir cd $test_dir +test_app="sockperf" + +# Download sockperf to use verifier do_cmd "wget -O sockperf_v2.zip https://github.com/Mellanox/sockperf/archive/sockperf_v2.zip && unzip sockperf_v2.zip && mv sockperf-sockperf_v2 sockperf" cd sockperf -./autogen.sh -./configure --prefix=$PWD/install CPPFLAGS="-I${install_dir}/include" -make install -test_app="$PWD/install/bin/sockperf" - -if [ $(command -v $test_app >/dev/null 2>&1 || echo $?) ]; then - echo can not find $test_app - exit 1 +# This unit requires sockperf so check for existence +if [ $(command -v ${test_app} >/dev/null 2>&1 || echo $?) ]; then + set +e + ./autogen.sh + ./configure --prefix=$PWD/install CPPFLAGS="-I${install_dir}/include" + make install + test_app="$PWD/install/bin/sockperf" + set -e + + if [ $(command -v ${test_app} >/dev/null 2>&1 || echo $?) ]; then + echo "[SKIP] $test_app does not exist" + exit 1 + fi +else + test_app="$(command -v ${test_app})" fi test_ip_list="" @@ -42,7 +52,7 @@ if [ ! -z "${test_remote_ip}" ] ; then exit 1 } test_ip_list="eth:${test_remote_ip}" - [ -z "${NODE_NAME}" ] && NODE_NAME=$(hostname) + [ -z "${NODE_NAME}" ] && NODE_NAME=${HOSTNAME} sperf_exec_dir="/tmp/sockperf_exec_${NODE_NAME}" rmt_user=root diff --git a/contrib/jenkins_tests/tool.sh b/contrib/jenkins_tests/tool.sh index 8652c2e252..7fd27e66f9 100755 --- a/contrib/jenkins_tests/tool.sh +++ b/contrib/jenkins_tests/tool.sh @@ -53,31 +53,6 @@ function check_daemon() if [ "0" == "$ret" -a "" != "$(pgrep ${prj_service})" ]; then ret=1 fi - else - service=${install_dir}/etc/init.d/vma - service_arg="" - - echo "System has been booted with SystemV" >> ${out_log} - echo "daemon check output: ${service}" >> ${out_log} - - if [ $(${sudo_cmd} ${service} start >>${out_log} 2>&1 || echo $?) ]; then - ret=1 - fi - sleep 3 - if [ "0" == "$ret" -a "" == "$(pgrep ${prj_service})" ]; then - ret=1 - fi - if [ $(${sudo_cmd} ${service} status >>${out_log} 2>&1 || echo $?) ]; then - ret=1 - fi - if [ $(${sudo_cmd} ${service} stop >>${out_log} 2>&1 || echo $?) ]; then - ret=1 - fi - sleep 3 - # Under docker containers service can be a zombie after killing - if [ "0" == "$ret" -a "" != "$(ps aux | grep ${prj_service} | egrep -v 'grep|defunct')" ]; then - ret=1 - fi fi eval "${sudo_cmd} pkill -9 ${prj_service} 2>/dev/null || true" diff --git a/contrib/jenkins_tests/vg.sh b/contrib/jenkins_tests/vg.sh index f7e57bbf07..5b397e3f6c 100755 --- a/contrib/jenkins_tests/vg.sh +++ b/contrib/jenkins_tests/vg.sh @@ -21,11 +21,11 @@ rc=$? test_ip_list="" -#if [ ! -z $(do_get_ip 'ib' 'mlx5') ]; then -# test_ip_list="${test_ip_list} ib:$(do_get_ip 'ib' 'mlx5')" +#if [ ! -z $(do_get_ip 'ib') ]; then +# test_ip_list="${test_ip_list} ib:$(do_get_ip 'ib')" #fi -if [ ! -z "$(do_get_ip 'eth' 'mlx5')" ]; then - test_ip_list="${test_ip_list} eth:$(do_get_ip 'eth' 'mlx5')" +if [ ! -z "$(do_get_ip 'eth')" ]; then + test_ip_list="${test_ip_list} eth_ip4:$(do_get_ip 'eth')" fi test_list="tcp:--tcp udp:" test_lib=${vg_dir}/install/lib/${prj_lib} @@ -41,7 +41,7 @@ if [ $(command -v $test_app_path >/dev/null 2>&1 || echo $?) ]; then ./autogen.sh ./configure --prefix=$PWD/install CPPFLAGS="-I${install_dir}/include" - make install + make $make_opt install test_app_path="$PWD/install/bin/sockperf" cd $vg_dir @@ -68,7 +68,7 @@ for test_link in $test_ip_list; do test_name=${test_in}-${test_n} vg_args="-v \ - --memcheck:leak-check=full --track-origins=yes --read-var-info=yes \ + --memcheck:leak-check=full --track-origins=yes --fair-sched=yes --read-var-info=yes \ --errors-for-leak-kinds=definite --show-leak-kinds=definite,possible \ --undef-value-errors=yes --track-fds=yes --num-callers=32 \ --fullpath-after=${WORKSPACE} --gen-suppressions=all \ @@ -95,7 +95,7 @@ for test_link in $test_ip_list; do if [ `ps -ef | grep $test_app | wc -l` -gt 1 ]; then - ${sudo_cmd} pkill -9 -f $test_app 2>/dev/null || true + ${sudo_cmd} pkill -SIGINT -f $test_app 2>/dev/null || true sleep 10 # in case SIGINT didn't work if [ `ps -ef | grep $test_app | wc -l` -gt 1 ]; diff --git a/contrib/jenkins_tests/vutil.sh b/contrib/jenkins_tests/vutil.sh index 53c741c36b..bd4a2125ef 100755 --- a/contrib/jenkins_tests/vutil.sh +++ b/contrib/jenkins_tests/vutil.sh @@ -1,6 +1,6 @@ #!/bin/bash -HOST=$(hostname) +HOST=${HOSTNAME} server_success_msgs="'Test end', 'interrupted by', 'exit'" server_failure_msgs="'Segmentation fault', 'Assertion', 'ERROR'" diff --git a/contrib/scripts/libvma.spec.in b/contrib/scripts/libvma.spec.in index 9117f268bb..b378b95483 100644 --- a/contrib/scripts/libvma.spec.in +++ b/contrib/scripts/libvma.spec.in @@ -4,7 +4,7 @@ %{!?make_build: %global make_build %{__make} %{?_smp_mflags} %{?mflags} V=1} %{!?run_ldconfig: %global run_ldconfig %{?ldconfig}} %{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}} -%global use_systemd %(if systemctl >/dev/null 2>&1; then echo -n '1'; else echo -n '0'; fi) +%global use_systemd %(if command -v systemctl >/dev/null 2>&1; then echo -n '1'; else echo -n '0'; fi) Name: libvma Version: @VERSION@ @@ -112,7 +112,7 @@ install -m 755 ./%{name}-debug.so $RPM_BUILD_ROOT/%{_libdir}/%{name}-debug.so %{run_ldconfig} %endif if [ $1 = 1 ]; then - if systemctl >/dev/null 2>&1; then + if command -v systemctl >/dev/null 2>&1; then %if 0%{?rhel} >= 9 || 0%{?fedora} >= 30 || 0%{?suse_version} >= 1210 %if 0%{?suse_version} %service_add_post vma.service @@ -122,18 +122,12 @@ if [ $1 = 1 ]; then %else systemctl --no-reload enable vma.service >/dev/null 2>&1 || true %endif - elif [ -e /sbin/chkconfig ]; then - /sbin/chkconfig --add vma - elif [ -e /usr/sbin/update-rc.d ]; then - /usr/sbin/update-rc.d vma defaults - else - %{_libdir}/lsb/install_initd %{_sysconfdir}/init.d/vma fi fi %preun if [ $1 = 0 ]; then - if systemctl >/dev/null 2>&1; then + if command -v systemctl >/dev/null 2>&1; then %if 0%{?rhel} >= 9 || 0%{?fedora} >= 30 || 0%{?suse_version} >= 1210 %if 0%{?suse_version} %service_del_preun vma.service @@ -144,15 +138,6 @@ if [ $1 = 0 ]; then systemctl --no-reload disable vma.service >/dev/null 2>&1 || true systemctl stop vma.service || true %endif - elif [ -e /sbin/chkconfig ]; then - %{_sysconfdir}/init.d/vma stop - /sbin/chkconfig --del vma - elif [ -e /usr/sbin/update-rc.d ]; then - %{_sysconfdir}/init.d/vma stop - /usr/sbin/update-rc.d -f vma remove - else - %{_sysconfdir}/init.d/vma stop - %{_libdir}/lsb/remove_initd %{_sysconfdir}/init.d/vma fi fi @@ -162,7 +147,7 @@ fi %else %{run_ldconfig} %endif -if systemctl >/dev/null 2>&1; then +if command -v systemctl >/dev/null 2>&1; then %if 0%{?rhel} >= 9 || 0%{?fedora} >= 30 || 0%{?suse_version} >= 1210 %if 0%{?suse_version} %service_del_postun vma.service @@ -183,8 +168,6 @@ fi %{_sbindir}/vmad %if "%{use_systemd}" == "1" %{_prefix}/lib/systemd/system/vma.service -%else -%{_sysconfdir}/init.d/vma %endif %{_mandir}/man7/vma.* %{_mandir}/man8/vmad.* @@ -204,7 +187,7 @@ fi %{_mandir}/man8/vma_stats.* %changelog -* Mon Oct 24 2022 NVIDIA CORPORATION 9.7.1-1 -- Bump version to 9.7.1 +* Thu Jan 8 2026 NVIDIA CORPORATION 9.8.84-1 +- Bump version to 9.8.84 - Please refer to CHANGES for full changelog. diff --git a/contrib/scripts/vma.init.in b/contrib/scripts/vma.init.in index 1f2a7adea2..b0e0b18e57 100644 --- a/contrib/scripts/vma.init.in +++ b/contrib/scripts/vma.init.in @@ -1,34 +1,8 @@ #!/bin/bash # -# Copyright © 2001-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # # vma: Start the VMA Daemon diff --git a/contrib/test_jenkins.sh b/contrib/test_jenkins.sh index 21e09ff356..179ee543b7 100755 --- a/contrib/test_jenkins.sh +++ b/contrib/test_jenkins.sh @@ -2,7 +2,7 @@ # # Testing script for VMA, to run from Jenkins CI # -# Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # See file LICENSE for terms. # @@ -15,7 +15,7 @@ echo "======================================================" echo -echo "# starting on host ---------> $(hostname 2>/dev/null) " +echo "# starting on host ---------> ${HOSTNAME} " echo "# arguments called with ----> ${@} " echo "# path to me ---------------> ${0} " echo "# parent path --------------> ${0%/*} " @@ -54,10 +54,12 @@ echo "# BUILD_NUMBER -------------> ${BUILD_NUMBER} " echo "# TARGET -------------------> ${TARGET} " echo +# When create artifact # Values: none, fail, always # jenkins_opt_artifacts=${jenkins_opt_artifacts:="always"} +# Stop verification after number of erros # Values: 0..N test (max 100) # jenkins_opt_exit=${jenkins_opt_exit:="6"} @@ -95,22 +97,9 @@ do_check_env TARGET=${TARGET:=all} i=0 if [ "$TARGET" == "all" -o "$TARGET" == "default" ]; then - target_list[$i]="default: --disable-tso" + target_list[$i]="default: " i=$((i+1)) fi -if [ "$TARGET" == "all" -o "$TARGET" == "extra" ]; then - target_list[$i]="extra: --enable-tso" - i=$((i+1)) -fi -if [ "$TARGET" == "all" -o "$TARGET" == "dpcp" ]; then - do_check_dpcp opt_value - if [ ! -z "${opt_value}" ]; then - target_list[$i]="dpcp: --enable-tso --enable-nginx --with-dpcp=${opt_value}" - i=$((i+1)) - else - echo "Requested dpcp support can not be executed" - fi -fi echo echo "======================================================" @@ -124,7 +113,7 @@ for target_v in "${target_list[@]}"; do ret=0 IFS=':' read target_name target_option <<< "$target_v" - export jenkins_test_artifacts="${WORKSPACE}/${prefix}/vma-${BUILD_NUMBER}-$(hostname -s)-${target_name}" + export jenkins_test_artifacts="${WORKSPACE}/${prefix}/vma-${BUILD_NUMBER}-${HOSTNAME}-${target_name}" export jenkins_test_custom_configure="${jenkins_test_custom_configure} ${target_option}" export jenkins_target="${target_name}" set +x diff --git a/contrib/valgrind/valgrind_vma.supp b/contrib/valgrind/valgrind_vma.supp index 1fac86aa16..12bdce8fe0 100644 --- a/contrib/valgrind/valgrind_vma.supp +++ b/contrib/valgrind/valgrind_vma.supp @@ -491,6 +491,33 @@ fun:_ZN6ServerI10IoRecvfrom9SwitchOffS1_E13server_acceptEi fun:_ZN6ServerI10IoRecvfrom9SwitchOffS1_E6doLoopEv } +{ + sockperf_free_check + Memcheck:Free + fun:free + fun:_Z9close_ifdiiP8fds_data + fun:server_receive_then_send_impl + fun:server_receive_then_send<> + fun:_ZN6ServerI10IoRecvfrom9SwitchOffE6doLoopEv + fun:doHandler + fun:server_handler + fun:_Z14server_handlerI10IoRecvfromEviii + fun:_Z7do_testv + fun:main +} +{ + sockperf_leak_on_sigint + Memcheck:Leak + match-leak-kinds: definite + fun:_Znwm + fun:_ZN6ServerI10IoRecvfrom9SwitchOffE13server_acceptEi + fun:_ZN6ServerI10IoRecvfrom9SwitchOffE6doLoopEv + fun:doHandler + fun:server_handler + fun:_Z14server_handlerI10IoRecvfromEviii + fun:_Z7do_testv + fun:main +} ########################################################### # libnl1 { diff --git a/debian/copyright b/debian/copyright index bd3b5ff20f..52d7d5385e 100644 --- a/debian/copyright +++ b/debian/copyright @@ -3,7 +3,7 @@ Upstream-Name: libvma Source: https://github.com/Mellanox/libvma Files: * -Copyright: 2001-2022 NVIDIA CORPORATION & AFFILIATES. +Copyright: 2001-2026 NVIDIA CORPORATION & AFFILIATES. License: GPL-2 or BSD * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -46,7 +46,7 @@ Copyright: 2007-2008, Swinburne University of Technology, Melbourne, Australia. 2009-2010, Lawrence Stewart 2010, The FreeBSD Foundation - 2001-2022 NVIDIA CORPORATION & AFFILIATES. + 2001-2023 NVIDIA CORPORATION & AFFILIATES. License: GPL-2 and 2BSD Files: src/vma/lwip/def.h diff --git a/debian/postinst b/debian/postinst index 4b400db495..4d6f157e40 100644 --- a/debian/postinst +++ b/debian/postinst @@ -2,12 +2,6 @@ /sbin/ldconfig -if systemctl >/dev/null 2>&1; then +if command -v systemctl >/dev/null 2>&1; then systemctl --no-reload enable vma.service >/dev/null 2>&1 || true -elif [ -e /sbin/chkconfig ]; then - /sbin/chkconfig --add vma || true -elif [ -e /usr/sbin/update-rc.d ]; then - /usr/sbin/update-rc.d vma defaults || true -else - /usr/lib/lsb/install_initd /etc/init.d/vma || true fi diff --git a/debian/postrm b/debian/postrm index 401aea5846..4750f5e5bd 100644 --- a/debian/postrm +++ b/debian/postrm @@ -1,5 +1,5 @@ #!/bin/bash /sbin/ldconfig -if systemctl >/dev/null 2>&1; then +if command -v systemctl >/dev/null 2>&1; then systemctl --system daemon-reload >/dev/null 2>&1 || true fi diff --git a/debian/prerm b/debian/prerm index 3e66bd060f..aa5723f245 100644 --- a/debian/prerm +++ b/debian/prerm @@ -1,15 +1,6 @@ #!/bin/bash -if systemctl >/dev/null 2>&1; then +if command -v systemctl >/dev/null 2>&1; then systemctl --no-reload disable vma.service >/dev/null 2>&1 || true systemctl stop vma.service || true -elif [ -e /sbin/chkconfig ]; then - /etc/init.d/vma stop || true - /sbin/chkconfig --del vma || true -elif [ -e /usr/sbin/update-rc.d ]; then - /etc/init.d/vma stop || true - /usr/sbin/update-rc.d -f vma remove || true -else - /etc/init.d/vma stop || true - /usr/lib/lsb/remove_initd /etc/init.d/vma || true fi diff --git a/docs/man/vma.7.in b/docs/man/vma.7.in index 111151237f..8775eb3675 100644 --- a/docs/man/vma.7.in +++ b/docs/man/vma.7.in @@ -39,4 +39,4 @@ VMA Library version information. .SH "AUTHORS" .TP -Igor Ivanov +NVIDIA CORPORATION diff --git a/docs/man/vma_stats.8.in b/docs/man/vma_stats.8.in index 9609a464cc..228f9b71c2 100644 --- a/docs/man/vma_stats.8.in +++ b/docs/man/vma_stats.8.in @@ -67,4 +67,4 @@ Print version. .SH "AUTHORS" .TP -Igor Ivanov +NVIDIA CORPORATION diff --git a/docs/man/vmad.8.in b/docs/man/vmad.8.in index 08e9816c61..78e800171b 100644 --- a/docs/man/vmad.8.in +++ b/docs/man/vmad.8.in @@ -38,4 +38,4 @@ Output verbose level .SH "AUTHORS" .TP -Igor Ivanov +NVIDIA CORPORATION diff --git a/src/state_machine/main.cpp b/src/state_machine/main.cpp index c4f2046fdc..da51ded9eb 100644 --- a/src/state_machine/main.cpp +++ b/src/state_machine/main.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/state_machine/sm.cpp b/src/state_machine/sm.cpp index aeb97b0d12..5b4ec2b88b 100644 --- a/src/state_machine/sm.cpp +++ b/src/state_machine/sm.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -250,6 +224,7 @@ BULLSEYE_EXCLUDE_BLOCK_END // Run print event info function if (m_new_event_notify_func) { + /* coverity[check_return] */ m_new_event_notify_func(get_curr_state(), event, m_info.app_hndl); } diff --git a/src/state_machine/sm.h b/src/state_machine/sm.h index 68da0df255..29caf30720 100644 --- a/src/state_machine/sm.h +++ b/src/state_machine/sm.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/state_machine/sm_fifo.cpp b/src/state_machine/sm_fifo.cpp index 66fad7c01f..02f6a21ceb 100644 --- a/src/state_machine/sm_fifo.cpp +++ b/src/state_machine/sm_fifo.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/state_machine/sm_fifo.h b/src/state_machine/sm_fifo.h index a075c5562e..d633624f22 100644 --- a/src/state_machine/sm_fifo.h +++ b/src/state_machine/sm_fifo.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/stats/stats_data_reader.h b/src/stats/stats_data_reader.h index 8cdf991fdd..eac4a77693 100644 --- a/src/stats/stats_data_reader.h +++ b/src/stats/stats_data_reader.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/stats/stats_printer.cpp b/src/stats/stats_printer.cpp index eade1ea6c0..45ee2a94e0 100644 --- a/src/stats/stats_printer.cpp +++ b/src/stats/stats_printer.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifdef HAVE_CONFIG_H diff --git a/src/stats/stats_publisher.cpp b/src/stats/stats_publisher.cpp index 2198b9f745..601d4f8119 100644 --- a/src/stats/stats_publisher.cpp +++ b/src/stats/stats_publisher.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -227,7 +201,6 @@ void vma_shmem_stats_open(vlog_levels_t** p_p_vma_log_level, uint8_t** p_p_vma_l p_shmem = g_sh_mem_info.p_sh_stats; free(buf); - buf = NULL; goto success; diff --git a/src/stats/stats_reader.cpp b/src/stats/stats_reader.cpp index 107f5e8770..8ddaef5d8c 100644 --- a/src/stats/stats_reader.cpp +++ b/src/stats/stats_reader.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifdef HAVE_CONFIG_H @@ -116,7 +90,7 @@ typedef enum { #define VLOG_DETAILS_NUM 4 #define INIT_VMA_LOG_DETAILS -1 #define NANO_TO_MICRO(n) (((n) + 500) / 1000) -#define SEC_TO_MICRO(n) ((n) * 1000000) +#define SEC_TO_MICRO(n) ((n)*1000000ULL) #define TIME_DIFF_in_MICRO(start,end) (SEC_TO_MICRO((end).tv_sec-(start).tv_sec) + \ (NANO_TO_MICRO((end).tv_nsec-(start).tv_nsec))) // printf formating when IP is in network byte ordering (for LITTLE_ENDIAN) @@ -281,6 +255,7 @@ void print_ring_stats(ring_instance_block_t* p_ring_inst_arr) strcpy(post_fix, "/s"); for (int i = 0; i < NUM_OF_SUPPORTED_RINGS; i++) { + // coverity[missing_lock:FALSE] /* Turn off coverity missing_lock check */ if (p_ring_inst_arr[i].b_enabled) { p_ring_stats = &p_ring_inst_arr[i].ring_stats; printf("======================================================\n"); @@ -331,6 +306,7 @@ void print_cq_stats(cq_instance_block_t* p_cq_inst_arr) strcpy(post_fix, "/s"); for (int i = 0; i < NUM_OF_SUPPORTED_CQS; i++) { + // coverity[missing_lock:FALSE] /* Turn off coverity missing_lock check */ if (p_cq_inst_arr[i].b_enabled) { p_cq_stats = &p_cq_inst_arr[i].cq_stats; printf("======================================================\n"); @@ -353,6 +329,7 @@ void print_bpool_stats(bpool_instance_block_t* p_bpool_inst_arr) strcpy(post_fix, "/s"); for (int i = 0; i < NUM_OF_SUPPORTED_BPOOLS; i++) { + // coverity[missing_lock:FALSE] /* Turn off coverity missing_lock check */ if (p_bpool_inst_arr && p_bpool_inst_arr[i].b_enabled) { p_bpool_stats = &p_bpool_inst_arr[i].bpool_stats; printf("======================================================\n"); @@ -558,17 +535,19 @@ int show_socket_stats(socket_instance_block_t* p_instance, socket_instance_block size_t fd = (size_t)p_instance[i].skt_stats.fd; if (p_instance[i].b_enabled && g_fd_mask[fd]) { num_act_inst++; + socket_instance_block_t *prev_inst = + p_prev_instance_block ? &p_prev_instance_block[i] : NULL; switch (user_params.view_mode) { case e_basic: - show_basic_stats(&p_instance[i], &p_prev_instance_block[i]); + show_basic_stats(&p_instance[i], prev_inst); *p_printed_lines_num += BASIC_STATS_LINES_NUM; break; case e_medium: - print_medium_stats(&p_instance[i], &p_prev_instance_block[i]); + print_medium_stats(&p_instance[i], prev_inst); *p_printed_lines_num += MEDIUM_STATS_LINES_NUM; break; case e_full: - show_full_stats(&p_instance[i], &p_prev_instance_block[i], p_mc_grp_info); + show_full_stats(&p_instance[i], prev_inst, p_mc_grp_info); break; case e_netstat_like: print_netstat_like(&p_instance[i].skt_stats, p_mc_grp_info, g_stats_file, pid); @@ -682,6 +661,9 @@ void print_full_iomux_deltas(iomux_stats_t* p_curr_iomux_stats, iomux_stats_t* p void print_basic_iomux_deltas(iomux_stats_t* p_curr_stats, iomux_stats_t* p_prev_stats, int* p_printed_lines_num) { + if (unlikely(!p_curr_stats || !p_prev_stats)) { + return; + } update_iomux_deltas(p_curr_stats, p_prev_stats); print_iomux_totals(p_prev_stats, p_printed_lines_num); } @@ -840,7 +822,8 @@ void show_mc_group_stats(mc_grp_info_t* p_mc_grp_info , socket_instance_block_t* for (uint32_t i=0; i < num_of_obj; i++) { size_t fd = (size_t)p_instance[i].skt_stats.fd; if (p_instance[i].b_enabled && g_fd_mask[fd]) { - socket_stats_t* p_si_stats = &p_instance[i].skt_stats; + socket_stats_t* p_si_stats = &p_instance[i].skt_stats; + // coverity[missing_lock:FALSE] /* Turn off coverity missing_lock check */ for (int grp_idx = 0; grp_idx < p_mc_grp_info->max_grp_num; grp_idx++) { if (p_si_stats->mc_grp_map.test(grp_idx)) { //printf("fd %d Member of = [%d.%d.%d.%d]\n",p_si_stats->fd, NIPQUAD(p_si_stats->mc_grp[grp_idx])); @@ -965,9 +948,8 @@ bool check_if_process_running(char* pid_str) { char proccess_proc_dir[FILE_NAME_MAX_SIZE] = {0}; struct stat st; - int n = -1; + int n = snprintf(proccess_proc_dir, sizeof(proccess_proc_dir), "/proc/%s", pid_str); - n = snprintf(proccess_proc_dir, sizeof(proccess_proc_dir), "/proc/%s", pid_str); if (likely((0 < n) && (n < (int)sizeof(proccess_proc_dir)))) { return stat(proccess_proc_dir, &st) == 0; } @@ -977,9 +959,8 @@ bool check_if_process_running(char* pid_str) bool check_if_process_running(int pid) { char pid_str[MAX_BUFF_SIZE] = {0}; - int n = -1; - - n = snprintf(pid_str, sizeof(pid_str), "%d", pid); + int n = snprintf(pid_str, sizeof(pid_str), "%d", pid); + if (likely((0 < n) && (n < (int)sizeof(pid_str)))) { return check_if_process_running(pid_str); } @@ -1078,6 +1059,7 @@ void stats_reader_handler(sh_mem_t* p_sh_mem, int pid) } switch (user_params.print_details_mode) { case e_totals: + /* coverity[forward_null] */ num_act_inst = show_socket_stats(p_sh_mem->skt_inst_arr, NULL, p_sh_mem->max_skt_inst_num, &printed_line_num, &p_sh_mem->mc_info, pid); show_iomux_stats(&p_sh_mem->iomux, NULL, &printed_line_num); if (user_params.view_mode == e_full) { @@ -1135,9 +1117,8 @@ bool check_if_app_match(char* app_name, char* pid_str) char app_full_name[PATH_MAX] = {0}; char proccess_proc_dir[FILE_NAME_MAX_SIZE] = {0}; char* app_base_name = NULL; - int n = -1; + int n = snprintf(proccess_proc_dir, sizeof(proccess_proc_dir), "/proc/%s/exe", pid_str); - n = snprintf(proccess_proc_dir, sizeof(proccess_proc_dir), "/proc/%s/exe", pid_str); if (likely((0 < n) && (n < (int)sizeof(proccess_proc_dir)))) { n = readlink(proccess_proc_dir, app_full_name, sizeof(app_full_name) - 1); if (n > 0) { @@ -1171,9 +1152,8 @@ void clean_inactive_sh_ibj() proccess_running = check_if_process_running(dirent->d_name + pid_offset); if (!proccess_running) { char to_delete[PATH_MAX + 1] = {0}; - int n = -1; - - n = snprintf(to_delete, sizeof(to_delete), "%s/%s", user_params.vma_stats_path.c_str(), dirent->d_name); + int n = snprintf(to_delete, sizeof(to_delete), "%s/%s", user_params.vma_stats_path.c_str(), dirent->d_name); + if (likely((0 < n) && (n < (int)sizeof(to_delete)))) { unlink(to_delete); } diff --git a/src/utils/asm-arm64.h b/src/utils/asm-arm64.h index 60762e0b1d..a04337e3ab 100644 --- a/src/utils/asm-arm64.h +++ b/src/utils/asm-arm64.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2014-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/utils/asm-ppc64.h b/src/utils/asm-ppc64.h index 1c7c16e535..07ba8f7124 100644 --- a/src/utils/asm-ppc64.h +++ b/src/utils/asm-ppc64.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2014-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/utils/asm-x86.h b/src/utils/asm-x86.h index 95380cb504..bd57d5a7bb 100644 --- a/src/utils/asm-x86.h +++ b/src/utils/asm-x86.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/utils/asm.h b/src/utils/asm.h index a99353ea3f..bb0c835413 100644 --- a/src/utils/asm.h +++ b/src/utils/asm.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/utils/atomic.h b/src/utils/atomic.h index 2c0d4efcdd..7b0b707f2f 100644 --- a/src/utils/atomic.h +++ b/src/utils/atomic.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/utils/bullseye.h b/src/utils/bullseye.h index 3de32085d6..56a51a1706 100644 --- a/src/utils/bullseye.h +++ b/src/utils/bullseye.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/utils/clock.h b/src/utils/clock.h index 241dbde777..e1f63479d0 100644 --- a/src/utils/clock.h +++ b/src/utils/clock.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/utils/compiler.h b/src/utils/compiler.h index 399aa3068c..288db44460 100644 --- a/src/utils/compiler.h +++ b/src/utils/compiler.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/utils/lock_wrapper.h b/src/utils/lock_wrapper.h index 8379541d24..8d072fba7a 100644 --- a/src/utils/lock_wrapper.h +++ b/src/utils/lock_wrapper.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -221,6 +195,7 @@ class lock_spin_recursive : public lock_spin inline int lock() { DEFINED_NO_THREAD_LOCK_RETURN_0 pthread_t self = pthread_self(); + // coverity[use_same_locks_for_read_and_modify:FALSE] if (m_owner == self) { ++m_lock_count; return 0; diff --git a/src/utils/rdtsc.h b/src/utils/rdtsc.h index a6f23d3e50..93875c1793 100644 --- a/src/utils/rdtsc.h +++ b/src/utils/rdtsc.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/utils/types.h b/src/utils/types.h index 1af2e4e3ac..41de822340 100644 --- a/src/utils/types.h +++ b/src/utils/types.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vlogger/main.cpp b/src/vlogger/main.cpp index 7c135966c9..db44cd85f3 100644 --- a/src/vlogger/main.cpp +++ b/src/vlogger/main.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vlogger/vlogger.cpp b/src/vlogger/vlogger.cpp index c2b31643c2..b6d53e90b7 100644 --- a/src/vlogger/vlogger.cpp +++ b/src/vlogger/vlogger.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vlogger/vlogger.h b/src/vlogger/vlogger.h index de2b358f4d..7f2dc98c41 100644 --- a/src/vlogger/vlogger.h +++ b/src/vlogger/vlogger.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/Makefile.am b/src/vma/Makefile.am index 1fd5f43735..ddc0fa7f59 100644 --- a/src/vma/Makefile.am +++ b/src/vma/Makefile.am @@ -51,7 +51,7 @@ AM_CPPFLAGS := \ libvma_la_LDFLAGS := -no-undefined -version-number @PRJ_LIBRARY_MAJOR@:@PRJ_LIBRARY_MINOR@:@PRJ_LIBRARY_REVISION@ libvma_la_LIBADD = \ - -lrt -ldl -lpthread $(LIBNL_LIBS) $(VERBS_LIBS) $(DPCP_LIBS) \ + -lrt -ldl -lpthread $(LIBNL_LIBS) $(VERBS_LIBS) \ $(top_builddir)/src/utils/libutils.la \ $(top_builddir)/src/vlogger/libvlogger.la \ $(top_builddir)/src/state_machine/libstate_machine.la \ @@ -83,7 +83,6 @@ libvma_la_SOURCES := \ dev/net_device_entry.cpp \ dev/net_device_table_mgr.cpp \ dev/wqe_send_handler.cpp \ - dev/wqe_send_ib_handler.cpp \ dev/ring.cpp \ dev/ring_bond.cpp \ dev/ring_slave.cpp \ @@ -100,8 +99,6 @@ libvma_la_SOURCES := \ \ ib/base/verbs_extra.cpp \ ib/mlx5/ib_mlx5.cpp \ - ib/mlx5/ib_mlx5_hw.cpp \ - ib/mlx5/ib_mlx5_dv.cpp \ \ iomux/epfd_info.cpp \ iomux/epoll_wait_call.cpp \ @@ -137,8 +134,6 @@ libvma_la_SOURCES := \ proto/dst_entry_tcp.cpp \ proto/header.cpp \ proto/arp.cpp \ - proto/igmp_mgr.cpp \ - proto/igmp_handler.cpp \ \ sock/sockinfo.cpp \ sock/sockinfo_udp.cpp \ @@ -190,7 +185,6 @@ libvma_la_SOURCES := \ dev/ring_profile.h \ dev/ring_allocation_logic.h \ dev/wqe_send_handler.h \ - dev/wqe_send_ib_handler.h \ \ event/command.h \ event/delta_timer.h \ @@ -205,8 +199,6 @@ libvma_la_SOURCES := \ \ ib/base/verbs_extra.h \ ib/mlx5/ib_mlx5.h \ - ib/mlx5/ib_mlx5_hw.h \ - ib/mlx5/ib_mlx5_dv.h \ \ infra/sender.h \ infra/sender_info_dst.h \ @@ -245,14 +237,11 @@ libvma_la_SOURCES := \ proto/dst_entry_udp_mc.h \ proto/flow_tuple.h \ proto/header.h \ - proto/igmp_handler.h \ - proto/igmp_mgr.h \ proto/ip_address.h \ proto/ip_frag.h \ proto/L2_address.h \ proto/mem_buf_desc.h \ proto/neighbour.h \ - proto/neighbour_observer.h \ proto/neighbour_table_mgr.h \ proto/netlink_socket_mgr.h \ proto/peer_key.h \ diff --git a/src/vma/config_parser.c b/src/vma/config_parser.c index 18f8a2ef98..5ac24e1622 100644 --- a/src/vma/config_parser.c +++ b/src/vma/config_parser.c @@ -1984,6 +1984,7 @@ yyparse () yymsgp = yymsg; } } + /* coverity[uninit_use_in_call:FALSE] */ yyerror (yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; @@ -2148,6 +2149,13 @@ int yyerror(const char *msg) char *orig_msg = (char*)malloc(strlen(msg)+25); char *final_msg = (char*)malloc(strlen(msg)+25); + if (!orig_msg || !final_msg) { + __vma_log(9, "Error: Failed to allocate memory for an error message\n"); + free(orig_msg); + free(final_msg); + return 1; + } + strcpy(orig_msg, msg); char *word = strtok(orig_msg, " "); diff --git a/src/vma/config_scanner.c b/src/vma/config_scanner.c index 7756b92f4b..6e98083334 100644 --- a/src/vma/config_scanner.c +++ b/src/vma/config_scanner.c @@ -756,35 +756,9 @@ int libvma_yy_flex_debug = 0; char *libvma_yytext; /* Line 1 of config_scanner.l */ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause * * $Id: ibnl_scanner.ll,v 1.4 2005/02/23 21:08:37 eitan Exp $ */ @@ -1045,8 +1019,9 @@ YY_DECL */ yy_bp = yy_cp; - /* coverity[var_deref_op] */ + // coverity[var_deref_op:FALSE] /* Turn off coverity check for null deref */ yy_current_state = (yy_start); + // coverity[var_deref_op:FALSE] /* Turn off coverity check for null deref */ yy_current_state += YY_AT_BOL(); yy_match: do @@ -1945,7 +1920,8 @@ static void libvma_yy_load_buffer_state (void) b->yy_bs_column = 0; } - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + int fd = file ? fileno(file) : -1; + b->yy_is_interactive = (fd >= 0 && isatty(fd) > 0) ? 1 : 0; errno = oerrno; } diff --git a/src/vma/dev/allocator.cpp b/src/vma/dev/allocator.cpp index 1276496810..fd2fb2334e 100644 --- a/src/vma/dev/allocator.cpp +++ b/src/vma/dev/allocator.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include @@ -44,6 +18,26 @@ vma_allocator::vma_allocator() m_length = 0; m_data_block = NULL; m_mem_alloc_type = safe_mce_sys().mem_alloc_type; + m_memalloc = NULL; + m_memfree = NULL; + + __log_info_dbg("Done"); +} + +vma_allocator::vma_allocator(alloc_t alloc_func, free_t free_func) +{ + __log_info_dbg(""); + + m_shmid = -1; + m_length = 0; + m_data_block = NULL; + m_mem_alloc_type = safe_mce_sys().mem_alloc_type; + m_memalloc = alloc_func; + m_memfree = free_func; + if (m_memalloc && m_memfree) { + m_mem_alloc_type = ALLOC_TYPE_EXTERNAL; + __log_info_dbg("allocator uses external functions to allocate and free memory"); + } __log_info_dbg("Done"); } @@ -59,8 +53,12 @@ vma_allocator::~vma_allocator() return; } switch (m_mem_alloc_type) { - case ALLOC_TYPE_EXTERNAL: + case ALLOC_TYPE_REGISTER_MEMORY: // not allocated by us + break; + case ALLOC_TYPE_EXTERNAL: + m_memfree(m_data_block); + break; case ALLOC_TYPE_CONTIG: // freed as part of deregister_memory break; @@ -90,16 +88,29 @@ vma_allocator::~vma_allocator() void* vma_allocator::alloc_and_reg_mr(size_t size, ib_ctx_handler *p_ib_ctx_h, void *ptr /* NULL */) { - uint64_t access = VMA_IBV_ACCESS_LOCAL_WRITE; + uint64_t access = IBV_ACCESS_LOCAL_WRITE; if (ptr) { - m_mem_alloc_type = ALLOC_TYPE_EXTERNAL; + m_mem_alloc_type = ALLOC_TYPE_REGISTER_MEMORY; } switch (m_mem_alloc_type) { - case ALLOC_TYPE_EXTERNAL: + case ALLOC_TYPE_REGISTER_MEMORY: m_data_block = ptr; register_memory(size, p_ib_ctx_h, access); break; + case ALLOC_TYPE_EXTERNAL: + ptr = m_memalloc(size); + if (NULL == ptr) { + __log_info_warn("Failed allocating using external functions, " + "falling back to another memory allocation method" + "(errno=%d %m)", errno); + } else { + m_data_block = ptr; + m_length = size; + register_memory(m_length, p_ib_ctx_h, access); + break; + } + // fallthrough case ALLOC_TYPE_HUGEPAGES: if (!hugetlb_alloc(size)) { __log_info_dbg("Failed allocating huge pages, " @@ -113,9 +124,9 @@ void* vma_allocator::alloc_and_reg_mr(size_t size, ib_ctx_handler *p_ib_ctx_h, v } // fallthrough case ALLOC_TYPE_CONTIG: -#ifdef VMA_IBV_ACCESS_ALLOCATE_MR +#ifdef DEFINED_IBV_ACCESS_ALLOCATE_MR if (mce_sys_var::HYPER_MSHV != safe_mce_sys().hypervisor) { - register_memory(size, p_ib_ctx_h, (access | VMA_IBV_ACCESS_ALLOCATE_MR)); + register_memory(size, p_ib_ctx_h, (access | IBV_ACCESS_ALLOCATE_MR)); __log_info_dbg("Contiguous pages allocation passed successfully"); m_mem_alloc_type = ALLOC_TYPE_CONTIG; break; @@ -155,6 +166,7 @@ bool vma_allocator::hugetlb_alloc(size_t sz_bytes) if (!hugepagemask) { return false; } + // coverity[overflow:FALSE] /* Turn off coverity check for overflow */ hugepagemask -= 1; } @@ -283,7 +295,7 @@ void vma_allocator::register_memory(size_t size, ib_ctx_handler *p_ib_ctx_h, { ib_context_map_t *ib_ctx_map = NULL; ib_ctx_handler *p_ib_ctx_h_ref = p_ib_ctx_h; - uint32_t lkey = (uint32_t)(-1); + uint32_t lkey; bool failed = false; ib_ctx_map = g_p_ib_ctx_handler_collection->get_ib_cxt_list(); @@ -304,14 +316,15 @@ void vma_allocator::register_memory(size_t size, ib_ctx_handler *p_ib_ctx_h, } else { m_lkey_map_ib_ctx[p_ib_ctx_h] = lkey; if (NULL == m_data_block) { + /* coverity[dereference:FALSE] */ m_data_block = p_ib_ctx_h->get_mem_reg(lkey)->addr; } errno = 0; //ibv_reg_mr() set errno=12 despite successful returning -#ifdef VMA_IBV_ACCESS_ALLOCATE_MR - if ((access & VMA_IBV_ACCESS_ALLOCATE_MR) != 0) { // contig pages mode +#ifdef DEFINED_IBV_ACCESS_ALLOCATE_MR + if ((access & IBV_ACCESS_ALLOCATE_MR) != 0) { // contig pages mode // When using 'IBV_ACCESS_ALLOCATE_MR', ibv_reg_mr will return a pointer that its 'addr' field will hold the address of the allocated memory. // Second registration and above is done using 'IBV_ACCESS_LOCAL_WRITE' and the 'addr' we received from the first registration. - access &= ~VMA_IBV_ACCESS_ALLOCATE_MR; + access &= ~IBV_ACCESS_ALLOCATE_MR; } #endif __log_info_dbg("Registered memory on dev: %s addr=%p length=%lu", @@ -350,9 +363,9 @@ void vma_allocator::register_memory(size_t size, ib_ctx_handler *p_ib_ctx_h, void vma_allocator::deregister_memory() { - ib_ctx_handler *p_ib_ctx_h = NULL; - ib_context_map_t *ib_ctx_map = NULL; - uint32_t lkey = (uint32_t)(-1); + ib_ctx_handler *p_ib_ctx_h; + ib_context_map_t *ib_ctx_map; + uint32_t lkey; ib_ctx_map = g_p_ib_ctx_handler_collection->get_ib_cxt_list(); if (ib_ctx_map) { diff --git a/src/vma/dev/allocator.h b/src/vma/dev/allocator.h index 194ab046f8..1d7193f3bb 100644 --- a/src/vma/dev/allocator.h +++ b/src/vma/dev/allocator.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef SRC_VMA_DEV_ALLOCATOR_H_ @@ -43,6 +17,7 @@ typedef std::unordered_map lkey_map_ib_ctx_map_t; class vma_allocator { public: vma_allocator(); + vma_allocator(alloc_t alloc_func, free_t free_func); ~vma_allocator(); void* alloc_and_reg_mr(size_t size, ib_ctx_handler *p_ib_ctx_h, void *ptr = NULL); uint32_t find_lkey_by_ib_ctx(ib_ctx_handler *p_ib_ctx_h) const; @@ -58,6 +33,8 @@ class vma_allocator { size_t m_length; void *m_data_block; alloc_mode_t m_mem_alloc_type; + alloc_t m_memalloc; + free_t m_memfree; }; #endif /* SRC_VMA_DEV_ALLOCATOR_H_ */ diff --git a/src/vma/dev/buffer_pool.cpp b/src/vma/dev/buffer_pool.cpp index fea85ae161..97e3b72762 100644 --- a/src/vma/dev/buffer_pool.cpp +++ b/src/vma/dev/buffer_pool.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -74,11 +48,16 @@ void buffer_pool::free_tx_lwip_pbuf_custom(struct pbuf *p_buff) g_buffer_pool_tx->put_buffers_thread_safe((mem_buf_desc_t *)p_buff); } -buffer_pool::buffer_pool(size_t buffer_count, size_t buf_size, pbuf_free_custom_fn custom_free_function) : +buffer_pool::buffer_pool(size_t buffer_count, + size_t buf_size, + pbuf_free_custom_fn custom_free_function, + alloc_t alloc_func, + free_t free_func) : m_lock_spin("buffer_pool"), m_n_buffers(0), m_n_buffers_created(buffer_count), - m_p_head(NULL) + m_p_head(NULL), + m_allocator(alloc_func, free_func) { size_t sz_aligned_element = 0; uint8_t *ptr_buff, *ptr_desc; @@ -141,7 +120,7 @@ void buffer_pool::free_bpool_resources() void buffer_pool::register_memory(ib_ctx_handler *p_ib_ctx_h) { - m_allocator.register_memory(m_size, p_ib_ctx_h, VMA_IBV_ACCESS_LOCAL_WRITE); + m_allocator.register_memory(m_size, p_ib_ctx_h, IBV_ACCESS_LOCAL_WRITE); } void buffer_pool::print_val_tbl() diff --git a/src/vma/dev/buffer_pool.h b/src/vma/dev/buffer_pool.h index e25b551bed..a64782859a 100644 --- a/src/vma/dev/buffer_pool.h +++ b/src/vma/dev/buffer_pool.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -51,7 +25,11 @@ inline static void free_lwip_pbuf(struct pbuf_custom *pbuf_custom) class buffer_pool { public: - buffer_pool(size_t buffer_count, size_t size, pbuf_free_custom_fn custom_free_function); + buffer_pool(size_t buffer_count, + size_t size, + pbuf_free_custom_fn custom_free_function, + alloc_t alloc_func = NULL, + free_t free_func = NULL); ~buffer_pool(); void register_memory(ib_ctx_handler *p_ib_ctx_h); diff --git a/src/vma/dev/cq_mgr.cpp b/src/vma/dev/cq_mgr.cpp index 2182fe2e9c..9a47407709 100644 --- a/src/vma/dev/cq_mgr.cpp +++ b/src/vma/dev/cq_mgr.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -86,11 +60,9 @@ cq_mgr::cq_mgr(ring_simple* p_ring, ib_ctx_handler* p_ib_ctx_handler, int cq_siz ,m_n_sysvar_cq_poll_batch_max(safe_mce_sys().cq_poll_batch_max) ,m_n_sysvar_progress_engine_wce_max(safe_mce_sys().progress_engine_wce_max) ,m_p_cq_stat(&m_cq_stat_static) // use local copy of stats by default (on rx cq get shared memory stats) - ,m_transport_type(m_p_ring->get_transport_type()) ,m_p_next_rx_desc_poll(NULL) ,m_n_sysvar_rx_prefetch_bytes_before_poll(safe_mce_sys().rx_prefetch_bytes_before_poll) ,m_n_sysvar_rx_prefetch_bytes(safe_mce_sys().rx_prefetch_bytes) - ,m_sz_transport_header(0) ,m_p_ib_ctx_handler(p_ib_ctx_handler) ,m_n_sysvar_rx_num_wr_to_post_recv(safe_mce_sys().rx_num_wr_to_post_recv) ,m_comp_event_channel(p_comp_event_channel) @@ -119,38 +91,17 @@ cq_mgr::cq_mgr(ring_simple* p_ring, ib_ctx_handler* p_ib_ctx_handler, int cq_siz void cq_mgr::configure(int cq_size) { - vma_ibv_cq_init_attr attr; - memset(&attr, 0, sizeof(attr)); - - prep_ibv_cq(attr); - - m_p_ibv_cq = vma_ibv_create_cq(m_p_ib_ctx_handler->get_ibv_context(), - cq_size - 1, (void *)this, m_comp_event_channel, 0, &attr); + m_p_ibv_cq = ibv_create_cq(m_p_ib_ctx_handler->get_ibv_context(), + cq_size - 1, (void *)this, m_comp_event_channel, 0); BULLSEYE_EXCLUDE_BLOCK_START if (!m_p_ibv_cq) { throw_vma_exception("ibv_create_cq failed"); } BULLSEYE_EXCLUDE_BLOCK_END VALGRIND_MAKE_MEM_DEFINED(m_p_ibv_cq, sizeof(ibv_cq)); - switch (m_transport_type) { - case VMA_TRANSPORT_IB: - m_sz_transport_header = GRH_HDR_LEN; - break; - case VMA_TRANSPORT_ETH: - m_sz_transport_header = ETH_HDR_LEN; - break; - BULLSEYE_EXCLUDE_BLOCK_START - default: - cq_logpanic("Unknown transport type: %d", m_transport_type); - break; - BULLSEYE_EXCLUDE_BLOCK_END - } if (m_b_is_rx) { vma_stats_instance_create_cq_block(m_p_cq_stat); - } - - if (m_b_is_rx) { m_b_is_rx_hw_csum_on = vma_is_rx_hw_csum_supported(m_p_ib_ctx_handler->get_ibv_device_attr()); cq_logdbg("RX CSUM support = %d", m_b_is_rx_hw_csum_on); } @@ -158,13 +109,6 @@ void cq_mgr::configure(int cq_size) cq_logdbg("Created CQ as %s with fd[%d] and of size %d elements (ibv_cq_hndl=%p)", (m_b_is_rx?"Rx":"Tx"), get_channel_fd(), cq_size, m_p_ibv_cq); } -void cq_mgr::prep_ibv_cq(vma_ibv_cq_init_attr& attr) const -{ - if (m_p_ib_ctx_handler->get_ctx_time_converter_status()) { - vma_ibv_cq_init_ts_attr(&attr); - } -} - uint32_t cq_mgr::clean_cq() { uint32_t ret_total = 0; @@ -172,7 +116,7 @@ uint32_t cq_mgr::clean_cq() uint64_t cq_poll_sn = 0; mem_buf_desc_t* buff = NULL; /* coverity[stack_use_local_overflow] */ - vma_ibv_wc wce[MCE_MAX_CQ_POLL_BATCH]; + ibv_wc wce[MCE_MAX_CQ_POLL_BATCH]; while ((ret = poll(wce, MCE_MAX_CQ_POLL_BATCH, &cq_poll_sn)) > 0) { for (int i = 0; i < ret; i++) { if (m_b_is_rx) { @@ -330,7 +274,7 @@ void cq_mgr::return_extra_buffers() m_p_cq_stat->n_buffer_pool_len = m_rx_pool.size(); } -int cq_mgr::poll(vma_ibv_wc* p_wce, int num_entries, uint64_t* p_cq_poll_sn) +int cq_mgr::poll(ibv_wc* p_wce, int num_entries, uint64_t* p_cq_poll_sn) { // Assume locked!!! cq_logfuncall(""); @@ -346,7 +290,7 @@ int cq_mgr::poll(vma_ibv_wc* p_wce, int num_entries, uint64_t* p_cq_poll_sn) #ifdef RDTSC_MEASURE_RX_VMA_TCP_IDLE_POLL RDTSC_TAKE_END(g_rdtsc_instr_info_arr[RDTSC_FLOW_RX_VMA_TCP_IDLE_POLL]); #endif //RDTSC_MEASURE_RX_VMA_TCP_IDLE_POLL - int ret = vma_ibv_poll_cq(m_p_ibv_cq, num_entries, p_wce); + int ret = ibv_poll_cq(m_p_ibv_cq, num_entries, p_wce); if (ret <= 0) { #ifdef RDTSC_MEASURE_RX_VERBS_IDLE_POLL RDTSC_TAKE_END(g_rdtsc_instr_info_arr[RDTSC_FLOW_RX_VERBS_IDLE_POLL]); @@ -403,7 +347,7 @@ int cq_mgr::poll(vma_ibv_wc* p_wce, int num_entries, uint64_t* p_cq_poll_sn) return ret; } -void cq_mgr::process_cq_element_log_helper(mem_buf_desc_t* p_mem_buf_desc, vma_ibv_wc* p_wce) +void cq_mgr::process_cq_element_log_helper(mem_buf_desc_t* p_mem_buf_desc, ibv_wc* p_wce) { BULLSEYE_EXCLUDE_BLOCK_START // wce with bad status value @@ -428,7 +372,7 @@ void cq_mgr::process_cq_element_log_helper(mem_buf_desc_t* p_mem_buf_desc, vma_i cq_logfunc("wce error status '%s' [%d] (wr_id=%p, qp_num=%x)", priv_ibv_wc_status_str(p_wce->status), p_wce->status, p_wce->wr_id, p_wce->qp_num); } -mem_buf_desc_t* cq_mgr::process_cq_element_tx(vma_ibv_wc* p_wce) +mem_buf_desc_t* cq_mgr::process_cq_element_tx(ibv_wc* p_wce) { // Assume locked!!! cq_logfuncall(""); @@ -462,7 +406,7 @@ mem_buf_desc_t* cq_mgr::process_cq_element_tx(vma_ibv_wc* p_wce) return p_mem_buf_desc; } -mem_buf_desc_t* cq_mgr::process_cq_element_rx(vma_ibv_wc* p_wce) +mem_buf_desc_t* cq_mgr::process_cq_element_rx(ibv_wc* p_wce) { // Assume locked!!! cq_logfuncall(""); @@ -508,7 +452,7 @@ mem_buf_desc_t* cq_mgr::process_cq_element_rx(vma_ibv_wc* p_wce) p_mem_buf_desc->rx.is_sw_csum_need = !(m_b_is_rx_hw_csum_on && vma_wc_rx_hw_csum_ok(*p_wce)); - if (likely(vma_wc_opcode(*p_wce) & VMA_IBV_WC_RECV)) { + if (likely(vma_wc_opcode(*p_wce) & IBV_WC_RECV)) { // Save recevied total bytes p_mem_buf_desc->sz_data = p_wce->byte_len; @@ -517,17 +461,10 @@ mem_buf_desc_t* cq_mgr::process_cq_element_rx(vma_ibv_wc* p_wce) p_mem_buf_desc->rx.context = this; p_mem_buf_desc->rx.socketxtreme_polled = false; - //this is not a deadcode if timestamping is defined in verbs API - // coverity[dead_error_condition] - if (vma_wc_flags(*p_wce) & VMA_IBV_WC_WITH_TIMESTAMP) { - p_mem_buf_desc->rx.hw_raw_timestamp = vma_wc_timestamp(*p_wce); - } - VALGRIND_MAKE_MEM_DEFINED(p_mem_buf_desc->p_buffer, p_mem_buf_desc->sz_data); - prefetch_range((uint8_t*)p_mem_buf_desc->p_buffer + m_sz_transport_header, - std::min(p_mem_buf_desc->sz_data - m_sz_transport_header, (size_t)m_n_sysvar_rx_prefetch_bytes)); - //prefetch((uint8_t*)p_mem_buf_desc->p_buffer + m_sz_transport_header); + prefetch_range((uint8_t*)p_mem_buf_desc->p_buffer + ETH_HDR_LEN, + std::min(p_mem_buf_desc->sz_data - ETH_HDR_LEN, (size_t)m_n_sysvar_rx_prefetch_bytes)); } return p_mem_buf_desc; @@ -642,7 +579,7 @@ int cq_mgr::poll_and_process_element_rx(uint64_t* p_cq_poll_sn, void* pv_fd_read cq_logfuncall(""); /* coverity[stack_use_local_overflow] */ - vma_ibv_wc wce[MCE_MAX_CQ_POLL_BATCH]; + ibv_wc wce[MCE_MAX_CQ_POLL_BATCH]; int ret; uint32_t ret_rx_processed = process_recv_queue(pv_fd_ready_array); @@ -664,7 +601,7 @@ int cq_mgr::poll_and_process_element_rx(uint64_t* p_cq_poll_sn, void* pv_fd_read for (int i = 0; i < ret; i++) { mem_buf_desc_t *buff = process_cq_element_rx((&wce[i])); if (buff) { - if (vma_wc_opcode(wce[i]) & VMA_IBV_WC_RECV) { + if (vma_wc_opcode(wce[i]) & IBV_WC_RECV) { if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || !compensate_qp_poll_success(buff)) { process_recv_buffer(buff, pv_fd_ready_array); @@ -687,7 +624,7 @@ int cq_mgr::poll_and_process_element_tx(uint64_t* p_cq_poll_sn) cq_logfuncall(""); /* coverity[stack_use_local_overflow] */ - vma_ibv_wc wce[MCE_MAX_CQ_POLL_BATCH]; + ibv_wc wce[MCE_MAX_CQ_POLL_BATCH]; int ret = poll(wce, m_n_sysvar_cq_poll_batch_max, p_cq_poll_sn); if (ret > 0) { m_n_wce_counter += ret; @@ -798,7 +735,7 @@ int cq_mgr::drain_and_proccess(uintptr_t* p_recycle_buffers_last_wr_id /*=NULL*/ (p_recycle_buffers_last_wr_id)) { /* coverity[stack_use_local_overflow] */ - vma_ibv_wc wce[MCE_MAX_CQ_POLL_BATCH]; + ibv_wc wce[MCE_MAX_CQ_POLL_BATCH]; int ret = poll(wce, MCE_MAX_CQ_POLL_BATCH, &cq_poll_sn); if (ret <= 0) { m_b_was_drained = true; @@ -816,29 +753,19 @@ int cq_mgr::drain_and_proccess(uintptr_t* p_recycle_buffers_last_wr_id /*=NULL*/ if (p_recycle_buffers_last_wr_id) { m_p_cq_stat->n_rx_pkt_drop++; reclaim_recv_buffer_helper(buff); - } else { - bool procces_now = false; - if (m_transport_type == VMA_TRANSPORT_ETH) { - procces_now = is_eth_tcp_frame(buff); - } - if (m_transport_type == VMA_TRANSPORT_IB) { - procces_now = is_ib_tcp_frame(buff); - } + } else if (is_eth_tcp_frame(buff)) { // We process immediately all non udp/ip traffic.. - if (procces_now) { - buff->rx.is_vma_thr = true; - if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || - !compensate_qp_poll_success(buff)) { - process_recv_buffer(buff, NULL); - } + buff->rx.is_vma_thr = true; + if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || + !compensate_qp_poll_success(buff)) { + process_recv_buffer(buff, NULL); } - else { //udp/ip traffic we just put in the cq's rx queue - m_rx_queue.push_back(buff); - mem_buf_desc_t* buff_cur = m_rx_queue.get_and_pop_front(); - if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || - !compensate_qp_poll_success(buff_cur)) { - m_rx_queue.push_front(buff_cur); - } + } else { //udp/ip traffic we just put in the cq's rx queue + m_rx_queue.push_back(buff); + mem_buf_desc_t* buff_cur = m_rx_queue.get_and_pop_front(); + if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || + !compensate_qp_poll_success(buff_cur)) { + m_rx_queue.push_front(buff_cur); } } } diff --git a/src/vma/dev/cq_mgr.h b/src/vma/dev/cq_mgr.h index 2a40ed35d4..bdf7c8ee43 100644 --- a/src/vma/dev/cq_mgr.h +++ b/src/vma/dev/cq_mgr.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -174,7 +148,7 @@ class cq_mgr * @p_cq_poll_sn global unique wce id that maps last wce polled * @return Number of successfully polled wce */ - virtual int poll(vma_ibv_wc* p_wce, int num_entries, uint64_t* p_cq_poll_sn); + virtual int poll(ibv_wc* p_wce, int num_entries, uint64_t* p_cq_poll_sn); void compensate_qp_poll_failed(); inline void process_recv_buffer(mem_buf_desc_t* buff, void* pv_fd_ready_array = NULL); @@ -183,8 +157,8 @@ class cq_mgr * and deliver them to their owner for further processing (sockinfo on Tx path and ib_conn_mgr on Rx path) * - for Tx wce the data buffers will be released to the associated ring before the mem_buf_desc are returned */ - mem_buf_desc_t* process_cq_element_tx(vma_ibv_wc* p_wce); - mem_buf_desc_t* process_cq_element_rx(vma_ibv_wc* p_wce); + mem_buf_desc_t* process_cq_element_tx(ibv_wc* p_wce); + mem_buf_desc_t* process_cq_element_rx(ibv_wc* p_wce); void reclaim_recv_buffer_helper(mem_buf_desc_t* buff); // Returns true if the given buffer was used, @@ -192,7 +166,6 @@ class cq_mgr bool compensate_qp_poll_success(mem_buf_desc_t* buff); inline uint32_t process_recv_queue(void* pv_fd_ready_array = NULL); - virtual void prep_ibv_cq(vma_ibv_cq_init_attr &attr) const; //returns list of buffers to the owner. void process_tx_buffer_list(mem_buf_desc_t* p_mem_buf_desc); @@ -210,11 +183,9 @@ class cq_mgr const uint32_t m_n_sysvar_cq_poll_batch_max; const uint32_t m_n_sysvar_progress_engine_wce_max; cq_stats_t* m_p_cq_stat; - transport_type_t m_transport_type; mem_buf_desc_t* m_p_next_rx_desc_poll; const uint32_t m_n_sysvar_rx_prefetch_bytes_before_poll; const uint32_t m_n_sysvar_rx_prefetch_bytes; - size_t m_sz_transport_header; ib_ctx_handler* m_p_ib_ctx_handler; const uint32_t m_n_sysvar_rx_num_wr_to_post_recv; private: @@ -251,7 +222,7 @@ class cq_mgr //Finds and sets the vma if to which the buff is addressed (according to qpn). inline void find_buff_dest_vma_if_ctx(mem_buf_desc_t * buff); - void process_cq_element_log_helper(mem_buf_desc_t* p_mem_buf_desc, vma_ibv_wc* p_wce); + void process_cq_element_log_helper(mem_buf_desc_t* p_mem_buf_desc, ibv_wc* p_wce); virtual int req_notify_cq() { return ibv_req_notify_cq(m_p_ibv_cq, 0); diff --git a/src/vma/dev/cq_mgr.inl b/src/vma/dev/cq_mgr.inl index e7cf087706..dd164d05a2 100644 --- a/src/vma/dev/cq_mgr.inl +++ b/src/vma/dev/cq_mgr.inl @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -88,22 +62,4 @@ inline bool is_eth_tcp_frame(mem_buf_desc_t* buff) return false; } -inline bool is_ib_tcp_frame(mem_buf_desc_t* buff) -{ - struct ipoibhdr* p_ipoib_h = (struct ipoibhdr*)(buff->p_buffer + GRH_HDR_LEN); - - // Validate IPoIB header - if (unlikely(p_ipoib_h->ipoib_header != htonl(IPOIB_HEADER))) { - return false; - } - - size_t transport_header_len = GRH_HDR_LEN + IPOIB_HDR_LEN; - - struct iphdr * p_ip_h = (struct iphdr*)(buff->p_buffer + transport_header_len); - if (likely(p_ip_h->protocol == IPPROTO_TCP)) { - return true; - } - return false; -} - #endif//CQ_MGR_INL_H diff --git a/src/vma/dev/cq_mgr_mlx5.cpp b/src/vma/dev/cq_mgr_mlx5.cpp index 06c1b8a531..d7754fda2a 100644 --- a/src/vma/dev/cq_mgr_mlx5.cpp +++ b/src/vma/dev/cq_mgr_mlx5.cpp @@ -1,39 +1,11 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "cq_mgr_mlx5.h" -#if defined(DEFINED_DIRECT_VERBS) - #include #include "cq_mgr.inl" #include "cq_mgr_mlx5.inl" @@ -88,7 +60,7 @@ uint32_t cq_mgr_mlx5::clean_cq() } else {//Tx int ret = 0; /* coverity[stack_use_local_overflow] */ - vma_ibv_wc wce[MCE_MAX_CQ_POLL_BATCH]; + ibv_wc wce[MCE_MAX_CQ_POLL_BATCH]; while ((ret = cq_mgr::poll(wce, MCE_MAX_CQ_POLL_BATCH, &cq_poll_sn)) > 0) { for (int i = 0; i < ret; i++) { buff = process_cq_element_tx(&wce[i]); @@ -196,7 +168,7 @@ inline void cq_mgr_mlx5::cqe64_to_mem_buff_desc(struct mlx5_cqe64 *cqe, mem_buf_ status = BS_OK; p_rx_wc_buf_desc->sz_data = ntohl(cqe->byte_cnt); p_rx_wc_buf_desc->rx.hw_raw_timestamp = ntohll(cqe->timestamp); - p_rx_wc_buf_desc->rx.flow_tag_id = vma_get_flow_tag(cqe); + p_rx_wc_buf_desc->rx.flow_tag_id = vma_get_flow_tag(cqe) & 0x00FFFFFF; p_rx_wc_buf_desc->rx.is_sw_csum_need = !(m_b_is_rx_hw_csum_on && (cqe->hds_ip_ext & MLX5_CQE_L4_OK) && (cqe->hds_ip_ext & MLX5_CQE_L3_OK)); return; @@ -293,7 +265,7 @@ int cq_mgr_mlx5::drain_and_proccess(uintptr_t* p_recycle_buffers_last_wr_id /*=N for (int i = 0; i < ret; i++) { uint32_t wqe_sz = 0; mlx5_cqe64 *cqe = cqe_arr[i]; - vma_ibv_wc wce; + ibv_wc wce; uint16_t wqe_ctr = ntohs(cqe->wqe_counter); if (m_b_is_rx) { @@ -320,29 +292,19 @@ int cq_mgr_mlx5::drain_and_proccess(uintptr_t* p_recycle_buffers_last_wr_id /*=N if (p_recycle_buffers_last_wr_id) { m_p_cq_stat->n_rx_pkt_drop++; reclaim_recv_buffer_helper(m_rx_hot_buffer); - } else { - bool procces_now = false; - if (m_transport_type == VMA_TRANSPORT_ETH) { - procces_now = is_eth_tcp_frame(m_rx_hot_buffer); - } - if (m_transport_type == VMA_TRANSPORT_IB) { - procces_now = is_ib_tcp_frame(m_rx_hot_buffer); - } + } else if (is_eth_tcp_frame(m_rx_hot_buffer)) { // We process immediately all non udp/ip traffic.. - if (procces_now) { - m_rx_hot_buffer->rx.is_vma_thr = true; - if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || - !compensate_qp_poll_success(m_rx_hot_buffer)) { - process_recv_buffer(m_rx_hot_buffer, NULL); - } + m_rx_hot_buffer->rx.is_vma_thr = true; + if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || + !compensate_qp_poll_success(m_rx_hot_buffer)) { + process_recv_buffer(m_rx_hot_buffer, NULL); } - else { //udp/ip traffic we just put in the cq's rx queue - m_rx_queue.push_back(m_rx_hot_buffer); - mem_buf_desc_t* buff_cur = m_rx_queue.get_and_pop_front(); - if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || - !compensate_qp_poll_success(buff_cur)) { - m_rx_queue.push_front(buff_cur); - } + } else { //udp/ip traffic we just put in the cq's rx queue + m_rx_queue.push_back(m_rx_hot_buffer); + mem_buf_desc_t* buff_cur = m_rx_queue.get_and_pop_front(); + if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || + !compensate_qp_poll_success(buff_cur)) { + m_rx_queue.push_front(buff_cur); } } } @@ -370,30 +332,20 @@ int cq_mgr_mlx5::drain_and_proccess(uintptr_t* p_recycle_buffers_last_wr_id /*=N if (p_recycle_buffers_last_wr_id) { m_p_cq_stat->n_rx_pkt_drop++; reclaim_recv_buffer_helper(buff); - } else { - bool procces_now = false; - if (m_transport_type == VMA_TRANSPORT_ETH) { - procces_now = is_eth_tcp_frame(buff); - } - if (m_transport_type == VMA_TRANSPORT_IB) { - procces_now = is_ib_tcp_frame(buff); - } + } else if (is_eth_tcp_frame(buff)) { /* We process immediately all non udp/ip traffic.. */ - if (procces_now) { - buff->rx.is_vma_thr = true; - if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || - !compensate_qp_poll_success(buff)) { - process_recv_buffer(buff, NULL); - } + buff->rx.is_vma_thr = true; + if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || + !compensate_qp_poll_success(buff)) { + process_recv_buffer(buff, NULL); } - else { /* udp/ip traffic we just put in the cq's rx queue */ - m_rx_queue.push_back(buff); - mem_buf_desc_t* buff_cur = m_rx_queue.front(); - m_rx_queue.pop_front(); - if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || - !compensate_qp_poll_success(buff_cur)) { - m_rx_queue.push_front(buff_cur); - } + } else { /* udp/ip traffic we just put in the cq's rx queue */ + m_rx_queue.push_back(buff); + mem_buf_desc_t* buff_cur = m_rx_queue.front(); + m_rx_queue.pop_front(); + if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || + !compensate_qp_poll_success(buff_cur)) { + m_rx_queue.push_front(buff_cur); } } } @@ -470,8 +422,8 @@ mem_buf_desc_t* cq_mgr_mlx5::process_cq_element_rx(mem_buf_desc_t* p_mem_buf_des VALGRIND_MAKE_MEM_DEFINED(p_mem_buf_desc->p_buffer, p_mem_buf_desc->sz_data); - prefetch_range((uint8_t*)p_mem_buf_desc->p_buffer + m_sz_transport_header, - std::min(p_mem_buf_desc->sz_data - m_sz_transport_header, (size_t)m_n_sysvar_rx_prefetch_bytes)); + prefetch_range((uint8_t*)p_mem_buf_desc->p_buffer + ETH_HDR_LEN, + std::min(p_mem_buf_desc->sz_data - ETH_HDR_LEN, (size_t)m_n_sysvar_rx_prefetch_bytes)); return p_mem_buf_desc; @@ -627,7 +579,7 @@ int cq_mgr_mlx5::poll_and_process_element_rx(mem_buf_desc_t **p_desc_lst) } -inline void cq_mgr_mlx5::cqe64_to_vma_wc(struct mlx5_cqe64 *cqe, vma_ibv_wc *wc) +inline void cq_mgr_mlx5::cqe64_to_vma_wc(struct mlx5_cqe64 *cqe, ibv_wc *wc) { struct mlx5_err_cqe* ecqe = (struct mlx5_err_cqe *)cqe; @@ -638,7 +590,7 @@ inline void cq_mgr_mlx5::cqe64_to_vma_wc(struct mlx5_cqe64 *cqe, vma_ibv_wc *wc) case MLX5_CQE_RESP_SEND: case MLX5_CQE_RESP_SEND_IMM: case MLX5_CQE_RESP_SEND_INV: - vma_wc_opcode(*wc) = VMA_IBV_WC_RECV; + vma_wc_opcode(*wc) = IBV_WC_RECV; wc->byte_len = ntohl(cqe->byte_cnt); wc->status = IBV_WC_SUCCESS; return; @@ -706,7 +658,7 @@ int cq_mgr_mlx5::poll_and_process_error_element_tx(struct mlx5_cqe64 *cqe, uint6 uint16_t wqe_ctr = ntohs(cqe->wqe_counter); int index = wqe_ctr & (m_qp->m_tx_num_wr - 1); mem_buf_desc_t* buff = NULL; - vma_ibv_wc wce; + ibv_wc wce; // spoil the global sn if we have packets ready union __attribute__((packed)) { @@ -829,7 +781,7 @@ bool cq_mgr_mlx5::fill_cq_hw_descriptors(struct hw_cq_data &data) int cq_mgr_mlx5::poll_and_process_error_element_rx(struct mlx5_cqe64 *cqe, void* pv_fd_ready_array) { - vma_ibv_wc wce; + ibv_wc wce; memset(&wce, 0, sizeof(wce)); wce.wr_id = (uintptr_t)m_rx_hot_buffer; @@ -840,7 +792,7 @@ int cq_mgr_mlx5::poll_and_process_error_element_rx(struct mlx5_cqe64 *cqe, void* m_rx_hot_buffer = cq_mgr::process_cq_element_rx(&wce); if (m_rx_hot_buffer) { - if (vma_wc_opcode(wce) & VMA_IBV_WC_RECV) { + if (vma_wc_opcode(wce) & IBV_WC_RECV) { if ((++m_qp_rec.debt < (int)m_n_sysvar_rx_num_wr_to_post_recv) || !compensate_qp_poll_success(m_rx_hot_buffer)) { process_recv_buffer(m_rx_hot_buffer, pv_fd_ready_array); @@ -851,5 +803,3 @@ int cq_mgr_mlx5::poll_and_process_error_element_rx(struct mlx5_cqe64 *cqe, void* return 1; } - -#endif /* DEFINED_DIRECT_VERBS */ diff --git a/src/vma/dev/cq_mgr_mlx5.h b/src/vma/dev/cq_mgr_mlx5.h index 82b181439e..001e4fcd35 100644 --- a/src/vma/dev/cq_mgr_mlx5.h +++ b/src/vma/dev/cq_mgr_mlx5.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -37,7 +11,6 @@ #include "cq_mgr.h" #include "qp_mgr_eth_mlx5.h" -#if defined(DEFINED_DIRECT_VERBS) class qp_mgr_eth_mlx5; /* Get CQE opcode. */ @@ -83,7 +56,7 @@ class cq_mgr_mlx5: public cq_mgr inline struct mlx5_cqe64* get_cqe64(struct mlx5_cqe64 **cqe_err = NULL); inline void cqe64_to_mem_buff_desc(struct mlx5_cqe64 *cqe, mem_buf_desc_t* p_rx_wc_buf_desc, enum buff_status_e& status); - void cqe64_to_vma_wc(struct mlx5_cqe64 *cqe, vma_ibv_wc *wc); + void cqe64_to_vma_wc(struct mlx5_cqe64 *cqe, ibv_wc *wc); inline struct mlx5_cqe64* check_error_completion(struct mlx5_cqe64 *cqe, uint32_t *ci, uint8_t op_own); inline void update_global_sn(uint64_t& cq_poll_sn, uint32_t rettotal); @@ -92,5 +65,4 @@ class cq_mgr_mlx5: public cq_mgr }; }; -#endif /* DEFINED_DIRECT_VERBS */ #endif //CQ_MGR_MLX5_H diff --git a/src/vma/dev/cq_mgr_mlx5.inl b/src/vma/dev/cq_mgr_mlx5.inl index df91687e3d..ee8e0c04f1 100644 --- a/src/vma/dev/cq_mgr_mlx5.inl +++ b/src/vma/dev/cq_mgr_mlx5.inl @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -36,8 +10,6 @@ #include "dev/cq_mgr_mlx5.h" -#if defined(DEFINED_DIRECT_VERBS) - /**/ /** inlining functions can only help if they are implemented before their usage **/ /**/ @@ -58,5 +30,4 @@ inline struct mlx5_cqe64* cq_mgr_mlx5::check_cqe(void) return NULL; } -#endif /* DEFINED_DIRECT_VERBS */ #endif//CQ_MGR_MLX5_INL_H diff --git a/src/vma/dev/dm_mgr.cpp b/src/vma/dev/dm_mgr.cpp index fe40a5158a..808f061a7b 100644 --- a/src/vma/dev/dm_mgr.cpp +++ b/src/vma/dev/dm_mgr.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "dm_mgr.h" @@ -35,7 +9,6 @@ #include "vma/proto/mem_buf_desc.h" #include "vma/dev/ib_ctx_handler.h" -#if defined(DEFINED_DIRECT_VERBS) #if defined(DEFINED_IBV_DM) #define DM_MEMORY_MASK_8 7 @@ -67,7 +40,7 @@ dm_mgr::dm_mgr() : bool dm_mgr::allocate_resources(ib_ctx_handler* ib_ctx, ring_stats_t* ring_stats) { size_t allocation_size = DM_ALIGN_SIZE(safe_mce_sys().ring_dev_mem_tx, DM_MEMORY_MASK_64); - vma_ibv_alloc_dm_attr dm_attr; + ibv_alloc_dm_attr dm_attr; vma_ibv_reg_mr_in mr_in; m_p_ring_stat = ring_stats; if (!allocation_size) { @@ -83,7 +56,7 @@ bool dm_mgr::allocate_resources(ib_ctx_handler* ib_ctx, ring_stats_t* ring_stats // Allocate on device memory buffer memset(&dm_attr, 0, sizeof(dm_attr)); dm_attr.length = allocation_size; - m_p_ibv_dm = vma_ibv_alloc_dm(ib_ctx->get_ibv_context(), &dm_attr); + m_p_ibv_dm = ibv_alloc_dm(ib_ctx->get_ibv_context(), &dm_attr); if (!m_p_ibv_dm) { // Memory allocation can fail if we have already allocated the maximum possible. VLOG_PRINTF_ONCE_THEN_DEBUG(VLOG_WARNING, "**************************************************************\n"); @@ -101,7 +74,7 @@ bool dm_mgr::allocate_resources(ib_ctx_handler* ib_ctx, ring_stats_t* ring_stats // Register On Device Memory MR m_p_dm_mr = vma_ibv_reg_dm_mr(&mr_in); if (!m_p_dm_mr) { - vma_ibv_free_dm(m_p_ibv_dm); + ibv_free_dm(m_p_ibv_dm); m_p_ibv_dm = NULL; dm_logerr("ibv_free_dm error - dm_mr registration failed, %d %m", errno); return false; @@ -131,7 +104,7 @@ void dm_mgr::release_resources() } if (m_p_ibv_dm) { - if (vma_ibv_free_dm(m_p_ibv_dm)) { + if (ibv_free_dm(m_p_ibv_dm)) { dm_logerr("ibv_free_dm failed %d %m", errno); } else { dm_logdbg("ibv_free_dm success"); @@ -267,4 +240,3 @@ void dm_mgr::release_data(mem_buf_desc_t* buff) } #endif /* DEFINED_IBV_DM */ -#endif /* DEFINED_DIRECT_VERBS */ diff --git a/src/vma/dev/dm_mgr.h b/src/vma/dev/dm_mgr.h index baeb16f94b..14b3cf88c9 100644 --- a/src/vma/dev/dm_mgr.h +++ b/src/vma/dev/dm_mgr.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef DM_MGR_H @@ -39,7 +13,6 @@ class mem_buf_desc_t; class ib_ctx_handler; -#if defined(DEFINED_DIRECT_VERBS) #if defined(DEFINED_IBV_DM) #define DM_COMPLETION_THRESHOLD 8192 @@ -57,7 +30,7 @@ class dm_mgr { private: struct ibv_mr *m_p_dm_mr; - vma_ibv_dm *m_p_ibv_dm; + ibv_dm *m_p_ibv_dm; ring_stats_t *m_p_ring_stat; size_t m_allocation; // Size of device memory buffer (bytes) size_t m_used; // Next available index inside the buffer @@ -77,5 +50,4 @@ class dm_mgr { }; #endif /* DEFINED_IBV_DM */ -#endif /* DEFINED_DIRECT_VERBS */ #endif /* DM_MGR_H */ diff --git a/src/vma/dev/gro_mgr.cpp b/src/vma/dev/gro_mgr.cpp index 965ad6cba1..dc702df16a 100644 --- a/src/vma/dev/gro_mgr.cpp +++ b/src/vma/dev/gro_mgr.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "vma/dev/gro_mgr.h" diff --git a/src/vma/dev/gro_mgr.h b/src/vma/dev/gro_mgr.h index e0b7f20533..4dd62eb5ca 100644 --- a/src/vma/dev/gro_mgr.h +++ b/src/vma/dev/gro_mgr.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef GRO_MGR_H_ diff --git a/src/vma/dev/ib_ctx_handler.cpp b/src/vma/dev/ib_ctx_handler.cpp index 95c68ed5af..2a923694b2 100644 --- a/src/vma/dev/ib_ctx_handler.cpp +++ b/src/vma/dev/ib_ctx_handler.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -60,6 +34,7 @@ ib_ctx_handler::ib_ctx_handler(struct ib_ctx_handler_desc *desc) : , m_removed(false) , m_lock_mr("spin_lock_mr") , m_p_ctx_time_converter(NULL) + , m_str {} { if (NULL == desc) { ibch_logpanic("Invalid ib_ctx_handler"); @@ -72,10 +47,6 @@ ib_ctx_handler::ib_ctx_handler(struct ib_ctx_handler_desc *desc) : } m_p_ibv_context = NULL; -#ifdef DEFINED_DPCP - m_p_adapter = set_dpcp_adapter(); - if (NULL == m_p_adapter) -#endif /* DEFINED_DPCP */ { #if defined(DEFINED_ROCE_LAG) struct mlx5dv_context_attr dv_attr; @@ -104,7 +75,7 @@ ib_ctx_handler::ib_ctx_handler(struct ib_ctx_handler_desc *desc) : ibch_logpanic("ibv device %p attr allocation failure (ibv context %p) (errno=%d %m)", m_p_ibv_device, m_p_ibv_context, errno); } - vma_ibv_device_attr_comp_mask(m_p_ibv_device_attr); + IF_VERBS_FAILURE(vma_ibv_query_device(m_p_ibv_context, m_p_ibv_device_attr)) { ibch_logerr("ibv_query_device failed on ibv device %p (ibv context %p) (errno=%d %m)", m_p_ibv_device, m_p_ibv_context, errno); @@ -135,12 +106,6 @@ ib_ctx_handler::ib_ctx_handler(struct ib_ctx_handler_desc *desc) : ibv_dealloc_pd(m_p_ibv_pd); } -#ifdef DEFINED_DPCP - if (m_p_adapter) { - delete m_p_adapter; - m_p_ibv_context = NULL; - } -#endif /* DEFINED_DPCP */ if (m_p_ibv_context) { ibv_close_device(m_p_ibv_context); m_p_ibv_context = NULL; @@ -174,12 +139,6 @@ ib_ctx_handler::~ib_ctx_handler() } delete m_p_ibv_device_attr; -#ifdef DEFINED_DPCP - if (m_p_adapter) { - delete m_p_adapter; - m_p_ibv_context = NULL; - } -#endif /* DEFINED_DPCP */ if (m_p_ibv_context) { ibv_close_device(m_p_ibv_context); m_p_ibv_context = NULL; @@ -229,113 +188,6 @@ void ib_ctx_handler::print_val() ibch_logdbg("%s", m_str); } -#ifdef DEFINED_DPCP -dpcp::adapter* ib_ctx_handler::set_dpcp_adapter() -{ - dpcp::status status = dpcp::DPCP_ERR_NO_SUPPORT; - dpcp::provider *p_provider = NULL; - dpcp::adapter_info* dpcp_lst = NULL; - size_t adapters_num = 0; - size_t i = 0; - - m_p_adapter = NULL; - if (!m_p_ibv_device) { - return NULL; - } - - status = dpcp::provider::get_instance(p_provider); - if (dpcp::DPCP_OK != status) { - ibch_logerr("failed getting provider status = %d", status); - goto err; - } - - status = p_provider->get_adapter_info_lst(NULL, adapters_num); - if (0 == adapters_num) { - ibch_logdbg("found no adapters status = %d", status); - goto err; - } - - dpcp_lst = new (std::nothrow)dpcp::adapter_info[adapters_num]; - if (!dpcp_lst) { - ibch_logerr("failed allocating memory for devices"); - goto err; - } - - status = p_provider->get_adapter_info_lst(dpcp_lst, adapters_num); - if (dpcp::DPCP_OK != status) { - ibch_logerr("failed getting adapter list"); - goto err; - } - - for (i = 0; i < adapters_num; i++) { - if (dpcp_lst[i].name == m_p_ibv_device->name) { - dpcp::adapter *adapter = NULL; - - status = p_provider->open_adapter(dpcp_lst[i].name, adapter); - if ((dpcp::DPCP_OK == status) && (adapter)) { - int ret = 0; - struct ibv_context *ctx = NULL; - struct ibv_pd *pd = NULL; - mlx5dv_obj mlx5_obj; - - ctx = (ibv_context*)adapter->get_ibv_context(); - if (!ctx) { - ibch_logerr("failed getting context for adapter %p (errno=%d %m) ", - adapter, errno); - delete adapter; - goto err; - } - - pd = ibv_alloc_pd(ctx); - if (!pd) { - ibch_logerr("failed pd allocation for %p context (errno=%d %m) ", - ctx, errno); - delete adapter; - goto err; - } - - mlx5_obj.pd.in = pd; - mlx5dv_pd out_pd; - mlx5_obj.pd.out = &out_pd; - - ret = vma_ib_mlx5dv_init_obj(&mlx5_obj, MLX5DV_OBJ_PD); - if (ret) { - ibch_logerr("failed getting mlx5_pd for %p (errno=%d %m) ", - m_p_ibv_pd, errno); - ibv_dealloc_pd(pd); - delete adapter; - goto err; - } - - adapter->set_pd(out_pd.pdn, pd); - status = adapter->open(); - if (dpcp::DPCP_OK != status) { - ibch_logerr("failed opening dpcp adapter %s got %d", - adapter->get_name().c_str(), status); - ibv_dealloc_pd(pd); - delete adapter; - goto err; - } - - m_p_adapter = adapter; - m_p_ibv_context = ctx; - m_p_ibv_pd = pd; - ibch_logdbg("dpcp adapter: %s is up", adapter->get_name().c_str()); - } - - break; - } - } - -err: - if (dpcp_lst) { - delete[] dpcp_lst; - } - - return m_p_adapter; -} -#endif /* DEFINED_DPCP */ - void ib_ctx_handler::set_ctx_time_converter_status(ts_conversion_mode_t conversion_mode) { if (m_p_ctx_time_converter != NULL) { @@ -361,14 +213,14 @@ void ib_ctx_handler::set_ctx_time_converter_status(ts_conversion_mode_t conversi ibch_logwarn("ptp is not supported for mlx4 devices, reverting to mode TS_CONVERSION_MODE_SYNC (ibv context %p)", m_p_ibv_context); } else { - vma_ibv_clock_info clock_info; + mlx5dv_clock_info clock_info; memset(&clock_info, 0, sizeof(clock_info)); - int ret = vma_ibv_query_clock_info(m_p_ibv_context, &clock_info); + int ret = mlx5dv_get_clock_info(m_p_ibv_context, &clock_info); if (ret == 0) { m_p_ctx_time_converter = new time_converter_ptp(m_p_ibv_context); } else { m_p_ctx_time_converter = new time_converter_ib_ctx(m_p_ibv_context, TS_CONVERSION_MODE_SYNC, m_p_ibv_device_attr->hca_core_clock); - ibch_logwarn("vma_ibv_query_clock_info failure for clock_info, reverting to mode TS_CONVERSION_MODE_SYNC (ibv context %p) (ret %d)", + ibch_logwarn("mlx5dv_get_clock_info failure for clock_info, reverting to mode TS_CONVERSION_MODE_SYNC (ibv context %p) (ret %d)", m_p_ibv_context, ret); } } diff --git a/src/vma/dev/ib_ctx_handler.h b/src/vma/dev/ib_ctx_handler.h index c066b46346..c08c00ff1e 100644 --- a/src/vma/dev/ib_ctx_handler.h +++ b/src/vma/dev/ib_ctx_handler.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -42,10 +16,6 @@ #include "vma/ib/base/verbs_extra.h" #include "utils/lock_wrapper.h" -#ifdef DEFINED_DPCP -#include -#endif /* DEFINED_DPCP */ - typedef std::unordered_map mr_map_lkey_t; @@ -77,14 +47,7 @@ class ib_ctx_handler : public event_handler_ibverbs ibv_device* get_ibv_device() { return m_p_ibv_device; } inline char* get_ibname() { return (m_p_ibv_device ? m_p_ibv_device->name : (char *)""); } struct ibv_context* get_ibv_context() { return m_p_ibv_context; } -#ifdef DEFINED_DPCP - dpcp::adapter* set_dpcp_adapter(); - dpcp::adapter* get_dpcp_adapter() { return m_p_adapter; } -#endif /* DEFINED_DPCP */ - vma_ibv_device_attr* get_ibv_device_attr() { return vma_get_device_orig_attr(m_p_ibv_device_attr); } -#ifdef DEFINED_TSO - vma_ibv_device_attr_ex* get_ibv_device_attr_ex() { return m_p_ibv_device_attr; } -#endif /* DEFINED_TSO */ + ibv_device_attr* get_ibv_device_attr() { return vma_get_device_orig_attr(m_p_ibv_device_attr); } uint32_t mem_reg(void *addr, size_t length, uint64_t access); void mem_dereg(uint32_t lkey); struct ibv_mr* get_mem_reg(uint32_t lkey); @@ -113,9 +76,6 @@ class ib_ctx_handler : public event_handler_ibverbs void handle_event_device_fatal(); ibv_device* m_p_ibv_device; // HCA handle struct ibv_context* m_p_ibv_context; -#ifdef DEFINED_DPCP - dpcp::adapter *m_p_adapter; -#endif /* DEFINED_DPCP */ vma_ibv_device_attr_ex* m_p_ibv_device_attr; ibv_pd* m_p_ibv_pd; bool m_flow_tag_enabled; diff --git a/src/vma/dev/ib_ctx_handler_collection.cpp b/src/vma/dev/ib_ctx_handler_collection.cpp index 26ff985432..774f9468fa 100644 --- a/src/vma/dev/ib_ctx_handler_collection.cpp +++ b/src/vma/dev/ib_ctx_handler_collection.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include @@ -125,11 +99,11 @@ void ib_ctx_handler_collection::update_tbl(const char *ifa_name) ibchc_logdbg("Checking for offload capable IB devices..."); - dev_list = vma_ibv_get_device_list(&num_devices); + dev_list = ibv_get_device_list(&num_devices); BULLSEYE_EXCLUDE_BLOCK_START if (!dev_list) { - ibchc_logerr("Failure in vma_ibv_get_device_list() (error=%d %m)", errno); + ibchc_logerr("Failure in ibv_get_device_list() (error=%d %m)", errno); ibchc_logerr("Please check rdma configuration"); throw_vma_exception("No IB capable devices found!"); } diff --git a/src/vma/dev/ib_ctx_handler_collection.h b/src/vma/dev/ib_ctx_handler_collection.h index 029e6e77cb..e447bc5cb9 100644 --- a/src/vma/dev/ib_ctx_handler_collection.h +++ b/src/vma/dev/ib_ctx_handler_collection.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/dev/net_device_entry.cpp b/src/vma/dev/net_device_entry.cpp index 5f7b047ce8..8fe3f98410 100644 --- a/src/vma/dev/net_device_entry.cpp +++ b/src/vma/dev/net_device_entry.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/dev/net_device_entry.h b/src/vma/dev/net_device_entry.h index d4fca71c70..4546771c9c 100644 --- a/src/vma/dev/net_device_entry.h +++ b/src/vma/dev/net_device_entry.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/dev/net_device_table_mgr.cpp b/src/vma/dev/net_device_table_mgr.cpp index 02357fc9f1..eca8a7e70d 100644 --- a/src/vma/dev/net_device_table_mgr.cpp +++ b/src/vma/dev/net_device_table_mgr.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -108,7 +82,7 @@ net_device_table_mgr::net_device_table_mgr() : if (m_net_device_map_index.empty()) { int num_devices = 0; struct ibv_device **dev_list = NULL; - dev_list = vma_ibv_get_device_list(&num_devices); + dev_list = ibv_get_device_list(&num_devices); if (dev_list && num_devices == 0) { ibv_free_device_list(dev_list); ndtm_logdbg("net_device_map is empty %d", num_devices); @@ -173,8 +147,8 @@ net_device_table_mgr::~net_device_table_mgr() void net_device_table_mgr::update_tbl() { - int rc = 0; - int fd = -1; + int rc; + int fd; struct { struct nlmsghdr hdr; struct ifinfomsg infomsg; @@ -240,9 +214,6 @@ void net_device_table_mgr::update_tbl() case ARPHRD_ETHER: p_net_device_val = new net_device_val_eth(&desc); break; - case ARPHRD_INFINIBAND: - p_net_device_val = new net_device_val_ib(&desc); - break; default: goto next; } diff --git a/src/vma/dev/net_device_table_mgr.h b/src/vma/dev/net_device_table_mgr.h index 401f0e7b8f..1abd82bc0a 100644 --- a/src/vma/dev/net_device_table_mgr.h +++ b/src/vma/dev/net_device_table_mgr.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/dev/net_device_val.cpp b/src/vma/dev/net_device_val.cpp index a5be4a259e..d24bf11b3c 100644 --- a/src/vma/dev/net_device_val.cpp +++ b/src/vma/dev/net_device_val.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -178,7 +152,12 @@ const char* ring_alloc_logic_attr::to_str() return m_str; } -net_device_val::net_device_val(struct net_device_val_desc *desc) : m_lock("net_device_val lock") +net_device_val::net_device_val(struct net_device_val_desc *desc) + : m_lock("net_device_val lock") + , m_l2_if_addr {} + , m_l2_bc_addr {} + , m_str {} + , m_base_name {} { bool valid = false; ib_ctx_handler* ib_ctx; @@ -199,7 +178,6 @@ net_device_val::net_device_val(struct net_device_val_desc *desc) : m_lock("net_d m_if_active = 0; m_bond_xmit_hash_policy = XHP_LAYER_2; m_bond_fail_over_mac = 0; - m_transport_type = VMA_TRANSPORT_UNKNOWN; if (NULL == desc) { nd_logerr("Invalid net_device_val name=%s", "NA"); @@ -278,10 +256,10 @@ net_device_val::net_device_val(struct net_device_val_desc *desc) : m_lock("net_d case LAG_8023ad: case ACTIVE_BACKUP: // this is a bond interface (or a vlan/alias over bond), find the slaves - valid = verify_bond_ipoib_or_eth_qp_creation(); + valid = verify_bond_eth_qp_creation(); break; default: - valid = (bool)(ib_ctx && verify_ipoib_or_eth_qp_creation(get_ifname_link())); + valid = (bool)(ib_ctx && verify_eth_qp_creation(get_ifname_link())); break; } @@ -364,8 +342,8 @@ net_device_val::~net_device_val() void net_device_val::set_ip_array() { - int rc = 0; - int fd = -1; + int rc; + int fd; struct { struct nlmsghdr hdr; struct ifaddrmsg addrmsg; @@ -500,9 +478,6 @@ void net_device_val::set_str() case ARPHRD_ETHER: sprintf(str_x, " type %s", "ether"); break; - case ARPHRD_INFINIBAND: - sprintf(str_x, " type %s", "infiniband"); - break; default: sprintf(str_x, " type %s", "unknown"); break; @@ -1392,7 +1367,7 @@ L2_address* net_device_val_eth::create_L2_address(const char* ifname) delete m_p_L2_addr; m_p_L2_addr = NULL; } - unsigned char hw_addr[ETH_ALEN]; + unsigned char hw_addr[ETH_ALEN] = {0}; get_local_ll_addr(ifname, hw_addr, ETH_ALEN, false); return new ETH_addr(hw_addr); } @@ -1403,7 +1378,7 @@ void net_device_val_eth::create_br_address(const char* ifname) delete m_p_br_addr; m_p_br_addr = NULL; } - uint8_t hw_addr[ETH_ALEN]; + uint8_t hw_addr[ETH_ALEN] = {0}; get_local_ll_addr(ifname, hw_addr, ETH_ALEN, true); m_p_br_addr = new ETH_addr(hw_addr); @@ -1418,106 +1393,7 @@ std::string net_device_val_eth::to_str() return std::string("ETH: ") + net_device_val::to_str(); } -net_device_val_ib::~net_device_val_ib() -{ - struct in_addr in; - if (1 == inet_pton(AF_INET, BROADCAST_IP, &in)) { - g_p_neigh_table_mgr->unregister_observer(neigh_key(ip_address(in.s_addr), this), this); - } -} - -void net_device_val_ib::configure() -{ - ib_ctx_handler* p_ib_ctx = NULL; - struct in_addr in; - - m_p_L2_addr = create_L2_address(get_ifname()); - - BULLSEYE_EXCLUDE_BLOCK_START - if(m_p_L2_addr == NULL) { - nd_logpanic("m_p_L2_addr allocation error"); - } - BULLSEYE_EXCLUDE_BLOCK_END - - create_br_address(get_ifname()); - - if (1 == inet_pton(AF_INET, BROADCAST_IP, &in)) { - g_p_neigh_table_mgr->unregister_observer(neigh_key(ip_address(in.s_addr), this), this); - } - - //Register to IB BR neigh - cache_entry_subject* p_ces = NULL; - if (1 == inet_pton(AF_INET, BROADCAST_IP, &in)) { - g_p_neigh_table_mgr->register_observer(neigh_key(ip_address(in.s_addr), this), this, &p_ces); - } - m_br_neigh = dynamic_cast(p_ces); - - p_ib_ctx = g_p_ib_ctx_handler_collection->get_ib_ctx(get_ifname_link()); - if (!p_ib_ctx || ibv_query_pkey(p_ib_ctx->get_ibv_context(), get_port_from_ifname(get_ifname_link()), 0, &m_pkey)) { - nd_logerr("failed querying pkey"); - } - nd_logdbg("pkey: %d", m_pkey); -} - -ring* net_device_val_ib::create_ring(resource_allocation_key *key) -{ - ring* ring = NULL; - - NOT_IN_USE(key); - try { - switch (m_bond) { - case NO_BOND: - ring = new ring_ib(get_if_idx()); - break; - case ACTIVE_BACKUP: - case LAG_8023ad: - ring = new ring_bond_ib(get_if_idx()); - break; - default: - nd_logdbg("Unknown ring type"); - break; - } - } catch (vma_error &error) { - nd_logdbg("failed creating ring %s", error.message); - } - - return ring; -} - -L2_address* net_device_val_ib::create_L2_address(const char* ifname) -{ - if (m_p_L2_addr) { - delete m_p_L2_addr; - m_p_L2_addr = NULL; - } - unsigned char hw_addr[IPOIB_HW_ADDR_LEN]; - get_local_ll_addr(ifname, hw_addr, IPOIB_HW_ADDR_LEN, false); - return new IPoIB_addr(hw_addr); -} - -void net_device_val_ib::create_br_address(const char* ifname) -{ - if (m_p_br_addr) { - delete m_p_br_addr; - m_p_br_addr = NULL; - } - unsigned char hw_addr[IPOIB_HW_ADDR_LEN]; - get_local_ll_addr(ifname, hw_addr, IPOIB_HW_ADDR_LEN, true); - m_p_br_addr = new IPoIB_addr(hw_addr); - BULLSEYE_EXCLUDE_BLOCK_START - if (m_p_br_addr == NULL) { - nd_logpanic("m_p_br_addr allocation error"); - } - BULLSEYE_EXCLUDE_BLOCK_END -} - -std::string net_device_val_ib::to_str() -{ - return std::string("IB: ") + net_device_val::to_str(); -} - - -bool net_device_val::verify_bond_ipoib_or_eth_qp_creation() +bool net_device_val::verify_bond_eth_qp_creation() { char slaves[IFNAMSIZ * MAX_SLAVES] = {0}; @@ -1536,7 +1412,7 @@ bool net_device_val::verify_bond_ipoib_or_eth_qp_creation() { char* p = strchr(slave_name, '\n'); if (p) *p = '\0'; // Remove the tailing 'new line" char - if (!verify_ipoib_or_eth_qp_creation(slave_name)) { + if (!verify_eth_qp_creation(slave_name)) { //check all slaves but print only once for bond bond_ok = false; } @@ -1559,11 +1435,8 @@ bool net_device_val::verify_bond_ipoib_or_eth_qp_creation() */ sys_image_guid_map_t::iterator guid_iter; for (guid_iter = m_sys_image_guid_map.begin(); guid_iter != m_sys_image_guid_map.end(); guid_iter++) { - char bond_roce_lag_path[256] = {0}; - if (guid_iter->second.size() > 1 && - check_bond_roce_lag_exist(bond_roce_lag_path, sizeof(bond_roce_lag_path), guid_iter->second.front().c_str()) && - check_bond_roce_lag_exist(bond_roce_lag_path, sizeof(bond_roce_lag_path), guid_iter->second.back().c_str())) { - print_roce_lag_warnings(get_ifname_link(), bond_roce_lag_path, guid_iter->second.front().c_str(), guid_iter->second.back().c_str()); + if (guid_iter->second.size() > 1) { + print_roce_lag_warnings(get_ifname_link(), guid_iter->second.front().c_str(), guid_iter->second.back().c_str()); } } #endif /* DEFINED_ROCE_LAG */ @@ -1572,76 +1445,15 @@ bool net_device_val::verify_bond_ipoib_or_eth_qp_creation() } //interface name can be slave while ifa struct can describe bond -bool net_device_val::verify_ipoib_or_eth_qp_creation(const char* interface_name) +bool net_device_val::verify_eth_qp_creation(const char* interface_name) { - if (m_type == ARPHRD_INFINIBAND) { - if (verify_enable_ipoib(interface_name) && verify_qp_creation(interface_name, IBV_QPT_UD)) { - return true; - } - } else { - if (verify_qp_creation(interface_name, IBV_QPT_RAW_PACKET)) { - return true; - } - } - return false; -} - -bool net_device_val::verify_enable_ipoib(const char* interface_name) -{ - char filename[256] = "\0"; - char ifname[IFNAMSIZ] = "\0"; - NOT_IN_USE(interface_name); // Suppress --enable-opt-log=high warning - - if(!safe_mce_sys().enable_ipoib) { - nd_logdbg("Blocking offload: IPoIB interfaces ('%s')", interface_name); - return false; - } - -#ifndef DEFINED_IBV_QP_INIT_SOURCE_QPN - // Note: mlx4 does not support this capability - ib_ctx_handler* ib_ctx = g_p_ib_ctx_handler_collection->get_ib_ctx(get_ifname_link()); - if (!ib_ctx->is_mlx4()) { - nd_logwarn("Blocking offload: SOURCE_QPN is not supported for this driver ('%s')", interface_name); - return false; - } -#endif - - // Verify IPoIB is in 'datagram mode' for proper VMA with flow steering operation - if (validate_ipoib_prop(get_ifname(), m_flags, IPOIB_MODE_PARAM_FILE, "datagram", 8, filename, ifname)) { - vlog_printf(VLOG_WARNING,"*******************************************************************************************************\n"); - vlog_printf(VLOG_WARNING,"* IPoIB mode of interface '%s' is \"connected\" !\n", get_ifname()); - vlog_printf(VLOG_WARNING,"* Please change it to datagram: \"echo datagram > %s\" before loading your application with VMA library\n", filename); - vlog_printf(VLOG_WARNING,"* VMA doesn't support IPoIB in connected mode.\n"); - vlog_printf(VLOG_WARNING,"* Please refer to VMA Release Notes for more information\n"); - vlog_printf(VLOG_WARNING,"*******************************************************************************************************\n"); - return false; - } - else { - nd_logdbg("verified interface '%s' is running in datagram mode", get_ifname()); - } - - // Verify umcast is disabled for IB flow - if (validate_ipoib_prop(get_ifname(), m_flags, UMCAST_PARAM_FILE, "0", 1, filename, ifname)) { // Extract UMCAST flag (only for IB transport types) - vlog_printf(VLOG_WARNING,"*******************************************************************************************************\n"); - vlog_printf(VLOG_WARNING,"* UMCAST flag is Enabled for interface %s !\n", get_ifname()); - vlog_printf(VLOG_WARNING,"* Please disable it: \"echo 0 > %s\" before loading your application with VMA library\n", filename); - vlog_printf(VLOG_WARNING,"* This option in no longer needed in this version\n"); - vlog_printf(VLOG_WARNING,"* Please refer to Release Notes for more information\n"); - vlog_printf(VLOG_WARNING,"*******************************************************************************************************\n"); - return false; - } - else { - nd_logdbg("verified interface '%s' is running with umcast disabled", get_ifname()); - } - - return true; + return verify_qp_creation(interface_name, IBV_QPT_RAW_PACKET); } //ifname should point to a physical device bool net_device_val::verify_qp_creation(const char* ifname, enum ibv_qp_type qp_type) { bool success = false; - char bond_roce_lag_path[256] = {0}; struct ibv_cq* cq = NULL; struct ibv_comp_channel *channel = NULL; struct ibv_qp* qp = NULL; @@ -1649,9 +1461,6 @@ bool net_device_val::verify_qp_creation(const char* ifname, enum ibv_qp_type qp_ vma_ibv_qp_init_attr qp_init_attr; memset(&qp_init_attr, 0, sizeof(qp_init_attr)); - vma_ibv_cq_init_attr attr; - memset(&attr, 0, sizeof(attr)); - qp_init_attr.cap.max_send_wr = MCE_DEFAULT_TX_NUM_WRE; qp_init_attr.cap.max_recv_wr = MCE_DEFAULT_RX_NUM_WRE; qp_init_attr.cap.max_inline_data = MCE_DEFAULT_TX_MAX_INLINE; @@ -1661,7 +1470,7 @@ bool net_device_val::verify_qp_creation(const char* ifname, enum ibv_qp_type qp_ qp_init_attr.qp_type = qp_type; //find ib_cxt - char base_ifname[IFNAMSIZ]; + char base_ifname[IFNAMSIZ] = {0}; get_base_interface_name((const char*)(ifname), base_ifname, sizeof(base_ifname)); int port_num = get_port_from_ifname(base_ifname); ib_ctx_handler* p_ib_ctx = g_p_ib_ctx_handler_collection->get_ib_ctx(base_ifname); @@ -1669,12 +1478,7 @@ bool net_device_val::verify_qp_creation(const char* ifname, enum ibv_qp_type qp_ if (!p_ib_ctx) { nd_logdbg("Cant find ib_ctx for interface %s", base_ifname); if (qp_type == IBV_QPT_RAW_PACKET && m_bond != NO_BOND) { - if (check_bond_roce_lag_exist(bond_roce_lag_path, sizeof(bond_roce_lag_path), ifname)) { - print_roce_lag_warnings(get_ifname_link(), bond_roce_lag_path); - } else if ((p_ib_ctx = g_p_ib_ctx_handler_collection->get_ib_ctx(get_ifname_link())) - && strstr(p_ib_ctx->get_ibname(), "bond")) { - print_roce_lag_warnings(get_ifname_link()); - } + print_roce_lag_warnings(get_ifname_link()); } goto release_resources; } else if (port_num > p_ib_ctx->get_ibv_device_attr()->phys_port_cnt) { @@ -1697,7 +1501,7 @@ bool net_device_val::verify_qp_creation(const char* ifname, enum ibv_qp_type qp_ goto release_resources; } VALGRIND_MAKE_MEM_DEFINED(channel, sizeof(ibv_comp_channel)); - cq = vma_ibv_create_cq(p_ib_ctx->get_ibv_context(), safe_mce_sys().tx_num_wr, (void*)this, channel, 0, &attr); + cq = ibv_create_cq(p_ib_ctx->get_ibv_context(), safe_mce_sys().tx_num_wr, (void*)this, channel, 0); if (!cq) { nd_logdbg("cq creation failed for interface %s (errno=%d %s)", ifname, errno, strerror(errno)); goto release_resources; @@ -1707,14 +1511,6 @@ bool net_device_val::verify_qp_creation(const char* ifname, enum ibv_qp_type qp_ qp_init_attr.recv_cq = cq; qp_init_attr.send_cq = cq; - // Set source qpn for non mlx4 IPoIB devices - if (qp_type == IBV_QPT_UD && !p_ib_ctx->is_mlx4()) { - unsigned char hw_addr[IPOIB_HW_ADDR_LEN]; - get_local_ll_addr(ifname, hw_addr, IPOIB_HW_ADDR_LEN, false); - IPoIB_addr ipoib_addr(hw_addr); - ibv_source_qpn_set(qp_init_attr, ipoib_addr.get_qpn()); - } - qp = vma_ibv_create_qp(p_ib_ctx->get_ibv_pd(), &qp_init_attr); if (qp) { if (qp_type == IBV_QPT_UD && priv_ibv_create_flow_supported(qp, port_num) == -1) { @@ -1737,19 +1533,6 @@ bool net_device_val::verify_qp_creation(const char* ifname, enum ibv_qp_type qp_ nd_logdbg("QP creation failed on interface %s (errno=%d %s), Traffic will not be offloaded", ifname, errno, strerror(errno)); qp_failure: int err = errno; //verify_raw_qp_privliges can overwrite errno so keep it before the call -#if defined(DEFINED_VERBS_VERSION) && (DEFINED_VERBS_VERSION == 2) - if (validate_raw_qp_privliges() == 0) { - // MLNX_OFED raw_qp_privliges file exist with bad value - vlog_printf(VLOG_WARNING,"*******************************************************************************************************\n"); - vlog_printf(VLOG_WARNING,"* Interface %s will not be offloaded.\n", ifname); - vlog_printf(VLOG_WARNING,"* Working in this mode might causes VMA malfunction over Ethernet/InfiniBand interfaces\n"); - vlog_printf(VLOG_WARNING,"* WARNING: the following steps will restart your network interface!\n"); - vlog_printf(VLOG_WARNING,"* 1. \"echo options ib_uverbs disable_raw_qp_enforcement=1 > /etc/modprobe.d/ib_uverbs.conf\"\n"); - vlog_printf(VLOG_WARNING,"* 2. Restart openibd or rdma service depending on your system configuration\n"); - vlog_printf(VLOG_WARNING,"* Read the RAW_PACKET QP root access enforcement section in the VMA's User Manual for more information\n"); - vlog_printf(VLOG_WARNING,"******************************************************************************************************\n"); - } else -#endif /* DEFINED_VERBS_VERSION */ if (validate_user_has_cap_net_raw_privliges() == 0 || err == EPERM) { vlog_printf(VLOG_WARNING,"*******************************************************************************************************\n"); vlog_printf(VLOG_WARNING,"* Interface %s will not be offloaded.\n", ifname); diff --git a/src/vma/dev/net_device_val.h b/src/vma/dev/net_device_val.h index f68623f21f..1a7104b3c8 100644 --- a/src/vma/dev/net_device_val.h +++ b/src/vma/dev/net_device_val.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -47,7 +21,6 @@ #include "vma/event/event_handler_ibverbs.h" #include "vma/event/event_handler_rdma_cm.h" #include "vma/dev/ib_ctx_handler.h" -#include "vma/proto/neighbour_observer.h" #include "vma/proto/L2_address.h" #include "vma/infra/cache_subject_observer.h" @@ -55,7 +28,6 @@ class L2_address; class ring; class ib_ctx_handler; -class neigh_ib_broadcast; #define RING_ALLOC_STR_SIZE 256 class ring_alloc_logic_attr @@ -249,8 +221,6 @@ class net_device_val int release_ring(resource_allocation_key*); // delete from m_hash if ref_cnt == 0 state get_state() const { return m_state; } // not sure, look at state init at c'tor virtual std::string to_str(); - inline void set_transport_type(transport_type_t value) { m_transport_type = value; } - transport_type_t get_transport_type() const { return m_transport_type; } bool update_active_backup_slaves(); in_addr_t get_local_addr() { return m_ip[0]->local_addr; } // Valid object must have at least one address int global_ring_poll_and_process_element(uint64_t *p_poll_sn, void* pv_fd_ready_array = NULL); @@ -275,7 +245,6 @@ class net_device_val L2_address* m_p_L2_addr; L2_address* m_p_br_addr; - transport_type_t m_transport_type; lock_mutex_recursive m_lock; rings_hash_map_t m_h_ring_map; sys_image_guid_map_t m_sys_image_guid_map; @@ -292,9 +261,8 @@ class net_device_val private: void verify_bonding_mode(); bool verify_qp_creation(const char* ifname, enum ibv_qp_type qp_type); - bool verify_bond_ipoib_or_eth_qp_creation(); - bool verify_ipoib_or_eth_qp_creation(const char* interface_name); - bool verify_enable_ipoib(const char* ifname); + bool verify_bond_eth_qp_creation(); + bool verify_eth_qp_creation(const char* interface_name); resource_allocation_key* ring_key_redirection_reserve(resource_allocation_key *key); resource_allocation_key* get_ring_key_redirection(resource_allocation_key *key); @@ -323,7 +291,6 @@ class net_device_val_eth : public net_device_val { public: net_device_val_eth(struct net_device_val_desc *desc) : net_device_val(desc), m_vlan(0) { - set_transport_type(VMA_TRANSPORT_ETH); if (INVALID != get_state()) { set_slave_array(); configure(); @@ -333,7 +300,7 @@ class net_device_val_eth : public net_device_val std::string to_str(); protected: - virtual ring* create_ring(resource_allocation_key *key); + virtual ring* create_ring(resource_allocation_key *key); void parse_prio_egress_map(); private: void configure(); @@ -342,34 +309,4 @@ class net_device_val_eth : public net_device_val uint16_t m_vlan; }; - -class net_device_val_ib : public net_device_val, public neigh_observer, public cache_observer -{ -public: - net_device_val_ib(struct net_device_val_desc *desc) : net_device_val(desc), m_pkey(0), m_br_neigh(NULL) { - set_transport_type(VMA_TRANSPORT_IB); - if (INVALID != get_state()) { - set_slave_array(); - configure(); - } - } - ~net_device_val_ib(); - - std::string to_str(); - uint16_t get_pkey() { return m_pkey; } - const neigh_ib_broadcast* get_br_neigh() {return m_br_neigh;} - virtual transport_type_t get_obs_transport_type() const {return get_transport_type();} - -protected: - ring* create_ring(resource_allocation_key *key); - -private: - void configure(); - L2_address* create_L2_address(const char* ifname); - void create_br_address(const char* ifname); - uint16_t m_pkey; - neigh_ib_broadcast* m_br_neigh; -}; - - #endif diff --git a/src/vma/dev/qp_mgr.cpp b/src/vma/dev/qp_mgr.cpp index 2eb39ba456..9f6151123f 100644 --- a/src/vma/dev/qp_mgr.cpp +++ b/src/vma/dev/qp_mgr.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "qp_mgr.h" @@ -58,8 +32,6 @@ #define FICTIVE_REMOTE_QPN 0x48 #define FICTIVE_REMOTE_QKEY 0x01234567 -#define FICTIVE_AH_SL 5 -#define FICTIVE_AH_DLID 0x3 #define MAX_UPSTREAM_CQ_MSHV_SIZE 8192 @@ -86,16 +58,7 @@ qp_mgr::qp_mgr(struct qp_mgr_desc *desc, const uint32_t tx_num_wr): ,m_n_ip_id_base(0) ,m_n_ip_id_offset(0) { -#ifdef DEFINED_TSO - memset(&m_qp_cap, 0, sizeof(m_qp_cap)); - m_qp_cap.max_inline_data = safe_mce_sys().tx_max_inline; - m_qp_cap.max_send_sge = (m_p_ring->is_tso() ? - m_p_ib_ctx_handler->get_ibv_device_attr()->max_sge : MCE_DEFAULT_TX_NUM_SGE); - m_qp_cap.max_recv_sge = (m_p_ring->is_socketxtreme()) ? 1 : MCE_DEFAULT_RX_NUM_SGE; -#else m_max_inline_data = 0; -#endif /* DEFINED_TSO */ - m_ibv_rx_sg_array = new ibv_sge[m_n_sysvar_rx_num_wr_to_post_recv]; m_ibv_rx_wr_array = new ibv_recv_wr[m_n_sysvar_rx_num_wr_to_post_recv]; @@ -174,8 +137,7 @@ cq_mgr* qp_mgr::init_tx_cq_mgr() int qp_mgr::configure(struct qp_mgr_desc *desc) { - qp_logdbg("Creating QP of transport type '%s' on ibv device '%s' [%p] on port %d", - priv_vma_transport_type_str(m_p_ring->get_transport_type()), + qp_logdbg("Creating QP on ibv device '%s' [%p] on port %d", m_p_ib_ctx_handler->get_ibname(), m_p_ib_ctx_handler->get_ibv_device(), m_port_num); // Check device capabilities for max QP work requests @@ -214,78 +176,6 @@ int qp_mgr::configure(struct qp_mgr_desc *desc) vma_ibv_qp_init_attr qp_init_attr; memset(&qp_init_attr, 0, sizeof(qp_init_attr)); -#ifdef DEFINED_TSO - // TODO: m_tx_num_wr and m_rx_num_wr should be part of m_qp_cap - // and assigned as a result of ibv_query_qp() - m_qp_cap.max_send_wr = m_tx_num_wr; - m_qp_cap.max_recv_wr = m_rx_num_wr; - - memcpy(&qp_init_attr.cap, &m_qp_cap, sizeof(qp_init_attr.cap)); - qp_init_attr.recv_cq = m_p_cq_mgr_rx->get_ibv_cq_hndl(); - qp_init_attr.send_cq = m_p_cq_mgr_tx->get_ibv_cq_hndl(); - qp_init_attr.sq_sig_all = 0; - - // In case of enabled TSO we need to take into account amount of SGE together with header inline - // Per PRM maximum of CTRL + ETH + ETH_HEADER_INLINE+DATA_PTR*NUM_SGE+MAX_INLINE+INLINE_SIZE - // MLX5 return 32678 WQEBBs at max so minimal number - int max_wqe_sz = 16+14+m_p_ring->m_tso.max_header_sz+16*qp_init_attr.cap.max_send_sge+qp_init_attr.cap.max_inline_data+4; - int num_wr = 32678*64/max_wqe_sz; - qp_logdbg("calculated max_wqe_sz=%d num_wr=%d", max_wqe_sz, num_wr); - if (num_wr < (signed)m_tx_num_wr) { - qp_init_attr.cap.max_send_wr = num_wr; // force min for create_qp or you will have error of memory allocation - } - - qp_logdbg("Requested QP parameters: " - "wre: tx = %d rx = %d " - "sge: tx = %d rx = %d " - "inline: %d", - qp_init_attr.cap.max_send_wr, qp_init_attr.cap.max_recv_wr, - qp_init_attr.cap.max_send_sge, qp_init_attr.cap.max_recv_sge, - qp_init_attr.cap.max_inline_data); - - // Create the QP - if (prepare_ibv_qp(qp_init_attr)) { - return -1; - } - - qp_logdbg("Configured QP parameters: " - "wre: tx = %d rx = %d " - "sge: tx = %d rx = %d " - "inline: %d", - qp_init_attr.cap.max_send_wr, qp_init_attr.cap.max_recv_wr, - qp_init_attr.cap.max_send_sge, qp_init_attr.cap.max_recv_sge, - qp_init_attr.cap.max_inline_data); - - /* Check initial parameters with actual */ - enum ibv_qp_attr_mask attr_mask = IBV_QP_CAP; - struct ibv_qp_attr tmp_ibv_qp_attr; - struct ibv_qp_init_attr tmp_ibv_qp_init_attr; - IF_VERBS_FAILURE(ibv_query_qp(m_qp, &tmp_ibv_qp_attr, attr_mask, - &tmp_ibv_qp_init_attr)) { - qp_logerr("ibv_query_qp failed (errno=%d %m)", errno); - return -1; - } ENDIF_VERBS_FAILURE; - m_qp_cap.max_send_wr = min(tmp_ibv_qp_attr.cap.max_send_wr, m_qp_cap.max_send_wr); - m_qp_cap.max_recv_wr = min(tmp_ibv_qp_attr.cap.max_recv_wr, m_qp_cap.max_recv_wr); - m_qp_cap.max_send_sge = min(tmp_ibv_qp_attr.cap.max_send_sge, m_qp_cap.max_send_sge); - m_qp_cap.max_recv_sge = min(tmp_ibv_qp_attr.cap.max_recv_sge, m_qp_cap.max_recv_sge); - m_qp_cap.max_inline_data = min(tmp_ibv_qp_attr.cap.max_inline_data, m_qp_cap.max_inline_data); - - if ( m_qp_cap.max_send_wr < m_tx_num_wr ) { - qp_logwarn("Amount of requested TX_WRE %d lowered to %d", m_tx_num_wr, m_qp_cap.max_send_wr); - m_tx_num_wr = m_qp_cap.max_send_wr; - m_p_ring->set_tx_num_wr( m_tx_num_wr ); - } - - qp_logdbg("Used QP (num=%d) " - "wre: tx = %d rx = %d " - "sge: tx = %d rx = %d " - "inline: %d", - m_qp->qp_num, - m_qp_cap.max_send_wr, m_qp_cap.max_recv_wr, - m_qp_cap.max_send_sge, m_qp_cap.max_recv_sge, - m_qp_cap.max_inline_data); -#else // Check device capabilities for max SG elements uint32_t tx_max_inline = safe_mce_sys().tx_max_inline; uint32_t rx_num_sge = (m_p_ring->is_socketxtreme() ? 1 : MCE_DEFAULT_RX_NUM_SGE); @@ -308,7 +198,6 @@ int qp_mgr::configure(struct qp_mgr_desc *desc) qp_logdbg("Created QP (num=%d) with %d tx wre and inline=%d and %d rx " "wre and %d sge", m_qp->qp_num, m_tx_num_wr, m_max_inline_data, m_rx_num_wr, rx_num_sge); -#endif /* DEFINED_TSO */ #if defined(DEFINED_ROCE_LAG) if (desc->slave && desc->slave->lag_tx_port_affinity > 0) { @@ -412,7 +301,8 @@ void qp_mgr::release_rx_buffers() qp_logdbg("draining rx cq_mgr %p (last_posted_rx_wr_id = %lu)", m_p_cq_mgr_rx, m_last_posted_rx_wr_id); uintptr_t last_polled_rx_wr_id = 0; while (m_p_cq_mgr_rx && last_polled_rx_wr_id != m_last_posted_rx_wr_id && - errno != EIO && !m_p_ib_ctx_handler->is_removed()) { + errno != EIO && !m_p_ib_ctx_handler->is_removed() && + !is_rq_empty()) { // Process the FLUSH'ed WQE's int ret = m_p_cq_mgr_rx->drain_and_proccess(&last_polled_rx_wr_id); @@ -447,7 +337,7 @@ void qp_mgr::release_tx_buffers() void qp_mgr::trigger_completion_for_all_sent_packets() { - vma_ibv_send_wr send_wr; + ibv_send_wr send_wr; ibv_sge sge[1]; // Handle releasing of Tx buffers @@ -470,7 +360,6 @@ void qp_mgr::trigger_completion_for_all_sent_packets() // Prepare dummy packet: zeroed payload ('0000'). // For ETH it replaces the MAC header!! (Nothing is going on the wire, QP in error state) - // For IB it replaces the IPoIB header. /* need to send at least eth+ip, since libmlx5 will drop just eth header */ ethhdr* p_buffer_ethhdr = (ethhdr *)p_mem_buf_desc->p_buffer; @@ -482,38 +371,13 @@ void qp_mgr::trigger_completion_for_all_sent_packets() sge[0].addr = (uintptr_t)(p_mem_buf_desc->p_buffer); sge[0].lkey = m_p_ring->m_tx_lkey; - struct ibv_ah *p_ah = NULL; - ibv_ah_attr ah_attr; - - if (m_p_ring->get_transport_type() == VMA_TRANSPORT_IB) { - memset(&ah_attr, 0, sizeof(ah_attr)); - ah_attr.dlid = FICTIVE_AH_DLID; - ah_attr.sl = FICTIVE_AH_SL; - ah_attr.src_path_bits = 0; - ah_attr.static_rate = 0; - ah_attr.is_global = 0; - ah_attr.port_num = m_port_num; // Do we need it? - - p_ah = ibv_create_ah(m_p_ib_ctx_handler->get_ibv_pd(), &ah_attr); - BULLSEYE_EXCLUDE_BLOCK_START - if (!p_ah && (errno != EIO)) { - qp_logpanic("failed creating address handler (errno=%d %m)", errno); - } - BULLSEYE_EXCLUDE_BLOCK_END - } - - // Prepare send wr for (does not care if it is UD/IB or RAW/ETH) - // UD requires AH+qkey, RAW requires minimal payload instead of MAC header. - memset(&send_wr, 0, sizeof(send_wr)); send_wr.wr_id = (uintptr_t)p_mem_buf_desc; - send_wr.wr.ud.ah = p_ah; - send_wr.wr.ud.remote_qpn = FICTIVE_REMOTE_QPN; - send_wr.wr.ud.remote_qkey = FICTIVE_REMOTE_QKEY; + send_wr.wr.ud.ah = nullptr; send_wr.sg_list = sge; send_wr.num_sge = 1; send_wr.next = NULL; - vma_send_wr_opcode(send_wr) = VMA_IBV_WR_SEND; + vma_send_wr_opcode(send_wr) = IBV_WR_SEND; qp_logdbg("IBV_SEND_SIGNALED"); // Close the Tx unsignaled send list @@ -527,12 +391,6 @@ void qp_mgr::trigger_completion_for_all_sent_packets() m_p_ring->m_tx_num_wr_free--; send_to_wire(&send_wr, (vma_wr_tx_packet_attr)(VMA_TX_PACKET_L3_CSUM|VMA_TX_PACKET_L4_CSUM), true); - if (p_ah) { - IF_VERBS_FAILURE_EX(ibv_destroy_ah(p_ah), EIO) - { - qp_logpanic("failed destroying address handle (errno=%d %m)", errno); - }ENDIF_VERBS_FAILURE; - } } } @@ -592,18 +450,18 @@ void qp_mgr::post_recv_buffers(descq_t* p_buffers, size_t count) } } -inline int qp_mgr::send_to_wire(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr, bool request_comp) +inline int qp_mgr::send_to_wire(ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr, bool request_comp) { NOT_IN_USE(attr); int ret = 0; - vma_ibv_send_wr *bad_wr = NULL; + ibv_send_wr *bad_wr = NULL; if (request_comp) { - vma_send_wr_send_flags(*p_send_wqe) = (vma_ibv_send_flags)(vma_send_wr_send_flags(*p_send_wqe) | VMA_IBV_SEND_SIGNALED); + vma_send_wr_send_flags(*p_send_wqe) = (ibv_send_flags)(vma_send_wr_send_flags(*p_send_wqe) | IBV_SEND_SIGNALED); } - IF_VERBS_FAILURE(vma_ibv_post_send(m_qp, p_send_wqe, &bad_wr)) { - qp_logerr("failed post_send%s (errno=%d %m)\n", ((vma_send_wr_send_flags(*p_send_wqe) & VMA_IBV_SEND_INLINE)?"(+inline)":""), errno); + IF_VERBS_FAILURE(ibv_post_send(m_qp, p_send_wqe, &bad_wr)) { + qp_logerr("failed post_send%s (errno=%d %m)\n", ((vma_send_wr_send_flags(*p_send_wqe) & IBV_SEND_INLINE)?"(+inline)":""), errno); if (bad_wr) { qp_logerr("bad_wr info: wr_id=%#lx, send_flags=%#lx, addr=%#lx, length=%d, lkey=%#x, max_inline_data=%d", bad_wr->wr_id, (unsigned long)vma_send_wr_send_flags(*bad_wr), bad_wr->sg_list[0].addr, bad_wr->sg_list[0].length, bad_wr->sg_list[0].lkey, get_max_inline_data()); @@ -612,12 +470,12 @@ inline int qp_mgr::send_to_wire(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_at } ENDIF_VERBS_FAILURE; // Clear the SINGAL request - vma_send_wr_send_flags(*p_send_wqe) = (vma_ibv_send_flags)(vma_send_wr_send_flags(*p_send_wqe) & ~VMA_IBV_SEND_SIGNALED); + vma_send_wr_send_flags(*p_send_wqe) = (ibv_send_flags)(vma_send_wr_send_flags(*p_send_wqe) & ~IBV_SEND_SIGNALED); return ret; } -int qp_mgr::send(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) +int qp_mgr::send(ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) { mem_buf_desc_t* p_mem_buf_desc = (mem_buf_desc_t *)p_send_wqe->wr_id; @@ -705,13 +563,6 @@ int qp_mgr_eth::prepare_ibv_qp(vma_ibv_qp_init_attr& qp_init_attr) qp_init_attr.qp_type = IBV_QPT_RAW_PACKET; vma_ibv_qp_init_attr_comp_mask(m_p_ib_ctx_handler->get_ibv_pd(), qp_init_attr); -#ifdef DEFINED_TSO - if (m_p_ring->is_tso()) { - vma_ibv_qp_init_attr_tso(qp_init_attr, m_p_ring->get_max_header_sz()); - qp_logdbg("create qp with max_tso_header = %d", m_p_ring->get_max_header_sz()); - } -#endif /* DEFINED_TSO */ - m_qp = vma_ibv_create_qp(m_p_ib_ctx_handler->get_ibv_pd(), &qp_init_attr); BULLSEYE_EXCLUDE_BLOCK_START @@ -726,8 +577,6 @@ int qp_mgr_eth::prepare_ibv_qp(vma_ibv_qp_init_attr& qp_init_attr) } BULLSEYE_EXCLUDE_BLOCK_END -#ifdef DEFINED_TSO -#else enum ibv_qp_attr_mask attr_mask = IBV_QP_CAP; struct ibv_qp_attr tmp_ibv_qp_attr; struct ibv_qp_init_attr tmp_ibv_qp_init_attr; @@ -736,88 +585,10 @@ int qp_mgr_eth::prepare_ibv_qp(vma_ibv_qp_init_attr& qp_init_attr) qp_logerr("ibv_query_qp failed (errno=%d %m)", errno); return -1; } ENDIF_VERBS_FAILURE; - uint32_t tx_max_inline = safe_mce_sys().tx_max_inline; - m_max_inline_data = min(tmp_ibv_qp_attr.cap.max_inline_data, tx_max_inline); - qp_logdbg("requested max inline = %d QP, actual max inline = %d, " - "VMA max inline set to %d, max_send_wr=%d, max_recv_wr=%d, " - "max_recv_sge=%d, max_send_sge=%d", - tx_max_inline, tmp_ibv_qp_init_attr.cap.max_inline_data, - m_max_inline_data, tmp_ibv_qp_attr.cap.max_send_wr, - tmp_ibv_qp_attr.cap.max_recv_wr, tmp_ibv_qp_attr.cap.max_recv_sge, - tmp_ibv_qp_attr.cap.max_send_sge); -#endif /* DEFINED_TSO */ - return 0; -} -void qp_mgr_ib::modify_qp_to_ready_state() -{ - qp_logdbg(""); - int ret = 0; - int qp_state = priv_ibv_query_qp_state(m_qp); - - BULLSEYE_EXCLUDE_BLOCK_START - if (qp_state != IBV_QPS_INIT) { - if ((ret = priv_ibv_modify_qp_from_err_to_init_ud(m_qp, m_port_num, m_pkey_index, m_underly_qpn)) != 0) { - qp_logpanic("failed to modify QP from %d to RTS state (ret = %d)", qp_state, ret); - } - } - if ((ret = priv_ibv_modify_qp_from_init_to_rts(m_qp, m_underly_qpn)) != 0) { - qp_logpanic("failed to modify QP from INIT to RTS state (ret = %d)", ret); - } - BULLSEYE_EXCLUDE_BLOCK_END -} - -int qp_mgr_ib::prepare_ibv_qp(vma_ibv_qp_init_attr& qp_init_attr) -{ - qp_logdbg(""); - int ret = 0; - - qp_init_attr.qp_type = IBV_QPT_UD; - vma_ibv_qp_init_attr_comp_mask(m_p_ib_ctx_handler->get_ibv_pd(), qp_init_attr); - -#ifdef DEFINED_TSO - if (m_p_ring->is_tso()) { - vma_ibv_qp_init_attr_tso(qp_init_attr, m_p_ring->get_max_header_sz()); - qp_logdbg("create qp with max_tso_header = %d", m_p_ring->get_max_header_sz()); - } -#endif /* DEFINED_TSO */ - - if (m_underly_qpn) { - ibv_source_qpn_set(qp_init_attr, m_underly_qpn); - qp_logdbg("create qp using underly qpn = 0x%X", m_underly_qpn); - } - - m_qp = vma_ibv_create_qp(m_p_ib_ctx_handler->get_ibv_pd(), &qp_init_attr); - - BULLSEYE_EXCLUDE_BLOCK_START - if (!m_qp) { - qp_logerr("ibv_create_qp failed (errno=%d %m)", errno); - return -1; - } - - if ((ret = priv_ibv_modify_qp_from_err_to_init_ud(m_qp, m_port_num, - m_pkey_index, - m_underly_qpn)) != 0) { - VLOG_PRINTF_INFO_ONCE_THEN_ALWAYS( - VLOG_ERROR, VLOG_DEBUG, - "failed to modify QP from ERR to INIT state (ret = %d) check number of available fds (ulimit -n)", - ret); - return ret; - } - BULLSEYE_EXCLUDE_BLOCK_END - -#ifdef DEFINED_TSO -#else - enum ibv_qp_attr_mask attr_mask = IBV_QP_CAP; - struct ibv_qp_attr tmp_ibv_qp_attr; - struct ibv_qp_init_attr tmp_ibv_qp_init_attr; - IF_VERBS_FAILURE(ibv_query_qp(m_qp, &tmp_ibv_qp_attr, attr_mask, - &tmp_ibv_qp_init_attr)) { - qp_logerr("ibv_query_qp failed (errno=%d %m)", errno); - return -1; - } ENDIF_VERBS_FAILURE; uint32_t tx_max_inline = safe_mce_sys().tx_max_inline; m_max_inline_data = min(tmp_ibv_qp_attr.cap.max_inline_data, tx_max_inline); + qp_logdbg("requested max inline = %d QP, actual max inline = %d, " "VMA max inline set to %d, max_send_wr=%d, max_recv_wr=%d, " "max_recv_sge=%d, max_send_sge=%d", @@ -825,40 +596,10 @@ int qp_mgr_ib::prepare_ibv_qp(vma_ibv_qp_init_attr& qp_init_attr) m_max_inline_data, tmp_ibv_qp_attr.cap.max_send_wr, tmp_ibv_qp_attr.cap.max_recv_wr, tmp_ibv_qp_attr.cap.max_recv_sge, tmp_ibv_qp_attr.cap.max_send_sge); -#endif /* DEFINED_TSO */ return 0; } -void qp_mgr_ib::update_pkey_index() -{ - qp_logdbg(""); - VALGRIND_MAKE_MEM_DEFINED(&m_pkey, sizeof(m_pkey)); - if (priv_ibv_find_pkey_index(m_p_ib_ctx_handler->get_ibv_context(), get_port_num(), m_pkey, &m_pkey_index)) { - qp_logdbg("IB: Can't find correct pkey_index for pkey '%d'", m_pkey); - m_pkey_index = (uint16_t)-1; - } - else { - qp_logdbg("IB: Found correct pkey_index (%d) for pkey '%d'", m_pkey_index, m_pkey); - } -#ifdef DEFINED_IBV_QP_INIT_SOURCE_QPN - /* m_underly_qpn is introduced to detect if current qp_mgr is able to - * use associated qp. - * It is set to non zero value if OFED supports such possibility only but final - * decision can be made just after attempt to create qp. The value of - * m_underly_qpn is reverted to zero if function to qp creation returns - * failure. - * So zero value for this field means no such capability. - * Note: mlx4 does not support this capability. Disable it explicitly because dynamic check - * using ibv_create_qp does not help - */ - if (!m_p_ib_ctx_handler->is_mlx4()) { - m_underly_qpn = m_p_ring->get_qpn(); - } - qp_logdbg("IB: Use qpn = 0x%X for device: %s", m_underly_qpn, m_p_ib_ctx_handler->get_ibname()); -#endif /* DEFINED_IBV_QP_INIT_SOURCE_QPN */ -} - uint32_t qp_mgr::is_ratelimit_change(struct vma_rate_limit_t &rate_limit) { uint32_t rl_changes = 0; diff --git a/src/vma/dev/qp_mgr.h b/src/vma/dev/qp_mgr.h index 2ccf59735b..6ecaecf987 100644 --- a/src/vma/dev/qp_mgr.h +++ b/src/vma/dev/qp_mgr.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -99,21 +73,10 @@ friend class cq_mgr_mp; virtual void post_recv_buffer(mem_buf_desc_t* p_mem_buf_desc); // Post for receive single mem_buf_desc void post_recv_buffers(descq_t* p_buffers, size_t count); // Post for receive a list of mem_buf_desc - int send(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); - -#ifdef DEFINED_TSO - inline uint32_t get_max_inline_data() const { - return m_qp_cap.max_inline_data; - } - inline uint32_t get_max_send_sge() const { - return m_qp_cap.max_send_sge; - } -#else + int send(ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); uint32_t get_max_inline_data() const {return m_max_inline_data; } -#endif /* DEFINED_TSO */ int get_port_num() const { return m_port_num; } virtual uint16_t get_partiton() const { return 0; }; - virtual uint32_t get_underly_qpn() const { return 0; }; struct ibv_qp* get_ibv_qp() const { return m_qp; }; class cq_mgr* get_tx_cq_mgr() const { return m_p_cq_mgr_tx; } class cq_mgr* get_rx_cq_mgr() const { return m_p_cq_mgr_rx; } @@ -133,29 +96,20 @@ friend class cq_mgr_mp; static inline bool is_lib_mlx5(const char* device_name) {return strstr(device_name, "mlx5");} virtual void dm_release_data(mem_buf_desc_t* buff) { NOT_IN_USE(buff); } virtual bool fill_hw_descriptors(vma_mlx_hw_device_data &data) {NOT_IN_USE(data);return false;}; + protected: struct ibv_qp* m_qp; uint64_t* m_rq_wqe_idx_to_wrid; - ring_simple* m_p_ring; uint8_t m_port_num; ib_ctx_handler* m_p_ib_ctx_handler; - -#ifdef DEFINED_TSO - struct ibv_qp_cap m_qp_cap; -#else uint32_t m_max_inline_data; -#endif /* DEFINED_TSO */ uint32_t m_max_qp_wr; - cq_mgr* m_p_cq_mgr_rx; cq_mgr* m_p_cq_mgr_tx; - uint32_t m_rx_num_wr; uint32_t m_tx_num_wr; - bool m_hw_dummy_send_support; - uint32_t m_n_sysvar_rx_num_wr_to_post_recv; const uint32_t m_n_sysvar_tx_num_wr_to_signal; const uint32_t m_n_sysvar_rx_prefetch_bytes_before_poll; @@ -169,7 +123,6 @@ friend class cq_mgr_mp; // send wr uint32_t m_n_unsignaled_count; mem_buf_desc_t* m_p_last_tx_mem_buf_desc; // Remembered so we can list several mem_buf_desc_t on a single notification request - mem_buf_desc_t* m_p_prev_rx_desc_pushed; // generating packet IDs @@ -186,8 +139,9 @@ friend class cq_mgr_mp; cq_mgr* handle_cq_initialization(uint32_t *num_wr, struct ibv_comp_channel* comp_event_channel, bool is_rx); - virtual int send_to_wire(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr, bool request_comp); + virtual int send_to_wire(ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr, bool request_comp); virtual bool is_completion_need() { return !m_n_unsignaled_count; }; + virtual bool is_rq_empty() const { return false; } }; class qp_mgr_eth : public qp_mgr @@ -212,28 +166,4 @@ class qp_mgr_eth : public qp_mgr const uint16_t m_vlan; }; -class qp_mgr_ib : public qp_mgr -{ -public: - qp_mgr_ib(struct qp_mgr_desc *desc, - const uint32_t tx_num_wr, const uint16_t pkey): - qp_mgr(desc, tx_num_wr), m_pkey(pkey), m_underly_qpn(0) { - update_pkey_index(); - if(configure(desc)) throw_vma_exception("failed creating qp"); }; - - virtual void modify_qp_to_ready_state(); - virtual uint16_t get_partiton() const { return m_pkey; }; - virtual uint32_t get_underly_qpn() const { return m_underly_qpn; }; - -protected: - virtual int prepare_ibv_qp(vma_ibv_qp_init_attr& qp_init_attr); - -private: - const uint16_t m_pkey; - uint16_t m_pkey_index; - uint32_t m_underly_qpn; - - void update_pkey_index(); -}; - #endif diff --git a/src/vma/dev/qp_mgr_eth_direct.cpp b/src/vma/dev/qp_mgr_eth_direct.cpp index 1104540f1f..d06fc2f030 100644 --- a/src/vma/dev/qp_mgr_eth_direct.cpp +++ b/src/vma/dev/qp_mgr_eth_direct.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "qp_mgr_eth_direct.h" #include "vlogger/vlogger.h" @@ -35,8 +9,6 @@ #include "cq_mgr_mlx5.h" #include "ring_simple.h" -#if defined(DEFINED_DIRECT_VERBS) - #undef MODULE_NAME #define MODULE_NAME "qp_mgr_direct" #define qp_logpanic __log_info_panic @@ -143,5 +115,3 @@ qp_mgr_eth_direct::~qp_mgr_eth_direct() delete m_p_cq_mgr_rx; m_p_cq_mgr_rx = NULL; } - -#endif /* DEFINED_DIRECT_VERBS */ diff --git a/src/vma/dev/qp_mgr_eth_direct.h b/src/vma/dev/qp_mgr_eth_direct.h index eb17de15ec..f744c3286e 100644 --- a/src/vma/dev/qp_mgr_eth_direct.h +++ b/src/vma/dev/qp_mgr_eth_direct.h @@ -1,41 +1,13 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef SRC_VMA_DEV_QP_MGR_ETH_DIRECT_H_ #define SRC_VMA_DEV_QP_MGR_ETH_DIRECT_H_ #include "qp_mgr_eth_mlx5.h" -#if defined(DEFINED_DIRECT_VERBS) - class qp_mgr_eth_direct: public qp_mgr_eth_mlx5 { public: @@ -51,6 +23,4 @@ class qp_mgr_eth_direct: public qp_mgr_eth_mlx5 virtual int prepare_ibv_qp(vma_ibv_qp_init_attr& qp_init_attr); }; -#endif /* DEFINED_DIRECT_VERBS */ - #endif /* SRC_VMA_DEV_QP_MGR_ETH_DIRECT_H_ */ diff --git a/src/vma/dev/qp_mgr_eth_mlx5.cpp b/src/vma/dev/qp_mgr_eth_mlx5.cpp index 4b5369adbb..c759247378 100644 --- a/src/vma/dev/qp_mgr_eth_mlx5.cpp +++ b/src/vma/dev/qp_mgr_eth_mlx5.cpp @@ -1,38 +1,10 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "qp_mgr_eth_mlx5.h" -#if defined(DEFINED_DIRECT_VERBS) - #include #include "cq_mgr_mlx5.h" #include "vma/util/utils.h" @@ -84,6 +56,7 @@ static inline uint64_t align_to_WQEBB_up(uint64_t val) static bool is_bf(struct ibv_context *ib_ctx) { char *env; + bool bf_supported = false; /* This limitation is done for RM: 1557652, 1894523, 1914464, 2069198 */ if (safe_mce_sys().hypervisor != mce_sys_var::HYPER_NONE) { @@ -92,11 +65,11 @@ static bool is_bf(struct ibv_context *ib_ctx) env = getenv("MLX5_SHUT_UP_BF"); if (!env || !strcmp(env, "0")) { -#if defined(DEFINED_DIRECT_VERBS) && (DEFINED_DIRECT_VERBS == 3) && defined(MLX5DV_UAR_ALLOC_TYPE_BF) +#if defined(MLX5DV_UAR_ALLOC_TYPE_BF) struct mlx5dv_devx_uar *uar = mlx5dv_devx_alloc_uar(ib_ctx, MLX5DV_UAR_ALLOC_TYPE_BF); if (uar) { mlx5dv_devx_free_uar(uar); - return true; + bf_supported = true; } #else #define VMA_MLX5_MMAP_GET_WC_PAGES_CMD 2 // Corresponding to MLX5_MMAP_GET_WC_PAGES_CMD @@ -112,24 +85,25 @@ static bool is_bf(struct ibv_context *ib_ctx) ib_ctx->cmd_fd, page_size * offset); if (addr != MAP_FAILED) { (void)munmap(addr, page_size); - return true; + bf_supported = true; } -#endif /* DEFINED_DIRECT_VERBS */ +#endif /* MLX5DV_UAR_ALLOC_TYPE_BF */ + } + + if (safe_mce_sys().handle_bf && !bf_supported) { + __log_warn("Unable to initialize BlueFlame. Performance may be affected."); } - return false; + + return bf_supported; } -//! Maps vma_ibv_wr_opcode to real MLX5 opcode. +//! Maps ibv_wr_opcode to real MLX5 opcode. // -static inline uint32_t get_mlx5_opcode(vma_ibv_wr_opcode verbs_opcode) +static inline uint32_t get_mlx5_opcode(ibv_wr_opcode verbs_opcode) { switch (verbs_opcode) { - case VMA_IBV_WR_SEND: + case IBV_WR_SEND: return MLX5_OPCODE_SEND; -#ifdef DEFINED_TSO - case VMA_IBV_WR_TSO: - return MLX5_OPCODE_TSO; -#endif /* DEFINED_TSO */ case VMA_IBV_WR_NOP: return MLX5_OPCODE_NOP; default: @@ -185,11 +159,7 @@ void qp_mgr_eth_mlx5::init_sq() * the 4 bytes used for stating the inline data size * - 3 WQEBB are fully availabie for data inlining */ -#ifdef DEFINED_TSO - m_qp_cap.max_inline_data = OCTOWORD - 4 + 3 * WQEBB; -#else m_max_inline_data = OCTOWORD-4 + 3*WQEBB; -#endif /* DEFINED_TSO */ if (m_sq_wqe_idx_to_wrid == NULL) { m_sq_wqe_idx_to_wrid = (uint64_t*)mmap(NULL, m_tx_num_wr * sizeof(*m_sq_wqe_idx_to_wrid), @@ -336,46 +306,6 @@ inline void qp_mgr_eth_mlx5::set_signal_in_next_send_wqe() wqe->ctrl.data[2] = htonl(8); } -#ifdef DEFINED_TSO -inline void qp_mgr_eth_mlx5::ring_doorbell(uint64_t* wqe, int db_method, int num_wqebb, int num_wqebb_top) -{ - uint64_t* dst = (uint64_t*)((uint8_t*)m_mlx5_qp.bf.reg + m_mlx5_qp.bf.offset); - uint64_t* src = wqe; - - m_sq_wqe_counter = (m_sq_wqe_counter + num_wqebb + num_wqebb_top) & 0xFFFF; - - // Make sure that descriptors are written before - // updating doorbell record and ringing the doorbell - wmb(); - *m_mlx5_qp.sq.dbrec = htonl(m_sq_wqe_counter); - - // This wc_wmb ensures ordering between DB record and BF copy */ - wc_wmb(); - if (likely(db_method == MLX5_DB_METHOD_BF)) { - /* Copying src to BlueFlame register buffer by Write Combining cnt WQEBBs - * Avoid using memcpy() to copy to BlueFlame page, since memcpy() - * implementations may use move-string-buffer assembler instructions, - * which do not guarantee order of copying. - */ - while (num_wqebb--) { - COPY_64B_NT(dst, src); - } - src = (uint64_t*)m_sq_wqes; - while (num_wqebb_top--) { - COPY_64B_NT(dst, src); - } - } else { - *dst = *src; - } - - /* Use wc_wmb() to ensure write combining buffers are flushed out - * of the running CPU. - * sfence instruction affects only the WC buffers of the CPU that executes it - */ - wc_wmb(); - m_mlx5_qp.bf.offset ^= m_mlx5_qp.bf.size; -} -#else inline void qp_mgr_eth_mlx5::ring_doorbell(uint64_t* wqe, int num_wqebb, int num_wqebb_top) { uint64_t* dst = (uint64_t*)((uint8_t*)m_mlx5_qp.bf.reg + m_mlx5_qp.bf.offset); @@ -414,7 +344,6 @@ inline void qp_mgr_eth_mlx5::ring_doorbell(uint64_t* wqe, int num_wqebb, int num wc_wmb(); m_mlx5_qp.bf.offset ^= m_mlx5_qp.bf.size; } -#endif /* DEFINED_TSO */ inline int qp_mgr_eth_mlx5::fill_inl_segment(sg_array &sga, uint8_t *cur_seg, uint8_t* data_addr, int max_inline_len, int inline_len) @@ -463,135 +392,7 @@ inline int qp_mgr_eth_mlx5::fill_ptr_segment(sg_array &sga, struct mlx5_wqe_data } //! Fill WQE dynamically, based on amount of free WQEBB in SQ -#ifdef DEFINED_TSO -inline int qp_mgr_eth_mlx5::fill_wqe(vma_ibv_send_wr *pswr) -{ - // control segment is mostly filled by preset after previous packet - // we always inline ETH header - sg_array sga(pswr->sg_list, pswr->num_sge); - uint8_t* cur_seg = (uint8_t*)m_sq_wqe_hot + sizeof(struct mlx5_wqe_ctrl_seg); - int inline_len = MLX5_ETH_INLINE_HEADER_SIZE; - int data_len = sga.length(); - int wqe_size = sizeof(struct mlx5_wqe_ctrl_seg) / OCTOWORD; - int max_inline_len = get_max_inline_data(); - - // assume packet is full inline - if (likely(data_len <= max_inline_len)) { - uint8_t* data_addr = sga.get_data(&inline_len); // data for inlining in ETH header - data_len -= inline_len; - qp_logfunc("wqe_hot:%p num_sge: %d data_addr: %p data_len: %d max_inline_len: %d inline_len: %d", - m_sq_wqe_hot, pswr->num_sge, data_addr, data_len, max_inline_len, inline_len); - - // Fill Ethernet segment with header inline, static data - // were populated in preset after previous packet send - memcpy(cur_seg+offsetof(struct mlx5_wqe_eth_seg, inline_hdr_start), data_addr, MLX5_ETH_INLINE_HEADER_SIZE); - cur_seg += sizeof(struct mlx5_wqe_eth_seg); - wqe_size += sizeof(struct mlx5_wqe_eth_seg)/OCTOWORD; - - max_inline_len = data_len; - // Filling inline data segment - // size of BlueFlame buffer is 4*WQEBBs, 3*OCTOWORDS of the first - // was allocated for control and ethernet segment so we have 3*WQEBB+16-4 - int rest_space = std::min((int)(m_sq_wqes_end-cur_seg-4), (3*WQEBB+OCTOWORD-4)); - // Filling till the end of inline WQE segment or - // to end of WQEs - if (likely(max_inline_len <= rest_space)) { - inline_len = max_inline_len; - qp_logfunc("data_addr:%p cur_seg: %p rest_space: %d inline_len: %d wqe_size: %d", - data_addr, cur_seg, rest_space, inline_len, wqe_size); - //bypass inline size and fill inline data segment - data_addr = sga.get_data(&inline_len); - inline_len = fill_inl_segment(sga, cur_seg+4, data_addr, max_inline_len, inline_len); - - // store inline data size and mark the data as inlined - *(uint32_t*)((uint8_t*)m_sq_wqe_hot+sizeof(struct mlx5_wqe_ctrl_seg)+sizeof(struct mlx5_wqe_eth_seg)) - = htonl(0x80000000|inline_len); - rest_space = align_to_octoword_up(inline_len+4); // align to OCTOWORDs - wqe_size += rest_space/OCTOWORD; - //assert((data_len-inline_len)==0); - // configuring control - m_sq_wqe_hot->ctrl.data[1] = htonl((m_mlx5_qp.qpn << 8) | wqe_size); - rest_space = align_to_WQEBB_up(wqe_size)/4; - qp_logfunc("data_len: %d inline_len: %d wqe_size: %d wqebbs: %d", - data_len-inline_len, inline_len, wqe_size, rest_space); - ring_doorbell((uint64_t *)m_sq_wqe_hot, m_db_method, rest_space); - return rest_space; - } else { - // wrap around case, first filling till the end of m_sq_wqes - int wrap_up_size = max_inline_len-rest_space; - inline_len = rest_space; - qp_logfunc("WRAP_UP_SIZE: %d data_addr:%p cur_seg: %p rest_space: %d inline_len: %d wqe_size: %d", - wrap_up_size, data_addr, cur_seg, rest_space, inline_len, wqe_size); - - data_addr = sga.get_data(&inline_len); - inline_len = fill_inl_segment(sga, cur_seg+4, data_addr, rest_space, inline_len); - data_len -= inline_len; - rest_space = align_to_octoword_up(inline_len+4); - wqe_size += rest_space/OCTOWORD; - rest_space = align_to_WQEBB_up(rest_space/OCTOWORD)/4;// size of 1st chunk at the end - - qp_logfunc("END chunk data_addr: %p data_len: %d inline_len: %d wqe_size: %d wqebbs: %d", - data_addr, data_len, inline_len, wqe_size, rest_space); - // Wrap around - // - cur_seg = (uint8_t*)m_sq_wqes; - data_addr = sga.get_data(&wrap_up_size); - - wrap_up_size = fill_inl_segment(sga, cur_seg, data_addr, data_len, wrap_up_size); - inline_len += wrap_up_size; - max_inline_len = align_to_octoword_up(wrap_up_size); - wqe_size += max_inline_len/OCTOWORD; - max_inline_len = align_to_WQEBB_up(max_inline_len/OCTOWORD)/4; - // store inline data size - *(uint32_t*)((uint8_t* )m_sq_wqe_hot+sizeof(struct mlx5_wqe_ctrl_seg)+sizeof(struct mlx5_wqe_eth_seg)) - = htonl(0x80000000|inline_len); - qp_logfunc("BEGIN_CHUNK data_addr: %p data_len: %d wqe_size: %d inline_len: %d end_wqebbs: %d wqebbs: %d", - data_addr, data_len-wrap_up_size, wqe_size, inline_len+wrap_up_size, rest_space, max_inline_len); - //assert((data_len-wrap_up_size)==0); - // configuring control - m_sq_wqe_hot->ctrl.data[1] = htonl((m_mlx5_qp.qpn << 8) | wqe_size); - - dbg_dump_wqe((uint32_t*)m_sq_wqe_hot, rest_space*4*16); - dbg_dump_wqe((uint32_t*)m_sq_wqes, max_inline_len*4*16); - - ring_doorbell((uint64_t*)m_sq_wqe_hot, m_db_method, rest_space, max_inline_len); - return rest_space+max_inline_len; - } - } else { - // data is bigger than max to inline we inlined only ETH header + uint from IP (18 bytes) - // the rest will be in data pointer segment - // adding data seg with pointer if there still data to transfer - if (vma_send_wr_opcode(*pswr) == VMA_IBV_WR_SEND ) { - uint8_t* data_addr = sga.get_data(&inline_len); // data for inlining in ETH header - - qp_logfunc("wqe_hot:%p num_sge: %d data_addr: %p data_len: %d max_inline_len: %d inline_len$ %d", - m_sq_wqe_hot, pswr->num_sge, data_addr, data_len, max_inline_len, inline_len); - - // Fill Ethernet segment with header inline, static data - // were populated in preset after previous packet send - memcpy(cur_seg+offsetof(struct mlx5_wqe_eth_seg, inline_hdr_start), data_addr, MLX5_ETH_INLINE_HEADER_SIZE); - data_addr += MLX5_ETH_INLINE_HEADER_SIZE; - data_len -= MLX5_ETH_INLINE_HEADER_SIZE; - cur_seg += sizeof(struct mlx5_wqe_eth_seg); - wqe_size += sizeof(struct mlx5_wqe_eth_seg)/OCTOWORD; - inline_len = fill_ptr_segment(sga, (struct mlx5_wqe_data_seg*)cur_seg, data_addr, data_len, (mem_buf_desc_t *)pswr->wr_id); - wqe_size += inline_len/OCTOWORD; - qp_logfunc("data_addr: %p data_len: %d rest_space: %d wqe_size: %d", - data_addr, data_len, inline_len, wqe_size); - // configuring control - m_sq_wqe_hot->ctrl.data[1] = htonl((m_mlx5_qp.qpn << 8) | wqe_size); - inline_len = align_to_WQEBB_up(wqe_size)/4; - ring_doorbell((uint64_t*)m_sq_wqe_hot, m_db_method, inline_len); - } else { - // We supporting also VMA_IBV_WR_SEND_TSO, it is the case - wqe_size = fill_wqe_lso(pswr); - return wqe_size; - } - } - return 1; -} -#else -inline int qp_mgr_eth_mlx5::fill_wqe(vma_ibv_send_wr *pswr) +inline int qp_mgr_eth_mlx5::fill_wqe(ibv_send_wr *pswr) { // control segment is mostly filled by preset after previous packet // we always inline ETH header @@ -609,6 +410,7 @@ inline int qp_mgr_eth_mlx5::fill_wqe(vma_ibv_send_wr *pswr) // Fill Ethernet segment with header inline, static data // were populated in preset after previous packet send + /* coverity[dereference:FALSE] */ memcpy(cur_seg+offsetof(struct mlx5_wqe_eth_seg, inline_hdr_start), data_addr, MLX5_ETH_INLINE_HEADER_SIZE); data_addr += MLX5_ETH_INLINE_HEADER_SIZE; cur_seg += sizeof(struct mlx5_wqe_eth_seg); @@ -700,126 +502,9 @@ inline int qp_mgr_eth_mlx5::fill_wqe(vma_ibv_send_wr *pswr) } return 1; } -#endif /* DEFINED_TSO */ - -#ifdef DEFINED_TSO -//! Filling wqe for LSO -int qp_mgr_eth_mlx5::fill_wqe_lso(vma_ibv_send_wr* pswr) -{ - struct mlx5_wqe_eth_seg* eth_seg = (struct mlx5_wqe_eth_seg*)((uint8_t*)m_sq_wqe_hot + sizeof(struct mlx5_wqe_ctrl_seg)); - struct mlx5_wqe_data_seg* dp_seg = NULL; - uint8_t* cur_seg = (uint8_t*)eth_seg; - uint8_t* p_hdr = (uint8_t*)pswr->tso.hdr; - int wqe_size = sizeof(struct mlx5_wqe_ctrl_seg) / OCTOWORD; - // For TSO we fully inline headers in Ethernet segment - // - int inline_len = pswr->tso.hdr_sz; - int max_inline_len = align_to_octoword_up(sizeof(struct mlx5_wqe_eth_seg) + inline_len - MLX5_ETH_INLINE_HEADER_SIZE); - eth_seg->mss = htons(pswr->tso.mss); - eth_seg->inline_hdr_sz = htons(inline_len); - int rest = (int)(m_sq_wqes_end - (uint8_t*)eth_seg); - int bottom_hdr_sz = 0; - int i = 0; - - if (likely(max_inline_len < rest)) { - // Fill Ethernet segment with full header inline - memcpy(cur_seg+offsetof(struct mlx5_wqe_eth_seg, inline_hdr_start), p_hdr, inline_len); - cur_seg += max_inline_len; - } else { - // wrap around SQ on inline ethernet header - bottom_hdr_sz = rest - offsetof(struct mlx5_wqe_eth_seg, inline_hdr_start); - memcpy(cur_seg + offsetof(struct mlx5_wqe_eth_seg, inline_hdr_start), p_hdr, bottom_hdr_sz); - memcpy(m_sq_wqes, p_hdr + bottom_hdr_sz, inline_len - bottom_hdr_sz); - max_inline_len = align_to_octoword_up(inline_len - bottom_hdr_sz); - cur_seg = (uint8_t*)m_sq_wqes + max_inline_len; - wqe_size += rest / OCTOWORD; - bottom_hdr_sz = align_to_WQEBB_up(wqe_size) / 4; - } - wqe_size += max_inline_len / OCTOWORD; - qp_logfunc("TSO: num_sge: %d max_inline_len: %d inline_len: %d rest: %d", - pswr->num_sge, max_inline_len, inline_len, rest); - // Filling data pointer segments with payload by scatter-gather list elements - dp_seg = (struct mlx5_wqe_data_seg*)cur_seg; - for (i = 0; i < pswr->num_sge; i++) { - if (unlikely((uintptr_t)dp_seg >= (uintptr_t)m_sq_wqes_end)) { - dp_seg = (struct mlx5_wqe_data_seg *)m_sq_wqes; - bottom_hdr_sz = align_to_WQEBB_up(wqe_size)/4; - } - dp_seg->addr = htonll((uint64_t)pswr->sg_list[i].addr); - dp_seg->lkey = htonl(pswr->sg_list[i].lkey); - dp_seg->byte_count = htonl(pswr->sg_list[i].length); - - qp_logfunc("DATA_SEG: addr:%llx len: %d lkey: %x dp_seg: %p wqe_size: %d", - pswr->sg_list[i].addr, pswr->sg_list[i].length, dp_seg->lkey, dp_seg, wqe_size); - - dp_seg ++; - wqe_size += sizeof(struct mlx5_wqe_data_seg)/OCTOWORD; - } - inline_len = align_to_WQEBB_up(wqe_size) / 4; - m_sq_wqe_hot->ctrl.data[1] = htonl((m_mlx5_qp.qpn << 8) | wqe_size); - // sending by BlueFlame or DoorBell covering wrap around - if (likely(inline_len <= 4)) { - if (likely(bottom_hdr_sz == 0)) { - ring_doorbell((uint64_t*)m_sq_wqe_hot, MLX5_DB_METHOD_DB, inline_len); - } else { - ring_doorbell((uint64_t*)m_sq_wqe_hot, MLX5_DB_METHOD_DB, bottom_hdr_sz, inline_len - bottom_hdr_sz); - } - } else { - ring_doorbell((uint64_t*)m_sq_wqe_hot, MLX5_DB_METHOD_DB, inline_len); - } - return wqe_size; -} -#endif /* DEFINED_TSO */ //! Send one RAW packet by MLX5 BlueFlame -// -#ifdef DEFINED_TSO -int qp_mgr_eth_mlx5::send_to_wire(vma_ibv_send_wr *p_send_wqe, vma_wr_tx_packet_attr attr, bool request_comp) -{ - struct mlx5_wqe_ctrl_seg *ctrl = NULL; - struct mlx5_wqe_eth_seg *eseg = NULL; - - ctrl = (struct mlx5_wqe_ctrl_seg *)m_sq_wqe_hot; - eseg = (struct mlx5_wqe_eth_seg *)((uint8_t *)m_sq_wqe_hot + sizeof(*ctrl)); - - /* Configure ctrl segment - * qpn_ds or ctrl.data[1] is set inside fill_wqe() - */ - ctrl->opmod_idx_opcode = htonl(((m_sq_wqe_counter & 0xffff) << 8) | (get_mlx5_opcode(vma_send_wr_opcode(*p_send_wqe)) & 0xff)); - m_sq_wqe_hot->ctrl.data[2] = 0; - ctrl->fm_ce_se = (request_comp ? (uint8_t)MLX5_WQE_CTRL_CQ_UPDATE : 0); - ctrl->imm = 0; - - /* Configure eth segment - * reset rsvd0, cs_flags, rsvd1, mss and rsvd2 fields - * checksum flags are set here - */ - *((uint64_t *)eseg) = 0; - eseg->rsvd2 = 0; - eseg->cs_flags = (uint8_t)(attr & (VMA_TX_PACKET_L3_CSUM | VMA_TX_PACKET_L4_CSUM) & 0xff); - - /* Complete WQE */ - fill_wqe(p_send_wqe); - - /* Store buffer descriptor */ - m_sq_wqe_idx_to_wrid[m_sq_wqe_hot_index] = (uintptr_t)p_send_wqe->wr_id; - - /* Preparing next WQE and index */ - m_sq_wqe_hot = &(*m_sq_wqes)[m_sq_wqe_counter & (m_tx_num_wr - 1)]; - qp_logfunc("m_sq_wqe_hot: %p m_sq_wqe_hot_index: %d wqe_counter: %d new_hot_index: %d wr_id: %llx", - m_sq_wqe_hot, m_sq_wqe_hot_index, m_sq_wqe_counter, (m_sq_wqe_counter&(m_tx_num_wr-1)), p_send_wqe->wr_id); - m_sq_wqe_hot_index = m_sq_wqe_counter & (m_tx_num_wr - 1); - - memset((void*)m_sq_wqe_hot, 0, sizeof(struct mlx5_wqe64)); - - /* Fill Ethernet segment with header inline */ - eseg = (struct mlx5_wqe_eth_seg*)((uint8_t*)m_sq_wqe_hot + sizeof(struct mlx5_wqe_ctrl_seg)); - eseg->inline_hdr_sz = htons(MLX5_ETH_INLINE_HEADER_SIZE); - - return 0; -} -#else -int qp_mgr_eth_mlx5::send_to_wire(vma_ibv_send_wr *p_send_wqe, vma_wr_tx_packet_attr attr, bool request_comp) +int qp_mgr_eth_mlx5::send_to_wire(ibv_send_wr *p_send_wqe, vma_wr_tx_packet_attr attr, bool request_comp) { // Set current WQE's ethernet segment checksum flags struct mlx5_wqe_eth_seg* eth_seg = (struct mlx5_wqe_eth_seg*)((uint8_t*)m_sq_wqe_hot+sizeof(struct mlx5_wqe_ctrl_seg)); @@ -845,7 +530,6 @@ int qp_mgr_eth_mlx5::send_to_wire(vma_ibv_send_wr *p_send_wqe, vma_wr_tx_packet_ return 0; } -#endif /* DEFINED_TSO */ //! Handle releasing of Tx buffers // Single post send with SIGNAL of a dummy packet @@ -882,7 +566,7 @@ void qp_mgr_eth_mlx5::trigger_completion_for_all_sent_packets() // Prepare send wr for (does not care if it is UD/IB or RAW/ETH) // UD requires AH+qkey, RAW requires minimal payload instead of MAC header. - vma_ibv_send_wr send_wr; + ibv_send_wr send_wr; memset(&send_wr, 0, sizeof(send_wr)); send_wr.wr_id = (uintptr_t)p_mem_buf_desc; @@ -890,7 +574,7 @@ void qp_mgr_eth_mlx5::trigger_completion_for_all_sent_packets() send_wr.sg_list = sge; send_wr.num_sge = 1; send_wr.next = NULL; - vma_send_wr_opcode(send_wr) = VMA_IBV_WR_SEND; + vma_send_wr_opcode(send_wr) = IBV_WR_SEND; // Close the Tx unsignaled send list set_unsignaled_count(); @@ -906,5 +590,3 @@ void qp_mgr_eth_mlx5::trigger_completion_for_all_sent_packets() send_to_wire(&send_wr, (vma_wr_tx_packet_attr)(VMA_TX_PACKET_L3_CSUM|VMA_TX_PACKET_L4_CSUM), true); } } - -#endif /* DEFINED_DIRECT_VERBS */ diff --git a/src/vma/dev/qp_mgr_eth_mlx5.h b/src/vma/dev/qp_mgr_eth_mlx5.h index 742cc0b85f..3b284e645f 100644 --- a/src/vma/dev/qp_mgr_eth_mlx5.h +++ b/src/vma/dev/qp_mgr_eth_mlx5.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -38,9 +12,6 @@ #include "vma/util/sg_array.h" #include "vma/dev/dm_mgr.h" -#if defined(DEFINED_DIRECT_VERBS) - - struct mlx5_wqe64 { union { struct mlx5_wqe_ctrl_seg ctrl; @@ -66,6 +37,8 @@ friend class cq_mgr_mlx5; void trigger_completion_for_all_sent_packets(); void init_sq(); + virtual bool is_rq_empty() const { return (m_mlx5_qp.rq.head == m_mlx5_qp.rq.tail); } + uint64_t* m_sq_wqe_idx_to_wrid; uint64_t m_rq_wqe_counter; private: @@ -75,14 +48,9 @@ friend class cq_mgr_mlx5; virtual void dm_release_data(mem_buf_desc_t* buff) { m_dm_mgr.release_data(buff); } inline void set_signal_in_next_send_wqe(); - int send_to_wire(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr, bool request_comp); - inline int fill_wqe(vma_ibv_send_wr* p_send_wqe); -#ifdef DEFINED_TSO - int fill_wqe_lso(vma_ibv_send_wr* pswr); - inline void ring_doorbell(uint64_t* wqe, int db_method, int num_wqebb, int num_wqebb_top = 0); -#else + int send_to_wire(ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr, bool request_comp); + inline int fill_wqe(ibv_send_wr* p_send_wqe); inline void ring_doorbell(uint64_t* wqe, int num_wqebb, int num_wqebb_top = 0); -#endif /* DEFINED_TSO */ inline int fill_inl_segment(sg_array &sga, uint8_t *cur_seg, uint8_t* data_addr, int max_inline_len, int inline_len); inline int fill_ptr_segment(sg_array &sga, struct mlx5_wqe_data_seg* dp_seg, uint8_t* data_addr, int data_len, mem_buf_desc_t* buffer); @@ -99,5 +67,5 @@ friend class cq_mgr_mlx5; dm_mgr m_dm_mgr; bool m_dm_enabled; }; -#endif //defined(DEFINED_DIRECT_VERBS) + #endif //QP_MGR_ETH_MLX5_H diff --git a/src/vma/dev/rfs.cpp b/src/vma/dev/rfs.cpp index d14ea732e6..fa78f6d1ce 100644 --- a/src/vma/dev/rfs.cpp +++ b/src/vma/dev/rfs.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -274,7 +248,7 @@ bool rfs::create_ibv_flow() { for (size_t i = 0; i < m_attach_flow_data_vector.size(); i++) { attach_flow_data_t* iter = m_attach_flow_data_vector[i]; - iter->ibv_flow = vma_ibv_create_flow(iter->p_qp_mgr->get_ibv_qp(), &(iter->ibv_flow_attr)); + iter->ibv_flow = ibv_create_flow(iter->p_qp_mgr->get_ibv_qp(), &(iter->ibv_flow_attr)); if (!iter->ibv_flow) { rfs_logerr("Create of QP flow ID (tag: %d) failed with flow %s (errno=%d - %m)", m_flow_tag_id, m_flow_tuple.to_str(), errno); //TODO ALEXR - Add info about QP, spec, priority into log msg @@ -295,7 +269,7 @@ bool rfs::destroy_ibv_flow() rfs_logdbg("Destroy of QP flow ID failed - QP flow ID that was not created. This is OK for MC same ip diff port scenario."); //TODO ALEXR - Add info about QP, spec, priority into log msg } if (iter->ibv_flow) { - IF_VERBS_FAILURE_EX(vma_ibv_destroy_flow(iter->ibv_flow), EIO) { + IF_VERBS_FAILURE_EX(ibv_destroy_flow(iter->ibv_flow), EIO) { rfs_logerr("Destroy of QP flow ID failed"); //TODO ALEXR - Add info about QP, spec, priority into log msg } ENDIF_VERBS_FAILURE; } diff --git a/src/vma/dev/rfs.h b/src/vma/dev/rfs.h index ae9357b495..132c3b1251 100644 --- a/src/vma/dev/rfs.h +++ b/src/vma/dev/rfs.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -56,23 +30,21 @@ class qp_mgr; class pkt_rcvr_sink; -/* ETHERNET - */ typedef struct attach_flow_data_eth_ipv4_tcp_udp_t { struct ibv_flow * ibv_flow; qp_mgr* p_qp_mgr; struct ibv_flow_attr_eth_ipv4_tcp_udp { vma_ibv_flow_attr attr; - vma_ibv_flow_spec_eth eth; - vma_ibv_flow_spec_ipv4 ipv4; - vma_ibv_flow_spec_tcp_udp tcp_udp; + ibv_flow_spec_eth eth; + ibv_flow_spec_ipv4 ipv4; + ibv_flow_spec_tcp_udp tcp_udp; vma_ibv_flow_spec_action_tag flow_tag; // must be the last as struct can be used without it ibv_flow_attr_eth_ipv4_tcp_udp(uint8_t port) { memset(this, 0, sizeof(*this)); attr.size = sizeof(struct ibv_flow_attr_eth_ipv4_tcp_udp) - sizeof(flow_tag); attr.num_of_specs = 3; - attr.type = VMA_IBV_FLOW_ATTR_NORMAL; + attr.type = IBV_FLOW_ATTR_NORMAL; attr.priority = 1; // almost highest priority, 0 is used for 5-tuple later attr.port = port; } @@ -87,114 +59,10 @@ typedef struct attach_flow_data_eth_ipv4_tcp_udp_t { ibv_flow_attr(qp_mgr->get_port_num()) {} } attach_flow_data_eth_ipv4_tcp_udp_t; -/* IPOIB (MC) - */ -typedef struct attach_flow_data_ib_v2_t { - struct ibv_flow * ibv_flow; - qp_mgr* p_qp_mgr; - struct ibv_flow_attr_ib_v2 { - vma_ibv_flow_attr attr; - vma_ibv_flow_spec_ipv4 ipv4; - vma_ibv_flow_spec_tcp_udp tcp_udp; - - ibv_flow_attr_ib_v2(uint8_t port) { - memset(this, 0, sizeof(*this)); - attr.size = sizeof(struct ibv_flow_attr_ib_v2); - attr.num_of_specs = 2; - attr.type = VMA_IBV_FLOW_ATTR_NORMAL; - attr.priority = 1; // almost highest priority, 0 is used for 5-tuple later - attr.port = port; - } - } ibv_flow_attr; - attach_flow_data_ib_v2_t(qp_mgr* qp_mgr) : - ibv_flow(NULL), - p_qp_mgr(qp_mgr), - ibv_flow_attr(qp_mgr->get_port_num()) {} - -} attach_flow_data_ib_v2_t; - -#ifdef DEFINED_IBV_FLOW_SPEC_IB -typedef struct attach_flow_data_ib_v1_t { - struct ibv_flow * ibv_flow; - qp_mgr* p_qp_mgr; - struct ibv_flow_attr_ib_v1 { - vma_ibv_flow_attr attr; - vma_ibv_flow_spec_ib ib; - - ibv_flow_attr_ib_v1(uint8_t port) { - memset(this, 0, sizeof(*this)); - attr.size = sizeof(struct ibv_flow_attr_ib_v1); - attr.num_of_specs = 1; - attr.type = VMA_IBV_FLOW_ATTR_NORMAL; - attr.priority = 1; // almost highest priority, 0 is used for 5-tuple later - attr.port = port; - } - } ibv_flow_attr; - attach_flow_data_ib_v1_t(qp_mgr* qp_mgr) : - ibv_flow(NULL), - p_qp_mgr(qp_mgr), - ibv_flow_attr(qp_mgr->get_port_num()) {} - -} attach_flow_data_ib_v1_t; -#endif - -/* IPOIB (UC) - */ -typedef struct attach_flow_data_ib_ipv4_tcp_udp_v2_t { - struct ibv_flow * ibv_flow; - qp_mgr* p_qp_mgr; - struct ibv_flow_attr_ib_ipv4_tcp_udp_v2 { - - vma_ibv_flow_attr attr; - vma_ibv_flow_spec_ipv4 ipv4; - vma_ibv_flow_spec_tcp_udp tcp_udp; - - ibv_flow_attr_ib_ipv4_tcp_udp_v2(uint8_t port) { - memset(this, 0, sizeof(*this)); - attr.size = sizeof(struct ibv_flow_attr_ib_ipv4_tcp_udp_v2); - attr.num_of_specs = 2; - attr.type = VMA_IBV_FLOW_ATTR_NORMAL; - attr.priority = 1; // almost highest priority, 0 is used for 5-tuple later - attr.port = port; - } - } ibv_flow_attr; - attach_flow_data_ib_ipv4_tcp_udp_v2_t(qp_mgr* qp_mgr) : - ibv_flow(NULL), - p_qp_mgr(qp_mgr), - ibv_flow_attr(qp_mgr->get_port_num()) {} -} attach_flow_data_ib_ipv4_tcp_udp_v2_t; - -#ifdef DEFINED_IBV_FLOW_SPEC_IB -typedef struct attach_flow_data_ib_ipv4_tcp_udp_v1_t { - struct ibv_flow * ibv_flow; - qp_mgr* p_qp_mgr; - struct ibv_flow_attr_ib_ipv4_tcp_udp_v1 { - - vma_ibv_flow_attr attr; - vma_ibv_flow_spec_ib ib; - vma_ibv_flow_spec_ipv4 ipv4; - vma_ibv_flow_spec_tcp_udp tcp_udp; - - ibv_flow_attr_ib_ipv4_tcp_udp_v1(uint8_t port) { - memset(this, 0, sizeof(*this)); - attr.size = sizeof(struct ibv_flow_attr_ib_ipv4_tcp_udp_v1); - attr.num_of_specs = 3; - attr.type = VMA_IBV_FLOW_ATTR_NORMAL; - attr.priority = 1; // almost highest priority, 0 is used for 5-tuple later - attr.port = port; - } - } ibv_flow_attr; - attach_flow_data_ib_ipv4_tcp_udp_v1_t(qp_mgr* qp_mgr) : - ibv_flow(NULL), - p_qp_mgr(qp_mgr), - ibv_flow_attr(qp_mgr->get_port_num()) {} -} attach_flow_data_ib_ipv4_tcp_udp_v1_t; -#endif /* DEFINED_IBV_FLOW_SPEC_IB */ - typedef struct attach_flow_data_t { - vma_ibv_flow * ibv_flow; - qp_mgr* p_qp_mgr; - vma_ibv_flow_attr ibv_flow_attr; + vma_ibv_flow* ibv_flow; + qp_mgr* p_qp_mgr; + vma_ibv_flow_attr ibv_flow_attr; } attach_flow_data_t; typedef std::vector attach_flow_data_vector_t; @@ -253,7 +121,7 @@ class rfs bool destroy_ibv_flow(); // Detach flow from all qps bool add_sink(pkt_rcvr_sink* p_sink); bool del_sink(pkt_rcvr_sink* p_sink); - virtual bool prepare_flow_spec() = 0; + virtual void prepare_flow_spec() = 0; private: rfs(); // I don't want anyone to use the default constructor diff --git a/src/vma/dev/rfs_mc.cpp b/src/vma/dev/rfs_mc.cpp index 0ffef04474..ed35554d20 100644 --- a/src/vma/dev/rfs_mc.cpp +++ b/src/vma/dev/rfs_mc.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -48,12 +22,12 @@ rfs_mc::rfs_mc(flow_tuple *flow_spec_5t, ring_slave *p_ring, rfs_rule_filter* ru } BULLSEYE_EXCLUDE_BLOCK_END - if (m_p_ring->is_simple() && !prepare_flow_spec()) { - throw_vma_exception("IB multicast offload is not supported"); + if (m_p_ring->is_simple()) { + prepare_flow_spec(); } } -bool rfs_mc::prepare_flow_spec() +void rfs_mc::prepare_flow_spec() { ring_simple* p_ring = dynamic_cast(m_p_ring); @@ -61,8 +35,6 @@ bool rfs_mc::prepare_flow_spec() rfs_logpanic("Incompatible ring type"); } - transport_type_t type = p_ring->get_transport_type(); - /* * todo note that ring is not locked here. * we touch members that should not change during the ring life. @@ -71,93 +43,39 @@ bool rfs_mc::prepare_flow_spec() */ attach_flow_data_t* p_attach_flow_data = NULL; - switch (type) { - case VMA_TRANSPORT_IB: - { - attach_flow_data_ib_v2_t* attach_flow_data_ib_v2 = NULL; - - if (0 == p_ring->m_p_qp_mgr->get_underly_qpn()) { - // IB MC flow steering is done only on L2 --> need to zero other fields to get correct behaviour - // CX3 HW does not support L3+L4 MC flow steering rule -#ifdef DEFINED_IBV_FLOW_SPEC_IB - attach_flow_data_ib_v1_t* attach_flow_data_ib_v1 = NULL; - - attach_flow_data_ib_v1 = new attach_flow_data_ib_v1_t(p_ring->m_p_qp_mgr); - - uint8_t dst_gid[16]; - create_mgid_from_ipv4_mc_ip(dst_gid, p_ring->m_p_qp_mgr->get_partiton(), m_flow_tuple.get_dst_ip()); - ibv_flow_spec_ib_set_by_dst_gid(&(attach_flow_data_ib_v1->ibv_flow_attr.ib), - dst_gid); - - p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_ib_v1; - break; -#else - return false; -#endif - } - - attach_flow_data_ib_v2 = new attach_flow_data_ib_v2_t(p_ring->m_p_qp_mgr); - - ibv_flow_spec_ipv4_set(&(attach_flow_data_ib_v2->ibv_flow_attr.ipv4), - m_flow_tuple.get_dst_ip(), - 0); - - ibv_flow_spec_tcp_udp_set(&(attach_flow_data_ib_v2->ibv_flow_attr.tcp_udp), - (m_flow_tuple.get_protocol() == PROTO_TCP), - m_flow_tuple.get_dst_port(), - m_flow_tuple.get_src_port()); - - p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_ib_v2; - break; - } - case VMA_TRANSPORT_ETH: - { - attach_flow_data_eth_ipv4_tcp_udp_t* attach_flow_data_eth = NULL; - - attach_flow_data_eth = new attach_flow_data_eth_ipv4_tcp_udp_t(p_ring->m_p_qp_mgr); - - uint8_t dst_mac[6]; - create_multicast_mac_from_ip(dst_mac, m_flow_tuple.get_dst_ip()); - ibv_flow_spec_eth_set(&(attach_flow_data_eth->ibv_flow_attr.eth), - dst_mac, - htons(p_ring->m_p_qp_mgr->get_partiton())); - - if (safe_mce_sys().eth_mc_l2_only_rules) { - ibv_flow_spec_ipv4_set(&(attach_flow_data_eth->ibv_flow_attr.ipv4), 0, 0); - ibv_flow_spec_tcp_udp_set(&(attach_flow_data_eth->ibv_flow_attr.tcp_udp), 0, 0, 0); - p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_eth; - break; - } - - ibv_flow_spec_ipv4_set(&(attach_flow_data_eth->ibv_flow_attr.ipv4), - m_flow_tuple.get_dst_ip(), - 0); - - ibv_flow_spec_tcp_udp_set(&(attach_flow_data_eth->ibv_flow_attr.tcp_udp), - (m_flow_tuple.get_protocol() == PROTO_TCP), - m_flow_tuple.get_dst_port(), - m_flow_tuple.get_src_port()); - - if (m_flow_tag_id) { // Will not attach flow_tag spec to rule for tag_id==0 - ibv_flow_spec_flow_tag_set(&attach_flow_data_eth->ibv_flow_attr.flow_tag, m_flow_tag_id); - attach_flow_data_eth->ibv_flow_attr.add_flow_tag_spec(); - rfs_logdbg("Adding flow_tag spec to MC rule, num_of_specs: %d flow_tag_id: %d", - attach_flow_data_eth->ibv_flow_attr.attr.num_of_specs, m_flow_tag_id); - } - - p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_eth; - break; - } - BULLSEYE_EXCLUDE_BLOCK_START - default: - rfs_logpanic("Incompatible transport type = %d", type); - return false; - break; - BULLSEYE_EXCLUDE_BLOCK_END + attach_flow_data_eth_ipv4_tcp_udp_t* attach_flow_data_eth = NULL; + + attach_flow_data_eth = new attach_flow_data_eth_ipv4_tcp_udp_t(p_ring->m_p_qp_mgr); + + uint8_t dst_mac[6]; + create_multicast_mac_from_ip(dst_mac, m_flow_tuple.get_dst_ip()); + ibv_flow_spec_eth_set(&(attach_flow_data_eth->ibv_flow_attr.eth), + dst_mac, htons(p_ring->m_p_qp_mgr->get_partiton())); + + if (safe_mce_sys().eth_mc_l2_only_rules) { + ibv_flow_spec_ipv4_set(&(attach_flow_data_eth->ibv_flow_attr.ipv4), 0, 0); + ibv_flow_spec_tcp_udp_set(&(attach_flow_data_eth->ibv_flow_attr.tcp_udp), 0, 0, 0); + p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_eth; + } else { + ibv_flow_spec_ipv4_set(&(attach_flow_data_eth->ibv_flow_attr.ipv4), + m_flow_tuple.get_dst_ip(), 0); + + ibv_flow_spec_tcp_udp_set(&(attach_flow_data_eth->ibv_flow_attr.tcp_udp), + (m_flow_tuple.get_protocol() == PROTO_TCP), + m_flow_tuple.get_dst_port(), + m_flow_tuple.get_src_port()); + + if (m_flow_tag_id) { // Will not attach flow_tag spec to rule for tag_id==0 + ibv_flow_spec_flow_tag_set(&attach_flow_data_eth->ibv_flow_attr.flow_tag, m_flow_tag_id); + attach_flow_data_eth->ibv_flow_attr.add_flow_tag_spec(); + rfs_logdbg("Adding flow_tag spec to MC rule, num_of_specs: %d flow_tag_id: %d", + attach_flow_data_eth->ibv_flow_attr.attr.num_of_specs, m_flow_tag_id); + } + + p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_eth; } m_attach_flow_data_vector.push_back(p_attach_flow_data); - return true; } bool rfs_mc::rx_dispatch_packet(mem_buf_desc_t* p_rx_wc_buf_desc, void* pv_fd_ready_array) diff --git a/src/vma/dev/rfs_mc.h b/src/vma/dev/rfs_mc.h index 33b1ad2d10..2cdeee455f 100644 --- a/src/vma/dev/rfs_mc.h +++ b/src/vma/dev/rfs_mc.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -54,7 +28,7 @@ class rfs_mc : public rfs virtual bool rx_dispatch_packet(mem_buf_desc_t* p_rx_wc_buf_desc, void* pv_fd_ready_array); protected: - virtual bool prepare_flow_spec(); + virtual void prepare_flow_spec(); }; diff --git a/src/vma/dev/rfs_uc.cpp b/src/vma/dev/rfs_uc.cpp index 18d25f898b..5567c6cb27 100644 --- a/src/vma/dev/rfs_uc.cpp +++ b/src/vma/dev/rfs_uc.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -39,7 +13,6 @@ #define MODULE_NAME "rfs_uc" - rfs_uc::rfs_uc(flow_tuple *flow_spec_5t, ring_slave *p_ring, rfs_rule_filter* rule_filter, uint32_t flow_tag_id) : rfs(flow_spec_5t, p_ring, rule_filter, flow_tag_id) { @@ -49,12 +22,12 @@ rfs_uc::rfs_uc(flow_tuple *flow_spec_5t, ring_slave *p_ring, rfs_rule_filter* ru } BULLSEYE_EXCLUDE_BLOCK_END - if (m_p_ring->is_simple() && !prepare_flow_spec()) { - throw_vma_exception("rfs_uc: Incompatible transport type"); + if (m_p_ring->is_simple()) { + prepare_flow_spec(); } } -bool rfs_uc::prepare_flow_spec() +void rfs_uc::prepare_flow_spec() { ring_simple* p_ring = dynamic_cast(m_p_ring); @@ -62,64 +35,27 @@ bool rfs_uc::prepare_flow_spec() rfs_logpanic("Incompatible ring type"); } - transport_type_t type = p_ring->get_transport_type(); /* * todo note that ring is not locked here. * we touch members that should not change during the ring life. * the ring will not be deleted as we increased refcnt. * if one of these assumptions change, we must lock. */ - attach_flow_data_t* p_attach_flow_data = NULL; - vma_ibv_flow_spec_ipv4* p_ipv4 = NULL; - vma_ibv_flow_spec_tcp_udp* p_tcp_udp = NULL; - vma_ibv_flow_spec_action_tag* p_flow_tag = NULL; - - attach_flow_data_eth_ipv4_tcp_udp_t* attach_flow_data_eth = NULL; - - switch (type) { - case VMA_TRANSPORT_IB: - { - attach_flow_data_ib_ipv4_tcp_udp_v2_t* attach_flow_data_ib_v2 = NULL; - -#ifdef DEFINED_IBV_FLOW_SPEC_IB - if (0 == p_ring->m_p_qp_mgr->get_underly_qpn()) { - attach_flow_data_ib_ipv4_tcp_udp_v1_t* attach_flow_data_ib_v1 = NULL; - - attach_flow_data_ib_v1 = new attach_flow_data_ib_ipv4_tcp_udp_v1_t(p_ring->m_p_qp_mgr); - ibv_flow_spec_ib_set_by_dst_qpn(&(attach_flow_data_ib_v1->ibv_flow_attr.ib), - htonl(((IPoIB_addr*)p_ring->m_p_l2_addr)->get_qpn())); - p_ipv4 = &(attach_flow_data_ib_v1->ibv_flow_attr.ipv4); - p_tcp_udp = &(attach_flow_data_ib_v1->ibv_flow_attr.tcp_udp); - p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_ib_v1; - break; - } -#endif - attach_flow_data_ib_v2 = new attach_flow_data_ib_ipv4_tcp_udp_v2_t(p_ring->m_p_qp_mgr); - - p_ipv4 = &(attach_flow_data_ib_v2->ibv_flow_attr.ipv4); - p_tcp_udp = &(attach_flow_data_ib_v2->ibv_flow_attr.tcp_udp); - p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_ib_v2; - break; - } - case VMA_TRANSPORT_ETH: - { - attach_flow_data_eth = new attach_flow_data_eth_ipv4_tcp_udp_t(p_ring->m_p_qp_mgr); - - ibv_flow_spec_eth_set(&(attach_flow_data_eth->ibv_flow_attr.eth), - p_ring->m_p_l2_addr->get_address(), - htons(p_ring->m_p_qp_mgr->get_partiton())); - p_ipv4 = &(attach_flow_data_eth->ibv_flow_attr.ipv4); - p_tcp_udp = &(attach_flow_data_eth->ibv_flow_attr.tcp_udp); - p_flow_tag = &(attach_flow_data_eth->ibv_flow_attr.flow_tag); - p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_eth; - break; - } - BULLSEYE_EXCLUDE_BLOCK_START - default: - return false; - break; - BULLSEYE_EXCLUDE_BLOCK_END - } + attach_flow_data_t* p_attach_flow_data = NULL; + ibv_flow_spec_ipv4* p_ipv4 = NULL; + ibv_flow_spec_tcp_udp* p_tcp_udp = NULL; + vma_ibv_flow_spec_action_tag* p_flow_tag = NULL; + + attach_flow_data_eth_ipv4_tcp_udp_t* attach_flow_data_eth = + new attach_flow_data_eth_ipv4_tcp_udp_t(p_ring->m_p_qp_mgr); + + ibv_flow_spec_eth_set(&(attach_flow_data_eth->ibv_flow_attr.eth), + p_ring->m_p_l2_addr->get_address(), + htons(p_ring->m_p_qp_mgr->get_partiton())); + p_ipv4 = &(attach_flow_data_eth->ibv_flow_attr.ipv4); + p_tcp_udp = &(attach_flow_data_eth->ibv_flow_attr.tcp_udp); + p_flow_tag = &(attach_flow_data_eth->ibv_flow_attr.flow_tag); + p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_eth; ibv_flow_spec_ipv4_set(p_ipv4, m_flow_tuple.get_dst_ip(), @@ -136,20 +72,19 @@ bool rfs_uc::prepare_flow_spec() p_attach_flow_data->ibv_flow_attr.priority = 0; } - if (m_flow_tag_id && attach_flow_data_eth) { // Will not attach flow_tag spec to rule for tag_id==0 + if (m_flow_tag_id) { // Will not attach flow_tag spec to rule for tag_id==0 ibv_flow_spec_flow_tag_set(p_flow_tag, m_flow_tag_id); attach_flow_data_eth->ibv_flow_attr.add_flow_tag_spec(); rfs_logdbg("Adding flow_tag spec to rule, num_of_specs: %d flow_tag_id: %d", attach_flow_data_eth->ibv_flow_attr.attr.num_of_specs, m_flow_tag_id); } - rfs_logfunc("transport type: %s, num_of_specs: %d flow_tag_id: %d", - priv_vma_transport_type_str(type), - p_attach_flow_data->ibv_flow_attr.num_of_specs, - m_flow_tag_id); + + rfs_logfunc("num_of_specs: %d flow_tag_id: %d", + p_attach_flow_data->ibv_flow_attr.num_of_specs, + m_flow_tag_id); m_attach_flow_data_vector.push_back(p_attach_flow_data); - return true; } bool rfs_uc::rx_dispatch_packet(mem_buf_desc_t* p_rx_wc_buf_desc, void* pv_fd_ready_array) diff --git a/src/vma/dev/rfs_uc.h b/src/vma/dev/rfs_uc.h index d34e20fb92..0716ffc494 100644 --- a/src/vma/dev/rfs_uc.h +++ b/src/vma/dev/rfs_uc.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -55,7 +29,7 @@ class rfs_uc : public rfs virtual bool rx_dispatch_packet(mem_buf_desc_t* p_rx_wc_buf_desc, void* pv_fd_ready_array); protected: - virtual bool prepare_flow_spec(); + virtual void prepare_flow_spec(); }; diff --git a/src/vma/dev/rfs_uc_tcp_gro.cpp b/src/vma/dev/rfs_uc_tcp_gro.cpp index 70cfea16a2..bdf4afae6c 100644 --- a/src/vma/dev/rfs_uc_tcp_gro.cpp +++ b/src/vma/dev/rfs_uc_tcp_gro.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "utils/bullseye.h" @@ -35,6 +9,7 @@ #include "vma/dev/gro_mgr.h" #include "vma/dev/ring_simple.h" #include "vma/proto/route_rule_table_key.h" +#include #define MODULE_NAME "rfs_uc_tcp_gro" @@ -45,7 +20,7 @@ rfs_uc_tcp_gro::rfs_uc_tcp_gro(flow_tuple *flow_spec_5t, ring_slave *p_ring, rfs_rule_filter* rule_filter, uint32_t flow_tag_id) : rfs_uc(flow_spec_5t, p_ring, rule_filter, flow_tag_id), - m_b_active(false), m_b_reserved(false) + m_b_active(false), m_b_reserved(false), m_pcb(nullptr) { ring_simple* p_check_ring = dynamic_cast(p_ring); @@ -236,6 +211,21 @@ bool rfs_uc_tcp_gro::tcp_ip_check(mem_buf_desc_t* mem_buf_desc, iphdr* p_ip_h, t return false; } + // Set pbc once here since in constructor we don't have sockinfo yet + if (unlikely(!m_pcb)) { + sockinfo_tcp *sock = dynamic_cast(m_sinks_list[0]); + if (unlikely(!sock)) { + __log_err("sockinfo_tcp is null, can't check for already received packets"); + return false; + } + m_pcb = sock->get_pcb(); + } + + // Dont accumulate packets that already received before + if (TCP_SEQ_LT(ntohl(p_tcp_h->seq) + mem_buf_desc->rx.sz_payload - 1, m_pcb->rcv_nxt)) { + return false; + } + return true; } diff --git a/src/vma/dev/rfs_uc_tcp_gro.h b/src/vma/dev/rfs_uc_tcp_gro.h index ab9a480f7d..9e175539e5 100644 --- a/src/vma/dev/rfs_uc_tcp_gro.h +++ b/src/vma/dev/rfs_uc_tcp_gro.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -85,6 +59,7 @@ class rfs_uc_tcp_gro : public rfs_uc struct gro_mem_buf_desc m_gro_desc; uint32_t m_n_buf_max; uint32_t m_n_byte_max; + struct tcp_pcb *m_pcb; }; diff --git a/src/vma/dev/ring.cpp b/src/vma/dev/ring.cpp index 99f61080a7..ad571876ad 100644 --- a/src/vma/dev/ring.cpp +++ b/src/vma/dev/ring.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/dev/ring.h b/src/vma/dev/ring.h index 169e465130..3e8a833edd 100644 --- a/src/vma/dev/ring.h +++ b/src/vma/dev/ring.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -88,14 +62,14 @@ class ring // Get/Release memory buffer descriptor with a linked data memory buffer virtual mem_buf_desc_t* mem_buf_tx_get(ring_user_id_t id, bool b_block, int n_num_mem_bufs = 1) = 0; virtual int mem_buf_tx_release(mem_buf_desc_t* p_mem_buf_desc_list, bool b_accounting, bool trylock = false) = 0; - virtual void send_ring_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) = 0; - virtual void send_lwip_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) = 0; + virtual void send_ring_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) = 0; + virtual void send_lwip_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) = 0; // Funcs taken from cq_mgr.h virtual int get_num_resources() const = 0; virtual int* get_rx_channel_fds(size_t &length) const { length = 1; return m_p_n_rx_channel_fds; }; virtual int get_tx_channel_fd() const { return -1; }; - virtual bool get_hw_dummy_send_support(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe) = 0; + virtual bool get_hw_dummy_send_support(ring_user_id_t id, ibv_send_wr* p_send_wqe) = 0; virtual int request_notification(cq_type_t cq_type, uint64_t poll_sn) = 0; virtual bool reclaim_recv_buffers(descq_t *rx_reuse) = 0; virtual bool reclaim_recv_buffers(mem_buf_desc_t* rx_reuse_lst) = 0; @@ -112,14 +86,8 @@ class ring ring_user_id_t generate_id() { return 0; }; virtual ring_user_id_t generate_id(const address_t src_mac, const address_t dst_mac, uint16_t eth_proto, uint16_t encap_proto, uint32_t src_ip, uint32_t dst_ip, uint16_t src_port, uint16_t dst_port) = 0; virtual int modify_ratelimit(struct vma_rate_limit_t &rate_limit) = 0; - virtual uint32_t get_max_inline_data() = 0; -#ifdef DEFINED_TSO - virtual uint32_t get_max_send_sge(void) = 0; - virtual uint32_t get_max_payload_sz(void) = 0; - virtual uint16_t get_max_header_sz(void) = 0; - virtual uint32_t get_tx_lkey(ring_user_id_t id) = 0; - virtual bool is_tso(void) = 0; -#endif /* DEFINED_TSO */ + virtual uint32_t get_max_inline_data() = 0; + virtual int reg_mr(void *addr, size_t length, uint32_t &lkey) { NOT_IN_USE(addr); NOT_IN_USE(length); NOT_IN_USE(lkey); return -1;}; virtual int dereg_mr(void *addr, size_t length) { NOT_IN_USE(addr);NOT_IN_USE(length); return -1;}; diff --git a/src/vma/dev/ring_allocation_logic.cpp b/src/vma/dev/ring_allocation_logic.cpp index 419fc1cbf6..1d80bbe348 100644 --- a/src/vma/dev/ring_allocation_logic.cpp +++ b/src/vma/dev/ring_allocation_logic.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -255,6 +229,7 @@ int cpu_manager::reserve_cpu_for_thread(pthread_t tid, int suggested_cpu /* = NO cpu = suggested_cpu; } CPU_ZERO(&cpu_set); + // coverity[overflow_const:FALSE] /* Turn off coverity check, cpu value is non-negative */ CPU_SET(cpu, &cpu_set); __log_dbg("attach tid=%lu running on cpu=%d to cpu=%d", tid, sched_getcpu(), cpu); ret = pthread_setaffinity_np(tid, sizeof(cpu_set_t), &cpu_set); diff --git a/src/vma/dev/ring_allocation_logic.h b/src/vma/dev/ring_allocation_logic.h index bf9046e4c8..97b545f0b6 100644 --- a/src/vma/dev/ring_allocation_logic.h +++ b/src/vma/dev/ring_allocation_logic.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -81,6 +55,7 @@ class ring_allocation_logic bool should_migrate_ring(); bool is_logic_support_migration() { return m_res_key.get_ring_alloc_logic() >= RING_LOGIC_PER_THREAD && m_ring_migration_ratio > 0;} uint64_t calc_res_key_by_logic(); + inline ring_logic_t get_alloc_logic_type() { return m_res_key.get_ring_alloc_logic(); } inline void enable_migration(bool active) { m_active = active; } const char* to_str(); diff --git a/src/vma/dev/ring_bond.cpp b/src/vma/dev/ring_bond.cpp index b4405b7fcc..6ba6ef87fa 100644 --- a/src/vma/dev/ring_bond.cpp +++ b/src/vma/dev/ring_bond.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "ring_bond.h" @@ -67,9 +41,6 @@ ring_bond::ring_bond(int if_index) : m_type = p_ndev->get_is_bond(); m_xmit_hash_policy = p_ndev->get_bond_xmit_hash_policy(); m_max_inline_data = 0; -#ifdef DEFINED_TSO - m_max_send_sge = 0; -#endif /* DEFINED_TSO */ print_val(); } @@ -166,9 +137,9 @@ void ring_bond::restart() if (p_ring_tap) { size_t num_ring_rx_fds = 0; int *ring_rx_fds_array = NULL; - int epfd = -1; - int fd = -1; - int rc = 0; + int rc; + int fd; + int epfd; size_t i, j, k; NOT_IN_USE(rc); // Suppress --enable-opt-log=high warning @@ -228,7 +199,9 @@ void ring_bond::restart() } for (j = 0; j < m_rx_flows.size(); j++) { sockinfo* si = static_cast (m_rx_flows[j].sink); - p_ring_bond_netvsc->m_vf_ring->attach_flow(m_rx_flows[j].flow, m_rx_flows[j].sink); + if (!p_ring_bond_netvsc->m_vf_ring->attach_flow(m_rx_flows[j].flow, m_rx_flows[j].sink)) { + ring_logwarn("Failed to attach flow during VF migration"); + } for (k = 0; k < num_ring_rx_fds; k++ ) { epfd = si->get_rx_epfd(); if (epfd > 0) { @@ -300,7 +273,7 @@ void ring_bond::restart() } popup_xmit_rings(); - int ret = 0; + int ret; uint64_t poll_sn = cq_mgr::m_n_global_sn; ret = request_notification(CQT_RX, poll_sn); if (ret < 0) { @@ -382,7 +355,7 @@ void ring_bond::mem_buf_desc_return_single_to_owner_tx(mem_buf_desc_t* p_mem_buf p_mem_buf_desc->p_desc_owner->mem_buf_desc_return_single_to_owner_tx(p_mem_buf_desc); } -void ring_bond::send_ring_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) +void ring_bond::send_ring_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) { mem_buf_desc_t* p_mem_buf_desc = (mem_buf_desc_t*)(p_send_wqe->wr_id); @@ -401,7 +374,7 @@ void ring_bond::send_ring_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, } } -void ring_bond::send_lwip_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) +void ring_bond::send_lwip_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) { mem_buf_desc_t* p_mem_buf_desc = (mem_buf_desc_t*)(p_send_wqe->wr_id); @@ -419,7 +392,7 @@ void ring_bond::send_lwip_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, } } -bool ring_bond::get_hw_dummy_send_support(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe) +bool ring_bond::get_hw_dummy_send_support(ring_user_id_t id, ibv_send_wr* p_send_wqe) { mem_buf_desc_t* p_mem_buf_desc = (mem_buf_desc_t*)(p_send_wqe->wr_id); @@ -603,21 +576,12 @@ void ring_bond::update_cap(ring_slave *slave) { if (NULL == slave) { m_max_inline_data = (uint32_t)(-1); -#ifdef DEFINED_TSO - m_max_send_sge = (uint32_t)(-1); -#endif /* DEFINED_TSO */ return ; } m_max_inline_data = (m_max_inline_data == (uint32_t)(-1) ? slave->get_max_inline_data() : min(m_max_inline_data, slave->get_max_inline_data())); - -#ifdef DEFINED_TSO - m_max_send_sge = (m_max_send_sge == (uint32_t)(-1) ? - slave->get_max_send_sge() : - min(m_max_send_sge, slave->get_max_send_sge())); -#endif /* DEFINED_TSO */ } void ring_bond::devide_buffers_helper(descq_t *rx_reuse, descq_t* buffer_per_ring) @@ -850,28 +814,6 @@ uint32_t ring_bond::get_max_inline_data() return m_max_inline_data; } -#ifdef DEFINED_TSO -uint32_t ring_bond::get_max_send_sge(void) -{ - return m_max_send_sge; -} - -uint32_t ring_bond::get_max_payload_sz(void) -{ - return 0; -} - -uint16_t ring_bond::get_max_header_sz(void) -{ - return 0; -} - -bool ring_bond::is_tso(void) -{ - return false; -} -#endif /* DEFINED_TSO */ - int ring_bond::socketxtreme_poll(struct vma_completion_t *, unsigned int, int) { return 0; @@ -916,28 +858,6 @@ void ring_bond_eth::slave_create(int if_index) update_rx_channel_fds(); } -void ring_bond_ib::slave_create(int if_index) -{ - ring_slave *cur_slave; - ring_simple *cur_simple; - - cur_slave = cur_simple = new ring_ib(if_index, this); - if (cur_slave == NULL) { - ring_logpanic("Error creating bond ring: memory allocation error"); - } - - update_cap(cur_slave); - m_bond_rings.push_back(cur_slave); - - if (m_bond_rings.size() > MAX_NUM_RING_RESOURCES) { - ring_logpanic("Error creating bond ring with more than %d resource", MAX_NUM_RING_RESOURCES); - } - - popup_xmit_rings(); - popup_recv_rings(); - update_rx_channel_fds(); -} - void ring_bond_netvsc::slave_create(int if_index) { ring_slave *cur_slave = NULL; diff --git a/src/vma/dev/ring_bond.h b/src/vma/dev/ring_bond.h index 128aa38792..8227a640d9 100644 --- a/src/vma/dev/ring_bond.h +++ b/src/vma/dev/ring_bond.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef RING_BOND_H @@ -68,22 +42,15 @@ class ring_bond : public ring { virtual mem_buf_desc_t* mem_buf_tx_get(ring_user_id_t id, bool b_block, int n_num_mem_bufs = 1); virtual int mem_buf_tx_release(mem_buf_desc_t* p_mem_buf_desc_list, bool b_accounting, bool trylock = false); virtual void inc_tx_retransmissions_stats(ring_user_id_t id); - virtual void send_ring_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); - virtual void send_lwip_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); + virtual void send_ring_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); + virtual void send_lwip_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); virtual void mem_buf_desc_return_single_to_owner_tx(mem_buf_desc_t* p_mem_buf_desc); virtual bool is_member(ring_slave* rng); virtual bool is_active_member(ring_slave* rng, ring_user_id_t id); virtual ring_user_id_t generate_id(const address_t src_mac, const address_t dst_mac, uint16_t eth_proto, uint16_t encap_proto, uint32_t src_ip, uint32_t dst_ip, uint16_t src_port, uint16_t dst_port); - virtual bool get_hw_dummy_send_support(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe); + virtual bool get_hw_dummy_send_support(ring_user_id_t id, ibv_send_wr* p_send_wqe); virtual int modify_ratelimit(struct vma_rate_limit_t &rate_limit); - virtual uint32_t get_max_inline_data(); -#ifdef DEFINED_TSO - virtual uint32_t get_max_send_sge(void); - virtual uint32_t get_max_payload_sz(void); - virtual uint16_t get_max_header_sz(void); - virtual uint32_t get_tx_lkey(ring_user_id_t id) { return m_xmit_rings[id]->get_tx_lkey(id); } - virtual bool is_tso(void); -#endif /* DEFINED_TSO */ + virtual uint32_t get_max_inline_data(); int socketxtreme_poll(struct vma_completion_t *vma_completions, unsigned int ncompletions, int flags); virtual void slave_create(int if_index) = 0; virtual void slave_destroy(int if_index); @@ -121,9 +88,6 @@ class ring_bond : public ring { std::vector m_rx_flows; uint32_t m_max_inline_data; -#ifdef DEFINED_TSO - uint32_t m_max_send_sge; -#endif /* DEFINED_TSO */ private: void devide_buffers_helper(descq_t *rx_reuse, descq_t *buffer_per_ring); @@ -160,26 +124,6 @@ class ring_bond_eth : public ring_bond virtual void slave_create(int if_index); }; -class ring_bond_ib : public ring_bond -{ -public: - ring_bond_ib(int if_index): - ring_bond(if_index) { - net_device_val* p_ndev = - g_p_net_device_table_mgr->get_net_device_val(m_parent->get_if_index()); - if (p_ndev) { - const slave_data_vector_t& slaves = p_ndev->get_slave_array(); - update_cap(); - for (size_t i = 0; i < slaves.size(); i++) { - slave_create(slaves[i]->if_index); - } - } - } - -protected: - virtual void slave_create(int if_index); -}; - class ring_bond_netvsc : public ring_bond { public: diff --git a/src/vma/dev/ring_eth_direct.cpp b/src/vma/dev/ring_eth_direct.cpp index 78049b3c3e..cd8d361732 100644 --- a/src/vma/dev/ring_eth_direct.cpp +++ b/src/vma/dev/ring_eth_direct.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "ring_eth_direct.h" @@ -53,12 +27,8 @@ ring_eth_direct::ring_eth_direct(int if_index, qp_mgr* ring_eth_direct::create_qp_mgr(struct qp_mgr_desc *desc) { -#if defined(DEFINED_DIRECT_VERBS) return new qp_mgr_eth_direct(desc, get_tx_num_wr(), m_partition); -#endif - NOT_IN_USE(desc); - return NULL; } void ring_eth_direct::init_tx_buffers(uint32_t count) @@ -107,7 +77,7 @@ int ring_eth_direct::reg_mr(void *addr, size_t length, uint32_t &lkey) it->second.second++; return 0; } - lkey = m_p_ib_ctx->mem_reg(addr, length, VMA_IBV_ACCESS_LOCAL_WRITE); + lkey = m_p_ib_ctx->mem_reg(addr, length, IBV_ACCESS_LOCAL_WRITE); if (lkey == (uint32_t)-1) { ring_logdbg("failed registering MR"); return -1; diff --git a/src/vma/dev/ring_eth_direct.h b/src/vma/dev/ring_eth_direct.h index c038f4df04..9649de634f 100644 --- a/src/vma/dev/ring_eth_direct.h +++ b/src/vma/dev/ring_eth_direct.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef SRC_VMA_DEV_RING_ETH_DIRECT_H_ diff --git a/src/vma/dev/ring_profile.cpp b/src/vma/dev/ring_profile.cpp index 4b102b5200..a126612694 100644 --- a/src/vma/dev/ring_profile.cpp +++ b/src/vma/dev/ring_profile.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/src/vma/dev/ring_profile.h b/src/vma/dev/ring_profile.h index 9bf2326024..00a358825b 100644 --- a/src/vma/dev/ring_profile.h +++ b/src/vma/dev/ring_profile.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef SRC_VMA_DEV_RING_PROFILE_H_ diff --git a/src/vma/dev/ring_simple.cpp b/src/vma/dev/ring_simple.cpp index a8b9e575be..c08fd0383a 100644 --- a/src/vma/dev/ring_simple.cpp +++ b/src/vma/dev/ring_simple.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -36,9 +10,7 @@ #include "vma/util/valgrind.h" #include "vma/util/sg_array.h" #include "vma/sock/fd_collection.h" -#if defined(DEFINED_DIRECT_VERBS) #include "vma/dev/qp_mgr_eth_mlx5.h" -#endif #undef MODULE_NAME #define MODULE_NAME "ring_simple" @@ -62,7 +34,7 @@ /** inlining functions can only help if they are implemented before their usage **/ /**/ -inline void ring_simple::send_status_handler(int ret, vma_ibv_send_wr* p_send_wqe) +inline void ring_simple::send_status_handler(int ret, ibv_send_wr* p_send_wqe) { BULLSEYE_EXCLUDE_BLOCK_START if (unlikely(ret)) { @@ -87,19 +59,12 @@ inline void ring_simple::send_status_handler(int ret, vma_ibv_send_wr* p_send_wq qp_mgr* ring_eth::create_qp_mgr(struct qp_mgr_desc *desc) { -#if defined(DEFINED_DIRECT_VERBS) if (qp_mgr::is_lib_mlx5(((ib_ctx_handler*)desc->slave->p_ib_ctx)->get_ibname())) { return new qp_mgr_eth_mlx5(desc, get_tx_num_wr(), m_partition); } -#endif - return new qp_mgr_eth(desc, - get_tx_num_wr(), m_partition); -} -qp_mgr* ring_ib::create_qp_mgr(struct qp_mgr_desc *desc) -{ - return new qp_mgr_ib(desc, + return new qp_mgr_eth(desc, get_tx_num_wr(), m_partition); } @@ -116,8 +81,13 @@ ring_simple::ring_simple(int if_index, ring* parent, ring_type_t type): m_p_rx_comp_event_channel(NULL), m_p_tx_comp_event_channel(NULL), m_p_l2_addr(NULL) { net_device_val* p_ndev = g_p_net_device_table_mgr->get_net_device_val(m_parent->get_if_index()); + if (unlikely(!p_ndev)) { + ring_logpanic("Cannot find net_device_val for a ring if_index = %d", get_if_index()); + } const slave_data_t * p_slave = p_ndev->get_slave(get_if_index()); - + if (unlikely(!p_slave)) { + ring_logpanic("Cannot find slave for a ring if_index = %d", get_if_index()); + } ring_logdbg("new ring_simple()"); /* m_p_ib_ctx, m_tx_lkey should be initialized to be used @@ -139,9 +109,6 @@ ring_simple::ring_simple(int if_index, ring* parent, ring_type_t type): m_mtu = p_ndev->get_mtu(); memset(&m_cq_moderation_info, 0, sizeof(m_cq_moderation_info)); -#ifdef DEFINED_TSO - memset(&m_tso, 0, sizeof(m_tso)); -#endif /* DEFINED_TSO */ m_socketxtreme.active = safe_mce_sys().enable_socketxtreme; INIT_LIST_HEAD(&m_socketxtreme.ec_list); @@ -160,6 +127,7 @@ ring_simple::~ring_simple() // Allow last few post sends to be sent by HCA. // Was done in order to allow iperf's FIN packet to be sent. + // coverity[sleep:FALSE] /* Turn off coverity sleep while holding lock */ usleep(25000); if (m_p_qp_mgr) { @@ -234,7 +202,13 @@ ring_simple::~ring_simple() void ring_simple::create_resources() { net_device_val* p_ndev = g_p_net_device_table_mgr->get_net_device_val(m_parent->get_if_index()); + if (unlikely(!p_ndev)) { + ring_logpanic("Cannot find net_device_val for a ring if_index = %d", get_if_index()); + } const slave_data_t * p_slave = p_ndev->get_slave(get_if_index()); + if (unlikely(!p_slave)) { + ring_logpanic("Cannot find slave for a ring if_index = %d", get_if_index()); + } save_l2_address(p_slave->p_L2_addr); m_p_tx_comp_event_channel = ibv_create_comp_channel(m_p_ib_ctx->get_ibv_context()); @@ -259,23 +233,8 @@ void ring_simple::create_resources() m_tx_num_wr_free = m_tx_num_wr; -#ifdef DEFINED_TSO - memset(&m_tso, 0, sizeof(m_tso)); - if (safe_mce_sys().enable_tso && (1 == validate_tso(get_if_index()))) { - if (vma_check_dev_attr_tso(m_p_ib_ctx->get_ibv_device_attr())) { - const vma_ibv_tso_caps *caps = &vma_get_tso_caps(m_p_ib_ctx->get_ibv_device_attr_ex()); - if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_RAW_PACKET) || - ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_UD)) { - m_tso.max_payload_sz = caps->max_tso; - /* ETH(14) + IP(20) + TCP(20) + TCP OPTIONS(40) */ - m_tso.max_header_sz = 94; - } - } - } - ring_logdbg("ring attributes: m_tso = %d", is_tso()); - ring_logdbg("ring attributes: m_tso:max_payload_sz = %d", get_max_payload_sz()); - ring_logdbg("ring attributes: m_tso:max_header_sz = %d", get_max_header_sz()); -#endif /* DEFINED_TSO */ + // Temporary fix for rd #4213201 + m_tx_num_wr_free--; m_flow_tag_enabled = m_p_ib_ctx->get_flow_tag_capability(); ring_logdbg("ring attributes: m_flow_tag_enabled = %d", m_flow_tag_enabled); @@ -396,6 +355,7 @@ int ring_simple::socketxtreme_poll(struct vma_completion_t *vma_completions, uns mem_buf_desc_t *desc; if (likely(m_p_cq_mgr_rx->poll_and_process_element_rx(&desc))) { desc->rx.socketxtreme_polled = true; + /* coverity[check_return] */ rx_process_buffer(desc, NULL); if (m_socketxtreme.completion->events) { m_socketxtreme.completion++; @@ -630,7 +590,7 @@ int ring_simple::mem_buf_tx_release(mem_buf_desc_t* p_mem_buf_desc_list, bool b_ } /* note that this function is inline, so keep it above the functions using it */ -inline int ring_simple::send_buffer(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) +inline int ring_simple::send_buffer(ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) { //Note: this is debatable logic as it count of WQEs waiting completion but //our SQ is cyclic buffer so in reality only last WQE is still being sent @@ -652,7 +612,7 @@ inline int ring_simple::send_buffer(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packe return ret; } -bool ring_simple::get_hw_dummy_send_support(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe) +bool ring_simple::get_hw_dummy_send_support(ring_user_id_t id, ibv_send_wr* p_send_wqe) { NOT_IN_USE(id); NOT_IN_USE(p_send_wqe); @@ -660,7 +620,7 @@ bool ring_simple::get_hw_dummy_send_support(ring_user_id_t id, vma_ibv_send_wr* return m_p_qp_mgr->get_hw_dummy_send_support(); } -void ring_simple::send_ring_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) +void ring_simple::send_ring_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) { NOT_IN_USE(id); @@ -674,15 +634,13 @@ void ring_simple::send_ring_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wq } auto_unlocker lock(m_lock_ring_tx); -#ifdef DEFINED_TSO -#else p_send_wqe->sg_list[0].lkey = m_tx_lkey; -#endif /* DEFINED_TSO */ + int ret = send_buffer(p_send_wqe, attr); send_status_handler(ret, p_send_wqe); } -void ring_simple::send_lwip_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) +void ring_simple::send_lwip_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) { NOT_IN_USE(id); @@ -692,12 +650,10 @@ void ring_simple::send_lwip_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wq #endif auto_unlocker lock(m_lock_ring_tx); -#ifdef DEFINED_TSO -#else p_send_wqe->sg_list[0].lkey = m_tx_lkey; mem_buf_desc_t* p_mem_buf_desc = (mem_buf_desc_t*)(p_send_wqe->wr_id); p_mem_buf_desc->lwip_pbuf.pbuf.ref++; -#endif /* DEFINED_TSO */ + int ret = send_buffer(p_send_wqe, attr); send_status_handler(ret, p_send_wqe); } @@ -777,6 +733,7 @@ bool ring_simple::is_available_qp_wr(bool b_block) m_lock_ring_tx_buf_wait.unlock(); /* coverity[double_lock] TODO: RM#1049980 */ m_lock_ring_tx.lock(); + // coverity[missing_unlock:FALSE] /*Turn off coverity check for overflow*/ return false; } ring_logfunc("polling/blocking succeeded on tx cq_mgr (we got %d wce)", ret); @@ -825,6 +782,7 @@ mem_buf_desc_t* ring_simple::get_tx_buffers(uint32_t n_num_mem_bufs) } head = m_tx_pool.get_and_pop_back(); + /* coverity[dereference:FALSE] */ head->lwip_pbuf.pbuf.ref = 1; n_num_mem_bufs--; @@ -875,6 +833,9 @@ int ring_simple::put_tx_buffers(mem_buf_desc_t* buff_list) count++; buff_list = next; } + + // to suppress warning in case ring_logfunc is compiled out + NOT_IN_USE(freed); ring_logfunc("buf_list: %p count: %d freed: %d\n", buff_list, count, freed); return_to_global_pool(); @@ -1066,25 +1027,3 @@ uint32_t ring_simple::get_max_inline_data() { return m_p_qp_mgr->get_max_inline_data(); } - -#ifdef DEFINED_TSO -uint32_t ring_simple::get_max_send_sge(void) -{ - return m_p_qp_mgr->get_max_send_sge(); -} - -uint32_t ring_simple::get_max_payload_sz(void) -{ - return m_tso.max_payload_sz; -} - -uint16_t ring_simple::get_max_header_sz(void) -{ - return m_tso.max_header_sz; -} - -bool ring_simple::is_tso(void) -{ - return (m_tso.max_payload_sz && m_tso.max_header_sz); -} -#endif /* DEFINED_TSO */ diff --git a/src/vma/dev/ring_simple.h b/src/vma/dev/ring_simple.h index 3089370d58..6f94126c2d 100644 --- a/src/vma/dev/ring_simple.h +++ b/src/vma/dev/ring_simple.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef RING_SIMPLE_H @@ -77,29 +51,20 @@ class ring_simple : public ring_slave void mem_buf_desc_completion_with_error_rx(mem_buf_desc_t* p_rx_wc_buf_desc); // Assume locked... void mem_buf_desc_return_to_owner_tx(mem_buf_desc_t* p_mem_buf_desc); void mem_buf_desc_return_to_owner_rx(mem_buf_desc_t* p_mem_buf_desc, void* pv_fd_ready_array = NULL); - inline int send_buffer(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); + inline int send_buffer(ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); virtual bool is_up(); void start_active_qp_mgr(); void stop_active_qp_mgr(); virtual mem_buf_desc_t* mem_buf_tx_get(ring_user_id_t id, bool b_block, int n_num_mem_bufs = 1); virtual int mem_buf_tx_release(mem_buf_desc_t* p_mem_buf_desc_list, bool b_accounting, bool trylock = false); - virtual void send_ring_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); - virtual void send_lwip_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); + virtual void send_ring_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); + virtual void send_lwip_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); virtual void mem_buf_desc_return_single_to_owner_tx(mem_buf_desc_t* p_mem_buf_desc); - virtual bool get_hw_dummy_send_support(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe); + virtual bool get_hw_dummy_send_support(ring_user_id_t id, ibv_send_wr* p_send_wqe); inline void convert_hw_time_to_system_time(uint64_t hwtime, struct timespec* systime) { m_p_ib_ctx->convert_hw_time_to_system_time(hwtime, systime); } - inline uint32_t get_qpn() const { return (m_p_l2_addr ? ((IPoIB_addr *)m_p_l2_addr)->get_qpn() : 0); } - virtual uint32_t get_underly_qpn() { return m_p_qp_mgr->get_underly_qpn(); } virtual int modify_ratelimit(struct vma_rate_limit_t &rate_limit); virtual int get_tx_channel_fd() const { return m_p_tx_comp_event_channel ? m_p_tx_comp_event_channel->fd : -1; }; - virtual uint32_t get_max_inline_data(); -#ifdef DEFINED_TSO - virtual uint32_t get_max_send_sge(void); - virtual uint32_t get_max_payload_sz(void); - virtual uint16_t get_max_header_sz(void); - virtual uint32_t get_tx_lkey(ring_user_id_t id) { NOT_IN_USE(id); return m_tx_lkey; } - virtual bool is_tso(void); -#endif /* DEFINED_TSO */ + virtual uint32_t get_max_inline_data(); struct ibv_comp_channel* get_tx_comp_event_channel() { return m_p_tx_comp_event_channel; } int get_ring_descriptors(vma_mlx_hw_device_data &data); @@ -120,9 +85,7 @@ class ring_simple : public ring_slave void create_resources(); virtual void init_tx_buffers(uint32_t count); virtual void inc_cq_moderation_stats(size_t sz_data); -#ifdef DEFINED_TSO - void set_tx_num_wr(int32_t num_wr) { m_tx_num_wr = m_tx_num_wr_free = num_wr; } -#endif /* DEFINED_TSO */ + uint32_t get_tx_num_wr() { return m_tx_num_wr; } uint32_t get_mtu() { return m_mtu; } @@ -187,7 +150,7 @@ class ring_simple : public ring_slave bool active; } m_socketxtreme; - inline void send_status_handler(int ret, vma_ibv_send_wr* p_send_wqe); + inline void send_status_handler(int ret, ibv_send_wr* p_send_wqe); inline mem_buf_desc_t* get_tx_buffers(uint32_t n_num_mem_bufs); inline int put_tx_buffers(mem_buf_desc_t* buff_list); inline int put_tx_single_buffer(mem_buf_desc_t* buff); @@ -209,16 +172,6 @@ class ring_simple : public ring_slave struct ibv_comp_channel* m_p_tx_comp_event_channel; L2_address* m_p_l2_addr; uint32_t m_mtu; - -#ifdef DEFINED_TSO - struct { - /* Maximum length of TCP payload for TSO */ - uint32_t max_payload_sz; - - /* Maximum length of header for TSO */ - uint16_t max_header_sz; - } m_tso; -#endif /* DEFINED_TSO */ }; class ring_eth : public ring_simple @@ -246,21 +199,4 @@ class ring_eth : public ring_simple virtual qp_mgr* create_qp_mgr(struct qp_mgr_desc *desc); }; -class ring_ib : public ring_simple -{ -public: - ring_ib(int if_index, - ring* parent = NULL): - ring_simple(if_index, parent, RING_IB) { - net_device_val_ib* p_ndev = - dynamic_cast(g_p_net_device_table_mgr->get_net_device_val(m_parent->get_if_index())); - if (p_ndev) { - m_partition = p_ndev->get_pkey(); - create_resources(); - } - } -protected: - virtual qp_mgr* create_qp_mgr(struct qp_mgr_desc *desc); -}; - #endif //RING_SIMPLE_H diff --git a/src/vma/dev/ring_slave.cpp b/src/vma/dev/ring_slave.cpp index b5c11590aa..8dca3eab62 100644 --- a/src/vma/dev/ring_slave.cpp +++ b/src/vma/dev/ring_slave.cpp @@ -1,39 +1,12 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "ring_slave.h" #include "vma/proto/ip_frag.h" -#include "vma/proto/igmp_mgr.h" #include "vma/dev/rfs_mc.h" #include "vma/dev/rfs_uc_tcp_gro.h" #include "vma/sock/fd_collection.h" @@ -87,7 +60,6 @@ ring_slave::ring_slave(int if_index, ring* parent, ring_type_t type): p_slave = p_ndev->get_slave(get_if_index()); /* Configure ring_slave() fields */ - m_transport_type = p_ndev->get_transport_type(); m_local_if = p_ndev->get_local_addr(); /* Set the same ring active status as related slave has for all ring types @@ -248,7 +220,7 @@ bool ring_slave::attach_flow(flow_tuple& flow_spec_5t, pkt_rcvr_sink *sink) // It means that for every MC group, even if we have sockets with different ports - only one rule in the HW. // So the hash map below keeps track of the number of sockets per rule so we know when to call ibv_attach and ibv_detach rfs_rule_filter* l2_mc_ip_filter = NULL; - if ((m_transport_type == VMA_TRANSPORT_IB && 0 == get_underly_qpn()) || m_b_sysvar_eth_mc_l2_only_rules) { + if (m_b_sysvar_eth_mc_l2_only_rules) { rule_filter_map_t::iterator l2_mc_iter = m_l2_mc_ip_attach_map.find(key_udp_mc.dst_ip); if (l2_mc_iter == m_l2_mc_ip_attach_map.end()) { // It means that this is the first time attach called with this MC ip m_l2_mc_ip_attach_map[key_udp_mc.dst_ip].counter = 1; @@ -258,7 +230,7 @@ bool ring_slave::attach_flow(flow_tuple& flow_spec_5t, pkt_rcvr_sink *sink) } p_rfs = m_flow_udp_mc_map.get(key_udp_mc, NULL); if (p_rfs == NULL) { // It means that no rfs object exists so I need to create a new one and insert it to the flow map - if ((m_transport_type == VMA_TRANSPORT_IB && 0 == get_underly_qpn()) || m_b_sysvar_eth_mc_l2_only_rules) { + if (m_b_sysvar_eth_mc_l2_only_rules) { l2_mc_ip_filter = new rfs_rule_filter(m_l2_mc_ip_attach_map, key_udp_mc.dst_ip, flow_spec_5t); } try { @@ -400,7 +372,7 @@ bool ring_slave::detach_flow(flow_tuple& flow_spec_5t, pkt_rcvr_sink* sink) } else if (flow_spec_5t.is_udp_mc()) { int keep_in_map = 1; flow_spec_2t_key_t key_udp_mc(flow_spec_5t.get_dst_ip(), flow_spec_5t.get_dst_port()); - if (m_transport_type == VMA_TRANSPORT_IB || m_b_sysvar_eth_mc_l2_only_rules) { + if (m_b_sysvar_eth_mc_l2_only_rules) { rule_filter_map_t::iterator l2_mc_iter = m_l2_mc_ip_attach_map.find(key_udp_mc.dst_ip); BULLSEYE_EXCLUDE_BLOCK_START if (l2_mc_iter == m_l2_mc_ip_attach_map.end()) { @@ -616,78 +588,38 @@ bool ring_slave::rx_process_buffer(mem_buf_desc_t* p_rx_wc_buf_desc, void* pv_fd } } - // Validate transport type headers - switch (m_transport_type) { - case VMA_TRANSPORT_IB: - { - // Get the data buffer start pointer to the ipoib header pointer - struct ipoibhdr* p_ipoib_h = (struct ipoibhdr*)(p_rx_wc_buf_desc->p_buffer + GRH_HDR_LEN); - - transport_header_len = GRH_HDR_LEN + IPOIB_HDR_LEN; - - // Validate IPoIB header - if (unlikely(p_ipoib_h->ipoib_header != htonl(IPOIB_HEADER))) { - ring_logwarn("Rx buffer dropped - Invalid IPOIB Header Type (%#x : %#x)", p_ipoib_h->ipoib_header, htonl(IPOIB_HEADER)); - return false; - } + uint16_t h_proto = p_eth_h->h_proto; + + ring_logfunc("Rx buffer Ethernet dst=" ETH_HW_ADDR_PRINT_FMT " <- src=" ETH_HW_ADDR_PRINT_FMT " type=%#x", + ETH_HW_ADDR_PRINT_ADDR(p_eth_h->h_dest), + ETH_HW_ADDR_PRINT_ADDR(p_eth_h->h_source), + htons(h_proto)); + + // Handle VLAN header as next protocol + struct vlanhdr* p_vlan_hdr = NULL; + uint16_t packet_vlan = 0; + if (h_proto == htons(ETH_P_8021Q)) { + p_vlan_hdr = (struct vlanhdr*)((uint8_t*)p_eth_h + ETH_HDR_LEN); + transport_header_len = ETH_VLAN_HDR_LEN; + h_proto = p_vlan_hdr->h_vlan_encapsulated_proto; + packet_vlan = (htons(p_vlan_hdr->h_vlan_TCI) & VLAN_VID_MASK); + } else { + transport_header_len = ETH_HDR_LEN; } - break; - case VMA_TRANSPORT_ETH: - { -// printf("\nring_slave::rx_process_buffer\n"); -// { -// struct ethhdr* p_eth_h = (struct ethhdr*)(p_rx_wc_buf_desc->p_buffer); -// -// int i = 0; -// printf("p_eth_h->h_dest [0]=%d, [1]=%d, [2]=%d, [3]=%d, [4]=%d, [5]=%d\n", -// (uint8_t)p_eth_h->h_dest[0], (uint8_t)p_eth_h->h_dest[1], (uint8_t)p_eth_h->h_dest[2], (uint8_t)p_eth_h->h_dest[3], (uint8_t)p_eth_h->h_dest[4], (uint8_t)p_eth_h->h_dest[5]); -// printf("p_eth_h->h_source [0]=%d, [1]=%d, [2]=%d, [3]=%d, [4]=%d, [5]=%d\n", -// (uint8_t)p_eth_h->h_source[0], (uint8_t)p_eth_h->h_source[1], (uint8_t)p_eth_h->h_source[2], (uint8_t)p_eth_h->h_source[3], (uint8_t)p_eth_h->h_source[4], (uint8_t)p_eth_h->h_source[5]); -// -// while(i++<62){ -// printf("%d, ", (uint8_t)p_rx_wc_buf_desc->p_buffer[i]); -// } -// printf("\n"); -// } - - uint16_t h_proto = p_eth_h->h_proto; - - ring_logfunc("Rx buffer Ethernet dst=" ETH_HW_ADDR_PRINT_FMT " <- src=" ETH_HW_ADDR_PRINT_FMT " type=%#x", - ETH_HW_ADDR_PRINT_ADDR(p_eth_h->h_dest), - ETH_HW_ADDR_PRINT_ADDR(p_eth_h->h_source), - htons(h_proto)); - - // Handle VLAN header as next protocol - struct vlanhdr* p_vlan_hdr = NULL; - uint16_t packet_vlan = 0; - if (h_proto == htons(ETH_P_8021Q)) { - p_vlan_hdr = (struct vlanhdr*)((uint8_t*)p_eth_h + ETH_HDR_LEN); - transport_header_len = ETH_VLAN_HDR_LEN; - h_proto = p_vlan_hdr->h_vlan_encapsulated_proto; - packet_vlan = (htons(p_vlan_hdr->h_vlan_TCI) & VLAN_VID_MASK); - } else { - transport_header_len = ETH_HDR_LEN; - } - - //TODO: Remove this code when handling vlan in flow steering will be available. Change this code if vlan stripping is performed. - if((m_partition & VLAN_VID_MASK) != packet_vlan) { - ring_logfunc("Rx buffer dropped- Mismatched vlan. Packet vlan = %d, Local vlan = %d", packet_vlan, m_partition & VLAN_VID_MASK); - return false; - } - // Validate IP header as next protocol - if (unlikely(h_proto != htons(ETH_P_IP))) { - ring_logwarn("Rx buffer dropped - Invalid Ethr Type (%#x : %#x)", p_eth_h->h_proto, htons(ETH_P_IP)); - return false; - } + //TODO: Remove this code when handling vlan in flow steering will be available. Change this code if vlan stripping is performed. + if((m_partition & VLAN_VID_MASK) != packet_vlan) { + ring_logfunc("Rx buffer dropped- Mismatched vlan. Packet vlan = %d, Local vlan = %d", packet_vlan, m_partition & VLAN_VID_MASK); + return false; } - break; - default: - ring_logwarn("Rx buffer dropped - Unknown transport type %d", m_transport_type); + + // Validate IP header as next protocol + if (unlikely(h_proto != htons(ETH_P_IP))) { + ring_logwarn("Rx buffer dropped - Invalid Ethr Type (%#x : %#x)", p_eth_h->h_proto, htons(ETH_P_IP)); return false; } - // Jump to IP header - Skip IB (GRH and IPoIB) or Ethernet (MAC) header sizes + // Jump to IP header - Skip Ethernet (MAC) header sizes sz_data -= transport_header_len; // Validate size for IPv4 header @@ -735,16 +667,9 @@ bool ring_slave::rx_process_buffer(mem_buf_desc_t* p_rx_wc_buf_desc, void* pv_fd // Handle fragmentation p_rx_wc_buf_desc->rx.n_frags = 1; - if (unlikely((ip_frag_off & MORE_FRAGMENTS_FLAG) || n_frag_offset)) { // Currently we don't expect to receive fragments - //for disabled fragments handling: - /*ring_logwarn("Rx packet dropped - VMA doesn't support fragmentation in receive flow!"); - ring_logwarn("packet info: dst=%d.%d.%d.%d, src=%d.%d.%d.%d, packet_sz=%d, frag_offset=%d, id=%d, proto=%s[%d], transport type=%s, (local if: %d.%d.%d.%d)", - NIPQUAD(p_ip_h->daddr), NIPQUAD(p_ip_h->saddr), - (sz_data > ip_tot_len ? ip_tot_len : sz_data), n_frag_offset, ntohs(p_ip_h->id), - iphdr_protocol_type_to_str(p_ip_h->protocol), p_ip_h->protocol, (m_transport_type ? "ETH" : "IB"), - NIPQUAD(local_addr)); - return false;*/ -#if 1 //handle fragments + + // Currently we don't expect to receive fragments. + if (unlikely((ip_frag_off & MORE_FRAGMENTS_FLAG) || n_frag_offset)) { // Update fragments descriptor with datagram base address and length p_rx_wc_buf_desc->rx.frag.iov_base = (uint8_t*)p_ip_h + ip_hdr_len; p_rx_wc_buf_desc->rx.frag.iov_len = ip_tot_len - ip_hdr_len; @@ -769,21 +694,12 @@ bool ring_slave::rx_process_buffer(mem_buf_desc_t* p_rx_wc_buf_desc, void* pv_fd for (tmp = p_rx_wc_buf_desc; tmp; tmp = tmp->p_next_desc) { ++p_rx_wc_buf_desc->rx.n_frags; } -#endif } if (p_rx_wc_buf_desc->rx.is_sw_csum_need && compute_ip_checksum((unsigned short*)p_ip_h, p_ip_h->ihl * 2)) { return false; // false ip checksum } -//We want to enable loopback between processes for IB -#if 0 - //AlexV: We don't support Tx MC Loopback today! - if (p_ip_h->saddr == m_local_if) { - ring_logfunc("Rx udp datagram discarded - mc loop disabled"); - return false; - } -#endif rfs* p_rfs = NULL; // Update the L3 info @@ -880,31 +796,11 @@ bool ring_slave::rx_process_buffer(mem_buf_desc_t* p_rx_wc_buf_desc, void* pv_fd } break; - case IPPROTO_IGMP: - { - struct igmp* p_igmp_h= (struct igmp*)((uint8_t*)p_ip_h + ip_hdr_len); - NOT_IN_USE(p_igmp_h); /* to supress warning in case VMA_MAX_DEFINED_LOG_LEVEL */ - ring_logdbg("Rx IGMP packet info: type=%s (%d), group=%d.%d.%d.%d, code=%d", - priv_igmp_type_tostr(p_igmp_h->igmp_type), p_igmp_h->igmp_type, - NIPQUAD(p_igmp_h->igmp_group.s_addr), p_igmp_h->igmp_code); - if (m_transport_type == VMA_TRANSPORT_IB || m_b_sysvar_eth_mc_l2_only_rules) { - ring_logdbg("Transport type is IB (or eth_mc_l2_only_rules), passing igmp packet to igmp_manager to process"); - if(g_p_igmp_mgr) { - (g_p_igmp_mgr->process_igmp_packet(p_ip_h, m_local_if)); - return false; // we return false in order to free the buffer, although we handled the packet - } - ring_logdbg("IGMP packet drop. IGMP manager does not exist."); - return false; - } - ring_logerr("Transport type is ETH, dropping the packet"); - return false; - } - break; - default: ring_logwarn("Rx packet dropped - undefined protocol = %d", p_ip_h->protocol); return false; } + if (unlikely(p_rfs == NULL)) { ring_logdbg("Rx packet dropped - rfs object not found: dst:%d.%d.%d.%d:%d, src%d.%d.%d.%d:%d, proto=%s[%d]", NIPQUAD(p_rx_wc_buf_desc->rx.dst.sin_addr.s_addr), ntohs(p_rx_wc_buf_desc->rx.dst.sin_port), diff --git a/src/vma/dev/ring_slave.h b/src/vma/dev/ring_slave.h index a494640ae1..80842c9072 100644 --- a/src/vma/dev/ring_slave.h +++ b/src/vma/dev/ring_slave.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef RING_SLAVE_H_ @@ -103,7 +77,7 @@ typedef hash_map flow_spec_4t_map_t; struct counter_and_ibv_flows { int counter; - std::vector ibv_flows; + std::vector ibv_flows; }; // rule key based on ip and port @@ -136,12 +110,10 @@ class ring_slave : public ring virtual bool rx_process_buffer(mem_buf_desc_t* p_rx_wc_buf_desc, void* pv_fd_ready_array); virtual int reclaim_recv_single_buffer(mem_buf_desc_t* rx_reuse) = 0; virtual void inc_cq_moderation_stats(size_t sz_data) = 0; - virtual uint32_t get_underly_qpn() = 0; virtual bool attach_flow(flow_tuple& flow_spec_5t, pkt_rcvr_sink* sink); virtual bool detach_flow(flow_tuple& flow_spec_5t, pkt_rcvr_sink* sink); inline bool is_simple() const { return m_type != RING_TAP; } - transport_type_t get_transport_type() const { return m_transport_type; } inline ring_type_t get_type() const { return m_type; } bool m_active; /* State indicator */ @@ -167,7 +139,6 @@ class ring_slave : public ring lock_spin_recursive m_lock_ring_tx; descq_t m_tx_pool; - transport_type_t m_transport_type; /* transport ETH/IB */ ring_stats_t* m_p_ring_stat; in_addr_t m_local_if; uint16_t m_partition; diff --git a/src/vma/dev/ring_tap.cpp b/src/vma/dev/ring_tap.cpp index 9936e4b9a5..9e4a4b9573 100644 --- a/src/vma/dev/ring_tap.cpp +++ b/src/vma/dev/ring_tap.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "ring_tap.h" @@ -54,6 +28,9 @@ ring_tap::ring_tap(int if_index, ring* parent): char tap_if_name[IFNAMSIZ] = {0}; net_device_val* p_ndev = g_p_net_device_table_mgr->get_net_device_val(m_parent->get_if_index()); + if (unlikely(!p_ndev)) { + ring_logpanic("Cannot find net_device for ring_tap"); + } /* Create TAP device and update ring class with new if_index */ tap_create(p_ndev); @@ -75,6 +52,7 @@ ring_tap::ring_tap(int if_index, ring* parent): request_more_tx_buffers(m_sysvar_qp_compensation_level, 0); /* Update ring statistics */ + // coverity[overflow_const:FALSE] /* Turn off coverity overflow_const check */ m_p_ring_stat->tap.n_tap_fd = m_tap_fd; if_indextoname(get_if_index(), tap_if_name); memcpy(m_p_ring_stat->tap.s_tap_name, tap_if_name, IFNAMSIZ); @@ -116,10 +94,10 @@ void ring_tap::tap_create(net_device_val* p_ndev) #define TAP_STR_LENGTH 512 #define TAP_DISABLE_IPV6 "sysctl -w net.ipv6.conf.%s.disable_ipv6=1" - int rc = 0, tap_if_index = -1, ioctl_sock = -1; + int rc, tap_if_index, ioctl_sock = -1; struct ifreq ifr; char command_str[TAP_STR_LENGTH], return_str[TAP_STR_LENGTH], tap_name[IFNAMSIZ]; - unsigned char hw_addr[ETH_ALEN]; + unsigned char hw_addr[ETH_ALEN] = {0}; /* Open TAP device */ if( (m_tap_fd = orig_os_api.open("/dev/net/tun", O_RDWR)) < 0 ) { @@ -344,7 +322,7 @@ bool ring_tap::reclaim_recv_buffers(mem_buf_desc_t *buff) return false; } -void ring_tap::send_ring_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) +void ring_tap::send_ring_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) { NOT_IN_USE(id); compute_tx_checksum((mem_buf_desc_t*)(p_send_wqe->wr_id), attr & VMA_TX_PACKET_L3_CSUM, attr & VMA_TX_PACKET_L4_CSUM); @@ -354,17 +332,16 @@ void ring_tap::send_ring_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, send_status_handler(ret, p_send_wqe); } -void ring_tap::send_lwip_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) +void ring_tap::send_lwip_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) { NOT_IN_USE(id); compute_tx_checksum((mem_buf_desc_t*)(p_send_wqe->wr_id), attr & VMA_TX_PACKET_L3_CSUM, attr & VMA_TX_PACKET_L4_CSUM); auto_unlocker lock(m_lock_ring_tx); -#ifdef DEFINED_TSO -#else + mem_buf_desc_t* p_mem_buf_desc = (mem_buf_desc_t*)(p_send_wqe->wr_id); p_mem_buf_desc->lwip_pbuf.pbuf.ref++; -#endif /* DEFINED_TSO */ + int ret = send_buffer(p_send_wqe, attr); send_status_handler(ret, p_send_wqe); } @@ -425,6 +402,7 @@ int ring_tap::process_element_rx(void* pv_fd_ready_array) auto_unlocker lock(m_lock_ring_rx); if (m_rx_pool.size() || request_more_rx_buffers()) { mem_buf_desc_t *buff = m_rx_pool.get_and_pop_front(); + /* coverity[dereference:FALSE] */ ret = orig_os_api.read(m_tap_fd, buff->p_buffer, buff->sz_buffer); if (ret > 0) { /* Data was read and processed successfully */ @@ -485,8 +463,10 @@ mem_buf_desc_t* ring_tap::mem_buf_tx_get(ring_user_id_t id, bool b_block, int n_ return head; } } - + /* coverity[nonnull] */ head = m_tx_pool.get_and_pop_back(); + /* coverity[dereference:FALSE] */ + /* coverity[var_deref_op:FALSE] */ head->lwip_pbuf.pbuf.ref = 1; n_num_mem_bufs--; @@ -515,8 +495,6 @@ void ring_tap::mem_buf_desc_return_single_to_owner_tx(mem_buf_desc_t* p_mem_buf_ { auto_unlocker lock(m_lock_ring_tx); - int count = 0; - if (likely(p_mem_buf_desc)) { //potential race, ref is protected here by ring_tx lock, and in dst_entry_tcp & sockinfo_tcp by tcp lock if (likely(p_mem_buf_desc->lwip_pbuf.pbuf.ref)) @@ -528,7 +506,6 @@ void ring_tap::mem_buf_desc_return_single_to_owner_tx(mem_buf_desc_t* p_mem_buf_ p_mem_buf_desc->p_next_desc = NULL; free_lwip_pbuf(&p_mem_buf_desc->lwip_pbuf); m_tx_pool.push_back(p_mem_buf_desc); - count++; } } @@ -567,6 +544,8 @@ int ring_tap::mem_buf_tx_release(mem_buf_desc_t* buff_list, bool b_accounting, b count++; buff_list = next; } + // to suppress warning in case ring_logfunc is compiled out + NOT_IN_USE(freed); ring_logfunc("buf_list: %p count: %d freed: %d\n", buff_list, count, freed); return_to_global_pool(); @@ -576,7 +555,7 @@ int ring_tap::mem_buf_tx_release(mem_buf_desc_t* buff_list, bool b_accounting, b return count; } -int ring_tap::send_buffer(vma_ibv_send_wr* wr, vma_wr_tx_packet_attr attr) +int ring_tap::send_buffer(ibv_send_wr* wr, vma_wr_tx_packet_attr attr) { int ret = 0; iovec iovec[wr->num_sge]; @@ -595,7 +574,7 @@ int ring_tap::send_buffer(vma_ibv_send_wr* wr, vma_wr_tx_packet_attr attr) return ret; } -void ring_tap::send_status_handler(int ret, vma_ibv_send_wr* p_send_wqe) +void ring_tap::send_status_handler(int ret, ibv_send_wr* p_send_wqe) { // Pay attention that there is a difference in return values in ring_simple and ring_tap // Non positive value of ret means that we are on error flow (unlike for ring_simple). diff --git a/src/vma/dev/ring_tap.h b/src/vma/dev/ring_tap.h index 3feb58d7b5..5117721ae7 100644 --- a/src/vma/dev/ring_tap.h +++ b/src/vma/dev/ring_tap.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef RING_TAP_H_ @@ -51,12 +25,12 @@ class ring_tap : public ring_slave virtual bool reclaim_recv_buffers(descq_t *rx_reuse); virtual bool reclaim_recv_buffers(mem_buf_desc_t *buff); virtual int reclaim_recv_single_buffer(mem_buf_desc_t* rx_reuse) { NOT_IN_USE(rx_reuse); return -1; } - virtual void send_ring_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); - virtual void send_lwip_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); + virtual void send_ring_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); + virtual void send_lwip_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); virtual void mem_buf_desc_return_single_to_owner_tx(mem_buf_desc_t* p_mem_buf_desc); virtual mem_buf_desc_t* mem_buf_tx_get(ring_user_id_t id, bool b_block, int n_num_mem_bufs = 1); virtual int mem_buf_tx_release(mem_buf_desc_t* p_mem_buf_desc_list, bool b_accounting, bool trylock = false); - virtual bool get_hw_dummy_send_support(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe) { NOT_IN_USE(id); NOT_IN_USE(p_send_wqe); return false; } + virtual bool get_hw_dummy_send_support(ring_user_id_t id, ibv_send_wr* p_send_wqe) { NOT_IN_USE(id); NOT_IN_USE(p_send_wqe); return false; } virtual int request_notification(cq_type_t cq_type, uint64_t poll_sn) { NOT_IN_USE(cq_type); NOT_IN_USE(poll_sn); return 0; } virtual void adapt_cq_moderation() {} @@ -69,15 +43,7 @@ class ring_tap : public ring_slave virtual int modify_ratelimit(struct vma_rate_limit_t &rate_limit) { NOT_IN_USE(rate_limit); return 0; } void inc_cq_moderation_stats(size_t sz_data) { NOT_IN_USE(sz_data); } - virtual uint32_t get_underly_qpn() { return -1; } - virtual uint32_t get_max_inline_data() { return 0; } -#ifdef DEFINED_TSO - virtual uint32_t get_max_send_sge(void) { return 1; } - virtual uint32_t get_max_payload_sz(void) { return 0; } - virtual uint16_t get_max_header_sz(void) { return 0; } - virtual uint32_t get_tx_lkey(ring_user_id_t id) { NOT_IN_USE(id); return 0; } - virtual bool is_tso(void) { return false; } -#endif /* DEFINED_TSO */ + virtual uint32_t get_max_inline_data() { return 0; } inline void set_tap_data_available() { m_tap_data_available = true; } inline void set_vf_ring(ring_slave *p_ring) { m_vf_ring = p_ring; } @@ -89,8 +55,8 @@ class ring_tap : public ring_slave int prepare_flow_message(vma_msg_flow& data, msg_flow_t flow_action); int process_element_rx(void* pv_fd_ready_array); bool request_more_rx_buffers(); - int send_buffer(vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); - void send_status_handler(int ret, vma_ibv_send_wr* p_send_wqe); + int send_buffer(ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr); + void send_status_handler(int ret, ibv_send_wr* p_send_wqe); void tap_create(net_device_val* p_ndev); void tap_destroy(); diff --git a/src/vma/dev/time_converter.cpp b/src/vma/dev/time_converter.cpp index b98b51fc09..07bdb870ea 100644 --- a/src/vma/dev/time_converter.cpp +++ b/src/vma/dev/time_converter.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -64,7 +38,7 @@ uint32_t time_converter::get_single_converter_status(struct ibv_context* ctx) { // Checking if ibv_exp_query_device() is valid vma_ibv_device_attr_ex device_attr; memset(&device_attr, 0, sizeof(device_attr)); - device_attr.comp_mask = VMA_IBV_DEVICE_ATTR_HCA_CORE_CLOCK; + device_attr.comp_mask = 0; if ((rval = vma_ibv_query_device(ctx ,&device_attr)) || !device_attr.hca_core_clock) { ibchtc_logdbg("time_converter::get_single_converter_status :Error in querying hca core clock " @@ -74,12 +48,12 @@ uint32_t time_converter::get_single_converter_status(struct ibv_context* ctx) { } // Checking if ibv_exp_query_values() is valid - vma_ts_values queried_values; + ibv_values_ex queried_values; memset(&queried_values, 0, sizeof(queried_values)); - queried_values.comp_mask = VMA_IBV_VALUES_MASK_RAW_CLOCK; - if ((rval = vma_ibv_query_values(ctx, &queried_values)) || !vma_get_ts_val(queried_values)) { + queried_values.comp_mask = IBV_VALUES_MASK_RAW_CLOCK; + if ((rval = ibv_query_rt_values_ex(ctx, &queried_values)) || !vma_get_ts_val(queried_values)) { ibchtc_logdbg("time_converter::get_single_converter_status :Error in querying hw clock, can't convert" - " hw time to system time (vma_ibv_query_values() return value=%d ) (ibv context %p) (errno=%d %m)\n", rval, ctx, errno); + " hw time to system time (ibv_query_rt_values_ex() return value=%d ) (ibv context %p) (errno=%d %m)\n", rval, ctx, errno); } else { dev_status |= VMA_QUERY_VALUES_SUPPORTED; } diff --git a/src/vma/dev/time_converter.h b/src/vma/dev/time_converter.h index 3fbe5e6e39..530ce40c71 100644 --- a/src/vma/dev/time_converter.h +++ b/src/vma/dev/time_converter.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/dev/time_converter_ib_ctx.cpp b/src/vma/dev/time_converter_ib_ctx.cpp index da7acafddc..a3babc75af 100644 --- a/src/vma/dev/time_converter_ib_ctx.cpp +++ b/src/vma/dev/time_converter_ib_ctx.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -99,15 +73,15 @@ uint64_t time_converter_ib_ctx::get_hca_core_clock(){ #ifdef DEFINED_IBV_CQ_TIMESTAMP bool time_converter_ib_ctx::sync_clocks(struct timespec* st, uint64_t* hw_clock){ struct timespec st1, st2, diff, st_min = TIMESPEC_INITIALIZER; - vma_ts_values queried_values; + ibv_values_ex queried_values; int64_t interval, best_interval = 0; uint64_t hw_clock_min = 0; memset(&queried_values, 0, sizeof(queried_values)); - queried_values.comp_mask = VMA_IBV_VALUES_MASK_RAW_CLOCK; + queried_values.comp_mask = IBV_VALUES_MASK_RAW_CLOCK; for (int i = 0 ; i < 10 ; i++) { clock_gettime(CLOCK_REALTIME, &st1); - if (vma_ibv_query_values(m_p_ibv_context, &queried_values) || !vma_get_ts_val(queried_values)) { + if (ibv_query_rt_values_ex(m_p_ibv_context, &queried_values) || !vma_get_ts_val(queried_values)) { return false; } diff --git a/src/vma/dev/time_converter_ib_ctx.h b/src/vma/dev/time_converter_ib_ctx.h index b44a855ca5..c99aa0a8ea 100644 --- a/src/vma/dev/time_converter_ib_ctx.h +++ b/src/vma/dev/time_converter_ib_ctx.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/dev/time_converter_ptp.cpp b/src/vma/dev/time_converter_ptp.cpp index e786f0c91d..8656c5560a 100644 --- a/src/vma/dev/time_converter_ptp.cpp +++ b/src/vma/dev/time_converter_ptp.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -60,8 +34,8 @@ time_converter_ptp::time_converter_ptp(struct ibv_context* ctx) : { for (size_t i=0; i < ARRAY_SIZE(m_clock_values); i++) { memset(&m_clock_values[i], 0, sizeof(m_clock_values[i])); - if (vma_ibv_query_clock_info(m_p_ibv_context, &m_clock_values[i])) { - ibchtc_logerr("vma_ibv_query_clock_info failure for clock_info, (ibv context %p)", m_p_ibv_context); + if (mlx5dv_get_clock_info(m_p_ibv_context, &m_clock_values[i])) { + ibchtc_logerr("mlx5dv_get_clock_info failure for clock_info, (ibv context %p)", m_p_ibv_context); } } @@ -78,15 +52,15 @@ void time_converter_ptp::handle_timer_expired(void* user_data) { } int ret = 0; - ret = vma_ibv_query_clock_info(m_p_ibv_context, &m_clock_values[1 - m_clock_values_id]); + ret = mlx5dv_get_clock_info(m_p_ibv_context, &m_clock_values[1 - m_clock_values_id]); if (ret) - ibchtc_logerr("vma_ibv_query_clock_info failure for clock_info, (ibv context %p) (return value=%d)", m_p_ibv_context, ret); + ibchtc_logerr("mlx5dv_get_clock_info failure for clock_info, (ibv context %p) (return value=%d)", m_p_ibv_context, ret); m_clock_values_id = 1 - m_clock_values_id; } void time_converter_ptp::convert_hw_time_to_system_time(uint64_t hwtime, struct timespec* systime) { - uint64_t sync_hw_clock = vma_ibv_convert_ts_to_ns(&m_clock_values[m_clock_values_id], hwtime); + uint64_t sync_hw_clock = mlx5dv_ts_to_ns(&m_clock_values[m_clock_values_id], hwtime); systime->tv_sec = sync_hw_clock / NSEC_PER_SEC; systime->tv_nsec = sync_hw_clock % NSEC_PER_SEC; diff --git a/src/vma/dev/time_converter_ptp.h b/src/vma/dev/time_converter_ptp.h index 04946946aa..f30afe60d7 100644 --- a/src/vma/dev/time_converter_ptp.h +++ b/src/vma/dev/time_converter_ptp.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -53,7 +27,7 @@ class time_converter_ptp : public time_converter private: struct ibv_context* m_p_ibv_context; - vma_ibv_clock_info m_clock_values[2]; + mlx5dv_clock_info m_clock_values[2]; int m_clock_values_id; }; diff --git a/src/vma/dev/wqe_send_handler.cpp b/src/vma/dev/wqe_send_handler.cpp index 6285c66e52..3ac5d1bf9b 100644 --- a/src/vma/dev/wqe_send_handler.cpp +++ b/src/vma/dev/wqe_send_handler.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -41,24 +15,24 @@ wqe_send_handler::~wqe_send_handler() { } -void wqe_send_handler::init_inline_wqe(vma_ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge) +void wqe_send_handler::init_inline_wqe(ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge) { init_not_inline_wqe(wqe_to_init, sge_list, num_sge); enable_inline(wqe_to_init); } -void wqe_send_handler::init_not_inline_wqe(vma_ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge) +void wqe_send_handler::init_not_inline_wqe(ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge) { init_wqe(wqe_to_init, sge_list, num_sge); enable_hw_csum(wqe_to_init); } -void wqe_send_handler::init_wqe(vma_ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge) +void wqe_send_handler::init_wqe(ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge) { memset(&wqe_to_init, 0, sizeof(wqe_to_init)); wqe_to_init.num_sge = num_sge; - vma_send_wr_opcode(wqe_to_init) = VMA_IBV_WR_SEND; + vma_send_wr_opcode(wqe_to_init) = IBV_WR_SEND; wqe_to_init.next = NULL; wqe_to_init.sg_list = sge_list; wqe_to_init.wr_id = 0; diff --git a/src/vma/dev/wqe_send_handler.h b/src/vma/dev/wqe_send_handler.h index abebeb2037..ce21579cef 100644 --- a/src/vma/dev/wqe_send_handler.h +++ b/src/vma/dev/wqe_send_handler.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "vma/ib/base/verbs_extra.h" @@ -42,34 +16,25 @@ class wqe_send_handler: public tostr wqe_send_handler(); virtual ~wqe_send_handler(); - void init_wqe(vma_ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge); - void init_inline_wqe(vma_ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge); - void init_not_inline_wqe(vma_ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge); + void init_wqe(ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge); + void init_inline_wqe(ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge); + void init_not_inline_wqe(ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge); - inline vma_ibv_wr_opcode set_opcode(vma_ibv_send_wr &wqe, vma_ibv_wr_opcode opcode) { - vma_ibv_wr_opcode last_opcode = vma_send_wr_opcode(wqe); + inline ibv_wr_opcode set_opcode(ibv_send_wr &wqe, ibv_wr_opcode opcode) { + ibv_wr_opcode last_opcode = vma_send_wr_opcode(wqe); vma_send_wr_opcode(wqe) = opcode; return last_opcode; } #ifndef DEFINED_SW_CSUM - inline void enable_hw_csum (vma_ibv_send_wr &send_wqe) { vma_send_wr_send_flags(send_wqe) |= VMA_IBV_SEND_IP_CSUM; } - inline void disable_hw_csum (vma_ibv_send_wr &send_wqe) { vma_send_wr_send_flags(send_wqe) &= ~VMA_IBV_SEND_IP_CSUM; } + inline void enable_hw_csum (ibv_send_wr &send_wqe) { vma_send_wr_send_flags(send_wqe) |= IBV_SEND_IP_CSUM; } + inline void disable_hw_csum (ibv_send_wr &send_wqe) { vma_send_wr_send_flags(send_wqe) &= ~IBV_SEND_IP_CSUM; } #else - inline void enable_hw_csum (vma_ibv_send_wr &) {} - inline void disable_hw_csum (vma_ibv_send_wr &) {} + inline void enable_hw_csum (ibv_send_wr &) {} + inline void disable_hw_csum (ibv_send_wr &) {} #endif -#ifdef DEFINED_TSO - inline void enable_tso(vma_ibv_send_wr &wr, void *hdr, uint16_t hdr_sz, uint16_t mss) { - vma_send_wr_opcode(wr) = VMA_IBV_WR_TSO; - wr.tso.hdr = hdr; - wr.tso.hdr_sz = hdr_sz; - wr.tso.mss = mss; - } -#endif /* DEFINED_TSO */ - - inline void enable_inline (vma_ibv_send_wr &send_wqe) { vma_send_wr_send_flags(send_wqe) |= VMA_IBV_SEND_INLINE; } + inline void enable_inline (ibv_send_wr &send_wqe) { vma_send_wr_send_flags(send_wqe) |= IBV_SEND_INLINE; } }; #endif /* IB_WQE_TEMPLATE_H */ diff --git a/src/vma/dev/wqe_send_ib_handler.cpp b/src/vma/dev/wqe_send_ib_handler.cpp deleted file mode 100644 index b299128408..0000000000 --- a/src/vma/dev/wqe_send_ib_handler.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "wqe_send_ib_handler.h" - -wqe_send_ib_handler::wqe_send_ib_handler() -{ -} - -wqe_send_ib_handler::~wqe_send_ib_handler() -{ -} - -void wqe_send_ib_handler::init_path_record(vma_ibv_send_wr &wqe_to_init, struct ibv_ah *ah, uint32_t rem_qkey, uint32_t rem_qpn) -{ - wqe_to_init.wr.ud.ah = ah; - wqe_to_init.wr.ud.remote_qkey = rem_qkey; - wqe_to_init.wr.ud.remote_qpn = rem_qpn; -} - -void wqe_send_ib_handler::init_ib_wqe(vma_ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge, - struct ibv_ah *ah, uint32_t rem_qpn, uint32_t rem_qkey) -{ - wqe_send_handler::init_wqe(wqe_to_init, sge_list, num_sge); - init_path_record(wqe_to_init, ah, rem_qkey, rem_qpn); -} - -void wqe_send_ib_handler::init_inline_ib_wqe(vma_ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge, - struct ibv_ah *ah, uint32_t rem_qpn, uint32_t rem_qkey) -{ - wqe_send_handler::init_inline_wqe(wqe_to_init, sge_list, num_sge); - init_path_record(wqe_to_init, ah, rem_qkey, rem_qpn); -} - -void wqe_send_ib_handler::init_not_inline_ib_wqe(vma_ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge, - struct ibv_ah *ah, uint32_t rem_qpn, uint32_t rem_qkey) -{ - wqe_send_handler::init_not_inline_wqe(wqe_to_init, sge_list, num_sge); - init_path_record(wqe_to_init, ah, rem_qkey, rem_qpn); -} diff --git a/src/vma/dev/wqe_send_ib_handler.h b/src/vma/dev/wqe_send_ib_handler.h deleted file mode 100644 index 0b94ed7b82..0000000000 --- a/src/vma/dev/wqe_send_ib_handler.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "wqe_send_handler.h" -#include "vma/util/vtypes.h" - -#ifndef WQE_TEMPLATE_SEND_IB_H_ -#define WQE_TEMPLATE_SEND_IB_H_ - -class wqe_send_ib_handler: public wqe_send_handler -{ -public: - wqe_send_ib_handler(); - virtual ~wqe_send_ib_handler(); - - void init_ib_wqe(vma_ibv_send_wr &wqe_to_init, struct ibv_sge* sge_list, uint32_t num_sge, struct ibv_ah *ah, uint32_t rem_qpn, uint32_t rem_qkey); - void init_inline_ib_wqe(vma_ibv_send_wr & wqe_to_init, struct ibv_sge *sge_list, uint32_t num_sge, struct ibv_ah *ah, uint32_t rem_qpn, uint32_t rem_qkey); - void init_not_inline_ib_wqe(vma_ibv_send_wr & wqe_to_init, struct ibv_sge *sge_list, uint32_t num_sge, struct ibv_ah *ah, uint32_t rem_qpn, uint32_t rem_qkey); - -private: - void init_path_record(vma_ibv_send_wr & wqe_to_init, struct ibv_ah *ah, uint32_t rem_qkey, uint32_t rem_qpn); -}; - -#endif /* WQE_TEMPLATE_SEND_IB_H_ */ diff --git a/src/vma/event/command.h b/src/vma/event/command.h index a8cc2f4225..4e14039113 100644 --- a/src/vma/event/command.h +++ b/src/vma/event/command.h @@ -1,36 +1,9 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause + * * command.h - * */ #ifndef COMMAND_H_ diff --git a/src/vma/event/delta_timer.cpp b/src/vma/event/delta_timer.cpp index 9c3c273bec..c7d4c6f055 100644 --- a/src/vma/event/delta_timer.cpp +++ b/src/vma/event/delta_timer.cpp @@ -1,38 +1,12 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ +#include #include -#include #include "utils/bullseye.h" #include "utils/clock.h" #include "vlogger/vlogger.h" @@ -52,15 +26,16 @@ //#define tmr_logfuncall __log_funcall #define tmr_logfuncall(fmt, ...) +using namespace std::chrono; #define IS_NODE_INVALID(_node_) \ (!_node_ || !_node_->handler || (_node_->req_type < 0 || _node_->req_type >= INVALID_TIMER)) timer::timer() + : m_list_head(nullptr) + , m_ts_last(steady_clock::now()) { - m_list_head = NULL; - gettime(&m_ts_last); } timer::~timer() @@ -82,7 +57,7 @@ void timer::add_new_timer(unsigned int timeout_msec, timer_node_t* node, timer_h node->handler = handler; node->req_type = req_type; node->user_data = user_data; - node->orig_time_msec = timeout_msec; + node->orig_time_msec = milliseconds(timeout_msec); BULLSEYE_EXCLUDE_BLOCK_START if (IS_NODE_INVALID(node)) { @@ -105,8 +80,8 @@ void timer::wakeup_timer(timer_node_t* node) remove_from_list(node); - unsigned int orig_time = node->orig_time_msec; - node->orig_time_msec = 0; + auto orig_time = node->orig_time_msec; + node->orig_time_msec = milliseconds(0); insert_to_list(node); node->orig_time_msec = orig_time; @@ -166,6 +141,7 @@ void timer::remove_all_timers(timer_handler *handler) remove_from_list(node_tmp); // Remove & Free node free(node_tmp); + // coverity[assigned_pointer:FALSE] /* NULL assign for already freed object */ node_tmp = NULL; } else { node = node->next; @@ -178,48 +154,41 @@ void timer::remove_all_timers(timer_handler *handler) int timer::update_timeout() { - int ret = 0, delta_msec = 0; + int ret; timer_node_t* list_tmp = NULL; - struct timespec ts_now, ts_delta; + auto now = steady_clock::now(); - ret = gettime(&ts_now); - BULLSEYE_EXCLUDE_BLOCK_START - if (ret) { - tmr_logpanic("gettime() returned with error (errno %d %m)", ret); - return INFINITE_TIMEOUT; - } - BULLSEYE_EXCLUDE_BLOCK_END - // Find difference (subtract) - ts_sub(&ts_now, &m_ts_last, &ts_delta); - delta_msec = ts_to_msec(&ts_delta); + auto delta = duration_cast(now - m_ts_last); // Save 'now' as 'last' - if (delta_msec > 0) - m_ts_last = ts_now; + if (delta > milliseconds(0)) { + m_ts_last = now; + } // empty list -> unlimited timeout if (!m_list_head) { - tmr_logfunc("elapsed time: %d msec", delta_msec); + tmr_logfunc("elapsed time: %ld msec", delta.count()); ret = INFINITE_TIMEOUT; goto out; } // Check for timeout! list_tmp = m_list_head; - while (delta_msec > 0 && list_tmp) { - tmr_logfuncall("updating list node %p with elapsed time: %d msec", list_tmp, delta_msec); - if ((int) list_tmp->delta_time_msec > delta_msec) { - list_tmp->delta_time_msec -= delta_msec; + while (delta > milliseconds(0) && list_tmp) { + tmr_logfuncall("updating list node %p with elapsed time: %ld msec", list_tmp, + delta.count()); + if (list_tmp->delta_time_msec > delta) { + list_tmp->delta_time_msec -= delta; break; } else { - delta_msec -= list_tmp->delta_time_msec; - list_tmp->delta_time_msec = 0; + delta -= list_tmp->delta_time_msec; + list_tmp->delta_time_msec = milliseconds(0); } list_tmp = list_tmp->next; } - ret = m_list_head->delta_time_msec; + ret = m_list_head->delta_time_msec.count(); out: tmr_logfuncall("next timeout: %d msec", ret); @@ -230,7 +199,7 @@ void timer::process_registered_timers() { timer_node_t* iter = m_list_head; timer_node_t* next_iter; - while (iter && (iter->delta_time_msec == 0)) { + while (iter && (iter->delta_time_msec == milliseconds(0))) { tmr_logfuncall("timer expired on %p", iter->handler); /* Special check is need to protect @@ -273,7 +242,6 @@ void timer::process_registered_timers() // insert allocated node to the list void timer::insert_to_list(timer_node_t* new_node) { - unsigned int tmp_delta; timer_node_t* iter; timer_node_t* prev; @@ -282,16 +250,17 @@ void timer::insert_to_list(timer_node_t* new_node) new_node->next = NULL; new_node->prev = NULL; m_list_head = new_node; - tmr_logfuncall("insert first node to list (handler %p, timer %d, delta time %d)", new_node->handler, new_node->orig_time_msec, new_node->delta_time_msec); + tmr_logfuncall("insert first node to list (handler %p, timer %d, delta time %d)", + new_node->handler, new_node->orig_time_msec, new_node->delta_time_msec); return; } // else: need to find the correct place in the list - tmp_delta = new_node->orig_time_msec; + auto tmp_delta = new_node->orig_time_msec; iter = m_list_head; prev = NULL; while (iter && tmp_delta >= iter->delta_time_msec) { - tmp_delta = tmp_delta - iter->delta_time_msec; + tmp_delta -= iter->delta_time_msec; prev = iter; iter = iter->next; } @@ -307,10 +276,12 @@ void timer::insert_to_list(timer_node_t* new_node) } // update the delta time for the next element if (new_node->next) { - new_node->next->delta_time_msec = new_node->next->delta_time_msec - new_node->delta_time_msec; + new_node->next->delta_time_msec -= new_node->delta_time_msec; new_node->next->prev = new_node; } - tmr_logfuncall("insert new node to list (handler %p, timer %d, delta time %d)", new_node->handler, new_node->orig_time_msec, new_node->delta_time_msec); + tmr_logfuncall("insert new node to list (handler %p, timer %ld, delta time %ld)", + new_node->handler, new_node->orig_time_msec.count(), + new_node->delta_time_msec.count()); } // remove timer from list (without free) @@ -325,10 +296,11 @@ void timer::remove_from_list(timer_node_t* node) m_list_head = node->next; } if (node->next) { // not the last element in list - node->next->delta_time_msec = node->next->delta_time_msec + node->delta_time_msec; + node->next->delta_time_msec += node->delta_time_msec; node->next->prev = node->prev; } - tmr_logfuncall("removed node from list (handler %p, timer %d, delta time %d)", node->handler, node->orig_time_msec, node->delta_time_msec); + tmr_logfuncall("removed node from list (handler %p, timer %ld, delta time %ld)", node->handler, + node->orig_time_msec.count(), node->delta_time_msec.count()); } @@ -353,7 +325,7 @@ void timer::debug_print_list() timer_node_t* iter = m_list_head; tmr_logdbg(""); while (iter) { - tmr_logdbg("node %p timer %d",iter, iter->delta_time_msec); + tmr_logdbg("node %p timer %ld",iter, iter->delta_time_msec.count()); iter = iter->next; } } diff --git a/src/vma/event/delta_timer.h b/src/vma/event/delta_timer.h index c453f8510b..3e6f9c050c 100644 --- a/src/vma/event/delta_timer.h +++ b/src/vma/event/delta_timer.h @@ -1,40 +1,14 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef DELTA_TIMER_H #define DELTA_TIMER_H -#include +#include #include "utils/lock_wrapper.h" #define INFINITE_TIMEOUT (-1) @@ -55,9 +29,9 @@ enum timer_req_type_t { struct timer_node_t { /* delta time from the previous node (millisec) */ - unsigned int delta_time_msec; + std::chrono::milliseconds delta_time_msec; /* the orig timer requested (saved in order to re-register periodic timers) */ - unsigned int orig_time_msec; + std::chrono::milliseconds orig_time_msec; /* control thread-safe access to handler. Recursive because unregister_timer_event() * can be called from handle_timer_expired() * that is under trylock() inside process_registered_timers @@ -107,7 +81,7 @@ class timer void remove_from_list(timer_node_t* node); timer_node_t* m_list_head; - timespec m_ts_last; + std::chrono::time_point m_ts_last; }; const char* timer_req_type_str(timer_req_type_t type); diff --git a/src/vma/event/event.h b/src/vma/event/event.h index fe7678efe9..aadb5fcf32 100644 --- a/src/vma/event/event.h +++ b/src/vma/event/event.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/event/event_handler_ibverbs.h b/src/vma/event/event_handler_ibverbs.h index f3e783fd27..7e251c7949 100644 --- a/src/vma/event/event_handler_ibverbs.h +++ b/src/vma/event/event_handler_ibverbs.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/event/event_handler_manager.cpp b/src/vma/event/event_handler_manager.cpp index 9e2a2515ca..b26de0cac6 100644 --- a/src/vma/event/event_handler_manager.cpp +++ b/src/vma/event/event_handler_manager.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -230,7 +204,9 @@ void event_handler_manager::register_command_event(int fd, command* cmd) event_handler_manager::event_handler_manager() : m_reg_action_q_lock("reg_action_q_lock"), m_b_sysvar_internal_thread_arm_cq_enabled(safe_mce_sys().internal_thread_arm_cq_enabled), + #ifdef VMA_TIME_MEASURE m_n_sysvar_vma_time_measure_num_samples(safe_mce_sys().vma_time_measure_num_samples), + #endif m_n_sysvar_timer_resolution_msec(safe_mce_sys().timer_resolution_msec) { evh_logfunc(""); @@ -509,15 +485,7 @@ void event_handler_manager::priv_register_ibverbs_events(ibverbs_reg_info_t& inf event_handler_map_t::iterator i; i = m_event_handler_map.find(info.fd); if (i == m_event_handler_map.end()) { - event_data_t v; - - v.type = EV_IBVERBS; - v.ibverbs_ev.fd = info.fd; - v.ibverbs_ev.channel = info.channel; - - /* coverity[uninit_use_in_call] */ - /* cppcheck-suppress uninitStructMember */ - m_event_handler_map[info.fd] = v; + m_event_handler_map[info.fd] = event_data_t(EV_IBVERBS, info); i = m_event_handler_map.find(info.fd); priv_prepare_ibverbs_async_event_queue(i); @@ -598,16 +566,7 @@ void event_handler_manager::priv_register_rdma_cm_events(rdma_cm_reg_info_t& inf event_handler_map_t::iterator iter_fd = m_event_handler_map.find(info.fd); if (iter_fd == m_event_handler_map.end()) { evh_logdbg("Adding new channel (fd %d, id %p, handler %p)", info.fd, info.id, info.handler); - event_data_t map_value; - - map_value.type = EV_RDMA_CM; - map_value.rdma_cm_ev.n_ref_count = 1; - map_value.rdma_cm_ev.map_rdma_cm_id[info.id] = info.handler; - map_value.rdma_cm_ev.cma_channel = info.cma_channel; - - /* coverity[uninit_use_in_call] */ - /* cppcheck-suppress uninitStructMember */ - m_event_handler_map[info.fd] = map_value; + m_event_handler_map[info.fd] = event_data_t(EV_RDMA_CM, info); update_epfd(info.fd, EPOLL_CTL_ADD, EPOLLIN | EPOLLPRI); } @@ -673,14 +632,8 @@ void event_handler_manager::priv_register_command_events(command_reg_info_t& inf event_handler_map_t::iterator iter_fd = m_event_handler_map.find(info.fd); if (iter_fd == m_event_handler_map.end()) { evh_logdbg("Adding new channel (fd %d)", info.fd); - event_data_t map_value; - - map_value.type = EV_COMMAND; - map_value.command_ev.cmd = info.cmd; + m_event_handler_map[info.fd] = event_data_t(EV_COMMAND, info); - /* coverity[uninit_use_in_call] */ - /* cppcheck-suppress uninitStructMember */ - m_event_handler_map[info.fd] = map_value; update_epfd(info.fd, EPOLL_CTL_ADD, EPOLLIN | EPOLLPRI); } @@ -844,7 +797,7 @@ void event_handler_manager::process_rdma_cm_event(event_handler_map_t::iterator // Ack rdma_cm event (free) rdma_ack_cm_event(p_tmp_cm_event); - evh_logdbg("[%d] Received rdma_cm event %s (%d)", cma_channel->fd, priv_rdma_cm_event_type_str(cma_event.event), cma_event.event); + evh_logdbg("[%d] Received rdma_cm event %s (%d)", cma_channel->fd, rdma_event_str(cma_event.event), cma_event.event); void* cma_id = (void*)cma_event.id; if (cma_event.listen_id) // we assume that cma_listen_id != NULL in case of connect request @@ -866,7 +819,7 @@ void event_handler_manager::process_rdma_cm_event(event_handler_map_t::iterator } } - evh_logdbg("[%d] Completed rdma_cm event %s (%d)", cma_channel->fd, priv_rdma_cm_event_type_str(cma_event.event), cma_event.event); + evh_logdbg("[%d] Completed rdma_cm event %s (%d)", cma_channel->fd, rdma_event_str(cma_event.event), cma_event.event); } diff --git a/src/vma/event/event_handler_manager.h b/src/vma/event/event_handler_manager.h index 300eae5d0e..ccfe889025 100644 --- a/src/vma/event/event_handler_manager.h +++ b/src/vma/event/event_handler_manager.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -140,6 +114,34 @@ struct event_data_t { ibverbs_ev_t ibverbs_ev; rdma_cm_ev_t rdma_cm_ev; command_ev_t command_ev; + event_data_t() = default; + event_data_t(ev_type t, const ibverbs_reg_info_t &info) + : type(t) + , ibverbs_ev {} + , rdma_cm_ev {} + , command_ev {} + { + ibverbs_ev.fd = info.fd; + ibverbs_ev.channel = info.channel; + } + event_data_t(ev_type t, const rdma_cm_reg_info_t &info) + : type(t) + , ibverbs_ev {} + , rdma_cm_ev {} + , command_ev {} + { + rdma_cm_ev.n_ref_count = 1; + rdma_cm_ev.map_rdma_cm_id[info.id] = info.handler; + rdma_cm_ev.cma_channel = info.cma_channel; + } + event_data_t(ev_type t, const command_reg_info_t &info) + : type(t) + , ibverbs_ev {} + , rdma_cm_ev {} + , command_ev {} + { + command_ev.cmd = info.cmd; + } }; typedef std::map event_handler_map_t; @@ -191,7 +193,9 @@ class event_handler_manager : public wakeup_pipe timer m_timer; const bool m_b_sysvar_internal_thread_arm_cq_enabled; + #ifdef VMA_TIME_MEASURE const uint32_t m_n_sysvar_vma_time_measure_num_samples; + #endif const uint32_t m_n_sysvar_timer_resolution_msec; event_handler_map_t m_event_handler_map; diff --git a/src/vma/event/event_handler_rdma_cm.h b/src/vma/event/event_handler_rdma_cm.h index dd0bcb5188..3e60c5b55c 100644 --- a/src/vma/event/event_handler_rdma_cm.h +++ b/src/vma/event/event_handler_rdma_cm.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/event/netlink_event.cpp b/src/vma/event/netlink_event.cpp index a8ad39450d..683e9ccd61 100644 --- a/src/vma/event/netlink_event.cpp +++ b/src/vma/event/netlink_event.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/event/netlink_event.h b/src/vma/event/netlink_event.h index 2ea38262df..a5d7691057 100644 --- a/src/vma/event/netlink_event.h +++ b/src/vma/event/netlink_event.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/event/timer_handler.h b/src/vma/event/timer_handler.h index 0d7efdf874..a42477739d 100644 --- a/src/vma/event/timer_handler.h +++ b/src/vma/event/timer_handler.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/event/timers_group.h b/src/vma/event/timers_group.h index 40f25f6f53..01131176bd 100644 --- a/src/vma/event/timers_group.h +++ b/src/vma/event/timers_group.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/event/vlogger_timer_handler.cpp b/src/vma/event/vlogger_timer_handler.cpp index 3fc3941072..f8764aeeb2 100644 --- a/src/vma/event/vlogger_timer_handler.cpp +++ b/src/vma/event/vlogger_timer_handler.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/event/vlogger_timer_handler.h b/src/vma/event/vlogger_timer_handler.h index d9a330ba38..7c71550d1c 100644 --- a/src/vma/event/vlogger_timer_handler.h +++ b/src/vma/event/vlogger_timer_handler.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/ib/base/verbs_extra.cpp b/src/vma/ib/base/verbs_extra.cpp index cf69b141e8..444adb949e 100644 --- a/src/vma/ib/base/verbs_extra.cpp +++ b/src/vma/ib/base/verbs_extra.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -105,27 +79,13 @@ const char* priv_ibv_event_desc_str(enum ibv_event_type type) BULLSEYE_EXCLUDE_BLOCK_END } -int priv_ibv_find_pkey_index(struct ibv_context *verbs, uint8_t port_num, uint16_t pkey, uint16_t *pkey_index) -{ - int ret, i; - uint16_t chk_pkey = 0; - for (i = 0, ret = 0; !ret; i++) { - ret = ibv_query_pkey(verbs, port_num, i, &chk_pkey); - if (!ret && pkey == chk_pkey) { - *pkey_index = (uint16_t)i; - return 0; - } - } - return -1; -} - int priv_ibv_modify_qp_to_err(struct ibv_qp *qp) { - vma_ibv_qp_attr qp_attr; + ibv_qp_attr qp_attr; memset(&qp_attr, 0, sizeof(qp_attr)); qp_attr.qp_state = IBV_QPS_ERR; BULLSEYE_EXCLUDE_BLOCK_START - IF_VERBS_FAILURE_EX(vma_ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE), EIO) { + IF_VERBS_FAILURE_EX(ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE), EIO) { return -1; } ENDIF_VERBS_FAILURE; BULLSEYE_EXCLUDE_BLOCK_END @@ -135,11 +95,11 @@ int priv_ibv_modify_qp_to_err(struct ibv_qp *qp) int priv_ibv_modify_qp_to_reset(struct ibv_qp *qp) { - vma_ibv_qp_attr qp_attr; + ibv_qp_attr qp_attr; memset(&qp_attr, 0, sizeof(qp_attr)); qp_attr.qp_state = IBV_QPS_RESET; BULLSEYE_EXCLUDE_BLOCK_START - IF_VERBS_FAILURE(vma_ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE)) { + IF_VERBS_FAILURE(ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE)) { return -1; } ENDIF_VERBS_FAILURE; BULLSEYE_EXCLUDE_BLOCK_END @@ -148,7 +108,7 @@ int priv_ibv_modify_qp_to_reset(struct ibv_qp *qp) int priv_ibv_modify_qp_from_err_to_init_raw(struct ibv_qp *qp, uint8_t port_num) { - vma_ibv_qp_attr qp_attr; + ibv_qp_attr qp_attr; if (qp->qp_type != IBV_QPT_RAW_PACKET) return -1; @@ -163,39 +123,7 @@ int priv_ibv_modify_qp_from_err_to_init_raw(struct ibv_qp *qp, uint8_t port_num) qp_attr.qp_state = IBV_QPS_INIT; qp_attr.port_num = port_num; BULLSEYE_EXCLUDE_BLOCK_START - IF_VERBS_FAILURE(vma_ibv_modify_qp(qp, &qp_attr, (ibv_qp_attr_mask)(IBV_QP_STATE | IBV_QP_PORT))) { - return -3; - } ENDIF_VERBS_FAILURE; - BULLSEYE_EXCLUDE_BLOCK_END - - return 0; -} - -int priv_ibv_modify_qp_from_err_to_init_ud(struct ibv_qp *qp, uint8_t port_num, uint16_t pkey_index, uint32_t underly_qpn) -{ - vma_ibv_qp_attr qp_attr; - ibv_qp_attr_mask qp_attr_mask = (ibv_qp_attr_mask)IBV_QP_STATE; - - if (qp->qp_type != IBV_QPT_UD) - return -1; - - if (priv_ibv_query_qp_state(qp) != IBV_QPS_RESET) { - if (priv_ibv_modify_qp_to_reset(qp)) { - return -2; - } - } - - memset(&qp_attr, 0, sizeof(qp_attr)); - qp_attr.qp_state = IBV_QPS_INIT; - if (0 == underly_qpn) { - qp_attr_mask = (ibv_qp_attr_mask)(qp_attr_mask | IBV_QP_QKEY | IBV_QP_PKEY_INDEX | IBV_QP_PORT); - qp_attr.qkey = IPOIB_QKEY; - qp_attr.pkey_index = pkey_index; - qp_attr.port_num = port_num; - } - - BULLSEYE_EXCLUDE_BLOCK_START - IF_VERBS_FAILURE(vma_ibv_modify_qp(qp, &qp_attr, qp_attr_mask)) { + IF_VERBS_FAILURE(ibv_modify_qp(qp, &qp_attr, (ibv_qp_attr_mask)(IBV_QP_STATE | IBV_QP_PORT))) { return -3; } ENDIF_VERBS_FAILURE; BULLSEYE_EXCLUDE_BLOCK_END @@ -205,7 +133,7 @@ int priv_ibv_modify_qp_from_err_to_init_ud(struct ibv_qp *qp, uint8_t port_num, int priv_ibv_modify_qp_from_init_to_rts(struct ibv_qp *qp, uint32_t underly_qpn) { - vma_ibv_qp_attr qp_attr; + ibv_qp_attr qp_attr; ibv_qp_attr_mask qp_attr_mask = (ibv_qp_attr_mask)IBV_QP_STATE; if (priv_ibv_query_qp_state(qp) != IBV_QPS_INIT) { @@ -215,7 +143,7 @@ int priv_ibv_modify_qp_from_init_to_rts(struct ibv_qp *qp, uint32_t underly_qpn) memset(&qp_attr, 0, sizeof(qp_attr)); qp_attr.qp_state = IBV_QPS_RTR; BULLSEYE_EXCLUDE_BLOCK_START - IF_VERBS_FAILURE(vma_ibv_modify_qp(qp, &qp_attr, qp_attr_mask)) { + IF_VERBS_FAILURE(ibv_modify_qp(qp, &qp_attr, qp_attr_mask)) { return -2; } ENDIF_VERBS_FAILURE; BULLSEYE_EXCLUDE_BLOCK_END @@ -228,7 +156,7 @@ int priv_ibv_modify_qp_from_init_to_rts(struct ibv_qp *qp, uint32_t underly_qpn) } BULLSEYE_EXCLUDE_BLOCK_START - IF_VERBS_FAILURE(vma_ibv_modify_qp(qp, &qp_attr, qp_attr_mask)) { + IF_VERBS_FAILURE(ibv_modify_qp(qp, &qp_attr, qp_attr_mask)) { return -3; } ENDIF_VERBS_FAILURE; BULLSEYE_EXCLUDE_BLOCK_END @@ -280,10 +208,10 @@ int priv_ibv_query_flow_tag_supported(struct ibv_qp *qp, uint8_t port_num) // Create struct { - vma_ibv_flow_attr attr; - vma_ibv_flow_spec_eth eth; - vma_ibv_flow_spec_ipv4 ipv4; - vma_ibv_flow_spec_tcp_udp tcp_udp; + ibv_flow_attr attr; + ibv_flow_spec_eth eth; + ibv_flow_spec_ipv4 ipv4; + ibv_flow_spec_tcp_udp tcp_udp; vma_ibv_flow_spec_action_tag flow_tag; } ft_attr; @@ -291,7 +219,7 @@ int priv_ibv_query_flow_tag_supported(struct ibv_qp *qp, uint8_t port_num) memset(&ft_attr, 0, sizeof(ft_attr)); ft_attr.attr.size = sizeof(ft_attr); ft_attr.attr.num_of_specs = 4; - ft_attr.attr.type = VMA_IBV_FLOW_ATTR_NORMAL; + ft_attr.attr.type = IBV_FLOW_ATTR_NORMAL; ft_attr.attr.priority = 1; // almost highest priority, 0 is used for 5-tuple later ft_attr.attr.port = port_num; @@ -308,10 +236,10 @@ int priv_ibv_query_flow_tag_supported(struct ibv_qp *qp, uint8_t port_num) ibv_flow_spec_flow_tag_set(&ft_attr.flow_tag, FLOW_TAG_MASK-1); // enable flow tag // Create flow - vma_ibv_flow *ibv_flow = vma_ibv_create_flow(qp, &ft_attr.attr); + ibv_flow *ibv_flow = ibv_create_flow(qp, &ft_attr.attr); if (ibv_flow) { res = 0; - vma_ibv_destroy_flow(ibv_flow); + ibv_destroy_flow(ibv_flow); } #endif // DEFINED_IBV_FLOW_TAG @@ -323,16 +251,16 @@ int priv_ibv_create_flow_supported(struct ibv_qp *qp, uint8_t port_num) int res = -1; struct { - vma_ibv_flow_attr attr; - vma_ibv_flow_spec_ipv4 ipv4; - vma_ibv_flow_spec_tcp_udp tcp_udp; + ibv_flow_attr attr; + ibv_flow_spec_ipv4 ipv4; + ibv_flow_spec_tcp_udp tcp_udp; } cf_attr; // Initialize memset(&cf_attr, 0, sizeof(cf_attr)); cf_attr.attr.size = sizeof(cf_attr); cf_attr.attr.num_of_specs = 2; - cf_attr.attr.type = VMA_IBV_FLOW_ATTR_NORMAL; + cf_attr.attr.type = IBV_FLOW_ATTR_NORMAL; cf_attr.attr.priority = 1; // almost highest priority, 0 is used for 5-tuple later cf_attr.attr.port = port_num; @@ -340,10 +268,10 @@ int priv_ibv_create_flow_supported(struct ibv_qp *qp, uint8_t port_num) ibv_flow_spec_tcp_udp_set(&cf_attr.tcp_udp, true, 0, 0); // L4 filter // Create flow - vma_ibv_flow *ibv_flow = vma_ibv_create_flow(qp, &cf_attr.attr); + ibv_flow *ibv_flow = ibv_create_flow(qp, &cf_attr.attr); if (ibv_flow) { res = 0; - vma_ibv_destroy_flow(ibv_flow); + ibv_destroy_flow(ibv_flow); } return res; @@ -375,7 +303,8 @@ int priv_ibv_modify_qp_ratelimit(struct ibv_qp *qp, struct vma_rate_limit_t &rat if (rate_limit.rate && (rl_changes & RL_RATE)) { qp_attr.rate_limit = rate_limit.rate; - attr_mask |= VMA_IBV_QP_RATE_LIMIT; + /* coverity[assigned_value] */ + attr_mask |= IBV_QP_RATE_LIMIT; } #ifdef DEFINED_IBV_QP_SUPPORT_BURST if (rate_limit.max_burst_sz && rate_limit.typical_pkt_sz && (rl_changes & (RL_BURST_SIZE | RL_PKT_SIZE))) { @@ -388,6 +317,7 @@ int priv_ibv_modify_qp_ratelimit(struct ibv_qp *qp, struct vma_rate_limit_t &rat return -2; } ENDIF_VERBS_FAILURE; BULLSEYE_EXCLUDE_BLOCK_END + NOT_IN_USE(attr_mask); /* vma_ibv_modify_qp_rate_limit may drop mask under DEFINED_IBV_QP_SUPPORT_BURST */ #ifdef DEFINED_IBV_QP_SUPPORT_BURST vlog_printf(VLOG_DEBUG, "qp was set to rate limit %d, burst size %d, packet size %d\n", rate_limit.rate, rate_limit.max_burst_sz, rate_limit.typical_pkt_sz); @@ -407,15 +337,15 @@ int priv_ibv_modify_qp_ratelimit(struct ibv_qp *qp, struct vma_rate_limit_t &rat void priv_ibv_modify_cq_moderation(struct ibv_cq* cq, uint32_t period, uint32_t count) { #ifdef DEFINED_IBV_CQ_ATTR_MODERATE - vma_ibv_cq_attr cq_attr; + ibv_modify_cq_attr cq_attr; memset(&cq_attr, 0, sizeof(cq_attr)); - vma_cq_attr_mask(cq_attr) = VMA_IBV_CQ_MODERATION; + vma_cq_attr_mask(cq_attr) = IBV_CQ_ATTR_MODERATE; vma_cq_attr_moderation(cq_attr).cq_count = count; vma_cq_attr_moderation(cq_attr).cq_period = period; vlog_printf(VLOG_FUNC, "modify cq moderation, period=%d, count=%d\n", period, count); - IF_VERBS_FAILURE_EX(vma_ibv_modify_cq(cq, &cq_attr, VMA_IBV_CQ_MODERATION), EIO) { + IF_VERBS_FAILURE_EX(ibv_modify_cq(cq, &cq_attr), EIO) { vlog_printf(VLOG_DEBUG, "Failure modifying cq moderation (errno=%d %m)\n", errno); } ENDIF_VERBS_FAILURE; #else diff --git a/src/vma/ib/base/verbs_extra.h b/src/vma/ib/base/verbs_extra.h index 1692541347..9c43302fb1 100644 --- a/src/vma/ib/base/verbs_extra.h +++ b/src/vma/ib/base/verbs_extra.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -38,21 +12,10 @@ #include #include #include "vma/util/vtypes.h" -#if defined(DEFINED_VERBS_VERSION) && (DEFINED_VERBS_VERSION == 2) -#include -#endif #include #include #include -#if defined(DEFINED_DIRECT_VERBS) #include "vma/ib/mlx5/ib_mlx5.h" -#endif /* DEFINED_DIRECT_VERBS */ - -#ifndef DEFINED_IBV_WC_WITH_VLAN -//#warning probaly you are trying to compile on OFED which doesnt support VLAN for RAW QP. -//#error when you see this then you need to manually open the below comment and to comment the current and the previous lines. -//#define IBV_WC_WITH_VLAN 1 << 3 -#endif // Wrapper for all IBVERBS & RDMA_CM API to normalize the return code and errno value // With these marco all ibverbs & rdma_cm failures are caugth and errno is updated @@ -71,7 +34,6 @@ inline int _errnocheck(int rc) { #define IF_RDMACM_FAILURE(__func__) IF_VERBS_FAILURE(__func__) #define ENDIF_RDMACM_FAILURE ENDIF_VERBS_FAILURE -#define IPOIB_QKEY 0x0b1b // See - IB Arch Spec - 11.6.2 COMPLETION RETURN STATUS const char* priv_ibv_wc_status_str(enum ibv_wc_status status); @@ -79,15 +41,8 @@ const char* priv_ibv_wc_status_str(enum ibv_wc_status status); // See - IB Arch Spec - 11.6.3 ASYNCHRONOUS EVENTS const char* priv_ibv_event_desc_str(enum ibv_event_type type); -#define priv_rdma_cm_event_type_str(__rdma_cm_ev_t__) \ - rdma_event_str(__rdma_cm_ev_t__) - -// Find pkey_index from the ibv_context + port_num + pkey -int priv_ibv_find_pkey_index(struct ibv_context *verbs, uint8_t port_num, uint16_t pkey, uint16_t *pkey_index); - int priv_ibv_modify_qp_to_err(struct ibv_qp *qp); int priv_ibv_modify_qp_from_err_to_init_raw(struct ibv_qp *qp, uint8_t port_num); -int priv_ibv_modify_qp_from_err_to_init_ud(struct ibv_qp *qp, uint8_t port_num, uint16_t pkey_index, uint32_t underly_qpn); int priv_ibv_modify_qp_from_init_to_rts(struct ibv_qp *qp, uint32_t underly_qpn = 0); // Return 'ibv_qp_state' of the ibv_qp @@ -112,20 +67,10 @@ int priv_ibv_query_flow_tag_supported(struct ibv_qp *qp, uint8_t port_num); int priv_ibv_create_flow_supported(struct ibv_qp *qp, uint8_t port_num); int priv_ibv_query_burst_supported(struct ibv_qp *qp, uint8_t port_num); -/* DEFINED_VERBS_VERSION: - * 1 - Legacy Verbs API - * 2 - Experimental Verbs API - * 3 - Upstream Verbs API - */ -#if defined(DEFINED_VERBS_VERSION) && (DEFINED_VERBS_VERSION == 1 || DEFINED_VERBS_VERSION == 3) //ibv_create_qp #ifdef DEFINED_IBV_QP_INIT_SOURCE_QPN #define vma_ibv_create_qp(pd, attr) ibv_create_qp_ex((pd)->context, attr) typedef struct ibv_qp_init_attr_ex vma_ibv_qp_init_attr; -#define vma_ibv_qp_create_flags(attr) (attr).create_flags -#define vma_ibv_qp_source_qpn(attr) (attr).source_qpn -#define VMA_IBV_QP_INIT_QPN_CREATE_FLAGS IBV_QP_CREATE_SOURCE_QPN -#define VMA_IBV_QP_INIT_QPN_MASK IBV_QP_INIT_ATTR_CREATE_FLAGS #define vma_ibv_qp_init_attr_comp_mask(_pd, _attr) { (_attr).pd = _pd; (_attr).comp_mask |= IBV_QP_INIT_ATTR_PD; } #else #define vma_ibv_create_qp(pd, attr) ibv_create_qp(pd, attr) @@ -134,28 +79,20 @@ typedef struct ibv_qp_init_attr vma_ibv_qp_init_attr; #endif //ibv_query_device -#define vma_ibv_device_attr_comp_mask(attr) NOT_IN_USE(attr) -typedef struct ibv_device_attr vma_ibv_device_attr; - #ifdef DEFINED_IBV_DEVICE_ATTR_EX #define vma_ibv_query_device(context, attr) ibv_query_device_ex(context, NULL, attr) typedef struct ibv_device_attr_ex vma_ibv_device_attr_ex; #define vma_get_device_orig_attr(device_attr) &device_attr->orig_attr #else #define vma_ibv_query_device(context, attr) ibv_query_device(context, attr) -typedef vma_ibv_device_attr vma_ibv_device_attr_ex; +typedef ibv_device_attr vma_ibv_device_attr_ex; #define vma_get_device_orig_attr(device_attr) device_attr #endif -//ibv_modify_qp -#define vma_ibv_modify_qp(qp, attr, mask) ibv_modify_qp(qp, attr, mask) -typedef struct ibv_qp_attr vma_ibv_qp_attr; //ibv_poll_cq -#define vma_ibv_poll_cq(cq, num, wc) ibv_poll_cq(cq, num, wc) -typedef struct ibv_wc vma_ibv_wc; #define vma_wc_flags(wc) (wc).wc_flags #define vma_wc_opcode(wc) (wc).opcode -#define VMA_IBV_WC_RECV IBV_WC_RECV + //csum offload #ifdef DEFINED_IBV_DEVICE_RAW_IP_CSUM #define vma_is_rx_hw_csum_supported(attr) ((attr)->device_cap_flags & (IBV_DEVICE_RAW_IP_CSUM | IBV_DEVICE_UD_IP_CSUM)) @@ -165,90 +102,32 @@ typedef struct ibv_wc vma_ibv_wc; #define vma_wc_rx_hw_csum_ok(wc) (1) #endif -typedef int vma_ibv_cq_init_attr; -#define vma_ibv_create_cq(context, cqe, cq_context, channel, comp_vector, attr) ibv_create_cq(context, cqe, cq_context, channel, comp_vector) - -//rx hw timestamp -#define VMA_IBV_WC_WITH_TIMESTAMP 0 -#define vma_wc_timestamp(wc) 0 -#define vma_ibv_cq_init_ts_attr(attr) { NOT_IN_USE(attr); } - #ifdef DEFINED_IBV_CQ_TIMESTAMP -#define VMA_IBV_DEVICE_ATTR_HCA_CORE_CLOCK 0 -#define VMA_IBV_VALUES_MASK_RAW_CLOCK IBV_VALUES_MASK_RAW_CLOCK -#define vma_ibv_query_values(ctx, values) ibv_query_rt_values_ex(ctx, values) #define vma_get_ts_val(values) values.raw_clock.tv_nsec -typedef struct ibv_values_ex vma_ts_values; #endif //ibv_post_send -#define VMA_IBV_SEND_SIGNALED IBV_SEND_SIGNALED -#define VMA_IBV_SEND_INLINE IBV_SEND_INLINE -#ifdef DEFINED_IBV_SEND_IP_CSUM - #define VMA_IBV_SEND_IP_CSUM (IBV_SEND_IP_CSUM) -#else +#ifndef DEFINED_IBV_SEND_IP_CSUM #define DEFINED_SW_CSUM #endif -#define vma_ibv_send_flags ibv_send_flags + #define vma_send_wr_send_flags(wr) (wr).send_flags -#define VMA_IBV_WR_SEND IBV_WR_SEND -#define vma_ibv_wr_opcode ibv_wr_opcode #define vma_send_wr_opcode(wr) (wr).opcode -#ifdef DEFINED_TSO - #define VMA_IBV_WR_TSO (vma_ibv_wr_opcode)IBV_WR_TSO - #define vma_check_dev_attr_tso(_attr) 1 - #define vma_get_tso_caps(_attr) (((vma_ibv_device_attr_ex *)(_attr))->tso_caps) - #define vma_ibv_qp_init_attr_tso(_attr, _max_tso_header) \ - do { \ - _attr.comp_mask |= IBV_QP_INIT_ATTR_MAX_TSO_HEADER; \ - _attr.max_tso_header = _max_tso_header; \ - } while (0) - typedef struct ibv_tso_caps vma_ibv_tso_caps; -#else - #define VMA_IBV_WR_TSO (vma_ibv_wr_opcode)VMA_IBV_WR_SEND - #define vma_check_dev_attr_tso(_attr) 0 - #define vma_ibv_qp_init_attr_tso(_attr, _max_tso_header) ((void)0) -#endif /* DEFINED_TSO */ - // Dummy send #ifdef DEFINED_IBV_WR_NOP #define vma_is_nop_supported(device_attr) 1 -#define VMA_IBV_WR_NOP (vma_ibv_wr_opcode)MLX5_OPCODE_NOP +#define VMA_IBV_WR_NOP (ibv_wr_opcode)MLX5_OPCODE_NOP #else #define vma_is_nop_supported(device_attr) 0 -#define VMA_IBV_WR_NOP (vma_ibv_wr_opcode)(0) // Use 0 as "default" opcode when NOP is not defined. +#define VMA_IBV_WR_NOP (ibv_wr_opcode)(0) // Use 0 as "default" opcode when NOP is not defined. #endif -#define vma_ibv_post_send(qp, wr, bad_wr) ibv_post_send(qp, wr, bad_wr) -typedef struct ibv_send_wr vma_ibv_send_wr; -//ibv_reg_mr -#define VMA_IBV_ACCESS_LOCAL_WRITE IBV_ACCESS_LOCAL_WRITE -#ifdef DEFINED_IBV_ACCESS_ALLOCATE_MR -#define VMA_IBV_ACCESS_ALLOCATE_MR IBV_ACCESS_ALLOCATE_MR -#endif -//flow steering -#define VMA_IBV_FLOW_ATTR_NORMAL IBV_FLOW_ATTR_NORMAL -#define VMA_IBV_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK IBV_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK -#ifdef DEFINED_IBV_FLOW_SPEC_IB -#define VMA_IBV_FLOW_SPEC_IB IBV_FLOW_SPEC_IB -#endif -#define VMA_IBV_FLOW_SPEC_ETH IBV_FLOW_SPEC_ETH -#define VMA_IBV_FLOW_SPEC_IPV4 IBV_FLOW_SPEC_IPV4 -#define VMA_IBV_FLOW_SPEC_TCP IBV_FLOW_SPEC_TCP -#define VMA_IBV_FLOW_SPEC_UDP IBV_FLOW_SPEC_UDP -#define vma_ibv_create_flow(qp, flow) ibv_create_flow(qp, flow) -#define vma_ibv_destroy_flow(flow_id) ibv_destroy_flow(flow_id) -typedef struct ibv_flow vma_ibv_flow; -typedef struct ibv_flow_attr vma_ibv_flow_attr; -typedef struct ibv_flow_spec_ib vma_ibv_flow_spec_ib; -typedef struct ibv_flow_spec_eth vma_ibv_flow_spec_eth; -typedef struct ibv_flow_spec_ipv4 vma_ibv_flow_spec_ipv4; -typedef struct ibv_flow_spec_tcp_udp vma_ibv_flow_spec_tcp_udp; +typedef struct ibv_flow vma_ibv_flow; +typedef struct ibv_flow_attr vma_ibv_flow_attr; // Flow tag #ifdef DEFINED_IBV_FLOW_TAG -#define VMA_IBV_FLOW_SPEC_ACTION_TAG IBV_FLOW_SPEC_ACTION_TAG typedef struct ibv_flow_spec_action_tag vma_ibv_flow_spec_action_tag; #define vma_get_flow_tag(cqe) ntohl((uint32_t)(cqe->sop_drop_qpn)) #else @@ -257,30 +136,16 @@ typedef struct ibv_flow_spec_action_tag_dummy {} vma_ibv_flow_spec_action_tag; #endif // DEFINED_IBV_FLOW_TAG #ifdef DEFINED_IBV_CQ_ATTR_MODERATE -typedef struct ibv_modify_cq_attr vma_ibv_cq_attr; -#define vma_ibv_modify_cq(cq, cq_attr, mask) ibv_modify_cq(cq, cq_attr) #define vma_cq_attr_mask(cq_attr) (cq_attr).attr_mask #define vma_cq_attr_moderation(cq_attr) (cq_attr).moderate -#define VMA_IBV_CQ_MODERATION IBV_CQ_ATTR_MODERATE #endif -// Clock info -#ifdef DEFINED_IBV_CLOCK_INFO -typedef struct mlx5dv_clock_info vma_ibv_clock_info; -#define vma_ibv_query_clock_info(ctx, clock_info) mlx5dv_get_clock_info(ctx, clock_info) -#define vma_ibv_convert_ts_to_ns(clock_info, hw_ts) mlx5dv_ts_to_ns(clock_info, hw_ts) -#endif //DEFINED_IBV_CLOCK_INFO - // ibv_dm #ifdef DEFINED_IBV_DM -#define vma_ibv_alloc_dm(ctx, attr) ibv_alloc_dm(ctx, attr) -#define vma_ibv_free_dm(dm) ibv_free_dm(dm) #define vma_ibv_reg_dm_mr(mr) ibv_reg_dm_mr((mr)->pd, (mr)->dm, 0, (mr)->length, IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_ZERO_BASED) #define vma_ibv_memcpy_dm(dm, attr) ibv_memcpy_to_dm(dm, (attr)->dm_offset, (attr)->host_addr, (attr)->length) #define vma_ibv_init_memcpy_dm(attr, src, head, size) { attr.host_addr = src; attr.dm_offset = head; attr.length = size; } #define vma_ibv_init_dm_mr(in_mr, ctx_pd, size, allocated_dm) { in_mr.pd = ctx_pd; in_mr.length = size; in_mr.dm = allocated_dm; } -typedef struct ibv_alloc_dm_attr vma_ibv_alloc_dm_attr; -typedef struct ibv_dm vma_ibv_dm; typedef struct { void * host_addr; uint64_t dm_offset; @@ -288,13 +153,12 @@ typedef struct { } vma_ibv_memcpy_dm_attr; typedef struct { struct ibv_pd *pd; - size_t length; - vma_ibv_dm *dm; + size_t length; + ibv_dm *dm; } vma_ibv_reg_mr_in; #endif #ifdef DEFINED_IBV_PACKET_PACING_CAPS -#define VMA_IBV_QP_RATE_LIMIT IBV_QP_RATE_LIMIT #define vma_is_pacing_caps_supported(attr) (attr->packet_pacing_caps.qp_rate_limit_min) #ifdef DEFINED_IBV_QP_SUPPORT_BURST @@ -303,217 +167,13 @@ typedef struct ibv_qp_rate_limit_attr vma_ibv_rate_limit_attr; #define vma_ibv_modify_qp_rate_limit(qp, attr, mask) ibv_modify_qp_rate_limit(qp, attr) #define vma_ibv_init_qps_attr(qp_attr) { NOT_IN_USE(qp_attr); } #else -typedef vma_ibv_qp_attr vma_ibv_rate_limit_attr; -#define vma_ibv_modify_qp_rate_limit(qp, attr, mask) vma_ibv_modify_qp(qp, attr, mask) +typedef ibv_qp_attr vma_ibv_rate_limit_attr; +#define vma_ibv_modify_qp_rate_limit(qp, attr, mask) ibv_modify_qp(qp, attr, mask) #define vma_ibv_init_qps_attr(qp_attr) { qp_attr.qp_state = IBV_QPS_RTS; } #endif // DEFINED_IBV_QP_SUPPORT_BURST #endif // DEFINED_IBV_PACKET_PACING_CAPS -#else /* DEFINED_VERBS_VERSION */ - -//ibv_create_qp -#define vma_ibv_create_qp(pd, attr) ibv_exp_create_qp((pd)->context, attr) -typedef struct ibv_exp_qp_init_attr vma_ibv_qp_init_attr; -#define vma_ibv_qp_init_attr_comp_mask(_pd, _attr) { (_attr).pd = _pd; (_attr).comp_mask |= IBV_EXP_QP_INIT_ATTR_PD; } - -#ifdef DEFINED_IBV_QP_INIT_SOURCE_QPN -#define vma_ibv_qp_create_flags(attr) (attr).exp_create_flags -#define vma_ibv_qp_source_qpn(attr) (attr).associated_qpn -#define VMA_IBV_QP_INIT_QPN_CREATE_FLAGS 0 -#define VMA_IBV_QP_INIT_QPN_MASK IBV_EXP_QP_INIT_ATTR_ASSOCIATED_QPN -#endif - -//ibv_query_device -#define vma_ibv_query_device(context, attr) ibv_exp_query_device(context, attr) -typedef struct ibv_exp_device_attr vma_ibv_device_attr; -typedef vma_ibv_device_attr vma_ibv_device_attr_ex; -#define vma_get_device_orig_attr(device_attr) device_attr -#define vma_ibv_device_attr_comp_mask(attr) { (attr)->comp_mask = IBV_EXP_DEVICE_ATTR_RESERVED - 1; } - -#ifdef DEFINED_IBV_EXP_DEVICE_RX_CSUM_L4_PKT -#define vma_is_rx_hw_csum_supported(attr) (((attr)->exp_device_cap_flags & IBV_EXP_DEVICE_RX_CSUM_L3_PKT) \ - && ((attr)->exp_device_cap_flags & IBV_EXP_DEVICE_RX_CSUM_L4_PKT)) -#else -#ifdef DEFINED_IBV_EXP_DEVICE_RX_CSUM_TCP_UDP_PKT -#define vma_is_rx_hw_csum_supported(attr) (((attr)->exp_device_cap_flags & IBV_EXP_DEVICE_RX_CSUM_IP_PKT) \ - && ((attr)->exp_device_cap_flags & IBV_EXP_DEVICE_RX_CSUM_TCP_UDP_PKT)) -#else -#define vma_is_rx_hw_csum_supported(attr) 0 -#endif -#endif -//ibv_modify_qp -#define vma_ibv_modify_qp(qp, attr, mask) ibv_exp_modify_qp(qp, attr, mask) -typedef struct ibv_exp_qp_attr vma_ibv_qp_attr; - -//ibv_exp_poll_cq -#ifdef DEFINED_IBV_EXP_CQ -#define vma_ibv_poll_cq(cq, num, wc) ibv_exp_poll_cq(cq, num, wc, sizeof(struct ibv_exp_wc)) -typedef struct ibv_exp_wc vma_ibv_wc; -#define vma_wc_flags(wc) (wc).exp_wc_flags -#define vma_wc_opcode(wc) (wc).exp_opcode -#define VMA_IBV_WC_RECV IBV_EXP_WC_RECV - -//experimental cq -typedef struct ibv_exp_cq_init_attr vma_ibv_cq_init_attr; -#define vma_ibv_create_cq(context, cqe, cq_context, channel, comp_vector, attr) ibv_exp_create_cq(context, cqe, cq_context, channel, comp_vector, attr) -#else -//ibv_poll_cq -#define vma_ibv_poll_cq(cq, num, wc) ibv_poll_cq(cq, num, wc) -typedef struct ibv_wc vma_ibv_wc; -#define vma_wc_flags(wc) (wc).wc_flags -#define vma_wc_opcode(wc) (wc).opcode -#define VMA_IBV_WC_RECV IBV_WC_RECV - -//verbs cq -typedef int vma_ibv_cq_init_attr; -#define vma_ibv_create_cq(context, cqe, cq_context, channel, comp_vector, attr) ibv_create_cq(context, cqe, cq_context, channel, comp_vector) -#endif - -#ifdef DEFINED_IBV_EXP_DEVICE_RX_CSUM_L4_PKT -#define vma_wc_rx_hw_csum_ok(wc) ((vma_wc_flags(wc) & IBV_EXP_L3_RX_CSUM_OK) && (vma_wc_flags(wc) & IBV_EXP_L4_RX_CSUM_OK)) -#else -#ifdef DEFINED_IBV_EXP_DEVICE_RX_CSUM_TCP_UDP_PKT -#define vma_wc_rx_hw_csum_ok(wc) ((vma_wc_flags(wc) & IBV_EXP_WC_RX_IP_CSUM_OK) && (vma_wc_flags(wc) & IBV_EXP_WC_RX_TCP_UDP_CSUM_OK)) -#else -#define vma_wc_rx_hw_csum_ok(wc) (1) -#endif -#endif - -//rx hw timestamp -#ifdef DEFINED_IBV_CQ_TIMESTAMP -#define VMA_IBV_WC_WITH_TIMESTAMP IBV_EXP_WC_WITH_TIMESTAMP -#define vma_wc_timestamp(wc) (wc).timestamp -#define VMA_IBV_DEVICE_ATTR_HCA_CORE_CLOCK IBV_EXP_DEVICE_ATTR_WITH_HCA_CORE_CLOCK -#define VMA_IBV_VALUES_MASK_RAW_CLOCK 0 -#define vma_ibv_query_values(ctx, values) ibv_exp_query_values(ctx, IBV_EXP_VALUES_HW_CLOCK, values) -#define vma_get_ts_val(values) values.hwclock -typedef struct ibv_exp_values vma_ts_values; -#define vma_ibv_cq_init_ts_attr(attr) { (attr)->flags |= IBV_EXP_CQ_TIMESTAMP; (attr)->comp_mask |= IBV_EXP_CQ_INIT_ATTR_FLAGS; } -#else -#define VMA_IBV_WC_WITH_TIMESTAMP 0 -#define vma_wc_timestamp(wc) 0 -#define vma_ibv_cq_init_ts_attr(attr) { NOT_IN_USE(attr); } -#endif - -#ifdef DEFINED_IBV_CQ_ATTR_MODERATE -typedef struct ibv_exp_cq_attr vma_ibv_cq_attr; -#define vma_ibv_modify_cq(cq, cq_attr, mask) ibv_exp_modify_cq(cq, cq_attr,mask) -#define vma_cq_attr_mask(cq_attr) (cq_attr).comp_mask -#define vma_cq_attr_moderation(cq_attr) (cq_attr).moderation -#define VMA_IBV_CQ_MODERATION IBV_EXP_CQ_ATTR_MODERATION -#endif - -//ibv_post_send -#define VMA_IBV_SEND_SIGNALED IBV_EXP_SEND_SIGNALED -#define VMA_IBV_SEND_INLINE IBV_EXP_SEND_INLINE -#ifdef DEFINED_IBV_EXP_SEND_IP_CSUM - #define VMA_IBV_SEND_IP_CSUM (IBV_EXP_SEND_IP_CSUM) -#else - #define DEFINED_SW_CSUM -#endif -#define vma_ibv_send_flags ibv_exp_send_flags -#define vma_send_wr_send_flags(wr) (wr).exp_send_flags -#define VMA_IBV_WR_SEND IBV_EXP_WR_SEND -#define vma_ibv_wr_opcode ibv_exp_wr_opcode -#define vma_send_wr_opcode(wr) (wr).exp_opcode - -#ifdef DEFINED_TSO - #define VMA_IBV_WR_TSO (vma_ibv_wr_opcode)IBV_EXP_WR_TSO - #define vma_check_dev_attr_tso(_attr) ((_attr)->comp_mask & IBV_EXP_DEVICE_ATTR_TSO_CAPS) - #define vma_get_tso_caps(_attr) (((vma_ibv_device_attr_ex *)(_attr))->tso_caps) - #define vma_ibv_qp_init_attr_tso(_attr, _max_tso_header) \ - do { \ - _attr.comp_mask |= IBV_EXP_QP_INIT_ATTR_MAX_TSO_HEADER; \ - _attr.max_tso_header = _max_tso_header; \ - } while (0) - typedef struct ibv_exp_tso_caps vma_ibv_tso_caps; -#else - #define VMA_IBV_WR_TSO (vma_ibv_wr_opcode)VMA_IBV_WR_SEND - #define vma_check_dev_attr_tso(_attr) 0 - #define vma_ibv_qp_init_attr_tso(_attr, _max_tso_header) ((void)0) -#endif /* DEFINED_TSO */ - -// Dummy send -#ifdef DEFINED_IBV_WR_NOP -#define vma_is_nop_supported(device_attr) ((device_attr)->exp_device_cap_flags & IBV_EXP_DEVICE_NOP) -#define VMA_IBV_WR_NOP IBV_EXP_WR_NOP -#else -#define vma_is_nop_supported(device_attr) 0 -#define VMA_IBV_WR_NOP (vma_ibv_wr_opcode)(0) // Use 0 as "default" opcode when NOP is not defined. -#endif - -#define vma_ibv_post_send(qp, wr, bad_wr) ibv_exp_post_send(qp, wr, bad_wr) -typedef struct ibv_exp_send_wr vma_ibv_send_wr; -//ibv_reg_mr -#define VMA_IBV_ACCESS_LOCAL_WRITE IBV_EXP_ACCESS_LOCAL_WRITE -#ifdef DEFINED_IBV_EXP_ACCESS_ALLOCATE_MR -#define VMA_IBV_ACCESS_ALLOCATE_MR IBV_EXP_ACCESS_ALLOCATE_MR -#endif -//flow steering -#define VMA_IBV_FLOW_ATTR_NORMAL IBV_EXP_FLOW_ATTR_NORMAL -#define VMA_IBV_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK IBV_EXP_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK -#ifdef DEFINED_IBV_FLOW_SPEC_IB -#define VMA_IBV_FLOW_SPEC_IB IBV_EXP_FLOW_SPEC_IB -#endif -#define VMA_IBV_FLOW_SPEC_ETH IBV_EXP_FLOW_SPEC_ETH -#define VMA_IBV_FLOW_SPEC_IPV4 IBV_EXP_FLOW_SPEC_IPV4 -#define VMA_IBV_FLOW_SPEC_TCP IBV_EXP_FLOW_SPEC_TCP -#define VMA_IBV_FLOW_SPEC_UDP IBV_EXP_FLOW_SPEC_UDP -#define vma_ibv_create_flow(qp, flow) ibv_exp_create_flow(qp, flow) -#define vma_ibv_destroy_flow(flow_id) ibv_exp_destroy_flow(flow_id) -typedef struct ibv_exp_flow vma_ibv_flow; -typedef struct ibv_exp_flow_attr vma_ibv_flow_attr; -typedef struct ibv_exp_flow_spec_ib vma_ibv_flow_spec_ib; -typedef struct ibv_exp_flow_spec_eth vma_ibv_flow_spec_eth; -typedef struct ibv_exp_flow_spec_ipv4 vma_ibv_flow_spec_ipv4; -typedef struct ibv_exp_flow_spec_tcp_udp vma_ibv_flow_spec_tcp_udp; - -//Flow tag -#ifdef DEFINED_IBV_FLOW_TAG -#define VMA_IBV_FLOW_SPEC_ACTION_TAG IBV_EXP_FLOW_SPEC_ACTION_TAG -#define vma_get_flow_tag(cqe) ntohl((uint32_t)(cqe->sop_drop_qpn)) -typedef struct ibv_exp_flow_spec_action_tag vma_ibv_flow_spec_action_tag; -#else -#define vma_get_flow_tag(cqe) 0 -typedef struct ibv_exp_flow_spec_action_tag_dummy {} vma_ibv_flow_spec_action_tag; -#endif //DEFINED_IBV_FLOW_TAG - -// Clock info -#ifdef DEFINED_IBV_CLOCK_INFO -typedef struct ibv_exp_values vma_ibv_clock_info; -#define vma_ibv_convert_ts_to_ns(info, hw_ts) ibv_exp_cqe_ts_to_ns(&((info)->clock_info), hw_ts) -#define vma_ibv_query_clock_info(ctx, clock_info) ibv_exp_query_values(ctx, IBV_EXP_VALUES_CLOCK_INFO, clock_info) -#endif //DEFINED_IBV_CLOCK_INFO - -// ibv_dm -#ifdef DEFINED_IBV_DM -#define vma_ibv_alloc_dm(ctx, attr) ibv_exp_alloc_dm(ctx, attr) -#define vma_ibv_free_dm(dm) ibv_exp_free_dm(dm) -#define vma_ibv_reg_dm_mr(mr) ibv_exp_reg_mr(mr) -#define vma_ibv_memcpy_dm(dm, attr) ibv_exp_memcpy_dm(dm, attr) -#define vma_ibv_init_memcpy_dm(attr, src, head, size) { attr.memcpy_dir = IBV_EXP_DM_CPY_TO_DEVICE; attr.host_addr = src; attr.dm_offset = head; attr.length = size; } -#define vma_ibv_init_dm_mr(in_mr, ctx_pd, size, allocated_dm) { in_mr.pd = ctx_pd; in_mr.comp_mask = IBV_EXP_REG_MR_DM; in_mr.length = size; in_mr.dm = allocated_dm; } -typedef struct ibv_exp_alloc_dm_attr vma_ibv_alloc_dm_attr; -typedef struct ibv_exp_memcpy_dm_attr vma_ibv_memcpy_dm_attr; -typedef struct ibv_exp_dm vma_ibv_dm; -typedef struct ibv_exp_reg_mr_in vma_ibv_reg_mr_in; -#endif - -#ifdef DEFINED_IBV_PACKET_PACING_CAPS -#define VMA_IBV_QP_RATE_LIMIT IBV_EXP_QP_RATE_LIMIT -#define vma_is_pacing_caps_supported(attr) ((attr)->comp_mask & IBV_EXP_DEVICE_ATTR_PACKET_PACING_CAPS) -typedef vma_ibv_qp_attr vma_ibv_rate_limit_attr; -#define vma_ibv_modify_qp_rate_limit(qp, attr, mask) vma_ibv_modify_qp(qp, attr, mask) -#define vma_ibv_init_qps_attr(qp_attr) { qp_attr.qp_state = IBV_QPS_RTS; } -#endif // DEFINED_IBV_PACKET_PACING_CAPS - -#ifdef DEFINED_IBV_QP_SUPPORT_BURST -#define vma_ibv_init_burst_attr(qp_attr, rate_limit) { qp_attr.burst_info.max_burst_sz = rate_limit.max_burst_sz; qp_attr.burst_info.typical_pkt_sz = rate_limit.typical_pkt_sz; qp_attr.comp_mask |= IBV_EXP_QP_ATTR_BURST_INFO; } -#endif // DEFINED_IBV_QP_SUPPORT_BURST - -#endif /* DEFINED_VERBS_VERSION */ - // ibv_dm #ifdef DEFINED_IBV_DM #define vma_ibv_dm_size(attr) ((attr)->max_dm_size) @@ -521,12 +181,6 @@ typedef vma_ibv_qp_attr vma_ibv_rate_limit_attr; #define vma_ibv_dm_size(attr) (0) #endif -#if defined(HAVE_IBV_EXP_GET_DEVICE_LIST) -#define vma_ibv_get_device_list(num) ibv_exp_get_device_list(num) -#else -#define vma_ibv_get_device_list(num) ibv_get_device_list(num) -#endif - typedef enum { RL_RATE = 1<<0, RL_BURST_SIZE = 1<<1, @@ -535,31 +189,10 @@ typedef enum { int vma_rdma_lib_reset(); -#ifdef DEFINED_IBV_FLOW_SPEC_IB -static inline void ibv_flow_spec_ib_set_by_dst_gid(vma_ibv_flow_spec_ib* ib, uint8_t* dst_gid) -{ - ib->type = VMA_IBV_FLOW_SPEC_IB; - ib->size = sizeof(vma_ibv_flow_spec_ib); - if (dst_gid) - { - memcpy(ib->val.dst_gid, dst_gid, 16); - memset(ib->mask.dst_gid, FS_MASK_ON_8, 16); - } -} - -static inline void ibv_flow_spec_ib_set_by_dst_qpn(vma_ibv_flow_spec_ib* ib, uint32_t dst_qpn) -{ - ib->type = VMA_IBV_FLOW_SPEC_IB; - ib->size = sizeof(vma_ibv_flow_spec_ib); - ib->val.qpn = dst_qpn; - ib->mask.qpn = FS_MASK_ON_32; -} -#endif - -static inline void ibv_flow_spec_eth_set(vma_ibv_flow_spec_eth* eth, uint8_t* dst_mac, uint16_t vlan_tag) +static inline void ibv_flow_spec_eth_set(ibv_flow_spec_eth* eth, uint8_t* dst_mac, uint16_t vlan_tag) { - eth->type = VMA_IBV_FLOW_SPEC_ETH; - eth->size = sizeof(vma_ibv_flow_spec_eth); + eth->type = IBV_FLOW_SPEC_ETH; + eth->size = sizeof(ibv_flow_spec_eth); eth->val.ether_type = ntohs(ETH_P_IP); eth->mask.ether_type = FS_MASK_ON_16; memcpy(eth->val.dst_mac, dst_mac, ETH_ALEN); @@ -568,20 +201,20 @@ static inline void ibv_flow_spec_eth_set(vma_ibv_flow_spec_eth* eth, uint8_t* ds eth->mask.vlan_tag = eth->val.vlan_tag ? htons(VLAN_VID_MASK) : 0; //we do not support vlan options } -static inline void ibv_flow_spec_ipv4_set(vma_ibv_flow_spec_ipv4* ipv4, uint32_t dst_ip, uint32_t src_ip) +static inline void ibv_flow_spec_ipv4_set(ibv_flow_spec_ipv4* ipv4, uint32_t dst_ip, uint32_t src_ip) { - ipv4->type = VMA_IBV_FLOW_SPEC_IPV4; - ipv4->size = sizeof(vma_ibv_flow_spec_ipv4); + ipv4->type = IBV_FLOW_SPEC_IPV4; + ipv4->size = sizeof(ibv_flow_spec_ipv4); ipv4->val.src_ip = src_ip; if (ipv4->val.src_ip) ipv4->mask.src_ip = FS_MASK_ON_32; ipv4->val.dst_ip = dst_ip; if (ipv4->val.dst_ip) ipv4->mask.dst_ip = FS_MASK_ON_32; } -static inline void ibv_flow_spec_tcp_udp_set(vma_ibv_flow_spec_tcp_udp* tcp_udp, bool is_tcp, uint16_t dst_port, uint16_t src_port) +static inline void ibv_flow_spec_tcp_udp_set(ibv_flow_spec_tcp_udp* tcp_udp, bool is_tcp, uint16_t dst_port, uint16_t src_port) { - tcp_udp->type = is_tcp ? VMA_IBV_FLOW_SPEC_TCP : VMA_IBV_FLOW_SPEC_UDP; - tcp_udp->size = sizeof(vma_ibv_flow_spec_tcp_udp); + tcp_udp->type = is_tcp ? IBV_FLOW_SPEC_TCP : IBV_FLOW_SPEC_UDP; + tcp_udp->size = sizeof(ibv_flow_spec_tcp_udp); tcp_udp->val.src_port = src_port; if(tcp_udp->val.src_port) tcp_udp->mask.src_port = FS_MASK_ON_16; tcp_udp->val.dst_port = dst_port; @@ -594,25 +227,10 @@ static inline void ibv_flow_spec_flow_tag_set(vma_ibv_flow_spec_action_tag* flow if (flow_tag == NULL) return; #ifdef DEFINED_IBV_FLOW_TAG - flow_tag->type = VMA_IBV_FLOW_SPEC_ACTION_TAG; + flow_tag->type = IBV_FLOW_SPEC_ACTION_TAG; flow_tag->size = sizeof(vma_ibv_flow_spec_action_tag); flow_tag->tag_id = tag_id; #endif //DEFINED_IBV_FLOW_TAG } - -static inline void ibv_source_qpn_set(vma_ibv_qp_init_attr& qp_init_attr, uint32_t source_qpn) -{ - NOT_IN_USE(qp_init_attr); - NOT_IN_USE(source_qpn); - -#ifdef DEFINED_IBV_QP_INIT_SOURCE_QPN - if (source_qpn) { - qp_init_attr.comp_mask |= VMA_IBV_QP_INIT_QPN_MASK; - vma_ibv_qp_create_flags(qp_init_attr) |= VMA_IBV_QP_INIT_QPN_CREATE_FLAGS; - vma_ibv_qp_source_qpn(qp_init_attr) = source_qpn; - } -#endif /* DEFINED_IBV_QP_INIT_SOURCE_QPN */ -} - #endif diff --git a/src/vma/ib/mlx5/ib_mlx5.cpp b/src/vma/ib/mlx5/ib_mlx5.cpp index d8431a9e98..647b8c41e6 100644 --- a/src/vma/ib/mlx5/ib_mlx5.cpp +++ b/src/vma/ib/mlx5/ib_mlx5.cpp @@ -1,46 +1,17 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "util/valgrind.h" -#if defined(DEFINED_DIRECT_VERBS) - #include "vma/util/valgrind.h" #include "vma/util/utils.h" #include "vma/ib/mlx5/ib_mlx5.h" - int vma_ib_mlx5_get_qp(struct ibv_qp *qp, vma_ib_mlx5_qp_t *mlx5_qp, uint32_t flags) { int ret = 0; @@ -55,7 +26,7 @@ int vma_ib_mlx5_get_qp(struct ibv_qp *qp, vma_ib_mlx5_qp_t *mlx5_qp, uint32_t fl obj.qp.in = qp; obj.qp.out = &dqp; - ret = vma_ib_mlx5dv_init_obj(&obj, MLX5DV_OBJ_QP); + ret = mlx5dv_init_obj(&obj, MLX5DV_OBJ_QP); if (ret != 0) { goto out; } @@ -63,6 +34,7 @@ int vma_ib_mlx5_get_qp(struct ibv_qp *qp, vma_ib_mlx5_qp_t *mlx5_qp, uint32_t fl mlx5_qp->qp = qp; mlx5_qp->qpn = qp->qp_num; mlx5_qp->flags = flags; + /* coverity[var_deref_op] */ mlx5_qp->sq.dbrec = &dqp.dbrec[MLX5_SND_DBR]; mlx5_qp->sq.buf = dqp.sq.buf; mlx5_qp->sq.wqe_cnt = dqp.sq.wqe_cnt; @@ -116,7 +88,7 @@ int vma_ib_mlx5_get_cq(struct ibv_cq *cq, vma_ib_mlx5_cq_t *mlx5_cq) obj.cq.in = cq; obj.cq.out = &dcq; - ret = vma_ib_mlx5dv_init_obj(&obj, MLX5DV_OBJ_CQ); + ret = mlx5dv_init_obj(&obj, MLX5DV_OBJ_CQ); if (ret != 0) { return ret; } @@ -212,4 +184,37 @@ int vma_ib_mlx5_post_recv(vma_ib_mlx5_qp_t *mlx5_qp, return err; } -#endif /* DEFINED_DIRECT_VERBS */ +int vma_ib_mlx5_req_notify_cq(vma_ib_mlx5_cq_t *mlx5_cq, int solicited) +{ + uint64_t doorbell; + uint32_t sn; + uint32_t ci; + uint32_t cmd; + + sn = mlx5_cq->cq_sn & 3; + ci = mlx5_cq->cq_ci & 0xffffff; + cmd = solicited ? MLX5_CQ_DB_REQ_NOT_SOL : MLX5_CQ_DB_REQ_NOT; + + doorbell = sn << 28 | cmd | ci; + doorbell <<= 32; + doorbell |= mlx5_cq->cq_num; + + mlx5_cq->dbrec[VMA_IB_MLX5_CQ_ARM_DB] = htonl(sn << 28 | cmd | ci); + + /* + * Make sure that the doorbell record in host memory is + * written before ringing the doorbell via PCI WC MMIO. + */ + wmb(); + + *(uint64_t *)((uint8_t *)mlx5_cq->uar + MLX5_CQ_DOORBELL) = htonll(doorbell); + + wc_wmb(); + + return 0; +} + +void vma_ib_mlx5_get_cq_event(vma_ib_mlx5_cq_t *mlx5_cq, int count) +{ + mlx5_cq->cq_sn += count; +} diff --git a/src/vma/ib/mlx5/ib_mlx5.h b/src/vma/ib/mlx5/ib_mlx5.h index 1888d324b6..26574d6da2 100644 --- a/src/vma/ib/mlx5/ib_mlx5.h +++ b/src/vma/ib/mlx5/ib_mlx5.h @@ -1,54 +1,16 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef SRC_VMA_IB_MLX5_H_ #define SRC_VMA_IB_MLX5_H_ -#if defined(DEFINED_DIRECT_VERBS) - #include - -#if (DEFINED_DIRECT_VERBS == 2) -#include -#include "vma/ib/mlx5/ib_mlx5_hw.h" -#elif (DEFINED_DIRECT_VERBS == 3) extern "C" { #include } -#include "vma/ib/mlx5/ib_mlx5_dv.h" -#else -#error "Unsupported Direct VERBS parameter" -#endif - #include #include @@ -60,12 +22,6 @@ extern "C" { * inside this layer */ - -/** - * Get internal verbs information. - */ -int vma_ib_mlx5dv_init_obj(struct mlx5dv_obj *obj, uint64_t type); - enum { VMA_IB_MLX5_QP_FLAGS_USE_UNDERLAY = 0x01 }; @@ -76,7 +32,7 @@ enum { }; /* Queue pair */ -typedef struct vma_ib_mlx5_qp { +struct vma_ib_mlx5_qp_t { struct ibv_qp *qp; uint32_t qpn; uint32_t flags; @@ -101,10 +57,10 @@ typedef struct vma_ib_mlx5_qp { uint32_t size; uint32_t offset; } bf; -} vma_ib_mlx5_qp_t; +}; /* Completion queue */ -typedef struct vma_ib_mlx5_cq { +struct vma_ib_mlx5_cq_t { struct ibv_cq *cq; void *cq_buf; unsigned cq_num; @@ -115,7 +71,7 @@ typedef struct vma_ib_mlx5_cq { unsigned cqe_size_log; volatile uint32_t *dbrec; void *uar; -} vma_ib_mlx5_cq_t; +}; int vma_ib_mlx5_get_qp(struct ibv_qp *qp, vma_ib_mlx5_qp_t *mlx5_qp, uint32_t flags = 0); int vma_ib_mlx5_post_recv(vma_ib_mlx5_qp_t *mlx5_qp, struct ibv_recv_wr *wr, struct ibv_recv_wr **bad_wr); @@ -124,6 +80,4 @@ int vma_ib_mlx5_get_cq(struct ibv_cq *cq, vma_ib_mlx5_cq_t *mlx5_cq); int vma_ib_mlx5_req_notify_cq(vma_ib_mlx5_cq_t *mlx5_cq, int solicited); void vma_ib_mlx5_get_cq_event(vma_ib_mlx5_cq_t *mlx5_cq, int count); -#endif /* DEFINED_DIRECT_VERBS */ - #endif /* SRC_VMA_IB_MLX5_H_ */ diff --git a/src/vma/ib/mlx5/ib_mlx5_dv.cpp b/src/vma/ib/mlx5/ib_mlx5_dv.cpp deleted file mode 100644 index 36a279fa99..0000000000 --- a/src/vma/ib/mlx5/ib_mlx5_dv.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#if defined(DEFINED_DIRECT_VERBS) && (DEFINED_DIRECT_VERBS == 3) - -#include "vma/ib/mlx5/ib_mlx5.h" - -int vma_ib_mlx5dv_init_obj(struct mlx5dv_obj *obj, uint64_t type) -{ - int ret = 0; - - ret = mlx5dv_init_obj(obj, type); - - return ret; -} - -int vma_ib_mlx5_req_notify_cq(vma_ib_mlx5_cq_t *mlx5_cq, int solicited) -{ - uint64_t doorbell; - uint32_t sn; - uint32_t ci; - uint32_t cmd; - - sn = mlx5_cq->cq_sn & 3; - ci = mlx5_cq->cq_ci & 0xffffff; - cmd = solicited ? MLX5_CQ_DB_REQ_NOT_SOL : MLX5_CQ_DB_REQ_NOT; - - doorbell = sn << 28 | cmd | ci; - doorbell <<= 32; - doorbell |= mlx5_cq->cq_num; - - mlx5_cq->dbrec[VMA_IB_MLX5_CQ_ARM_DB] = htonl(sn << 28 | cmd | ci); - - /* - * Make sure that the doorbell record in host memory is - * written before ringing the doorbell via PCI WC MMIO. - */ - wmb(); - - *(uint64_t *)((uint8_t *)mlx5_cq->uar + MLX5_CQ_DOORBELL) = htonll(doorbell); - - wc_wmb(); - - return 0; -} - -void vma_ib_mlx5_get_cq_event(vma_ib_mlx5_cq_t *mlx5_cq, int count) -{ - mlx5_cq->cq_sn += count; -} - -#endif /* (DEFINED_DIRECT_VERBS == 3) */ diff --git a/src/vma/ib/mlx5/ib_mlx5_dv.h b/src/vma/ib/mlx5/ib_mlx5_dv.h deleted file mode 100644 index 0209e51510..0000000000 --- a/src/vma/ib/mlx5/ib_mlx5_dv.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef SRC_VMA_IB_MLX5_DV_H_ -#define SRC_VMA_IB_MLX5_DV_H_ - -#ifndef SRC_VMA_IB_MLX5_H_ -#error "Use instead." -#endif - -#if defined(DEFINED_DIRECT_VERBS) && (DEFINED_DIRECT_VERBS == 3) - -#endif /* (DEFINED_DIRECT_VERBS == 3) */ - -#endif /* SRC_VMA_IB_MLX5_DV_H_ */ diff --git a/src/vma/ib/mlx5/ib_mlx5_hw.cpp b/src/vma/ib/mlx5/ib_mlx5_hw.cpp deleted file mode 100644 index 05122b797a..0000000000 --- a/src/vma/ib/mlx5/ib_mlx5_hw.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include "util/valgrind.h" -#if defined(DEFINED_DIRECT_VERBS) && (DEFINED_DIRECT_VERBS == 2) - -#include "vma/ib/mlx5/ib_mlx5.h" - -static int vma_ib_mlx5dv_get_qp(struct ibv_qp *qp, struct mlx5dv_qp *mlx5_qp); -static int vma_ib_mlx5dv_get_cq(struct ibv_cq *cq, struct mlx5dv_cq *mlx5_cq); - - -int vma_ib_mlx5dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type) -{ - int ret = 0; - - if (obj_type & MLX5DV_OBJ_QP) { - ret = vma_ib_mlx5dv_get_qp(obj->qp.in, obj->qp.out); - } - - if (!ret && (obj_type & MLX5DV_OBJ_CQ)) { - ret = vma_ib_mlx5dv_get_cq(obj->cq.in, obj->cq.out); - } - - return ret; -} - -static int vma_ib_mlx5dv_get_qp(struct ibv_qp *qp, struct mlx5dv_qp *mlx5_qp) -{ - int ret = 0; - struct ibv_mlx5_qp_info ibv_qp_info; - struct mlx5_qp *mqp = to_mqp(qp); - - ret = ibv_mlx5_exp_get_qp_info(qp, &ibv_qp_info); - if (ret != 0) { - return ret; - } - VALGRIND_MAKE_MEM_DEFINED(&ibv_qp_info, sizeof(ibv_qp_info)); - mlx5_qp->dbrec = ibv_qp_info.dbrec; - mlx5_qp->sq.buf = (mqp->sq_buf_size ? - (void *)((uintptr_t)mqp->sq_buf.buf) : /* IBV_QPT_RAW_PACKET or Underly QP */ - (void *)((uintptr_t)mqp->buf.buf + mqp->sq.offset)); - mlx5_qp->sq.wqe_cnt = ibv_qp_info.sq.wqe_cnt; - mlx5_qp->sq.stride = ibv_qp_info.sq.stride; - mlx5_qp->rq.buf = ibv_qp_info.rq.buf; - mlx5_qp->rq.wqe_cnt = ibv_qp_info.rq.wqe_cnt; - mlx5_qp->rq.stride = ibv_qp_info.rq.stride; - mlx5_qp->bf.reg = ibv_qp_info.bf.reg; - mlx5_qp->bf.size = ibv_qp_info.bf.size; - - return ret; -} - -static int vma_ib_mlx5dv_get_cq(struct ibv_cq *cq, struct mlx5dv_cq *mlx5_cq) -{ - int ret = 0; - struct ibv_mlx5_cq_info ibv_cq_info; - - ret = ibv_mlx5_exp_get_cq_info(cq, &ibv_cq_info); - if (ret != 0) { - return ret; - } - VALGRIND_MAKE_MEM_DEFINED(&ibv_cq_info, sizeof(ibv_cq_info)); - mlx5_cq->buf = ibv_cq_info.buf; - mlx5_cq->dbrec = ibv_cq_info.dbrec; - mlx5_cq->cqe_cnt = ibv_cq_info.cqe_cnt; - mlx5_cq->cqe_size = ibv_cq_info.cqe_size; - mlx5_cq->cq_uar = NULL; - mlx5_cq->cqn = ibv_cq_info.cqn; - - return ret; -} - -int vma_ib_mlx5_req_notify_cq(vma_ib_mlx5_cq_t *mlx5_cq, int solicited) -{ - struct mlx5_cq *mcq = to_mcq(mlx5_cq->cq); - mcq->cons_index = mlx5_cq->cq_ci; - return ibv_req_notify_cq(mlx5_cq->cq, solicited); -} - -void vma_ib_mlx5_get_cq_event(vma_ib_mlx5_cq_t *, int) -{ - // no need in operation with cq_sn as far as it is managed by driver code for now -} - -#endif /* (DEFINED_DIRECT_VERBS == 2) */ diff --git a/src/vma/ib/mlx5/ib_mlx5_hw.h b/src/vma/ib/mlx5/ib_mlx5_hw.h deleted file mode 100644 index e5aec9c671..0000000000 --- a/src/vma/ib/mlx5/ib_mlx5_hw.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef SRC_VMA_IB_MLX5_HW_H_ -#define SRC_VMA_IB_MLX5_HW_H_ - -#ifndef SRC_VMA_IB_MLX5_H_ -#error "Use instead." -#endif - -#if defined(DEFINED_DIRECT_VERBS) && (DEFINED_DIRECT_VERBS == 2) - -#include - -/* This structures duplicate mlx5dv.h (rdma-core upstream) - * to use upstream specific approach as a basis - */ -struct mlx5dv_qp { - volatile uint32_t *dbrec; - struct { - void *buf; - uint32_t wqe_cnt; - uint32_t stride; - } sq; - struct { - void *buf; - uint32_t wqe_cnt; - uint32_t stride; - } rq; - struct { - void *reg; - uint32_t size; - } bf; - uint64_t comp_mask; -}; - -struct mlx5dv_cq { - void *buf; - volatile uint32_t *dbrec; - uint32_t cqe_cnt; - uint32_t cqe_size; - void *cq_uar; - uint32_t cqn; - uint64_t comp_mask; -}; - -struct mlx5dv_obj { - struct { - struct ibv_qp *in; - struct mlx5dv_qp *out; - } qp; - struct { - struct ibv_cq *in; - struct mlx5dv_cq *out; - } cq; -}; - -enum mlx5dv_obj_type { - MLX5DV_OBJ_QP = 1 << 0, - MLX5DV_OBJ_CQ = 1 << 1, -}; - -#endif /* (DEFINED_DIRECT_VERBS == 2) */ - -#endif /* SRC_VMA_IB_MLX5_HW_H_ */ diff --git a/src/vma/infra/DemoCollMgr.cpp b/src/vma/infra/DemoCollMgr.cpp index 9ff1003659..5e52ef6c12 100644 --- a/src/vma/infra/DemoCollMgr.cpp +++ b/src/vma/infra/DemoCollMgr.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/infra/DemoCollMgr.h b/src/vma/infra/DemoCollMgr.h index 51fb4b3fce..debfc4092d 100644 --- a/src/vma/infra/DemoCollMgr.h +++ b/src/vma/infra/DemoCollMgr.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/infra/DemoObserver.cpp b/src/vma/infra/DemoObserver.cpp index a278e1ed2b..d4cd236170 100644 --- a/src/vma/infra/DemoObserver.cpp +++ b/src/vma/infra/DemoObserver.cpp @@ -1,37 +1,9 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause * * DemoObserver.cpp - * */ #include "DemoObserver.h" diff --git a/src/vma/infra/DemoObserver.h b/src/vma/infra/DemoObserver.h index fb7f9b0efc..d1c94075c7 100644 --- a/src/vma/infra/DemoObserver.h +++ b/src/vma/infra/DemoObserver.h @@ -1,37 +1,9 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause * * DemoObserver.h - * */ #ifndef DEMOOBSERVER_H_ diff --git a/src/vma/infra/DemoSubject.cpp b/src/vma/infra/DemoSubject.cpp index 8604bd25e2..488384c368 100644 --- a/src/vma/infra/DemoSubject.cpp +++ b/src/vma/infra/DemoSubject.cpp @@ -1,37 +1,9 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause * * DemoSubject.h - * */ diff --git a/src/vma/infra/DemoSubject.h b/src/vma/infra/DemoSubject.h index 9c4714831e..8b0aadbff6 100644 --- a/src/vma/infra/DemoSubject.h +++ b/src/vma/infra/DemoSubject.h @@ -1,37 +1,9 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause * * DemoSubject.h - * */ #ifndef DEMOSUBJECT_H_ diff --git a/src/vma/infra/cache_subject_observer.h b/src/vma/infra/cache_subject_observer.h index 46f0e4825f..937355f3dc 100644 --- a/src/vma/infra/cache_subject_observer.h +++ b/src/vma/infra/cache_subject_observer.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/infra/main.cpp b/src/vma/infra/main.cpp index 5a29430b91..aba2219c78 100644 --- a/src/vma/infra/main.cpp +++ b/src/vma/infra/main.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/infra/sender.cpp b/src/vma/infra/sender.cpp index 8de97444f6..a6321bff38 100644 --- a/src/vma/infra/sender.cpp +++ b/src/vma/infra/sender.cpp @@ -1,33 +1,7 @@ /* - * Copyright © 2013-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2013-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ /* diff --git a/src/vma/infra/sender.h b/src/vma/infra/sender.h index ec0dbdb089..2188d589f8 100644 --- a/src/vma/infra/sender.h +++ b/src/vma/infra/sender.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/infra/sender_info_dst.cpp b/src/vma/infra/sender_info_dst.cpp index cdea27c224..464fba7b8a 100644 --- a/src/vma/infra/sender_info_dst.cpp +++ b/src/vma/infra/sender_info_dst.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/infra/sender_info_dst.h b/src/vma/infra/sender_info_dst.h index a471178a04..e7c7e480f4 100644 --- a/src/vma/infra/sender_info_dst.h +++ b/src/vma/infra/sender_info_dst.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/infra/subject_observer.cpp b/src/vma/infra/subject_observer.cpp index e8b30a4a99..17c483c43a 100644 --- a/src/vma/infra/subject_observer.cpp +++ b/src/vma/infra/subject_observer.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/infra/subject_observer.h b/src/vma/infra/subject_observer.h index 68585f15b4..b4cdf87d88 100644 --- a/src/vma/infra/subject_observer.h +++ b/src/vma/infra/subject_observer.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/iomux/epfd_info.cpp b/src/vma/iomux/epfd_info.cpp index 40554cf2f1..ffc5ce031b 100644 --- a/src/vma/iomux/epfd_info.cpp +++ b/src/vma/iomux/epfd_info.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include @@ -600,7 +574,7 @@ int epfd_info::ring_poll_and_process_element(uint64_t *p_poll_sn, void* pv_fd_re __log_func(""); int ret_total = 0; - + // coverity[missing_lock:FALSE] /* Turn off coverity sleep while holding lock */ if (m_ring_map.empty()) { return ret_total; } @@ -637,7 +611,7 @@ int epfd_info::ring_request_notification(uint64_t poll_sn) { __log_func(""); int ret_total = 0; - + // coverity[missing_lock:FALSE] /* Turn off coverity sleep while holding lock */ if (m_ring_map.empty()) { return ret_total; } diff --git a/src/vma/iomux/epfd_info.h b/src/vma/iomux/epfd_info.h index b89cbff920..cef6c5c605 100644 --- a/src/vma/iomux/epfd_info.h +++ b/src/vma/iomux/epfd_info.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/iomux/epoll_wait_call.cpp b/src/vma/iomux/epoll_wait_call.cpp index 46a5fa9e20..020d81b5b8 100644 --- a/src/vma/iomux/epoll_wait_call.cpp +++ b/src/vma/iomux/epoll_wait_call.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/iomux/epoll_wait_call.h b/src/vma/iomux/epoll_wait_call.h index 4505053067..6a7a7af5ed 100644 --- a/src/vma/iomux/epoll_wait_call.h +++ b/src/vma/iomux/epoll_wait_call.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/iomux/io_mux_call.cpp b/src/vma/iomux/io_mux_call.cpp index 96c5a09979..39bae13d18 100644 --- a/src/vma/iomux/io_mux_call.cpp +++ b/src/vma/iomux/io_mux_call.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -170,7 +144,6 @@ io_mux_call::io_mux_call(int *off_fds_buffer, offloaded_mode_t *off_modes_buffer m_n_sysvar_select_skip_os_fd_check(safe_mce_sys().select_skip_os_fd_check), m_n_sysvar_select_poll_os_ratio(safe_mce_sys().select_poll_os_ratio), m_n_sysvar_select_poll_num(safe_mce_sys().select_poll_num), - m_b_sysvar_select_poll_os_force(safe_mce_sys().select_poll_os_force), m_b_sysvar_select_handle_cpu_usage_stats(safe_mce_sys().select_handle_cpu_usage_stats), m_p_all_offloaded_fds(off_fds_buffer), m_p_offloaded_modes(off_modes_buffer), @@ -395,6 +368,7 @@ void io_mux_call::polling_loops() } __if_dbg("2nd scenario exit (loop %d, elapsed %d)", poll_counter, m_elapsed.tv_usec); + NOT_IN_USE(poll_counter); /* to suppress warning in case VMA_MAX_DEFINED_LOG_LEVEL */ } void io_mux_call::blocking_loops() @@ -468,8 +442,7 @@ int io_mux_call::call() __log_funcall(""); - if (!m_b_sysvar_select_poll_os_force // TODO: evaluate/consider this logic - && (*m_p_num_all_offloaded_fds == 0)) + if (*m_p_num_all_offloaded_fds == 0) { // 1st scenario timer_update(); diff --git a/src/vma/iomux/io_mux_call.h b/src/vma/iomux/io_mux_call.h index 4b6f577a17..1e34140423 100644 --- a/src/vma/iomux/io_mux_call.h +++ b/src/vma/iomux/io_mux_call.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -239,7 +213,6 @@ class io_mux_call const uint32_t m_n_sysvar_select_skip_os_fd_check; const uint32_t m_n_sysvar_select_poll_os_ratio; const int32_t m_n_sysvar_select_poll_num; - const bool m_b_sysvar_select_poll_os_force; const bool m_b_sysvar_select_handle_cpu_usage_stats; public: diff --git a/src/vma/iomux/poll_call.cpp b/src/vma/iomux/poll_call.cpp index 7dada5e0f3..c15c20c537 100644 --- a/src/vma/iomux/poll_call.cpp +++ b/src/vma/iomux/poll_call.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/iomux/poll_call.h b/src/vma/iomux/poll_call.h index cd250c2263..417daa1bd7 100644 --- a/src/vma/iomux/poll_call.h +++ b/src/vma/iomux/poll_call.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/iomux/select_call.cpp b/src/vma/iomux/select_call.cpp index 22615ef618..cf62fce1f9 100644 --- a/src/vma/iomux/select_call.cpp +++ b/src/vma/iomux/select_call.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -51,12 +25,23 @@ memset(__FDS_BITS(__fddst), 0, ((__nfds) + 7) >> 3) iomux_func_stats_t g_select_stats; -select_call::select_call(int *off_fds_buffer, offloaded_mode_t *off_modes_buffer, - int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, timeval *timeout, const sigset_t *__sigmask /* = NULL */) : +select_call::select_call(int *off_fds_buffer, offloaded_mode_t *off_modes_buffer, int nfds, + fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timeval *timeout, + const sigset_t *__sigmask /* = NULL */) : io_mux_call(off_fds_buffer, off_modes_buffer, nfds, __sigmask), - m_nfds(nfds), m_readfds(readfds), m_writefds(writefds), - m_exceptfds(exceptfds), m_timeout(timeout), m_nfds_with_cq(0), m_b_run_prepare_to_poll(false) + m_nfds(nfds), + m_readfds(readfds), + m_writefds(writefds), + m_exceptfds(exceptfds), + m_timeout(timeout), + m_orig_readfds {}, + m_orig_writefds {}, + m_orig_exceptfds {}, + m_nfds_with_cq(0), + m_b_run_prepare_to_poll(false), + m_os_rfds {0}, + m_os_wfds {0}, + m_cq_rfds {0} { int fd; //socket_fd_api* temp_sock_fd_api = NULL; diff --git a/src/vma/iomux/select_call.h b/src/vma/iomux/select_call.h index 0fc2c2b2a2..e84c02cd87 100644 --- a/src/vma/iomux/select_call.h +++ b/src/vma/iomux/select_call.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/libvma.c b/src/vma/libvma.c index a91d578ff0..d48d056d88 100644 --- a/src/vma/libvma.c +++ b/src/vma/libvma.c @@ -1,49 +1,19 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ -extern int main_init(void); -extern int main_destroy(void); +extern int vma_init(void); +extern int vma_exit(void); -/* library init function ------------------------------------------------------------------------------ -__attribute__((constructor)) causes the function to be called when -library is firsrt loaded */ int __attribute__((constructor)) sock_redirect_lib_load_constructor(void) { - return main_init(); + return vma_init(); } int __attribute__((destructor)) sock_redirect_lib_load_destructor(void) { - return main_destroy(); + return vma_exit(); } diff --git a/src/vma/lwip/cc.c b/src/vma/lwip/cc.c index 343274c90c..95e373e9f3 100644 --- a/src/vma/lwip/cc.c +++ b/src/vma/lwip/cc.c @@ -49,35 +49,9 @@ */ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "vma/lwip/cc.h" diff --git a/src/vma/lwip/cc.h b/src/vma/lwip/cc.h index f3d650aa49..badcec8a71 100644 --- a/src/vma/lwip/cc.h +++ b/src/vma/lwip/cc.h @@ -49,35 +49,9 @@ */ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef CC_H_ diff --git a/src/vma/lwip/cc_cubic.c b/src/vma/lwip/cc_cubic.c index 4af31499a3..1759760b6f 100644 --- a/src/vma/lwip/cc_cubic.c +++ b/src/vma/lwip/cc_cubic.c @@ -49,35 +49,9 @@ */ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "cc_cubic.h" @@ -210,9 +184,10 @@ cubic_cb_init(struct tcp_pcb *pcb) struct cubic *cubic_data; cubic_data = malloc(sizeof(struct cubic)); - memset(cubic_data, 0, sizeof(*cubic_data)); - if (cubic_data == NULL) + if (cubic_data == NULL){ return (ENOMEM); + } + memset(cubic_data, 0, sizeof(*cubic_data)); /* Init some key variables with sensible defaults. */ cubic_data->t_last_cong = ticks; diff --git a/src/vma/lwip/cc_cubic.h b/src/vma/lwip/cc_cubic.h index f70b7ba641..38a157e654 100644 --- a/src/vma/lwip/cc_cubic.h +++ b/src/vma/lwip/cc_cubic.h @@ -48,36 +48,10 @@ * http://caia.swin.edu.au/urp/newtcp/ */ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + /* + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef CC_CUBIC_H_ diff --git a/src/vma/lwip/cc_lwip.c b/src/vma/lwip/cc_lwip.c index da4e223787..34b50cec4e 100644 --- a/src/vma/lwip/cc_lwip.c +++ b/src/vma/lwip/cc_lwip.c @@ -49,35 +49,9 @@ */ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "vma/lwip/cc.h" diff --git a/src/vma/lwip/cc_none.c b/src/vma/lwip/cc_none.c index 4f28926ffd..10d608c466 100644 --- a/src/vma/lwip/cc_none.c +++ b/src/vma/lwip/cc_none.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "vma/lwip/cc.h" diff --git a/src/vma/lwip/opt.h b/src/vma/lwip/opt.h index ebe8680410..79726d0b72 100644 --- a/src/vma/lwip/opt.h +++ b/src/vma/lwip/opt.h @@ -297,7 +297,6 @@ //#define TCP_OUTPUT_DEBUG LWIP_DBG_ON //#define TCP_RST_DEBUG LWIP_DBG_ON //#define TCP_QLEN_DEBUG LWIP_DBG_ON -//#define TCP_TSO_DEBUG LWIP_DBG_ON #endif /* @@ -721,7 +720,7 @@ * in seconds. (does not require sockets.c, and will affect tcp.c) */ #ifndef LWIP_TCP_KEEPALIVE -#define LWIP_TCP_KEEPALIVE 0 +#define LWIP_TCP_KEEPALIVE 1 #endif /* @@ -847,17 +846,6 @@ #define LWIP_CHECKSUM_ON_COPY 0 #endif -/** - * LWIP_TSO: Enable Large Segment Offload capability. - */ -#ifndef LWIP_TSO -#ifdef DEFINED_TSO -#define LWIP_TSO 1 -#else -#define LWIP_TSO 0 -#endif /* DEFINED_TSO */ -#endif - /* Define platform endianness */ #ifndef BYTE_ORDER #define BYTE_ORDER LITTLE_ENDIAN @@ -1049,16 +1037,8 @@ typedef unsigned long mem_ptr_t; #define TCP_QLEN_DEBUG LWIP_DBG_OFF #endif -/** - * TCP_TSO_DEBUG: Enable debugging for TSO. - */ -#ifndef TCP_TSO_DEBUG -#define TCP_TSO_DEBUG LWIP_DBG_OFF -#endif - #define LWIP_DEBUG_ENABLE PBUF_DEBUG | TCP_DEBUG | TCP_INPUT_DEBUG | TCP_FR_DEBUG | TCP_RTO_DEBUG \ - | TCP_CWND_DEBUG | TCP_WND_DEBUG | TCP_OUTPUT_DEBUG | TCP_RST_DEBUG | TCP_QLEN_DEBUG \ - | TCP_TSO_DEBUG + | TCP_CWND_DEBUG | TCP_WND_DEBUG | TCP_OUTPUT_DEBUG | TCP_RST_DEBUG | TCP_QLEN_DEBUG #if LWIP_DEBUG_ENABLE diff --git a/src/vma/lwip/pbuf.c b/src/vma/lwip/pbuf.c index 940ef39016..5bbba3ae12 100644 --- a/src/vma/lwip/pbuf.c +++ b/src/vma/lwip/pbuf.c @@ -87,10 +87,10 @@ * @note Despite its name, pbuf_realloc cannot grow the size of a pbuf (chain). */ void -pbuf_realloc(struct pbuf *p, u16_t new_len) +pbuf_realloc(struct pbuf *p, u32_t new_len) { struct pbuf *q; - u16_t rem_len; /* remaining length */ + u32_t rem_len; /* remaining length */ s32_t grow; LWIP_ASSERT("pbuf_realloc: p != NULL", p != NULL); @@ -117,7 +117,6 @@ pbuf_realloc(struct pbuf *p, u16_t new_len) /* decrease remaining length by pbuf length */ rem_len -= q->len; /* decrease total length indicator */ - LWIP_ASSERT("grow < max_u16_t", grow < 0xffff); q->tot_len += grow; /* proceed to next pbuf in chain */ q = q->next; @@ -166,11 +165,11 @@ pbuf_realloc(struct pbuf *p, u16_t new_len) * */ u8_t -pbuf_header(struct pbuf *p, s16_t header_size_increment) +pbuf_header(struct pbuf *p, s32_t header_size_increment) { u16_t type; + u32_t increment_magnitude; void *payload; - u16_t increment_magnitude; LWIP_ASSERT("p != NULL", p != NULL); if ((header_size_increment == 0) || (p == NULL)) { @@ -209,7 +208,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment) p->len += header_size_increment; p->tot_len += header_size_increment; - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_header: old %p new %p (%"S16_F")\n", + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_header: old %p new %p (%"S32_F")\n", (void *)payload, (void *)p->payload, header_size_increment)); (void)payload; /* Fix warning -Wunused-but-set-variable */ diff --git a/src/vma/lwip/pbuf.h b/src/vma/lwip/pbuf.h index d59bf87e59..6b0c09d7ad 100644 --- a/src/vma/lwip/pbuf.h +++ b/src/vma/lwip/pbuf.h @@ -118,8 +118,8 @@ struct pbuf_custom { /* Initializes the pbuf module. This call is empty for now, but may not be in future. */ #define pbuf_init() -void pbuf_realloc(struct pbuf *p, u16_t size); -u8_t pbuf_header(struct pbuf *p, s16_t header_size); +void pbuf_realloc(struct pbuf *p, u32_t size); +u8_t pbuf_header(struct pbuf *p, s32_t header_size); void pbuf_ref(struct pbuf *p); u8_t pbuf_free(struct pbuf *p); u8_t pbuf_clen(struct pbuf *p); diff --git a/src/vma/lwip/tcp.c b/src/vma/lwip/tcp.c index 0bdefcc8ae..1151b1262d 100644 --- a/src/vma/lwip/tcp.c +++ b/src/vma/lwip/tcp.c @@ -359,10 +359,12 @@ tcp_abandon(struct tcp_pcb *pcb, int reset) if (pcb->unacked != NULL) { tcp_tx_segs_free(pcb, pcb->unacked); pcb->unacked = NULL; + pcb->last_unacked = NULL; } if (pcb->unsent != NULL) { tcp_tx_segs_free(pcb, pcb->unsent); pcb->unsent = NULL; + pcb->last_unsent = NULL; } #if TCP_QUEUE_OOSEQ if (pcb->ooseq != NULL) { @@ -486,6 +488,7 @@ u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb) if (TCP_SEQ_GEQ(new_right_edge, pcb->rcv_ann_right_edge + LWIP_MIN((pcb->rcv_wnd_max / 2), pcb->mss))) { /* we can advertise more window */ pcb->rcv_ann_wnd = pcb->rcv_wnd; + // coverity[overflow:FALSE] /* Turn off coverity check, value is non-negative */ return new_right_edge - pcb->rcv_ann_right_edge; } else { if (TCP_SEQ_GT(pcb->rcv_nxt, pcb->rcv_ann_right_edge)) { @@ -761,7 +764,7 @@ tcp_slowtmr(struct tcp_pcb* pcb) ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); ++pcb_remove; - err = ERR_ABRT; + err = ERR_TIMEOUT; ++pcb_reset; } #if LWIP_TCP_KEEPALIVE @@ -1233,6 +1236,18 @@ tcp_syn_handled(struct tcp_pcb_listen *pcb, tcp_syn_handled_fn syn_handled) pcb->syn_handled_cb = syn_handled; } +/** + * Used for specifying the function that should be when a accepted pcb is ready. + * + * @param pcb Listen pcb + * @param accepted_pcb Callback function to call when the accepted pcb is ready. + */ +void +tcp_accepted_pcb(struct tcp_pcb_listen *pcb, tcp_accepted_pcb_fn accepted_pcb) +{ + pcb->accepted_pcb = accepted_pcb; +} + /** * Used for specifying the function that should be called to clone pcb * @@ -1305,7 +1320,7 @@ tcp_pcb_purge(struct tcp_pcb *pcb) tcp_tx_segs_free(pcb, pcb->unsent); tcp_tx_segs_free(pcb, pcb->unacked); pcb->unacked = pcb->unsent = NULL; - pcb->last_unsent = NULL; + pcb->last_unacked = pcb->last_unsent = NULL; #if TCP_OVERSIZE pcb->unsent_oversize = 0; #endif /* TCP_OVERSIZE */ @@ -1398,6 +1413,18 @@ tcp_mss_follow_mtu_with_default(u16_t defsendmss, struct tcp_pcb *pcb) } #endif /* TCP_CALCULATE_EFF_SEND_MSS */ +void tcp_set_keepalive(struct tcp_pcb *pcb, u32_t idle, u32_t intvl, u32_t cnt) +{ + pcb->keep_idle = idle; +#if LWIP_TCP_KEEPALIVE + pcb->keep_intvl = intvl; + pcb->keep_cnt = cnt; +#else + (void)intvl; + (void)cnt; +#endif /* LWIP_TCP_KEEPALIVE */ +} + #if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG /** * Print a tcp header for debugging purposes. diff --git a/src/vma/lwip/tcp.h b/src/vma/lwip/tcp.h index 22d8bb79aa..cf823c105f 100644 --- a/src/vma/lwip/tcp.h +++ b/src/vma/lwip/tcp.h @@ -53,11 +53,7 @@ void register_sys_now(sys_now_fn fn); extern u16_t lwip_tcp_mss; #if LWIP_3RD_PARTY_L3 -#if LWIP_TSO -typedef err_t (*ip_output_fn)(struct pbuf *p, void* p_conn, u16_t flags); -#else typedef err_t (*ip_output_fn)(struct pbuf *p, void* p_conn, int is_rexmit, u8_t is_dummy); -#endif /* LWIP_TSO */ void register_ip_output(ip_output_fn fn); typedef ssize_t (*sys_readv_fn)(int __fd, const struct iovec *iov, int iovcnt); @@ -129,6 +125,11 @@ typedef err_t (*tcp_syn_handled_fn)(void *arg, struct tcp_pcb *newpcb, err_t err */ typedef err_t (*tcp_clone_conn_fn)(void *arg, struct tcp_pcb **newpcb, err_t err); +/** Function prototype for tcp new-pcb callback functions. + * Called when a new pcb is ready as part of tcp_listen_input handling. + * @param newpcb The new connection pcb + */ +typedef void (*tcp_accepted_pcb_fn)(struct tcp_pcb *accepted_pcb); /** Function prototype for tcp receive callback functions. Called when data has * been received. @@ -416,28 +417,11 @@ struct tcp_pcb { #ifdef VMA_NO_TCP_PCB_LISTEN_STRUCT tcp_syn_handled_fn syn_handled_cb; tcp_clone_conn_fn clone_conn; - + tcp_accepted_pcb_fn accepted_pcb; #endif /* VMA_NO_TCP_PCB_LISTEN_STRUCT */ /* Delayed ACK control: number of quick acks */ u8_t quickack; - -#if LWIP_TSO - /* TSO description */ - struct { - /* Maximum length of memory buffer */ - u32_t max_buf_sz; - - /* Maximum length of TCP payload for TSO */ - u32_t max_payload_sz; - - /* Maximum length of header for TSO */ - u16_t max_header_sz; - - /* Maximum number of SGE */ - u32_t max_send_sge; - } tso; -#endif /* LWIP_TSO */ }; typedef u16_t (*ip_route_mtu_fn)(struct tcp_pcb *pcb); @@ -453,6 +437,7 @@ struct tcp_pcb_listen { TCP_PCB_COMMON(struct tcp_pcb_listen); tcp_syn_handled_fn syn_handled_cb; tcp_clone_conn_fn clone_conn; + tcp_accepted_pcb_fn accepted_pcb; }; #endif /* VMA_NO_TCP_PCB_LISTEN_STRUCT */ @@ -488,6 +473,7 @@ void tcp_ip_output (struct tcp_pcb *pcb, ip_output_fn ip_ou void tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept); void tcp_syn_handled (struct tcp_pcb_listen *pcb, tcp_syn_handled_fn syn_handled); void tcp_clone_conn (struct tcp_pcb_listen *pcb, tcp_clone_conn_fn clone_conn); +void tcp_accepted_pcb (struct tcp_pcb_listen *pcb, tcp_accepted_pcb_fn accepted_pcb); void tcp_recv (struct tcp_pcb *pcb, tcp_recv_fn recv); void tcp_sent (struct tcp_pcb *pcb, tcp_sent_fn sent); void tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval); @@ -499,13 +485,6 @@ void tcp_err (struct tcp_pcb *pcb, tcp_err_fn err); #define tcp_nagle_disable(pcb) ((pcb)->flags |= TF_NODELAY) #define tcp_nagle_enable(pcb) ((pcb)->flags &= ~TF_NODELAY) #define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0) - -#if LWIP_TSO -#define tcp_tso(pcb) ((pcb)->tso.max_payload_sz) -#else -#define tcp_tso(pcb) (0) -#endif /* LWIP_TSO */ - #define tcp_accepted(pcb) LWIP_ASSERT("get_tcp_state(pcb) == LISTEN (called for wrong pcb?)", \ get_tcp_state(pcb) == LISTEN) @@ -526,7 +505,6 @@ err_t tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx); #define TCP_WRITE_FLAG_MORE 0x02 #define TCP_WRITE_REXMIT 0x08 #define TCP_WRITE_DUMMY 0x10 -#define TCP_WRITE_TSO 0x20 #define TCP_WRITE_FILE 0x40 err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u32_t len, @@ -547,6 +525,8 @@ s32_t tcp_is_wnd_available(struct tcp_pcb *pcb, u32_t data_len); #define get_tcp_state(pcb) ((pcb)->private_state) #define set_tcp_state(pcb, state) external_tcp_state_observer((pcb)->my_container, (pcb)->private_state = state) +void tcp_set_keepalive(struct tcp_pcb *pcb, u32_t idle, u32_t intvl, u32_t cnt); + #ifdef __cplusplus } #endif diff --git a/src/vma/lwip/tcp_impl.h b/src/vma/lwip/tcp_impl.h index e2b584724e..64467c561c 100644 --- a/src/vma/lwip/tcp_impl.h +++ b/src/vma/lwip/tcp_impl.h @@ -218,6 +218,14 @@ PACK_STRUCT_END else (ret) = ERR_ARG; \ } while (0) + +#define TCP_EVENT_ACCEPTED_PCB(pcb, newpcb) \ +do { \ + if ((pcb)->accepted_pcb != NULL) \ + (pcb)->accepted_pcb((newpcb)); \ +} while (0) + + #define TCP_EVENT_SENT(pcb,space,ret) \ do { \ if((pcb)->sent != NULL) \ @@ -279,14 +287,9 @@ PACK_STRUCT_END struct tcp_seg { struct tcp_seg *next; /* used when putting segements on a queue */ struct pbuf *p; /* buffer containing data + TCP header */ -#if LWIP_TSO - u32_t seqno; - u32_t len; /* the TCP length of this segment should allow >64K size */ -#else void *dataptr; /* pointer to the TCP data in the pbuf */ u32_t seqno; u16_t len; /* the TCP length of this segment should allow >64K size */ -#endif /* LWIP_TSO */ #if TCP_OVERSIZE_DBGCHECK u16_t oversize_left; /* Extra bytes available at the end of the last @@ -304,7 +307,6 @@ struct tcp_seg { checksummed into 'chksum' */ #define TF_SEG_OPTS_WNDSCALE (u8_t)0x08U /* Include window scaling option */ #define TF_SEG_OPTS_DUMMY_MSG (u8_t)TCP_WRITE_DUMMY /* Include dummy send option */ -#define TF_SEG_OPTS_TSO (u8_t)TCP_WRITE_TSO /* Use TSO send mode */ struct tcp_hdr *tcphdr; /* the TCP header */ }; diff --git a/src/vma/lwip/tcp_in.c b/src/vma/lwip/tcp_in.c index 985d75d24b..eaffb67a06 100644 --- a/src/vma/lwip/tcp_in.c +++ b/src/vma/lwip/tcp_in.c @@ -115,7 +115,7 @@ L3_level_tcp_input(struct pbuf *p, struct tcp_pcb* pcb) /* remove header from payload */ - if (pbuf_header(p, -((s16_t)(IPH_HL(in_data.iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) { + if (pbuf_header(p, -((s32_t)(IPH_HL(in_data.iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) { /* drop short packets */ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%"U16_F" bytes) discarded\n", (u16_t)p->tot_len)); TCP_STATS_INC(tcp.lenerr); @@ -160,10 +160,7 @@ L3_level_tcp_input(struct pbuf *p, struct tcp_pcb* pcb) /* Set up a tcp_seg structure. */ in_data.inseg.next = NULL; in_data.inseg.len = p->tot_len; -#if LWIP_TSO -#else in_data.inseg.dataptr = p->payload; -#endif /* LWIP_TSO */ in_data.inseg.p = p; in_data.inseg.tcphdr = in_data.tcphdr; in_data.inseg.flags = 0; @@ -283,12 +280,14 @@ L3_level_tcp_input(struct pbuf *p, struct tcp_pcb* pcb) Below this line, 'pcb' may not be dereferenced! */ aborted: tcp_input_pcb = NULL; + /* coverity[assigned_pointer] */ in_data.recv_data = NULL; /* give up our reference to inseg.p */ if (in_data.inseg.p != NULL) { pbuf_free(in_data.inseg.p); + /* coverity[assigned_pointer] */ in_data.inseg.p = NULL; } } @@ -422,11 +421,13 @@ tcp_listen_input(struct tcp_pcb_listen *pcb, tcp_in_data* in_data) /* Send a SYN|ACK together with the MSS option. */ rc = tcp_enqueue_flags(npcb, TCP_SYN | TCP_ACK); - if (rc != ERR_OK) { + if (rc == ERR_OK) { + rc = tcp_output(npcb); + }else{ tcp_abandon(npcb, 0); - return rc; } - return tcp_output(npcb); + TCP_EVENT_ACCEPTED_PCB(pcb, npcb); + return rc; } return ERR_OK; } @@ -575,6 +576,7 @@ tcp_process(struct tcp_pcb *pcb, tcp_in_data* in_data) /* If there's nothing left to acknowledge, stop the retransmit timer, otherwise reset it to start again */ if(pcb->unacked == NULL) { + pcb->last_unacked = NULL; pcb->rtime = -1; } else { pcb->rtime = 0; @@ -738,11 +740,7 @@ tcp_oos_insert_segment(struct tcp_pcb *pcb, struct tcp_seg *cseg, struct tcp_seg if (next && TCP_SEQ_GT(in_data->seqno + cseg->len, next->tcphdr->seqno)) { /* We need to trim the incoming segment. */ -#if LWIP_TSO - cseg->len = (u32_t)(next->tcphdr->seqno - in_data->seqno); -#else cseg->len = (u16_t)(next->tcphdr->seqno - in_data->seqno); -#endif /* LWIP_TSO */ pbuf_realloc(cseg->p, cseg->len); } } @@ -750,136 +748,6 @@ tcp_oos_insert_segment(struct tcp_pcb *pcb, struct tcp_seg *cseg, struct tcp_seg } #endif /* TCP_QUEUE_OOSEQ */ -#if LWIP_TSO -/** - * Called by tcp_output() to shrink TCP segment to lastackno. - * This call should process retransmitted TSO segment. - * - * @param pcb the tcp_pcb for the TCP connection used to send the segment - * @param seg the tcp_seg to send - * @param ackqno current ackqno - * @return number of freed pbufs - */ -static u32_t -tcp_shrink_segment(struct tcp_pcb *pcb, struct tcp_seg *seg, u32_t ackno) -{ - struct pbuf *cur_p; - struct pbuf *p; - u32_t len; - u32_t count = 0; - u8_t optflags = 0; - u8_t optlen; - - if ((NULL == seg) || (NULL == seg->p) || - !(TCP_SEQ_GT(ackno, seg->seqno) && TCP_SEQ_LT(ackno, seg->seqno + TCP_TCPLEN(seg)))) { - return count; - } - -#if LWIP_TCP_TIMESTAMPS - if ((pcb->flags & TF_TIMESTAMP)) { - optflags |= TF_SEG_OPTS_TS; - } -#endif /* LWIP_TCP_TIMESTAMPS */ - - optlen = LWIP_TCP_OPT_LENGTH(optflags); - - /* Just shrink first pbuf */ - if (TCP_SEQ_GT((seg->seqno + seg->p->len - optlen - TCP_HLEN), ackno)) { - len = ackno - seg->seqno; - if (optlen > 0) { - /* tcp_output_segment() relies on aligned options area */ - len &= 0xfffffffc; - } - - seg->len -= len; - seg->seqno += len; - seg->tcphdr->seqno = htonl(seg->seqno); - p = seg->p; - p->tot_len -= len; - p->len -= len; - p->payload = (u8_t *)p->payload + len; - MEMMOVE(p->payload, seg->tcphdr, TCP_HLEN); - seg->tcphdr = p->payload; - return count; - } - - cur_p = seg->p->next; - - if (cur_p) { - /* Process more than first pbuf */ - len = seg->p->len - TCP_HLEN - optlen; - seg->len -= len; - seg->seqno += len; - seg->tcphdr->seqno = htonl(seg->seqno); - seg->p->tot_len -= len; - seg->p->len = TCP_HLEN + optlen; - } - - while (cur_p) { - if (TCP_SEQ_GT((seg->seqno + cur_p->len), ackno)) { - break; - } else { - seg->len -= cur_p->len; - seg->seqno += cur_p->len; - seg->tcphdr->seqno = htonl(seg->seqno); - seg->p->tot_len -= cur_p->len; - seg->p->next = cur_p->next; - - p = cur_p; - cur_p = p->next; - p->next = NULL; - - if (p->type == PBUF_RAM) { - external_tcp_tx_pbuf_free(pcb, p); - } else { - pbuf_free(p); - } - count++; - } - } - - if (cur_p) { - len = ackno - seg->seqno; - if (optlen > 0) { - /* tcp_output_segment() relies on aligned options area */ - len &= 0xfffffffc; - } - - seg->len -= len; - seg->seqno += len; - seg->tcphdr->seqno = htonl(seg->seqno); - cur_p->tot_len -= len - optlen; - cur_p->len -= len - optlen; - cur_p->payload = (u8_t *)cur_p->payload + ((s32_t)len - (s32_t)optlen); - - /* Add space for TCP header */ - cur_p->tot_len += TCP_HLEN; - cur_p->len += TCP_HLEN; - cur_p->payload = (u8_t *)cur_p->payload - TCP_HLEN; - MEMCPY(cur_p->payload, seg->tcphdr, TCP_HLEN); - seg->tcphdr = cur_p->payload; - - p = seg->p; - seg->p = cur_p; - - if (p->type == PBUF_RAM) { - external_tcp_tx_pbuf_free(pcb, p); - } else { - pbuf_free(p); - } - count++; - } - -#if TCP_TSO_DEBUG - LWIP_DEBUGF(TCP_TSO_DEBUG | LWIP_DBG_TRACE, - ("tcp_shrink: count: %-5d unsent %s\n", - count, _dump_seg(pcb->unsent))); -#endif /* TCP_TSO_DEBUG */ - - return count; -} -#endif /* LWIP_TSO */ - /** * Called by tcp_process. Checks if the given segment is an ACK for outstanding * data, and if so frees the memory of the buffered data. Next, is places the @@ -903,7 +771,7 @@ tcp_receive(struct tcp_pcb *pcb, tcp_in_data* in_data) s32_t off; s16_t m; u32_t right_wnd_edge; - u16_t new_tot_len; + u32_t new_tot_len; int found_dupack = 0; s8_t persist = 0; @@ -1062,25 +930,8 @@ tcp_receive(struct tcp_pcb *pcb, tcp_in_data* in_data) /* Remove segment from the unacknowledged list if the incoming ACK acknowlegdes them. */ -#if LWIP_TSO - while (pcb->unacked != NULL) { - - /* The purpose of this processing is to avoid to send again - * data from TSO segment that is partially acknowledged. - * This TSO segment was not released in tcp_receive() because - * input data processing releases whole acknowledged segment only. - */ - if (pcb->unacked->flags & TF_SEG_OPTS_TSO) { - pcb->snd_queuelen -= tcp_shrink_segment(pcb, pcb->unacked, in_data->ackno); - } - - if (!(TCP_SEQ_LEQ(pcb->unacked->seqno + TCP_TCPLEN(pcb->unacked), in_data->ackno))) { - break; - } -#else while (pcb->unacked != NULL && TCP_SEQ_LEQ(pcb->unacked->seqno + TCP_TCPLEN(pcb->unacked), in_data->ackno)) { -#endif /* LWIP_TSO */ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unacked\n", ntohl(pcb->unacked->tcphdr->seqno), ntohl(pcb->unacked->tcphdr->seqno) + @@ -1103,6 +954,7 @@ tcp_receive(struct tcp_pcb *pcb, tcp_in_data* in_data) /* If there's nothing left to acknowledge, stop the retransmit timer, otherwise reset it to start again */ if(pcb->unacked == NULL) { + pcb->last_unacked = NULL; if (persist) { /* start persist timer */ pcb->persist_cnt = 0; @@ -1251,36 +1103,27 @@ tcp_receive(struct tcp_pcb *pcb, tcp_in_data* in_data) off = pcb->rcv_nxt - in_data->seqno; p = in_data->inseg.p; LWIP_ASSERT("inseg.p != NULL", in_data->inseg.p); - LWIP_ASSERT("insane offset!", (off < 0x7fff)); if (in_data->inseg.p->len < off) { LWIP_ASSERT("pbuf too short!", (((s32_t)in_data->inseg.p->tot_len) >= off)); - new_tot_len = (u16_t)(in_data->inseg.p->tot_len - off); + new_tot_len = in_data->inseg.p->tot_len - off; while (p->len < off) { off -= p->len; - /* KJM following line changed (with addition of new_tot_len var) - to fix bug #9076 - inseg.p->tot_len -= p->len; */ p->tot_len = new_tot_len; p->len = 0; p = p->next; } - if(pbuf_header(p, (s16_t)-off)) { + if(pbuf_header(p, -off)) { /* Do we need to cope with this failing? Assert for now */ LWIP_ASSERT("pbuf_header failed", 0); } } else { - if(pbuf_header(in_data->inseg.p, (s16_t)-off)) { + if(pbuf_header(in_data->inseg.p, -off)) { /* Do we need to cope with this failing? Assert for now */ LWIP_ASSERT("pbuf_header failed", 0); } } - /* KJM following line changed to use p->payload rather than inseg->p->payload - to fix bug #9076 */ -#if LWIP_TSO -#else in_data->inseg.dataptr = p->payload; -#endif /* LWIP_TSO */ - in_data->inseg.len -= (u16_t)(pcb->rcv_nxt - in_data->seqno); + in_data->inseg.len -= pcb->rcv_nxt - in_data->seqno; in_data->inseg.tcphdr->seqno = in_data->seqno = pcb->rcv_nxt; } else { @@ -1364,11 +1207,7 @@ tcp_receive(struct tcp_pcb *pcb, tcp_in_data* in_data) TCP_SEQ_GT(in_data->seqno + in_data->tcplen, next->tcphdr->seqno)) { /* inseg cannot have FIN here (already processed above) */ -#if LWIP_TSO - in_data->inseg.len = (u32_t)(next->tcphdr->seqno - in_data->seqno); -#else in_data->inseg.len = (u16_t)(next->tcphdr->seqno - in_data->seqno); -#endif /* LWIP_TSO */ if (TCPH_FLAGS(in_data->inseg.tcphdr) & TCP_SYN) { in_data->inseg.len -= 1; } @@ -1532,11 +1371,7 @@ tcp_receive(struct tcp_pcb *pcb, tcp_in_data* in_data) if (cseg != NULL) { if (TCP_SEQ_GT(prev->tcphdr->seqno + prev->len, in_data->seqno)) { /* We need to trim the prev segment. */ -#if LWIP_TSO - prev->len = (u32_t)(in_data->seqno - prev->tcphdr->seqno); -#else prev->len = (u16_t)(in_data->seqno - prev->tcphdr->seqno); -#endif /* LWIP_TSO */ pbuf_realloc(prev->p, prev->len); } prev->next = cseg; @@ -1558,15 +1393,11 @@ tcp_receive(struct tcp_pcb *pcb, tcp_in_data* in_data) if (next->next != NULL) { if (TCP_SEQ_GT(next->tcphdr->seqno + next->len, in_data->seqno)) { /* We need to trim the last segment. */ -#if LWIP_TSO - next->len = (u32_t)(in_data->seqno - next->tcphdr->seqno); -#else next->len = (u16_t)(in_data->seqno - next->tcphdr->seqno); -#endif /* LWIP_TSO */ pbuf_realloc(next->p, next->len); } /* check if the remote side overruns our receive window */ - if ((u32_t)in_data->tcplen + in_data->seqno > pcb->rcv_nxt + (u32_t)pcb->rcv_wnd) { + if (TCP_SEQ_GT(in_data->seqno + in_data->tcplen, pcb->rcv_nxt + pcb->rcv_wnd)) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: other end overran receive window" "seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n", diff --git a/src/vma/lwip/tcp_out.c b/src/vma/lwip/tcp_out.c index 9af8398981..7a72410373 100644 --- a/src/vma/lwip/tcp_out.c +++ b/src/vma/lwip/tcp_out.c @@ -147,6 +147,7 @@ tcp_output_alloc_header(struct tcp_pcb *pcb, u16_t optlen, u16_t datalen, struct tcp_hdr *tcphdr; struct pbuf *p = tcp_tx_pbuf_alloc(pcb, optlen + datalen, PBUF_RAM); if (p != NULL) { + /* coverity[check_return] */ pbuf_header(p, TCP_HLEN); LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr", (p->len >= TCP_HLEN + optlen)); @@ -177,13 +178,9 @@ tcp_send_fin(struct tcp_pcb *pcb) { /* first, try to add the fin to the last unsent segment */ if (pcb->unsent != NULL) { - struct tcp_seg *last_unsent; - for (last_unsent = pcb->unsent; last_unsent->next != NULL; - last_unsent = last_unsent->next); - - if ((TCPH_FLAGS(last_unsent->tcphdr) & (TCP_SYN | TCP_FIN | TCP_RST)) == 0) { + if ((TCPH_FLAGS(pcb->last_unsent->tcphdr) & (TCP_SYN | TCP_FIN | TCP_RST)) == 0) { /* no SYN/FIN/RST flag in the header, we can add the FIN flag */ - TCPH_SET_FLAG(last_unsent->tcphdr, TCP_FIN); + TCPH_SET_FLAG(pcb->last_unsent->tcphdr, TCP_FIN); pcb->flags |= TF_FIN; return ERR_OK; } @@ -245,10 +242,7 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno, seg->flags = optflags; seg->p = p; -#if LWIP_TSO -#else seg->dataptr = p->payload; -#endif /* LWIP_TSO */ seg->len = p->tot_len - optlen; seg->seqno = seqno; @@ -368,32 +362,6 @@ tcp_write_checks(struct tcp_pcb *pcb, u32_t len) return ERR_OK; } -#if LWIP_TSO -static inline u16_t tcp_xmit_size_goal(struct tcp_pcb *pcb, int use_max) -{ - u16_t size = pcb->mss; - -#if LWIP_TCP_TIMESTAMPS - if ((pcb->flags & TF_TIMESTAMP)) { - /* ensure that segments can hold at least one data byte... */ - size = LWIP_MAX(size, LWIP_TCP_OPT_LEN_TS + 1); - } -#endif /* LWIP_TCP_TIMESTAMPS */ - -#if LWIP_TSO - if (use_max && tcp_tso(pcb) && pcb->tso.max_buf_sz) { - /* use maximum buffer size in case TSO */ - size = LWIP_MAX(size, pcb->tso.max_buf_sz); - } -#endif /* LWIP_TSO */ - - /* don't allocate segments bigger than half the maximum window we ever received */ - size = LWIP_MIN(size, (pcb->snd_wnd_max >> 1)); - - return size; -} -#endif /* LWIP_TSO */ - /** * Write data for sending (but does not send it immediately). * @@ -432,9 +400,6 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u32_t len, u8_t apiflags) #endif /* TCP_CHECKSUM_ON_COPY */ err_t err; u16_t mss_local = 0; -#if LWIP_TSO - int tot_p = 0; -#endif /* LWIP_TSO */ const int piov_max_size = 512; const int piov_max_len = 65536; struct iovec piov[piov_max_size]; @@ -456,23 +421,16 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u32_t len, u8_t apiflags) } queuelen = pcb->snd_queuelen; -#if LWIP_TSO - mss_local = tcp_xmit_size_goal(pcb, 1); -#else mss_local = LWIP_MIN(pcb->mss, pcb->snd_wnd_max/2); mss_local = mss_local ? mss_local : pcb->mss; -#endif /* LWIP_TSO */ optflags |= (apiflags & TCP_WRITE_DUMMY ? TF_SEG_OPTS_DUMMY_MSG : 0); #if LWIP_TCP_TIMESTAMPS if ((pcb->flags & TF_TIMESTAMP)) { optflags |= TF_SEG_OPTS_TS; -#if LWIP_TSO -#else /* ensure that segments can hold at least one data byte... */ mss_local = LWIP_MAX(mss_local, LWIP_TCP_OPT_LEN_TS + 1); -#endif /* LWIP_TSO */ } #endif /* LWIP_TCP_TIMESTAMPS */ @@ -500,24 +458,24 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u32_t len, u8_t apiflags) * pos records progress as data is segmented. */ - /* Find the tail of the unsent queue. */ - if (pcb->unsent != NULL) { + if (pcb->last_unsent != NULL) { u16_t space; u16_t unsent_optlen; - if (!pcb->last_unsent || pcb->last_unsent->next) { - /* @todo: this could be sped up by keeping last_unsent in the pcb */ - for (pcb->last_unsent = pcb->unsent; pcb->last_unsent->next != NULL; - pcb->last_unsent = pcb->last_unsent->next); - } /* Usable space at the end of the last unsent segment */ unsent_optlen = LWIP_TCP_OPT_LENGTH(pcb->last_unsent->flags); LWIP_ASSERT("mss_local is too small", mss_local >= pcb->last_unsent->len + unsent_optlen); - space = mss_local - (pcb->last_unsent->len + unsent_optlen); + + if((TCP_SEQ_GEQ(pcb->last_unsent->seqno, pcb->snd_nxt)) && + (pcb->last_unsent->seqno + pcb->last_unsent->len == pcb->snd_lbb)) { + space = mss_local - (pcb->last_unsent->len + unsent_optlen); + } else { + space = 0; +#if TCP_OVERSIZE + pcb->unsent_oversize = 0; +#endif /* TCP_OVERSIZE */ + } seg = pcb->last_unsent; -#if LWIP_TSO - tot_p = pbuf_clen(seg->p); -#endif /* LWIP_TSO */ /* * Phase 1: Copy data directly into an oversized pbuf. @@ -554,13 +512,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u32_t len, u8_t apiflags) * (len==0). The new pbuf is kept in concat_p and pbuf_cat'ed at * the end. */ -#if LWIP_TSO - if (!(apiflags & TCP_WRITE_FILE) && (pos < len) && (space > 0) && (pcb->last_unsent->len > 0) && - (tot_p < (int)pcb->tso.max_send_sge)) { -#else if (!(apiflags & TCP_WRITE_FILE) && (pos < len) && (space > 0) && (pcb->last_unsent->len > 0)) { -#endif /* LWIP_TSO */ - u16_t seglen = space < len - pos ? space : len - pos; /* Create a pbuf with a copy or reference to seglen bytes. We @@ -586,7 +538,6 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u32_t len, u8_t apiflags) } } else { #if TCP_OVERSIZE - pcb->last_unsent = NULL; LWIP_ASSERT("unsent_oversize mismatch (pcb->unsent is NULL)", pcb->unsent_oversize == 0); #endif /* TCP_OVERSIZE */ @@ -751,8 +702,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u32_t len, u8_t apiflags) TCPH_SET_FLAG(seg->tcphdr, TCP_PSH); } - LWIP_DEBUGF(TCP_TSO_DEBUG | LWIP_DBG_TRACE, - ("tcp_write: mss: %-5d unsent %s\n", mss_local, _dump_seg(pcb->unsent))); + LWIP_DEBUGF(LWIP_DBG_TRACE, ("tcp_write: mss: %-5d unsent %s\n", mss_local, _dump_seg(pcb->unsent))); return ERR_OK; memerr: @@ -865,9 +815,7 @@ tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags) if (pcb->unsent == NULL) { pcb->unsent = seg; } else { - struct tcp_seg *useg; - for (useg = pcb->unsent; useg->next != NULL; useg = useg->next); - useg->next = seg; + pcb->last_unsent->next = seg; } pcb->last_unsent = seg; #if TCP_OVERSIZE @@ -953,11 +901,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb) opts += 3; } #endif -#if LWIP_TSO - pcb->ip_output(p, pcb, 0); -#else pcb->ip_output(p, pcb, 0, 0); -#endif /* LWIP_TSO */ tcp_tx_pbuf_free(pcb, p); (void)opts; /* Fix warning -Wunused-but-set-variable */ @@ -976,300 +920,6 @@ static void tcp_seg_move_flags(struct tcp_seg *from, struct tcp_seg *to, u8_t fl } } -#if LWIP_TSO -/** - * Called by tcp_output() to actually join few following TCP segments - * in one to send a TCP segment over IP using Large Segment Offload method. - * - * @param pcb the tcp_pcb for the TCP connection used to send the segment - * @param seg the tcp_seg to send - * @param wnd current wnd - * @return pbuf with p->payload being the tcp_hdr - */ -static void -tcp_tso_segment(struct tcp_pcb *pcb, struct tcp_seg *seg, u32_t wnd) -{ - struct tcp_seg *cur_seg = seg; - u32_t max_payload_sz = LWIP_MIN(pcb->tso.max_payload_sz, (wnd - (seg->seqno - pcb->lastack))); - u32_t tot_len = 0; - u8_t flags = seg->flags; - int tot_p = 0; - - /* Ignore retransmitted segments and special segments - */ - if (TCP_SEQ_LT(seg->seqno, pcb->snd_nxt) || - (seg->flags & (TF_SEG_OPTS_TSO | TF_SEG_OPTS_DUMMY_MSG)) || - ((TCPH_FLAGS(seg->tcphdr) & (~(TCP_ACK | TCP_PSH))) != 0)) { - goto err; - } - - while (cur_seg && cur_seg->next && - (cur_seg->flags == flags) && - ((TCPH_FLAGS(cur_seg->tcphdr) & (~(TCP_ACK | TCP_PSH))) == 0)) { - - tot_len += cur_seg->len; - if (tot_len > max_payload_sz) { - goto err; - } - - tot_p += pbuf_clen(cur_seg->p); - if (tot_p > (int)pcb->tso.max_send_sge) { - goto err; - } - - if (seg != cur_seg) { - /* Update the original segment with current segment details */ - seg->next = cur_seg->next; - seg->len += cur_seg->len; - - /* Update the first pbuf of current segment */ - cur_seg->p->payload = (u8_t *)cur_seg->tcphdr + LWIP_TCP_HDRLEN(cur_seg->tcphdr); - cur_seg->p->len = cur_seg->len - (cur_seg->p->tot_len - cur_seg->p->len); - cur_seg->p->tot_len = cur_seg->len; - - /* Concatenate two pbufs (each may be a pbuf chain) and - * update tot_len values for all pbuf in the chain - */ - pbuf_cat(seg->p, cur_seg->p); - - /* Free joined segment w/o releasing pbuf - * tcp_seg_free() and tcp_segs_free() release pbuf chain. - * Note, this code doesn't join the last unsent segment and thus - * pcb->last_unsent is left unchanged. Otherwise, we would have - * to update the last_unsent pointer to keep it valid. - */ - external_tcp_seg_free(pcb, cur_seg); - } - cur_seg = seg->next; - } - -err: - - /* All segments that greater than MSS must be processed as TSO segments - * For example it can be actual for segments with large (more than MSS) buffer size - */ - if (seg->len > pcb->mss) { - seg->flags |= TF_SEG_OPTS_TSO; - } - -#if TCP_TSO_DEBUG - LWIP_DEBUGF(TCP_TSO_DEBUG | LWIP_DBG_TRACE, - ("tcp_join: max: %-5d unsent %s\n", - max_payload_sz, _dump_seg(pcb->unsent))); -#endif /* TCP_TSO_DEBUG */ - - return; -} - -static struct tcp_seg * -tcp_split_one_segment(struct tcp_pcb *pcb, struct tcp_seg *seg, u32_t lentosend, u8_t optflags, u8_t optlen) -{ - struct tcp_seg *cur_seg = NULL; - struct tcp_seg *new_seg = NULL; - struct tcp_seg *result = NULL; - struct pbuf *cur_p = NULL; - u16_t max_length = 0; - u16_t oversize = 0; - - cur_seg = seg; - max_length = cur_seg->p->len; - while ((cur_seg->p->len == cur_seg->p->tot_len) && (cur_seg->len > lentosend)) { - - u32_t lentoqueue = cur_seg->len - lentosend; - - /* Allocate memory for p_buf and fill in fields. */ - if (NULL == (cur_p = tcp_pbuf_prealloc(lentoqueue + optlen, max_length, &oversize, pcb, 0, 0))) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_split_one_segment: could not allocate memory for pbuf copy size %"U16_F"\n", (lentoqueue + optlen))); - goto out; - } - - /* Do prefetch to avoid no memory issue during segment creation with - * predefined pbuf. It allows to avoid releasing pbuf during failure processing. - */ - if (!pcb->seg_alloc) { - if (NULL == (pcb->seg_alloc = tcp_create_segment(pcb, NULL, 0, 0, 0))) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_split_one_segment: could not allocate memory for segment\n")); - tcp_tx_pbuf_free(pcb, cur_p); - goto out; - } - } - - /* Copy the data from the original buffer */ - TCP_DATA_COPY2((char *)cur_p->payload + optlen, (u8_t *)cur_seg->tcphdr + LWIP_TCP_HDRLEN(cur_seg->tcphdr) + lentosend, lentoqueue , &chksum, &chksum_swapped); - - /* Update new buffer */ - cur_p->tot_len = cur_seg->p->tot_len - lentosend - TCP_HLEN ; - cur_p->next = cur_seg->p->next; - - /* Fill in tcp_seg (allocation was done before). - * Do not expect NULL but it is possible as far as pbuf_header(p, TCP_HLEN) can return NULL inside tcp_create_segment() - */ - if (NULL == (new_seg = tcp_create_segment(pcb, cur_p, 0, cur_seg->seqno + lentosend, optflags))) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_split_one_segment: could not allocate memory for segment\n")); - goto out; - } - - /* New segment update */ - new_seg->next = cur_seg->next; - new_seg->flags = cur_seg->flags; - - /* Update original buffer */ - cur_seg->p->next = NULL; - cur_seg->p->len = cur_seg->p->len - lentoqueue; - cur_seg->p->tot_len = cur_seg->p->len; - - /* Original segment update */ - cur_seg->next = new_seg; - cur_seg->len = cur_seg->p->len - (TCP_HLEN + optlen); - - cur_seg = new_seg; - - /* Update number of buffer to be send */ - pcb->snd_queuelen++; - } - - result = seg; - -out: - if (cur_seg->len > pcb->mss) { - cur_seg->flags |= TF_SEG_OPTS_TSO; - } - if (pcb->last_unsent == seg) { - /* We have split the last unsent segment, update last_unsent */ - pcb->last_unsent = cur_seg; -#if TCP_OVERSIZE - pcb->unsent_oversize = result ? oversize : 0; -#endif /* TCP_OVERSIZE */ - } - tcp_seg_move_flags(seg, cur_seg, TCP_FIN | TCP_RST); - return result; -} - - /** - * Called by tcp_output() to process TCP segment with ref > 1. - * This call should process retransmitted TSO segment. - * - * @param pcb the tcp_pcb for the TCP connection used to send the segment - * @param seg the tcp_seg to send - * @param wnd current window size - * @return current segment to proceed - */ -__attribute__((unused)) static struct tcp_seg * -tcp_rexmit_segment(struct tcp_pcb *pcb, struct tcp_seg *seg, u32_t wnd) -{ - struct tcp_seg *cur_seg = NULL; - struct tcp_seg *new_seg = NULL; - struct pbuf *cur_p = NULL; - u16_t mss_local = 0; - u8_t optflags = 0; - u8_t optlen = 0; - - LWIP_ASSERT("tcp_rexmit_segment: sanity check", (seg && seg->p)); - - mss_local = tcp_xmit_size_goal(pcb, 0); - - /* TCP_SEQ_LT(seg->seqno, pcb->snd_nxt) can be used as - * retransmission attribute but according current design - * checking this condition is needless. - * Following check makes a decision to retransmit TSO segment as is or - * convert one into a sequence of none TSO segments - * Keep TSO segment w/o change in case: - * 1. current TSO segment was sent and send operation - * was completed - * 2. current wnd is enough to send this segment as is - */ - if ((seg->p->ref == 1) && ((seg->len + seg->seqno - pcb->lastack) <= wnd)) { - if (seg->len <= mss_local) { - seg->flags &= (~TF_SEG_OPTS_TSO); - } - return seg; - } - -#if LWIP_TCP_TIMESTAMPS - if ((pcb->flags & TF_TIMESTAMP)) { - optflags |= TF_SEG_OPTS_TS; - } -#endif /* LWIP_TCP_TIMESTAMPS */ - - optlen += LWIP_TCP_OPT_LENGTH(optflags); - - cur_seg = seg; - cur_seg->flags &= (~TF_SEG_OPTS_TSO); - cur_p = cur_seg->p->next; - while (cur_p) { - /* Do prefetch to avoid no memory issue during segment creation with - * predefined pbuf. It allows to avoid releasing pbuf inside tcp_create_segment() - * during failure processing. - */ - if (!pcb->seg_alloc) { - if (NULL == (pcb->seg_alloc = tcp_create_segment(pcb, NULL, 0, 0, 0))) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_split_segment: could not allocate memory for segment\n")); - return seg; - } - } - - cur_p->len += optlen; - cur_p->tot_len = cur_p->len; - cur_p->payload = (u8_t *)cur_p->payload - optlen; - - /* Fill in tcp_seg (allocation was done before). - * Do not expect NULL but it is possible as far as pbuf_header(p, TCP_HLEN) can return NULL inside tcp_create_segment() - */ - if (NULL == (new_seg = tcp_create_segment(pcb, cur_p, 0, cur_seg->seqno + cur_seg->p->len - TCP_HLEN - optlen, optflags))) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_split_one_segment: could not allocate memory for segment\n")); - if (cur_seg->len > pcb->mss) { - cur_seg->flags |= TF_SEG_OPTS_TSO; - } - return seg; - } - - /* New segment update */ - new_seg->next = cur_seg->next; - new_seg->flags = cur_seg->flags; - - /* Original segment update */ - cur_seg->next = new_seg; - cur_seg->len = cur_seg->p->len - TCP_HLEN - optlen; - cur_seg->p->tot_len = cur_seg->p->len; - cur_seg->p->next = NULL; - - if (pcb->last_unsent == cur_seg) { - /* We have split the last unsent segment, update last_unsent */ - pcb->last_unsent = new_seg; -#if TCP_OVERSIZE - pcb->unsent_oversize = 0; -#endif /* TCP_OVERSIZE */ - } - - tcp_seg_move_flags(cur_seg, new_seg, TCP_FIN | TCP_RST); - - if (NULL == tcp_split_one_segment(pcb, cur_seg, mss_local, optflags, optlen)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_split_one_segment: could not allocate memory for segment\n")); - if (new_seg->len > pcb->mss) { - new_seg->flags |= TF_SEG_OPTS_TSO; - } - return seg; - } - cur_seg = new_seg; - - cur_p = cur_seg->p->next; - } - - if (NULL == tcp_split_one_segment(pcb, cur_seg, mss_local, optflags, optlen)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_split_one_segment: could not allocate memory for segment\n")); - return seg; - } - -#if TCP_TSO_DEBUG - LWIP_DEBUGF(TCP_TSO_DEBUG | LWIP_DBG_TRACE, - ("tcp_rexmit: cwnd: %-5d unsent %s\n", - pcb->cwnd, _dump_seg(pcb->unsent))); -#endif /* TCP_TSO_DEBUG */ - - return seg; -} -#endif /* LWIP_TSO */ - void tcp_split_segment(struct tcp_pcb *pcb, struct tcp_seg *seg, u32_t wnd) { @@ -1289,9 +939,6 @@ tcp_split_segment(struct tcp_pcb *pcb, struct tcp_seg *seg, u32_t wnd) lentosend = (wnd - (seg->seqno - pcb->lastack)); -#if LWIP_TSO - mss_local = tcp_xmit_size_goal(pcb, 0); -#else /* don't allocate segments bigger than half the maximum window we ever received */ mss_local = LWIP_MIN(pcb->mss, pcb->snd_wnd_max / 2); mss_local = mss_local ? mss_local : pcb->mss; @@ -1302,7 +949,6 @@ tcp_split_segment(struct tcp_pcb *pcb, struct tcp_seg *seg, u32_t wnd) mss_local = LWIP_MAX(mss_local, LWIP_TCP_OPT_LEN_TS + 1); } #endif /* LWIP_TCP_TIMESTAMPS */ -#endif /* LWIP_TSO */ #if LWIP_TCP_TIMESTAMPS if ((pcb->flags & TF_TIMESTAMP)) { @@ -1319,11 +965,7 @@ tcp_split_segment(struct tcp_pcb *pcb, struct tcp_seg *seg, u32_t wnd) } /* Copy the data from the original buffer */ -#if LWIP_TSO - TCP_DATA_COPY2((char *)p->payload + optlen, (u8_t *)seg->tcphdr + LWIP_TCP_HDRLEN(seg->tcphdr) + lentosend, lentoqueue , &chksum, &chksum_swapped); -#else TCP_DATA_COPY2((char *)p->payload + optlen, (u8_t *)seg->dataptr + lentosend, lentoqueue , &chksum, &chksum_swapped); -#endif /* LWIP_TSO */ /* Update new buffer */ p->tot_len = seg->p->tot_len - lentosend - TCP_HLEN ; @@ -1420,12 +1062,6 @@ tcp_split_segment(struct tcp_pcb *pcb, struct tcp_seg *seg, u32_t wnd) tcp_seg_move_flags(seg, newseg, TCP_FIN | TCP_RST); -#if TCP_TSO_DEBUG - LWIP_DEBUGF(TCP_TSO_DEBUG | LWIP_DBG_TRACE, - ("tcp_split: max: %-5d unsent %s\n", - lentosend, _dump_seg(pcb->unsent))); -#endif /* TCP_TSO_DEBUG */ - return; } @@ -1528,25 +1164,8 @@ tcp_output(struct tcp_pcb *pcb) ntohl(seg->tcphdr->seqno), pcb->lastack)); } #endif /* TCP_CWND_DEBUG */ -#if TCP_TSO_DEBUG - if (seg) { - LWIP_DEBUGF(TCP_TSO_DEBUG | LWIP_DBG_TRACE, - ("tcp_output: wnd: %-5d unsent %s\n", - wnd, _dump_seg(pcb->unsent))); - } -#endif /* TCP_TSO_DEBUG */ while (seg) { -#if LWIP_TSO - /* TSO segment can be in unsent queue only in case of retransmission. - * Clear TSO flag, tcp_split_segment() and tcp_tso_segment() will handle - * all scenarios further. - */ - if (seg->flags & TF_SEG_OPTS_TSO) { - seg->flags &= ~TF_SEG_OPTS_TSO; - } -#endif /* LWIP_TSO */ - /* Split the segment in case of a small window */ if ((NULL == pcb->unacked) && (wnd) && ((seg->len + seg->seqno - pcb->lastack) > wnd)) { LWIP_ASSERT("tcp_output: no window for dummy packet", !LWIP_IS_DUMMY_SEGMENT(seg)); @@ -1579,15 +1198,6 @@ tcp_output(struct tcp_pcb *pcb) } } -#if LWIP_TSO - /* Use TSO send operation in case TSO is enabled - * and current segment is not retransmitted - */ - if (tcp_tso(pcb)) { - tcp_tso_segment(pcb, seg, wnd); - } -#endif /* LWIP_TSO */ - #if TCP_CWND_DEBUG LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"U32_F", cwnd %"U16_F", wnd %"U32_F", effwnd %"U32_F", seq %"U32_F", ack %"U32_F", i %"S16_F"\n", pcb->snd_wnd, pcb->cwnd, wnd, @@ -1781,15 +1391,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb) TCP_STATS_INC(tcp.xmit); -#if LWIP_TSO - u16_t flags = 0; - flags |= seg->flags & TF_SEG_OPTS_DUMMY_MSG; - flags |= seg->flags & TF_SEG_OPTS_TSO; - flags |= (TCP_SEQ_LT(seg->seqno, pcb->snd_nxt) ? TCP_WRITE_REXMIT : 0); - pcb->ip_output(seg->p, pcb, flags); -#else pcb->ip_output(seg->p, pcb, seg->seqno < pcb->snd_nxt, LWIP_IS_DUMMY_SEGMENT(seg)); -#endif /* LWIP_TSO */ } /** @@ -1828,6 +1430,7 @@ tcp_rst(u32_t seqno, u32_t ackno, u16_t local_port, u16_t remote_port, struct tc LWIP_DEBUGF(TCP_DEBUG, ("tcp_rst: could not allocate memory for pbuf\n")); return; } + /* coverity[check_return] */ pbuf_header(p, TCP_HLEN); LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr", (p->len >= sizeof(struct tcp_hdr))); @@ -1844,11 +1447,7 @@ tcp_rst(u32_t seqno, u32_t ackno, u16_t local_port, u16_t remote_port, struct tc TCP_STATS_INC(tcp.xmit); /* Send output with hardcoded TTL since we have no access to the pcb */ -#if LWIP_TSO - if(pcb) pcb->ip_output(p, pcb, 0); -#else if(pcb) pcb->ip_output(p, pcb, 0, 0); -#endif /* LWIP_TSO */ /* external_ip_output(p, NULL, local_ip, remote_ip, TCP_TTL, 0, IP_PROTO_TCP) */; tcp_tx_pbuf_free(pcb, p); LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_rst: seqno %"U32_F" ackno %"U32_F".\n", seqno, ackno)); @@ -1864,28 +1463,43 @@ tcp_rst(u32_t seqno, u32_t ackno, u16_t local_port, u16_t remote_port, struct tc void tcp_rexmit_rto(struct tcp_pcb *pcb) { - struct tcp_seg *seg; - if (pcb->unacked == NULL) { return; } + if (pcb->unsent != NULL && TCP_SEQ_GT(pcb->unacked->seqno, pcb->unsent->seqno)) { + // Move fast-retransmitted segments to unacked - RTO after fast retransmission + struct tcp_seg *rexmit_start = pcb->unsent; + struct tcp_seg *rexmit_end = pcb->unsent; + while (rexmit_end->next != NULL && + TCP_SEQ_GT(pcb->unacked->seqno, rexmit_end->next->seqno)) { + rexmit_end = rexmit_end->next; + } + + pcb->unsent = rexmit_end->next; + if (pcb->unsent == NULL) { + pcb->last_unsent = NULL; + } + + rexmit_end->next = pcb->unacked; + pcb->unacked = rexmit_start; + } /* Move all unacked segments to the head of the unsent queue */ - for (seg = pcb->unacked; seg->next != NULL; seg = seg->next); /* concatenate unsent queue after unacked queue */ - seg->next = pcb->unsent; - if (pcb->unsent == NULL) { + if(pcb->unsent){ + pcb->last_unacked->next = pcb->unsent; + }else{ /* If there are no unsent segments, update last_unsent to the last unacked */ - pcb->last_unsent = seg; + pcb->last_unsent = pcb->last_unacked; #if TCP_OVERSIZE && TCP_OVERSIZE_DBGCHECK - pcb->unsent_oversize = seg->oversize_left; + pcb->unsent_oversize = pcb->last_unacked->oversize_left; #endif /* TCP_OVERSIZE && TCP_OVERSIZE_DBGCHECK*/ } /* unsent queue is the concatenated queue (of unacked, unsent) */ pcb->unsent = pcb->unacked; /* unacked queue is now empty */ pcb->unacked = NULL; - + pcb->last_unacked = NULL; /* increment number of retransmissions */ ++pcb->nrtx; @@ -1917,6 +1531,9 @@ tcp_rexmit(struct tcp_pcb *pcb) /* Keep the unsent queue sorted. */ seg = pcb->unacked; pcb->unacked = seg->next; + if(pcb->unacked == NULL){ + pcb->last_unacked = NULL; + } cur_seg = &(pcb->unsent); while (*cur_seg && @@ -2036,11 +1653,7 @@ tcp_keepalive(struct tcp_pcb *pcb) TCP_STATS_INC(tcp.xmit); /* Send output to IP */ -#if LWIP_TSO - pcb->ip_output(p, pcb, 0); -#else pcb->ip_output(p, pcb, 0, 0); -#endif /* LWIP_TSO */ tcp_tx_pbuf_free(pcb, p); @@ -2130,11 +1743,7 @@ tcp_zero_window_probe(struct tcp_pcb *pcb) TCPH_FLAGS_SET(tcphdr, TCP_ACK | TCP_FIN); } else { /* Data segment, copy in one byte from the head of the unacked queue */ -#if LWIP_TSO - *((char *)p->payload + TCP_HLEN + optlen) = *(char *)((u8_t *)seg->tcphdr + LWIP_TCP_HDRLEN(seg->tcphdr)); -#else *((char *)p->payload + TCP_HLEN + optlen) = *(char *)seg->dataptr; -#endif /* LWIP_TSO */ } /* The byte may be acknowledged without the window being opened. */ @@ -2150,11 +1759,7 @@ tcp_zero_window_probe(struct tcp_pcb *pcb) TCP_STATS_INC(tcp.xmit); /* Send output to IP */ -#if LWIP_TSO - pcb->ip_output(p, pcb, 0); -#else pcb->ip_output(p, pcb, 0, 0); -#endif /* LWIP_TSO */ tcp_tx_pbuf_free(pcb, p); diff --git a/src/vma/main.cpp b/src/vma/main.cpp index db56d1e6f1..da9a907b9f 100644 --- a/src/vma/main.cpp +++ b/src/vma/main.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -48,6 +22,7 @@ #include #include "vlogger/vlogger.h" +#include "utils/compiler.h" #include "utils/rdtsc.h" #include "vma/util/vma_stats.h" #include "vma/util/utils.h" @@ -61,8 +36,6 @@ #include "vma/proto/vma_lwip.h" #include "vma/proto/route_table_mgr.h" #include "vma/proto/rule_table_mgr.h" -#include "vma/proto/igmp_mgr.h" - #include "vma/proto/neighbour_table_mgr.h" #include "vma/netlink/netlink_wrapper.h" #include "vma/event/command.h" @@ -131,13 +104,6 @@ static int free_libvma_resources() g_p_net_device_table_mgr->global_ring_drain_and_procces(); } - if(g_p_igmp_mgr) { - igmp_mgr* g_p_igmp_mgr_tmp = g_p_igmp_mgr; - g_p_igmp_mgr = NULL; - delete g_p_igmp_mgr_tmp; - usleep(50000); - } - if (g_p_event_handler_manager) g_p_event_handler_manager->stop_thread(); @@ -352,6 +318,7 @@ void print_vma_global_settings() vlog_printf(VLOG_INFO,"Cmd Line: %s\n", safe_mce_sys().app_name); // Use DEBUG level logging with more details in RPM release builds + /* coverity[assigned_value] */ vlog_levels_t log_level = VLOG_DEBUG; #if !defined(PRJ_LIBRARY_RELEASE) || (PRJ_LIBRARY_RELEASE == 0) // If non RPM (development builds) use more verbosity @@ -431,9 +398,6 @@ void print_vma_global_settings() VLOG_PARAM_NUMBER("Tx Mem Segs TCP", safe_mce_sys().tx_num_segs_tcp, MCE_DEFAULT_TX_NUM_SEGS_TCP, SYS_VAR_TX_NUM_SEGS_TCP); VLOG_PARAM_NUMBER("Tx Mem Bufs", safe_mce_sys().tx_num_bufs, MCE_DEFAULT_TX_NUM_BUFS, SYS_VAR_TX_NUM_BUFS); -#ifdef DEFINED_TSO - VLOG_PARAM_NUMBER("Tx Mem Buf size", safe_mce_sys().tx_buf_size, MCE_DEFAULT_TX_BUF_SIZE, SYS_VAR_TX_BUF_SIZE); -#endif /* DEFINED_TSO */ VLOG_PARAM_NUMBER("Tx QP WRE", safe_mce_sys().tx_num_wr, MCE_DEFAULT_TX_NUM_WRE, SYS_VAR_TX_NUM_WRE); VLOG_PARAM_NUMBER("Tx QP WRE Batching", safe_mce_sys().tx_num_wr_to_signal, MCE_DEFAULT_TX_NUM_WRE_TO_SIGNAL, SYS_VAR_TX_NUM_WRE_TO_SIGNAL); VLOG_PARAM_NUMBER("Tx Max QP INLINE", safe_mce_sys().tx_max_inline, MCE_DEFAULT_TX_MAX_INLINE, SYS_VAR_TX_MAX_INLINE); @@ -480,7 +444,6 @@ void print_vma_global_settings() VLOG_PARAM_STRING("Force Flowtag for MC", safe_mce_sys().mc_force_flowtag, MCE_DEFAULT_MC_FORCE_FLOWTAG, SYS_VAR_MC_FORCE_FLOWTAG, safe_mce_sys().mc_force_flowtag ? "Enabled " : "Disabled"); VLOG_PARAM_NUMBER("Select Poll (usec)", safe_mce_sys().select_poll_num, MCE_DEFAULT_SELECT_NUM_POLLS, SYS_VAR_SELECT_NUM_POLLS); - VLOG_PARAM_STRING("Select Poll OS Force", safe_mce_sys().select_poll_os_force, MCE_DEFAULT_SELECT_POLL_OS_FORCE, SYS_VAR_SELECT_POLL_OS_FORCE, safe_mce_sys().select_poll_os_force ? "Enabled " : "Disabled"); if (safe_mce_sys().select_poll_os_ratio) { VLOG_PARAM_NUMBER("Select Poll OS Ratio", safe_mce_sys().select_poll_os_ratio, MCE_DEFAULT_SELECT_POLL_OS_RATIO, SYS_VAR_SELECT_POLL_OS_RATIO); @@ -533,7 +496,6 @@ void print_vma_global_settings() VLOG_STR_PARAM_STRING("Internal Thread Affinity", safe_mce_sys().internal_thread_affinity_str, MCE_DEFAULT_INTERNAL_THREAD_AFFINITY_STR, SYS_VAR_INTERNAL_THREAD_AFFINITY, safe_mce_sys().internal_thread_affinity_str); VLOG_STR_PARAM_STRING("Internal Thread Cpuset", safe_mce_sys().internal_thread_cpuset, MCE_DEFAULT_INTERNAL_THREAD_CPUSET, SYS_VAR_INTERNAL_THREAD_CPUSET, safe_mce_sys().internal_thread_cpuset); VLOG_PARAM_STRING("Internal Thread Arm CQ", safe_mce_sys().internal_thread_arm_cq_enabled, MCE_DEFAULT_INTERNAL_THREAD_ARM_CQ_ENABLED, SYS_VAR_INTERNAL_THREAD_ARM_CQ, safe_mce_sys().internal_thread_arm_cq_enabled ? "Enabled " : "Disabled"); - VLOG_PARAM_NUMSTR("Internal Thread TCP Handling", safe_mce_sys().internal_thread_tcp_timer_handling, MCE_DEFAULT_INTERNAL_THREAD_TCP_TIMER_HANDLING, SYS_VAR_INTERNAL_THREAD_TCP_TIMER_HANDLING, internal_thread_tcp_timer_handling_str(safe_mce_sys().internal_thread_tcp_timer_handling)); VLOG_PARAM_STRING("Thread mode", safe_mce_sys().thread_mode, MCE_DEFAULT_THREAD_MODE, SYS_VAR_THREAD_MODE, thread_mode_str(safe_mce_sys().thread_mode)); VLOG_PARAM_NUMSTR("Buffer batching mode", safe_mce_sys().buffer_batching_mode, MCE_DEFAULT_BUFFER_BATCHING_MODE, SYS_VAR_BUFFER_BATCHING_MODE, buffer_batching_mode_str(safe_mce_sys().buffer_batching_mode)); switch (safe_mce_sys().mem_alloc_type) { @@ -549,12 +511,7 @@ void print_vma_global_settings() VLOG_PARAM_NUMBER("Num of UC ARPs", safe_mce_sys().neigh_uc_arp_quata, MCE_DEFAULT_NEIGH_UC_ARP_QUATA, SYS_VAR_NEIGH_UC_ARP_QUATA); VLOG_PARAM_NUMBER("UC ARP delay (msec)", safe_mce_sys().neigh_wait_till_send_arp_msec, MCE_DEFAULT_NEIGH_UC_ARP_DELAY_MSEC, SYS_VAR_NEIGH_UC_ARP_DELAY_MSEC); VLOG_PARAM_NUMBER("Num of neigh restart retries", safe_mce_sys().neigh_num_err_retries, MCE_DEFAULT_NEIGH_NUM_ERR_RETRIES, SYS_VAR_NEIGH_NUM_ERR_RETRIES ); - - VLOG_PARAM_STRING("IPOIB support", safe_mce_sys().enable_ipoib, MCE_DEFAULT_IPOIB_FLAG, SYS_VAR_IPOIB, safe_mce_sys().enable_ipoib ? "Enabled " : "Disabled"); VLOG_PARAM_STRING("SocketXtreme mode", safe_mce_sys().enable_socketxtreme, MCE_DEFAULT_SOCKETXTREME, SYS_VAR_SOCKETXTREME, safe_mce_sys().enable_socketxtreme ? "Enabled " : "Disabled"); -#ifdef DEFINED_TSO - VLOG_PARAM_STRING("TSO support", safe_mce_sys().enable_tso, MCE_DEFAULT_TSO, SYS_VAR_TSO, safe_mce_sys().enable_tso ? "Enabled " : "Disabled"); -#endif /* DEFINED_TSO */ VLOG_PARAM_STRING("BF (Blue Flame)", safe_mce_sys().handle_bf, MCE_DEFAULT_BF_FLAG, SYS_VAR_BF, safe_mce_sys().handle_bf ? "Enabled " : "Disabled"); VLOG_PARAM_STRING("fork() support", safe_mce_sys().handle_fork, MCE_DEFAULT_FORK_SUPPORT, SYS_VAR_FORK, safe_mce_sys().handle_fork ? "Enabled " : "Disabled"); VLOG_PARAM_STRING("close on dup2()", safe_mce_sys().close_on_dup2, MCE_DEFAULT_CLOSE_ON_DUP2, SYS_VAR_CLOSE_ON_DUP2, safe_mce_sys().close_on_dup2 ? "Enabled " : "Disabled"); @@ -571,6 +528,7 @@ void print_vma_global_settings() VLOG_PARAM_NUMBER("MSS", safe_mce_sys().lwip_mss, MCE_DEFAULT_MSS, SYS_VAR_MSS); break; } VLOG_PARAM_NUMSTR("TCP CC Algorithm", safe_mce_sys().lwip_cc_algo_mod, MCE_DEFAULT_LWIP_CC_ALGO_MOD, SYS_VAR_TCP_CC_ALGO, lwip_cc_algo_str(safe_mce_sys().lwip_cc_algo_mod)); + VLOG_PARAM_STRING("Deferred close", safe_mce_sys().deferred_close, MCE_DEFAULT_DEFERRED_CLOSE, SYS_VAR_DEFERRED_CLOSE, safe_mce_sys().deferred_close ? "Enabled " : "Disabled"); VLOG_PARAM_STRING("Polling Rx on Tx TCP", safe_mce_sys().rx_poll_on_tx_tcp, MCE_DEFAULT_RX_POLL_ON_TX_TCP, SYS_VAR_VMA_RX_POLL_ON_TX_TCP, safe_mce_sys().rx_poll_on_tx_tcp ? "Enabled " : "Disabled"); VLOG_PARAM_STRING("Trig dummy send getsockname()", safe_mce_sys().trigger_dummy_send_getsockname, MCE_DEFAULT_TRIGGER_DUMMY_SEND_GETSOCKNAME, SYS_VAR_VMA_TRIGGER_DUMMY_SEND_GETSOCKNAME, safe_mce_sys().trigger_dummy_send_getsockname ? "Enabled " : "Disabled"); @@ -699,28 +657,18 @@ static void do_global_ctors_helper() NEW_CTOR(g_p_route_table_mgr, route_table_mgr()); - NEW_CTOR(g_p_igmp_mgr, igmp_mgr()); - NEW_CTOR(g_buffer_pool_rx, buffer_pool(safe_mce_sys().rx_num_bufs, RX_BUF_SIZE(g_p_net_device_table_mgr->get_max_mtu()), - buffer_pool::free_rx_lwip_pbuf_custom)); + buffer_pool::free_rx_lwip_pbuf_custom, + (safe_mce_sys().m_ioctl.user_alloc.flags & VMA_IOCTL_USER_ALLOC_FLAG_RX ? safe_mce_sys().m_ioctl.user_alloc.memalloc : NULL), + (safe_mce_sys().m_ioctl.user_alloc.flags & VMA_IOCTL_USER_ALLOC_FLAG_RX ? safe_mce_sys().m_ioctl.user_alloc.memfree : NULL))); g_buffer_pool_rx->set_RX_TX_for_stats(true); - #ifdef DEFINED_TSO - safe_mce_sys().tx_buf_size = MIN((int)safe_mce_sys().tx_buf_size, (int)0xFF00); - if (safe_mce_sys().tx_buf_size <= get_lwip_tcp_mss(g_p_net_device_table_mgr->get_max_mtu(), safe_mce_sys().lwip_mss)) { - safe_mce_sys().tx_buf_size = 0; - } - NEW_CTOR(g_buffer_pool_tx, buffer_pool(safe_mce_sys().tx_num_bufs, - TX_BUF_SIZE(safe_mce_sys().tx_buf_size ? - safe_mce_sys().tx_buf_size : - get_lwip_tcp_mss(g_p_net_device_table_mgr->get_max_mtu(), safe_mce_sys().lwip_mss)), - buffer_pool::free_tx_lwip_pbuf_custom)); -#else NEW_CTOR(g_buffer_pool_tx, buffer_pool(safe_mce_sys().tx_num_bufs, TX_BUF_SIZE(get_lwip_tcp_mss(g_p_net_device_table_mgr->get_max_mtu(), safe_mce_sys().lwip_mss)), - buffer_pool::free_tx_lwip_pbuf_custom)); -#endif /* DEFINED_TSO */ + buffer_pool::free_tx_lwip_pbuf_custom, + (safe_mce_sys().m_ioctl.user_alloc.flags & VMA_IOCTL_USER_ALLOC_FLAG_TX ? safe_mce_sys().m_ioctl.user_alloc.memalloc : NULL), + (safe_mce_sys().m_ioctl.user_alloc.flags & VMA_IOCTL_USER_ALLOC_FLAG_TX ? safe_mce_sys().m_ioctl.user_alloc.memfree : NULL))); g_buffer_pool_tx->set_RX_TX_for_stats(false); NEW_CTOR(g_tcp_seg_pool, tcp_seg_pool(safe_mce_sys().tx_num_segs_tcp)); @@ -800,7 +748,6 @@ int do_global_ctors() void reset_globals() { g_p_fd_collection = NULL; - g_p_igmp_mgr = NULL; g_p_ip_frag_manager = NULL; g_buffer_pool_rx = NULL; g_buffer_pool_tx = NULL; @@ -865,13 +812,31 @@ void check_netperf_flags() } } -//----------------------------------------------------------------------------- -// library init function -//----------------------------------------------------------------------------- -// __attribute__((constructor)) causes the function to be called when -// library is firsrt loaded -//extern "C" int __attribute__((constructor)) sock_redirect_lib_load_constructor(void) -extern "C" int main_init(void) +/* + * ----------------------------------------------------------------------------- + * library init/exit function + * sock_redirect_lib_load_constructor(void) is used to be called when + * library is loaded + * sock_redirect_lib_load_destructor(void) is used to be called when + * library is unloaded + * + * Note: + * The POSIX standard actually does not require dlclose() to ever unload a library + * from address space on function return. + * See: https://pubs.opengroup.org/onlinepubs/007904975/functions/dlclose.html + * That means other than invalidating the handle, dlclose() can not required to + * do anything at all and real unloading can be delayed. + * It can be important in case owner application uses the library resources. + * Workaround: + * - vma_exit symbol should be visible + * - call dlclose(handle) + * - call dlopen("library", RTLD_NOW | RTLD_NOLOAD) to check if the library is in memory + * - do nothing in case library is unloaded + * or + * call vma_exit() to force the library finalization + * ----------------------------------------------------------------------------- + */ +extern "C" int vma_init(void) { get_orig_funcs(); @@ -900,8 +865,12 @@ extern "C" int main_init(void) return 0; } -//extern "C" int __attribute__((destructor)) sock_redirect_lib_load_destructor(void) -extern "C" int main_destroy(void) +extern "C" EXPORT_SYMBOL int vma_exit(void) { - return free_libvma_resources(); + int rc = 0; + if (g_init_global_ctors_done) { + rc = free_libvma_resources(); + g_init_global_ctors_done = false; + } + return rc; } diff --git a/src/vma/main.h b/src/vma/main.h index 4079b7fbd8..b44ed5237c 100644 --- a/src/vma/main.h +++ b/src/vma/main.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/netlink/link_info.cpp b/src/vma/netlink/link_info.cpp index 0edde95eed..5d992af7c7 100644 --- a/src/vma/netlink/link_info.cpp +++ b/src/vma/netlink/link_info.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/netlink/link_info.h b/src/vma/netlink/link_info.h index 333f63a3bf..50d7242e6c 100644 --- a/src/vma/netlink/link_info.h +++ b/src/vma/netlink/link_info.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/netlink/neigh_info.cpp b/src/vma/netlink/neigh_info.cpp index f5f037e252..91a6f6f0bb 100644 --- a/src/vma/netlink/neigh_info.cpp +++ b/src/vma/netlink/neigh_info.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/netlink/neigh_info.h b/src/vma/netlink/neigh_info.h index 26b780565b..7b86166647 100644 --- a/src/vma/netlink/neigh_info.h +++ b/src/vma/netlink/neigh_info.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/netlink/netlink_compatibility.cpp b/src/vma/netlink/netlink_compatibility.cpp index 7034ebe723..f893ffb041 100644 --- a/src/vma/netlink/netlink_compatibility.cpp +++ b/src/vma/netlink/netlink_compatibility.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "utils/bullseye.h" @@ -121,7 +95,10 @@ in_addr_t nl_object_get_compatible_gateway(struct rtnl_route* nl_route_obj) { struct nl_addr * addr; addr = rtnl_route_nh_get_gateway(nh); if (addr) { - return *(in_addr_t *) nl_addr_get_binary_addr(addr); + void *binary_addr = nl_addr_get_binary_addr(addr); + if (binary_addr) { + return *(in_addr_t *)binary_addr; + } } } return INADDR_ANY; diff --git a/src/vma/netlink/netlink_compatibility.h b/src/vma/netlink/netlink_compatibility.h index b4152a69ae..78257f1a0f 100644 --- a/src/vma/netlink/netlink_compatibility.h +++ b/src/vma/netlink/netlink_compatibility.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/netlink/netlink_wrapper.cpp b/src/vma/netlink/netlink_wrapper.cpp index bdd2934ce1..700f49858e 100644 --- a/src/vma/netlink/netlink_wrapper.cpp +++ b/src/vma/netlink/netlink_wrapper.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/netlink/netlink_wrapper.h b/src/vma/netlink/netlink_wrapper.h index c7912e4470..738f0ab188 100644 --- a/src/vma/netlink/netlink_wrapper.h +++ b/src/vma/netlink/netlink_wrapper.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/netlink/route_info.cpp b/src/vma/netlink/route_info.cpp index 7976091d0d..91e3cce941 100644 --- a/src/vma/netlink/route_info.cpp +++ b/src/vma/netlink/route_info.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -92,18 +66,24 @@ void netlink_route_info::fill(struct rtnl_route* nl_route_obj) unsigned int dst_prefixlen = nl_addr_get_prefixlen(addr); m_route_val->set_dst_mask(htonl(VMA_NETMASK(dst_prefixlen))); m_route_val->set_dst_pref_len(dst_prefixlen); - m_route_val->set_dst_addr(*(in_addr_t *) nl_addr_get_binary_addr(addr)); + void *binary_addr = nl_addr_get_binary_addr(addr); + if (binary_addr) { + m_route_val->set_dst_addr(*(in_addr_t *) binary_addr); + } } addr = rtnl_route_get_pref_src(nl_route_obj); if (addr) { - m_route_val->set_src_addr(*(in_addr_t *) nl_addr_get_binary_addr(addr)); + void *binary_addr = nl_addr_get_binary_addr(addr); + if (binary_addr) { + m_route_val->set_src_addr(*(in_addr_t *) binary_addr); + } } int oif = nl_object_get_compatible_oif(nl_route_obj); if (oif > 0) { m_route_val->set_if_index(oif); - char if_name[IFNAMSIZ]; + char if_name[IFNAMSIZ] = {0}; if_indextoname(oif, if_name); m_route_val->set_if_name(if_name); } diff --git a/src/vma/netlink/route_info.h b/src/vma/netlink/route_info.h index f8fdf3669f..1fa3391413 100644 --- a/src/vma/netlink/route_info.h +++ b/src/vma/netlink/route_info.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/netlink/test_main.cpp b/src/vma/netlink/test_main.cpp index 41ccb16512..045a6cc8b8 100644 --- a/src/vma/netlink/test_main.cpp +++ b/src/vma/netlink/test_main.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -43,28 +17,6 @@ extern uint8_t g_vlogger_level; #define MODULE_NAME "NETLINK_TEST" -class neigh_observer : public observer { - virtual void notify_cb(event * ev) { - if (ev) { -/* - neigh_nl_event* net_ev = dynamic_cast (ev); - if (net_ev->neigh_dst_addr_str == "1.1.1.12") { - //__log_info("!!! IN neigh_observer !!!"); - __log_info("%s", ev->to_str().c_str()); - } -*/ - __log_info("!!! IN neigh_observer !!!"); - neigh_nl_event* nlev = dynamic_cast(ev); - __log_info("%s", ev->to_str().c_str()); - netlink_neigh_info info; - g_p_netlink_handler->get_neigh("1.1.1.1", 1, &info); - __log_info("AFTER get_neigh"); - __log_info("NEIGH STATE=%s", nlev->get_neigh_info()->get_state2str().c_str()); - } - } -}; - - class route_observer : public observer { virtual void notify_cb(event * ev) { if (ev) { @@ -91,10 +43,8 @@ void netlink_test() g_vlogger_level=3; netlink_wrapper* nl = new netlink_wrapper(); g_p_netlink_handler=nl; - neigh_observer neigh_obs; route_observer route_obs; link_observer link_obs; - nl->register_event(nlgrpNEIGH, &neigh_obs); //nl->register_event(nlgrpROUTE, &route_obs); //nl->register_event(nlgrpLINK, &link_obs); int nevents; diff --git a/src/vma/proto/L2_address.cpp b/src/vma/proto/L2_address.cpp index 02e3043ca0..7bacf3287f 100644 --- a/src/vma/proto/L2_address.cpp +++ b/src/vma/proto/L2_address.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -80,25 +54,3 @@ const std::string ETH_addr::to_str() const sprintf(s, ETH_HW_ADDR_PRINT_FMT, ETH_HW_ADDR_PRINT_ADDR(m_p_raw_address)); return (std::string(s)); } - -const std::string IPoIB_addr::to_str() const -{ - char s[100] = ""; - if (m_len > 0) - sprintf(s, IPOIB_HW_ADDR_PRINT_FMT, IPOIB_HW_ADDR_PRINT_ADDR(m_p_raw_address)); - return (std::string(s)); -} - -void IPoIB_addr::extract_qpn() -{ - unsigned char rem_qpn[4]; - - rem_qpn[0] = m_p_raw_address[3]; - rem_qpn[1] = m_p_raw_address[2]; - rem_qpn[2] = m_p_raw_address[1]; - rem_qpn[3] = 0; - memcpy(&m_qpn, rem_qpn, 4); - L2_logdbg("qpn = %#x", m_qpn); -} - - diff --git a/src/vma/proto/L2_address.h b/src/vma/proto/L2_address.h index ce9f931ded..484078d66e 100644 --- a/src/vma/proto/L2_address.h +++ b/src/vma/proto/L2_address.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -81,39 +55,4 @@ class ETH_addr : public L2_address } }; -class IPoIB_addr : public L2_address -{ -public: - - IPoIB_addr(): L2_address(), m_qpn(0) - { - - } - - //This constructor is for UC - IPoIB_addr(address_t const address) : L2_address(address, 20), m_qpn(0) - { - extract_qpn(); - }; - //This constructor is for MC - IPoIB_addr(uint32_t qpn, address_t const address) : L2_address(address, 20), m_qpn(qpn) {}; - ~IPoIB_addr() {}; - - virtual L2_address* clone() const - { - uint32_t qpn = ((IPoIB_addr*)this)->get_qpn(); - return (new IPoIB_addr(qpn, get_address())); - } - - void set_qpn(uint32_t qpn) { m_qpn = qpn; }; - uint32_t get_qpn() { return m_qpn; }; - - const std::string to_str() const; - -private: - uint32_t m_qpn; - - void extract_qpn(); -}; - #endif /* L2_ADDRESS_H */ diff --git a/src/vma/proto/arp.cpp b/src/vma/proto/arp.cpp index 08ef8f3c48..465f073e8a 100644 --- a/src/vma/proto/arp.cpp +++ b/src/vma/proto/arp.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -42,10 +16,8 @@ #define ARP_REQUEST 0x0001 #define HWTYPE_ETHERNET 0x0001 -#define HWTYPE_IB 0x0020 #define IPv4_ALEN 0x04 #define ETHADDR_COPY(dst, src) memcpy(dst, src, ETH_ALEN) -#define IBADDR_COPY(dst, src) memcpy(dst, src, IPOIB_HW_ADDR_LEN) void set_eth_arp_hdr(eth_arp_hdr *p_arph, in_addr_t ipsrc_addr, in_addr_t ipdst_addr, const uint8_t* hwsrc_addr, const uint8_t* hwdst_addr) { @@ -60,16 +32,3 @@ void set_eth_arp_hdr(eth_arp_hdr *p_arph, in_addr_t ipsrc_addr, in_addr_t ipdst_ p_arph->m_dipaddr = ipdst_addr; } -void set_ib_arp_hdr(ib_arp_hdr* p_arph, in_addr_t ipsrc_addr, in_addr_t ipdst_addr, const uint8_t* hwsrc_addr, const uint8_t* hwdst_addr) -{ - p_arph->m_hwtype = htons(HWTYPE_IB); - p_arph->m_proto = htons(ETH_P_IP); - p_arph->m_hwlen = IPOIB_HW_ADDR_LEN; - p_arph->m_protolen = IPv4_ALEN; - p_arph->m_opcode = htons(ARP_REQUEST); - IBADDR_COPY(p_arph->m_shwaddr, hwsrc_addr); - p_arph->m_sipaddr = ipsrc_addr; - if(hwdst_addr) - IBADDR_COPY(p_arph->m_dhwaddr, hwdst_addr); - p_arph->m_dipaddr = ipdst_addr; -} diff --git a/src/vma/proto/arp.h b/src/vma/proto/arp.h index 4a723d6c7e..48389e1eba 100644 --- a/src/vma/proto/arp.h +++ b/src/vma/proto/arp.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -53,20 +27,4 @@ struct __attribute__ ((packed)) eth_arp_hdr void set_eth_arp_hdr(eth_arp_hdr* p_arph, in_addr_t ipsrc_addr, in_addr_t ipdst_addr, const uint8_t* hwsrc_addr, const uint8_t* hwdst_addr); -struct __attribute__ ((packed)) ib_arp_hdr -{ - uint16_t m_hwtype; - uint16_t m_proto; - uint8_t m_hwlen; - uint8_t m_protolen; - uint16_t m_opcode; - uint8_t m_shwaddr[IPOIB_HW_ADDR_LEN]; - uint32_t m_sipaddr; - uint8_t m_dhwaddr[IPOIB_HW_ADDR_LEN]; - uint32_t m_dipaddr; -}; - -void set_ib_arp_hdr(ib_arp_hdr* p_arph, in_addr_t ipsrc_addr, in_addr_t ipdst_addr, const uint8_t* hwsrc_addr, const uint8_t* hwdst_addr); - - #endif diff --git a/src/vma/proto/dst_entry.cpp b/src/vma/proto/dst_entry.cpp index c4c17aa4a1..5e92b5a45b 100644 --- a/src/vma/proto/dst_entry.cpp +++ b/src/vma/proto/dst_entry.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -87,12 +61,16 @@ dst_entry::~dst_entry() m_p_tx_mem_buf_desc_list = NULL; } - m_p_net_dev_val->release_ring(m_ring_alloc_logic.get_key()); + if (m_p_net_dev_val->release_ring(m_ring_alloc_logic.get_key()) < 0){ + dst_logwarn("Failed to release ring for allocation key %s", m_ring_alloc_logic.get_key()->to_str()); + } m_p_ring = NULL; } if (m_p_net_dev_entry && m_p_net_dev_val) { - g_p_net_device_table_mgr->unregister_observer(m_p_net_dev_val->get_local_addr(), this); + if(!g_p_net_device_table_mgr->unregister_observer(m_p_net_dev_val->get_local_addr(), this)) { + dst_logwarn("Failed to unregister observer for local address %d.%d.%d.%d", NIPQUAD(m_p_net_dev_val->get_local_addr())); + } } if (m_p_send_wqe_handler) { @@ -180,7 +158,7 @@ bool dst_entry::update_net_dev_val() if (m_p_net_dev_val) { // more resource clean and alloc... - ret_val = alloc_transport_dep_res(); + ret_val = alloc_neigh_val(); } else { dst_logdbg("Netdev is not offloaded fallback to OS"); @@ -315,11 +293,9 @@ bool dst_entry::resolve_ring() delete[] m_sge; m_sge = NULL; } -#ifdef DEFINED_TSO - m_sge = new (nothrow) struct ibv_sge [m_p_ring->get_max_send_sge()]; -#else + m_sge = new (nothrow) struct ibv_sge [2]; -#endif /* DEFINED_TSO */ + if (!m_sge) { dst_logpanic("%s Failed to allocate send SGE", to_str().c_str()); } @@ -341,7 +317,9 @@ bool dst_entry::release_ring() m_p_tx_mem_buf_desc_list = NULL; } dst_logdbg("releasing a ring"); - m_p_net_dev_val->release_ring(m_ring_alloc_logic.get_key()); + if (m_p_net_dev_val->release_ring(m_ring_alloc_logic.get_key()) < 0){ + dst_logwarn("Failed to release ring for allocation key %s", m_ring_alloc_logic.get_key()->to_str()); + } m_p_ring = NULL; } ret_val = true; @@ -411,76 +389,13 @@ bool dst_entry::conf_l2_hdr_and_snd_wqe_eth() return ret_val; } - -bool dst_entry::conf_l2_hdr_and_snd_wqe_ib() -{ - bool ret_val = false; - neigh_ib_val *neigh_ib = dynamic_cast(m_p_neigh_val); - - BULLSEYE_EXCLUDE_BLOCK_START - if (!neigh_ib) { - dst_logerr("Dynamic cast to neigh_ib failed, can't build proper ibv_send_wqe: header"); - BULLSEYE_EXCLUDE_BLOCK_END - } - else { - uint32_t qpn = neigh_ib->get_qpn(); - uint32_t qkey = neigh_ib->get_qkey(); - struct ibv_ah *ah = (struct ibv_ah *)neigh_ib->get_ah(); - - //Maybe we after invalidation so we free the wqe_handler since we are going to build it from scratch - if (m_p_send_wqe_handler) { - delete m_p_send_wqe_handler; - m_p_send_wqe_handler = NULL; - } - m_p_send_wqe_handler = new wqe_send_ib_handler(); - - BULLSEYE_EXCLUDE_BLOCK_START - if (!m_p_send_wqe_handler) { - dst_logpanic("%s Failed to allocate send WQE handler", to_str().c_str()); - } - BULLSEYE_EXCLUDE_BLOCK_END - ((wqe_send_ib_handler *)(m_p_send_wqe_handler))->init_inline_ib_wqe(m_inline_send_wqe, get_sge_lst_4_inline_send(), get_inline_sge_num(), ah, qpn, qkey); - ((wqe_send_ib_handler*)(m_p_send_wqe_handler))->init_not_inline_ib_wqe(m_not_inline_send_wqe, get_sge_lst_4_not_inline_send(), 1, ah, qpn, qkey); - ((wqe_send_ib_handler*)(m_p_send_wqe_handler))->init_ib_wqe(m_fragmented_send_wqe, get_sge_lst_4_not_inline_send(), 1, ah, qpn, qkey); - m_header.configure_ipoib_headers(); - init_sge(); - - ret_val = true; - } - return ret_val; -} - bool dst_entry::conf_hdrs_and_snd_wqe() { - transport_type_t tranposrt = VMA_TRANSPORT_IB; - bool ret_val = true; - dst_logdbg("dst_entry %s configuring the header template", to_str().c_str()); configure_ip_header(&m_header); - if (m_p_net_dev_val) { - tranposrt = m_p_net_dev_val->get_transport_type(); - } - - switch (tranposrt) { - case VMA_TRANSPORT_ETH: - ret_val = conf_l2_hdr_and_snd_wqe_eth(); - break; - case VMA_TRANSPORT_IB: - default: - ret_val = conf_l2_hdr_and_snd_wqe_ib(); - break; - } - return ret_val; -} - -//Implementation of pure virtual function of neigh_observer -transport_type_t dst_entry::get_obs_transport_type() const -{ - if(m_p_net_dev_val) - return(m_p_net_dev_val->get_transport_type()); - return VMA_TRANSPORT_UNKNOWN; + return conf_l2_hdr_and_snd_wqe_eth(); } bool dst_entry::offloaded_according_to_rules() @@ -528,11 +443,7 @@ bool dst_entry::prepare_to_send(struct vma_rate_limit_t &rate_limit, bool skip_r is_ofloaded = true; modify_ratelimit(rate_limit); if (resolve_neigh()) { - if (get_obs_transport_type() == VMA_TRANSPORT_ETH) { - dst_logdbg("local mac: %s peer mac: %s", m_p_net_dev_val->get_l2_address()->to_str().c_str(), m_p_neigh_val->get_l2_address()->to_str().c_str()); - } else { - dst_logdbg("peer L2 address: %s", m_p_neigh_val->get_l2_address()->to_str().c_str()); - } + dst_logdbg("local mac: %s peer mac: %s", m_p_net_dev_val->get_l2_address()->to_str().c_str(), m_p_neigh_val->get_l2_address()->to_str().c_str()); configure_headers(); m_id = m_p_ring->generate_id(m_p_net_dev_val->get_l2_address()->get_address(), m_p_neigh_val->get_l2_address()->get_address(), @@ -617,6 +528,8 @@ void dst_entry::do_ring_migration(lock_base& socket_lock, resource_allocation_ke socket_lock.lock(); return; } + + // coverity[use_same_locks_for_read_and_modify:FALSE] if (new_ring == m_p_ring) { if (m_p_net_dev_val->release_ring(&old_key) < 0) { dst_logerr("Failed to release ring for allocation key %s", @@ -640,11 +553,9 @@ void dst_entry::do_ring_migration(lock_base& socket_lock, resource_allocation_ke delete[] m_sge; m_sge = NULL; } -#ifdef DEFINED_TSO - m_sge = new (nothrow) struct ibv_sge [m_p_ring->get_max_send_sge()]; -#else + m_sge = new (nothrow) struct ibv_sge [2]; -#endif /* DEFINED_TSO */ + if (!m_sge) { dst_logpanic("%s Failed to allocate send SGE", to_str().c_str()); } @@ -661,7 +572,9 @@ void dst_entry::do_ring_migration(lock_base& socket_lock, resource_allocation_ke old_ring->mem_buf_tx_release(tmp_list, true); } - m_p_net_dev_val->release_ring(&old_key); + if (m_p_net_dev_val->release_ring(&old_key)<0) { + dst_logwarn("Failed to release ring for allocation key %s", old_key.to_str()); + } socket_lock.lock(); } @@ -709,33 +622,15 @@ ssize_t dst_entry::pass_buff_to_neigh(const iovec * p_iov, size_t sz_iov, uint16 return ret_val; } -bool dst_entry::alloc_transport_dep_res() -{ - return alloc_neigh_val(get_obs_transport_type()); -} - -bool dst_entry::alloc_neigh_val(transport_type_t tranport) +bool dst_entry::alloc_neigh_val() { - bool ret_val = false; - if (m_p_neigh_val) { delete m_p_neigh_val; m_p_neigh_val = NULL; } - switch (tranport) { - case VMA_TRANSPORT_IB: - m_p_neigh_val = new neigh_ib_val; - break; - case VMA_TRANSPORT_ETH: - default: - m_p_neigh_val = new neigh_eth_val; - break; - } - if (m_p_neigh_val) { - ret_val = true; - } - return ret_val; + m_p_neigh_val = new neigh_val; + return (!!m_p_neigh_val); } void dst_entry::return_buffers_pool() diff --git a/src/vma/proto/dst_entry.h b/src/vma/proto/dst_entry.h index 12c7b05f9b..6cbbe01cce 100644 --- a/src/vma/proto/dst_entry.h +++ b/src/vma/proto/dst_entry.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -48,7 +22,6 @@ #include "vma/dev/net_device_val.h" #include "vma/dev/net_device_table_mgr.h" #include "vma/dev/wqe_send_handler.h" -#include "vma/dev/wqe_send_ib_handler.h" #include "vma/dev/ring.h" #include "vma/dev/ring_allocation_logic.h" #include "vma/infra/sender.h" @@ -62,14 +35,8 @@ struct socket_data { uint32_t pcp; }; -typedef struct { - vma_wr_tx_packet_attr flags; - uint16_t mss; -} vma_send_attr; - -class dst_entry : public cache_observer, public tostr, public neigh_observer +class dst_entry : public cache_observer, public tostr { - public: dst_entry(in_addr_t dst_ip, uint16_t dst_port, uint16_t src_port, socket_data &sock_data, resource_allocation_key &ring_alloc_logic); virtual ~dst_entry(); @@ -77,15 +44,9 @@ class dst_entry : public cache_observer, public tostr, public neigh_observer virtual void notify_cb(); virtual bool prepare_to_send(struct vma_rate_limit_t &rate_limit, bool skip_rules=false, bool is_connect=false); -#ifdef DEFINED_TSO - virtual ssize_t fast_send(const iovec* p_iov, const ssize_t sz_iov, vma_send_attr attr) = 0; - virtual ssize_t slow_send(const iovec* p_iov, const ssize_t sz_iov, vma_send_attr attr, - struct vma_rate_limit_t &rate_limit, int flags = 0, - socket_fd_api* sock = 0, tx_call_t call_type = TX_UNDEF) = 0; -#else + virtual ssize_t slow_send(const iovec* p_iov, size_t sz_iov, bool is_dummy, struct vma_rate_limit_t &rate_limit, bool b_blocked = true, bool is_rexmit = false, int flags = 0, socket_fd_api* sock = 0, tx_call_t call_type = TX_UNDEF) = 0 ; virtual ssize_t fast_send(const iovec* p_iov, const ssize_t sz_iov, bool is_dummy, bool b_blocked = true, bool is_rexmit = false) = 0; -#endif /* DEFINED_TSO */ bool try_migrate_ring(lock_base& socket_lock); @@ -100,8 +61,6 @@ class dst_entry : public cache_observer, public tostr, public neigh_observer int modify_ratelimit(struct vma_rate_limit_t &rate_limit); bool update_ring_alloc_logic(int fd, lock_base & socket_lock, resource_allocation_key & ring_alloc_logic); - virtual transport_type_t get_obs_transport_type() const; - void return_buffers_pool(); int get_route_mtu(); inline void set_ip_ttl(uint8_t ttl) { m_header.set_ip_ttl(ttl); } @@ -121,9 +80,9 @@ class dst_entry : public cache_observer, public tostr, public neigh_observer in_addr_t m_pkt_src_ip; // source IP address copied into IP header lock_mutex_recursive m_slow_path_lock; lock_mutex m_tx_migration_lock; - vma_ibv_send_wr m_inline_send_wqe; - vma_ibv_send_wr m_not_inline_send_wqe; - vma_ibv_send_wr m_fragmented_send_wqe; + ibv_send_wr m_inline_send_wqe; + ibv_send_wr m_not_inline_send_wqe; + ibv_send_wr m_fragmented_send_wqe; wqe_send_handler* m_p_send_wqe_handler; ibv_sge *m_sge; route_entry* m_p_rt_entry; @@ -145,7 +104,7 @@ class dst_entry : public cache_observer, public tostr, public neigh_observer uint8_t m_pcp; bool m_b_is_initialized; - vma_ibv_send_wr* m_p_send_wqe; + ibv_send_wr* m_p_send_wqe; uint32_t m_max_inline; ring_user_id_t m_id; uint16_t m_max_ip_payload_size; @@ -171,19 +130,16 @@ class dst_entry : public cache_observer, public tostr, public neigh_observer virtual void configure_headers() { conf_hdrs_and_snd_wqe();}; bool conf_hdrs_and_snd_wqe(); virtual bool conf_l2_hdr_and_snd_wqe_eth(); - virtual bool conf_l2_hdr_and_snd_wqe_ib(); virtual void init_sge() {}; - bool alloc_transport_dep_res(); - bool alloc_neigh_val(transport_type_t tranport); - + bool alloc_neigh_val(); void do_ring_migration(lock_base& socket_lock, resource_allocation_key &old_key); inline void set_tx_buff_list_pending(bool is_pending = true) {m_b_tx_mem_buf_desc_list_pending = is_pending;} int get_priority_by_tc_class(uint32_t tc_clas); - inline void send_ring_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) + inline void send_ring_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) { if (unlikely(is_set(attr, VMA_TX_PACKET_DUMMY))) { if (m_p_ring->get_hw_dummy_send_support(id, p_send_wqe)) { - vma_ibv_wr_opcode last_opcode = m_p_send_wqe_handler->set_opcode(*p_send_wqe, VMA_IBV_WR_NOP); + ibv_wr_opcode last_opcode = m_p_send_wqe_handler->set_opcode(*p_send_wqe, VMA_IBV_WR_NOP); m_p_ring->send_ring_buffer(id, p_send_wqe, attr); m_p_send_wqe_handler->set_opcode(*p_send_wqe, last_opcode); } else { diff --git a/src/vma/proto/dst_entry_tcp.cpp b/src/vma/proto/dst_entry_tcp.cpp index 5d5dc678e8..04cacec353 100644 --- a/src/vma/proto/dst_entry_tcp.cpp +++ b/src/vma/proto/dst_entry_tcp.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -66,179 +40,6 @@ transport_t dst_entry_tcp::get_transport(sockaddr_in to) return TRANS_VMA; } -#ifdef DEFINED_TSO -ssize_t dst_entry_tcp::fast_send(const iovec* p_iov, const ssize_t sz_iov, vma_send_attr attr) -{ - int ret = 0; - tx_packet_template_t* p_pkt; - tcp_iovec* p_tcp_iov = NULL; - size_t hdr_alignment_diff = 0; - - /* The header is aligned for fast copy but we need to maintain this diff - * in order to get the real header pointer easily - */ - hdr_alignment_diff = m_header.m_aligned_l2_l3_len - m_header.m_total_hdr_len; - - p_tcp_iov = (tcp_iovec*)p_iov; - - attr.flags = (vma_wr_tx_packet_attr)(attr.flags | VMA_TX_PACKET_L3_CSUM | VMA_TX_PACKET_L4_CSUM); - - /* Supported scenarios: - * 1. Standard: - * Use lwip memory buffer (zero copy) in case iov consists of single buffer with single TCP packet. - * 2. Large send offload: - * Use lwip sequence of memory buffers (zero copy) in case attribute is set as TSO and no retransmission. - * Size of iov can be one or more. - * 3. Simple: - * Use intermediate buffers for data send - */ - if (likely(m_p_ring->is_active_member(p_tcp_iov->p_desc->p_desc_owner, m_id) && - (is_set(attr.flags, (vma_wr_tx_packet_attr)(VMA_TX_PACKET_TSO)) || - (sz_iov == 1 && !is_set(attr.flags, (vma_wr_tx_packet_attr)(VMA_TX_PACKET_REXMIT)))))) { - size_t total_packet_len = 0; - vma_ibv_send_wr send_wqe; - wqe_send_handler send_wqe_h; - - /* iov_base is a pointer to TCP header and data - * so p_pkt should point to L2 - */ - p_pkt = (tx_packet_template_t*)((uint8_t*)p_tcp_iov[0].iovec.iov_base - m_header.m_aligned_l2_l3_len); - - /* iov_len is a size of TCP header and data - * m_total_hdr_len is a size of L2/L3 header - */ - total_packet_len = p_tcp_iov[0].iovec.iov_len + m_header.m_total_hdr_len; - - /* copy just L2/L3 headers to p_pkt */ - m_header.copy_l2_ip_hdr(p_pkt); - - /* L3(Total Length) field means nothing in case TSO usage and can be set as zero but - * setting this field to actual value allows to do valid call for scenario - * when payload size less or equal to mss - */ - p_pkt->hdr.m_ip_hdr.tot_len = (htons)(p_tcp_iov[0].iovec.iov_len + m_header.m_ip_header_len); - - if ((total_packet_len < m_max_inline) && (1 == sz_iov)) { - m_p_send_wqe = &m_inline_send_wqe; - m_sge[0].addr = (uintptr_t)((uint8_t*)p_pkt + hdr_alignment_diff); - m_sge[0].length = total_packet_len; - } else if (is_set(attr.flags, (vma_wr_tx_packet_attr)(VMA_TX_PACKET_TSO))) { - /* update send work request. do not expect noninlined scenario */ - send_wqe_h.init_not_inline_wqe(send_wqe, m_sge, sz_iov); - send_wqe_h.enable_tso(send_wqe, - (void *)((uint8_t*)p_pkt + hdr_alignment_diff), - m_header.m_total_hdr_len + p_pkt->hdr.m_tcp_hdr.doff * 4, - attr.mss); - m_p_send_wqe = &send_wqe; - m_sge[0].addr = (uintptr_t)((uint8_t *)&p_pkt->hdr.m_tcp_hdr + p_pkt->hdr.m_tcp_hdr.doff * 4); - m_sge[0].length = p_tcp_iov[0].iovec.iov_len - p_pkt->hdr.m_tcp_hdr.doff * 4; - } else { - m_p_send_wqe = &m_not_inline_send_wqe; - m_sge[0].addr = (uintptr_t)((uint8_t*)p_pkt + hdr_alignment_diff); - m_sge[0].length = total_packet_len; - } - - /* save pointers to ip and tcp headers for software checksum calculation */ - p_tcp_iov[0].p_desc->tx.p_ip_h = &p_pkt->hdr.m_ip_hdr; - p_tcp_iov[0].p_desc->tx.p_tcp_h =(struct tcphdr*)((uint8_t*)(&(p_pkt->hdr.m_ip_hdr)) + sizeof(p_pkt->hdr.m_ip_hdr)); - p_tcp_iov[0].p_desc->lwip_pbuf.pbuf.ref++; - - /* set wr_id as a pointer to memory descriptor */ - m_p_send_wqe->wr_id = (uintptr_t)p_tcp_iov[0].p_desc; - - /* Update scatter gather element list - * ref counter is incremented for the first memory descriptor only because it is needed - * for processing send wr completion (tx batching mode) - */ - m_sge[0].lkey = m_p_ring->get_tx_lkey(m_id); - for (int i = 1; i < sz_iov; ++i) { - m_sge[i].addr = (uintptr_t)p_tcp_iov[i].iovec.iov_base; - m_sge[i].length = p_tcp_iov[i].iovec.iov_len; - m_sge[i].lkey = m_sge[0].lkey; - } - - send_lwip_buffer(m_id, m_p_send_wqe, attr.flags); - - } else { // We don'nt support inline in this case, since we believe that this a very rare case - mem_buf_desc_t *p_mem_buf_desc; - size_t total_packet_len = 0; - - p_mem_buf_desc = get_buffer(is_set(attr.flags, VMA_TX_PACKET_BLOCK)); - if (p_mem_buf_desc == NULL) { - ret = -1; - goto out; - } - - m_header.copy_l2_ip_hdr((tx_packet_template_t*)p_mem_buf_desc->p_buffer); - - // Actually this is not the real packet len we will subtract the alignment diff at the end of the copy - total_packet_len = m_header.m_aligned_l2_l3_len; - - for (int i = 0; i < sz_iov; ++i) { - memcpy(p_mem_buf_desc->p_buffer + total_packet_len, p_tcp_iov[i].iovec.iov_base, p_tcp_iov[i].iovec.iov_len); - total_packet_len += p_tcp_iov[i].iovec.iov_len; - } - - m_sge[0].addr = (uintptr_t)(p_mem_buf_desc->p_buffer + hdr_alignment_diff); - m_sge[0].length = total_packet_len - hdr_alignment_diff; - m_sge[0].lkey = m_p_ring->get_tx_lkey(m_id); - - p_pkt = (tx_packet_template_t*)((uint8_t*)p_mem_buf_desc->p_buffer); - p_pkt->hdr.m_ip_hdr.tot_len = (htons)(m_sge[0].length - m_header.m_transport_header_len); - - p_mem_buf_desc->tx.p_ip_h = &p_pkt->hdr.m_ip_hdr; - p_mem_buf_desc->tx.p_tcp_h = (struct tcphdr*)((uint8_t*)(&(p_pkt->hdr.m_ip_hdr))+sizeof(p_pkt->hdr.m_ip_hdr)); - - m_p_send_wqe = &m_not_inline_send_wqe; - m_p_send_wqe->wr_id = (uintptr_t)p_mem_buf_desc; - - send_ring_buffer(m_id, m_p_send_wqe, attr.flags); - - } - - if (unlikely(m_p_tx_mem_buf_desc_list == NULL)) { - m_p_tx_mem_buf_desc_list = m_p_ring->mem_buf_tx_get(m_id, - is_set(attr.flags, VMA_TX_PACKET_BLOCK), m_n_sysvar_tx_bufs_batch_tcp); - } - -out: - if (unlikely(is_set(attr.flags, VMA_TX_PACKET_REXMIT))) { - m_p_ring->inc_tx_retransmissions_stats(m_id); - } - - return ret; -} - -ssize_t dst_entry_tcp::slow_send(const iovec* p_iov, const ssize_t sz_iov, vma_send_attr attr, - struct vma_rate_limit_t &rate_limit, int flags /*= 0*/, - socket_fd_api* sock /*= 0*/, tx_call_t call_type /*= 0*/) -{ - ssize_t ret_val = -1; - - NOT_IN_USE(sock); - NOT_IN_USE(call_type); - NOT_IN_USE(flags); - - m_slow_path_lock.lock(); - - prepare_to_send(rate_limit, true); - - if (m_b_is_offloaded) { - if (!is_valid()) { // That means that the neigh is not resolved yet - //there is a copy inside so we should not update any ref-counts - ret_val = pass_buff_to_neigh(p_iov, sz_iov); - } - else { - ret_val = fast_send(p_iov, sz_iov, attr); - } - } - else { - dst_tcp_logdbg("Dst_entry is not offloaded, bug?"); - } - m_slow_path_lock.unlock(); - return ret_val; -} -#else ssize_t dst_entry_tcp::fast_send(const iovec* p_iov, const ssize_t sz_iov, bool is_dummy, bool b_blocked /*= true*/, bool is_rexmit /*= false*/) { int ret = 0; @@ -376,7 +177,6 @@ ssize_t dst_entry_tcp::slow_send(const iovec* p_iov, size_t sz_iov, bool is_dumm m_slow_path_lock.unlock(); return ret_val; } -#endif /* DEFINED_TSO */ ssize_t dst_entry_tcp::slow_send_neigh( const iovec* p_iov, size_t sz_iov, struct vma_rate_limit_t &rate_limit) { diff --git a/src/vma/proto/dst_entry_tcp.h b/src/vma/proto/dst_entry_tcp.h index 50b5db4337..147be2ea33 100644 --- a/src/vma/proto/dst_entry_tcp.h +++ b/src/vma/proto/dst_entry_tcp.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -50,15 +24,8 @@ class dst_entry_tcp : public dst_entry socket_data &data, resource_allocation_key &ring_alloc_logic); virtual ~dst_entry_tcp(); -#ifdef DEFINED_TSO - ssize_t fast_send(const iovec* p_iov, const ssize_t sz_iov, vma_send_attr attr); - ssize_t slow_send(const iovec* p_iov, const ssize_t sz_iov, vma_send_attr attr, - struct vma_rate_limit_t &rate_limit, int flags = 0, - socket_fd_api* sock = 0, tx_call_t call_type = TX_UNDEF); -#else virtual ssize_t fast_send(const iovec* p_iov, const ssize_t sz_iov, bool is_dummy, bool b_blocked = true, bool is_rexmit = false); ssize_t slow_send(const iovec* p_iov, size_t sz_iov, bool is_dummy, struct vma_rate_limit_t &rate_limit, bool b_blocked = true, bool is_rexmit = false, int flags = 0, socket_fd_api* sock = 0, tx_call_t call_type = TX_UNDEF); -#endif /* DEFINED_TSO */ ssize_t slow_send_neigh(const iovec* p_iov, size_t sz_iov, struct vma_rate_limit_t &rate_limit); mem_buf_desc_t* get_buffer(bool b_blocked = false); @@ -77,11 +44,11 @@ class dst_entry_tcp : public dst_entry private: const uint32_t m_n_sysvar_tx_bufs_batch_tcp; - inline void send_lwip_buffer(ring_user_id_t id, vma_ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) + inline void send_lwip_buffer(ring_user_id_t id, ibv_send_wr* p_send_wqe, vma_wr_tx_packet_attr attr) { if (unlikely(is_set(attr, VMA_TX_PACKET_DUMMY))) { if (m_p_ring->get_hw_dummy_send_support(id, p_send_wqe)) { - vma_ibv_wr_opcode last_opcode = m_p_send_wqe_handler->set_opcode(*p_send_wqe, VMA_IBV_WR_NOP); + ibv_wr_opcode last_opcode = m_p_send_wqe_handler->set_opcode(*p_send_wqe, VMA_IBV_WR_NOP); m_p_ring->send_lwip_buffer(id, p_send_wqe, attr); m_p_send_wqe_handler->set_opcode(*p_send_wqe, last_opcode); } diff --git a/src/vma/proto/dst_entry_udp.cpp b/src/vma/proto/dst_entry_udp.cpp index e34ec221df..d485e8bcc0 100644 --- a/src/vma/proto/dst_entry_udp.cpp +++ b/src/vma/proto/dst_entry_udp.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -119,9 +93,6 @@ inline ssize_t dst_entry_udp::fast_send_not_fragmented(const iovec* p_iov, const //so we just need to update the payload addr + len m_sge[1].length = p_iov[0].iov_len; m_sge[1].addr = (uintptr_t)p_iov[0].iov_base; -#ifdef DEFINED_TSO - m_sge[1].lkey = m_p_ring->get_tx_lkey(m_id); -#endif /* DEFINED_TSO */ } else { m_p_send_wqe = &m_not_inline_send_wqe; @@ -147,9 +118,6 @@ inline ssize_t dst_entry_udp::fast_send_not_fragmented(const iovec* p_iov, const // Update the payload addr + len m_sge[1].length = sz_data_payload + hdr_len; m_sge[1].addr = (uintptr_t)(p_mem_buf_desc->p_buffer + (uint8_t)m_header.m_transport_header_tx_offset); -#ifdef DEFINED_TSO - m_sge[1].lkey = m_p_ring->get_tx_lkey(m_id); -#endif /* DEFINED_TSO */ // Calc payload start point (after the udp header if present else just after ip header) uint8_t* p_payload = p_mem_buf_desc->p_buffer + m_header.m_transport_header_tx_offset + hdr_len; @@ -274,9 +242,6 @@ ssize_t dst_entry_udp::fast_send_fragmented(const iovec* p_iov, const ssize_t sz m_sge[1].addr = (uintptr_t)(p_mem_buf_desc->p_buffer + (uint8_t)m_header.m_transport_header_tx_offset); m_sge[1].length = sz_user_data_to_copy + hdr_len; -#ifdef DEFINED_TSO - m_sge[1].lkey = m_p_ring->get_tx_lkey(m_id); -#endif /* DEFINED_TSO */ m_p_send_wqe->wr_id = (uintptr_t)p_mem_buf_desc; dst_udp_logfunc("%s packet_sz=%d, payload_sz=%d, ip_offset=%d id=%d", m_header.to_str().c_str(), @@ -303,55 +268,6 @@ ssize_t dst_entry_udp::fast_send_fragmented(const iovec* p_iov, const ssize_t sz return sz_data_payload; } -#ifdef DEFINED_TSO -ssize_t dst_entry_udp::fast_send(const iovec* p_iov, const ssize_t sz_iov, vma_send_attr attr) -{ - ssize_t sz_data_payload = check_payload_size(p_iov, sz_iov); - if (unlikely(0 > sz_data_payload)) { // The errno is set inside check_payload_size. - return -1; - } - - // Calc udp payload size - size_t sz_udp_payload = sz_data_payload + sizeof(struct udphdr); - if (sz_udp_payload <= (size_t)m_max_udp_payload_size) { - attr.flags = (vma_wr_tx_packet_attr)(attr.flags | VMA_TX_PACKET_L3_CSUM | VMA_TX_PACKET_L4_CSUM); - return fast_send_not_fragmented(p_iov, sz_iov, attr.flags, sz_udp_payload, sz_data_payload); - } else { - attr.flags = (vma_wr_tx_packet_attr)(attr.flags | VMA_TX_PACKET_L3_CSUM); - return fast_send_fragmented(p_iov, sz_iov, attr.flags, sz_udp_payload, sz_data_payload); - } -} - -ssize_t dst_entry_udp::slow_send(const iovec* p_iov, const ssize_t sz_iov, vma_send_attr attr, - struct vma_rate_limit_t &rate_limit, int flags /*= 0*/, - socket_fd_api* sock /*= 0*/, tx_call_t call_type /*= 0*/) -{ - ssize_t ret_val = 0; - - dst_udp_logdbg("In slow send"); - - prepare_to_send(rate_limit, false); - - if (m_b_force_os || !m_b_is_offloaded) { - struct sockaddr_in to_saddr; - to_saddr.sin_port = m_dst_port; - to_saddr.sin_addr.s_addr = m_dst_ip.get_in_addr(); - to_saddr.sin_family = AF_INET; - dst_udp_logdbg("Calling to tx_os"); - ret_val = sock->tx_os(call_type, p_iov, sz_iov, flags, (const struct sockaddr*)&to_saddr, sizeof(struct sockaddr_in)); - } - else { - if (!is_valid()) { // That means that the neigh is not resolved yet - ret_val = pass_buff_to_neigh(p_iov, sz_iov); - } - else { - ret_val = fast_send(p_iov, sz_iov, attr); - } - } - - return ret_val; -} -#else ssize_t dst_entry_udp::fast_send(const iovec* p_iov, const ssize_t sz_iov, bool is_dummy, bool b_blocked /*=true*/, bool is_rexmit /*=false*/) { @@ -404,15 +320,11 @@ ssize_t dst_entry_udp::slow_send(const iovec* p_iov, size_t sz_iov, bool is_dumm return ret_val; } -#endif /* DEFINED_TSO */ void dst_entry_udp::init_sge() { m_sge[0].length = m_header.m_total_hdr_len; m_sge[0].addr = m_header.m_actual_hdr_addr; -#ifdef DEFINED_TSO - m_sge[0].lkey = m_p_ring->get_tx_lkey(m_id); -#endif /* DEFINED_TSO */ } ssize_t dst_entry_udp::check_payload_size(const iovec* p_iov, ssize_t sz_iov) diff --git a/src/vma/proto/dst_entry_udp.h b/src/vma/proto/dst_entry_udp.h index 3d548431e3..cabcd4f821 100644 --- a/src/vma/proto/dst_entry_udp.h +++ b/src/vma/proto/dst_entry_udp.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -43,15 +17,8 @@ class dst_entry_udp : public dst_entry socket_data &sock_data, resource_allocation_key &ring_alloc_logic); virtual ~dst_entry_udp(); -#ifdef DEFINED_TSO - ssize_t fast_send(const iovec* p_iov, const ssize_t sz_iov, vma_send_attr attr); - ssize_t slow_send(const iovec* p_iov, const ssize_t sz_iov, vma_send_attr attr, - struct vma_rate_limit_t &rate_limit, int flags = 0, - socket_fd_api* sock = 0, tx_call_t call_type = TX_UNDEF); -#else virtual ssize_t slow_send(const iovec* p_iov, size_t sz_iov, bool is_dummy, struct vma_rate_limit_t &rate_limit, bool b_blocked = true, bool is_rexmit = false, int flags = 0, socket_fd_api* sock = 0, tx_call_t call_type = TX_UNDEF); virtual ssize_t fast_send(const iovec* p_iov, const ssize_t sz_iov, bool is_dummy, bool b_blocked = true, bool is_rexmit = false); -#endif /* DEFINED_TSO */ protected: virtual transport_t get_transport(sockaddr_in to); diff --git a/src/vma/proto/dst_entry_udp_mc.cpp b/src/vma/proto/dst_entry_udp_mc.cpp index 3cdbe411b7..9fa27a7925 100644 --- a/src/vma/proto/dst_entry_udp_mc.cpp +++ b/src/vma/proto/dst_entry_udp_mc.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -59,30 +33,6 @@ dst_entry_udp_mc::~dst_entry_udp_mc() dst_udp_mc_logdbg("%s", to_str().c_str()); } -//The following function supposed to be called under m_lock -bool dst_entry_udp_mc::conf_l2_hdr_and_snd_wqe_ib() -{ - bool ret_val = false; - - dst_udp_mc_logfunc("%s", to_str().c_str()); - - ret_val = dst_entry_udp::conf_l2_hdr_and_snd_wqe_ib(); - - if (ret_val && !m_b_mc_loopback_enabled && m_p_send_wqe_handler) { - wqe_send_ib_handler *wqe_ib = dynamic_cast(m_p_send_wqe_handler); - if (wqe_ib) { - //Since checksum fails when packet contains an immediate header we don't enable an immediate header - //So MC loopback disable is NOT SUPPORTED! - //wqe_ib->enable_imm_data(m_inline_send_wqe); - //wqe_ib->enable_imm_data(m_not_inline_send_wqe); - } - else { - ret_val = false; - } - } - return ret_val; -} - void dst_entry_udp_mc::set_src_addr() { m_pkt_src_ip = INADDR_ANY; @@ -115,7 +65,7 @@ bool dst_entry_udp_mc::resolve_net_dev(bool is_connect) if (m_p_net_dev_entry) { m_p_net_dev_entry->get_val(m_p_net_dev_val); if (m_p_net_dev_val) { - ret_val = alloc_transport_dep_res(); + ret_val = alloc_neigh_val(); } else { dst_udp_mc_logdbg("Valid netdev value not found"); diff --git a/src/vma/proto/dst_entry_udp_mc.h b/src/vma/proto/dst_entry_udp_mc.h index fd58c639e1..02fb45f4e0 100644 --- a/src/vma/proto/dst_entry_udp_mc.h +++ b/src/vma/proto/dst_entry_udp_mc.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -44,8 +18,6 @@ class dst_entry_udp_mc : public dst_entry_udp resource_allocation_key &ring_alloc_logic); virtual ~dst_entry_udp_mc(); - virtual bool conf_l2_hdr_and_snd_wqe_ib(); - protected: ip_address m_mc_tx_if_ip; bool m_b_mc_loopback_enabled; diff --git a/src/vma/proto/flow_tuple.cpp b/src/vma/proto/flow_tuple.cpp index 6ed5ef4ea5..9f3f23c7da 100644 --- a/src/vma/proto/flow_tuple.cpp +++ b/src/vma/proto/flow_tuple.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/flow_tuple.h b/src/vma/proto/flow_tuple.h index f6c937be9d..4ae90f3a4e 100644 --- a/src/vma/proto/flow_tuple.h +++ b/src/vma/proto/flow_tuple.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/header.cpp b/src/vma/proto/header.cpp index ce85806618..b44a6f8e47 100644 --- a/src/vma/proto/header.cpp +++ b/src/vma/proto/header.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -47,8 +21,7 @@ void header::init() header::header() : m_actual_hdr_addr(0), m_transport_header_tx_offset(0), - m_is_vlan_enabled(false), - m_transport_type(VMA_TRANSPORT_UNKNOWN) + m_is_vlan_enabled(false) { init(); } @@ -62,7 +35,6 @@ header::header(const header &h): tostr() m_aligned_l2_l3_len = h.m_aligned_l2_l3_len; m_transport_header_tx_offset = h.m_transport_header_tx_offset; m_is_vlan_enabled = h.m_is_vlan_enabled; - m_transport_type = h.m_transport_type; update_actual_hdr_addr(); } @@ -111,16 +83,6 @@ void header::configure_ip_header(uint8_t protocol, in_addr_t src_addr, in_addr_t m_total_hdr_len += m_ip_header_len; } -void header::configure_ipoib_headers(uint32_t ipoib_header /*=IPOIB_HEADER*/) -{ - ib_hdr_template_t *p_hdr = &m_header.hdr.m_l2_hdr.ib_hdr; - m_transport_header_tx_offset = sizeof(p_hdr->m_alignment); - m_transport_header_len = sizeof(p_hdr->m_ipoib_hdr); - m_total_hdr_len += m_transport_header_len; - p_hdr->m_ipoib_hdr.ipoib_header = htonl(ipoib_header); - update_actual_hdr_addr(); -} - void header::set_mac_to_eth_header(const L2_address &src, const L2_address &dst, ethhdr ð_header) { // copy source and destination mac address to eth header diff --git a/src/vma/proto/header.h b/src/vma/proto/header.h index 1e164b4f0f..d001b27f21 100644 --- a/src/vma/proto/header.h +++ b/src/vma/proto/header.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -51,17 +25,10 @@ // We align the frame so IP header will be 4 bytes align // And we align the L2 headers so IP header on both transport // types will be at the same offset from buffer start -#define NET_IB_IP_ALIGN_SZ 16 #define NET_ETH_IP_ALIGN_SZ 6 #define NET_ETH_VLAN_IP_ALIGN_SZ 2 #define NET_ETH_VLAN_PCP_OFFSET 13 -struct __attribute__ ((packed)) ib_hdr_template_t { // Offeset Size - char m_alignment[NET_IB_IP_ALIGN_SZ]; // 0 16 = 16 - ipoibhdr m_ipoib_hdr; // 16 4 = 20 -// iphdr m_ip_hdr; // 20 20 = 40 -}; - struct __attribute__ ((packed)) eth_hdr_template_t { // Offeset Size char m_alignment[NET_ETH_IP_ALIGN_SZ]; // 0 6 = 6 ethhdr m_eth_hdr; // 6 14 = 20 @@ -76,7 +43,6 @@ struct __attribute__ ((packed)) vlan_eth_hdr_template_t { // Offeset Size }; union l2_hdr_template_t { - ib_hdr_template_t ib_hdr; eth_hdr_template_t eth_hdr; vlan_eth_hdr_template_t vlan_eth_hdr; }; @@ -108,7 +74,6 @@ class header: public tostr void configure_udp_header(uint16_t dest_port, uint16_t src_port); void configure_tcp_ports(uint16_t dest_port, uint16_t src_port); void configure_ip_header(uint8_t protocol, in_addr_t src_addr, in_addr_t dest_addr, uint8_t ttl = 64, uint8_t tos = 0, uint16_t packet_id = 0); - void configure_ipoib_headers(uint32_t ipoib_header = IPOIB_HEADER); void set_mac_to_eth_header(const L2_address &src, const L2_address &dst, ethhdr ð_header); void set_ip_ttl(uint8_t ttl); void set_ip_tos(uint8_t tos); @@ -158,7 +123,6 @@ class header: public tostr uint16_t m_aligned_l2_l3_len; uint16_t m_transport_header_tx_offset; bool m_is_vlan_enabled; - transport_type_t m_transport_type; }; #endif /* HEADER_H */ diff --git a/src/vma/proto/igmp_handler.cpp b/src/vma/proto/igmp_handler.cpp deleted file mode 100644 index 9bc09cf4b0..0000000000 --- a/src/vma/proto/igmp_handler.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -#include -#include - -#include "utils/bullseye.h" -#include "vlogger/vlogger.h" -#include "vma/proto/neighbour_table_mgr.h" -#include "vma/dev/wqe_send_handler.h" -#include "vma/dev/wqe_send_ib_handler.h" -#include "vma/util/utils.h" -#include "igmp_handler.h" - - - -#define MODULE_NAME "igmp_hdlr" -#undef MODULE_HDR_INFO -#define MODULE_HDR_INFO MODULE_NAME "[%s]:%d:%s() " - -#undef __INFO__ -#define __INFO__ this->to_str().c_str() - -#define igmp_hdlr_logpanic __log_info_panic -#define igmp_hdlr_logerr __log_info_err -#define igmp_hdlr_logwarn __log_info_warn -#define igmp_hdlr_loginfo __log_info_info -#define igmp_hdlr_logdbg __log_info_dbg -#define igmp_hdlr_logfunc __log_info_func -#define igmp_hdlr_logfuncall __log_info_funcall - -#define IGMPV1_MAX_RESPONSE_TIME 100 - -igmp_handler::igmp_handler(const igmp_key &key, uint8_t igmp_code) : m_mc_addr (key.get_in_addr()), m_p_ndvl(key.get_net_device_val()), - m_ignore_timer(false), m_timer_handle(NULL), m_p_neigh_entry(NULL), m_p_neigh_val(NULL), - m_p_ring(NULL), m_igmp_code(igmp_code ? igmp_code : IGMPV1_MAX_RESPONSE_TIME), m_id(0) -{ - ring_alloc_logic_attr ring_attr(safe_mce_sys().ring_allocation_logic_tx); - m_ring_allocation_logic = ring_allocation_logic_tx(m_p_ndvl->get_local_addr(), ring_attr, this); - - memset(&m_sge, 0, sizeof(m_sge)); - memset(&m_p_send_igmp_wqe, 0, sizeof(m_p_send_igmp_wqe)); -} - -igmp_handler::~igmp_handler() -{ - if (m_p_neigh_entry) { - g_p_neigh_table_mgr->unregister_observer(igmp_key(m_mc_addr, m_p_ndvl),this); - m_p_neigh_entry = NULL; - } - - if (m_p_ring) { - m_p_ndvl->release_ring(m_ring_allocation_logic.get_key()); - m_p_ring = NULL; - } - - if (m_p_neigh_val) { - delete m_p_neigh_val; - m_p_neigh_val = NULL; - } -} - -bool igmp_handler::init(const igmp_key &key) -{ - igmp_hdlr_logfunc(""); - cache_entry_subject* p_ces = NULL; - g_p_neigh_table_mgr->register_observer(key, this, &p_ces); - m_p_neigh_entry = dynamic_cast(p_ces); - - BULLSEYE_EXCLUDE_BLOCK_START - if (!m_p_neigh_entry) { - igmp_hdlr_logerr("Dynamic casting to neigh_entry has failed"); - return false; - } - - m_p_neigh_val = new neigh_ib_val; - if (!m_p_neigh_val) { - igmp_hdlr_logerr("Failed allocating neigh_val"); - return false; - } - - m_p_ring = m_p_ndvl->reserve_ring(m_ring_allocation_logic.get_key()); - if (!m_p_ring) { - igmp_hdlr_logerr("Ring was not reserved"); - return false; - } - m_id = m_p_ring->generate_id(); - BULLSEYE_EXCLUDE_BLOCK_END - - return true; -} - - // will register timer and later do 'tx_igmp_report(mc_group, ndvl)' -void igmp_handler::handle_query(uint8_t igmp_code) -{ - igmp_hdlr_logdbg("Received igmp query, preparing to send report"); - - m_igmp_code = igmp_code ? igmp_code : IGMPV1_MAX_RESPONSE_TIME; - - m_ignore_timer = false; - - priv_register_timer_event(this, ONE_SHOT_TIMER, (void*)IGMP_TIMER_ID); -} - -void igmp_handler::priv_register_timer_event(timer_handler* handler, timer_req_type_t req_type, void* user_data) -{ - int duration = 0 ; - srand(time(NULL)); - /* coverity[dont_call] */ - duration = (rand() % (m_igmp_code * 100)); // igmp_code (1-255) is in 1/10 sec units - - lock(); - if (!m_timer_handle && g_p_event_handler_manager) { - igmp_hdlr_logdbg("Register timer (%d msec) for sending igmp report after seen an igmp query for this group", duration); - m_timer_handle = g_p_event_handler_manager->register_timer_event(duration, handler, req_type, user_data); - } - unlock(); -} - -void igmp_handler::handle_report() -{ - igmp_hdlr_logdbg("Ignoring self timer (%p) after seen an igmp report for this group", m_timer_handle); - m_ignore_timer = true; // check if was not ignored before ? -} - -void igmp_handler::clean_obj() -{ - if (is_cleaned()) { - return ; - } - - set_cleaned(); - m_timer_handle = NULL; - if (g_p_event_handler_manager->is_running()) { - g_p_event_handler_manager->unregister_timers_event_and_delete(this); - } else { - cleanable_obj::clean_obj(); - } -} - -void igmp_handler::handle_timer_expired(void* user_data) -{ - NOT_IN_USE(user_data); - igmp_hdlr_logdbg("Timeout expired"); - m_timer_handle = NULL; - - if (m_ignore_timer) { - igmp_hdlr_logdbg("Ignoring timeout handling due to captured IGMP report"); - return; - } - igmp_hdlr_logdbg("Sending igmp report"); - - if (!tx_igmp_report()) { - igmp_hdlr_logdbg("Send igmp report failed, registering new timer"); - priv_register_timer_event(this, ONE_SHOT_TIMER, (void*)IGMP_TIMER_ID); - } -} - -bool igmp_handler::tx_igmp_report() -{ - - if (m_p_neigh_entry->get_peer_info(m_p_neigh_val)) { - igmp_hdlr_logdbg("neigh is valid"); - } - else { - igmp_hdlr_logdbg("neigh is not valid"); - return false; - } - - mem_buf_desc_t* p_mem_buf_desc = m_p_ring->mem_buf_tx_get(m_id, false, 1); - if (unlikely(p_mem_buf_desc == NULL)) { - igmp_hdlr_logdbg("No free TX buffer, not sending igmp report"); - return false; - } - - wqe_send_ib_handler wqe_sh; - wqe_sh.init_ib_wqe(m_p_send_igmp_wqe, &m_sge, 1, ((neigh_ib_val *)m_p_neigh_val)->get_ah(), - ((neigh_ib_val *)m_p_neigh_val)->get_qpn(), ((neigh_ib_val *)m_p_neigh_val)->get_qkey()); - m_header.init(); - m_header.configure_ipoib_headers(); - size_t m_total_l2_hdr_len = m_header.m_total_hdr_len; - m_header.configure_ip_header(IPPROTO_IGMP, m_p_ndvl->get_local_addr(), m_mc_addr.get_in_addr(),/*ttl for IGMP*/1); - m_header.copy_l2_ip_hdr((tx_packet_template_t*)p_mem_buf_desc->p_buffer); - - // Override IP header with IGMPV2 specific info - ip_igmp_tx_hdr_template_t* p_ip_pkt = (ip_igmp_tx_hdr_template_t*)(p_mem_buf_desc->p_buffer + m_header.m_transport_header_tx_offset + m_total_l2_hdr_len); - set_ip_igmp_hdr(p_ip_pkt); - - m_sge.addr = (uintptr_t)(p_mem_buf_desc->p_buffer + (uint8_t)m_header.m_transport_header_tx_offset); - m_sge.length = m_header.m_total_hdr_len + sizeof(uint32_t /*m_ip_hdr_ext*/) + sizeof (igmphdr /*m_igmp_hdr*/); - m_sge.lkey = p_mem_buf_desc->lkey; - p_mem_buf_desc->p_next_desc = NULL; - m_p_send_igmp_wqe.wr_id = (uintptr_t)p_mem_buf_desc; - - igmp_hdlr_logdbg("Sending igmp report"); - m_p_ring->send_ring_buffer(m_id, &m_p_send_igmp_wqe, (vma_wr_tx_packet_attr)0); - return true; -} - -void igmp_handler::set_ip_igmp_hdr(ip_igmp_tx_hdr_template_t* ip_igmp_hdr) -{ - ip_igmp_hdr->m_ip_hdr.ihl = IPV4_IGMP_HDR_LEN_WORDS; - ip_igmp_hdr->m_ip_hdr.tot_len = htons(IPV4_IGMP_HDR_LEN + sizeof(igmphdr)); - ip_igmp_hdr->m_ip_hdr_ext = htonl(IGMP_IP_HEADER_EXT); - ip_igmp_hdr->m_ip_hdr.check = 0; - ip_igmp_hdr->m_ip_hdr.check = compute_ip_checksum((unsigned short*)&ip_igmp_hdr->m_ip_hdr, (IPV4_IGMP_HDR_LEN_WORDS) * 2); - - // Create the IGMP header - ip_igmp_hdr->m_igmp_hdr.type = IGMPV2_HOST_MEMBERSHIP_REPORT; - ip_igmp_hdr->m_igmp_hdr.code = 0; - ip_igmp_hdr->m_igmp_hdr.group = m_mc_addr.get_in_addr(); - ip_igmp_hdr->m_igmp_hdr.csum = 0; - ip_igmp_hdr->m_igmp_hdr.csum = compute_ip_checksum((unsigned short*)&ip_igmp_hdr->m_igmp_hdr, IGMP_HDR_LEN_WORDS * 2); -} diff --git a/src/vma/proto/igmp_handler.h b/src/vma/proto/igmp_handler.h deleted file mode 100644 index 93c11510cc..0000000000 --- a/src/vma/proto/igmp_handler.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -#include "vma/proto/neighbour.h" -#include "vma/event/event_handler_manager.h" -#include "vma/event/timer_handler.h" -#include - - -#ifndef IGMP_HANDLER_H_ -#define IGMP_HANDLER_H_ - -#define igmp_key neigh_key - -#define IGMP_TIMER_ID 0 - -struct __attribute__ ((packed, aligned)) ip_igmp_tx_hdr_template_t { - iphdr m_ip_hdr; - uint32_t m_ip_hdr_ext; - igmphdr m_igmp_hdr; -}; - -#define IGMP_IP_HEADER_EXT 0x94040000 // IP header options field: Router alert - -class igmp_handler : public timer_handler, public lock_mutex, public cleanable_obj, public cache_observer, public neigh_observer -{ -public: - igmp_handler(const igmp_key &key, uint8_t igmp_code); - bool init(const igmp_key &key); - ~igmp_handler(); - - const std::string to_str() const - { - return(m_mc_addr.to_str() + " " + m_p_ndvl->to_str()); - } - - virtual transport_type_t get_obs_transport_type() const - { - return m_p_ndvl->get_transport_type(); - } - - void handle_query(uint8_t igmp_code); // handle queries coming from router - void handle_report(); // handle reports coming from other hosts - - virtual void clean_obj(); -private: - - ip_address m_mc_addr; - net_device_val* m_p_ndvl; - ring_allocation_logic_tx m_ring_allocation_logic; - bool m_ignore_timer; - void* m_timer_handle; - neigh_entry* m_p_neigh_entry; - neigh_val* m_p_neigh_val; - ring* m_p_ring; - header m_header; - ibv_sge m_sge; - vma_ibv_send_wr m_p_send_igmp_wqe; - uint8_t m_igmp_code; - ring_user_id_t m_id; - - void set_timer(); //called by tx_igmp_report - void unset_timer(); // called if igmp packet is report and not query - virtual void handle_timer_expired(void* user_data); - void priv_register_timer_event(timer_handler* handler, timer_req_type_t req_type, void* user_data); - bool tx_igmp_report(); - void set_ip_igmp_hdr(ip_igmp_tx_hdr_template_t* igmp_hdr); - -}; - -#endif diff --git a/src/vma/proto/igmp_mgr.cpp b/src/vma/proto/igmp_mgr.cpp deleted file mode 100644 index e1c70996f4..0000000000 --- a/src/vma/proto/igmp_mgr.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -#include -#include - -#include "utils/bullseye.h" -#include "vlogger/vlogger.h" -#include "igmp_mgr.h" -#include "vma/dev/net_device_table_mgr.h" -#include "vma/dev/net_device_val.h" - - - -#define MODULE_NAME "igmp_mgr" -#undef MODULE_HDR_INFO -#define MODULE_HDR_INFO MODULE_NAME "[%s]:%d:%s() " - -#undef __INFO__ -#define __INFO__ "" - -#define igmp_mgr_logpanic __log_info_panic -#define igmp_mgr_logerr __log_info_err -#define igmp_mgr_logwarn __log_info_warn -#define igmp_mgr_loginfo __log_info_info -#define igmp_mgr_logdbg __log_info_dbg -#define igmp_mgr_logfunc __log_info_func -#define igmp_mgr_logfuncall __log_info_funcall - - -igmp_mgr *g_p_igmp_mgr = NULL; - -igmp_mgr::~igmp_mgr() -{ - igmp_handler* p_igmp_hdlr = NULL; - igmp_hdlr_map_t::iterator iter = m_igmp_hash.begin(); - while (iter != m_igmp_hash.end()) { - p_igmp_hdlr = iter->second; - igmp_mgr_logdbg("Delete existing igmp handler '%s'", p_igmp_hdlr->to_str().c_str()); - m_igmp_hash.erase(iter); - p_igmp_hdlr->clean_obj(); - p_igmp_hdlr = NULL; - iter = m_igmp_hash.begin(); - } -} - -void igmp_mgr::process_igmp_packet(struct iphdr* p_ip_h, in_addr_t local_if) -{ - igmp_mgr_logfunc(""); - igmp_handler* p_igmp_hdlr = NULL; - uint16_t ip_h_hdr_len = (int)(p_ip_h->ihl)*4; - struct igmphdr* p_igmp_h = (struct igmphdr*)(((uint8_t*)p_ip_h) + ip_h_hdr_len); - - net_device_val* p_ndvl = g_p_net_device_table_mgr->get_net_device_val(local_if); - BULLSEYE_EXCLUDE_BLOCK_START - if (!p_ndvl){ - igmp_mgr_logerr("Failed getting relevant net device"); - return; - } - BULLSEYE_EXCLUDE_BLOCK_END - - igmp_key key(ip_address(p_igmp_h->group), p_ndvl); - p_igmp_hdlr = get_igmp_handler(key, p_igmp_h->code); - BULLSEYE_EXCLUDE_BLOCK_START - if (!p_igmp_hdlr){ - igmp_mgr_logerr("Failed getting relevant igmp_handler"); - return; - } - BULLSEYE_EXCLUDE_BLOCK_END - - switch (p_igmp_h->type) { - case IGMP_HOST_MEMBERSHIP_QUERY: - p_igmp_hdlr->handle_query(p_igmp_h->code); - break; - - case IGMP_HOST_MEMBERSHIP_REPORT: - case IGMPV2_HOST_MEMBERSHIP_REPORT: - p_igmp_hdlr->handle_report(); - break; - - default: - break; - } -} - -igmp_handler* igmp_mgr::get_igmp_handler(const igmp_key &key, uint8_t igmp_code) -{ - igmp_handler *p_igmp_hdlr = NULL; - - lock(); - igmp_hdlr_map_t::iterator iter = m_igmp_hash.find(key); - if (iter != m_igmp_hash.end()) { - p_igmp_hdlr = iter->second; - igmp_mgr_logdbg("Found existing igmp handler '%s'", p_igmp_hdlr->to_str().c_str()); - } - else { - p_igmp_hdlr = new igmp_handler(key, igmp_code); - BULLSEYE_EXCLUDE_BLOCK_START - if (!p_igmp_hdlr) { - igmp_mgr_logerr("Failed allocating new igmp handler for mc_address = %d.%d.%d.%d, local_if= %d.%d.%d.%d", - NIPQUAD(key.get_in_addr()), NIPQUAD(key.get_net_device_val()->get_local_addr())); - unlock(); - return p_igmp_hdlr; - } - if (!p_igmp_hdlr->init(key)) { - igmp_mgr_logerr("Failed to initialize new igmp handler '%s'", p_igmp_hdlr->to_str().c_str()); - delete(p_igmp_hdlr); - p_igmp_hdlr = NULL; - unlock(); - return p_igmp_hdlr; - } - BULLSEYE_EXCLUDE_BLOCK_END - m_igmp_hash[key] = p_igmp_hdlr; - igmp_mgr_logdbg("Created new igmp handler '%s'", p_igmp_hdlr->to_str().c_str()); - } - unlock(); - return p_igmp_hdlr; -} - diff --git a/src/vma/proto/igmp_mgr.h b/src/vma/proto/igmp_mgr.h deleted file mode 100644 index 00e0eb445f..0000000000 --- a/src/vma/proto/igmp_mgr.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -#include "vma/proto/igmp_handler.h" -#include - -#ifndef IGMP_MANAGER_H -#define IGMP_MANAGER_H - - -typedef std::unordered_map igmp_hdlr_map_t; - -class igmp_mgr : public lock_mutex -{ -public: - igmp_mgr() {}; - ~igmp_mgr(); - void process_igmp_packet(struct iphdr* p_ip_h, in_addr_t local_if); - -private: - igmp_hdlr_map_t m_igmp_hash; - igmp_handler* get_igmp_handler(const igmp_key &key, uint8_t igmp_code); -}; - -extern igmp_mgr *g_p_igmp_mgr; - -#endif - diff --git a/src/vma/proto/ip_address.h b/src/vma/proto/ip_address.h index 4d4594ac6e..021cffaec8 100644 --- a/src/vma/proto/ip_address.h +++ b/src/vma/proto/ip_address.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/ip_frag.cpp b/src/vma/proto/ip_frag.cpp index db94d81d08..1b9b172dad 100644 --- a/src/vma/proto/ip_frag.cpp +++ b/src/vma/proto/ip_frag.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/ip_frag.h b/src/vma/proto/ip_frag.h index ce372d4dbd..ad37bf8927 100644 --- a/src/vma/proto/ip_frag.h +++ b/src/vma/proto/ip_frag.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/mem_buf_desc.h b/src/vma/proto/mem_buf_desc.h index 084ab37979..267b0ecc00 100644 --- a/src/vma/proto/mem_buf_desc.h +++ b/src/vma/proto/mem_buf_desc.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -132,6 +106,7 @@ class mem_buf_desc_t { inline int get_ref_count() const {return atomic_read(&n_ref_count);} inline void reset_ref_count() {atomic_set(&n_ref_count, 0);} + inline void set_ref_count(int x) {atomic_set(&n_ref_count, x);} inline int inc_ref_count() {return atomic_fetch_and_inc(&n_ref_count);} inline int dec_ref_count() {return atomic_fetch_and_dec(&n_ref_count);} diff --git a/src/vma/proto/neighbour.cpp b/src/vma/proto/neighbour.cpp index da81d2d192..9e090ff2b4 100644 --- a/src/vma/proto/neighbour.cpp +++ b/src/vma/proto/neighbour.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -44,7 +18,6 @@ #include "vma/proto/route_rule_table_key.h" #include "vma/proto/route_table_mgr.h" #include "vma/dev/wqe_send_handler.h" -#include "vma/dev/wqe_send_ib_handler.h" //This include should be after vma includes #include @@ -88,7 +61,7 @@ inline int neigh_eth::build_mc_neigh_val() if (m_val == NULL) //This is the first time we are trying to allocate new val or it failed last time - m_val = new neigh_eth_val; + m_val = new neigh_val; BULLSEYE_EXCLUDE_BLOCK_START if (m_val == NULL) { @@ -124,7 +97,7 @@ inline int neigh_eth::build_uc_neigh_val() if (m_val == NULL) { // This is the first time we are trying to allocate new val or it failed last time - m_val = new neigh_eth_val; + m_val = new neigh_val; } BULLSEYE_EXCLUDE_BLOCK_START @@ -154,32 +127,12 @@ inline int neigh_eth::build_uc_neigh_val() return 0; } -neigh_val & neigh_ib_val::operator=(const neigh_val & val) -{ - IPoIB_addr* l2_addr = NULL; - neigh_val* tmp_val = const_cast(&val); - const neigh_ib_val* ib_val = dynamic_cast(tmp_val); - BULLSEYE_EXCLUDE_BLOCK_START - if (ib_val == NULL) { - __log_panic("neigh_ib_val is NULL"); - } - BULLSEYE_EXCLUDE_BLOCK_END - m_l2_address = new IPoIB_addr((ib_val->get_l2_address())->get_address()); - l2_addr = (IPoIB_addr *)m_l2_address; //no need to do dynamic casting here - m_ah = ib_val->get_ah(); //TODO: we need to handle this - in case ah is used in post_send we cannot destroy it - m_qkey = ib_val->get_qkey(); - l2_addr->set_qpn(ib_val->get_qpn()); - m_ah_attr = ib_val->get_ah_attr(); - return *this; -} - -neigh_entry::neigh_entry(neigh_key key, transport_type_t _type, bool is_init_resources): +neigh_entry::neigh_entry(neigh_key key, bool is_init_resources): cache_entry_subject(key), m_cma_id(NULL), m_rdma_port_space((enum rdma_port_space)0), m_state_machine(NULL), m_type(UNKNOWN), - m_trans_type(_type), m_state(false), m_err_counter(0), m_timer_handle(NULL), @@ -187,7 +140,7 @@ neigh_entry::neigh_entry(neigh_key key, transport_type_t _type, bool is_init_res m_p_dev(key.get_net_device_val()), m_p_ring(NULL), m_is_loopback(false), - m_to_str(std::string(priv_vma_transport_type_str(m_trans_type)) + ":" + get_key().to_str()), m_id(0), + m_to_str(get_key().to_str()), m_id(0), m_is_first_send_arp(true), m_n_sysvar_neigh_wait_till_send_arp_msec(safe_mce_sys().neigh_wait_till_send_arp_msec), m_n_sysvar_neigh_uc_arp_quata(safe_mce_sys().neigh_uc_arp_quata), m_n_sysvar_neigh_num_err_retries(safe_mce_sys().neigh_num_err_retries) @@ -248,7 +201,9 @@ neigh_entry::~neigh_entry() m_state_machine = NULL; } if (m_p_dev && m_p_ring) { - m_p_dev->release_ring(m_ring_allocation_logic.get_key()); + if (m_p_dev->release_ring(m_ring_allocation_logic.get_key())<0) { + neigh_logwarn("Failed to release ring for allocation key %s", m_ring_allocation_logic.get_key()->to_str()); + } m_p_ring = NULL; } if (m_val) { @@ -358,7 +313,7 @@ void neigh_entry::handle_timer_expired(void* ctx) if(!priv_is_failed(state)) { //We want to verify that L2 address wasn't changed - unsigned char tmp[IPOIB_HW_ADDR_LEN]; + unsigned char tmp[ETH_ALEN]; address_t l2_addr = (address_t)tmp; if(!priv_get_neigh_l2(l2_addr)) { return; @@ -513,9 +468,6 @@ bool neigh_entry::post_send_udp(neigh_send_data *n_send_data) m_sge.addr = (uintptr_t)(p_mem_buf_desc->p_buffer + (uint8_t)h->m_transport_header_tx_offset); m_sge.length = sz_user_data_to_copy + hdr_len; -#ifdef DEFINED_TSO - m_sge.lkey = m_p_ring->get_tx_lkey(m_id); -#endif /* DEFINED_TSO */ m_send_wqe.wr_id = (uintptr_t)p_mem_buf_desc; neigh_logdbg("%s packet_sz=%d, payload_sz=%zd, ip_offset=%d id=%d", h->to_str().c_str(), @@ -581,9 +533,6 @@ bool neigh_entry::post_send_tcp(neigh_send_data *p_data) size_t hdr_alignment_diff = h->m_aligned_l2_l3_len - h->m_total_hdr_len; m_sge.addr = (uintptr_t)((uint8_t*)p_pkt + hdr_alignment_diff); m_sge.length = total_packet_len; -#ifdef DEFINED_TSO - m_sge.lkey = m_p_ring->get_tx_lkey(m_id); -#endif /* DEFINED_TSO */ /* for DEBUG */ if ((uint8_t*)m_sge.addr < p_mem_buf_desc->p_buffer) { @@ -715,6 +664,7 @@ void neigh_entry::handle_neigh_event(neigh_nl_event* nl_ev) } // Check if neigh L2 address changed (HA event) and restart the state machine + /* coverity[check_return] */ priv_handle_neigh_is_l2_changed(nl_info->lladdr); break; } @@ -787,8 +737,6 @@ const char* neigh_entry::event_to_str(event_t event) const return "EV_PATH_RESOLVED"; case EV_ERROR: return "EV_ERROR"; - case EV_TIMEOUT_EXPIRED: - return "EV_TIMEOUT_EXPIRED"; case EV_UNHANDLED: return "EV_UNHANDELED"; BULLSEYE_EXCLUDE_BLOCK_START @@ -842,7 +790,7 @@ neigh_entry::event_t neigh_entry::rdma_event_mapping(struct rdma_cm_event* p_rdm return EV_UNHANDLED; } BULLSEYE_EXCLUDE_BLOCK_END - neigh_logdbg("Got event %s (%d)", priv_rdma_cm_event_type_str(p_rdma_cm_event->event), p_rdma_cm_event->event); + neigh_logdbg("Got event %s (%d)", rdma_event_str(p_rdma_cm_event->event), p_rdma_cm_event->event); switch (p_rdma_cm_event->event) { @@ -1255,7 +1203,7 @@ void neigh_entry::priv_unregister_timer() //============================================================== neigh_eth ================================================== neigh_eth::neigh_eth(neigh_key key) : - neigh_entry(key, VMA_TRANSPORT_ETH) + neigh_entry(key) { neigh_logdbg(""); m_rdma_port_space = RDMA_PS_UDP; @@ -1454,14 +1402,14 @@ bool neigh_eth::post_send_arp(bool is_broadcast) dst = m_p_dev->get_br_address(); } - - const unsigned char* peer_mac = dst->get_address(); BULLSEYE_EXCLUDE_BLOCK_START if (src == NULL || dst == NULL) { neigh_logdbg("src or dst is NULL not sending ARP"); return false; } BULLSEYE_EXCLUDE_BLOCK_END + + const unsigned char* peer_mac = dst->get_address(); m_id = m_p_ring->generate_id(src->get_address(), dst->get_address(), netdevice_eth->get_vlan() ? htons(ETH_P_8021Q) : htons(ETH_P_ARP), htons(ETH_P_ARP), 0, 0, 0, 0); mem_buf_desc_t* p_mem_buf_desc = m_p_ring->mem_buf_tx_get(m_id, false, 1); @@ -1551,628 +1499,3 @@ ring_user_id_t neigh_eth::generate_ring_user_id(header * h /* = NULL */) h->m_header.hdr.m_udp_hdr.source, h->m_header.hdr.m_udp_hdr.dest); } - -//============================================================== neigh_ib ================================================== - -neigh_ib::neigh_ib(neigh_key key, bool is_init_resources) : - neigh_entry(key, VMA_TRANSPORT_IB, is_init_resources), m_pd(NULL), m_n_sysvar_wait_after_join_msec(safe_mce_sys().wait_after_join_msec) -{ - neigh_logdbg(""); - - m_rdma_port_space = RDMA_PS_IPOIB; - - if(IS_BROADCAST_N(key.get_in_addr())) { - //In case of broadcast neigh we don't want to have state machine - m_type = MC; - return; - } - - if (IN_MULTICAST_N(key.get_in_addr())) { - //This is Multicast neigh - m_type = MC; - } - else { - // This is Unicast neigh - m_type = UC; - } - //Do we need to handle case when we get EV_ERROR but in case this error is not related to the state - //Like Address Resolve Error when we at ST_ARP_RESOLVED or ST_PATH_RESOLVED .... - - sm_short_table_line_t short_sm_table[] = - { - // {curr state, event, next state, action func } - { ST_NOT_ACTIVE, EV_KICK_START, ST_INIT, NULL }, - { ST_ERROR, EV_KICK_START, ST_INIT, NULL }, - { ST_INIT, EV_START_RESOLUTION, ST_INIT_RESOLUTION, NULL }, - { ST_INIT_RESOLUTION, EV_ADDR_RESOLVED, ST_ARP_RESOLVED, NULL }, - { ST_ARP_RESOLVED, EV_PATH_RESOLVED, ST_PATH_RESOLVED, NULL }, - { ST_PATH_RESOLVED, EV_TIMEOUT_EXPIRED, ST_READY, NULL }, - { ST_PATH_RESOLVED, EV_ERROR, ST_ERROR, NULL }, - { ST_ARP_RESOLVED, EV_ERROR, ST_ERROR, NULL }, - { ST_READY, EV_ERROR, ST_ERROR, NULL }, - { ST_INIT, EV_ERROR, ST_ERROR, NULL }, - { ST_INIT_RESOLUTION, EV_ERROR, ST_ERROR, NULL }, - { ST_ERROR, EV_ERROR, ST_NOT_ACTIVE, NULL }, - //Entry functions - { ST_INIT, SM_STATE_ENTRY, SM_NO_ST, neigh_entry::dofunc_enter_init }, - { ST_INIT_RESOLUTION, SM_STATE_ENTRY, SM_NO_ST, neigh_entry::dofunc_enter_init_resolution }, - { ST_ARP_RESOLVED, SM_STATE_ENTRY, SM_NO_ST, neigh_ib::dofunc_enter_arp_resolved }, - { ST_PATH_RESOLVED, SM_STATE_ENTRY, SM_NO_ST, neigh_ib::dofunc_enter_path_resolved }, - { ST_READY, SM_STATE_ENTRY, SM_NO_ST, neigh_entry::dofunc_enter_ready }, - { ST_NOT_ACTIVE, SM_STATE_ENTRY, SM_NO_ST, neigh_entry::dofunc_enter_not_active }, - { ST_ERROR, SM_STATE_ENTRY, SM_NO_ST, neigh_entry::dofunc_enter_error }, - SM_TABLE_END }; - - // Create state_nachine - m_state_machine = new state_machine(this, // app hndl - ST_NOT_ACTIVE, // start state_t - ST_LAST, // max states - EV_LAST, // max events - short_sm_table, // short table - general_st_entry, // default entry function - general_st_leave, // default leave function - NULL, // default func - print_event_info // debug function - ); - - BULLSEYE_EXCLUDE_BLOCK_START - if (m_state_machine == NULL) - neigh_logpanic("Failed allocating state_machine"); - BULLSEYE_EXCLUDE_BLOCK_END - - priv_kick_start_sm(); -} - -neigh_ib::~neigh_ib() -{ - priv_enter_not_active(); -} - -void neigh_ib::handle_event_ibverbs_cb(void* ev_data, void* ctx) -{ - NOT_IN_USE(ctx); - event_t event = ibverbs_event_mapping(ev_data); - event_handler(event, ev_data); -} - -// called when timer expired -void neigh_ib::handle_timer_expired(void* ctx) -{ - neigh_logdbg("general timeout expired!"); - - m_sm_lock.lock(); - int state = m_state_machine->get_curr_state(); - m_sm_lock.unlock(); - - if(state == ST_PATH_RESOLVED) { - // Clear Timer Handler - m_timer_handle = NULL; - event_handler(EV_TIMEOUT_EXPIRED); - } - else if(state == ST_READY) { - neigh_entry::handle_timer_expired(ctx); - } - else if(state == ST_INIT) { - // Clear Timer Handler - m_timer_handle = NULL; - event_handler(EV_START_RESOLUTION); - } -} - -bool neigh_ib::priv_handle_neigh_is_l2_changed(address_t new_l2_addr) -{ - auto_unlocker lock(m_lock); - IPoIB_addr new_l2_address(new_l2_addr); - if (m_val) { - if(m_val->get_l2_address()) { - if (!(m_val->get_l2_address()->compare(new_l2_address))) { - neigh_logdbg("l2 address was changed (%s => %s)", (m_val->get_l2_address())->to_str().c_str(), new_l2_address.to_str().c_str()); - event_handler(EV_ERROR); - return true; - } - else { - neigh_logdbg("No change in l2 address"); - return false; - } - } - else { - neigh_logdbg("l2 address is NULL\n"); - } - } - else { - neigh_logerr("m_val is NULL"); - } - - event_handler(EV_ERROR); - return true; -} - -bool neigh_ib::post_send_arp(bool is_broadcast) -{ - neigh_logdbg("Sending %s ARP", is_broadcast?"BC":"UC"); - - mem_buf_desc_t* p_mem_buf_desc = m_p_ring->mem_buf_tx_get(m_id, false, 1); - if (unlikely(p_mem_buf_desc == NULL)) { - neigh_logdbg("No free TX buffer, not sending ARP"); - return false; - } - - net_device_val_ib *netdevice_ib = dynamic_cast(m_p_dev); - if (netdevice_ib == NULL) { - m_p_ring->mem_buf_tx_release(p_mem_buf_desc, true); - neigh_logdbg("Net dev is NULL not sending ARP"); - return false; - } - - const L2_address *src = netdevice_ib->get_l2_address(); - const L2_address *dst; - neigh_ib_val br_neigh_val; - ibv_ah* ah = NULL; - uint32_t qpn; - uint32_t qkey; - const unsigned char* peer_mac = NULL; - if (!is_broadcast) { - dst = m_val->get_l2_address(); - peer_mac = dst->get_address(); - ah = ((neigh_ib_val *)m_val)->get_ah(); - qpn = ((neigh_ib_val *)m_val)->get_qpn(); - qkey = ((neigh_ib_val *)m_val)->get_qkey(); - } - else { - dst = m_p_dev->get_br_address(); - neigh_ib_broadcast * br_neigh = const_cast(((net_device_val_ib*)m_p_dev)->get_br_neigh()); - bool ret = br_neigh->get_peer_info(&br_neigh_val); - if (ret) { - ah = br_neigh_val.get_ah(); - qpn = br_neigh_val.get_qpn(); - qkey = br_neigh_val.get_qkey(); - } - else { - m_p_ring->mem_buf_tx_release(p_mem_buf_desc, true); - neigh_logdbg("BR Neigh is not valid, not sending BR ARP"); - return false; - } - } - - if (src == NULL || dst == NULL) { - m_p_ring->mem_buf_tx_release(p_mem_buf_desc, true); - neigh_logdbg("src or dst is NULL not sending ARP"); - return false; - } - - wqe_send_ib_handler wqe_sh; - wqe_sh.init_ib_wqe(m_send_wqe, &m_sge, 1, ah, qpn, qkey); - neigh_logdbg("ARP: ah=%p, qkey=%#x, qpn=%#x", ah ,qkey, qpn); - header h; - h.init(); - h.configure_ipoib_headers(IPOIB_ARP_HEADER); - - - tx_packet_template_t *p_pkt = (tx_packet_template_t*)p_mem_buf_desc->p_buffer; - h.copy_l2_hdr(p_pkt); - - ib_arp_hdr* p_arphdr = (ib_arp_hdr*) (p_mem_buf_desc->p_buffer + h.m_transport_header_tx_offset + h.m_total_hdr_len); - set_ib_arp_hdr(p_arphdr, m_p_dev->get_local_addr(), get_key().get_in_addr(), m_p_dev->get_l2_address()->get_address(), peer_mac); - - m_sge.addr = (uintptr_t)(p_mem_buf_desc->p_buffer + (uint8_t)h.m_transport_header_tx_offset); - m_sge.length = sizeof(ib_arp_hdr) + h.m_total_hdr_len; - m_sge.lkey = p_mem_buf_desc->lkey; - p_mem_buf_desc->p_next_desc = NULL; - m_send_wqe.wr_id = (uintptr_t)p_mem_buf_desc; - - m_p_ring->send_ring_buffer(m_id, &m_send_wqe, (vma_wr_tx_packet_attr)0); - - neigh_logdbg("ARP Sent"); - return true; -} - -bool neigh_ib::prepare_to_send_packet(header * h) -{ - neigh_logdbg(""); - wqe_send_ib_handler wqe_sh; - wqe_sh.init_ib_wqe(m_send_wqe, &m_sge , 1, ((neigh_ib_val *)m_val)->get_ah(), ((neigh_ib_val *)m_val)->get_qpn(), ((neigh_ib_val *)m_val)->get_qkey()); - h->configure_ipoib_headers(); - - return true; -} - -neigh_entry::event_t neigh_ib::ibverbs_event_mapping(void* p_event_info) -{ - struct ibv_async_event *ev = (struct ibv_async_event *) p_event_info; - neigh_logdbg("Got event %s (%d) ", priv_ibv_event_desc_str(ev->event_type), ev->event_type); - - switch (ev->event_type) - { - case IBV_EVENT_SM_CHANGE: - case IBV_EVENT_CLIENT_REREGISTER: - return EV_ERROR; - default: - return EV_UNHANDLED; - } -} - -void neigh_ib::dofunc_enter_arp_resolved(const sm_info_t& func_info) -{ - neigh_ib * my_neigh = (neigh_ib *) func_info.app_hndl; - neigh_entry::general_st_entry(func_info); - - run_helper_func(priv_enter_arp_resolved(), EV_ERROR); -} - -void neigh_ib::dofunc_enter_path_resolved(const sm_info_t& func_info) -{ - neigh_ib * my_neigh = (neigh_ib *) func_info.app_hndl; - neigh_entry::general_st_entry(func_info); - - uint32_t wait_after_join_msec; - - run_helper_func(priv_enter_path_resolved((struct rdma_cm_event*)func_info.ev_data, wait_after_join_msec), - EV_ERROR); - my_neigh->m_timer_handle = my_neigh->priv_register_timer_event(wait_after_join_msec, my_neigh, ONE_SHOT_TIMER, NULL); -} - -int neigh_ib::priv_enter_arp_resolved() -{ - neigh_logfunc(""); - - if (m_cma_id->verbs == NULL) { - neigh_logdbg("m_cma_id->verbs is NULL"); - return -1; - } - - if (find_pd()) - return -1; - - //Register Verbs event in case there was Fabric change - if (m_cma_id->verbs) { - g_p_event_handler_manager->register_ibverbs_event( - m_cma_id->verbs->async_fd, this, - m_cma_id->verbs, 0); - } - - if (m_type == UC) - return (handle_enter_arp_resolved_uc()); - else - // MC - return (handle_enter_arp_resolved_mc()); -} - -int neigh_ib::priv_enter_path_resolved(struct rdma_cm_event* event_data, - uint32_t & wait_after_join_msec) -{ - neigh_logfunc(""); - - if (m_val == NULL) - //This is the first time we are trying to allocate new val or it failed last time - m_val = new neigh_ib_val; - - BULLSEYE_EXCLUDE_BLOCK_START - if (m_val == NULL) - return -1; - BULLSEYE_EXCLUDE_BLOCK_END - - if (m_type == UC) - return (build_uc_neigh_val(event_data, wait_after_join_msec)); - else - //MC - return (build_mc_neigh_val(event_data, wait_after_join_msec)); -} - -void neigh_ib::priv_enter_error() -{ - auto_unlocker lock(m_lock); - - m_state = false; - m_pd = NULL; - - destroy_ah(); - priv_unregister_timer(); - - if (m_cma_id && m_cma_id->verbs) { - neigh_logdbg("Unregister Verbs event"); - g_p_event_handler_manager->unregister_ibverbs_event(m_cma_id->verbs->async_fd, this); - } - - neigh_entry::priv_enter_error(); -} - -void neigh_ib::priv_enter_not_active() -{ - neigh_logfunc(""); - - auto_unlocker lock(m_lock); - - m_state = false; - m_pd = NULL; - - destroy_ah(); - - if (m_cma_id && m_cma_id->verbs) { - neigh_logdbg("Unregister Verbs event"); - g_p_event_handler_manager->unregister_ibverbs_event(m_cma_id->verbs->async_fd, this); - } - - neigh_entry::priv_enter_not_active(); -} - -int neigh_ib::priv_enter_ready() -{ - neigh_logfunc(""); - priv_unregister_timer(); - return (neigh_entry::priv_enter_ready()); -} - -int neigh_ib::handle_enter_arp_resolved_mc() -{ - neigh_logdbg(""); - - IF_RDMACM_FAILURE(rdma_join_multicast( m_cma_id, (struct sockaddr*)&m_dst_addr, (void *)this)) - { - neigh_logdbg("Failed in rdma_join_multicast (errno=%d %m)", errno); - return -1; - } ENDIF_RDMACM_FAILURE; - - return 0; -} - -int neigh_ib::handle_enter_arp_resolved_uc() -{ - neigh_logdbg(""); - - IF_RDMACM_FAILURE(rdma_resolve_route(m_cma_id, RDMA_CM_TIMEOUT)) - { - neigh_logdbg("Resolve address error (errno=%d %m)", errno); - return -1; - } ENDIF_RDMACM_FAILURE; - - return 0; -} - -int neigh_ib::build_mc_neigh_val(struct rdma_cm_event* event_data, - uint32_t & wait_after_join_msec) -{ - neigh_logdbg(""); - - m_val->m_l2_address = new IPoIB_addr(event_data->param.ud.qp_num, (address_t)event_data->param.ud.ah_attr.grh.dgid.raw); - BULLSEYE_EXCLUDE_BLOCK_START - if (m_val->m_l2_address == NULL) { - neigh_logdbg("Failed allocating m_val->m_l2_address"); - return -1; - } - BULLSEYE_EXCLUDE_BLOCK_END - - ((neigh_ib_val *) m_val)->m_qkey = event_data->param.ud.qkey; - - memcpy(&((neigh_ib_val *) m_val)->m_ah_attr, - &event_data->param.ud.ah_attr, - sizeof(((neigh_ib_val *) m_val)->m_ah_attr)); - - BULLSEYE_EXCLUDE_BLOCK_START - if (create_ah()) - return -1; - BULLSEYE_EXCLUDE_BLOCK_END - - neigh_logdbg("IB multicast neigh params are : ah=%p, qkey=%#x, sl=%#x, rate=%#x, port_num = %#x, qpn=%#x dlid=%#x dgid = " IPOIB_HW_ADDR_PRINT_FMT_16, - ((neigh_ib_val *) m_val)->m_ah, ((neigh_ib_val *) m_val)->m_qkey, ((neigh_ib_val *) m_val)->m_ah_attr.sl, ((neigh_ib_val *) m_val)->m_ah_attr.static_rate, - ((neigh_ib_val *) m_val)->m_ah_attr.port_num, ((neigh_ib_val *) m_val)->get_qpn(), ((neigh_ib_val *) m_val)->m_ah_attr.dlid, - IPOIB_HW_ADDR_PRINT_ADDR_16(((neigh_ib_val *) m_val)->m_ah_attr.grh.dgid.raw)); - - wait_after_join_msec = m_n_sysvar_wait_after_join_msec; - - return 0; -} - -int neigh_ib::build_uc_neigh_val(struct rdma_cm_event* event_data, - uint32_t & wait_after_join_msec) -{ - NOT_IN_USE(event_data); - neigh_logdbg(""); - - // Find peer's IPoIB row address - unsigned char tmp[IPOIB_HW_ADDR_LEN]; - address_t address = (address_t) tmp; - BULLSEYE_EXCLUDE_BLOCK_START - if (!priv_get_neigh_l2(address)) { - neigh_logdbg("Failed in priv_get_neigh_l2()"); - return -1; - } - BULLSEYE_EXCLUDE_BLOCK_END - - m_val->m_l2_address = new IPoIB_addr(address); - BULLSEYE_EXCLUDE_BLOCK_START - if (m_val->m_l2_address == NULL) { - neigh_logdbg("Failed creating m_val->m_l2_address"); - return -1; - } - BULLSEYE_EXCLUDE_BLOCK_END - neigh_logdbg("IPoIB MAC = %s", m_val->m_l2_address->to_str().c_str()); - // IPoIB qkey is hard coded in SM . Do we want to take it from event or leave it hard coded - //((neigh_ib_val *) m_val)->m_qkey = event_data->param.ud.qkey; //0x0b1b; - ((neigh_ib_val *) m_val)->m_qkey = IPOIB_QKEY; - - //memcpy(&m_val.ib_addr.m_ah_attr, &event_data->param.ud.ah_attr, sizeof(struct ibv_ah_attr)); - - if (!m_cma_id || m_cma_id->route.num_paths <= 0) { - neigh_logdbg("Can't prepare AH attr (cma_id=%p, num_paths=%d)", m_cma_id, m_cma_id ? m_cma_id->route.num_paths : 0); - return -1; - } - - memset(&((neigh_ib_val *) m_val)->m_ah_attr, 0, sizeof(((neigh_ib_val *) m_val)->m_ah_attr)); - ((neigh_ib_val *) m_val)->m_ah_attr.dlid = ntohs(m_cma_id->route.path_rec->dlid); - ((neigh_ib_val *) m_val)->m_ah_attr.sl = m_cma_id->route.path_rec->sl; - ((neigh_ib_val *) m_val)->m_ah_attr.src_path_bits = 0; - ((neigh_ib_val *) m_val)->m_ah_attr.static_rate = m_cma_id->route.path_rec->rate; - ((neigh_ib_val *) m_val)->m_ah_attr.is_global = 0; - ((neigh_ib_val *) m_val)->m_ah_attr.port_num = m_cma_id->port_num; - - BULLSEYE_EXCLUDE_BLOCK_START - if (create_ah()) - return -1; - BULLSEYE_EXCLUDE_BLOCK_END - - neigh_logdbg("IB unicast neigh params ah=%p, qkey=%#x, qpn=%#x, dlid=%#x", ((neigh_ib_val *) m_val)->m_ah, - ((neigh_ib_val *) m_val)->m_qkey, ((neigh_ib_val *) m_val)->get_qpn(), ((neigh_ib_val *) m_val)->m_ah_attr.dlid); - - wait_after_join_msec = 0; - - return 0; -} - -int neigh_ib::find_pd() -{ - neigh_logdbg(""); - - ib_ctx_handler* ib_ctx_h = g_p_ib_ctx_handler_collection->get_ib_ctx(m_p_dev->get_ifname_link()); - - if (ib_ctx_h) { - m_pd = ib_ctx_h->get_ibv_pd(); - return 0; - } - - return -1; -} - -int neigh_ib::create_ah() -{ - neigh_logdbg(""); - - /* if (((neigh_ib_val *) m_val)->m_ah) { - // if there's ah we want to destroy it - shouldn't happen - neigh_logerr("destroy ah %p (shouldn't happen)", ((neigh_ib_val *) m_val)->m_ah); - if (destroy_ah()) - return -1; - } - */ - ((neigh_ib_val *) m_val)->m_ah = ibv_create_ah(m_pd, &((neigh_ib_val *) m_val)->m_ah_attr); - BULLSEYE_EXCLUDE_BLOCK_START - if (!((neigh_ib_val *) m_val)->m_ah) { - neigh_logdbg("failed creating address handler (errno=%d %m)", errno); - return -1; - } - BULLSEYE_EXCLUDE_BLOCK_END - return 0; -} - -int neigh_ib::destroy_ah() -{ - neigh_logdbg(""); - //For now we whouldn't destroy it - //We cannot destroy ah till each post_send with this ah has ended - //TODO: Need to think how to handle this - for now there will be ah leak - return 0; -#if 0 //unreachable code -#ifndef __COVERITY__ - if (m_val && ((neigh_ib_val *) m_val)->m_ah) { - IF_VERBS_FAILURE(ibv_destroy_ah(((neigh_ib_val *) m_val)->m_ah)) - { - neigh_logdbg("failed destroying address handle (errno=%d %m)", errno); - return -1; - }ENDIF_VERBS_FAILURE; - } - return 0; -#endif -#endif -} - -//================================================================================================================== - -neigh_ib_broadcast::neigh_ib_broadcast(neigh_key key) : neigh_ib(key, false) -{ - neigh_logdbg("Calling rdma_create_id"); - IF_RDMACM_FAILURE(rdma_create_id(g_p_neigh_table_mgr->m_neigh_cma_event_channel, &m_cma_id, (void *)this, m_rdma_port_space)) - { - neigh_logerr("Failed in rdma_create_id (errno=%d %m)", errno); - return; - } ENDIF_RDMACM_FAILURE; - - - neigh_logdbg("Calling rdma_bind_addr"); - struct sockaddr_in local_sockaddr; - local_sockaddr.sin_family = AF_INET; - local_sockaddr.sin_port = INPORT_ANY; - local_sockaddr.sin_addr.s_addr = m_p_dev->get_local_addr(); - - IF_RDMACM_FAILURE(rdma_bind_addr(m_cma_id, (struct sockaddr*)&local_sockaddr)) { - neigh_logerr("Failed in rdma_bind_addr (src=%d.%d.%d.%d) (errno=%d %m)", NIPQUAD(m_p_dev->get_local_addr()), errno); - return; - } ENDIF_RDMACM_FAILURE; - - build_mc_neigh_val(); - - m_state = true; -} - -void neigh_ib_broadcast::build_mc_neigh_val() -{ - m_val = new neigh_ib_val; - if(m_val == NULL) { - neigh_logerr("Failed allocating m_val"); - return; - } - - if (m_cma_id->verbs == NULL) { - neigh_logdbg("m_cma_id->verbs is NULL"); - return; - } - - m_val->m_l2_address = new IPoIB_addr(((m_p_dev->get_br_address())->get_address())); - if (m_val->m_l2_address == NULL) { - neigh_logerr("Failed allocating m_val->m_l2_address"); - return; - } - - ((neigh_ib_val *) m_val)->m_qkey = IPOIB_QKEY; - - memset(&((neigh_ib_val *) m_val)->m_ah_attr, 0, sizeof(((neigh_ib_val *) m_val)->m_ah_attr)); - memcpy( ((neigh_ib_val *) m_val)->m_ah_attr.grh.dgid.raw , &((m_val->m_l2_address->get_address())[4]), 16*sizeof(char)); - - ((neigh_ib_val *) m_val)->m_ah_attr.dlid = 0xc000; - ((neigh_ib_val *) m_val)->m_ah_attr.static_rate = 0x3; - ((neigh_ib_val *) m_val)->m_ah_attr.port_num = m_cma_id->port_num; - ((neigh_ib_val *) m_val)->m_ah_attr.is_global = 0x1; - - if(find_pd()) { - neigh_logerr("Failed find_pd()"); - return; - } - - if (create_ah()) - return; - - neigh_logdbg("IB broadcast neigh params are : ah=%p, qkey=%#x, sl=%#x, rate=%#x, port_num = %#x, qpn=%#x, dlid=%#x dgid = " IPOIB_HW_ADDR_PRINT_FMT_16, - ((neigh_ib_val *) m_val)->m_ah, ((neigh_ib_val *) m_val)->m_qkey, ((neigh_ib_val *) m_val)->m_ah_attr.sl, - ((neigh_ib_val *) m_val)->m_ah_attr.static_rate,((neigh_ib_val *) m_val)->m_ah_attr.port_num, - ((neigh_ib_val *) m_val)->get_qpn(), ((neigh_ib_val *) m_val)->m_ah_attr.dlid, IPOIB_HW_ADDR_PRINT_ADDR_16(((neigh_ib_val *) m_val)->m_ah_attr.grh.dgid.raw) ); - - -} - -bool neigh_ib_broadcast::get_peer_info(neigh_val * p_val) -{ - neigh_logfunc("calling neigh_entry get_peer_info. state = %d", m_state); - if (p_val == NULL) { - neigh_logdbg("p_val is NULL, return false"); - return false; - } - - auto_unlocker lock(m_lock); - if (m_state) { - neigh_logdbg("There is a valid val"); - *p_val = *m_val; - return m_state; - } - - return false; -} - -int neigh_ib_broadcast::send(neigh_send_info &s_info) -{ - NOT_IN_USE(s_info); - neigh_logerr("We should not call for this function, something is wrong"); - return false; -} - -void neigh_ib_broadcast::send_arp() -{ - neigh_logerr("We should not call for this function, something is wrong"); -} diff --git a/src/vma/proto/neighbour.h b/src/vma/proto/neighbour.h index ba1286d0a6..17fb70a7c1 100644 --- a/src/vma/proto/neighbour.h +++ b/src/vma/proto/neighbour.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -102,7 +76,7 @@ class hash class neigh_val : public tostr { public: - neigh_val(): m_trans_type(VMA_TRANSPORT_UNKNOWN), m_l2_address(NULL){}; + neigh_val(): m_l2_address(NULL){}; virtual ~neigh_val(){}; virtual void zero_all_members() @@ -116,73 +90,16 @@ class neigh_val : public tostr { if (this != &val) { m_l2_address = val.m_l2_address; - m_trans_type = val.m_trans_type; } return *this; } protected: - friend class neigh_entry; - friend class neigh_ib; - friend class neigh_eth; - friend class neigh_ib_broadcast; - transport_type_t m_trans_type; + friend class neigh_entry; + friend class neigh_eth; L2_address* m_l2_address; }; -class neigh_eth_val : public neigh_val -{ -public: - neigh_eth_val() - { - m_trans_type = VMA_TRANSPORT_ETH; - zero_all_members(); - } - - neigh_val & operator=(const neigh_val & val) - { - return neigh_val::operator=(val); - } - -private: - friend class neigh_eth; -}; - -class neigh_ib_val : public neigh_val -{ -public: - neigh_ib_val() : m_ah(NULL) { zero_all_members(); }; - - ibv_ah* get_ah()const { return m_ah; }; - ibv_ah_attr get_ah_attr() const { return m_ah_attr; }; - uint32_t get_qkey() const { return m_qkey; }; - uint32_t get_qpn() const - { - if (m_l2_address) - return(((IPoIB_addr *) m_l2_address)->get_qpn()); - else - return 0; - } - - neigh_val & operator=(const neigh_val & val); - -private: - friend class neigh_ib; - friend class neigh_ib_broadcast; - - ibv_ah_attr m_ah_attr; - ibv_ah* m_ah; - uint32_t m_qkey; - - void zero_all_members() - { - memset(&m_ah_attr, 0, sizeof(m_ah_attr)); - //m_ah = NULL; - m_qkey = 0; - neigh_val::zero_all_members(); - } -}; - /* neigh_entry inherits from cache_entry_subject where * Key = address (peer IP) * Val = class neigh_val @@ -220,14 +137,13 @@ class neigh_entry : public cache_entry_subject, public e EV_ADDR_RESOLVED, EV_PATH_RESOLVED, EV_ERROR, - EV_TIMEOUT_EXPIRED, // For IB MC join EV_UNHANDLED, EV_LAST }; friend class neighbour_table_mgr; - neigh_entry (neigh_key key, transport_type_t type, bool is_init_resources = true); + neigh_entry (neigh_key key, bool is_init_resources = true); virtual ~neigh_entry(); //Overwrite cach_entry virtual function @@ -269,7 +185,6 @@ class neigh_entry : public cache_entry_subject, public e enum rdma_port_space m_rdma_port_space; state_machine* m_state_machine; type m_type; // UC / MC - transport_type_t m_trans_type; bool m_state; unsent_queue_t m_unsent_queue; //Counter to sign that KickStart was already generated in ERROR_ST @@ -280,7 +195,7 @@ class neigh_entry : public cache_entry_subject, public e uint32_t m_arp_counter; net_device_val* m_p_dev; ring* m_p_ring; - vma_ibv_send_wr m_send_wqe; + ibv_send_wr m_send_wqe; ibv_sge m_sge; bool m_is_loopback; @@ -334,63 +249,6 @@ class neigh_entry : public cache_entry_subject, public e bool post_send_tcp(neigh_send_data *n_send_data); }; -class neigh_ib : public neigh_entry, public event_handler_ibverbs -{ -public: - friend class neighbour_table_mgr; - neigh_ib(neigh_key key, bool is_init_resources = true); - ~neigh_ib(); - - static void dofunc_enter_arp_resolved(const sm_info_t& func_info); - static void dofunc_enter_path_resolved(const sm_info_t& func_info); - -protected: - ibv_pd* m_pd; - - int find_pd(); - int create_ah(); - int destroy_ah(); - virtual int build_mc_neigh_val(struct rdma_cm_event* event_data, uint32_t & wait_after_join_msec); - -private: - - //Implementation of pure virtual functions - void handle_event_ibverbs_cb(void* ev_data, void* ctx); - void handle_timer_expired(void* user_data); - - // Overriding neigh_entry priv_enter_not_active - void priv_enter_not_active(); - void priv_enter_error(); - int priv_enter_arp_resolved(); - int priv_enter_path_resolved(struct rdma_cm_event* event_data, uint32_t & wait_after_join_msec); - virtual bool priv_handle_neigh_is_l2_changed(address_t); - // Overriding neigh_entry priv_enter_ready - int priv_enter_ready(); - - int handle_enter_arp_resolved_uc(); - int handle_enter_arp_resolved_mc(); - int build_uc_neigh_val(struct rdma_cm_event* event_data, uint32_t & wait_after_join_msec); - - event_t ibverbs_event_mapping(void* p_event_info); - virtual bool post_send_arp(bool); - virtual bool prepare_to_send_packet(header *); - - const uint32_t m_n_sysvar_wait_after_join_msec; -}; - -class neigh_ib_broadcast : public neigh_ib -{ -public: - neigh_ib_broadcast(neigh_key key); - virtual int send(neigh_send_info & s_info); - virtual bool get_peer_info(neigh_val * p_val); - virtual bool is_deletable() { return false; }; - -private: - void build_mc_neigh_val(); - virtual void send_arp(); -}; - class neigh_eth : public neigh_entry { public: diff --git a/src/vma/proto/neighbour_observer.h b/src/vma/proto/neighbour_observer.h deleted file mode 100644 index ee8b4684d7..0000000000 --- a/src/vma/proto/neighbour_observer.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - - -#ifndef NEIGHBOUR_OBSERVER_H -#define NEIGHBOUR_OBSERVER_H - -#include "vma/util/sys_vars.h" -#include "vma/infra/subject_observer.h" - -class neigh_observer : public observer -{ -public: - virtual transport_type_t get_obs_transport_type() const = 0; -}; - -#endif /* NEIGHBOUR_OBSERVER_H */ diff --git a/src/vma/proto/neighbour_table_mgr.cpp b/src/vma/proto/neighbour_table_mgr.cpp index 7ba12dc84f..891a85309f 100644 --- a/src/vma/proto/neighbour_table_mgr.cpp +++ b/src/vma/proto/neighbour_table_mgr.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -38,8 +12,6 @@ #include "vma/netlink/netlink_wrapper.h" #include "vma/event/netlink_event.h" #include "vma/proto/neighbour_table_mgr.h" - -#include "vma/proto/neighbour_observer.h" #include "vma/dev/net_device_table_mgr.h" #define MODULE_NAME "ntm:" @@ -94,35 +66,9 @@ bool neigh_table_mgr::register_observer(neigh_key key, neigh_entry* neigh_table_mgr::create_new_entry(neigh_key neigh_key, const observer* new_observer) { - observer * tmp = const_cast(new_observer); - const neigh_observer * dst = dynamic_cast(tmp) ; - - BULLSEYE_EXCLUDE_BLOCK_START - if (dst == NULL) { - //TODO: Need to add handling of this case - neigh_mgr_logpanic("dynamic_casr failed, new_observer type is not neigh_observer"); - } - BULLSEYE_EXCLUDE_BLOCK_END - - - transport_type_t transport = dst->get_obs_transport_type(); - - if (transport == VMA_TRANSPORT_IB) { - if(IS_BROADCAST_N(neigh_key.get_in_addr())){ - neigh_mgr_logdbg("Creating new neigh_ib_broadcast"); - return (new neigh_ib_broadcast(neigh_key)); - } - neigh_mgr_logdbg("Creating new neigh_ib"); - return (new neigh_ib(neigh_key)); - } - else if (transport == VMA_TRANSPORT_ETH) { - neigh_mgr_logdbg("Creating new neigh_eth"); - return (new neigh_eth(neigh_key)); - } - else { - neigh_mgr_logdbg("Cannot create new entry, transport type is UNKNOWN"); - return NULL; - } + NOT_IN_USE(new_observer); + neigh_mgr_logdbg("Creating new neigh_eth"); + return (new neigh_eth(neigh_key)); } void neigh_table_mgr::notify_cb(event *ev) diff --git a/src/vma/proto/neighbour_table_mgr.h b/src/vma/proto/neighbour_table_mgr.h index a42e9bc8a0..5ddf46c678 100644 --- a/src/vma/proto/neighbour_table_mgr.h +++ b/src/vma/proto/neighbour_table_mgr.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/netlink_socket_mgr.h b/src/vma/proto/netlink_socket_mgr.h index 94d02c7d61..af3655c549 100644 --- a/src/vma/proto/netlink_socket_mgr.h +++ b/src/vma/proto/netlink_socket_mgr.h @@ -1,39 +1,14 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef NETLINK_SOCKET_MGR_H #define NETLINK_SOCKET_MGR_H +#include #include #include #include @@ -48,6 +23,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "utils/bullseye.h" #include "utils/lock_wrapper.h" @@ -96,19 +76,19 @@ class netlink_socket_mgr table_t m_tab; - virtual bool parse_enrty(nlmsghdr *nl_header, Type *p_val) = 0; + virtual bool parse_entry(struct nl_object *nl_obj, void *p_val_context) = 0; virtual void update_tbl(); virtual void print_val_tbl(); void build_request(struct nlmsghdr **nl_msg); bool query(struct nlmsghdr *&nl_msg, int &len); int recv_info(); - void parse_tbl(int len, int *p_ent_num = NULL); + void parse_tbl_from_latest_cache(struct nl_cache *cache_state); private: nl_data_t m_data_type; - int m_fd; // netlink socket to communicate with the kernel + nl_sock *m_sock; // netlink socket to communicate with the kernel uint32_t m_pid; // process pid uint32_t m_seq_num; // seq num of the netlink messages char m_msg_buf[MSG_BUFF_SIZE]; // we use this buffer for sending/receiving netlink messages @@ -117,6 +97,7 @@ class netlink_socket_mgr /*********************************Implementation ********************************/ + template netlink_socket_mgr ::netlink_socket_mgr(nl_data_t data_type) { @@ -131,14 +112,19 @@ netlink_socket_mgr ::netlink_socket_mgr(nl_data_t data_type) // Create Socket BULLSEYE_EXCLUDE_BLOCK_START - if ((m_fd = orig_os_api.socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0) { + m_sock = nl_socket_alloc(); + if (m_sock == nullptr) { __log_err("NL socket Creation: "); return; } - if (orig_os_api.fcntl(m_fd, F_SETFD, FD_CLOEXEC) != 0) { - __log_warn("Fail in fctl, error = %d", errno); + if (nl_connect(m_sock, NETLINK_ROUTE) < 0) { + __log_err("NL socket Connection: "); + nl_socket_free(m_sock); + m_sock = nullptr; + return; } + BULLSEYE_EXCLUDE_BLOCK_END __log_dbg("Done"); @@ -148,161 +134,79 @@ template netlink_socket_mgr ::~netlink_socket_mgr() { __log_dbg(""); - if (m_fd) { - orig_os_api.close(m_fd); - m_fd = -1; + if (m_sock != nullptr) { + nl_socket_free(m_sock); + m_sock = nullptr; } - - __log_dbg("Done"); -} - -// This function build Netlink request to retrieve data (Rule, Route) from kernel. -// Parameters : -// nl_msg : request to be returned -template -void netlink_socket_mgr ::build_request(struct nlmsghdr **nl_msg) -{ - struct rtmsg *rt_msg; - - memset(m_msg_buf, 0, m_buff_size); - - // point the header and the msg structure pointers into the buffer - *nl_msg = (struct nlmsghdr *)m_msg_buf; - rt_msg = (struct rtmsg *)NLMSG_DATA(*nl_msg); - - //Fill in the nlmsg header - (*nl_msg)->nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); - (*nl_msg)->nlmsg_seq = m_seq_num++; - (*nl_msg)->nlmsg_pid = m_pid; - rt_msg->rtm_family = AF_INET; - - if (m_data_type == RULE_DATA_TYPE) - { - (*nl_msg)->nlmsg_type = RTM_GETRULE; - } - else if (m_data_type == ROUTE_DATA_TYPE) - { - (*nl_msg)->nlmsg_type = RTM_GETROUTE; - } - - (*nl_msg)->nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST; - -} - -// Query built request and receive requested data (Rule, Route) -// Parameters: -// nl_msg : request that is built previously. -// len : length of received data. -template -bool netlink_socket_mgr ::query(struct nlmsghdr *&nl_msg, int &len) -{ - if(m_fd < 0) - return false; - - BULLSEYE_EXCLUDE_BLOCK_START - if(orig_os_api.send(m_fd, nl_msg, nl_msg->nlmsg_len, 0) < 0){ - __log_err("Write To Socket Failed...\n"); - return false; - } - if((len = recv_info()) < 0) { - __log_err("Read From Socket Failed...\n"); - return false; - } - BULLSEYE_EXCLUDE_BLOCK_END - return true; -} - -// Receive requested data and save it locally. -// Return length of received data. -template -int netlink_socket_mgr ::recv_info() -{ - struct nlmsghdr *nlHdr; - int readLen = 0, msgLen = 0; - - char *buf_ptr = m_msg_buf; - - do{ - //Receive response from the kernel - BULLSEYE_EXCLUDE_BLOCK_START - if((readLen = orig_os_api.recv(m_fd, buf_ptr, MSG_BUFF_SIZE - msgLen, 0)) < 0){ - __log_err("SOCK READ: "); - return -1; - } - - nlHdr = (struct nlmsghdr *)buf_ptr; - - //Check if the header is valid - if((NLMSG_OK(nlHdr, (u_int)readLen) == 0) || (nlHdr->nlmsg_type == NLMSG_ERROR)) - { - __log_err("Error in received packet, readLen = %d, msgLen = %d, type=%d, bufLen = %d", readLen, nlHdr->nlmsg_len, nlHdr->nlmsg_type, MSG_BUFF_SIZE); - if (nlHdr->nlmsg_len == MSG_BUFF_SIZE) { - __log_err("The buffer we pass to netlink is too small for reading the whole table"); - } - return -1; - } - BULLSEYE_EXCLUDE_BLOCK_END - - buf_ptr += readLen; - msgLen += readLen; - - //Check if the its the last message - if(nlHdr->nlmsg_type == NLMSG_DONE || - (nlHdr->nlmsg_flags & NLM_F_MULTI) == 0) { - break; - } - - } while((nlHdr->nlmsg_seq != m_seq_num) || (nlHdr->nlmsg_pid != m_pid)); - return msgLen; + __log_dbg("Done"); } // Update data in a table template void netlink_socket_mgr ::update_tbl() { - struct nlmsghdr *nl_msg = NULL; - int counter = 0; - int len = 0; - m_tab.entries_num = 0; - // Build Netlink request to get route entry - build_request(&nl_msg); + struct nl_cache *cache_state = nullptr; + int err = 0; - // Query built request and receive requested data - if (!query(nl_msg, len)) - return; + // cache allocation fetches the latest existing rules/routes + if (m_data_type == RULE_DATA_TYPE) { + err = rtnl_rule_alloc_cache(m_sock, AF_INET, &cache_state); + } else if (m_data_type == ROUTE_DATA_TYPE) { + err = rtnl_route_alloc_cache(m_sock, AF_INET, 0, &cache_state); + } - // Parse received data in custom object (route_val) - parse_tbl(len, &counter); + if (err < 0) { + if (cache_state) { + nl_cache_free(cache_state); + } + + throw_vma_exception("Failed to allocate route cache"); + } - m_tab.entries_num = counter; + // Parse received data in custom object (route_val) + parse_tbl_from_latest_cache(cache_state); - if (counter >= MAX_TABLE_SIZE) { - __log_warn("reached the maximum route table size"); + if (cache_state) { + nl_cache_free(cache_state); } } // Parse received data in a table -// Parameters: +// Parameters: // len : length of received data. // p_ent_num : number of rows in received data. template -void netlink_socket_mgr ::parse_tbl(int len, int *p_ent_num) +void netlink_socket_mgr::parse_tbl_from_latest_cache(struct nl_cache *cache_state) { - struct nlmsghdr *nl_header; - int entry_cnt = 0; + uint16_t entry_cnt = 0; + + struct nl_iterator_context { + Type *p_val_array; + uint16_t &entry_cnt; + netlink_socket_mgr *this_ptr; + } iterator_context = {m_tab.value, entry_cnt, this}; + + // a lambda can't be casted to a c-fptr with ref captures - so we provide context ourselves + nl_cache_foreach( + cache_state, + [](struct nl_object *nl_obj, void *context) { + nl_iterator_context *operation_context = + reinterpret_cast(context); + const bool is_valid_entry = operation_context->this_ptr->parse_entry( + nl_obj, operation_context->p_val_array + operation_context->entry_cnt); + if (is_valid_entry) { + ++operation_context->entry_cnt; + } + }, + &iterator_context); - nl_header = (struct nlmsghdr *) m_msg_buf; - for(;NLMSG_OK(nl_header, (u_int)len) && entry_cnt < MAX_TABLE_SIZE; nl_header = NLMSG_NEXT(nl_header, len)) - { - if (parse_enrty(nl_header, &m_tab.value[entry_cnt])) { - entry_cnt++; - } + m_tab.entries_num = entry_cnt; + if (m_tab.entries_num >= MAX_TABLE_SIZE) { + __log_warn("reached the maximum route table size"); } - if (p_ent_num) - *p_ent_num = entry_cnt; } //print the table diff --git a/src/vma/proto/peer_key.h b/src/vma/proto/peer_key.h index c23ddcb609..0e954161b7 100644 --- a/src/vma/proto/peer_key.h +++ b/src/vma/proto/peer_key.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef __PEER_KEY_H__ #define __PEER_KEY_H__ diff --git a/src/vma/proto/route_entry.cpp b/src/vma/proto/route_entry.cpp index d8eae6cb6e..3fa57db704 100644 --- a/src/vma/proto/route_entry.cpp +++ b/src/vma/proto/route_entry.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/route_entry.h b/src/vma/proto/route_entry.h index 848ad13800..308e0915d2 100644 --- a/src/vma/proto/route_entry.h +++ b/src/vma/proto/route_entry.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/route_rule_table_key.h b/src/vma/proto/route_rule_table_key.h index df67634657..9cc4d5230d 100644 --- a/src/vma/proto/route_rule_table_key.h +++ b/src/vma/proto/route_rule_table_key.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/route_table_mgr.cpp b/src/vma/proto/route_table_mgr.cpp index 34ba6eb857..8c0dcabea7 100644 --- a/src/vma/proto/route_table_mgr.cpp +++ b/src/vma/proto/route_table_mgr.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -182,7 +156,7 @@ void route_table_mgr::rt_mgr_update_source_ip() if (p_val->get_gw_addr() && !p_val->get_src_addr()) { route_val* p_val_dst; in_addr_t in_addr = p_val->get_gw_addr(); - unsigned char table_id = p_val->get_table_id(); + uint32_t table_id = p_val->get_table_id(); if (find_route_val(in_addr, table_id, p_val_dst)) { if (p_val_dst->get_src_addr()) { p_val->set_src_addr(p_val_dst->get_src_addr()); @@ -234,91 +208,103 @@ void route_table_mgr::rt_mgr_update_source_ip() } } -bool route_table_mgr::parse_enrty(nlmsghdr *nl_header, route_val *p_val) +bool route_table_mgr::parse_entry(struct nl_object *nl_obj, void *p_val_context) { - int len; - struct rtmsg *rt_msg; - struct rtattr *rt_attribute; - - // get route entry header - rt_msg = (struct rtmsg *) NLMSG_DATA(nl_header); + route_val *p_val = static_cast(p_val_context); + // Cast the generic nl_object to a specific route or rule object + struct rtnl_route *route = reinterpret_cast(nl_obj); // we are not concerned about the local and default route table - if (rt_msg->rtm_family != AF_INET || rt_msg->rtm_table == RT_TABLE_LOCAL) + if (rtnl_route_get_family(route) != AF_INET || rtnl_route_get_table(route) == RT_TABLE_LOCAL) { return false; + } - p_val->set_protocol(rt_msg->rtm_protocol); - p_val->set_scope(rt_msg->rtm_scope); - p_val->set_type(rt_msg->rtm_type); - p_val->set_table_id(rt_msg->rtm_table); - - in_addr_t dst_mask = htonl(VMA_NETMASK(rt_msg->rtm_dst_len)); - p_val->set_dst_mask(dst_mask); - p_val->set_dst_pref_len(rt_msg->rtm_dst_len); + // Set protocol, scope, type, and table ID using libnl functions + p_val->set_protocol(rtnl_route_get_protocol(route)); + p_val->set_scope(rtnl_route_get_scope(route)); + p_val->set_type(rtnl_route_get_type(route)); + /* coverity[check_return] */ + p_val->set_table_id(rtnl_route_get_table(route)); + + // Set destination mask and prefix length + struct nl_addr *dst = rtnl_route_get_dst(route); + if (dst != nullptr) { + in_addr_t dst_mask = htonl(VMA_NETMASK(nl_addr_get_prefixlen(dst))); + p_val->set_dst_mask(dst_mask); + p_val->set_dst_pref_len(nl_addr_get_prefixlen(dst)); + } - len = RTM_PAYLOAD(nl_header); - rt_attribute = (struct rtattr *) RTM_RTA(rt_msg); + parse_attr(route, p_val); - for (;RTA_OK(rt_attribute, len);rt_attribute=RTA_NEXT(rt_attribute,len)) { - parse_attr(rt_attribute, p_val); - } p_val->set_state(true); p_val->set_str(); return true; } -void route_table_mgr::parse_attr(struct rtattr *rt_attribute, route_val *p_val) +static inline bool get_addr_from_nl_addr(struct nl_addr *addr, in_addr_t *p_addr) { - switch (rt_attribute->rta_type) { - case RTA_DST: - p_val->set_dst_addr(*(in_addr_t *)RTA_DATA(rt_attribute)); - break; - // next hop IPv4 address - case RTA_GATEWAY: - p_val->set_gw(*(in_addr_t *)RTA_DATA(rt_attribute)); - break; - // unique ID associated with the network interface - case RTA_OIF: - p_val->set_if_index(*(int *)RTA_DATA(rt_attribute)); - char if_name[IFNAMSIZ]; - if_indextoname(p_val->get_if_index(),if_name); - p_val->set_if_name(if_name); - break; - case RTA_SRC: - case RTA_PREFSRC: - p_val->set_src_addr(*(in_addr_t *)RTA_DATA(rt_attribute)); - break; - case RTA_TABLE: - p_val->set_table_id(*(uint32_t *)RTA_DATA(rt_attribute)); - break; - case RTA_METRICS: - { - struct rtattr *rta = (struct rtattr *)RTA_DATA(rt_attribute); - int len = RTA_PAYLOAD(rt_attribute); - uint16_t type; - while (RTA_OK(rta, len)) { - type = rta->rta_type; - switch (type) { - case RTAX_MTU: - p_val->set_mtu(*(uint32_t *)RTA_DATA(rta)); - break; - default: - rt_mgr_logdbg("got unexpected METRICS %d %x", - type, *(uint32_t *)RTA_DATA(rta)); - break; - } - rta = RTA_NEXT(rta, len); + if (addr && nl_addr_get_family(addr) == AF_INET) { + void *binary_addr = nl_addr_get_binary_addr(addr); + unsigned int addr_len = nl_addr_get_len(addr); + + if (binary_addr && addr_len == sizeof(in_addr_t)) { + memcpy(p_addr, binary_addr, sizeof(in_addr_t)); + return true; } - break; } - default: - rt_mgr_logdbg("got unexpected type %d %x", rt_attribute->rta_type, - *(uint32_t *)RTA_DATA(rt_attribute)); - break; + return false; +} + +void route_table_mgr::parse_attr(struct rtnl_route *route, route_val *p_val) +{ + struct nl_addr *addr; + + // Destination Address + addr = rtnl_route_get_dst(route); + in_addr_t dst_addr = 0; + if (get_addr_from_nl_addr(addr, &dst_addr) && dst_addr) { + p_val->set_dst_addr(dst_addr); + } + + // Gateway Address (Next Hop) + struct rtnl_nexthop *nh = rtnl_route_nexthop_n(route, 0); // Assuming the first nexthop + in_addr_t gw_addr = 0; + if (nh && get_addr_from_nl_addr(rtnl_route_nh_get_gateway(nh), &gw_addr) && gw_addr) { + p_val->set_gw(gw_addr); + } + + // Output Interface Index and Name + const int if_index = rtnl_route_nh_get_ifindex(nh); + if (if_index > 0) { + p_val->set_if_index(if_index); + + char if_name[IFNAMSIZ] = {0}; + if_indextoname(if_index, if_name); + p_val->set_if_name(if_name); + } + + // Source Address + addr = rtnl_route_get_pref_src(route); + in_addr_t pref_src_addr = 0; + if (get_addr_from_nl_addr(addr, &pref_src_addr) && pref_src_addr) { + p_val->set_src_addr(pref_src_addr); + } + + // Table ID + /* coverity[check_return] */ + p_val->set_table_id(rtnl_route_get_table(route)); + + // Metrics (e.g., MTU) + uint32_t mtu = 0; + int get_metric_result = rtnl_route_get_metric(route, RTAX_MTU, &mtu); + if (get_metric_result == 0) { + if (mtu > 0) { + p_val->set_mtu(mtu); + } } } -bool route_table_mgr::find_route_val(in_addr_t &dst, unsigned char table_id, route_val* &p_val) +bool route_table_mgr::find_route_val(in_addr_t &dst, uint32_t table_id, route_val* &p_val) { ip_address dst_addr = dst; rt_mgr_logfunc("dst addr '%s'", dst_addr.to_str().c_str()); @@ -357,12 +343,12 @@ bool route_table_mgr::route_resolve(IN route_rule_table_key key, OUT route_resul rt_mgr_logdbg("dst addr '%s'", dst_addr.to_str().c_str()); route_val *p_val = NULL; - std::deque table_id_list; + std::deque table_id_list; g_p_rule_table_mgr->rule_resolve(key, table_id_list); auto_unlocker lock(m_lock); - std::deque::iterator table_id_iter = table_id_list.begin(); + std::deque::iterator table_id_iter = table_id_list.begin(); for (; table_id_iter != table_id_list.end(); table_id_iter++) { if (find_route_val(dst, *table_id_iter, p_val)) { res.p_src = p_val->get_src_addr(); @@ -392,7 +378,7 @@ void route_table_mgr::update_entry(INOUT route_entry* p_ent, bool b_register_to_ if (p_rr_entry && p_rr_entry->get_val(p_rr_val)) { route_val* p_val = NULL; in_addr_t peer_ip = p_ent->get_key().get_dst_ip(); - unsigned char table_id; + uint32_t table_id; for (std::deque::iterator p_rule_val = p_rr_val->begin(); p_rule_val != p_rr_val->end(); p_rule_val++) { table_id = (*p_rule_val)->get_table_id(); if (find_route_val(peer_ip, table_id, p_val)) { @@ -406,14 +392,7 @@ void route_table_mgr::update_entry(INOUT route_entry* p_ent, bool b_register_to_ rt_mgr_logdbg("Disabling Offload for route_entry '%s' - this is BC address", p_ent->to_str().c_str()); // Need to route traffic to/from OS // Prevent registering of net_device to route entry - } - // Check if: Local loopback over Ethernet case which was not supported before OFED 2.1 - /*else if (p_ndv && (p_ndv->get_transport_type() == VMA_TRANSPORT_ETH) && (peer_ip == src_addr)) { - rt_mgr_logdbg("Disabling Offload for route_entry '%s' - this is an Ethernet unicast loopback route", p_ent->to_str().c_str()); - // Need to route traffic to/from OS - // Prevent registering of net_device to route entry - }*/ - else { + } else { // register to net device for bonding events p_ent->register_to_net_device(); } diff --git a/src/vma/proto/route_table_mgr.h b/src/vma/proto/route_table_mgr.h index 1aac72458d..966833462e 100644 --- a/src/vma/proto/route_table_mgr.h +++ b/src/vma/proto/route_table_mgr.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -69,17 +43,17 @@ class route_table_mgr : public netlink_socket_mgr, public cache_table virtual void notify_cb(event *ev); protected: - virtual bool parse_enrty(nlmsghdr *nl_header, route_val *p_val); + virtual bool parse_entry(struct nl_object *nl_obj, void *p_val_context); private: // in constructor creates route_entry for each net_dev, to receive events in case there are no other route_entrys in_addr_route_entry_map_t m_rte_list_for_each_net_dev; - bool find_route_val(in_addr_t &dst_addr, unsigned char table_id, route_val* &p_val); + bool find_route_val(in_addr_t &dst_addr, uint32_t table_id, route_val* &p_val); // save current main rt table void update_tbl(); - void parse_attr(struct rtattr *rt_attribute, route_val *p_val); + void parse_attr(struct rtnl_route *route, route_val *p_val); void rt_mgr_update_source_ip(); diff --git a/src/vma/proto/route_val.cpp b/src/vma/proto/route_val.cpp index 2a4e194db3..fb9123a689 100644 --- a/src/vma/proto/route_val.cpp +++ b/src/vma/proto/route_val.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/route_val.h b/src/vma/proto/route_val.h index fdab2345f7..d1b802dd2f 100644 --- a/src/vma/proto/route_val.h +++ b/src/vma/proto/route_val.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/rule_entry.cpp b/src/vma/proto/rule_entry.cpp index d5667719d1..d3b375bc9b 100644 --- a/src/vma/proto/rule_entry.cpp +++ b/src/vma/proto/rule_entry.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/rule_entry.h b/src/vma/proto/rule_entry.h index 0476c6e62f..71b849838d 100644 --- a/src/vma/proto/rule_entry.h +++ b/src/vma/proto/rule_entry.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/proto/rule_table_mgr.cpp b/src/vma/proto/rule_table_mgr.cpp index e9ba851458..cff9f00d45 100644 --- a/src/vma/proto/rule_table_mgr.cpp +++ b/src/vma/proto/rule_table_mgr.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -93,74 +67,82 @@ void rule_table_mgr::update_tbl() } // Parse received rule entry into custom object (rule_val). -// Parameters: -// nl_header : object that contain rule entry. +// Parameters: +// nl_obj : object that contain rule entry. // p_val : custom object that contain parsed rule data. // return true if its not related to local or default table, false otherwise. -bool rule_table_mgr::parse_enrty(nlmsghdr *nl_header, rule_val *p_val) +bool rule_table_mgr::parse_entry(struct nl_object *nl_obj, void *p_val_context) { - int len; - struct rtmsg *rt_msg; - struct rtattr *rt_attribute; - - // get rule entry header - rt_msg = (struct rtmsg *) NLMSG_DATA(nl_header); + rule_val *p_val = static_cast(p_val_context); + // Cast the generic nl_object to a specific route or rule object + struct rtnl_rule *rule = reinterpret_cast(nl_obj); - // we are not concerned about the local and default rule table - if (rt_msg->rtm_family != AF_INET || rt_msg->rtm_table == RT_TABLE_LOCAL) + uint32_t table_id = rtnl_rule_get_table(rule); + if (rtnl_rule_get_family(rule) != AF_INET || table_id == RT_TABLE_LOCAL) { return false; + } - p_val->set_protocol(rt_msg->rtm_protocol); - p_val->set_scope(rt_msg->rtm_scope); - p_val->set_type(rt_msg->rtm_type); - p_val->set_tos(rt_msg->rtm_tos); - p_val->set_table_id(rt_msg->rtm_table); + p_val->set_tos(rtnl_rule_get_dsfield(rule)); + p_val->set_table_id(table_id); - len = RTM_PAYLOAD(nl_header); - rt_attribute = (struct rtattr *) RTM_RTA(rt_msg); + parse_attr(rule, p_val); - for (;RTA_OK(rt_attribute, len);rt_attribute=RTA_NEXT(rt_attribute,len)) { - parse_attr(rt_attribute, p_val); - } p_val->set_state(true); p_val->set_str(); return true; } // Parse received rule attribute for given rule. -// Parameters: -// rt_attribute : object that contain rule attribute. +// Parameters: +// rule : object that contain rule attribute. // p_val : custom object that contain parsed rule data. -void rule_table_mgr::parse_attr(struct rtattr *rt_attribute, rule_val *p_val) +void rule_table_mgr::parse_attr(struct rtnl_rule *rule, rule_val *p_val) { - switch (rt_attribute->rta_type) { - case FRA_PRIORITY: - p_val->set_priority(*(uint32_t *)RTA_DATA(rt_attribute)); - break; - case FRA_DST: - p_val->set_dst_addr(*(in_addr_t *)RTA_DATA(rt_attribute)); - break; - case FRA_SRC: - p_val->set_src_addr(*(in_addr_t *)RTA_DATA(rt_attribute)); - break; - case FRA_IFNAME: - p_val->set_iif_name((char *)RTA_DATA(rt_attribute)); - break; - case FRA_TABLE: - p_val->set_table_id(*(uint32_t *)RTA_DATA(rt_attribute)); - break; + // FRA_PRIORITY: Rule Priority + uint32_t priority = rtnl_rule_get_prio(rule); + if (priority) { + p_val->set_priority(priority); + } + + // FRA_DST: Destination Address + struct nl_addr *dst = rtnl_rule_get_dst(rule); + if (dst) { + void *binary_addr = nl_addr_get_binary_addr(dst); + if (binary_addr) { + p_val->set_dst_addr(*(in_addr_t *)binary_addr); + } + } + + // FRA_SRC: Source Address + struct nl_addr *src = rtnl_rule_get_src(rule); + if (src) { + void *binary_addr = nl_addr_get_binary_addr(src); + if (binary_addr) { + p_val->set_src_addr(*(in_addr_t *)binary_addr); + } + } + + // FRA_IFNAME: Input Interface Name + char *iif_name = rtnl_rule_get_iif(rule); + if (iif_name) { + p_val->set_iif_name(iif_name); + } + + // FRA_TABLE: Table ID + uint32_t table_id = rtnl_rule_get_table(rule); + if (table_id) { + p_val->set_table_id(table_id); + } + #if DEFINED_FRA_OIFNAME - case FRA_OIFNAME: - p_val->set_oif_name((char *)RTA_DATA(rt_attribute)); - break; -#endif - default: - rr_mgr_logdbg("got undetected rta_type %d %x", rt_attribute->rta_type, *(uint32_t *)RTA_DATA(rt_attribute)); - break; + // FRA_OIFNAME: Output Interface Name (if available) + char *oif_name = rtnl_rule_get_oif(rule); + if (oif_name) { + p_val->set_oif_name(oif_name); } +#endif } - // Create rule entry object for given destination key and fill it with matching rule value from rule table. // Parameters: // key : key object that contain information about destination. @@ -261,7 +243,7 @@ bool rule_table_mgr::is_matching_rule(route_rule_table_key key, rule_val* p_val) // key : key object that contain information about destination. // table_id_list : list that will contain table ID for all rule that match destination info // Returns true if at least one rule match destination info, false otherwise. -bool rule_table_mgr::rule_resolve(route_rule_table_key key, std::deque &table_id_list) +bool rule_table_mgr::rule_resolve(route_rule_table_key key, std::deque &table_id_list) { rr_mgr_logdbg("dst info: '%s'", key.to_str().c_str()); diff --git a/src/vma/proto/rule_table_mgr.h b/src/vma/proto/rule_table_mgr.h index 6bf7368e44..85a4077549 100644 --- a/src/vma/proto/rule_table_mgr.h +++ b/src/vma/proto/rule_table_mgr.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -51,15 +25,15 @@ class rule_table_mgr : public netlink_socket_mgr, public cache_table_m rule_entry* create_new_entry(route_rule_table_key key, const observer *obs); void update_entry(rule_entry* p_ent); - bool rule_resolve(route_rule_table_key key, std::deque &table_id_list); + bool rule_resolve(route_rule_table_key key, std::deque &table_id_list); protected: - virtual bool parse_enrty(nlmsghdr *nl_header, rule_val *p_val); + virtual bool parse_entry(struct nl_object *nl_obj, void *p_val_context); virtual void update_tbl(); private: - void parse_attr(struct rtattr *rt_attribute, rule_val *p_val); + void parse_attr(struct rtnl_rule *rule, rule_val *p_val); bool find_rule_val(route_rule_table_key key, std::deque* &p_val); bool is_matching_rule(route_rule_table_key rrk, rule_val* p_val); diff --git a/src/vma/proto/rule_val.cpp b/src/vma/proto/rule_val.cpp index 638fbb4c17..877349820e 100644 --- a/src/vma/proto/rule_val.cpp +++ b/src/vma/proto/rule_val.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -46,9 +20,6 @@ rule_val::rule_val(): cache_observer() { - m_protocol = 0; - m_scope = 0; - m_type = 0; m_dst_addr = 0; m_src_addr = 0; memset(m_oif_name, 0, IFNAMSIZ * sizeof(char)); diff --git a/src/vma/proto/rule_val.h b/src/vma/proto/rule_val.h index 3412722cb5..d89c219ab3 100644 --- a/src/vma/proto/rule_val.h +++ b/src/vma/proto/rule_val.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -52,9 +26,6 @@ class rule_val : public cache_observer inline void set_dst_addr(in_addr_t const &dst_addr) { m_dst_addr = dst_addr; }; inline void set_src_addr(in_addr_t const &src_addr) { m_src_addr = src_addr; }; - inline void set_protocol(unsigned char protocol) { m_protocol = protocol; }; - inline void set_scope(unsigned char scope) { m_scope = scope; }; - inline void set_type(unsigned char type) { m_type = type; }; inline void set_tos(unsigned char tos) { m_tos = tos; }; inline void set_table_id(uint32_t table_id) { m_table_id = table_id; }; inline void set_iif_name(char *iif_name) { memcpy(m_iif_name, iif_name, IFNAMSIZ); }; @@ -78,9 +49,6 @@ class rule_val : public cache_observer private: - unsigned char m_protocol; - unsigned char m_scope; - unsigned char m_type; unsigned char m_tos; union { diff --git a/src/vma/proto/vma_lwip.cpp b/src/vma/proto/vma_lwip.cpp index 4855ea577c..c4f15ad667 100644 --- a/src/vma/proto/vma_lwip.cpp +++ b/src/vma/proto/vma_lwip.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "utils/rdtsc.h" diff --git a/src/vma/proto/vma_lwip.h b/src/vma/proto/vma_lwip.h index fe06698ff9..bf5818f2d4 100644 --- a/src/vma/proto/vma_lwip.h +++ b/src/vma/proto/vma_lwip.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -47,8 +21,6 @@ typedef enum vma_wr_tx_packet_attr { VMA_TX_PACKET_REXMIT = TCP_WRITE_REXMIT, /* 0x08 */ /* nop send operation. */ VMA_TX_PACKET_DUMMY = TCP_WRITE_DUMMY, /* 0x10 */ - /* large segment offload operation. */ - VMA_TX_PACKET_TSO = TCP_WRITE_TSO, /* 0x20 */ /* sendfile operation. */ VMA_TX_FILE = TCP_WRITE_FILE, /* 0x40 */ diff --git a/src/vma/sock/cleanable_obj.h b/src/vma/sock/cleanable_obj.h index 2d7323333c..77e1159ceb 100644 --- a/src/vma/sock/cleanable_obj.h +++ b/src/vma/sock/cleanable_obj.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/sock/fd_collection.cpp b/src/vma/sock/fd_collection.cpp index 26a5e59370..2bdda59ffa 100644 --- a/src/vma/sock/fd_collection.cpp +++ b/src/vma/sock/fd_collection.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -506,11 +480,13 @@ int fd_collection::add_cq_channel_fd(int cq_ch_fd, ring* p_ring) fdcoll_logwarn("cq channel fd already exists in fd_collection"); m_p_cq_channel_map[cq_ch_fd] = NULL; delete p_cq_ch_info; + // coverity[assigned_pointer:FALSE] /* NULL asign after freed object */ p_cq_ch_info = NULL; } BULLSEYE_EXCLUDE_BLOCK_END unlock(); + // coverity[value_overwrite:FALSE] /* p_cq_ch_info is NULL here */ p_cq_ch_info = new cq_channel_info(p_ring); lock(); @@ -642,7 +618,6 @@ void fd_collection::handle_timer_expired(void* user_data) if (p_sock_fd) { p_sock_fd->clean_obj(); - p_sock_fd = NULL; } //Deactivate the timer since there are no any pending to remove socket to handle anymore diff --git a/src/vma/sock/fd_collection.h b/src/vma/sock/fd_collection.h index b44f46e862..dfe7776d95 100644 --- a/src/vma/sock/fd_collection.h +++ b/src/vma/sock/fd_collection.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/sock/pipeinfo.cpp b/src/vma/sock/pipeinfo.cpp index 1daabb028f..eea7b550d3 100644 --- a/src/vma/sock/pipeinfo.cpp +++ b/src/vma/sock/pipeinfo.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -267,6 +241,7 @@ ssize_t pipeinfo::tx(vma_tx_call_attr_t &tx_arg) const int __flags = tx_arg.attr.msg.flags; const struct sockaddr *__to = tx_arg.attr.msg.addr; const socklen_t __tolen = tx_arg.attr.msg.len; + /* coverity[assigned_value] */ ssize_t ret = -1; pi_logfunc(""); diff --git a/src/vma/sock/pipeinfo.h b/src/vma/sock/pipeinfo.h index 59b5154661..7eefeac11e 100644 --- a/src/vma/sock/pipeinfo.h +++ b/src/vma/sock/pipeinfo.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/sock/pkt_rcvr_sink.h b/src/vma/sock/pkt_rcvr_sink.h index 1289224c01..353376e6b6 100644 --- a/src/vma/sock/pkt_rcvr_sink.h +++ b/src/vma/sock/pkt_rcvr_sink.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/sock/pkt_sndr_source.h b/src/vma/sock/pkt_sndr_source.h index 2e4d1ca849..14b21d603c 100644 --- a/src/vma/sock/pkt_sndr_source.h +++ b/src/vma/sock/pkt_sndr_source.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/sock/sock-redirect.cpp b/src/vma/sock/sock-redirect.cpp index 882cde080f..de67fccede 100644 --- a/src/vma/sock/sock-redirect.cpp +++ b/src/vma/sock/sock-redirect.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -127,9 +101,9 @@ void assign_dlsym(T &ptr, const char *name) { } \ } -#define SET_EXTRA_API(dst, func, mask) do { \ - vma_api->dst = func; \ - vma_api->vma_extra_supported_mask |= mask; \ +#define SET_EXTRA_API(__dst, __func, __mask) do { \ + vma_api->__dst = __func; \ + vma_api->vma_extra_supported_mask |= __mask; \ } while(0); #define VERIFY_PASSTROUGH_CHANGED(__ret, __func_and_params__) do { \ @@ -145,7 +119,6 @@ void get_orig_funcs() // Save pointer to original functions GET_ORIG_FUNC(socket); GET_ORIG_FUNC(close); - GET_ORIG_FUNC(close); GET_ORIG_FUNC(__res_iclose); GET_ORIG_FUNC(shutdown); GET_ORIG_FUNC(listen); @@ -319,9 +292,9 @@ void dbg_check_if_need_to_send_mcpkt() dbg_check_if_need_to_send_mcpkt_prevent_nested_calls--; } -void handle_close(int fd, bool cleanup, bool passthrough) +bool handle_close(int fd, bool cleanup, bool passthrough) { - + bool to_close_now = true; srdr_logfunc("Cleanup fd=%d", fd); if (g_p_fd_collection) { @@ -330,12 +303,17 @@ void handle_close(int fd, bool cleanup, bool passthrough) if (fd_collection_get_sockfd(fd)) { g_p_fd_collection->del_sockfd(fd, cleanup); + if (safe_mce_sys().deferred_close) { + to_close_now = false; + } } if (fd_collection_get_epfd(fd)) { g_p_fd_collection->del_epfd(fd, cleanup); } } + + return to_close_now; } @@ -466,7 +444,9 @@ int vma_socketxtreme_free_vma_packets(struct vma_packet_desc_t *packets, int num p_socket_object->free_buffs(packets[i].total_len); } if (rng) { - rng->reclaim_recv_buffers(desc); + if (!rng->reclaim_recv_buffers(desc)) { + g_buffer_pool_rx->put_buffers_thread_safe(desc); + } } else { goto err; } @@ -601,6 +581,8 @@ int vma_add_conf_rule(const char *config_line) extern "C" int vma_thread_offload(int offload, pthread_t tid) { + DO_GLOBAL_CTORS(); + if (g_p_fd_collection) { g_p_fd_collection->offloading_rule_change_thread(offload, tid); } else { @@ -754,45 +736,50 @@ int vma_dereg_mr_on_ring(int __fd, void *addr, size_t length) } } -extern "C" -int vma_get_dpcp_devices(uintptr_t **devices, size_t *devices_num) +static inline struct cmsghdr * __cmsg_nxthdr(void *__ctl, size_t __size, struct cmsghdr *__cmsg) { -#ifdef DEFINED_DPCP - ib_context_map_t *ib_ctx_map = NULL; - ib_ctx_handler *p_ib_ctx_h = NULL; - size_t found_devs = 0; + struct cmsghdr * __ptr; - if (!devices_num) { - return EINVAL; + __ptr = (struct cmsghdr*)(((unsigned char *) __cmsg) + CMSG_ALIGN(__cmsg->cmsg_len)); + if ((unsigned long)((char*)(__ptr + 1) - (char *) __ctl) > __size) { + return NULL; } - ib_ctx_map = g_p_ib_ctx_handler_collection->get_ib_cxt_list(); - if (ib_ctx_map) { - ib_context_map_t::iterator iter; + return __ptr; +} + +extern "C" +int vma_ioctl(void *cmsg_hdr, size_t cmsg_len) +{ + struct cmsghdr *cmsg = (struct cmsghdr *)cmsg_hdr; + + for (; cmsg; cmsg = __cmsg_nxthdr((struct cmsghdr *)cmsg_hdr, cmsg_len, cmsg)) { + if (cmsg->cmsg_type == CMSG_VMA_IOCTL_USER_ALLOC) { - for (iter = ib_ctx_map->begin(); iter != ib_ctx_map->end(); iter++) { - p_ib_ctx_h = iter->second; - if (p_ib_ctx_h->get_dpcp_adapter()) { - if (devices && (found_devs < *devices_num)) { - devices[found_devs] = (uintptr_t*)p_ib_ctx_h->get_dpcp_adapter(); + if (!g_init_global_ctors_done && + (cmsg->cmsg_len - CMSG_LEN(0)) == + (sizeof(uint8_t) + sizeof(alloc_t) + sizeof(free_t))) { + uint8_t *ptr = (uint8_t *)CMSG_DATA(cmsg); + + memcpy(&safe_mce_sys().m_ioctl.user_alloc.flags, ptr, sizeof(uint8_t)); + ptr += sizeof(uint8_t); + memcpy(&safe_mce_sys().m_ioctl.user_alloc.memalloc, ptr, sizeof(alloc_t)); + ptr += sizeof(alloc_t); + memcpy(&safe_mce_sys().m_ioctl.user_alloc.memfree, ptr, sizeof(free_t)); + if (!(safe_mce_sys().m_ioctl.user_alloc.memalloc && safe_mce_sys().m_ioctl.user_alloc.memfree) || + !(safe_mce_sys().m_ioctl.user_alloc.flags & (VMA_IOCTL_USER_ALLOC_FLAG_TX | VMA_IOCTL_USER_ALLOC_FLAG_RX))) { + srdr_logdbg("Invalid data for CMSG_VMA_IOCTL_USER_ALLOC\n"); + errno = EINVAL; + return -1; } - found_devs++; + } else { + errno = EINVAL; + return -1; } } } - *devices_num = found_devs; - srdr_logdbg_entry("returned %zd devices", found_devs); - return 0; -#else - NOT_IN_USE(devices); - NOT_IN_USE(devices_num); - VLOG_PRINTF_ONCE_THEN_ALWAYS(VLOG_WARNING, VLOG_DEBUG, - "vma_get_dpcp_devices is no supported"); - errno = EOPNOTSUPP; - return -1; -#endif /* DEFINED_DPCP */ } //----------------------------------------------------------------------------- @@ -853,9 +840,9 @@ int close(int __fd) srdr_logdbg_entry("fd=%d", __fd); - handle_close(__fd); + bool close_now = handle_close(__fd); - return orig_os_api.close(__fd); + return close_now ? orig_os_api.close(__fd) : 0; } extern "C" @@ -1105,34 +1092,42 @@ int getsockopt(int __fd, int __level, int __optname, srdr_logdbg_entry("fd=%d, level=%d, optname=%d", __fd, __level, __optname); if (__fd == -1 && __level == SOL_SOCKET && __optname == SO_VMA_GET_API && - __optlen && *__optlen >= sizeof(struct vma_api_t*)) { - DO_GLOBAL_CTORS(); - bool enable_socketxtreme = safe_mce_sys().enable_socketxtreme; + __optlen && *__optlen >= sizeof(struct vma_api_t *)) { + static struct vma_api_t *vma_api = NULL; + srdr_logdbg("User request for VMA Extra API pointers"); - struct vma_api_t *vma_api = new struct vma_api_t(); - - vma_api->vma_extra_supported_mask = 0; - SET_EXTRA_API(register_recv_callback, vma_register_recv_callback, VMA_EXTRA_API_REGISTER_RECV_CALLBACK); - SET_EXTRA_API(recvfrom_zcopy, vma_recvfrom_zcopy, VMA_EXTRA_API_RECVFROM_ZCOPY); - SET_EXTRA_API(free_packets, vma_free_packets, VMA_EXTRA_API_FREE_PACKETS); - SET_EXTRA_API(add_conf_rule, vma_add_conf_rule, VMA_EXTRA_API_ADD_CONF_RULE); - SET_EXTRA_API(thread_offload, vma_thread_offload, VMA_EXTRA_API_THREAD_OFFLOAD); - SET_EXTRA_API(get_socket_rings_num, vma_get_socket_rings_num, VMA_EXTRA_API_GET_SOCKET_RINGS_NUM); - SET_EXTRA_API(get_socket_rings_fds, vma_get_socket_rings_fds, VMA_EXTRA_API_GET_SOCKET_RINGS_FDS); - SET_EXTRA_API(get_socket_tx_ring_fd, vma_get_socket_tx_ring_fd, VMA_EXTRA_API_GET_SOCKET_TX_RING_FD); - SET_EXTRA_API(vma_add_ring_profile, vma_add_ring_profile, VMA_EXTRA_API_ADD_RING_PROFILE); - SET_EXTRA_API(get_socket_network_header, vma_get_socket_netowrk_header, VMA_EXTRA_API_GET_SOCKET_NETWORK_HEADER); - SET_EXTRA_API(get_ring_direct_descriptors, vma_get_ring_direct_descriptors, VMA_EXTRA_API_GET_RING_DIRECT_DESCRIPTORS); - SET_EXTRA_API(register_memory_on_ring, vma_reg_mr_on_ring, VMA_EXTRA_API_REGISTER_MEMORY_ON_RING); - SET_EXTRA_API(deregister_memory_on_ring, vma_dereg_mr_on_ring, VMA_EXTRA_API_DEREGISTER_MEMORY_ON_RING); - SET_EXTRA_API(socketxtreme_free_vma_packets, enable_socketxtreme ? vma_socketxtreme_free_vma_packets : dummy_vma_socketxtreme_free_vma_packets, VMA_EXTRA_API_SOCKETXTREME_FREE_VMA_PACKETS); - SET_EXTRA_API(socketxtreme_poll, enable_socketxtreme ? vma_socketxtreme_poll : dummy_vma_socketxtreme_poll, VMA_EXTRA_API_SOCKETXTREME_POLL); - SET_EXTRA_API(socketxtreme_ref_vma_buff, enable_socketxtreme ? vma_socketxtreme_ref_vma_buff : dummy_vma_socketxtreme_ref_vma_buff, VMA_EXTRA_API_SOCKETXTREME_REF_VMA_BUFF); - SET_EXTRA_API(socketxtreme_free_vma_buff, enable_socketxtreme ? vma_socketxtreme_free_vma_buff : dummy_vma_socketxtreme_free_vma_buff, VMA_EXTRA_API_SOCKETXTREME_FREE_VMA_BUFF); - SET_EXTRA_API(dump_fd_stats, vma_dump_fd_stats, VMA_EXTRA_API_DUMP_FD_STATS); - SET_EXTRA_API(vma_modify_ring, vma_modify_ring, VMA_EXTRA_API_MODIFY_RING); - SET_EXTRA_API(get_dpcp_devices, vma_get_dpcp_devices, VMA_EXTRA_API_GET_DPCP_DEVICES); - *((vma_api_t**)__optval) = vma_api; + + if (NULL == vma_api) { + bool enable_socketxtreme = safe_mce_sys().enable_socketxtreme; + + vma_api = new struct vma_api_t(); + + memset(vma_api, 0, sizeof(struct vma_api_t)); + vma_api->vma_extra_supported_mask = 0; + SET_EXTRA_API(register_recv_callback, vma_register_recv_callback, VMA_EXTRA_API_REGISTER_RECV_CALLBACK); + SET_EXTRA_API(recvfrom_zcopy, vma_recvfrom_zcopy, VMA_EXTRA_API_RECVFROM_ZCOPY); + SET_EXTRA_API(free_packets, vma_free_packets, VMA_EXTRA_API_FREE_PACKETS); + SET_EXTRA_API(add_conf_rule, vma_add_conf_rule, VMA_EXTRA_API_ADD_CONF_RULE); + SET_EXTRA_API(thread_offload, vma_thread_offload, VMA_EXTRA_API_THREAD_OFFLOAD); + SET_EXTRA_API(get_socket_rings_num, vma_get_socket_rings_num, VMA_EXTRA_API_GET_SOCKET_RINGS_NUM); + SET_EXTRA_API(get_socket_rings_fds, vma_get_socket_rings_fds, VMA_EXTRA_API_GET_SOCKET_RINGS_FDS); + SET_EXTRA_API(get_socket_tx_ring_fd, vma_get_socket_tx_ring_fd, VMA_EXTRA_API_GET_SOCKET_TX_RING_FD); + SET_EXTRA_API(vma_add_ring_profile, vma_add_ring_profile, VMA_EXTRA_API_ADD_RING_PROFILE); + SET_EXTRA_API(get_socket_network_header, vma_get_socket_netowrk_header, VMA_EXTRA_API_GET_SOCKET_NETWORK_HEADER); + SET_EXTRA_API(get_ring_direct_descriptors, vma_get_ring_direct_descriptors, VMA_EXTRA_API_GET_RING_DIRECT_DESCRIPTORS); + SET_EXTRA_API(register_memory_on_ring, vma_reg_mr_on_ring, VMA_EXTRA_API_REGISTER_MEMORY_ON_RING); + SET_EXTRA_API(deregister_memory_on_ring, vma_dereg_mr_on_ring, VMA_EXTRA_API_DEREGISTER_MEMORY_ON_RING); + SET_EXTRA_API(socketxtreme_free_vma_packets, enable_socketxtreme ? vma_socketxtreme_free_vma_packets : dummy_vma_socketxtreme_free_vma_packets, VMA_EXTRA_API_SOCKETXTREME_FREE_VMA_PACKETS); + SET_EXTRA_API(socketxtreme_poll, enable_socketxtreme ? vma_socketxtreme_poll : dummy_vma_socketxtreme_poll, VMA_EXTRA_API_SOCKETXTREME_POLL); + SET_EXTRA_API(socketxtreme_ref_vma_buff, enable_socketxtreme ? vma_socketxtreme_ref_vma_buff : dummy_vma_socketxtreme_ref_vma_buff, VMA_EXTRA_API_SOCKETXTREME_REF_VMA_BUFF); + SET_EXTRA_API(socketxtreme_free_vma_buff, enable_socketxtreme ? vma_socketxtreme_free_vma_buff : dummy_vma_socketxtreme_free_vma_buff, VMA_EXTRA_API_SOCKETXTREME_FREE_VMA_BUFF); + SET_EXTRA_API(dump_fd_stats, vma_dump_fd_stats, VMA_EXTRA_API_DUMP_FD_STATS); + SET_EXTRA_API(vma_modify_ring, vma_modify_ring, VMA_EXTRA_API_MODIFY_RING); + SET_EXTRA_API(ioctl, vma_ioctl, VMA_EXTRA_API_IOCTL); + } + + *((vma_api_t **)__optval) = vma_api; + *__optlen = sizeof(struct vma_api_t *); return 0; } @@ -1576,6 +1571,7 @@ int recvmmsg(int __fd, struct mmsghdr *__mmsghdr, unsigned int __vlen, int __fla } if (__timeout) { + /* coverity[check_return] */ gettime(&start_time); } socket_fd_api* p_socket_object = NULL; @@ -1596,6 +1592,7 @@ int recvmmsg(int __fd, struct mmsghdr *__mmsghdr, unsigned int __vlen, int __fla __flags |= MSG_DONTWAIT; } if (__timeout) { + /* coverity[check_return] */ gettime(¤t_time); ts_sub(¤t_time, &start_time, &delta_time); if (ts_cmp(&delta_time, __timeout, >)) { diff --git a/src/vma/sock/sock-redirect.h b/src/vma/sock/sock-redirect.h index 119d6e39f7..f6ad9631f9 100644 --- a/src/vma/sock/sock-redirect.h +++ b/src/vma/sock/sock-redirect.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -189,7 +163,7 @@ extern iomux_stats_t* g_p_epoll_stats; int do_global_ctors(); void reset_globals(); -void handle_close(int fd, bool cleanup = false, bool passthrough = false); +bool handle_close(int fd, bool cleanup = false, bool passthrough = false); // allow calling our socket(...) implementation safely from within libvma.so // this is critical in case VMA was loaded using dlopen and not using LD_PRELOAD diff --git a/src/vma/sock/socket_fd_api.cpp b/src/vma/sock/socket_fd_api.cpp index 1fc788de65..63ea681820 100644 --- a/src/vma/sock/socket_fd_api.cpp +++ b/src/vma/sock/socket_fd_api.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -56,6 +30,9 @@ socket_fd_api::socket_fd_api(int fd) : m_epoll_event_flags(0), m_fd(fd), m_n_sys socket_fd_api::~socket_fd_api() { + if (safe_mce_sys().deferred_close && (m_fd >= 0)) { + orig_os_api.close(m_fd); + } } @@ -260,19 +237,23 @@ ssize_t socket_fd_api::tx_os(const tx_call_t call_type, switch (call_type) { case TX_WRITE: __log_info_func("calling os transmit with orig write"); + /* coverity[null_dereference : FALSE]*/ return orig_os_api.write(m_fd, p_iov[0].iov_base, p_iov[0].iov_len); case TX_WRITEV: __log_info_func("calling os transmit with orig writev"); + /* coverity[null_dereference : FALSE]*/ return orig_os_api.writev(m_fd, p_iov, sz_iov); case TX_SEND: __log_info_func("calling os transmit with orig send"); + /* coverity[null_dereference : FALSE]*/ return orig_os_api.send(m_fd, p_iov[0].iov_base, p_iov[0].iov_len, __flags); case TX_SENDTO: __log_info_func("calling os transmit with orig sendto"); + /* coverity[null_dereference : FALSE]*/ return orig_os_api.sendto(m_fd, p_iov[0].iov_base, p_iov[0].iov_len, __flags, __to, __tolen); diff --git a/src/vma/sock/socket_fd_api.h b/src/vma/sock/socket_fd_api.h index acd2153451..6ae001c27e 100644 --- a/src/vma/sock/socket_fd_api.h +++ b/src/vma/sock/socket_fd_api.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/sock/sockinfo.cpp b/src/vma/sock/sockinfo.cpp index a16df79be3..e1d6d2745a 100644 --- a/src/vma/sock/sockinfo.cpp +++ b/src/vma/sock/sockinfo.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -724,8 +698,10 @@ net_device_resources_t* sockinfo::create_nd_resources(const ip_address ip_local) // Need to register as observer to net_device net_device_resources_t nd_resources; nd_resources.refcnt = 0; + /* coverity[assigned_pointer] */ nd_resources.p_nde = NULL; nd_resources.p_ndv = NULL; + /* coverity[assigned_pointer] */ nd_resources.p_ring = NULL; BULLSEYE_EXCLUDE_BLOCK_START @@ -747,7 +723,13 @@ net_device_resources_t* sockinfo::create_nd_resources(const ip_address ip_local) unlock_rx_q(); m_rx_ring_map_lock.lock(); resource_allocation_key *key; - if (m_rx_ring_map.size() && m_ring_alloc_logic.is_logic_support_migration()) { + /* Sockinfo object can use few different rx rings but all these rings should + * have the same key and identical ring allocation logic otherwise + * corruption happens during ring releasing + * Exception: RING_LOGIC_PER_IP - different ip generate different keys + */ + if (m_rx_ring_map.size() && + (m_ring_alloc_logic.get_alloc_logic_type() != RING_LOGIC_PER_IP)) { key = m_ring_alloc_logic.get_key(); } else { key = m_ring_alloc_logic.create_new_key(ip_local.get_in_addr()); @@ -817,7 +799,7 @@ bool sockinfo::destroy_nd_resources(const ip_address ip_local) BULLSEYE_EXCLUDE_BLOCK_START unlock_rx_q(); resource_allocation_key *key; - if (m_ring_alloc_logic.is_logic_support_migration()) { + if (m_ring_alloc_logic.get_alloc_logic_type() != RING_LOGIC_PER_IP) { key = m_ring_alloc_logic.get_key(); } else { key = m_ring_alloc_logic.create_new_key(ip_local.get_in_addr()); @@ -1311,9 +1293,8 @@ void sockinfo::move_descs(ring* p_ring, descq_t *toq, descq_t *fromq, bool own) #define __xor(_a, _b) ((!(_a) && (_b)) || ((_a) && !(_b))) mem_buf_desc_t *temp; - const size_t size = fromq->size(); - for (size_t i = 0 ; i < size; i++) { - temp = fromq->front(); + if (!fromq) return; + while ((temp = fromq->front())) { fromq->pop_front(); if (!__xor(own, p_ring->is_member(temp->p_desc_owner))) toq->push_back(temp); @@ -1348,14 +1329,12 @@ void sockinfo::push_descs_rx_ready(descq_t *cache) { // Assume locked by owner!!! mem_buf_desc_t *temp; - const size_t size = (cache ? cache->size() : 0); - - for (size_t i = 0 ; i < size; i++) { - temp = cache->front(); + + if (!cache) return; + while ((temp = cache->front())) { cache->pop_front(); m_n_rx_pkt_ready_list_count++; m_p_socket_stats->n_rx_ready_pkt_count++; - m_rx_ready_byte_count += temp->rx.sz_payload; m_p_socket_stats->n_rx_ready_byte_count += temp->rx.sz_payload; push_back_m_rx_pkt_ready_list(temp); diff --git a/src/vma/sock/sockinfo.h b/src/vma/sock/sockinfo.h index 1ce88d42b4..a51fd963a6 100644 --- a/src/vma/sock/sockinfo.h +++ b/src/vma/sock/sockinfo.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include @@ -371,24 +345,6 @@ class sockinfo : public socket_fd_api, public pkt_rcvr_sink, public pkt_sndr_sou socket_fd_api::notify_epoll_context((uint32_t)events); } - // This function validates the ipoib's properties - // Input params: - // 1. IF name (can be alias) - // 2. IF flags - // 3. general path to ipoib property file (for example: /sys/class/net/%s/mtu) - // 4. the expected value of the property - // 5. size of the property - // Output params: - // 1. property sysfs filename - // 2. physical IF name (stripped alias) - // Return Value - // Type: INT - // Val: -1 Reading from the sys file failed - // 1 Reading succeeded but the actual prop value != expected - // 0 Reading succeeded and acutal ptop value == expected one - //TODO need to copy this function from util - //int validate_ipoib_prop(char* ifname, unsigned int ifflags, const char param_file[], const char *val, int size, char *filename, char * base_ifname); - inline void fetch_peer_info(sockaddr_in *p_peer_addr, sockaddr_in *__from, socklen_t *__fromlen) { *__from = *p_peer_addr; diff --git a/src/vma/sock/sockinfo_tcp.cpp b/src/vma/sock/sockinfo_tcp.cpp index 3523a75c62..90f1703504 100644 --- a/src/vma/sock/sockinfo_tcp.cpp +++ b/src/vma/sock/sockinfo_tcp.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -105,6 +79,11 @@ static bool is_inherited_option(int __level, int __optname) switch (__optname) { case TCP_MAXSEG: case TCP_NODELAY: + case TCP_KEEPIDLE: +#if LWIP_TCP_KEEPALIVE + case TCP_KEEPINTVL: + case TCP_KEEPCNT: +#endif ret = true; } } else if (__level == IPPROTO_IP) { @@ -128,10 +107,6 @@ inline void sockinfo_tcp::lock_tcp_con() inline void sockinfo_tcp::unlock_tcp_con() { - if (m_timer_pending) { - tcp_timer(); - } - m_tcp_con_lock.unlock(); } @@ -157,12 +132,6 @@ inline int sockinfo_tcp::rx_wait(int &poll_count, bool is_blocking) inline int sockinfo_tcp::rx_wait_lockless(int & poll_count, bool is_blocking) { - if (m_timer_pending) { - m_tcp_con_lock.lock(); - tcp_timer(); - m_tcp_con_lock.unlock(); - } - return rx_wait_helper(poll_count, is_blocking); } @@ -224,10 +193,8 @@ inline void sockinfo_tcp::reuse_buffer(mem_buf_desc_t *buff) sockinfo_tcp::sockinfo_tcp(int fd): sockinfo(fd), m_timer_handle(NULL), - m_timer_pending(false), m_sysvar_buffer_batching_mode(safe_mce_sys().buffer_batching_mode), m_sysvar_tcp_ctl_thread(safe_mce_sys().tcp_ctl_thread), - m_sysvar_internal_thread_tcp_timer_handling(safe_mce_sys().internal_thread_tcp_timer_handling), m_sysvar_rx_poll_on_tx_tcp(safe_mce_sys().rx_poll_on_tx_tcp) { si_tcp_logfuncall(""); @@ -257,6 +224,12 @@ sockinfo_tcp::sockinfo_tcp(int fd): tcp_pcb_init(&m_pcb, TCP_PRIO_NORMAL); + const tcp_keepalive_info keepalive_info = + safe_mce_sys().sysctl_reader.get_tcp_keepalive_info(); + tcp_set_keepalive(&m_pcb, static_cast(1000U * keepalive_info.idle_secs), + static_cast(1000U * keepalive_info.interval_secs), + static_cast(keepalive_info.num_probes)); + si_tcp_logdbg("new pcb %p pcb state %d", &m_pcb, get_tcp_state(&m_pcb)); tcp_arg(&m_pcb, this); tcp_ip_output(&m_pcb, sockinfo_tcp::ip_output); @@ -396,7 +369,9 @@ bool sockinfo_tcp::prepare_listen_to_close() new_sock->m_sock_state = TCP_SOCK_INITED; class flow_tuple key; sockinfo_tcp::create_flow_tuple_key_from_pcb(key, &(new_sock->m_pcb)); - m_syn_received.erase(key); + if (m_syn_received.erase(key)==0) { + si_tcp_logdbg("Unexpected: child socket missing from syn_received list"); + } m_ready_conn_cnt--; new_sock->lock_tcp_con(); new_sock->m_parent = NULL; @@ -458,6 +433,7 @@ bool sockinfo_tcp::prepare_to_close(bool process_shutdown /* = false */) mem_buf_desc_t* p_rx_pkt_desc = m_rx_pkt_ready_list.get_and_pop_front(); m_n_rx_pkt_ready_list_count--; m_p_socket_stats->n_rx_ready_pkt_count--; + /* coverity[dereference:FALSE] */ m_rx_ready_byte_count -= p_rx_pkt_desc->rx.sz_payload; m_p_socket_stats->n_rx_ready_byte_count -= p_rx_pkt_desc->rx.sz_payload; reuse_buffer(p_rx_pkt_desc); @@ -518,6 +494,7 @@ bool sockinfo_tcp::prepare_to_close(bool process_shutdown /* = false */) tcp_accept(&m_pcb, 0); tcp_syn_handled((struct tcp_pcb_listen*)(&m_pcb), 0); tcp_clone_conn((struct tcp_pcb_listen*)(&m_pcb), 0); + tcp_accepted_pcb((struct tcp_pcb_listen*)(&m_pcb), 0); prepare_listen_to_close(); //close pending to accept sockets } else { tcp_recv(&m_pcb, sockinfo_tcp::rx_drop_lwip_cb); @@ -616,7 +593,6 @@ void sockinfo_tcp::tcp_timer() } tcp_tmr(&m_pcb); - m_timer_pending = false; return_pending_rx_buffs(); return_pending_tx_buffs(); @@ -632,19 +608,6 @@ bool sockinfo_tcp::prepare_dst_to_send(bool is_accepted_socket /* = false */) } else { ret_val = m_p_connected_dst_entry->prepare_to_send(m_so_ratelimit, false, true); } - -#ifdef DEFINED_TSO - if (ret_val) { - /* dst_entry has resolved tx ring, - * so it is a time to provide TSO information to PCB - */ - m_pcb.tso.max_buf_sz = std::min(safe_mce_sys().tx_buf_size, - m_p_connected_dst_entry->get_ring()->get_max_payload_sz()); - m_pcb.tso.max_payload_sz = m_p_connected_dst_entry->get_ring()->get_max_payload_sz(); - m_pcb.tso.max_header_sz = m_p_connected_dst_entry->get_ring()->get_max_header_sz(); - m_pcb.tso.max_send_sge = m_p_connected_dst_entry->get_ring()->get_max_send_sge(); - } -#endif /* DEFINED_TSO */ } return ret_val; } @@ -978,96 +941,12 @@ ssize_t sockinfo_tcp::tx(vma_tx_call_attr_t &tx_arg) INC_GO_TO_OS_TX_COUNT; #endif + // coverity[FORWARD_NULL : FALSE] ret = socket_fd_api::tx_os(tx_arg.opcode, p_iov, sz_iov, __flags, __dst, __dstlen); save_stats_tx_os(ret); return ret; } -#ifdef DEFINED_TSO -err_t sockinfo_tcp::ip_output(struct pbuf *p, void* v_p_conn, uint16_t flags) -{ - sockinfo_tcp *p_si_tcp = (sockinfo_tcp *)(((struct tcp_pcb*)v_p_conn)->my_container); - dst_entry *p_dst = p_si_tcp->m_p_connected_dst_entry; - int max_count = p_si_tcp->m_pcb.tso.max_send_sge; - tcp_iovec lwip_iovec[max_count]; - vma_send_attr attr = {(vma_wr_tx_packet_attr)0, 0}; - int count = 0; - - /* maximum number of sge can not exceed this value */ - while (p && (count < max_count)) { - lwip_iovec[count].iovec.iov_base = p->payload; - lwip_iovec[count].iovec.iov_len = p->len; - lwip_iovec[count].p_desc = (mem_buf_desc_t*)p; - p = p->next; - count++; - } - - /* Sanity check */ - if (unlikely(p)) { - vlog_printf(VLOG_ERROR, "Number of buffers in request exceed %d, so silently dropped.", max_count); - return ERR_OK; - } - - attr.flags = (vma_wr_tx_packet_attr)flags; - attr.mss = p_si_tcp->m_pcb.mss; - if (likely((p_dst->is_valid()))) { - p_dst->fast_send((struct iovec *)lwip_iovec, count, attr); - } else { - p_dst->slow_send((struct iovec *)lwip_iovec, count, attr, p_si_tcp->m_so_ratelimit); - } - - if (p_dst->try_migrate_ring(p_si_tcp->m_tcp_con_lock)) { - p_si_tcp->m_p_socket_stats->counters.n_tx_migrations++; - } - - if (is_set(attr.flags, VMA_TX_PACKET_REXMIT)) { - p_si_tcp->m_p_socket_stats->counters.n_tx_retransmits++; - } - - return ERR_OK; -} - -err_t sockinfo_tcp::ip_output_syn_ack(struct pbuf *p, void* v_p_conn, uint16_t flags) -{ - iovec iovec[64]; - struct iovec* p_iovec = iovec; - tcp_iovec tcp_iovec_temp; //currently we pass p_desc only for 1 size iovec, since for bigger size we allocate new buffers - sockinfo_tcp *p_si_tcp = (sockinfo_tcp *)(((struct tcp_pcb*)v_p_conn)->my_container); - dst_entry *p_dst = p_si_tcp->m_p_connected_dst_entry; - int count = 1; - vma_wr_tx_packet_attr attr; - - //ASSERT_NOT_LOCKED(p_si_tcp->m_tcp_con_lock); - - if (likely(!p->next)) { // We should hit this case 99% of cases - tcp_iovec_temp.iovec.iov_base = p->payload; - tcp_iovec_temp.iovec.iov_len = p->len; - tcp_iovec_temp.p_desc = (mem_buf_desc_t*)p; - __log_dbg("p_desc=%p,p->len=%d ", p, p->len); - p_iovec = (struct iovec*)&tcp_iovec_temp; - } else { - for (count = 0; count < 64 && p; ++count) { - iovec[count].iov_base = p->payload; - iovec[count].iov_len = p->len; - p = p->next; - } - - // We don't expect pbuf chain at all - if (p) { - vlog_printf(VLOG_ERROR, "pbuf chain size > 64!!! silently dropped."); - return ERR_OK; - } - } - - attr = (vma_wr_tx_packet_attr)flags; - if (is_set(attr, VMA_TX_PACKET_REXMIT)) - p_si_tcp->m_p_socket_stats->counters.n_tx_retransmits++; - - ((dst_entry_tcp*)p_dst)->slow_send_neigh(p_iovec, count, p_si_tcp->m_so_ratelimit); - - return ERR_OK; -} -#else err_t sockinfo_tcp::ip_output(struct pbuf *p, void* v_p_conn, int is_rexmit, uint8_t is_dummy) { iovec iovec[64]; @@ -1153,7 +1032,6 @@ err_t sockinfo_tcp::ip_output_syn_ack(struct pbuf *p, void* v_p_conn, int is_rex return ERR_OK; } -#endif /* DEFINED_TSO */ /*static*/void sockinfo_tcp::tcp_state_observer(void* pcb_container, enum tcp_state new_state) { @@ -1202,23 +1080,19 @@ void sockinfo_tcp::err_lwip_cb(void *pcb_container, err_t err) } if (conn->m_parent != NULL) { - //in case we got RST before we accepted the connection - int delete_fd = 0; - sockinfo_tcp *parent = conn->m_parent; - bool locked_by_me = false; - if (conn->m_tcp_con_lock.is_locked_by_me()) { - locked_by_me = true; - conn->unlock_tcp_con(); - } - if ((delete_fd = parent->handle_child_FIN(conn))) { - //close will clean sockinfo_tcp object and the opened OS socket + //in case we got RST or abandon() before we accepted the connection + conn->unlock_tcp_con(); + int delete_fd = conn->m_parent->handle_child_FIN(conn); + conn->lock_tcp_con(); + + if (delete_fd) { + // Object destruction is expected to happen in internal thread. Unless VMA is in late + // terminating stage, in which case we don't expect to handle packets. + // Calling close() under lock will prevent internal thread to delete the object before + // we finish with the current processing. close(delete_fd); - if (locked_by_me) - conn->lock_tcp_con(); //todo sock and fd_collection destruction race? if so, conn might be invalid? delay close to internal thread? return; } - if (locked_by_me) - conn->lock_tcp_con(); } /* @@ -1267,21 +1141,6 @@ void sockinfo_tcp::err_lwip_cb(void *pcb_container, err_t err) conn->m_sock_state = TCP_SOCK_INITED; } - /* In general VMA should avoid calling unregister_timer_event() for the same timer handle twice. - * It is protected by checking m_timer_handle for NULL value that should be under lock. - * In order to save locking time a quick check is done first to ensure that indeed the specific - * timer has not been freed (avoiding the lock/unlock). - * The 2nd check is to avoid a race of the timer been freed while the lock has been taken. - */ - if (conn->m_timer_handle) { - conn->lock_tcp_con(); - if (conn->m_timer_handle) { - g_p_event_handler_manager->unregister_timer_event(conn, conn->m_timer_handle); - conn->m_timer_handle = NULL; - } - conn->unlock_tcp_con(); - } - conn->do_wakeup(); } @@ -1501,34 +1360,9 @@ void sockinfo_tcp::handle_timer_expired(void* user_data) if (m_sysvar_tcp_ctl_thread > CTL_THREAD_DISABLE) process_rx_ctl_packets(); - if (m_sysvar_internal_thread_tcp_timer_handling == INTERNAL_THREAD_TCP_TIMER_HANDLING_DEFERRED) { - // DEFERRED. if Internal thread is here first and m_timer_pending is false it jsut - // sets it as true for its next iteration (within 100ms), letting - // application threads have a chance of running tcp_timer() - if (m_timer_pending) { - if (m_tcp_con_lock.trylock()) { - return; - } - tcp_timer(); - m_tcp_con_lock.unlock(); - } - m_timer_pending = true; - } - else { // IMMEDIATE - // Set the pending flag before getting the lock, so in the rare case of - // a race with unlock_tcp_con(), the timer will be called twice. If we set - // the flag after trylock(), the timer may not be called in case of a race. - - // any thread (internal or application) will try locking - // and running the tcp_timer - m_timer_pending = true; - if (m_tcp_con_lock.trylock()) { - return; - } - - tcp_timer(); - m_tcp_con_lock.unlock(); - } + m_tcp_con_lock.lock(); + tcp_timer(); + m_tcp_con_lock.unlock(); } void sockinfo_tcp::abort_connection() @@ -1642,18 +1476,21 @@ err_t sockinfo_tcp::rx_lwip_cb(void *arg, struct tcp_pcb *pcb, tcp_recv(&(conn->m_pcb), sockinfo_tcp::rx_drop_lwip_cb); if (conn->m_parent != NULL) { - //in case we got FIN before we accepted the connection - int delete_fd = 0; - sockinfo_tcp *parent = conn->m_parent; - /* TODO need to add some refcount inside parent in case parent and child are closed together*/ + // in case we got FIN before we accepted the connection + /* TODO need to add some refcount inside parent in case parent and child are closed + * together*/ conn->unlock_tcp_con(); - if ((delete_fd = parent->handle_child_FIN(conn))) { - //close will clean sockinfo_tcp object and the opened OS socket + int delete_fd = conn->m_parent->handle_child_FIN(conn); + conn->lock_tcp_con(); + + if (delete_fd) { + // Object destruction is expected to happen in internal thread. Unless XLIO is in late + // terminating stage, in which case we don't expect to handle packets. + // Calling close() under lock will prevent internal thread to delete the object before + // we finish with the current processing. close(delete_fd); - conn->lock_tcp_con(); //todo sock and fd_collection destruction race? if so, conn might be invalid? delay close to internal thread? return ERR_ABRT; } - conn->lock_tcp_con(); } return ERR_OK; } @@ -1677,7 +1514,16 @@ err_t sockinfo_tcp::rx_lwip_cb(void *arg, struct tcp_pcb *pcb, pbuf *p_curr_buff = p; conn->m_connected.get_sa(p_first_desc->rx.src); + // To avoid reset ref count for first mem_buf_desc, save it and set after the while + int head_ref = p_first_desc->get_ref_count(); while (p_curr_buff) { + /* Here we reset ref count for all mem_buf_desc except for the head (p_first_desc). + Chain of pbufs can contain some pbufs with ref count >=1 like in ooo or flow tag flows. + While processing Rx packets we may split buffer chains and we increment ref count + for the new head of the chain after the split. It will cause a wrong ref count, + and the buffer won't be reclaimed. Resetting it here will migitate the issue. + TODO: remove ref count for TCP. */ + p_curr_desc->reset_ref_count(); p_curr_desc->rx.context = conn; p_first_desc->rx.n_frags++; p_curr_desc->rx.frag.iov_base = p_curr_buff->payload; @@ -1687,6 +1533,7 @@ err_t sockinfo_tcp::rx_lwip_cb(void *arg, struct tcp_pcb *pcb, p_curr_buff = p_curr_buff->next; p_curr_desc = p_curr_desc->p_next_desc; } + p_first_desc->set_ref_count(head_ref); vma_recv_callback_retval_t callback_retval = VMA_PACKET_RECV; @@ -1861,6 +1708,9 @@ int sockinfo_tcp::handle_rx_error(bool is_blocking) si_tcp_logdbg("RX on reseted socket"); m_conn_state = TCP_CONN_FAILED; errno = ECONNRESET; + } else if (m_conn_state == TCP_CONN_TIMEOUT) { + si_tcp_logdbg("RX on timed out socket"); + errno = ETIMEDOUT; } else { si_tcp_logdbg("RX on disconnected socket - EOF"); ret = 0; @@ -2121,7 +1971,9 @@ bool sockinfo_tcp::rx_input_cb(mem_buf_desc_t* p_rx_pkt_mem_buf_desc_info, void* p_rx_pkt_mem_buf_desc_info->rx.socketxtreme_polled = false; while (dropped_count--) { + /* coverity[nonnull] */ mem_buf_desc_t* p_rx_pkt_desc = m_rx_cb_dropped_list.get_and_pop_front(); + /* coverity[dereference:FALSE] */ reuse_buffer(p_rx_pkt_desc); } @@ -2493,7 +2345,7 @@ int sockinfo_tcp::listen(int backlog) tcp_accept(&m_pcb, sockinfo_tcp::accept_lwip_cb); tcp_syn_handled((struct tcp_pcb_listen*)(&m_pcb), sockinfo_tcp::syn_received_lwip_cb); tcp_clone_conn((struct tcp_pcb_listen*)(&m_pcb), sockinfo_tcp::clone_conn_cb); - + tcp_accepted_pcb((struct tcp_pcb_listen*)(&m_pcb), sockinfo_tcp::accepted_pcb_cb); bool success = attach_as_uc_receiver(ROLE_TCP_SERVER); if (!success) { @@ -2740,6 +2592,11 @@ sockinfo_tcp *sockinfo_tcp::accept_clone() return 0; } + // This method is called from a flow which assumes that the socket is locked + // (tcp_listen_input, L3_level_tcp_input). + // Since we created a new socket and we are about to add it to the timers, + // we need to make sure it is also locked for further processing. + si->lock_tcp_con(); si->m_parent = this; si->m_sock_state = TCP_SOCK_BOUND; @@ -2861,25 +2718,8 @@ err_t sockinfo_tcp::accept_lwip_cb(void *arg, struct tcp_pcb *child_pcb, err_t e // todo register as 3-tuple rule for the case the listener is gone? new_sock->attach_as_uc_receiver(role_t (NULL), true); - if (new_sock->m_sysvar_tcp_ctl_thread > CTL_THREAD_DISABLE) { - new_sock->m_vma_thr = true; - - // Before handling packets from flow steering the child should process everything it got from parent - while (!new_sock->m_rx_ctl_packets_list.empty()) { - vma_desc_list_t temp_list; - new_sock->m_rx_ctl_packets_list_lock.lock(); - temp_list.splice_tail(new_sock->m_rx_ctl_packets_list); - new_sock->m_rx_ctl_packets_list_lock.unlock(); - - while (!temp_list.empty()) { - mem_buf_desc_t* desc = temp_list.get_and_pop_front(); - desc->inc_ref_count(); - L3_level_tcp_input((pbuf *)desc, &new_sock->m_pcb); - if (desc->dec_ref_count() <= 1) //todo reuse needed? - new_sock->m_rx_ctl_reuse_list.push_back(desc); - } - } - new_sock->m_vma_thr = false; + if (!conn->is_socketxtreme()) { + new_sock->m_parent = NULL; } new_sock->unlock_tcp_con(); @@ -2904,11 +2744,34 @@ err_t sockinfo_tcp::accept_lwip_cb(void *arg, struct tcp_pcb *child_pcb, err_t e conn->unlock_tcp_con(); - /* Do this after auto_accept_connection() call */ - new_sock->m_parent = NULL; - new_sock->lock_tcp_con(); + if (conn->is_socketxtreme()) { + /* Must be done after auto_accept_connection() call for SocketXtreme flow */ + new_sock->m_parent = NULL; + } + + if (new_sock->m_sysvar_tcp_ctl_thread > CTL_THREAD_DISABLE) { + new_sock->m_vma_thr = true; + + // Before handling packets from flow steering the child should process everything it got from parent + while (!new_sock->m_rx_ctl_packets_list.empty()) { + vma_desc_list_t temp_list; + new_sock->m_rx_ctl_packets_list_lock.lock(); + temp_list.splice_tail(new_sock->m_rx_ctl_packets_list); + new_sock->m_rx_ctl_packets_list_lock.unlock(); + + while (!temp_list.empty()) { + mem_buf_desc_t* desc = temp_list.get_and_pop_front(); + desc->inc_ref_count(); + L3_level_tcp_input((pbuf *)desc, &new_sock->m_pcb); + if (desc->dec_ref_count() <= 1) //todo reuse needed? + new_sock->m_rx_ctl_reuse_list.push_back(desc); + } + } + new_sock->m_vma_thr = false; + } + return ERR_OK; } @@ -2984,6 +2847,15 @@ err_t sockinfo_tcp::clone_conn_cb(void *arg, struct tcp_pcb **newpcb, err_t err) return ret_val; } +void sockinfo_tcp::accepted_pcb_cb(struct tcp_pcb *accepted_pcb) +{ + // A new pcb is always locked. When this callback is called the new pcb is ready + // and all related processing is done. Now it must be unlocked. + sockinfo_tcp *accepted_sock = reinterpret_cast(accepted_pcb->my_container); + ASSERT_LOCKED(accepted_sock->m_tcp_con_lock); + accepted_sock->unlock_tcp_con(); +} + err_t sockinfo_tcp::syn_received_lwip_cb(void *arg, struct tcp_pcb *newpcb, err_t err) { sockinfo_tcp *listen_sock = (sockinfo_tcp *)((arg)); @@ -3019,6 +2891,10 @@ err_t sockinfo_tcp::syn_received_lwip_cb(void *arg, struct tcp_pcb *newpcb, err_ if (!is_new_offloaded) { new_sock->setPassthrough(); set_tcp_state(&new_sock->m_pcb, CLOSED); + // This method is called from a flow (tcp_listen_input, L3_level_tcp_input) which priorly + // called clone_conn_cb which creates a locked new socket. Before we call to close() we need + // to unlock the socket, so close() can perform as a regular close() call. + new_sock->unlock_tcp_con(); close(new_sock->get_fd()); listen_sock->m_tcp_con_lock.lock(); return ERR_ABRT; @@ -3060,6 +2936,11 @@ err_t sockinfo_tcp::syn_received_drop_lwip_cb(void *arg, struct tcp_pcb *newpcb, tcp_arg(&(new_sock->m_pcb), new_sock); new_sock->abort_connection(); } + // This method is called from a flow (tcp_listen_input, L3_level_tcp_input) which priorly called + // clone_conn_cb which creates a locked new socket. Before we call to close() we need to unlock + // the socket, so close() can perform as a regular close() call. + new_sock->unlock_tcp_con(); + close(new_sock->get_fd()); listen_sock->m_tcp_con_lock.lock(); @@ -3671,6 +3552,41 @@ int sockinfo_tcp::setsockopt(int __level, int __optname, unlock_tcp_con(); si_tcp_logdbg("(TCP_QUICKACK) value: %d", val); break; + case TCP_KEEPIDLE: { + auto *int_ptr = reinterpret_cast(__optval); + if (__optlen < sizeof(int) || *int_ptr <= 0) { + errno = EINVAL; + ret = -1; + } else { + auto idle_sec = static_cast(*int_ptr); + si_tcp_logdbg("TCP_KEEPIDLE value: %us", idle_sec); + m_pcb.keep_idle = idle_sec * 1000U; + } + } break; +#if LWIP_TCP_KEEPALIVE + case TCP_KEEPINTVL: { + auto *int_ptr = reinterpret_cast(__optval); + if (__optlen < sizeof(int) || *int_ptr <= 0) { + errno = EINVAL; + ret = -1; + } else { + auto keep_intvl = static_cast(*int_ptr); + si_tcp_logdbg("TCP_KEEPINTVL value: %us", keep_intvl); + m_pcb.keep_intvl = keep_intvl * 1000U; + } + } break; + case TCP_KEEPCNT: { + auto *int_ptr = reinterpret_cast(__optval); + if (__optlen < sizeof(int) || *int_ptr <= 0) { + errno = EINVAL; + ret = -1; + } else { + auto keep_cnt = static_cast(*int_ptr); + si_tcp_logdbg("TCP_KEEPCNT value: %u", keep_cnt); + m_pcb.keep_cnt = keep_cnt; + } + } break; +#endif /* LWIP_TCP_KEEPALIVE */ default: ret = SOCKOPT_HANDLE_BY_OS; supported = false; @@ -3880,6 +3796,38 @@ int sockinfo_tcp::getsockopt_offload(int __level, int __optname, void *__optval, errno = EINVAL; } break; + case TCP_KEEPIDLE: + if (*__optlen >= sizeof(unsigned int)) { + *(unsigned int *)__optval = m_pcb.keep_idle / 1000; + *__optlen = sizeof(unsigned int); + si_tcp_logdbg("TCP_KEEPIDLE value: %us", m_pcb.keep_idle / 1000); + ret = 0; + } else { + errno = EINVAL; + } + break; +#if LWIP_TCP_KEEPALIVE + case TCP_KEEPINTVL: + if (*__optlen >= sizeof(unsigned int)) { + *(unsigned int *)__optval = m_pcb.keep_intvl / 1000; + *__optlen = sizeof(unsigned int); + si_tcp_logdbg("TCP_KEEPINTVL value: %us", m_pcb.keep_intvl / 1000); + ret = 0; + } else { + errno = EINVAL; + } + break; + case TCP_KEEPCNT: + if (*__optlen >= sizeof(unsigned int)) { + *(unsigned int *)__optval = m_pcb.keep_cnt; + *__optlen = sizeof(unsigned int); + si_tcp_logdbg("TCP_KEEPCNT value: %us", m_pcb.keep_cnt); + ret = 0; + } else { + errno = EINVAL; + } + break; +#endif /* LWIP_TCP_KEEPALIVE */ default: ret = SOCKOPT_HANDLE_BY_OS; break; @@ -4214,7 +4162,10 @@ int sockinfo_tcp::rx_wait_helper(int &poll_count, bool is_blocking) if (p_cq_ch_info) { ring* p_ring = p_cq_ch_info->get_ring(); if (p_ring) { - p_ring->wait_for_notification_and_process_element(fd, &poll_sn); + const int cq_ret = p_ring->wait_for_notification_and_process_element(fd, &poll_sn); + if (cq_ret < 0 && errno != EAGAIN) { + si_tcp_logwarn("Error in ring->wait_for_notification_and_process_element() of %p (errno=%d %m)", p_ring, errno); + } } } } @@ -4576,6 +4527,7 @@ void sockinfo_tcp::tcp_tx_pbuf_free(void* p_conn, struct pbuf *p_buff) //potential race, ref is protected here by tcp lock, and in ring by ring_tx lock if (likely(p_desc->lwip_pbuf_get_ref_count())) + /* coverity[check_return] */ p_desc->lwip_pbuf_dec_ref_count(); else __log_err("ref count of %p is already zero, double free??", p_desc); diff --git a/src/vma/sock/sockinfo_tcp.h b/src/vma/sock/sockinfo_tcp.h index d63a5025e1..ffb67bc2fb 100644 --- a/src/vma/sock/sockinfo_tcp.h +++ b/src/vma/sock/sockinfo_tcp.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -93,7 +67,9 @@ struct socket_option_t { socket_option_t(const int _level, const int _optname, const void *_optval, const socklen_t _optlen) : level(_level), optname(_optname), optlen(_optlen), optval(malloc(optlen)) { - memcpy(optval, _optval, optlen); + if (likely(optval)) { + memcpy(optval, _optval, optlen); + } } ~socket_option_t() { if (optval) free(optval); } @@ -158,7 +134,8 @@ class sockinfo_tcp : public sockinfo, public timer_handler /* This function is used for socketxtreme mode */ virtual int free_buffs(uint16_t len); - virtual void statistics_print(vlog_levels_t log_level = VLOG_DEBUG); + virtual void statistics_print(vlog_levels_t log_level = VLOG_DEBUG); + inline struct tcp_pcb *get_pcb(void) { return &m_pcb; } //Returns the connected pcb, with 5 tuple which matches the input arguments, //in state "SYN Received" or NULL if pcb wasn't found @@ -167,13 +144,10 @@ class sockinfo_tcp : public sockinfo, public timer_handler ssize_t tx(vma_tx_call_attr_t &tx_arg); ssize_t rx(const rx_call_t call_type, iovec *p_iov, ssize_t sz_iov, int *p_flags, sockaddr *__from = NULL, socklen_t *__fromlen = NULL, struct msghdr *__msg = NULL); -#ifdef DEFINED_TSO - static err_t ip_output(struct pbuf *p, void* v_p_conn, uint16_t flags); - static err_t ip_output_syn_ack(struct pbuf *p, void* v_p_conn, uint16_t flags); -#else + static err_t ip_output(struct pbuf *p, void* v_p_conn, int is_rexmit, uint8_t is_dummy); static err_t ip_output_syn_ack(struct pbuf *p, void* v_p_conn, int is_rexmit, uint8_t is_dummy); -#endif /* DEFINED_TSO */ + static void tcp_state_observer(void* pcb_container, enum tcp_state new_state); static uint16_t get_route_mtu(struct tcp_pcb *pcb); @@ -281,7 +255,6 @@ class sockinfo_tcp : public sockinfo, public timer_handler void *m_timer_handle; lock_spin_recursive m_tcp_con_lock; - bool m_timer_pending; // used for reporting 'connected' on second non-blocking call to connect or // second call to failed connect blocking socket. @@ -291,7 +264,6 @@ class sockinfo_tcp : public sockinfo, public timer_handler const buffer_batching_mode_t m_sysvar_buffer_batching_mode; const tcp_ctl_thread_t m_sysvar_tcp_ctl_thread; - const internal_thread_tcp_timer_handling_t m_sysvar_internal_thread_tcp_timer_handling; struct tcp_seg * m_tcp_seg_list; int m_tcp_seg_count; @@ -335,6 +307,11 @@ class sockinfo_tcp : public sockinfo, public timer_handler static err_t clone_conn_cb(void *arg, struct tcp_pcb **newpcb, err_t err); + + // Called by L3_level_tcp_input to unlock a new pcb/socket. + // @param newpcb The new pcb. Can be nullptr. + static void accepted_pcb_cb(struct tcp_pcb *newpcb); + int accept_helper(struct sockaddr *__addr, socklen_t *__addrlen, int __flags = 0); // clone socket in accept call diff --git a/src/vma/sock/sockinfo_udp.cpp b/src/vma/sock/sockinfo_udp.cpp index e85728d2d8..8438b5f792 100644 --- a/src/vma/sock/sockinfo_udp.cpp +++ b/src/vma/sock/sockinfo_udp.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -871,7 +845,7 @@ int sockinfo_udp::setsockopt(int __level, int __optname, __const void *__optval, case IP_MULTICAST_TTL: { - int n_mc_ttl = -1; + int n_mc_ttl; if (__optlen == sizeof(m_n_mc_ttl)) n_mc_ttl = *(char*)__optval; else if (__optlen == sizeof(int)) @@ -1234,10 +1208,12 @@ void sockinfo_udp::rx_ready_byte_count_limit_update(size_t n_rx_ready_bytes_limi m_lock_rcv.lock(); while (m_n_rx_pkt_ready_list_count) { mem_buf_desc_t* p_rx_pkt_desc = m_rx_pkt_ready_list.front(); + /* coverity[dereference:FALSE] */ if (m_p_socket_stats->n_rx_ready_byte_count > m_p_socket_stats->n_rx_ready_byte_limit || p_rx_pkt_desc->rx.sz_payload == 0U) { m_rx_pkt_ready_list.pop_front(); m_n_rx_pkt_ready_list_count--; + /* coverity[dereference:FALSE] */ m_rx_ready_byte_count -= p_rx_pkt_desc->rx.sz_payload; m_p_socket_stats->n_rx_ready_pkt_count--; m_p_socket_stats->n_rx_ready_byte_count -= p_rx_pkt_desc->rx.sz_payload; @@ -1326,7 +1302,7 @@ ssize_t sockinfo_udp::rx(const rx_call_t call_type, iovec* p_iov,ssize_t sz_iov, * Wait for RX to become ready. */ rx_wait_ret = rx_wait(m_b_blocking && !(in_flags & MSG_DONTWAIT)); - + // coverity[double_lock:FALSE] /* Turn off coverity check for overflow */ m_lock_rcv.lock(); if (likely(rx_wait_ret == 0)) { @@ -1401,7 +1377,10 @@ void sockinfo_udp::handle_ip_pktinfo(struct cmsg_state * cm_state) { struct in_pktinfo in_pktinfo; mem_buf_desc_t* p_desc = m_rx_pkt_ready_list.front(); - + if (unlikely(!p_desc)) { + si_udp_logerr("no packet descriptor"); + return; + } rx_net_device_map_t::iterator iter = m_rx_nd_map.find(p_desc->rx.udp.local_if); if (iter == m_rx_nd_map.end()) { si_udp_logerr("could not find net device for ip %d.%d.%d.%d", NIPQUAD(p_desc->rx.udp.local_if)); @@ -1519,6 +1498,8 @@ int sockinfo_udp::rx_request_notification(uint64_t poll_sn) } m_rx_ring_map_lock.unlock(); + // to suppress warning in case si_udp_logfunc is compiled out + NOT_IN_USE(ring_armed_count); si_udp_logfunc("armed or busy %d ring(s) and %d ring are pending processing", ring_armed_count, ring_ready_count); return ring_ready_count; } @@ -1655,22 +1636,6 @@ ssize_t sockinfo_udp::tx(vma_tx_call_attr_t &tx_arg) } { -#ifdef DEFINED_TSO - vma_send_attr attr = {(vma_wr_tx_packet_attr)0, 0}; - bool b_blocking = m_b_blocking; - if (unlikely(__flags & MSG_DONTWAIT)) - b_blocking = false; - - attr.flags = (vma_wr_tx_packet_attr)((b_blocking * VMA_TX_PACKET_BLOCK) | (is_dummy * VMA_TX_PACKET_DUMMY)); - if (likely(p_dst_entry->is_valid())) { - // All set for fast path packet sending - this is our best performance flow - ret = p_dst_entry->fast_send(p_iov, sz_iov, attr); - } - else { - // updates the dst_entry internal information and packet headers - ret = p_dst_entry->slow_send(p_iov, sz_iov, attr, m_so_ratelimit, __flags, this, tx_arg.opcode); - } -#else bool b_blocking = m_b_blocking; if (unlikely(__flags & MSG_DONTWAIT)) b_blocking = false; @@ -1683,7 +1648,6 @@ ssize_t sockinfo_udp::tx(vma_tx_call_attr_t &tx_arg) // updates the dst_entry internal information and packet headers ret = p_dst_entry->slow_send(p_iov, sz_iov, is_dummy, m_so_ratelimit, b_blocking, false, __flags, this, tx_arg.opcode); } -#endif /* DEFINED_TSO */ if (unlikely(p_dst_entry->try_migrate_ring(m_lock_snd))) { m_p_socket_stats->counters.n_tx_migrations++; @@ -1722,6 +1686,7 @@ ssize_t sockinfo_udp::tx(vma_tx_call_attr_t &tx_arg) INC_GO_TO_OS_TX_COUNT; #endif // Calling OS transmit + // coverity[FORWARD_NULL : FALSE] ret = socket_fd_api::tx_os(tx_arg.opcode, p_iov, sz_iov, __flags, __dst, __dstlen); tx_packet_to_os_stats: @@ -1966,6 +1931,7 @@ bool sockinfo_udp::rx_input_cb(mem_buf_desc_t* p_desc, void* pv_fd_ready_array) if (!sock_api || sock_api->get_type()!=FD_TYPE_SOCKET) { m_port_map.erase(std::remove(m_port_map.begin(), m_port_map.end(), m_port_map[m_port_map_index].port)); if (m_port_map_index) + // coverity[underflow:FALSE] /* Turn off coverity underflow check */ m_port_map_index--; m_port_map_lock.unlock(); continue; diff --git a/src/vma/sock/sockinfo_udp.h b/src/vma/sock/sockinfo_udp.h index 1f7305c002..9735309920 100644 --- a/src/vma/sock/sockinfo_udp.h +++ b/src/vma/sock/sockinfo_udp.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/agent.cpp b/src/vma/util/agent.cpp index ea5c1b56c2..5fdefe232d 100644 --- a/src/vma/util/agent.cpp +++ b/src/vma/util/agent.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifdef HAVE_CONFIG_H @@ -85,9 +59,13 @@ agent* g_p_agent = NULL; -agent::agent() : - m_state(AGENT_CLOSED), m_sock_fd(-1), m_pid_fd(-1), - m_msg_num(AGENT_DEFAULT_MSG_NUM) +agent::agent() + : m_state(AGENT_CLOSED) + , m_sock_fd(-1) + , m_pid_fd(-1) + , m_sock_file {} + , m_pid_file {} + , m_msg_num(AGENT_DEFAULT_MSG_NUM) { int rc = 0; agent_msg_t *msg = NULL; @@ -186,7 +164,9 @@ agent::agent() : if (m_pid_fd > 0) { int ret = 0; NOT_IN_USE(ret); + /* coverity[RESOURCE_LEAK] */ sys_call(ret, close, m_pid_fd); + /* coverity[leaked_handle] */ m_pid_fd = -1; unlink(m_pid_file); } @@ -194,7 +174,9 @@ agent::agent() : if (m_sock_fd > 0) { int ret = 0; NOT_IN_USE(ret); + /* coverity[RESOURCE_LEAK] */ sys_call(ret, close, m_sock_fd); + /* coverity[leaked_handle] */ m_sock_fd = -1; unlink(m_sock_file); } diff --git a/src/vma/util/agent.h b/src/vma/util/agent.h index 8738751c92..5503f53d5e 100644 --- a/src/vma/util/agent.h +++ b/src/vma/util/agent.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef SRC_VMA_UTIL_AGENT_H_ diff --git a/src/vma/util/agent_def.h b/src/vma/util/agent_def.h index 59a9db6533..cdc2a33579 100644 --- a/src/vma/util/agent_def.h +++ b/src/vma/util/agent_def.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef SRC_VMA_UTIL_AGENT_DEF_H_ diff --git a/src/vma/util/chunk_list.h b/src/vma/util/chunk_list.h index 13be8ff376..840936bfe0 100644 --- a/src/vma/util/chunk_list.h +++ b/src/vma/util/chunk_list.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef CHUNK_LIST_H_ @@ -143,6 +117,7 @@ class chunk_list_t { // Check if the list is empty. if (unlikely(empty())) return NULL; + /* coverity[returned_null][dereference] */ return m_used_containers.front()->m_p_buffer[m_front]; } @@ -178,7 +153,7 @@ class chunk_list_t { m_back = 0; m_used_containers.push_back(m_free_containers.get_and_pop_back()); } - + /* coverity[returned_null] */ m_used_containers.back()->m_p_buffer[m_back] = obj; m_size++; } diff --git a/src/vma/util/config_parser.y b/src/vma/util/config_parser.y index bdb4666a19..ca0b9ac453 100644 --- a/src/vma/util/config_parser.y +++ b/src/vma/util/config_parser.y @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause * * $Id: config_parser.y 1.5 2005/06/29 11:39:27 eitan Exp $ */ diff --git a/src/vma/util/config_scanner.l b/src/vma/util/config_scanner.l index 6d61831281..f724129fae 100644 --- a/src/vma/util/config_scanner.l +++ b/src/vma/util/config_scanner.l @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause * * $Id: ibnl_scanner.ll,v 1.4 2005/02/23 21:08:37 eitan Exp $ */ diff --git a/src/vma/util/data_updater.cpp b/src/vma/util/data_updater.cpp index 8f9fb1ff1f..2925018ac4 100644 --- a/src/vma/util/data_updater.cpp +++ b/src/vma/util/data_updater.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "data_updater.h" diff --git a/src/vma/util/data_updater.h b/src/vma/util/data_updater.h index decee14aa7..008998b9c1 100644 --- a/src/vma/util/data_updater.h +++ b/src/vma/util/data_updater.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef SRC_VMA_UTIL_DATA_UPDATER_H_ diff --git a/src/vma/util/hash_map.h b/src/vma/util/hash_map.h index da6f29a8f6..c420fe022c 100644 --- a/src/vma/util/hash_map.h +++ b/src/vma/util/hash_map.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/hash_map.inl b/src/vma/util/hash_map.inl index cec7273527..85dce6aea9 100644 --- a/src/vma/util/hash_map.inl +++ b/src/vma/util/hash_map.inl @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/if.h b/src/vma/util/if.h index 81b7bf8c16..a28430dfaa 100644 --- a/src/vma/util/if.h +++ b/src/vma/util/if.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/instrumentation.cpp b/src/vma/util/instrumentation.cpp index 83e526587f..bd19a68e21 100644 --- a/src/vma/util/instrumentation.cpp +++ b/src/vma/util/instrumentation.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "config.h" diff --git a/src/vma/util/instrumentation.h b/src/vma/util/instrumentation.h index 009ce23006..2ed9d308b2 100644 --- a/src/vma/util/instrumentation.h +++ b/src/vma/util/instrumentation.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/libvma.h b/src/vma/util/libvma.h index 48caad3998..c7d78b431d 100644 --- a/src/vma/util/libvma.h +++ b/src/vma/util/libvma.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/list.h b/src/vma/util/list.h index 1c7380cb6f..a5305db4da 100644 --- a/src/vma/util/list.h +++ b/src/vma/util/list.h @@ -1,567 +1,263 @@ -#ifndef _LINUX_LIST_H -#define _LINUX_LIST_H - -/* - * Simple doubly linked list implementation. +/*- + * Copyright (c) 2010 Isilon Systems, Inc. + * Copyright (c) 2010 iX Systems, Inc. + * Copyright (c) 2010 Panasas, Inc. + * All rights reserved. * - * Some of the internal functions ("__xxx") are useful when - * manipulating whole lists rather than single entries, as - * sometimes we already know the next/prev entries and we can - * generate better code by using them directly rather than - * using the generic single-entry routines. - */ - -/* This is a modified version of Linux kernel list.h */ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _LINUX_LIST_H_ +#define _LINUX_LIST_H_ struct list_head { - struct list_head *next, *prev; + struct list_head *next; + struct list_head *prev; }; -#define LIST_HEAD_INIT(name) { &(name), &(name) } - -#define LIST_HEAD(name) \ - struct list_head name = LIST_HEAD_INIT(name) - static inline void INIT_LIST_HEAD(struct list_head *list) { - list->next = list; - list->prev = list; + list->next = list->prev = list; } -/* - * Insert a new entry between two known consecutive entries. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -#ifndef CONFIG_DEBUG_LIST -static inline void __list_add(struct list_head *new_item, - struct list_head *prev, - struct list_head *next) +static inline int list_empty(const struct list_head *head) { - next->prev = new_item; - new_item->next = next; - new_item->prev = prev; - prev->next = new_item; + return (head->next == head); } -#else -extern void __list_add(struct list_head *new_item, - struct list_head *prev, - struct list_head *next); -#endif -/** - * list_add - add a new entry - * @new_item: new entry to be added - * @head: list head to add it after - * - * Insert a new entry after the specified head. - * This is good for implementing stacks. - */ -static inline void list_add(struct list_head *new_item, struct list_head *head) +static inline void list_del(struct list_head *entry) { - __list_add(new_item, head, head->next); + entry->next->prev = entry->prev; + entry->prev->next = entry->next; } - -/** - * list_add_tail - add a new entry - * @new_item: new entry to be added - * @head: list head to add it before - * - * Insert a new entry before the specified head. - * This is useful for implementing queues. - */ -static inline void list_add_tail(struct list_head *new_item, struct list_head *head) +static inline void _list_add(struct list_head *_new, struct list_head *prev, struct list_head *next) { - __list_add(new_item, head->prev, head); + next->prev = _new; + _new->next = next; + _new->prev = prev; + prev->next = _new; } -/* - * Delete a list entry by making the prev/next entries - * point to each other. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void __list_del(struct list_head * prev, struct list_head * next) +static inline void list_del_init(struct list_head *entry) { - next->prev = prev; - prev->next = next; + list_del(entry); + INIT_LIST_HEAD(entry); } -/** - * list_del - deletes entry from list. - * @entry: the element to delete from the list. - * Note: list_empty() on entry does not return true after this, the entry is - * in an undefined state. - */ -#ifndef CONFIG_DEBUG_LIST -static inline void list_del(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); - entry->next = 0; - entry->prev = 0; -} +#ifdef __cplusplus +#define list_entry(ptr, type, member) \ + (reinterpret_cast((char *)(ptr) - (char *)(&(reinterpret_cast(1)->member)) + 1)) #else -extern void list_del(struct list_head *entry); +#define list_entry(ptr, type, member) container_of(ptr, type, member) #endif -/** - * list_replace - replace old entry by new one - * @old : the element to be replaced - * @new_item : the new element to insert - * - * If @old was empty, it will be overwritten. - */ -static inline void list_replace(struct list_head *old, - struct list_head *new_item) -{ - new_item->next = old->next; - new_item->next->prev = new_item; - new_item->prev = old->prev; - new_item->prev->next = new_item; -} +#define list_first_entry(ptr, type, member) list_entry((ptr)->next, type, member) + +#define list_for_each(p, head) for (p = (head)->next; p != (head); p = p->next) + +#define list_for_each_safe(p, n, head) \ + for (p = (head)->next, n = p->next; p != (head); p = n, n = p->next) + +#define list_for_each_entry(p, h, field) \ + for (p = list_entry((h)->next, typeof(*p), field); &p->field != (h); \ + p = list_entry(p->field.next, typeof(*p), field)) -static inline void list_replace_init(struct list_head *old, - struct list_head *new_item) +#define list_for_each_entry_safe(p, n, h, field) \ + for (p = list_entry((h)->next, typeof(*p), field), \ + n = list_entry(p->field.next, typeof(*p), field); \ + &p->field != (h); p = n, n = list_entry(n->field.next, typeof(*n), field)) + +#define list_for_each_entry_reverse(p, h, field) \ + for (p = list_entry((h)->prev, typeof(*p), field); &p->field != (h); \ + p = list_entry(p->field.prev, typeof(*p), field)) + +#define list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = p->prev) + +static inline void list_add(struct list_head *_new, struct list_head *head) { - list_replace(old, new_item); - INIT_LIST_HEAD(old); + _list_add(_new, head, head->next); } -/** - * list_del_init - deletes entry from list and reinitialize it. - * @entry: the element to delete from the list. - */ -static inline void list_del_init(struct list_head *entry) +static inline void list_add_tail(struct list_head *_new, struct list_head *head) { - __list_del(entry->prev, entry->next); - INIT_LIST_HEAD(entry); + _list_add(_new, head->prev, head); } -/** - * list_move - delete from one list and add as another's head - * @list: the entry to move - * @head: the head that will precede our entry - */ static inline void list_move(struct list_head *list, struct list_head *head) { - __list_del(list->prev, list->next); - list_add(list, head); + list_del(list); + list_add(list, head); } -/** - * list_move_tail - delete from one list and add as another's tail - * @list: the entry to move - * @head: the head that will follow our entry - */ -static inline void list_move_tail(struct list_head *list, - struct list_head *head) +static inline void list_move_tail(struct list_head *entry, struct list_head *head) { - __list_del(list->prev, list->next); - list_add_tail(list, head); + list_del(entry); + list_add_tail(entry, head); } -/** - * list_is_last - tests whether @list is the last entry in list @head - * @list: the entry to test - * @head: the head of the list - */ -static inline int list_is_last(const struct list_head *list, - const struct list_head *head) +static inline void _list_splice(const struct list_head *list, struct list_head *prev, + struct list_head *next) { - return list->next == head; + struct list_head *first; + struct list_head *last; + + if (list_empty(list)) { + return; + } + first = list->next; + last = list->prev; + first->prev = prev; + prev->next = first; + last->next = next; + next->prev = last; } -/** - * list_empty - tests whether a list is empty - * @head: the list to test. - */ -static inline int list_empty(const struct list_head *head) +static inline void list_splice(const struct list_head *list, struct list_head *head) { - return head->next == head; + _list_splice(list, head, head->next); } -/** - * list_empty_careful - tests whether a list is empty and not being modified - * @head: the list to test - * - * Description: - * tests whether a list is empty _and_ checks that no other CPU might be - * in the process of modifying either member (next or prev) - * - * NOTE: using list_empty_careful() without synchronization - * can only be safe if the only activity that can happen - * to the list entry is list_del_init(). Eg. it cannot be used - * if another CPU could re-list_add() it. - */ -static inline int list_empty_careful(const struct list_head *head) +static inline void list_splice_tail(struct list_head *list, struct list_head *head) { - struct list_head *next = head->next; - return (next == head) && (next == head->prev); + _list_splice(list, head->prev, head); } -/** - * list_rotate_left - rotate the list to the left - * @head: the head of the list - */ -static inline void list_rotate_left(struct list_head *head) +static inline void list_splice_init(struct list_head *list, struct list_head *head) { - struct list_head *first; - - if (!list_empty(head)) { - first = head->next; - list_move_tail(first, head); - } + _list_splice(list, head, head->next); + INIT_LIST_HEAD(list); } -/** - * list_is_singular - tests whether a list has just one entry. - * @head: the list to test. - */ -static inline int list_is_singular(const struct list_head *head) +static inline void list_splice_tail_init(struct list_head *list, struct list_head *head) { - return !list_empty(head) && (head->next == head->prev); + _list_splice(list, head->prev, head); + INIT_LIST_HEAD(list); } -static inline void __list_cut_position(struct list_head *list, - struct list_head *head, struct list_head *entry) +#undef LIST_HEAD +#define LIST_HEAD(name) struct list_head name = {&(name), &(name)} + +struct hlist_head { + struct hlist_node *first; +}; + +struct hlist_node { + struct hlist_node *next, **pprev; +}; + +#define HLIST_HEAD_INIT \ + { \ + } +#define HLIST_HEAD(name) struct hlist_head name = HLIST_HEAD_INIT +#define INIT_HLIST_HEAD(head) (head)->first = NULL +#define INIT_HLIST_NODE(node) \ + do { \ + (node)->next = NULL; \ + (node)->pprev = NULL; \ + } while (0) + +static inline int hlist_unhashed(const struct hlist_node *h) { - struct list_head *new_first = entry->next; - list->next = head->next; - list->next->prev = list; - list->prev = entry; - entry->next = list; - head->next = new_first; - new_first->prev = head; + return !h->pprev; } -/** - * list_cut_position - cut a list into two - * @list: a new list to add all removed entries - * @head: a list with entries - * @entry: an entry within head, could be the head itself - * and if so we won't cut the list - * - * This helper moves the initial part of @head, up to and - * including @entry, from @head to @list. You should - * pass on @entry an element you know is on @head. @list - * should be an empty list or a list you do not care about - * losing its data. - * - */ -static inline void list_cut_position(struct list_head *list, - struct list_head *head, struct list_head *entry) +static inline int hlist_empty(const struct hlist_head *h) { - if (list_empty(head)) - return; - if (list_is_singular(head) && - (head->next != entry && head != entry)) - return; - if (entry == head) - INIT_LIST_HEAD(list); - else - __list_cut_position(list, head, entry); + return !h->first; } -static inline void __list_splice(const struct list_head *list, - struct list_head *prev, - struct list_head *next) +static inline void hlist_del(struct hlist_node *n) { - struct list_head *first = list->next; - struct list_head *last = list->prev; - - first->prev = prev; - prev->next = first; + if (n->next) { + n->next->pprev = n->pprev; + } + *n->pprev = n->next; +} - last->next = next; - next->prev = last; +static inline void hlist_del_init(struct hlist_node *n) +{ + if (hlist_unhashed(n)) { + return; + } + hlist_del(n); + INIT_HLIST_NODE(n); } -/** - * list_splice - join two lists, this is designed for stacks - * @list: the new list to add. - * @head: the place to add it in the first list. - */ -static inline void list_splice(const struct list_head *list, - struct list_head *head) +static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) { - if (!list_empty(list)) - __list_splice(list, head, head->next); + n->next = h->first; + if (h->first) { + h->first->pprev = &n->next; + } + h->first = n; + n->pprev = &h->first; } -/** - * list_splice_tail - join two lists, each list being a queue - * @list: the new list to add. - * @head: the place to add it in the first list. - */ -static inline void list_splice_tail(struct list_head *list, - struct list_head *head) +static inline void hlist_add_before(struct hlist_node *n, struct hlist_node *next) { - if (!list_empty(list)) - __list_splice(list, head->prev, head); + n->pprev = next->pprev; + n->next = next; + next->pprev = &n->next; + *(n->pprev) = n; } -/** - * list_splice_init - join two lists and reinitialise the emptied list. - * @list: the new list to add. - * @head: the place to add it in the first list. - * - * The list at @list is reinitialised - */ -static inline void list_splice_init(struct list_head *list, - struct list_head *head) +static inline void hlist_add_after(struct hlist_node *n, struct hlist_node *next) { - if (!list_empty(list)) { - __list_splice(list, head, head->next); - INIT_LIST_HEAD(list); - } + next->next = n->next; + n->next = next; + next->pprev = &n->next; + if (next->next) { + next->next->pprev = &next->next; + } } -/** - * list_splice_tail_init - join two lists and reinitialise the emptied list - * @list: the new list to add. - * @head: the place to add it in the first list. - * - * Each of the lists is a queue. - * The list at @list is reinitialised - */ -static inline void list_splice_tail_init(struct list_head *list, - struct list_head *head) +static inline void hlist_move_list(struct hlist_head *old, struct hlist_head *_new) { - if (!list_empty(list)) { - __list_splice(list, head->prev, head); - INIT_LIST_HEAD(list); - } + _new->first = old->first; + if (_new->first) { + _new->first->pprev = &_new->first; + } + old->first = NULL; } -/** - * list_entry - get the struct for this entry - * @ptr: the &struct list_head pointer. - * @type: the type of the struct this is embedded in. - * @member: the name of the list_struct within the struct. - */ -#ifdef __cplusplus -#define list_entry(ptr, type, member) \ - (reinterpret_cast((char *)(ptr)-(char *)(&(reinterpret_cast(1)->member))+1)) -#else -#define list_entry(ptr, type, member) \ - container_of(ptr, type, member) -#endif +#define hlist_entry(ptr, type, field) container_of(ptr, type, field) -/** - * list_first_entry - get the first element from a list - * @ptr: the list head to take the element from. - * @type: the type of the struct this is embedded in. - * @member: the name of the list_struct within the struct. - * - * Note, that list is expected to be not empty. - */ -#define list_first_entry(ptr, type, member) \ - list_entry((ptr)->next, type, member) +#define hlist_for_each(p, head) for (p = (head)->first; p; p = p->next) -/** - * list_for_each - iterate over a list - * @pos: the &struct list_head to use as a loop cursor. - * @head: the head for your list. - */ -#define list_for_each(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) +#define hlist_for_each_safe(p, n, head) \ + for (p = (head)->first; p ? (n = p->next) | (tp = hlist_entry(p, typeof(*tp), field)) : NULL; \ + p = n) -/** - * __list_for_each - iterate over a list - * @pos: the &struct list_head to use as a loop cursor. - * @head: the head for your list. - * - * This variant doesn't differ from list_for_each() any more. - * We don't do prefetching in either case. - */ -#define __list_for_each(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) +#define hlist_for_each_entry(tp, p, head, field) \ + for (p = (head)->first; p ? (tp = hlist_entry(p, typeof(*tp), field)) : NULL; p = p->next) -/** - * list_for_each_prev - iterate over a list backwards - * @pos: the &struct list_head to use as a loop cursor. - * @head: the head for your list. - */ -#define list_for_each_prev(pos, head) \ - for (pos = (head)->prev; pos != (head); pos = pos->prev) - -/** - * list_for_each_safe - iterate over a list safe against removal of list entry - * @pos: the &struct list_head to use as a loop cursor. - * @n: another &struct list_head to use as temporary storage - * @head: the head for your list. - */ -#define list_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, n = pos->next) - -/** - * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry - * @pos: the &struct list_head to use as a loop cursor. - * @n: another &struct list_head to use as temporary storage - * @head: the head for your list. - */ -#define list_for_each_prev_safe(pos, n, head) \ - for (pos = (head)->prev, n = pos->prev; \ - pos != (head); \ - pos = n, n = pos->prev) - -/** - * list_for_each_entry - iterate over list of given type - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define list_for_each_entry(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) - -/** - * list_for_each_entry_reverse - iterate backwards over list of given type. - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define list_for_each_entry_reverse(pos, head, member) \ - for (pos = list_entry((head)->prev, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.prev, typeof(*pos), member)) - -/** - * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue() - * @pos: the type * to use as a start point - * @head: the head of the list - * @member: the name of the list_struct within the struct. - * - * Prepares a pos entry for use as a start point in list_for_each_entry_continue(). - */ -#define list_prepare_entry(pos, head, member) \ - ((pos) ? : list_entry(head, typeof(*pos), member)) - -/** - * list_for_each_entry_continue - continue iteration over list of given type - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Continue to iterate over list of given type, continuing after - * the current position. - */ -#define list_for_each_entry_continue(pos, head, member) \ - for (pos = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) - -/** - * list_for_each_entry_continue_reverse - iterate backwards from the given point - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Start to iterate over list of given type backwards, continuing after - * the current position. - */ -#define list_for_each_entry_continue_reverse(pos, head, member) \ - for (pos = list_entry(pos->member.prev, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.prev, typeof(*pos), member)) - -/** - * list_for_each_entry_from - iterate over list of given type from the current point - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate over list of given type, continuing from current position. - */ -#define list_for_each_entry_from(pos, head, member) \ - for (; &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) - -/** - * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - */ -#define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) - -/** - * list_for_each_entry_safe_continue - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate over list of given type, continuing after current point, - * safe against removal of list entry. - */ -#define list_for_each_entry_safe_continue(pos, n, head, member) \ - for (pos = list_entry(pos->member.next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) - -/** - * list_for_each_entry_safe_from - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate over list of given type from current point, safe against - * removal of list entry. - */ -#define list_for_each_entry_safe_from(pos, n, head, member) \ - for (n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) - -/** - * list_for_each_entry_safe_reverse - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate backwards over list of given type, safe against removal - * of list entry. - */ -#define list_for_each_entry_safe_reverse(pos, n, head, member) \ - for (pos = list_entry((head)->prev, typeof(*pos), member), \ - n = list_entry(pos->member.prev, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.prev, typeof(*n), member)) - -/** - * list_safe_reset_next - reset a stale list_for_each_entry_safe loop - * @pos: the loop cursor used in the list_for_each_entry_safe loop - * @n: temporary storage used in list_for_each_entry_safe - * @member: the name of the list_struct within the struct. - * - * list_safe_reset_next is not safe to use in general if the list may be - * modified concurrently (eg. the lock is dropped in the loop body). An - * exception to this is if the cursor element (pos) is pinned in the list, - * and list_safe_reset_next is called after re-taking the lock and before - * completing the current iteration of the loop body. - */ -#define list_safe_reset_next(pos, n, member) \ - n = list_entry(pos->member.next, typeof(*pos), member) - -/* - * Double linked lists with a single pointer list head. - * Mostly useful for hash tables where the two pointer list head is - * too wasteful. - * You lose the ability to access the tail in O(1). - */ +#define hlist_for_each_entry_continue(tp, p, field) \ + for (p = (p)->next; p ? (tp = hlist_entry(p, typeof(*tp), field)) : NULL; p = p->next) + +#define hlist_for_each_entry_from(tp, p, field) \ + for (; p ? (tp = hlist_entry(p, typeof(*tp), field)) : NULL; p = p->next) + +#define hlist_for_each_entry_safe(tp, p, n, head, field) \ + for (p = (head)->first; p ? (n = p->next) | (tp = hlist_entry(p, typeof(*tp), field)) : NULL; \ + p = n) -#endif /* _LINUX_LIST_H */ +#endif /* _LINUX_LIST_H_ */ diff --git a/src/vma/util/match.cpp b/src/vma/util/match.cpp index f2fac3de19..7018f9c4fc 100644 --- a/src/vma/util/match.cpp +++ b/src/vma/util/match.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/sg_array.h b/src/vma/util/sg_array.h index 9cf4d06a03..135a274666 100644 --- a/src/vma/util/sg_array.h +++ b/src/vma/util/sg_array.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef SG_ARRAY_H diff --git a/src/vma/util/sock_addr.h b/src/vma/util/sock_addr.h index 7ac475bef8..57b1e0fc14 100644 --- a/src/vma/util/sock_addr.h +++ b/src/vma/util/sock_addr.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/sys_vars.cpp b/src/vma/util/sys_vars.cpp index 26a2994603..37781070b2 100644 --- a/src/vma/util/sys_vars.cpp +++ b/src/vma/util/sys_vars.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -60,8 +34,6 @@ #include "vma/proto/vma_lwip.h" #include "vma/proto/route_table_mgr.h" #include "vma/proto/rule_table_mgr.h" -#include "vma/proto/igmp_mgr.h" - #include "vma/proto/neighbour_table_mgr.h" #include "vma/netlink/netlink_wrapper.h" #include "vma/event/command.h" @@ -76,7 +48,7 @@ void check_netperf_flags(); -// Do not rely on global variable initialization in code that might be called from library constructor (main_init) +// Do not rely on global variable initialization in code that might be called from library constructor mce_sys_var & safe_mce_sys() {return mce_sys_var::instance();} #define MAX_BACKTRACE 25 @@ -304,6 +276,10 @@ int mce_sys_var::env_to_cpuset(char *orig_start, cpu_set_t *cpu_set) int ret; char* start = strdup(orig_start); // save the caller string from strtok destruction. + if (!start) { + vlog_printf(VLOG_WARNING, "Failed to allocate memory for CPU set"); + return -1; + } /* * We expect a hex number or comma delimited cpulist. Check for * starting characters of "0x" or "0X" and if present then parse @@ -324,8 +300,8 @@ int mce_sys_var::env_to_cpuset(char *orig_start, cpu_set_t *cpu_set) void mce_sys_var::read_env_variable_with_pid(char* mce_sys_name, size_t mce_sys_max_size, char* env_ptr) { - int n = -1; - char* d_pos = NULL; + int n; + char* d_pos; if (NULL == env_ptr || NULL == mce_sys_name || mce_sys_max_size < 2) { return ; @@ -531,9 +507,6 @@ void mce_sys_var::get_env_params() tx_num_segs_tcp = MCE_DEFAULT_TX_NUM_SEGS_TCP; tx_num_bufs = MCE_DEFAULT_TX_NUM_BUFS; -#ifdef DEFINED_TSO - tx_buf_size = MCE_DEFAULT_TX_BUF_SIZE; -#endif /* DEFINED_TSO */ tx_num_wr = MCE_DEFAULT_TX_NUM_WRE; tx_num_wr_to_signal = MCE_DEFAULT_TX_NUM_WRE_TO_SIGNAL; tx_max_inline = MCE_DEFAULT_TX_MAX_INLINE; @@ -589,7 +562,6 @@ void mce_sys_var::get_env_params() offloaded_sockets = MCE_DEFAULT_OFFLOADED_SOCKETS; timer_resolution_msec = MCE_DEFAULT_TIMER_RESOLUTION_MSEC; tcp_timer_resolution_msec= MCE_DEFAULT_TCP_TIMER_RESOLUTION_MSEC; - internal_thread_tcp_timer_handling = MCE_DEFAULT_INTERNAL_THREAD_TCP_TIMER_HANDLING; tcp_ctl_thread = MCE_DEFAULT_TCP_CTL_THREAD; tcp_ts_opt = MCE_DEFAULT_TCP_TIMESTAMP_OPTION; tcp_nodelay = MCE_DEFAULT_TCP_NODELAY; @@ -601,11 +573,7 @@ void mce_sys_var::get_env_params() thread_mode = MCE_DEFAULT_THREAD_MODE; buffer_batching_mode = MCE_DEFAULT_BUFFER_BATCHING_MODE; mem_alloc_type = MCE_DEFAULT_MEM_ALLOC_TYPE; - enable_ipoib = MCE_DEFAULT_IPOIB_FLAG; enable_socketxtreme = MCE_DEFAULT_SOCKETXTREME; -#ifdef DEFINED_TSO - enable_tso = MCE_DEFAULT_TSO; -#endif /* DEFINED_TSO */ handle_fork = MCE_DEFAULT_FORK_SUPPORT; handle_bf = MCE_DEFAULT_BF_FLAG; close_on_dup2 = MCE_DEFAULT_CLOSE_ON_DUP2; @@ -621,6 +589,7 @@ void mce_sys_var::get_env_params() neigh_wait_till_send_arp_msec = MCE_DEFAULT_NEIGH_UC_ARP_DELAY_MSEC; timer_netlink_update_msec = MCE_DEFAULT_NETLINK_TIMER_MSEC; + deferred_close = MCE_DEFAULT_DEFERRED_CLOSE; rx_poll_on_tx_tcp = MCE_DEFAULT_RX_POLL_ON_TX_TCP; trigger_dummy_send_getsockname = MCE_DEFAULT_TRIGGER_DUMMY_SEND_GETSOCKNAME; @@ -661,9 +630,6 @@ void mce_sys_var::get_env_params() rx_num_wr = 256; //MCE_DEFAULT_RX_NUM_WRE (16000) rx_num_wr_to_post_recv = 4; //MCE_DEFAULT_RX_NUM_WRE_TO_POST_RECV (64) rx_poll_num = -1; //MCE_DEFAULT_RX_NUM_POLLS -#ifdef DEFINED_TSO - enable_tso = false; //MCE_DEFAULT_TSO (true) -#endif /* DEFINED_TSO */ rx_udp_poll_os_ratio = 0; //MCE_DEFAULT_RX_UDP_POLL_OS_RATIO rx_prefetch_bytes = MCE_DEFAULT_RX_PREFETCH_BYTES; //(256) rx_prefetch_bytes_before_poll = 256; //MCE_DEFAULT_RX_PREFETCH_BYTES_BEFORE_POLL 0 @@ -690,9 +656,6 @@ void mce_sys_var::get_env_params() rx_num_wr = 256; //MCE_DEFAULT_RX_NUM_WRE (16000) rx_num_wr_to_post_recv = 4; //MCE_DEFAULT_RX_NUM_WRE_TO_POST_RECV (64) rx_poll_num = -1; //MCE_DEFAULT_RX_NUM_POLLS (100000) -#ifdef DEFINED_TSO - enable_tso = false; //MCE_DEFAULT_TSO (true) -#endif /* DEFINED_TSO */ rx_prefetch_bytes_before_poll = 256; //MCE_DEFAULT_RX_PREFETCH_BYTES_BEFORE_POLL (0) select_poll_num = -1; //MCE_DEFAULT_SELECT_NUM_POLLS (100000) avoid_sys_calls_on_tcp_fd = true; //MCE_DEFAULT_AVOID_SYS_CALLS_ON_TCP_FD (false) @@ -702,8 +665,8 @@ void mce_sys_var::get_env_params() mem_alloc_type = ALLOC_TYPE_HUGEPAGES; //MCE_DEFAULT_MEM_ALLOC_TYPE (ALLOC_TYPE_CONTIG) strcpy(internal_thread_affinity_str, "0"); //MCE_DEFAULT_INTERNAL_THREAD_AFFINITY_STR ("-1") progress_engine_interval_msec = 100; //MCE_DEFAULT_PROGRESS_ENGINE_INTERVAL_MSEC (10) - select_poll_os_ratio = 100; //MCE_DEFAULT_SELECT_POLL_OS_RATIO (10) - select_poll_os_force = 1; //MCE_DEFAULT_SELECT_POLL_OS_FORCE (0) + select_poll_os_ratio = 1; //MCE_DEFAULT_SELECT_POLL_OS_RATIO (10) + select_skip_os_fd_check = 1; //MCE_DEFAULT_SELECT_SKIP_OS (4) tcp_nodelay = true; // MCE_DEFAULT_TCP_NODELAY (falst) ring_dev_mem_tx = 16384; // MCE_DEFAULT_RING_DEV_MEM_TX (0) break; @@ -842,11 +805,6 @@ void mce_sys_var::get_env_params() if ((env_ptr = getenv(SYS_VAR_TX_NUM_BUFS)) != NULL) tx_num_bufs = (uint32_t)atoi(env_ptr); -#ifdef DEFINED_TSO - if ((env_ptr = getenv(SYS_VAR_TX_BUF_SIZE)) != NULL) - tx_buf_size = (uint32_t)atoi(env_ptr); -#endif /* DEFINED_TSO */ - if ((env_ptr = getenv(SYS_VAR_TX_NUM_WRE)) != NULL) tx_num_wr = (uint32_t)atoi(env_ptr); @@ -862,11 +820,11 @@ void mce_sys_var::get_env_params() MAX_SUPPORTED_IB_INLINE_SIZE, tx_max_inline); tx_max_inline = MAX_SUPPORTED_IB_INLINE_SIZE; } - unsigned int cx4_max_tx_wre_for_inl = (16 * 1024 * 64) / (VMA_ALIGN(VMA_ALIGN(tx_max_inline - 12, 64) + 12, 64)); - if (tx_num_wr > cx4_max_tx_wre_for_inl) { + unsigned int cx5_max_tx_wre_for_inl = (2* 16 * 1024 * 64) / (VMA_ALIGN(VMA_ALIGN(tx_max_inline - 12, 64) + 12, 64)); + if (tx_num_wr > cx5_max_tx_wre_for_inl) { vlog_printf(VLOG_WARNING,"For the given VMA_TX_MAX_INLINE [%d], VMA_TX_WRE [%d] must be smaller than %d\n", - tx_max_inline, tx_num_wr, cx4_max_tx_wre_for_inl); - tx_num_wr = cx4_max_tx_wre_for_inl; + tx_max_inline, tx_num_wr, cx5_max_tx_wre_for_inl); + tx_num_wr = cx5_max_tx_wre_for_inl; } if ((env_ptr = getenv(SYS_VAR_TX_MC_LOOPBACK)) != NULL) @@ -1117,11 +1075,6 @@ void mce_sys_var::get_env_params() if ((env_ptr = getenv(SYS_VAR_TCP_TIMER_RESOLUTION_MSEC)) != NULL) tcp_timer_resolution_msec = atoi(env_ptr); - if ((env_ptr = getenv(SYS_VAR_INTERNAL_THREAD_TCP_TIMER_HANDLING)) != NULL) { - internal_thread_tcp_timer_handling = - atoi(env_ptr) == 1 ? INTERNAL_THREAD_TCP_TIMER_HANDLING_IMMEDIATE : INTERNAL_THREAD_TCP_TIMER_HANDLING_DEFERRED; - } - if ((env_ptr = getenv(SYS_VAR_TCP_CTL_THREAD)) != NULL) { tcp_ctl_thread = (tcp_ctl_thread_t)atoi(env_ptr); if (tcp_ctl_thread >= CTL_THREAD_LAST || tcp_ctl_thread < 0) @@ -1246,20 +1199,6 @@ void mce_sys_var::get_env_params() if ((env_ptr = getenv(SYS_VAR_FORK)) != NULL) handle_fork = atoi(env_ptr) ? true : false; - if((env_ptr = getenv(SYS_VAR_IPOIB )) != NULL) - enable_ipoib = atoi(env_ptr) ? true : false; - -#ifdef DEFINED_TSO - if((env_ptr = getenv(SYS_VAR_TSO)) != NULL) - enable_tso = atoi(env_ptr) ? true : false; - - if (enable_tso && (ring_migration_ratio_tx != -1)) { - ring_migration_ratio_tx = -1; - vlog_printf(VLOG_DEBUG,"%s parameter is forced to %d in case %s is enabled\n", - SYS_VAR_RING_MIGRATION_RATIO_TX, -1, SYS_VAR_TSO); - } -#endif /* DEFINED_TSO */ - if ((env_ptr = getenv(SYS_VAR_CLOSE_ON_DUP2)) != NULL) close_on_dup2 = atoi(env_ptr) ? true : false; @@ -1272,6 +1211,10 @@ void mce_sys_var::get_env_params() if ((env_ptr = getenv(SYS_VAR_TCP_CC_ALGO)) != NULL) lwip_cc_algo_mod = (uint32_t)atoi(env_ptr); + if ((env_ptr = getenv(SYS_VAR_DEFERRED_CLOSE)) != NULL) { + deferred_close = atoi(env_ptr) ? true : false; + } + if ((env_ptr = getenv(SYS_VAR_VMA_RX_POLL_ON_TX_TCP)) != NULL) rx_poll_on_tx_tcp = atoi(env_ptr) ? true : false; @@ -1314,10 +1257,12 @@ void set_env_params() if (safe_mce_sys().handle_bf) { setenv("MLX4_POST_SEND_PREFER_BF", "1", 1); setenv("MLX5_POST_SEND_PREFER_BF", "1", 1); + setenv("MLX5_SHUT_UP_BF", "0", 1); } else { /* todo - these seem not to work if inline is on, since libmlx is doing (inl || bf) when deciding to bf*/ setenv("MLX4_POST_SEND_PREFER_BF", "0", 1); setenv("MLX5_POST_SEND_PREFER_BF", "0", 1); + setenv("MLX5_SHUT_UP_BF", "1", 1); } switch (safe_mce_sys().mem_alloc_type) { diff --git a/src/vma/util/sys_vars.h b/src/vma/util/sys_vars.h index 6435e5ccb7..32f318557c 100644 --- a/src/vma/util/sys_vars.h +++ b/src/vma/util/sys_vars.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -65,10 +39,14 @@ typedef enum { ALLOC_TYPE_ANON = 0, ALLOC_TYPE_CONTIG, ALLOC_TYPE_HUGEPAGES, + ALLOC_TYPE_EXTERNAL, ALLOC_TYPE_LAST_ALLOWED_TO_USE, - ALLOC_TYPE_EXTERNAL, /* not allowed as a global parameter */ + ALLOC_TYPE_REGISTER_MEMORY /* not allowed as a global parameter */ } alloc_mode_t; +typedef void* (*alloc_t)(size_t); +typedef void (*free_t)(void*); + typedef enum { TS_CONVERSION_MODE_DISABLE = 0, // TS_CONVERSION_MODE_DISABLE must be the first enum TS_CONVERSION_MODE_RAW, @@ -122,26 +100,6 @@ typedef enum { BUFFER_BATCHING_LAST, } buffer_batching_mode_t; -// See ibv_transport_type for general verbs transport types -typedef enum { - VMA_TRANSPORT_UNKNOWN = -1, - VMA_TRANSPORT_IB = 0, - VMA_TRANSPORT_ETH -} transport_type_t; - -static inline const char* priv_vma_transport_type_str(transport_type_t transport_type) -{ - BULLSEYE_EXCLUDE_BLOCK_START - switch (transport_type) { - case VMA_TRANSPORT_IB: return "IB"; - case VMA_TRANSPORT_ETH: return "ETH"; - case VMA_TRANSPORT_UNKNOWN: - default: break; - } - return "UNKNOWN"; - BULLSEYE_EXCLUDE_BLOCK_END -} - typedef enum { MSS_FOLLOW_MTU = 0 } mss_mode_t; @@ -175,21 +133,6 @@ static inline const char* ctl_thread_str(tcp_ctl_thread_t logic) return "unsupported"; } -typedef enum { - INTERNAL_THREAD_TCP_TIMER_HANDLING_DEFERRED = 0, - INTERNAL_THREAD_TCP_TIMER_HANDLING_IMMEDIATE -} internal_thread_tcp_timer_handling_t; - -static inline const char* internal_thread_tcp_timer_handling_str(internal_thread_tcp_timer_handling_t handling) -{ - switch (handling) { - case INTERNAL_THREAD_TCP_TIMER_HANDLING_DEFERRED: return "(deferred)"; - case INTERNAL_THREAD_TCP_TIMER_HANDLING_IMMEDIATE: return "(immediate)"; - default: break; - } - return "unsupported"; -} - namespace vma_spec { // convert str to vVMA_spec_t; upon error - returns the given 'def_value' vma_spec_t from_str(const char* str, vma_spec_t def_value = MCE_SPEC_NONE); @@ -328,9 +271,6 @@ struct mce_sys_var { uint32_t tx_num_segs_tcp; uint32_t tx_num_bufs; -#ifdef DEFINED_TSO - uint32_t tx_buf_size; -#endif /* DEFINED_TSO */ uint32_t tx_num_wr; uint32_t tx_num_wr_to_signal; uint32_t tx_max_inline; @@ -407,27 +347,29 @@ struct mce_sys_var { char internal_thread_affinity_str[FILENAME_MAX]; cpu_set_t internal_thread_affinity; bool internal_thread_arm_cq_enabled; - internal_thread_tcp_timer_handling_t internal_thread_tcp_timer_handling; bool handle_bf; - - bool enable_ipoib; bool enable_socketxtreme; -#ifdef DEFINED_TSO - bool enable_tso; -#endif /* DEFINED_TSO */ uint32_t timer_netlink_update_msec; //Neigh parameters uint32_t neigh_uc_arp_quata; uint32_t neigh_wait_till_send_arp_msec; uint32_t neigh_num_err_retries; - + #ifdef VMA_TIME_MEASURE uint32_t vma_time_measure_num_samples; + #endif char vma_time_measure_filename[PATH_MAX]; sysctl_reader_t & sysctl_reader; + // Workaround for #3440429: postpone close(2) to the socket destructor, so the sockfd is closed + // after the rfs rule is destroyed. Otherwise, flow_tag or TCP port can be reused too early. + bool deferred_close; bool rx_poll_on_tx_tcp; hyper_t hypervisor; bool trigger_dummy_send_getsockname; + /* This field should be used to store and use data for VMA_EXTRA_API_IOCTL */ + struct { + vma_cmsg_ioctl_user_alloc_t user_alloc; + } m_ioctl; private: void print_vma_load_failure_msg(); int list_to_cpuset(char *cpulist, cpu_set_t *cpu_set); @@ -440,7 +382,10 @@ struct mce_sys_var { void read_hv(); // prevent unautothrized creation of objects - mce_sys_var () : sysctl_reader(sysctl_reader_t::instance()){ + mce_sys_var() + : sysctl_reader(sysctl_reader_t::instance()) + , m_ioctl {} + { // coverity[uninit_member] get_env_params(); } @@ -474,9 +419,6 @@ extern mce_sys_var & safe_mce_sys(); #define SYS_VAR_TX_NUM_SEGS_TCP "VMA_TX_SEGS_TCP" #define SYS_VAR_TX_NUM_BUFS "VMA_TX_BUFS" -#ifdef DEFINED_TSO -#define SYS_VAR_TX_BUF_SIZE "VMA_TX_BUF_SIZE" -#endif /* DEFINED_TSO */ #define SYS_VAR_TX_NUM_WRE "VMA_TX_WRE" #define SYS_VAR_TX_NUM_WRE_TO_SIGNAL "VMA_TX_WRE_BATCHING" #define SYS_VAR_TX_MAX_INLINE "VMA_TX_MAX_INLINE" @@ -549,17 +491,11 @@ extern mce_sys_var & safe_mce_sys(); #define SYS_VAR_SPEC "VMA_SPEC" #define SYS_VAR_SPEC_PARAM1 "VMA_SPEC_PARAM1" #define SYS_VAR_SPEC_PARAM2 "VMA_SPEC_PARAM2" - -#define SYS_VAR_IPOIB "VMA_IPOIB" -#define SYS_VAR_SOCKETXTREME "VMA_SOCKETXTREME" -#ifdef DEFINED_TSO -#define SYS_VAR_TSO "VMA_TSO" -#endif /* DEFINED_TSO */ +#define SYS_VAR_SOCKETXTREME "VMA_SOCKETXTREME" #define SYS_VAR_INTERNAL_THREAD_AFFINITY "VMA_INTERNAL_THREAD_AFFINITY" #define SYS_VAR_INTERNAL_THREAD_CPUSET "VMA_INTERNAL_THREAD_CPUSET" #define SYS_VAR_INTERNAL_THREAD_ARM_CQ "VMA_INTERNAL_THREAD_ARM_CQ" -#define SYS_VAR_INTERNAL_THREAD_TCP_TIMER_HANDLING "VMA_INTERNAL_THREAD_TCP_TIMER_HANDLING" #define SYS_VAR_NETLINK_TIMER_MSEC "VMA_NETLINK_TIMER" @@ -569,6 +505,7 @@ extern mce_sys_var & safe_mce_sys(); #define SYS_VAR_VMA_TIME_MEASURE_NUM_SAMPLES "VMA_TIME_MEASURE_NUM_SAMPLES" #define SYS_VAR_VMA_TIME_MEASURE_DUMP_FILE "VMA_TIME_MEASURE_DUMP_FILE" +#define SYS_VAR_DEFERRED_CLOSE "VMA_DEFERRED_CLOSE" #define SYS_VAR_VMA_RX_POLL_ON_TX_TCP "VMA_RX_POLL_ON_TX_TCP" #define SYS_VAR_VMA_TRIGGER_DUMMY_SEND_GETSOCKNAME "VMA_TRIGGER_DUMMY_SEND_GETSOCKNAME" @@ -592,9 +529,6 @@ extern mce_sys_var & safe_mce_sys(); #define MCE_DEFAULT_TCP_MAX_SYN_RATE (0) #define MCE_DEFAULT_TX_NUM_SEGS_TCP (1000000) #define MCE_DEFAULT_TX_NUM_BUFS (200000) -#ifdef DEFINED_TSO -#define MCE_DEFAULT_TX_BUF_SIZE (0) -#endif /* DEFINED_TSO */ #define MCE_DEFAULT_TX_NUM_WRE (2048) #define MCE_DEFAULT_TX_NUM_WRE_TO_SIGNAL (64) #define MCE_DEFAULT_TX_MAX_INLINE (204) //+18(always inline ETH header) = 222 @@ -662,7 +596,7 @@ extern mce_sys_var & safe_mce_sys(); #define MCE_DEFAULT_WAIT_AFTER_JOIN_MSEC (0) #define MCE_DEFAULT_THREAD_MODE (THREAD_MODE_MULTI) #define MCE_DEFAULT_BUFFER_BATCHING_MODE (BUFFER_BATCHING_WITH_RECLAIM) -#ifndef VMA_IBV_ACCESS_ALLOCATE_MR +#ifndef DEFINED_IBV_ACCESS_ALLOCATE_MR #define MCE_DEFAULT_MEM_ALLOC_TYPE (ALLOC_TYPE_HUGEPAGES) #else #define MCE_DEFAULT_MEM_ALLOC_TYPE (ALLOC_TYPE_CONTIG) @@ -676,7 +610,6 @@ extern mce_sys_var & safe_mce_sys(); #define MCE_DEFAULT_INTERNAL_THREAD_AFFINITY (-1) #define MCE_DEFAULT_INTERNAL_THREAD_AFFINITY_STR ("-1") #define MCE_DEFAULT_INTERNAL_THREAD_CPUSET ("") -#define MCE_DEFAULT_INTERNAL_THREAD_TCP_TIMER_HANDLING (INTERNAL_THREAD_TCP_TIMER_HANDLING_DEFERRED) #define MCE_DEFAULT_NETLINK_TIMER_MSEC (10000) #define MCE_DEFAULT_NEIGH_UC_ARP_QUATA 3 @@ -690,23 +623,20 @@ extern mce_sys_var & safe_mce_sys(); #define MCE_MAX_NUM_SGE (32) #define MCE_MIN_RX_NUM_POLLS (-1) #define MCE_MAX_RX_NUM_POLLS (100000000) -#define MCE_MIN_RX_PREFETCH_BYTES (32) /* Just enough for headers (IPoIB+IP+UDP)*/ +#define MCE_MIN_RX_PREFETCH_BYTES (32) #define MCE_MAX_RX_PREFETCH_BYTES (2044) #define MCE_RX_CQ_DRAIN_RATE_DISABLED (0) #define MCE_CQ_DRAIN_INTERVAL_DISABLED (0) #define MCE_CQ_ADAPTIVE_MODERATION_DISABLED (0) #define MCE_MIN_CQ_POLL_BATCH (1) #define MCE_MAX_CQ_POLL_BATCH (128) -#define MCE_DEFAULT_IPOIB_FLAG (1) #define MCE_DEFAULT_SOCKETXTREME (false) -#ifdef DEFINED_TSO -#define MCE_DEFAULT_TSO (true) -#endif /* DEFINED_TSO */ #define MCE_DEFAULT_RX_POLL_ON_TX_TCP (false) #define MCE_DEFAULT_TRIGGER_DUMMY_SEND_GETSOCKNAME (false) +#define MCE_DEFAULT_DEFERRED_CLOSE (false) #define MCE_ALIGNMENT ((unsigned long)63) -#define RX_BUF_SIZE(mtu) ((mtu) + IPOIB_HDR_LEN + GRH_HDR_LEN) // RX buffers are larger in IB +#define RX_BUF_SIZE(mtu) ((mtu) + ETH_VLAN_HDR_LEN) #define TX_BUF_SIZE(mtu) ((mtu) + 92) // Tx buffers are larger in Ethernet (they include L2 for RAW QP) #define NUM_TX_WRE_TO_SIGNAL_MAX 64 #define NUM_RX_WRE_TO_POST_RECV_MAX 1024 @@ -715,7 +645,6 @@ extern mce_sys_var & safe_mce_sys(); #define IFTYPE_PARAM_FILE "/sys/class/net/%s/type" #define IFADDR_MTU_PARAM_FILE "/sys/class/net/%s/mtu" #define UMCAST_PARAM_FILE "/sys/class/net/%s/umcast" -#define IPOIB_MODE_PARAM_FILE "/sys/class/net/%s/mode" #define VERBS_DEVICE_PORT_PARAM_FILE "/sys/class/net/%s/dev_port" #define VERBS_DEVICE_ID_PARAM_FILE "/sys/class/net/%s/dev_id" #define BONDING_MODE_PARAM_FILE "/sys/class/net/%s/bonding/mode" @@ -729,9 +658,6 @@ extern mce_sys_var & safe_mce_sys(); #define L2_ADDR_FILE_FMT "/sys/class/net/%.*s/address" #define L2_BR_ADDR_FILE_FMT "/sys/class/net/%.*s/broadcast" #define OPER_STATE_PARAM_FILE "/sys/class/net/%s/operstate" -#if defined(DEFINED_VERBS_VERSION) && (DEFINED_VERBS_VERSION == 2) -#define RAW_QP_PRIVLIGES_PARAM_FILE "/sys/module/ib_uverbs/parameters/disable_raw_qp_enforcement" -#endif /* DEFINED_VERBS_VERSION */ #define FLOW_STEERING_MGM_ENTRY_SIZE_PARAM_FILE "/sys/module/mlx4_core/parameters/log_num_mgm_entry_size" #define VIRTUAL_DEVICE_FOLDER "/sys/devices/virtual/net/%s/" #define BOND_DEVICE_FILE "/proc/net/bonding/%s" diff --git a/src/vma/util/sysctl_reader.h b/src/vma/util/sysctl_reader.h index de1932fa5f..c6d0657835 100644 --- a/src/vma/util/sysctl_reader.h +++ b/src/vma/util/sysctl_reader.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -43,6 +17,12 @@ struct sysctl_tcp_mem { int max_value; }; +struct tcp_keepalive_info { + int idle_secs; + int interval_secs; + int num_probes; +}; + class sysctl_reader_t { private: @@ -97,6 +77,7 @@ public : get_net_ipv4_ttl(true); get_igmp_max_membership(true); get_igmp_max_source_membership(true); + get_tcp_keepalive_info(true); } int get_tcp_max_syn_backlog(bool update = false) { @@ -140,6 +121,26 @@ public : return &tcp_mem; } + const tcp_keepalive_info get_tcp_keepalive_info(bool update = false) + { + static tcp_keepalive_info val = {7200, 75, 9}; + auto read_positive_or_default = [](const char *path, int default_value) { + int ret = read_file_to_int(path, default_value); + return ret > 0 ? ret : default_value; + }; + if (update) { + val.idle_secs = + read_positive_or_default("/proc/sys/net/ipv4/tcp_keepalive_time", val.idle_secs); + val.interval_secs = + std::max(0, read_file_to_int("/proc/sys/net/ipv4/tcp_keepalive_intvl", + val.interval_secs)); + val.num_probes = + std::max(0, read_file_to_int("/proc/sys/net/ipv4/tcp_keepalive_probes", + val.num_probes)); + } + return val; + } + int get_tcp_window_scaling(bool update = false) { static int val; if (update) diff --git a/src/vma/util/to_str.h b/src/vma/util/to_str.h index eb49c4d63e..436c23afa9 100644 --- a/src/vma/util/to_str.h +++ b/src/vma/util/to_str.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/utils.cpp b/src/vma/util/utils.cpp index ef9c096dec..61594c3bde 100644 --- a/src/vma/util/utils.cpp +++ b/src/vma/util/utils.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -36,12 +10,14 @@ #include #include #include +#include #include #include "vma/util/if.h" #include #include #include #include +#include #include #include #include //IP header (struct iphdr) definition @@ -67,6 +43,7 @@ #endif using namespace std; +using namespace std::chrono; #undef MODULE_NAME #define MODULE_NAME "utils:" @@ -117,8 +94,8 @@ int get_base_interface_name(const char *if_name, char *base_ifname, size_t sz_ba return 0; } - unsigned char vlan_if_address[MAX_L2_ADDR_LEN]; - const size_t ADDR_LEN = get_local_ll_addr(if_name, vlan_if_address, MAX_L2_ADDR_LEN, false); + unsigned char vlan_if_address[ETH_ALEN]; + const size_t ADDR_LEN = get_local_ll_addr(if_name, vlan_if_address, ETH_ALEN, false); if (ADDR_LEN > 0) { struct ifaddrs *ifaddr, *ifa; int rc = getifaddrs(&ifaddr); @@ -148,12 +125,9 @@ int get_base_interface_name(const char *if_name, char *base_ifname, size_t sz_ba unsigned char tmp_mac[ADDR_LEN]; if (ADDR_LEN == get_local_ll_addr(ifa->ifa_name, tmp_mac, ADDR_LEN, false)) { - int size_to_compare; - if (ADDR_LEN == ETH_ALEN) size_to_compare = ETH_ALEN; - else size_to_compare = IPOIB_HW_ADDR_GID_LEN; - int offset = ADDR_LEN - size_to_compare; - if (0 == memcmp(vlan_if_address + offset, tmp_mac + offset, size_to_compare) && 0 == (ifa->ifa_flags & IFF_MASTER)) { - // A bond name cannot be a base name of an interface even if both have the same MAC(ethernet) or GID(IB) addresses + int offset = ADDR_LEN - ETH_ALEN; + if (0 == memcmp(vlan_if_address + offset, tmp_mac + offset, ETH_ALEN) && 0 == (ifa->ifa_flags & IFF_MASTER)) { + // A bond name cannot be a base name of an interface even if both have the same MAC(ethernet) snprintf(base_ifname, sz_base_ifname, "%s" ,ifa->ifa_name); freeifaddrs(ifaddr); __log_dbg("Found base_ifname %s for interface %s", base_ifname, if_name); @@ -168,7 +142,7 @@ int get_base_interface_name(const char *if_name, char *base_ifname, size_t sz_ba return 0; } -void print_roce_lag_warnings(char* interface, char* disable_path /* = NULL */, const char* port1 /* = NULL */, const char* port2 /* = NULL */) +void print_roce_lag_warnings(char* interface, const char* port1 /* = NULL */, const char* port2 /* = NULL */) { vlog_printf(VLOG_WARNING,"******************************************************************************************************\n"); @@ -181,11 +155,6 @@ void print_roce_lag_warnings(char* interface, char* disable_path /* = NULL */, c } vlog_printf(VLOG_WARNING,"* Please refer to VMA Release Notes for more info\n"); - - if (disable_path) { - vlog_printf(VLOG_WARNING,"* In order to disable RoCE LAG please use:\n"); - vlog_printf(VLOG_WARNING,"* echo 0 > %s\n", disable_path); - } vlog_printf(VLOG_WARNING,"******************************************************************************************************\n"); } @@ -417,7 +386,7 @@ const char* iphdr_protocol_type_to_str(const int type) int priv_read_file(const char *path, char *buf, size_t size, vlog_levels_t log_level /*= VLOG_ERROR*/) { - int len = -1; + int len; int fd = open(path, O_RDONLY); BULLSEYE_EXCLUDE_BLOCK_START if (fd < 0) { @@ -437,12 +406,13 @@ int priv_read_file(const char *path, char *buf, size_t size, vlog_levels_t log_l int read_file_to_int(const char *path, int default_value) { - char buf[25]; - int rc = priv_safe_read_file(path, buf, sizeof buf); - if (rc < 0) { + int value = -1; + std::ifstream file_stream(path); + if (!file_stream || !(file_stream >> value)) { __log_warn("ERROR while getting int from from file %s, we'll use default %d", path, default_value); + return default_value; } - return (rc < 0) ? default_value : atoi(buf); + return value; } int get_ifinfo_from_ip(const struct sockaddr& addr, char* ifname, uint32_t& ifflags) @@ -545,8 +515,8 @@ int get_iftype_from_ifname(const char* ifname) char iftype_filename[100]; char iftype_value_str[32]; - char base_ifname[32]; - char iftype_value = -1; + char base_ifname[32] = {0}; + int iftype_value = -1; get_base_interface_name(ifname, base_ifname, sizeof(base_ifname)); sprintf(iftype_filename, IFTYPE_PARAM_FILE, base_ifname); @@ -564,7 +534,7 @@ int get_if_mtu_from_ifname(const char* ifname) char if_mtu_len_filename[100]; char if_mtu_value_str[32]; - char base_ifname[32]; + char base_ifname[32] = {0}; int if_mtu_value = 0; /* initially try reading MTU from ifname. In case of failure (expected in alias ifnames) - try reading MTU from base ifname */ @@ -601,7 +571,7 @@ int get_window_scaling_factor(int tcp_rmem_max, int core_rmem_max) int get_ipv4_from_ifname(char *ifname, struct sockaddr_in *addr) { - int ret = -1; + int ret; __log_func("find ip addr for ifname '%s'", ifname); int fd = orig_os_api.socket(AF_INET, SOCK_DGRAM, 0); @@ -780,19 +750,12 @@ size_t get_local_ll_addr(IN const char * ifname, OUT unsigned char* addr, IN int if (addr_len < bytes_len) return 0; // error not enough room was provided by caller BULLSEYE_EXCLUDE_BLOCK_END - if (bytes_len == IPOIB_HW_ADDR_LEN && addr_len >= IPOIB_HW_ADDR_LEN) { // addr_len >= IPOIB_HW_ADDR_LEN is just for silencing coverity - sscanf(buf, IPOIB_HW_ADDR_SSCAN_FMT, IPOIB_HW_ADDR_SSCAN(addr)); - __log_dbg("found IB %s address " IPOIB_HW_ADDR_PRINT_FMT " for interface %s", is_broadcast?"BR":"UC", IPOIB_HW_ADDR_PRINT_ADDR(addr), ifname); - } - else if (bytes_len == ETH_ALEN) { - sscanf(buf, ETH_HW_ADDR_SSCAN_FMT, ETH_HW_ADDR_SSCAN(addr)); + if (bytes_len == ETH_ALEN && (0 < sscanf(buf, ETH_HW_ADDR_SSCAN_FMT, ETH_HW_ADDR_SSCAN(addr)))) { __log_dbg("found ETH %s address" ETH_HW_ADDR_PRINT_FMT " for interface %s", is_broadcast?"BR":"UC", ETH_HW_ADDR_PRINT_ADDR(addr), ifname); - } - else { - return 0; // error + return bytes_len; // Success } - return bytes_len; // success + return 0; // Failure } bool check_bond_device_exist(const char* ifname) @@ -845,7 +808,7 @@ bool check_bond_device_exist(const char* ifname) bool get_bond_name(IN const char* ifname, OUT char* bond_name, IN int sz) { char upper_path[256]; - char base_ifname[IFNAMSIZ]; + char base_ifname[IFNAMSIZ] = {0}; get_base_interface_name(ifname, base_ifname, sizeof(base_ifname)); struct ifaddrs *ifaddr, *ifa; bool ret = false; @@ -888,30 +851,10 @@ bool get_bond_active_slave_name(IN const char* bond_name, OUT char* active_slave return true; } -bool check_bond_roce_lag_exist(OUT char* bond_roce_lag_path, int sz, IN const char* slave_name) -{ -#if defined(DEFINED_DIRECT_VERBS) && defined(DEFINED_VERBS_VERSION) && (DEFINED_VERBS_VERSION == 3) - NOT_IN_USE(bond_roce_lag_path); - NOT_IN_USE(sz); - NOT_IN_USE(slave_name); - return true; -#else - char sys_res[1024] = {0}; - snprintf(bond_roce_lag_path, sz, BONDING_ROCE_LAG_FILE, slave_name); - if (priv_read_file(bond_roce_lag_path, sys_res, 1024, VLOG_FUNC) > 0) { - if (strtol(sys_res, NULL,10) > 0 && errno != ERANGE) { - return true; - } - } -#endif - - return false; -} - bool get_netvsc_slave(IN const char* ifname, OUT char* slave_name, OUT unsigned int &slave_flags) { char netvsc_path[256]; - char base_ifname[IFNAMSIZ]; + char base_ifname[IFNAMSIZ] = {0}; get_base_interface_name(ifname, base_ifname, sizeof(base_ifname)); struct ifaddrs *ifaddr, *ifa; bool ret = false; @@ -943,7 +886,7 @@ bool check_netvsc_device_exist(const char* ifname) { int ret = -1; char device_path[256] = {0}; - char base_ifname[IFNAMSIZ]; + char base_ifname[IFNAMSIZ] = {0}; get_base_interface_name(ifname, base_ifname, sizeof(base_ifname)); sprintf(device_path, NETVSC_DEVICE_CLASS_FILE, base_ifname); char sys_res[1024] = {0}; @@ -990,9 +933,8 @@ bool check_device_exist(const char* ifname, const char *path) { char device_path[256] = {0}; int fd = -1; - int n = -1; + int n = snprintf(device_path, sizeof(device_path), path, ifname); - n = snprintf(device_path, sizeof(device_path), path, ifname); if (likely((0 < n) && (n < (int)sizeof(device_path)))) { fd = orig_os_api.open(device_path, O_RDONLY); if (fd >= 0) { @@ -1008,17 +950,16 @@ bool check_device_exist(const char* ifname, const char *path) bool check_device_name_ib_name(const char* ifname, const char* ibname) { - int n = -1; - int fd = -1; + int fd; char ib_path[IBV_SYSFS_PATH_MAX]= {0}; const char *str_ifname = ifname; - + int n = snprintf(ib_path, sizeof(ib_path), "/sys/class/infiniband/%s/device/net/%s/ifindex", + ibname, str_ifname); /* Case #1: * Direct mapping between if device and ib device * For example: ens4f1 -> mlx5_3 */ - n = snprintf(ib_path, sizeof(ib_path), "/sys/class/infiniband/%s/device/net/%s/ifindex", - ibname, str_ifname); + if (likely((0 < n) && (n < (int)sizeof(ib_path)))) { fd = open(ib_path, O_RDONLY); if (fd >= 0) { @@ -1027,7 +968,6 @@ bool check_device_name_ib_name(const char* ifname, const char* ibname) } } -#if (defined(DEFINED_DIRECT_VERBS) && defined(DEFINED_VERBS_VERSION) && (DEFINED_VERBS_VERSION == 3)) /* Case #2: * When device is a slave interface * For example: ens4f1(bondX) -> mlx5_bond_X @@ -1056,7 +996,6 @@ bool check_device_name_ib_name(const char* ifname, const char* ibname) } } } -#endif return false; } @@ -1074,59 +1013,6 @@ bool get_interface_oper_state(IN const char* interface_name, OUT char* curr_stat return true; } -int validate_ipoib_prop(const char* ifname, unsigned int ifflags, - const char prop_file[], const char *expected_val, - int val_size, OUT char *filename, OUT char* base_ifname) -{ - char mode[10]; - char ifname_tmp[IFNAMSIZ]; - char active_slave_name[IFNAMSIZ]; - - // In case of alias (ib0:xx) take only the device name for that interface (ib0) - strncpy(ifname_tmp, ifname, sizeof(ifname_tmp) - 1); - ifname_tmp[sizeof(ifname_tmp) - 1] = '\0'; - base_ifname = strtok(ifname_tmp, ":"); - - if (ifflags & IFF_MASTER) { - // this is a bond interface, let find the slave - BULLSEYE_EXCLUDE_BLOCK_START - if (!get_bond_active_slave_name(base_ifname, active_slave_name, IFNAMSIZ)) { - return -1; - } - BULLSEYE_EXCLUDE_BLOCK_END - sprintf(filename, prop_file, active_slave_name); - } else { - sprintf(filename, prop_file, base_ifname); - } - - BULLSEYE_EXCLUDE_BLOCK_START - if (priv_read_file(filename, mode, val_size) <= 0) { - return -1; - } - BULLSEYE_EXCLUDE_BLOCK_END - if (strncmp(mode, expected_val, val_size)) { - return 1; - } else { - return 0; - } -} - -#if defined(DEFINED_VERBS_VERSION) && (DEFINED_VERBS_VERSION == 2) -//NOTE RAW_QP_PRIVLIGES_PARAM_FILE does not exist on upstream drivers -int validate_raw_qp_privliges() -{ - // RAW_QP_PRIVLIGES_PARAM_FILE: "/sys/module/ib_uverbs/parameters/disable_raw_qp_enforcement" - char raw_qp_privliges_value = 0; - if (priv_read_file((const char*)RAW_QP_PRIVLIGES_PARAM_FILE, &raw_qp_privliges_value, 1, VLOG_DEBUG) <= 0) { - return -1; - } - if (raw_qp_privliges_value != '1') { - return 0; - } - return 1; -} -#endif /* DEFINED_VERBS_VERSION */ - bool validate_user_has_cap_net_raw_privliges() { #ifdef HAVE_SYS_CAPABILITY_H @@ -1163,6 +1049,7 @@ size_t default_huge_page_size(void) if (file) { while (fgets(str, sizeof(str), file) != NULL) { if (sscanf(str, "Hugepagesize: %8lu kB", &sz) == 1) { + // coverity[overflow:FALSE] /* Turn off coverity overflow check */ hugepage_sz = sz * 1024; break; } @@ -1177,51 +1064,19 @@ size_t default_huge_page_size(void) return hugepage_sz; } -int validate_tso(int if_index) -{ -#ifdef HAVE_LINUX_ETHTOOL_H - int ret = -1; - int fd = -1; - struct ifreq req; - struct ethtool_value eval; - - fd = orig_os_api.socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) { - __log_err("ERROR from socket() (errno=%d %m)", errno); - return -1; - } - memset(&req, 0, sizeof(req)); - eval.cmd = ETHTOOL_GTSO; - req.ifr_ifindex = if_index; - if_indextoname(if_index, req.ifr_name); - req.ifr_data = (char *)&eval; - ret = orig_os_api.ioctl(fd, SIOCETHTOOL, &req); - if (ret < 0) { - __log_dbg("ioctl(SIOCETHTOOL) cmd=ETHTOOL_GTSO (errno=%d %m)", errno); - } else { - ret = eval.data; - } - orig_os_api.close(fd); - return ret; -#else - NOT_IN_USE(if_index); - return -1; -#endif -} - loops_timer::loops_timer() + : m_start() + , m_elapsed(milliseconds(0)) + , m_current() + , m_interval_it(2048) + , m_timer_countdown(0) + , m_timeout_msec(-1) { - m_timeout_msec = -1; - m_timer_countdown = 0; - m_interval_it = 2048; - ts_clear(&m_start); - ts_clear(&m_elapsed); - ts_clear(&m_current); } void loops_timer::start() { - ts_clear(&m_start); + m_start = steady_clock::time_point(); // set to 1 so the first loop is fast and only after it m_start will be initialized m_timer_countdown = 1; } @@ -1231,23 +1086,45 @@ int loops_timer::time_left_msec() if ( m_timeout_msec == -1 ) return -1; - if (!ts_isset(&m_start)) { //VMA_RX_POLL==0 - gettime(&m_start); + auto current = steady_clock::now(); + if (m_start.time_since_epoch() == steady_clock::duration::zero()) { + m_start = current; } - timespec current; - gettime(¤t); - ts_sub(¤t, &m_start, &m_elapsed); + m_elapsed = duration_cast(current - m_start); - //cover the case of left<0 - return (m_timeout_msec-ts_to_msec(&m_elapsed))>0 ? m_timeout_msec-ts_to_msec(&m_elapsed) : 0; + return std::max(0, m_timeout_msec - m_elapsed.count()); } +bool loops_timer::is_timeout() +{ + if (m_timeout_msec == -1) + return false; + + if (m_timer_countdown > 0) { + m_timer_countdown--; + return false; + } + //init counter + m_timer_countdown = m_interval_it; + + if (m_start.time_since_epoch() == steady_clock::duration::zero()) { + m_start = steady_clock::now(); + } + // update timer + m_current = steady_clock::now(); + m_elapsed = duration_cast(m_current - m_start); + + __log_finer("update loops_timer elapsed time=%ld msec\n", m_elapsed.count()); + + // test for timeout + return m_timeout_msec <= m_elapsed.count(); +} /////////////////////////////////////////// uint32_t fd2inode(int fd) { struct stat buf; int rc = fstat(fd, &buf); - return rc==0 ? buf.st_ino : 0; // no inode is 0 + return rc == 0 ? buf.st_ino : 0; // no inode is 0 } /////////////////////////////////////////// diff --git a/src/vma/util/utils.h b/src/vma/util/utils.h index fa711f3893..34df0c22ca 100644 --- a/src/vma/util/utils.h +++ b/src/vma/util/utils.h @@ -1,39 +1,14 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef UTILS_H #define UTILS_H +#include #include #include #include @@ -42,7 +17,6 @@ #include #include "vtypes.h" -#include "utils/rdtsc.h" #include "vlogger/vlogger.h" #include "vma/proto/mem_buf_desc.h" #include "vma/util/vma_stats.h" @@ -258,45 +232,27 @@ size_t get_vlan_base_name_from_ifname(const char* ifname, char* base_ifname, siz size_t get_local_ll_addr(const char* ifname, unsigned char* addr, int addr_len, bool is_broadcast); /* Print warning while RoCE Lag is enabled */ -void print_roce_lag_warnings(char* interface, char* disable_path = NULL, const char* port1 = NULL, const char* port2 = NULL); +void print_roce_lag_warnings(char* interface, const char* port1 = NULL, const char* port2 = NULL); bool check_bond_device_exist(const char* ifname); bool get_bond_active_slave_name(IN const char* bond_name, OUT char* active_slave_name, IN int sz); bool get_bond_slave_state(IN const char* slave_name, OUT char* curr_state, IN int sz); bool get_bond_slaves_name_list(IN const char* bond_name, OUT char* slaves_list, IN int sz); -bool check_bond_roce_lag_exist(OUT char* bond_roce_lag_path, int sz, IN const char* slave_name); bool check_device_exist(const char* ifname, const char *path); bool check_device_name_ib_name(const char* ifname, const char* ibname); bool check_netvsc_device_exist(const char* ifname); bool get_netvsc_slave(IN const char* ifname, OUT char* slave_name, OUT unsigned int &slave_flags); bool get_interface_oper_state(IN const char* interface_name, OUT char* slaves_list, IN int sz); - -int validate_ipoib_prop(const char* ifname, unsigned int ifflags, - const char prop_file[], const char *expected_val, - int val_size, char *filename, char* base_ifname); - -#if defined(DEFINED_VERBS_VERSION) && (DEFINED_VERBS_VERSION == 2) -int validate_raw_qp_privliges(); -#endif /* DEFINED_VERBS_VERSION */ - bool validate_user_has_cap_net_raw_privliges(); size_t default_huge_page_size(void); -/** - * Get TSO support using interface index - * - * @param if_index input interface index - * @return 0/1 or -1 on failure - */ -int validate_tso(int if_index); - static inline int get_procname(int pid, char *proc, size_t size) { char app_full_name[PATH_MAX] = {0}; char proccess_proc_dir[FILE_NAME_MAX_SIZE] = {0}; char* app_base_name = NULL; - int n = -1; + int n; if (NULL == proc) { return -1; @@ -346,96 +302,25 @@ inline void create_multicast_mac_from_ip(unsigned char* mc_mac, in_addr_t ip) mc_mac[5] = (uint8_t)((ip>>24)&0xff); } -static inline void create_mgid_from_ipv4_mc_ip(uint8_t *mgid, uint16_t pkey, uint32_t ip) -{ -// +--------+----+----+-----------------+---------+-------------------+ -// | 8 | 4 | 4 | 16 bits | 16 bits | 80 bits | -// +--------+----+----+-----------------+---------+-------------------+ -// |11111111|0001|scop||< P_Key >| group ID | -// +--------+----+----+-----------------+---------+-------------------+ -// |11111111|0001|0010|01000000000011011| | group ID | -// +--------+----+----+-----------------+---------+-------------------+ - - //Fixed for multicast - mgid[0] = 0xff; - mgid[1] = 0x12; - - //IPoIB signature: 0x401b for ipv4, 0x601b for ipv6 - mgid[2] = 0x40; - mgid[3] = 0x1b; - - //P_Key - mgid[4] = (((unsigned char *)(&pkey))[0]); - /* cppcheck-suppress objectIndex */ - mgid[5] = (((unsigned char *)(&pkey))[1]); - - //group ID - relevant only for ipv4 - mgid[6] = 0x00; - mgid[7] = 0x00; - mgid[8] = 0x00; - mgid[9] = 0x00; - mgid[10] = 0x00; - mgid[11] = 0x00; - mgid[12] = (uint8_t)((ip)&0x0f); - mgid[13] = (uint8_t)((ip>>8)&0xff); - mgid[14] = (uint8_t)((ip>>16)&0xff); - mgid[15] = (uint8_t)((ip>>24)&0xff); - - vlog_printf(VLOG_DEBUG, "Translated to mgid: %02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X\n", - ((unsigned char *)(mgid))[0],((unsigned char *)(mgid))[1], - ((unsigned char *)(mgid))[2],((unsigned char *)(mgid))[3], - ((unsigned char *)(mgid))[4],((unsigned char *)(mgid))[5], - ((unsigned char *)(mgid))[6],((unsigned char *)(mgid))[7], - ((unsigned char *)(mgid))[8],((unsigned char *)(mgid))[9], - ((unsigned char *)(mgid))[10],((unsigned char *)(mgid))[11], - ((unsigned char *)(mgid))[12],((unsigned char *)(mgid))[13], - ((unsigned char *)(mgid))[14],((unsigned char *)(mgid))[15]); -} - /** * special design for the rx loop. */ class loops_timer { - public: - loops_timer(); - void start(); - int time_left_msec(); - void set_timeout_msec(int timeout_msec) { m_timeout_msec = timeout_msec; } - int get_timeout_msec() { return m_timeout_msec; } - inline bool is_timeout() { - if (m_timeout_msec == -1) - return false; - - if (m_timer_countdown > 0) { - m_timer_countdown--; - return false; - } - //init counter - m_timer_countdown = m_interval_it; - - if (!ts_isset(&m_start)) { - gettime(&m_start); - } - //update timer - gettime(&m_current); - ts_sub(&m_current, &m_start, &m_elapsed); - vlog_printf(VLOG_FUNC_ALL, "update loops_timer (elapsed time=%ld sec %ld usec\n", ts_to_sec(&m_elapsed), ts_to_usec(&m_elapsed)); - - - - // test for timeout - if (m_timeout_msec <= ts_to_msec(&m_elapsed)) - return true; - - return false; - } - private: - timespec m_start; - timespec m_elapsed; - timespec m_current; - int m_interval_it; - int m_timer_countdown; - int m_timeout_msec; +public: + loops_timer(); + void start(); + int time_left_msec(); + void set_timeout_msec(int timeout_msec) { m_timeout_msec = timeout_msec; } + int get_timeout_msec() { return m_timeout_msec; } + bool is_timeout(); + +private: + std::chrono::time_point m_start; + std::chrono::milliseconds m_elapsed; + std::chrono::time_point m_current; + int m_interval_it; + int m_timer_countdown; + int m_timeout_msec; }; // Returns the filesystem's inode number for the given 'fd' using 'fstat' system call that assumes 32 bit inodes diff --git a/src/vma/util/valgrind.h b/src/vma/util/valgrind.h index a9fc65b228..f330df6e44 100644 --- a/src/vma/util/valgrind.h +++ b/src/vma/util/valgrind.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/vma_list.h b/src/vma/util/vma_list.h index cd3e5f9eef..0ad7e848f1 100644 --- a/src/vma/util/vma_list.h +++ b/src/vma/util/vma_list.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef VMA_LIST_H @@ -207,7 +181,7 @@ class vma_list_t } } - vma_list_t (const vma_list_t& other) { + vma_list_t(const vma_list_t& other) { if (!other.empty()) vlist_logwarn("Copy constructor is not supported for non-empty list! other.size=%zu", other.m_size); init_list(); diff --git a/src/vma/util/vma_stats.h b/src/vma/util/vma_stats.h index bf0f6a9116..5613843d58 100644 --- a/src/vma/util/vma_stats.h +++ b/src/vma/util/vma_stats.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -165,7 +139,7 @@ typedef struct { uint32_t n_tx_dummy; } socket_counters_t; -typedef struct { +typedef struct socket_stats_t { int fd; uint32_t inode; uint32_t tcp_state; // enum tcp_state @@ -210,7 +184,7 @@ typedef struct { }; } socket_stats_t; -typedef struct { +typedef struct socket_instance_block_t { bool b_enabled; socket_stats_t skt_stats; @@ -236,15 +210,13 @@ typedef struct { typedef enum { RING_ETH = 0, RING_ETH_DIRECT, - RING_TAP, - RING_IB + RING_TAP } ring_type_t; static const char * const ring_type_str[] = { "RING_ETH", "RING_ETH_DIRECT", - "RING_TAP", - "RING_IB" + "RING_TAP" }; // Ring stat info diff --git a/src/vma/util/vtypes.h b/src/vma/util/vtypes.h index 8d64255e88..897ebf824d 100644 --- a/src/vma/util/vtypes.h +++ b/src/vma/util/vtypes.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -106,66 +80,16 @@ static inline uint64_t ntohll(uint64_t x) { return x; } ((unsigned char *)(__addr))[2], ((unsigned char *)(__addr))[3], \ ((unsigned char *)(__addr))[4], ((unsigned char *)(__addr))[5] - -#define IPOIB_HW_ADDR_PRINT_FMT_16 "%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X" -#define IPOIB_HW_ADDR_PRINT_ADDR_16(__addr) \ - ((unsigned char *)(__addr))[0],((unsigned char *)(__addr))[1], \ - ((unsigned char *)(__addr))[2],((unsigned char *)(__addr))[3], \ - ((unsigned char *)(__addr))[4],((unsigned char *)(__addr))[5], \ - ((unsigned char *)(__addr))[6],((unsigned char *)(__addr))[7], \ - ((unsigned char *)(__addr))[8],((unsigned char *)(__addr))[9], \ - ((unsigned char *)(__addr))[10],((unsigned char *)(__addr))[11], \ - ((unsigned char *)(__addr))[12],((unsigned char *)(__addr))[13], \ - ((unsigned char *)(__addr))[14],((unsigned char *)(__addr))[15] - -#define IPOIB_HW_ADDR_PRINT_FMT "%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X" -#define IPOIB_HW_ADDR_PRINT_ADDR(__addr) \ - ((unsigned char *)(__addr))[0],((unsigned char *)(__addr))[1], \ - ((unsigned char *)(__addr))[2],((unsigned char *)(__addr))[3], \ - ((unsigned char *)(__addr))[4],((unsigned char *)(__addr))[5], \ - ((unsigned char *)(__addr))[6],((unsigned char *)(__addr))[7], \ - ((unsigned char *)(__addr))[8],((unsigned char *)(__addr))[9], \ - ((unsigned char *)(__addr))[10],((unsigned char *)(__addr))[11], \ - ((unsigned char *)(__addr))[12],((unsigned char *)(__addr))[13], \ - ((unsigned char *)(__addr))[14],((unsigned char *)(__addr))[15], \ - ((unsigned char *)(__addr))[16],((unsigned char *)(__addr))[17], \ - ((unsigned char *)(__addr))[18],((unsigned char *)(__addr))[19] - #define ETH_HW_ADDR_SSCAN_FMT "%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX" #define ETH_HW_ADDR_SSCAN(__addr) \ &(__addr[0]),&(__addr[1]), \ &(__addr[2]),&(__addr[3]), \ &(__addr[4]),&(__addr[5]) - -#define IPOIB_HW_ADDR_SSCAN_FMT "%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX" -#define IPOIB_HW_ADDR_SSCAN(__addr) \ - &(__addr[0]),&(__addr[1]), \ - &(__addr[2]),&(__addr[3]), \ - &(__addr[4]),&(__addr[5]), \ - &(__addr[6]),&(__addr[7]), \ - &(__addr[8]),&(__addr[9]), \ - &(__addr[10]),&(__addr[11]), \ - &(__addr[12]),&(__addr[13]), \ - &(__addr[14]),&(__addr[15]), \ - &(__addr[16]),&(__addr[17]), \ - &(__addr[18]),&(__addr[19]) - #define ETH_HDR_LEN (ETH_HLEN) #define ETH_VLAN_HDR_LEN (ETH_HDR_LEN + sizeof(struct vlanhdr)) -#define GRH_HDR_LEN (sizeof(struct ibv_grh)) -#define IPOIB_HDR_LEN (sizeof(struct ipoibhdr)) -#define IPOIB_HEADER ((uint32_t)0x08000000) -#define IPOIB_ARP_HEADER ((uint32_t)0x08060000) -#define IPOIB_HW_ADDR_LEN 20 -#define IPOIB_HW_ADDR_GID_LEN 16 -#define MAX_L2_ADDR_LEN (MAX(IPOIB_HW_ADDR_LEN, ETH_ALEN)) #define IPV4_VERSION 0x4 #define IPV4_HDR_LEN_WITHOUT_OPTIONS (sizeof(struct iphdr)) // Ip Header without any options -#define IPV4_IGMP_HDR_LEN (IPV4_HDR_LEN_WITHOUT_OPTIONS + sizeof(uint32_t)) -#define IPV4_IGMP_HDR_LEN_WORDS (IPV4_IGMP_HDR_LEN / sizeof(uint32_t)) -#define IGMP_HDR_LEN (sizeof(struct igmphdr)) -#define IGMP_HDR_LEN_WORDS (IGMP_HDR_LEN / sizeof(uint32_t)) #define DONT_FRAGMENT_FLAG 0x4000 #define MORE_FRAGMENTS_FLAG 0x2000 #define FRAGMENT_OFFSET 0x1FFF @@ -177,10 +101,6 @@ static inline uint64_t ntohll(uint64_t x) { return x; } #define BROADCAST_IP "255.255.255.255" -#ifndef ARPHRD_INFINIBAND -#define ARPHRD_INFINIBAND 32 /* InfiniBand */ -#endif - #ifndef ARPHRD_ETHER #define ARPHRD_ETHER 1 /* Ethernet 10Mbps */ #endif @@ -193,10 +113,6 @@ static inline uint64_t ntohll(uint64_t x) { return x; } #define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ #endif -struct __attribute__ ((packed)) ipoibhdr { - uint32_t ipoib_header; -}; - struct __attribute__((packed)) vlanhdr { uint16_t h_vlan_TCI; /* Encapsulates priority and VLAN ID */ uint16_t h_vlan_encapsulated_proto; /* packet type ID field (or len) */ diff --git a/src/vma/util/wakeup.cpp b/src/vma/util/wakeup.cpp index 459a65718d..ba1633d0d9 100644 --- a/src/vma/util/wakeup.cpp +++ b/src/vma/util/wakeup.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/wakeup.h b/src/vma/util/wakeup.h index bd4fe547f6..9d2a75ab6e 100644 --- a/src/vma/util/wakeup.h +++ b/src/vma/util/wakeup.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/wakeup_pipe.cpp b/src/vma/util/wakeup_pipe.cpp index 1acc315a24..e4c6712dd1 100644 --- a/src/vma/util/wakeup_pipe.cpp +++ b/src/vma/util/wakeup_pipe.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/util/wakeup_pipe.h b/src/vma/util/wakeup_pipe.h index 18a950038c..aabd7cf835 100644 --- a/src/vma/util/wakeup_pipe.h +++ b/src/vma/util/wakeup_pipe.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/src/vma/vma_extra.h b/src/vma/vma_extra.h index 803ea3f768..fde726b890 100644 --- a/src/vma/vma_extra.h +++ b/src/vma/vma_extra.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef VMA_EXTRA_H @@ -53,6 +27,38 @@ #define SO_VMA_FLOW_TAG 2820 #define SO_VMA_SHUTDOWN_RX 2821 +enum { + /* cmsg_level is SOL_SOCKET as protocol independent option + * cmsg_data has data in vma_cmsg_ioctl_user_alloc_t format + */ + CMSG_VMA_IOCTL_USER_ALLOC = 2900 +}; + +/** + * @brief This structure as an argument for vma_ioctl() call with + * @ref CMSG_VMA_IOCTL_USER_ALLOC to use user provided functions for + * internal pool allocation. + * + * @note CMSG_VMA_IOCTL_USER_ALLOC must be called before the library + * initialization that is done during first call of following functions + * as socket(), epoll_create(), epoll_create1(), pipe(). + * + * @param flags - set a internal memory pool to apply. + * @param memalloc - ponter to the function to allocate memory. + * @param memfree - ponter to the function to free previously allocated memory. + */ + +enum { + VMA_IOCTL_USER_ALLOC_FLAG_TX = (1 << 0), + VMA_IOCTL_USER_ALLOC_FLAG_RX = (1 << 1) +}; + +struct __attribute__ ((packed)) vma_cmsg_ioctl_user_alloc_t { + uint8_t flags; + void* (*memalloc)(size_t); + void (*memfree)(void *); +}; + /* * Flags for Dummy send API */ @@ -366,7 +372,7 @@ typedef enum { VMA_EXTRA_API_REGISTER_MEMORY_ON_RING = (1 << 17), VMA_EXTRA_API_DEREGISTER_MEMORY_ON_RING = (1 << 18), VMA_EXTRA_API_MODIFY_RING = (1 << 20), - VMA_EXTRA_API_GET_DPCP_DEVICES = (1 << 21) + VMA_EXTRA_API_IOCTL = (1 << 21), } vma_extra_api_mask; /** @@ -712,32 +718,36 @@ struct __attribute__ ((packed)) vma_api_t { /** * Used to identify which methods were initialized by VMA as part of vma_get_api(). * The value content is based on vma_extra_api_mask enum. + * Order of fields in this structure should not be changed to keep abi compatibility. */ uint64_t vma_extra_supported_mask; /** - * get dpcp devices allocated by VMA + * This function allows to communicate with library using extendable protocol + * based on struct cmshdr. * - * @param devices - pointer to write the data to. can be NULL see notes - * @param devices_num - IN\OUT parameter - * IN - devices size given by user - * OUT- devices returned to user + * Ancillary data is a sequence of cmsghdr structures with appended data. + * The sequence of cmsghdr structures should never be accessed directly. + * Instead, use only the following macros: CMSG_ALIGN, CMSG_SPACE, CMSG_DATA, + * CMSG_LEN. * - * @return 0 on success -1 otherwise + * @param cmsg_hdr - point to control message + * @param cmsg_len - the byte count of the ancillary data, + * which contains the size of the structure header. * - * @note application can: - * call twice once with devices == NULL and get the size needed to allocate - * and call again to get the filled device array. - * if application is called with big enough buffer VMA will update the - * size actually used. + * @return -1 on failure and 0 on success */ - int (*get_dpcp_devices)(uintptr_t **devices, size_t *devices_num); + int (*ioctl)(void *cmsg_hdr, size_t cmsg_len); }; /** * Retrieve VMA extended API. + * This function can be called as an alternative to getsockopt() call + * when library is preloaded using LD_PRELOAD + * getsockopt() call should be used in case application loads library + * using dlopen()/dlsym(). * - * @return Pointer to the VMA Extended Socket API, of NULL if VMA not found. + * @return Pointer to the VMA Extended Socket API, of NULL if VMA not found. */ static inline struct vma_api_t* vma_get_api() { diff --git a/tests/api-support-check.py b/tests/api-support-check.py index fe24487f4d..de331d7eab 100755 --- a/tests/api-support-check.py +++ b/tests/api-support-check.py @@ -1,36 +1,10 @@ #!/usr/bin/env python # -#@copyright: -# Copyright (c) 2015-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2015-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # +#@copyright: #@author: Avner BenHanoch #@date: 18Oct2015 diff --git a/tests/async-echo-client/async-echo-client.py b/tests/async-echo-client/async-echo-client.py index a3372c4162..7965cb8146 100755 --- a/tests/async-echo-client/async-echo-client.py +++ b/tests/async-echo-client/async-echo-client.py @@ -1,37 +1,10 @@ #!/usr/bin/env python # +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2015-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # #@copyright: -# Copyright (c) 2015-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# #@author: Avner BenHanoch #@date: 20June2015 diff --git a/tests/async-echo-client/echo-server.py b/tests/async-echo-client/echo-server.py index 4083d0f0cf..5b211d6d66 100755 --- a/tests/async-echo-client/echo-server.py +++ b/tests/async-echo-client/echo-server.py @@ -1,34 +1,8 @@ #!/usr/bin/env python # -# Copyright (c) 2015-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2015-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # """ diff --git a/tests/async-echo-client/syncronized-echo-client.py b/tests/async-echo-client/syncronized-echo-client.py index 6c62674cd4..1e4e70c1c8 100755 --- a/tests/async-echo-client/syncronized-echo-client.py +++ b/tests/async-echo-client/syncronized-echo-client.py @@ -1,37 +1,10 @@ #!/usr/bin/env python # +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2015-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # #@copyright: -# Copyright (c) 2015-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# #@author: Avner BenHanoch #@date: 05July2015 diff --git a/tests/benchmarking_test/Accelerators_Benchmarking.sh b/tests/benchmarking_test/Accelerators_Benchmarking.sh index af1b83e27a..0d02c08948 100755 --- a/tests/benchmarking_test/Accelerators_Benchmarking.sh +++ b/tests/benchmarking_test/Accelerators_Benchmarking.sh @@ -1,34 +1,10 @@ #!/bin/sh # -# Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2013-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: # -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. # diff --git a/tests/bindtodevice/client.py b/tests/bindtodevice/client.py index b0021b78e4..97ac8cc85d 100755 --- a/tests/bindtodevice/client.py +++ b/tests/bindtodevice/client.py @@ -1,37 +1,10 @@ #!/usr/bin/env python # +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2015-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # #@copyright: -# Copyright (c) 2016-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# #@author: Alex Rosenbaum #@date: 18May2016 diff --git a/tests/connect-disconnect/client.py b/tests/connect-disconnect/client.py index 2fea4e7827..6f1df55d01 100755 --- a/tests/connect-disconnect/client.py +++ b/tests/connect-disconnect/client.py @@ -1,37 +1,10 @@ #!/usr/bin/env python # +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2015-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # #@copyright: -# Copyright (c) 2015-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# #@author: Avner BenHanoch #@date: 31Mar2015 diff --git a/tests/extra_api_tests/socketxtreme/server_tcp.c b/tests/extra_api_tests/socketxtreme/server_tcp.c index 3b8ebc9b58..f0ab85c506 100644 --- a/tests/extra_api_tests/socketxtreme/server_tcp.c +++ b/tests/extra_api_tests/socketxtreme/server_tcp.c @@ -1,33 +1,7 @@ /* - * Copyright © 2019-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ /* server_tcp.c diff --git a/tests/extra_api_tests/tcp_zcopy_cb/client.c b/tests/extra_api_tests/tcp_zcopy_cb/client.c index 8e1bf4260c..b998a25110 100755 --- a/tests/extra_api_tests/tcp_zcopy_cb/client.c +++ b/tests/extra_api_tests/tcp_zcopy_cb/client.c @@ -1,33 +1,7 @@ /* - * Copyright © 2014-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2014-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/extra_api_tests/tcp_zcopy_cb/client.h b/tests/extra_api_tests/tcp_zcopy_cb/client.h index d7c64e577f..0f48ffa918 100755 --- a/tests/extra_api_tests/tcp_zcopy_cb/client.h +++ b/tests/extra_api_tests/tcp_zcopy_cb/client.h @@ -1,33 +1,7 @@ /* - * Copyright © 2014-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2014-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef _CLIENT_H_ diff --git a/tests/extra_api_tests/tcp_zcopy_cb/main.c b/tests/extra_api_tests/tcp_zcopy_cb/main.c index 37dd475c86..21e36ea4ef 100755 --- a/tests/extra_api_tests/tcp_zcopy_cb/main.c +++ b/tests/extra_api_tests/tcp_zcopy_cb/main.c @@ -1,33 +1,7 @@ /* - * Copyright © 2014-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2014-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/extra_api_tests/tcp_zcopy_cb/server.c b/tests/extra_api_tests/tcp_zcopy_cb/server.c index bce2675bf3..833d32899f 100755 --- a/tests/extra_api_tests/tcp_zcopy_cb/server.c +++ b/tests/extra_api_tests/tcp_zcopy_cb/server.c @@ -1,33 +1,7 @@ /* - * Copyright © 2014-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2014-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/extra_api_tests/tcp_zcopy_cb/server.h b/tests/extra_api_tests/tcp_zcopy_cb/server.h index bc558590c7..efdb802504 100755 --- a/tests/extra_api_tests/tcp_zcopy_cb/server.h +++ b/tests/extra_api_tests/tcp_zcopy_cb/server.h @@ -1,33 +1,7 @@ /* - * Copyright © 2014-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2014-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef _SERVER_H_ diff --git a/tests/extra_api_tests/tcp_zcopy_cb/types.h b/tests/extra_api_tests/tcp_zcopy_cb/types.h index 9b5e28e04d..39f8a82ff2 100755 --- a/tests/extra_api_tests/tcp_zcopy_cb/types.h +++ b/tests/extra_api_tests/tcp_zcopy_cb/types.h @@ -1,33 +1,7 @@ /* - * Copyright © 2014-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2014-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef _TYPES_H_ diff --git a/tests/extra_api_tests/tcp_zcopy_cb/utils.c b/tests/extra_api_tests/tcp_zcopy_cb/utils.c index 3fbe28eb25..38c6f4625c 100755 --- a/tests/extra_api_tests/tcp_zcopy_cb/utils.c +++ b/tests/extra_api_tests/tcp_zcopy_cb/utils.c @@ -1,33 +1,7 @@ /* - * Copyright © 2014-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2014-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/functionality/getsockname_test.c b/tests/functionality/getsockname_test.c index 440d10dd4c..2f8453b84a 100644 --- a/tests/functionality/getsockname_test.c +++ b/tests/functionality/getsockname_test.c @@ -1,33 +1,7 @@ /* - * Copyright © 2013-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/functionality/iomux/1epoll_1socket_twice.c b/tests/functionality/iomux/1epoll_1socket_twice.c index 366225df80..b6afe56efe 100644 --- a/tests/functionality/iomux/1epoll_1socket_twice.c +++ b/tests/functionality/iomux/1epoll_1socket_twice.c @@ -1,33 +1,7 @@ /* - * Copyright © 2016-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/functionality/iomux/2epoll_1socket.c b/tests/functionality/iomux/2epoll_1socket.c index f3e247ecd9..976b652745 100644 --- a/tests/functionality/iomux/2epoll_1socket.c +++ b/tests/functionality/iomux/2epoll_1socket.c @@ -1,33 +1,7 @@ /* - * Copyright © 2016-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/functionality/iomux/client.py b/tests/functionality/iomux/client.py index 4c718f7967..a5564120db 100755 --- a/tests/functionality/iomux/client.py +++ b/tests/functionality/iomux/client.py @@ -1,34 +1,8 @@ #!/usr/bin/python # -# Copyright (c) 2011-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2013-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # # Written By: Avner BenHanoch @@ -125,4 +99,4 @@ def block_till_writeable (sock): psocket.close() csocket.close() -sys.exit (ret) \ No newline at end of file +sys.exit (ret) diff --git a/tests/functionality/iomux/eclient.py b/tests/functionality/iomux/eclient.py index 8994df95b7..97b8542498 100644 --- a/tests/functionality/iomux/eclient.py +++ b/tests/functionality/iomux/eclient.py @@ -1,34 +1,8 @@ #!/usr/bin/python # -# Copyright (c) 2011-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2013-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # # Written By: Avner BenHanoch @@ -137,4 +111,4 @@ def block_till_writeable (sock): psocket.close() csocket.close() epfd.close() -sys.exit (ret) \ No newline at end of file +sys.exit (ret) diff --git a/tests/functionality/iomux/eserver.py b/tests/functionality/iomux/eserver.py index d6e0940cd1..41dee6ca29 100644 --- a/tests/functionality/iomux/eserver.py +++ b/tests/functionality/iomux/eserver.py @@ -1,34 +1,8 @@ #!/usr/bin/env python # -# Copyright (c) 2011-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2013-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # # Written By: Avner BenHanoch @@ -151,4 +125,4 @@ def print_info (msg): if cserver: cserver.close() if psocket: psocket.close() if csocket: csocket.close() -if epfd: epfd.close() \ No newline at end of file +if epfd: epfd.close() diff --git a/tests/functionality/iomux/pclient.py b/tests/functionality/iomux/pclient.py index 98d989eaee..8ecbd8540f 100644 --- a/tests/functionality/iomux/pclient.py +++ b/tests/functionality/iomux/pclient.py @@ -1,34 +1,8 @@ #!/usr/bin/python # -# Copyright (c) 2011-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2013-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # # Written By: Avner BenHanoch diff --git a/tests/functionality/iomux/pserver.py b/tests/functionality/iomux/pserver.py index db0ef8d180..2f9f39c795 100644 --- a/tests/functionality/iomux/pserver.py +++ b/tests/functionality/iomux/pserver.py @@ -1,34 +1,8 @@ #!/usr/bin/env python # -# Copyright (c) 2011-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2013-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # # Written By: Avner BenHanoch diff --git a/tests/functionality/iomux/server.py b/tests/functionality/iomux/server.py index 6581bb9755..0209158051 100755 --- a/tests/functionality/iomux/server.py +++ b/tests/functionality/iomux/server.py @@ -1,34 +1,8 @@ #!/usr/bin/env python # -# Copyright (c) 2011-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2013-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # # Written By: Avner BenHanoch diff --git a/tests/gtest/Makefile.am b/tests/gtest/Makefile.am index d5f9681910..f68a0494ed 100644 --- a/tests/gtest/Makefile.am +++ b/tests/gtest/Makefile.am @@ -104,6 +104,7 @@ gtest_SOURCES = \ tcp/tcp_sendfile.cc \ tcp/tcp_send_zc.cc \ tcp/tcp_tls.cc \ + tcp/tcp_sockopt.cc \ \ udp/udp_base.cc \ udp/udp_bind.cc \ @@ -116,6 +117,7 @@ gtest_SOURCES = \ vma/vma_poll.cc \ vma/vma_sockopt.cc \ vma/vma_recvfrom_zcopy.cc \ + vma/vma_ioctl.cc \ \ vmad/vmad_base.cc \ vmad/vmad_bitmap.cc \ diff --git a/tests/gtest/common/base.cc b/tests/gtest/common/base.cc index 2d6d2efc8b..b249d6dddf 100644 --- a/tests/gtest/common/base.cc +++ b/tests/gtest/common/base.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/common/base.h b/tests/gtest/common/base.h index f6b0ac4ea4..aea9336109 100644 --- a/tests/gtest/common/base.h +++ b/tests/gtest/common/base.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TESTS_GTEST_COMMON_BASE_H_ diff --git a/tests/gtest/common/cmn.h b/tests/gtest/common/cmn.h index 939394575c..c154284e7d 100644 --- a/tests/gtest/common/cmn.h +++ b/tests/gtest/common/cmn.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TESTS_GTEST_COMMON_CMN_H_ diff --git a/tests/gtest/common/def.h b/tests/gtest/common/def.h index 40e4ec3462..411c54895c 100644 --- a/tests/gtest/common/def.h +++ b/tests/gtest/common/def.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TESTS_GTEST_COMMON_DEF_H_ @@ -101,6 +75,12 @@ #define EOK 0 /* no error */ #endif +#define CHECK_ERR_OK(rc) \ + EXPECT_EQ(0, (rc)); \ + if ((rc) < 0) { \ + ASSERT_EQ(EOK, errno); \ + } + #ifndef container_of /** * container_of - cast a member of a structure out to the containing structure diff --git a/tests/gtest/common/log.h b/tests/gtest/common/log.h index ead69d0bb8..cd9536ff07 100644 --- a/tests/gtest/common/log.h +++ b/tests/gtest/common/log.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TESTS_GTEST_COMMON_LOG_H_ @@ -37,9 +11,10 @@ extern struct gtest_configure_t gtest_conf; #define log_fatal(fmt, ...) \ do { \ - if (gtest_conf.log_level > 0) \ + if (gtest_conf.log_level > 0) { \ fprintf(stderr, "[ FATAL ] " fmt, ##__VA_ARGS__); \ - exit(1); \ + } \ + exit(1); \ } while (0) #define log_error(fmt, ...) \ diff --git a/tests/gtest/common/sys.cc b/tests/gtest/common/sys.cc index 6c2325a1cc..a42412bd92 100644 --- a/tests/gtest/common/sys.cc +++ b/tests/gtest/common/sys.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/common/sys.h b/tests/gtest/common/sys.h index c20dece54b..689e3193cf 100644 --- a/tests/gtest/common/sys.h +++ b/tests/gtest/common/sys.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TESTS_GTEST_COMMON_SYS_H_ diff --git a/tests/gtest/main.cc b/tests/gtest/main.cc index fcd4b8fe31..1f225bc614 100644 --- a/tests/gtest/main.cc +++ b/tests/gtest/main.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/gtest/mix/mix_base.cc b/tests/gtest/mix/mix_base.cc index 12ac679bbd..566e5dcaab 100644 --- a/tests/gtest/mix/mix_base.cc +++ b/tests/gtest/mix/mix_base.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/mix/mix_base.h b/tests/gtest/mix/mix_base.h index 7158070024..84acaf9d7a 100644 --- a/tests/gtest/mix/mix_base.h +++ b/tests/gtest/mix/mix_base.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TESTS_GTEST_MIX_BASE_H_ #define TESTS_GTEST_MIX_BASE_H_ diff --git a/tests/gtest/mix/mix_list.cc b/tests/gtest/mix/mix_list.cc index 8eac746aa1..b3523bf589 100644 --- a/tests/gtest/mix/mix_list.cc +++ b/tests/gtest/mix/mix_list.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" @@ -149,7 +123,8 @@ TEST_F(mix_list, ti_7) { list_add_tail(&element.item, &head); ASSERT_FALSE(list_empty(&head)); - ASSERT_TRUE(list_is_last(&element.item, &head)); + // Check if element.item is the last entry in the list (its next points to head) + ASSERT_TRUE(element.item.next == &head); } TEST_F(mix_list, ti_8) { diff --git a/tests/gtest/mix/sg_array.cc b/tests/gtest/mix/sg_array.cc index bc5b97baaf..8ff97d14c1 100644 --- a/tests/gtest/mix/sg_array.cc +++ b/tests/gtest/mix/sg_array.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/sock/sock_base.cc b/tests/gtest/sock/sock_base.cc index 031990f4c0..2587d2c24c 100644 --- a/tests/gtest/sock/sock_base.cc +++ b/tests/gtest/sock/sock_base.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/sock/sock_base.h b/tests/gtest/sock/sock_base.h index 736e1b0afd..9afd713100 100644 --- a/tests/gtest/sock/sock_base.h +++ b/tests/gtest/sock/sock_base.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TESTS_GTEST_SOCK_BASE_H_ diff --git a/tests/gtest/sock/sock_socket.cc b/tests/gtest/sock/sock_socket.cc index 4e1d6bef06..55b5f54a72 100644 --- a/tests/gtest/sock/sock_socket.cc +++ b/tests/gtest/sock/sock_socket.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/tcp/tcp_base.cc b/tests/gtest/tcp/tcp_base.cc index 5a76c0f71e..a61151d541 100644 --- a/tests/gtest/tcp/tcp_base.cc +++ b/tests/gtest/tcp/tcp_base.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/tcp/tcp_base.h b/tests/gtest/tcp/tcp_base.h index 2da455ec84..e28058519c 100644 --- a/tests/gtest/tcp/tcp_base.h +++ b/tests/gtest/tcp/tcp_base.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TESTS_GTEST_TCP_BASE_H_ diff --git a/tests/gtest/tcp/tcp_bind.cc b/tests/gtest/tcp/tcp_bind.cc index 9a83fb04e6..f251adce87 100644 --- a/tests/gtest/tcp/tcp_bind.cc +++ b/tests/gtest/tcp/tcp_bind.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/tcp/tcp_connect.cc b/tests/gtest/tcp/tcp_connect.cc index 2e91681c19..d37050e7bf 100644 --- a/tests/gtest/tcp/tcp_connect.cc +++ b/tests/gtest/tcp/tcp_connect.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/tcp/tcp_connect_nb.cc b/tests/gtest/tcp/tcp_connect_nb.cc index 2f54f0564f..bb7c923601 100644 --- a/tests/gtest/tcp/tcp_connect_nb.cc +++ b/tests/gtest/tcp/tcp_connect_nb.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/tcp/tcp_event.cc b/tests/gtest/tcp/tcp_event.cc index 00e4b559e0..10806fa4a8 100644 --- a/tests/gtest/tcp/tcp_event.cc +++ b/tests/gtest/tcp/tcp_event.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/tcp/tcp_send.cc b/tests/gtest/tcp/tcp_send.cc index b5e11f6d6f..2d4a3a99cc 100644 --- a/tests/gtest/tcp/tcp_send.cc +++ b/tests/gtest/tcp/tcp_send.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include #include "common/def.h" diff --git a/tests/gtest/tcp/tcp_send_zc.cc b/tests/gtest/tcp/tcp_send_zc.cc index 8cef13954f..0418971c3d 100644 --- a/tests/gtest/tcp/tcp_send_zc.cc +++ b/tests/gtest/tcp/tcp_send_zc.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/gtest/tcp/tcp_sendfile.cc b/tests/gtest/tcp/tcp_sendfile.cc index f73eb90fdb..af695343c2 100644 --- a/tests/gtest/tcp/tcp_sendfile.cc +++ b/tests/gtest/tcp/tcp_sendfile.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/gtest/tcp/tcp_sendto.cc b/tests/gtest/tcp/tcp_sendto.cc index 174b082a7c..66dffd4e3d 100644 --- a/tests/gtest/tcp/tcp_sendto.cc +++ b/tests/gtest/tcp/tcp_sendto.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/tcp/tcp_socket.cc b/tests/gtest/tcp/tcp_socket.cc index 678b987644..f2253da524 100644 --- a/tests/gtest/tcp/tcp_socket.cc +++ b/tests/gtest/tcp/tcp_socket.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/tcp/tcp_sockopt.cc b/tests/gtest/tcp/tcp_sockopt.cc new file mode 100644 index 0000000000..18a3c6af9f --- /dev/null +++ b/tests/gtest/tcp/tcp_sockopt.cc @@ -0,0 +1,337 @@ +/* + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2023-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "common/def.h" +extern struct gtest_configure_t gtest_conf; + +struct reusable_cleanable_test_socket { + int m_fd; + reusable_cleanable_test_socket(int domain, int type, int protocol) { + m_fd = socket(domain, type, protocol); + EXPECT_GE(m_fd, 0) << "Unable to open the socket"; + int reuse = 1; + auto result = + setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)); + EXPECT_EQ(result, 0) << "setsockopt failed to set reuse addr"; + + struct timeval tv; + tv.tv_sec = 5; + tv.tv_usec = 0; + setsockopt(m_fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + } + explicit reusable_cleanable_test_socket(int fd) : m_fd{fd} { + EXPECT_GE(m_fd, 0) << "Unable to open the socket"; + }; + ~reusable_cleanable_test_socket() { close(m_fd); } + + operator int() const { return m_fd; } +}; + +struct ipc { + enum FifoDirection : size_t { ReadSide, WriteSide }; + int m_pipe[2]; + ipc() : m_pipe{-1, -1} {} + + ~ipc() { reset(); } + void create() { + if (pipe(m_pipe) != 0) { + throw std::runtime_error("Pipe not created"); + } + } + void reset() { + if (m_pipe[ReadSide] != -1) { + close(m_pipe[ReadSide]); + } + if (m_pipe[WriteSide] != -1) { + close(m_pipe[WriteSide]); + } + } + bool wait_peer() { + if (m_pipe[ReadSide] == -1) { + return false; + } + + if (m_pipe[WriteSide] != -1) { + if (close(m_pipe[WriteSide]) != 0) { + return false; + } + m_pipe[WriteSide] = -1; + } + + char buffer[16]; + auto result = read(m_pipe[ReadSide], buffer, 1) == 1; + return result; + } + + bool signal_to_peer() { + if (m_pipe[WriteSide] == -1) { + return false; + } + + if (m_pipe[ReadSide] != -1) { + if (close(m_pipe[ReadSide]) != 0) { + return false; + } + m_pipe[ReadSide] = -1; + } + + return write(m_pipe[WriteSide], "X", 1) == 1; + } +}; + +using sockopt_parameters = std::tuple; +using tcp_sockopt_positive = testing::TestWithParam; +/* + * @test tcp_sockopt_positive.set_and_get_value + * @brief + * This is a parameterized test requiring sockopt_parameters. The parameters in the + * sockopt_parameters are the socket domain, setsockopt/getsockopt level, optname, + * and value. + * The test sets the value and checks the value with the setsockopt/getsockopt syscalls. + * @details + */ +TEST_P(tcp_sockopt_positive, set_and_get_value) { + int socket_domain, level, optname, value; + std::tie(socket_domain, level, optname, value) = GetParam(); + + auto fd = reusable_cleanable_test_socket(socket_domain, static_cast(SOCK_STREAM), 0); + EXPECT_GE(fd, 0) << "socket syscall failed"; + auto result = setsockopt(fd, level, optname, &value, sizeof(value)); + EXPECT_EQ(result, 0) << "setsockopt failed to set the value"; + + int actual_value = -1; + socklen_t actual_len = sizeof(actual_value); + result = getsockopt(fd, level, optname, &actual_value, &actual_len); + EXPECT_EQ(result, 0) << "getsockopt failed to get the value"; + EXPECT_EQ(actual_len, sizeof(actual_value)) + << "Got unexpected size of agument"; + ASSERT_EQ(actual_value, value); +} + +/* The valid ranges are dictated by the Linux Kernel and not the TCP RFC 9293 + * There may be multiple instantiations of the tcp_sockopt_positive class and + * it's test cases. + */ +INSTANTIATE_TEST_CASE_P( + keep_alive, tcp_sockopt_positive, + testing::Values(std::make_tuple(AF_INET, SOL_SOCKET, SO_KEEPALIVE, 1), + std::make_tuple(AF_INET, SOL_SOCKET, SO_KEEPALIVE, 0), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPIDLE, 1), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPIDLE, + std::numeric_limits::max()), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPINTVL, 1), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPINTVL, + std::numeric_limits::max()), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPCNT, 1), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPCNT, + std::numeric_limits::max()), + std::make_tuple(AF_INET6, SOL_SOCKET, SO_KEEPALIVE, 1), + std::make_tuple(AF_INET6, SOL_SOCKET, SO_KEEPALIVE, 0), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPIDLE, 1), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPIDLE, + std::numeric_limits::max()), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPINTVL, 1), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPINTVL, + std::numeric_limits::max()), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPCNT, 1), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPCNT, + std::numeric_limits::max()))); + +using tcp_setsockopt_negative = testing::TestWithParam; +/* + * @test tcp_setsockopt_negative.set_invalid_value + * @brief + * This is a parameterized test requiring sockopt_parameters. The parameters in the + * sockopt_parameters are the socket domain, setsockopt/getsockopt level, optname, + * and value. + * The test attempts setting an invalid value via setsockopt syscall. + * @details + */ +TEST_P(tcp_setsockopt_negative, set_invalid_value) { + int socket_domain, level, optname, value; + std::tie(socket_domain, level, optname, value) = GetParam(); + + auto fd = reusable_cleanable_test_socket(socket_domain, SOCK_STREAM, 0); + EXPECT_GE(fd, 0) << "socket syscall failed to setup a socket"; + + auto result = setsockopt(fd, level, optname, &value, sizeof(value)); + EXPECT_NE(result, 0) << "setsockopt didn't fail to set the value"; +} + +/* The valid ranges are dictated by the Linux Kernel and not the TCP RFC 9293 + * There may be multiple instantiations of the tcp_setsockopt_negative class and + * it's test cases. + */ +INSTANTIATE_TEST_CASE_P( + keep_alive, tcp_setsockopt_negative, + testing::Values(std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPIDLE, -1), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPIDLE, + std::numeric_limits::max() + 1), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPINTVL, -1), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPINTVL, 0), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPINTVL, + std::numeric_limits::max() + 1), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPCNT, -1), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPCNT, 0), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPCNT, + std::numeric_limits::max() + 1), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPIDLE, -1), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPIDLE, + std::numeric_limits::max() + 1), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPINTVL, -1), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPINTVL, 0), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPINTVL, + std::numeric_limits::max() + 1), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPCNT, -1), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPCNT, 0), + std::make_tuple(AF_INET6, IPPROTO_TCP, TCP_KEEPCNT, + std::numeric_limits::max() + 1))); + +using getscokopt_params = std::tuple; +using tcp_sockopt_default = testing::TestWithParam; +/* + * @test tcp_sockopt_default.matches_the_value_in_the_file + * @brief + * This is a parameterized test requiring sockopt_parameters. The parameters in the + * sockopt_parameters are the socket domain, setsockopt/getsockopt level, optname, + * and file path containing the default value. + * The test verifies that the default value of a newly creates socket match file. + * @details + */ +TEST_P(tcp_sockopt_default, matches_the_value_in_the_file) { + int socket_domain, level, optname; + const char *file_path; + std::tie(socket_domain, level, optname, file_path) = GetParam(); + + auto fd = reusable_cleanable_test_socket(socket_domain, SOCK_STREAM, 0); + EXPECT_GE(fd, 0) << "socket syscall failed to setup a socket"; + + /* Get the value via getsockopt */ + int getsockopt_value = -1; + socklen_t actual_len = sizeof(getsockopt_value); + auto result = + getsockopt(fd, level, optname, &getsockopt_value, &actual_len); + EXPECT_EQ(result, 0) << "getsockopt failed"; + EXPECT_EQ(actual_len, sizeof(getsockopt_value)) + << "Got unexpected size of agument"; + + /* Get the value from the file */ + int file_value = -1; + EXPECT_TRUE(bool(std::ifstream{file_path} >> file_value)) + << "Failed reading the file"; + + ASSERT_EQ(getsockopt_value, file_value) + << "The values in the file and the getsockopt differ"; + close(fd); +} + +INSTANTIATE_TEST_CASE_P( + keep_alive, tcp_sockopt_default, + testing::Values( + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPIDLE, + "/proc/sys/net/ipv4/tcp_keepalive_time"), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPINTVL, + "/proc/sys/net/ipv4/tcp_keepalive_intvl"), + std::make_tuple(AF_INET, IPPROTO_TCP, TCP_KEEPCNT, + "/proc/sys/net/ipv4/tcp_keepalive_probes"))); + +using setsockopt_param = std::tuple; +class tcp_with_fifo : public testing::TestWithParam { +protected: + ipc m_ipc_server_to_client{}; + + void SetUp() override { m_ipc_server_to_client.create(); } + + void TearDown() override { m_ipc_server_to_client.reset(); } +}; + +/* + * @test tcp_with_fifo.set_listen_get_accept_socket + * @brief + * This is a parameterized test requiring sockopt_parameters. The parameters in the + * sockopt_parameters are the socket domain, setsockopt level, optname, and value. + * The test verifies that the set value is inherited by the accepted socket. + * @details + */ +TEST_P(tcp_with_fifo, accepted_socket_inherits_the_setsockopt_param) { + int level, optname, value; + std::tie(level, optname, value) = GetParam(); + pid_t pid = fork(); + + if (pid > 0) { // Parent process (the "server" process) + + auto listen_fd = reusable_cleanable_test_socket( + gtest_conf.server_addr.sin_family, SOCK_STREAM, 0); + EXPECT_GE(listen_fd, 0) << "socket syscall failed to setup a socket"; + + EXPECT_EQ(bind(listen_fd, (struct sockaddr *)>est_conf.server_addr, + sizeof(gtest_conf.server_addr)), + 0); + EXPECT_EQ(listen(listen_fd, 5), 0); + + auto result = setsockopt(listen_fd, level, optname, &value, sizeof(value)); + EXPECT_EQ(result, 0) << "setsockopt failed to set the value"; + + m_ipc_server_to_client.signal_to_peer(); + + reusable_cleanable_test_socket accepted_fd{accept(listen_fd, nullptr, 0)}; + EXPECT_GE(accepted_fd, 0) << "Invalid accepted_fd"; + + int actual_value = -1; + socklen_t actual_len = sizeof(actual_value); + result = getsockopt(accepted_fd, level, optname, &actual_value, + &actual_len); + m_ipc_server_to_client.signal_to_peer(); + + int status; + EXPECT_EQ(pid, wait(&status)); + EXPECT_TRUE(WIFEXITED(status)); + EXPECT_EQ(result, 0) << "getsockopt failed to get the value"; + EXPECT_EQ(actual_len, sizeof(actual_value)) + << "Got unexpected size of agument"; + + ASSERT_EQ(actual_value, value); + } else if (pid == 0) { // Child process (the "client" process) + auto client_fd = reusable_cleanable_test_socket( + gtest_conf.client_addr.sin_family, SOCK_STREAM, 0); + EXPECT_GE(client_fd, 0) << "socket syscall failed to setup a socket"; + EXPECT_EQ(bind(client_fd, (struct sockaddr *)>est_conf.client_addr, + sizeof(gtest_conf.client_addr)), + 0); + m_ipc_server_to_client.wait_peer(); + + auto result = connect(client_fd, (struct sockaddr *)>est_conf.server_addr, + sizeof(gtest_conf.server_addr)); + EXPECT_EQ(result, 0); + + m_ipc_server_to_client.wait_peer(); + + // This exit stops the process from inerfering with other tests. + exit(testing::Test::HasFailure()); + } else { + FAIL() << "Fork failed"; + } +} + +INSTANTIATE_TEST_CASE_P( + keep_alive, tcp_with_fifo, + testing::Values( + std::make_tuple(SOL_SOCKET, SO_KEEPALIVE, 0), + std::make_tuple(SOL_SOCKET, SO_KEEPALIVE, 1), + std::make_tuple(static_cast(IPPROTO_TCP), TCP_KEEPIDLE, 1234), + std::make_tuple(static_cast(IPPROTO_TCP), TCP_KEEPINTVL, 12345), + std::make_tuple(static_cast(IPPROTO_TCP), TCP_KEEPCNT, 123))); diff --git a/tests/gtest/tcp/tcp_tls.cc b/tests/gtest/tcp/tcp_tls.cc index e35323681d..6b9a15f971 100644 --- a/tests/gtest/tcp/tcp_tls.cc +++ b/tests/gtest/tcp/tcp_tls.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/udp/udp_base.cc b/tests/gtest/udp/udp_base.cc index 6a0a6dc136..d06f359116 100644 --- a/tests/gtest/udp/udp_base.cc +++ b/tests/gtest/udp/udp_base.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/udp/udp_base.h b/tests/gtest/udp/udp_base.h index 7c09a60441..de990f5705 100644 --- a/tests/gtest/udp/udp_base.h +++ b/tests/gtest/udp/udp_base.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TESTS_GTEST_UDP_BASE_H_ diff --git a/tests/gtest/udp/udp_bind.cc b/tests/gtest/udp/udp_bind.cc index 99d6a7035e..467c2efb83 100644 --- a/tests/gtest/udp/udp_bind.cc +++ b/tests/gtest/udp/udp_bind.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/udp/udp_connect.cc b/tests/gtest/udp/udp_connect.cc index dbba81bb47..34bdc0f0e9 100644 --- a/tests/gtest/udp/udp_connect.cc +++ b/tests/gtest/udp/udp_connect.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/udp/udp_send.cc b/tests/gtest/udp/udp_send.cc index 77ac99f664..28208ac31e 100644 --- a/tests/gtest/udp/udp_send.cc +++ b/tests/gtest/udp/udp_send.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/gtest/udp/udp_sendto.cc b/tests/gtest/udp/udp_sendto.cc index 9721d74720..77844dcbfd 100644 --- a/tests/gtest/udp/udp_sendto.cc +++ b/tests/gtest/udp/udp_sendto.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/vma/vma_base.cc b/tests/gtest/vma/vma_base.cc index f081de21f8..bf4c87dc54 100644 --- a/tests/gtest/vma/vma_base.cc +++ b/tests/gtest/vma/vma_base.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/vma/vma_base.h b/tests/gtest/vma/vma_base.h index 15f76f2e5f..5c7332f076 100644 --- a/tests/gtest/vma/vma_base.h +++ b/tests/gtest/vma/vma_base.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TESTS_GTEST_VMA_BASE_H_ diff --git a/tests/gtest/vma/vma_ioctl.cc b/tests/gtest/vma/vma_ioctl.cc new file mode 100644 index 0000000000..998f7b9f08 --- /dev/null +++ b/tests/gtest/vma/vma_ioctl.cc @@ -0,0 +1,187 @@ +/* + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause + */ + +#include "common/def.h" +#include "common/log.h" +#include "common/sys.h" +#include "common/base.h" +#include "common/cmn.h" + +#include "tcp/tcp_base.h" + +#if defined(EXTRA_API_ENABLED) && (EXTRA_API_ENABLED == 1) + +#include "vma_base.h" + +class vma_ioctl : public vma_base { +protected: + void SetUp() { + uint64_t vma_extra_api_cap = VMA_EXTRA_API_IOCTL; + + vma_base::SetUp(); + + SKIP_TRUE((vma_api->vma_extra_supported_mask & vma_extra_api_cap) == vma_extra_api_cap, + "This test requires VMA capabilities as VMA_EXTRA_API_IOCTL"); + } + void TearDown() { + vma_base::TearDown(); + } +}; + +static size_t allocated_size = 0; +void *test_malloc(size_t size) { + allocated_size += size; + return malloc(size); +}; + +/** + * @test vma_ioctl.ti_1 + * @note + * Should be launched individually (it depends on library init ordering) + * @brief + * CMSG_XLIO_IOCTL_USER_ALLOC command message format check + * @details + */ +TEST_F(vma_ioctl, ti_1) { + int rc = EOK; + int fd; + vma_cmsg_ioctl_user_alloc_t data; + struct cmsghdr *cmsg; + char cbuf[CMSG_SPACE(sizeof(data))]; + + ASSERT_TRUE((sizeof(uint8_t) + sizeof(uintptr_t) + sizeof(uintptr_t)) == sizeof(data)); + + /* scenario #1: Wrong cmsg length */ + errno = EOK; + cmsg = (struct cmsghdr *)cbuf; + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = CMSG_VMA_IOCTL_USER_ALLOC; + cmsg->cmsg_len = CMSG_LEN(sizeof(data)) - 1; + data.flags = VMA_IOCTL_USER_ALLOC_FLAG_RX; + data.memalloc = malloc; + data.memfree = free; + memcpy(CMSG_DATA(cmsg), &data, sizeof(data)); + + rc = vma_api->ioctl(cmsg, cmsg->cmsg_len); + EXPECT_EQ(-1, rc); + EXPECT_TRUE(EINVAL == errno); + + /* scenario #2: invalid function pointer */ + errno = EOK; + cmsg = (struct cmsghdr *)cbuf; + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = CMSG_VMA_IOCTL_USER_ALLOC; + cmsg->cmsg_len = CMSG_LEN(sizeof(data)); + data.flags = VMA_IOCTL_USER_ALLOC_FLAG_RX; + data.memalloc = malloc; + data.memfree = NULL; + memcpy(CMSG_DATA(cmsg), &data, sizeof(data)); + + rc = vma_api->ioctl(cmsg, cmsg->cmsg_len); + EXPECT_EQ(-1, rc); + EXPECT_TRUE(EINVAL == errno); + + /* scenario #3: Check memory functions are activated */ + errno = EOK; + cmsg = (struct cmsghdr *)cbuf; + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = CMSG_VMA_IOCTL_USER_ALLOC; + cmsg->cmsg_len = CMSG_LEN(sizeof(data)); + data.flags = VMA_IOCTL_USER_ALLOC_FLAG_RX; + data.memalloc = &test_malloc; + data.memfree = free; + memcpy(CMSG_DATA(cmsg), &data, sizeof(data)); + + rc = vma_api->ioctl(cmsg, cmsg->cmsg_len); + EXPECT_EQ(0, rc); + + /* the library initialization trigger */ + allocated_size = 0; + fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); + ASSERT_LE(0, fd); + EXPECT_LT(1500, allocated_size); + + /* scenario #4: Command can not be used after initialization of internals */ + errno = EOK; + cmsg = (struct cmsghdr *)cbuf; + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = CMSG_VMA_IOCTL_USER_ALLOC; + cmsg->cmsg_len = CMSG_LEN(sizeof(data)); + data.flags = VMA_IOCTL_USER_ALLOC_FLAG_TX | VMA_IOCTL_USER_ALLOC_FLAG_RX; + data.memalloc = malloc; + data.memfree = free; + memcpy(CMSG_DATA(cmsg), &data, sizeof(data)); + + rc = vma_api->ioctl(cmsg, cmsg->cmsg_len); + EXPECT_EQ(-1, rc); + EXPECT_TRUE(EINVAL == errno); + + /* scenario #5: Successfull connection with customer memalloc */ + rc = EOK; + char send_buf[] = "test"; + char recv_buf[sizeof(send_buf)]; + + int pid = fork(); + + if (0 == pid) { /* I am the child */ + barrier_fork(pid); + + fd = tcp_base::sock_create(); + ASSERT_LE(0, fd); + + rc = bind(fd, (struct sockaddr *)&client_addr, sizeof(client_addr)); + ASSERT_EQ(0, rc); + + rc = connect(fd, (struct sockaddr *)&server_addr, sizeof(server_addr)); + ASSERT_EQ(0, rc); + + log_trace("Established connection: fd=%d to %s\n", + fd, sys_addr2str((struct sockaddr_in *)&server_addr)); + + rc = send(fd, send_buf, sizeof(send_buf), 0); + EXPECT_GE(rc, 0); + + close(fd); + + /* This exit is very important, otherwise the fork + * keeps running and may duplicate other tests. + */ + exit(testing::Test::HasFailure()); + } else { /* I am the parent */ + int fd_peer; + struct sockaddr peer_addr; + socklen_t socklen; + + fd_peer = tcp_base::sock_create(); + ASSERT_LE(0, fd_peer); + + rc = bind(fd_peer, (struct sockaddr *)&server_addr, sizeof(server_addr)); + ASSERT_EQ(0, rc); + + rc = listen(fd_peer, 5); + ASSERT_EQ(0, rc); + + barrier_fork(pid); + + socklen = sizeof(peer_addr); + fd = accept(fd_peer, &peer_addr, &socklen); + ASSERT_LE(0, fd); + + log_trace("Accepted connection: fd=%d from %s\n", + fd, sys_addr2str((struct sockaddr_in *)&peer_addr)); + + rc = recv(fd, (void *)recv_buf, sizeof(recv_buf), MSG_WAITALL); + EXPECT_GE(rc, 0); + EXPECT_EQ(memcmp(send_buf, recv_buf, sizeof(send_buf)), 0); + + close(fd_peer); + close(fd); + + ASSERT_EQ(0, wait_fork(pid)); + } +} + +#endif /* EXTRA_API_ENABLED */ diff --git a/tests/gtest/vma/vma_poll.cc b/tests/gtest/vma/vma_poll.cc index 7085acccaf..53dded88ed 100644 --- a/tests/gtest/vma/vma_poll.cc +++ b/tests/gtest/vma/vma_poll.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" @@ -80,7 +54,7 @@ TEST_F(vma_poll, ti_1) { ASSERT_LE(0, fd); rc = bind(fd, (struct sockaddr *)&client_addr, sizeof(client_addr)); - ASSERT_EQ(0, rc); + CHECK_ERR_OK(rc); rc = connect(fd, (struct sockaddr *)&server_addr, sizeof(server_addr)); ASSERT_EQ(EINPROGRESS, errno); @@ -111,11 +85,10 @@ TEST_F(vma_poll, ti_1) { ASSERT_LE(0, fd); rc = bind(fd, (struct sockaddr *)&server_addr, sizeof(server_addr)); - ASSERT_EQ(0, rc); + CHECK_ERR_OK(rc); rc = listen(fd, 5); - ASSERT_EQ(EOK, errno); - ASSERT_EQ(0, rc); + CHECK_ERR_OK(rc); rc = vma_api->get_socket_rings_fds(fd, &_vma_ring_fd, 1); ASSERT_EQ(1, rc); @@ -125,6 +98,9 @@ TEST_F(vma_poll, ti_1) { rc = 0; while (rc == 0 && !child_fork_exit()) { rc = vma_api->socketxtreme_poll(_vma_ring_fd, &vma_comps, 1, 0); + if (rc == 0) { + continue; + } if (vma_comps.events & VMA_SOCKETXTREME_NEW_CONNECTION_ACCEPTED) { EXPECT_EQ(fd, (int)vma_comps.listen_fd); fd_peer = (int)vma_comps.user_data; @@ -165,7 +141,7 @@ TEST_F(vma_poll, ti_2) { ASSERT_LE(0, fd); rc = bind(fd, (struct sockaddr *)&client_addr, sizeof(client_addr)); - ASSERT_EQ(0, rc); + CHECK_ERR_OK(rc); rc = connect(fd, (struct sockaddr *)&server_addr, sizeof(server_addr)); ASSERT_EQ(0, rc); @@ -192,11 +168,10 @@ TEST_F(vma_poll, ti_2) { ASSERT_LE(0, fd); rc = bind(fd, (struct sockaddr *)&server_addr, sizeof(server_addr)); - ASSERT_EQ(0, rc); + CHECK_ERR_OK(rc); rc = listen(fd, 5); - ASSERT_EQ(EOK, errno); - ASSERT_EQ(0, rc); + CHECK_ERR_OK(rc); rc = vma_api->get_socket_rings_fds(fd, &_vma_ring_fd, 1); ASSERT_EQ(1, rc); @@ -206,6 +181,9 @@ TEST_F(vma_poll, ti_2) { rc = 0; while (rc == 0 && !child_fork_exit()) { rc = vma_api->socketxtreme_poll(_vma_ring_fd, &vma_comps, 1, 0); + if (rc == 0) { + continue; + } if ((vma_comps.events & EPOLLERR) || (vma_comps.events & EPOLLHUP) || (vma_comps.events & EPOLLRDHUP)) { @@ -263,7 +241,7 @@ TEST_F(vma_poll, ti_3) { ASSERT_LE(0, fd); rc = bind(fd, (struct sockaddr *)&client_addr, sizeof(client_addr)); - ASSERT_EQ(0, rc); + CHECK_ERR_OK(rc); rc = connect(fd, (struct sockaddr *)&server_addr, sizeof(server_addr)); ASSERT_EQ(0, rc); @@ -291,11 +269,10 @@ TEST_F(vma_poll, ti_3) { ASSERT_LE(0, fd); rc = bind(fd, (struct sockaddr *)&server_addr, sizeof(server_addr)); - ASSERT_EQ(0, rc); + CHECK_ERR_OK(rc); rc = listen(fd, 5); - ASSERT_EQ(EOK, errno); - ASSERT_EQ(0, rc); + CHECK_ERR_OK(rc); rc = vma_api->get_socket_rings_fds(fd, &_vma_ring_fd, 1); ASSERT_EQ(1, rc); @@ -305,6 +282,9 @@ TEST_F(vma_poll, ti_3) { rc = 0; while (rc == 0 && !child_fork_exit()) { rc = vma_api->socketxtreme_poll(_vma_ring_fd, &vma_comps, 1, 0); + if (rc == 0) { + continue; + } if ((vma_comps.events & EPOLLERR) || (vma_comps.events & EPOLLHUP) || (vma_comps.events & EPOLLRDHUP)) { @@ -366,7 +346,7 @@ TEST_F(vma_poll, ti_4) { ASSERT_LE(0, fd); rc = bind(fd, (struct sockaddr *)&client_addr, sizeof(client_addr)); - ASSERT_EQ(0, rc); + CHECK_ERR_OK(rc); rc = sendto(fd, (void *)msg, sizeof(msg), 0, (struct sockaddr *)&server_addr, sizeof(server_addr)); @@ -387,7 +367,7 @@ TEST_F(vma_poll, ti_4) { ASSERT_LE(0, fd); rc = bind(fd, (struct sockaddr *)&server_addr, sizeof(server_addr)); - ASSERT_EQ(0, rc); + CHECK_ERR_OK(rc); rc = vma_api->get_socket_rings_fds(fd, &_vma_ring_fd, 1); ASSERT_EQ(1, rc); @@ -397,6 +377,9 @@ TEST_F(vma_poll, ti_4) { rc = 0; while (rc == 0 && !child_fork_exit()) { rc = vma_api->socketxtreme_poll(_vma_ring_fd, &vma_comps, 1, 0); + if (rc == 0) { + continue; + } if ((vma_comps.events & EPOLLERR) || (vma_comps.events & EPOLLHUP) || (vma_comps.events & EPOLLRDHUP)) { diff --git a/tests/gtest/vma/vma_recvfrom_zcopy.cc b/tests/gtest/vma/vma_recvfrom_zcopy.cc index 9881e4aef1..2c9ebff738 100644 --- a/tests/gtest/vma/vma_recvfrom_zcopy.cc +++ b/tests/gtest/vma/vma_recvfrom_zcopy.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/vma/vma_ring.cc b/tests/gtest/vma/vma_ring.cc index ddd34f8ee7..6e58e7f7d5 100644 --- a/tests/gtest/vma/vma_ring.cc +++ b/tests/gtest/vma/vma_ring.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/vma/vma_sockopt.cc b/tests/gtest/vma/vma_sockopt.cc index 7941d7ea00..edec824f55 100644 --- a/tests/gtest/vma/vma_sockopt.cc +++ b/tests/gtest/vma/vma_sockopt.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/vmad/vmad_base.cc b/tests/gtest/vmad/vmad_base.cc index 195757a1ab..bbbdf538cb 100644 --- a/tests/gtest/vmad/vmad_base.cc +++ b/tests/gtest/vmad/vmad_base.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/vmad/vmad_base.h b/tests/gtest/vmad/vmad_base.h index e7de1caadc..1770f6e1f4 100644 --- a/tests/gtest/vmad/vmad_base.h +++ b/tests/gtest/vmad/vmad_base.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TESTS_GTEST_VMAD_BASE_H_ diff --git a/tests/gtest/vmad/vmad_bitmap.cc b/tests/gtest/vmad/vmad_bitmap.cc index b70536110e..8561e29710 100644 --- a/tests/gtest/vmad/vmad_bitmap.cc +++ b/tests/gtest/vmad/vmad_bitmap.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/vmad/vmad_flow.cc b/tests/gtest/vmad/vmad_flow.cc index ad38645a5e..d0106bf8c9 100644 --- a/tests/gtest/vmad/vmad_flow.cc +++ b/tests/gtest/vmad/vmad_flow.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/vmad/vmad_hash.cc b/tests/gtest/vmad/vmad_hash.cc index 1a04fdaa74..68ed54dc19 100644 --- a/tests/gtest/vmad/vmad_hash.cc +++ b/tests/gtest/vmad/vmad_hash.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/vmad/vmad_init.cc b/tests/gtest/vmad/vmad_init.cc index 0a8cf68199..16b10d2fb3 100644 --- a/tests/gtest/vmad/vmad_init.cc +++ b/tests/gtest/vmad/vmad_init.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/gtest/vmad/vmad_state.cc b/tests/gtest/vmad/vmad_state.cc index 6f055b94ff..bc35a0794b 100644 --- a/tests/gtest/vmad/vmad_state.cc +++ b/tests/gtest/vmad/vmad_state.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include "common/def.h" diff --git a/tests/latency_test/tcp_lat.cpp b/tests/latency_test/tcp_lat.cpp index 8d64e077ab..e9403cbf33 100644 --- a/tests/latency_test/tcp_lat.cpp +++ b/tests/latency_test/tcp_lat.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/latency_test/udp_lat.c b/tests/latency_test/udp_lat.c index 8382c9bfe0..4d57c3893f 100644 --- a/tests/latency_test/udp_lat.c +++ b/tests/latency_test/udp_lat.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/listen/tcp_client.py b/tests/listen/tcp_client.py index 4d43bb5d0f..6d8ab0c467 100755 --- a/tests/listen/tcp_client.py +++ b/tests/listen/tcp_client.py @@ -1,34 +1,8 @@ #!/usr/bin/python # -# Copyright (c) 2015-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2015-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # import sys diff --git a/tests/listen/tcp_server.py b/tests/listen/tcp_server.py index f5a55f3c39..ad88957bc1 100755 --- a/tests/listen/tcp_server.py +++ b/tests/listen/tcp_server.py @@ -1,34 +1,8 @@ #!/usr/bin/python # -# Copyright (c) 2015-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2015-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # from socket import * diff --git a/tests/low_pps_tcp_send_test/exchange.cpp b/tests/low_pps_tcp_send_test/exchange.cpp index a6e53a0f43..8d7557cd1d 100755 --- a/tests/low_pps_tcp_send_test/exchange.cpp +++ b/tests/low_pps_tcp_send_test/exchange.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ /* diff --git a/tests/low_pps_tcp_send_test/trader.cpp b/tests/low_pps_tcp_send_test/trader.cpp index 467a61b1b5..e4968c07bf 100755 --- a/tests/low_pps_tcp_send_test/trader.cpp +++ b/tests/low_pps_tcp_send_test/trader.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ /* diff --git a/tests/mc_loop_test/mc_loop_test.c b/tests/mc_loop_test/mc_loop_test.c index 3eace97e46..e0d25f38d8 100644 --- a/tests/mc_loop_test/mc_loop_test.c +++ b/tests/mc_loop_test/mc_loop_test.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/multithread_test/exchange.cpp b/tests/multithread_test/exchange.cpp index 0c8ab6050e..f76c42a952 100755 --- a/tests/multithread_test/exchange.cpp +++ b/tests/multithread_test/exchange.cpp @@ -1,33 +1,7 @@ /* - * Copyright © 2013-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ /* diff --git a/tests/multithread_test/trader.cpp b/tests/multithread_test/trader.cpp index 7e73e1c488..20ebcd34a3 100755 --- a/tests/multithread_test/trader.cpp +++ b/tests/multithread_test/trader.cpp @@ -1,33 +1,7 @@ /* - * Copyright © 2013-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2013-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ /* diff --git a/tests/pps_test/pps_test.c b/tests/pps_test/pps_test.c index a695949030..7f7815f2f8 100644 --- a/tests/pps_test/pps_test.c +++ b/tests/pps_test/pps_test.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/resource_release_checker/server_socket_receive_and_recreate_loop.py b/tests/resource_release_checker/server_socket_receive_and_recreate_loop.py index 54c61744db..aa6814cccc 100755 --- a/tests/resource_release_checker/server_socket_receive_and_recreate_loop.py +++ b/tests/resource_release_checker/server_socket_receive_and_recreate_loop.py @@ -1,37 +1,10 @@ #!/usr/bin/env python # +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # #@copyright: -# Copyright (c) 2016-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# #@author: Alex Rosenbaum #@date: 20160520 diff --git a/tests/resource_release_checker/server_socket_recreate_loop.py b/tests/resource_release_checker/server_socket_recreate_loop.py index dae2fbce4e..dac8967d58 100755 --- a/tests/resource_release_checker/server_socket_recreate_loop.py +++ b/tests/resource_release_checker/server_socket_recreate_loop.py @@ -1,37 +1,10 @@ #!/usr/bin/env python # +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2015-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # #@copyright: -# Copyright (c) 2016-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# #@author: Alex Rosenbaum #@date: 20160520 diff --git a/tests/reuse_ud_test.c b/tests/reuse_ud_test.c index 31abdad541..b6b0fd92b3 100644 --- a/tests/reuse_ud_test.c +++ b/tests/reuse_ud_test.c @@ -1,33 +1,7 @@ /* - * Copyright © 2013-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/select_t1.c b/tests/select_t1.c index 46ed9eda34..5858e3fe5e 100644 --- a/tests/select_t1.c +++ b/tests/select_t1.c @@ -1,33 +1,7 @@ /* - * Copyright © 2013-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/server_test/client.cc b/tests/server_test/client.cc index 5d7b8e1fde..bd63fa2950 100644 --- a/tests/server_test/client.cc +++ b/tests/server_test/client.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/server_test/client.h b/tests/server_test/client.h index 6c9aa65d33..c81ca8816d 100644 --- a/tests/server_test/client.h +++ b/tests/server_test/client.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/server_test/main.cc b/tests/server_test/main.cc index ce8e640e4d..fa2763cad1 100644 --- a/tests/server_test/main.cc +++ b/tests/server_test/main.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/server_test/options.cc b/tests/server_test/options.cc index 5a39e1d576..4d6181bd84 100644 --- a/tests/server_test/options.cc +++ b/tests/server_test/options.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/server_test/options.h b/tests/server_test/options.h index bca456a415..104249433d 100644 --- a/tests/server_test/options.h +++ b/tests/server_test/options.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/server_test/server.cc b/tests/server_test/server.cc index 18217db7be..a3b4efb4f8 100644 --- a/tests/server_test/server.cc +++ b/tests/server_test/server.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/server_test/server.h b/tests/server_test/server.h index 542dda6497..593c87581f 100644 --- a/tests/server_test/server.h +++ b/tests/server_test/server.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/server_test/vtime.cc b/tests/server_test/vtime.cc index 9470514c51..52b6f844cf 100644 --- a/tests/server_test/vtime.cc +++ b/tests/server_test/vtime.cc @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/server_test/vtime.h b/tests/server_test/vtime.h index a83f2a2a94..8710efc1ff 100644 --- a/tests/server_test/vtime.h +++ b/tests/server_test/vtime.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/simple_fork/fork.py b/tests/simple_fork/fork.py index 686bf0a9e8..305c883ccd 100755 --- a/tests/simple_fork/fork.py +++ b/tests/simple_fork/fork.py @@ -1,34 +1,8 @@ #!/usr/bin/python # -# Copyright (c) 2015-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2015-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # diff --git a/tests/tcp_window_size_exerciser/Makefile b/tests/tcp_window_size_exerciser/Makefile index 7298771eb6..2789ab7b72 100644 --- a/tests/tcp_window_size_exerciser/Makefile +++ b/tests/tcp_window_size_exerciser/Makefile @@ -1,5 +1,7 @@ # -# Copyright © 2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-3-Clause # # This software is available to you under a choice of one of two # licenses. You may choose to be licensed under the terms of the GNU diff --git a/tests/tcp_window_size_exerciser/tcp_wnd_test.h b/tests/tcp_window_size_exerciser/tcp_wnd_test.h index 17eeb5b8f0..e39d5a699c 100644 --- a/tests/tcp_window_size_exerciser/tcp_wnd_test.h +++ b/tests/tcp_window_size_exerciser/tcp_wnd_test.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/tcp_window_size_exerciser/tcp_wnd_test_client.c b/tests/tcp_window_size_exerciser/tcp_wnd_test_client.c index bf18c543b2..d45c50e3d2 100644 --- a/tests/tcp_window_size_exerciser/tcp_wnd_test_client.c +++ b/tests/tcp_window_size_exerciser/tcp_wnd_test_client.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/tcp_window_size_exerciser/tcp_wnd_test_server.c b/tests/tcp_window_size_exerciser/tcp_wnd_test_server.c index 7934283d36..191ce886a7 100644 --- a/tests/tcp_window_size_exerciser/tcp_wnd_test_server.c +++ b/tests/tcp_window_size_exerciser/tcp_wnd_test_server.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/testbed/testbed.c b/tests/testbed/testbed.c index d0bfc2d35b..bce6f98ef5 100644 --- a/tests/testbed/testbed.c +++ b/tests/testbed/testbed.c @@ -1,33 +1,7 @@ /* - * Copyright © 2016-2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ /* diff --git a/tests/throughput_test/bandwidth_test.c b/tests/throughput_test/bandwidth_test.c index 1b6e742223..2a044ef448 100644 --- a/tests/throughput_test/bandwidth_test.c +++ b/tests/throughput_test/bandwidth_test.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tests/timetest/timetest.cpp b/tests/timetest/timetest.cpp index fe84c8421e..c81c85ef5a 100644 --- a/tests/timetest/timetest.cpp +++ b/tests/timetest/timetest.cpp @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2014-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #include diff --git a/tests/vma_perf_envelope/vma_multiplexers_test.sh b/tests/vma_perf_envelope/vma_multiplexers_test.sh index 54cda5d230..ff6ab93578 100755 --- a/tests/vma_perf_envelope/vma_multiplexers_test.sh +++ b/tests/vma_perf_envelope/vma_multiplexers_test.sh @@ -1,34 +1,9 @@ #!/bin/bash # -# Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2013-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. #configurable parameters #--------------------------------------------------- diff --git a/tests/vma_perf_envelope/vma_perf_envelope.sh b/tests/vma_perf_envelope/vma_perf_envelope.sh index b85aab1fdc..c972d1fa8c 100755 --- a/tests/vma_perf_envelope/vma_perf_envelope.sh +++ b/tests/vma_perf_envelope/vma_perf_envelope.sh @@ -1,34 +1,9 @@ #!/bin/bash # -# Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2013-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause # -# This software is available to you under a choice of one of two -# licenses. You may choose to be licensed under the terms of the GNU -# General Public License (GPL) Version 2, available from the file -# COPYING in the main directory of this source tree, or the -# BSD license below: -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. #configurable parameters #--------------------------------------------------- diff --git a/tools/daemon/bitmap.h b/tools/daemon/bitmap.h index e415bccbc3..10b7954179 100644 --- a/tools/daemon/bitmap.h +++ b/tools/daemon/bitmap.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tools/daemon/daemon.c b/tools/daemon/daemon.c index c6f021e1f4..e411aa3cec 100644 --- a/tools/daemon/daemon.c +++ b/tools/daemon/daemon.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -413,7 +387,7 @@ ssize_t sys_sendto(int sockfd, const struct sockaddr *dest_addr, socklen_t addrlen) { char *data = (char *)buf; - int n, nb; + ssize_t n, nb; nb = 0; do { @@ -431,7 +405,7 @@ ssize_t sys_sendto(int sockfd, data += n; nb += n; } while (!(flags & MSG_DONTWAIT) && (len > 0)); - + // coverity[return_overflow:FALSE] /* Turn off coverity check for overflow */ return nb; } diff --git a/tools/daemon/daemon.h b/tools/daemon/daemon.h index 407a1d7188..820ff4cbb0 100644 --- a/tools/daemon/daemon.h +++ b/tools/daemon/daemon.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TOOLS_DAEMON_DAEMON_H_ diff --git a/tools/daemon/flow.c b/tools/daemon/flow.c index 3ae41d3334..a43d5539f6 100644 --- a/tools/daemon/flow.c +++ b/tools/daemon/flow.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -219,6 +193,8 @@ int add_flow(struct store_pid *pid_value, struct store_flow *value) */ cur_head = &cur_element->list; list_for_each(cur_entry, cur_head) { + /* coverity[leaked_storage:FALSE] */ + /* coverity[overwrite_var:FALSE] */ cur_element = list_entry(cur_entry, struct flow_element, item); if (cur_element->value[0] == (uint32_t)value->type && cur_element->value[1] == ip) { @@ -228,6 +204,8 @@ int add_flow(struct store_pid *pid_value, struct store_flow *value) } } if (cur_entry == cur_head) { + /* coverity[leaked_storage:FALSE] */ + /* coverity[overwrite_var:FALSE] */ cur_element = (void *)calloc(1, sizeof(*cur_element)); if (NULL == cur_element) { rc = -ENOMEM; @@ -275,12 +253,16 @@ int add_flow(struct store_pid *pid_value, struct store_flow *value) goto err; } list_for_each(cur_entry, cur_head) { + /* coverity[leaked_storage:FALSE] */ + /* coverity[overwrite_var:FALSE] */ cur_element = list_entry(cur_entry, struct flow_element, item); if ((int)cur_element->value[0] == bkt) { break; } } if (cur_entry == cur_head) { + /* coverity[leaked_storage:FALSE] */ + /* coverity[overwrite_var:FALSE] */ cur_element = (void *)calloc(1, sizeof(*cur_element)); if (NULL == cur_element) { rc = -ENOMEM; @@ -356,11 +338,11 @@ int add_flow(struct store_pid *pid_value, struct store_flow *value) free_pending_list(pid, ctx, value->if_id); err: - + // coverity[overflow_const:FALSE] /* Turn off coverity check for overflow */ value->handle = HANDLE_SET(ht, bkt, id); log_debug("[%d] add flow filter: %x:%x:%x rc=%d\n", pid, ht, bkt, id, rc); - + /* coverity[leaked_storage] */ return rc; } @@ -656,7 +638,6 @@ static inline void free_pending_list(pid_t pid, struct flow_ctx *ctx, int if_ind } } } - static inline void add_pending_list(pid_t pid, struct flow_ctx *ctx, int if_index, int ht_id, int prio, int *rc) { struct htid_node_t *htid_node = (void *)calloc(1, sizeof(struct htid_node_t)); @@ -668,11 +649,11 @@ static inline void add_pending_list(pid_t pid, struct flow_ctx *ctx, int if_inde INIT_LIST_HEAD(&htid_node->node); htid_node->htid = ht_id; htid_node->prio = prio; - list_add(&htid_node->node, &ctx->pending_list); log_debug("[%d] del flow request was added to the pending list: if %d htid %d prio %d\n", pid, if_index, ht_id, prio); + /* coverity[leaked_storage:FALSE] */ } static inline void free_htid(struct flow_ctx *ctx, int ht_id) diff --git a/tools/daemon/hash.c b/tools/daemon/hash.c index b4051c26e6..2655fd0828 100644 --- a/tools/daemon/hash.c +++ b/tools/daemon/hash.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -116,7 +90,6 @@ void hash_destroy(hash_t ht) ht->hash_table = NULL; } free(ht); - ht = NULL; } } diff --git a/tools/daemon/hash.h b/tools/daemon/hash.h index 67d1cec7d2..d92096c409 100644 --- a/tools/daemon/hash.h +++ b/tools/daemon/hash.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TOOLS_DAEMON_HASH_H_ diff --git a/tools/daemon/loop.c b/tools/daemon/loop.c index b1d63e46a7..4f2beb83c0 100644 --- a/tools/daemon/loop.c +++ b/tools/daemon/loop.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -96,7 +70,7 @@ int proc_loop(void) while ((0 == daemon_cfg.sig) && (errno != EINTR)) { fd_set readfds; struct timeval tv; - int max_fd = -1; + int max_fd; FD_ZERO(&readfds); FD_SET(daemon_cfg.sock_fd, &readfds); diff --git a/tools/daemon/message.c b/tools/daemon/message.c index 56ea577e4b..e0e7edcad1 100644 --- a/tools/daemon/message.c +++ b/tools/daemon/message.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -513,10 +487,11 @@ static int proc_msg_flow(struct vma_hdr *msg_hdr, size_t size, struct sockaddr_u strerror(errno)); } } - + /* coverity[leaked_storage : FALSE] */ if (value && !value_new) { free(value); } - + + /* coverity[leaked_storage : FALSE] */ return (rc ? rc : (int)sizeof(*data)); } diff --git a/tools/daemon/nl.c b/tools/daemon/nl.c index 03abf8da14..aec83cd8fe 100644 --- a/tools/daemon/nl.c +++ b/tools/daemon/nl.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -56,7 +30,7 @@ struct nl_object { nl_t nl_create(void) { nl_t nt = NULL; - int fd = -1; + int fd; nt = (struct nl_object *)malloc(sizeof(*nt)); if (nt) { @@ -98,7 +72,6 @@ nl_t nl_create(void) if (nt) { free(nt); } - nt = NULL; return NULL; } @@ -108,7 +81,6 @@ void nl_destroy(nl_t nt) if (nt) { close(nt->fd); free(nt); - nt = NULL; } } @@ -117,7 +89,7 @@ int nl_send(nl_t nt, struct nlmsghdr *nl_msg) struct sockaddr_nl nladdr; struct iovec iov; struct msghdr msg; - int ret = -1; + int ret; nl_msg->nlmsg_seq = nt->seq++; diff --git a/tools/daemon/nl.h b/tools/daemon/nl.h index 9eb4367c35..0d1f4f5f04 100644 --- a/tools/daemon/nl.h +++ b/tools/daemon/nl.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TOOLS_DAEMON_NL_H_ diff --git a/tools/daemon/notify.c b/tools/daemon/notify.c index 9ce97404bc..1bd3a90d71 100644 --- a/tools/daemon/notify.c +++ b/tools/daemon/notify.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -200,7 +174,7 @@ int proc_notify(void) static int setup_notify(void) { - int fd = -1; + int fd; /* Set method for processing * fanotify has the highest priority because it has better @@ -705,6 +679,7 @@ static int proc_fanotify(void *buffer, int nbyte) } /* Close the file descriptor of the event */ + // coverity[double_close:FALSE] /* Turn off coverity check */ close(data->fd); data = FAN_EVENT_NEXT(data, len); } diff --git a/tools/daemon/store.c b/tools/daemon/store.c index 5ac5efa4e9..ffe83e4f26 100644 --- a/tools/daemon/store.c +++ b/tools/daemon/store.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ diff --git a/tools/daemon/tc.c b/tools/daemon/tc.c index ad8b077b8c..d64b5822cb 100644 --- a/tools/daemon/tc.c +++ b/tools/daemon/tc.c @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ @@ -86,7 +60,6 @@ tc_t tc_create(void) return tc; err: free(tc); - tc = NULL; return NULL; } @@ -96,7 +69,6 @@ void tc_destroy(tc_t tc) if (tc) { nl_destroy(tc->nl); free(tc); - tc = NULL; } } diff --git a/tools/daemon/tc.h b/tools/daemon/tc.h index 94ee854697..3350b1fa45 100644 --- a/tools/daemon/tc.h +++ b/tools/daemon/tc.h @@ -1,33 +1,7 @@ /* - * Copyright (c) 2001-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2001-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause */ #ifndef TOOLS_DAEMON_TC_H_