diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..6843818d6e --- /dev/null +++ b/.clang-format @@ -0,0 +1,107 @@ +--- +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: false +BinPackParameters: false +BitFieldColonSpacing: After +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakStringLiterals: true +ColumnLimit: 200 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^' + Priority: 1 + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 1 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Right +ReflowComments: true +SortIncludes: false +SortUsingDeclarations: false +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +TabWidth: 2 +UseTab: Never +... + diff --git a/NOTICE.md b/NOTICE.md index 39dd33795d..b92941540d 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -21,7 +21,6 @@ The Regents of the University of California: BSD 3-Clause Licence. Niels Provos : BSD 2-Clause Licence. -## Credits for source code openair3/GTPV1-U/nw-gtpv1u: ## - -Amit Chawre : BSD 2-Clause Licence. +## Credits for source code openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c and nrLDPC_offload.h: ## +Intel Corporation SPDX-License-Identifier: BSD-3-Clause Licence diff --git a/ci-scripts/Jenkinsfile-GitLab-Container b/ci-scripts/Jenkinsfile-GitLab-Container index 7c872e7b22..c8fb565488 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Container +++ b/ci-scripts/Jenkinsfile-GitLab-Container @@ -136,16 +136,16 @@ pipeline { } } } - stage ("RHEL8 Build") { + stage ("RHEL8-Cluster-Image-Builder") { steps { script { - triggerSlaveJob ('RAN-RHEL8-Image-Builder', 'RHEL8-Images-Build') + triggerSlaveJob ('RAN-RHEL8-Cluster-Image-Builder', 'RHEL8-Cluster-Image-Builder') } } post { always { script { - finalizeSlaveJob('RAN-RHEL8-Image-Builder') + finalizeSlaveJob('RAN-RHEL8-Cluster-Image-Builder') } } failure { @@ -338,6 +338,27 @@ pipeline { } } } + //avra is offline, re-enable once it is available + //stage ("Test T1 Offload") { + // when { expression {doMandatoryTests} } + // steps { + // script { + // triggerSlaveJob ('RAN-T1-Offload-Test', 'Test-T1-Offload') + // } + // } + // post { + // always { + // script { + // finalizeSlaveJob('RAN-T1-Offload-Test') + // } + // } + // failure { + // script { + // currentBuild.result = 'FAILURE' + // } + // } + // } + //} } } stage ("Images Push to Registries") { diff --git a/ci-scripts/Jenkinsfile-cluster b/ci-scripts/Jenkinsfile-cluster new file mode 100644 index 0000000000..e3f7da6141 --- /dev/null +++ b/ci-scripts/Jenkinsfile-cluster @@ -0,0 +1,254 @@ +#!/bin/groovy +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +// Location of the executor node +def pythonExecutor = params.pythonExecutor + +// Location of the test XML file to be run +def testXMLFile = params.pythonTestXmlFile +def mainPythonAllXmlFiles = "" +def buildStageStatus = true + +// Name of the test stage +def testStageName = params.pipelineTestStageName + +// Name of the resource +def lockResources = [] +if (params.LockResources != null && params.LockResources.trim().length() > 0) + params.LockResources.trim().split(",").each{lockResources += [resource: it.trim()]} + +// Global Parameters. Normally they should be populated when the master job +// triggers the slave job with parameters +def eNB_Repository +def eNB_Branch +def eNB_CommitID +def eNB_AllowMergeRequestProcess = false +def eNB_TargetBranch + +def directoryExistsGlob(fileNameWithGlob) { + /* if multiple directories match, will join their names and call fileExists() on that */ + def dir = sh returnStdout: true, script: 'find . -name \'' + fileNameWithGlob + '\' -type d' + dir = dir.replaceAll("\n", "").trim() + echo "matching '" + fileNameWithGlob + "' found: '" + dir + "'" + if (dir == "") + return false + return fileExists(dir) +} + +//------------------------------------------------------------------------------- +// Pipeline start +pipeline { + agent { + label pythonExecutor + } + options { + disableConcurrentBuilds() + timestamps() + ansiColor('xterm') + lock(extra: lockResources) + } + + stages { + stage ('Verify Parameters') { + steps { + script { + echo '\u2705 \u001B[32mVerify Parameters\u001B[0m' + + JOB_TIMESTAMP = sh returnStdout: true, script: 'date --utc --rfc-3339=seconds | sed -e "s#+00:00##"' + JOB_TIMESTAMP = JOB_TIMESTAMP.trim() + + def allParametersPresent = true + + // It is already to late to check it + if (params.pythonExecutor != null) { + echo "eNB CI executor node : ${pythonExecutor}" + } + // If not present picking a default Stage Name + if (params.pipelineTestStageName == null) { + // picking default + testStageName = 'Template Test Stage' + } + + if (params.LockResources == null) { + echo "no LockResources given" + allParametersPresent = false + } + if (params.eNB_IPAddress == null) { + echo "no eNB_IPAddress given" + allParametersPresent = false + } + if (params.eNB_SourceCodePath == null) { + echo "no eNB_SourceCodePath given" + allParametersPresent = false + } + if (params.eNB_Credentials == null) { + echo "no eNB_Credentials given" + allParametersPresent = false + } + // the following 4 parameters should be pushed by the master trigger + // if not present, take the job GIT variables (used for developing) + if (params.eNB_Repository == null) { + eNB_Repository = env.GIT_URL + } else { + eNB_Repository = params.eNB_Repository + } + echo "eNB_Repository : ${eNB_Repository}" + if (params.eNB_Branch == null) { + eNB_Branch = env.GIT_BRANCH + } else { + eNB_Branch = params.eNB_Branch + } + echo "eNB_Branch : ${eNB_Branch}" + if (params.eNB_CommitID == null) { + eNB_CommitID = env.GIT_COMMIT + } else { + eNB_CommitID = params.eNB_CommitID + } + echo "eNB_CommitID : ${eNB_CommitID}" + if (params.eNB_mergeRequest != null) { + eNB_AllowMergeRequestProcess = params.eNB_mergeRequest + if (eNB_AllowMergeRequestProcess) { + if (params.eNB_TargetBranch != null) { + eNB_TargetBranch = params.eNB_TargetBranch + } else { + eNB_TargetBranch = 'develop' + } + echo "eNB_TargetBranch : ${eNB_TargetBranch}" + } + } else { + echo "no eNB_mergeRequest given - not merging develop" + } + + if (params.EPC_IPAddress == null) { + echo "no EPC_IPAddress given" + allParametersPresent = false + } + if (params.EPC_Type == null) { + echo "no EPC_Type given" + allParametersPresent = false + } + if (params.EPC_SourceCodePath == null) { + echo "no EPC_SourceCodePath given" + allParametersPresent = false + } + if (params.EPC_Credentials == null) { + echo "no EPC_Credentials given" + allParametersPresent = false + } + + if (params.ADB_IPAddress == null) { + echo "no ADB_IPAddress given" + allParametersPresent = false + } + if (params.ADB_Credentials == null) { + echo "no ADB_IPAddress given" + allParametersPresent = false + } + if (params.OC_Credentials == null) { + echo "no OC_Credentials given" + allParametersPresent = false + } + if (params.OC_ProjectName == null) { + echo "no OC_ProjectName given" + allParametersPresent = false + } + if (params.pythonTestXmlFile == null) { + echo "no pythonTestXmlFile given" + allParametersPresent = false + } + if (allParametersPresent) { + echo "All parameters are present" + if (eNB_AllowMergeRequestProcess) { + sh "git fetch" + sh "./ci-scripts/doGitLabMerge.sh --src-branch ${eNB_Branch} --src-commit ${eNB_CommitID} --target-branch ${eNB_TargetBranch} --target-commit latest" + } else { + sh "git fetch" + sh "git checkout -f ${eNB_CommitID}" + } + } else { + echo "Some parameters are missing" + sh "./ci-scripts/fail.sh" + } + } + } + } + + stage ("Deploy and Test") { + steps { + script { + dir ('ci-scripts') { + echo "\u2705 \u001B[32m${testStageName}\u001B[0m" + String[] myXmlTestSuite = testXMLFile.split("\\r?\\n") + for (xmlFile in myXmlTestSuite) { + if (fileExists(xmlFile)) { + mainPythonAllXmlFiles += "--XMLTestFile=" + xmlFile + " " + echo "Test XML file : ${xmlFile}" + } + } + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password'], + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'], + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.ADB_Credentials}", usernameVariable: 'ADB_Username', passwordVariable: 'ADB_Password'], + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.OC_Credentials}", usernameVariable: 'OC_Username', passwordVariable: 'OC_Password'] + ]) { + sh "python3 main.py --mode=InitiateHtml --ranRepository=${eNB_Repository} --ranBranch=${eNB_Branch} --ranCommitID=${eNB_CommitID} --ranAllowMerge=${eNB_AllowMergeRequestProcess} --ranTargetBranch=${eNB_TargetBranch} --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password} ${mainPythonAllXmlFiles}" + for (xmlFile in myXmlTestSuite) { + if (fileExists(xmlFile)) { + try { + sh "python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --ranRepository=${eNB_Repository} --ranBranch=${eNB_Branch} --ranCommitID=${eNB_CommitID} --ranAllowMerge=${eNB_AllowMergeRequestProcess} --ranTargetBranch=${eNB_TargetBranch} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath} --EPCIPAddress=${params.EPC_IPAddress} --EPCType=${params.EPC_Type} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password} --XMLTestFile=${xmlFile} --OCUserName=${OC_Username} --OCPassword=${OC_Password} --OCProjectName=${OC_ProjectName}" + } catch (Exception e) { + currentBuild.result = 'FAILURE' + buildStageStatus = false + } + } + } + sh "python3 main.py --mode=FinalizeHtml --finalStatus=${buildStageStatus} --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password}" + } + } + } + } + } + stage ("Log Collection") { + steps { + script { + dir ('ci-scripts') { + if (directoryExistsGlob("build_log_*")) { + sh "zip -r -qq build_log_${env.BUILD_ID}.zip build_log_*/*" + sh "rm -rf build_log_*/" + archiveArtifacts artifacts: "build_log_${env.BUILD_ID}.zip" + } + if (directoryExistsGlob("test_log_*")) { + sh "zip -r -qq test_log_${env.BUILD_ID}.zip test_log_*/*" + sh "rm -rf test_log_*/" + archiveArtifacts artifacts: "test_log_${env.BUILD_ID}.zip" + } + if (fileExists("test_results.html")) { + sh "mv test_results.html test_results-${env.JOB_NAME}.html" + sh "sed -i -e 's#TEMPLATE_JOB_NAME#${JOB_NAME}#' -e 's@build #TEMPLATE_BUILD_ID@build #${BUILD_ID}@' -e 's#Build-ID: TEMPLATE_BUILD_ID#Build-ID: ${BUILD_ID}#' -e 's#TEMPLATE_STAGE_NAME#${testStageName}#' test_results-${JOB_NAME}.html" + archiveArtifacts artifacts: "test_results-${env.JOB_NAME}.html" + } + } + } + } + } + } +} diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab index 784588357d..a5912f4609 100644 --- a/ci-scripts/Jenkinsfile-gitlab +++ b/ci-scripts/Jenkinsfile-gitlab @@ -111,17 +111,7 @@ pipeline { sh "./ci-scripts/doGitLabMerge.sh --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}" sh "zip -r -qq localZip.zip ." - // Running astyle options on the list of modified files by the merge request - // For the moment, there is no fail criteria. Just a notification of number of files that do not follow - sh "./ci-scripts/checkCodingFormattingRules.sh --src-branch ${env.gitlabSourceBranch} --target-branch ${env.gitlabTargetBranch}" - def res=readFile('./oai_rules_result.txt').trim(); - if ("0".equals(res)) { - def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): All Changed files in Merge Request follow OAI Formatting Rules" - addGitLabMRComment comment: message - } else { - def message = "OAI " + JOB_NAME + " build (" + BUILD_ID + "): Some Changed files in Merge Request DO NOT follow OAI Formatting Rules" - addGitLabMRComment comment: message - } + // here was an astyle formatting check, with corresponding messages. The same could be done with clang-format } else { echo "Git Branch is ${GIT_BRANCH}" echo "Git Commit is ${GIT_COMMIT}" @@ -132,9 +122,6 @@ pipeline { sh "git log -n1 --pretty=format:\"%s\" > .git/CI_COMMIT_MSG" sh "zip -r -qq localZip.zip ." - // Running astyle options on all C/H files in the repository - // For the moment, there is no fail criteria. Just a notification of number of files that do not follow - sh "./ci-scripts/checkCodingFormattingRules.sh" } } } @@ -187,7 +174,7 @@ pipeline { } } } - } + } stage ("Variant Builds") { parallel { @@ -349,142 +336,6 @@ pipeline { } } } - stage ("Test MONOLITHIC - FDD - Band 7 - B210") { - when { - expression {doFullTestsuite} - } - steps { - script { - triggerSlaveJob ('eNB-CI-FDD-Band7-B210', 'Test-Mono-FDD-Band7') - } - } - post { - always { - script { - finalizeSlaveJob('eNB-CI-FDD-Band7-B210') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } - stage ("Test MONOLITHIC - TDD - Band 40 - B210") { - when { - expression {doFullTestsuite} - } - steps { - script { - triggerSlaveJob ('eNB-CI-TDD-Band40-B210', 'Test-Mono-TDD-Band40') - } - } - post { - always { - script { - finalizeSlaveJob('eNB-CI-TDD-Band40-B210') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } - stage ("Test IF4p5 - FDD - Band 7 - B210") { - when { - expression {doFullTestsuite} - } - steps { - script { - sh "sleep 60" - triggerSlaveJob ('eNB-CI-IF4p5-FDD-Band7-B210', 'Test-IF4p5-FDD-Band7') - } - } - post { - always { - script { - finalizeSlaveJob('eNB-CI-IF4p5-FDD-Band7-B210') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } - stage ("Test IF4p5 - TDD - Band 40 - B210") { - when { - expression {doFullTestsuite} - } - steps { - script { - sh "sleep 60" - triggerSlaveJob ('eNB-CI-IF4p5-TDD-Band40-B210', 'Test-IF4p5-TDD-Band40') - } - } - post { - always { - script { - finalizeSlaveJob('eNB-CI-IF4p5-TDD-Band40-B210') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } - stage ("Test OAI UE - FDD - Band 20 - B200") { - when { - expression {doFullTestsuite} - } - steps { - script { - triggerSlaveJobNoGitLab ('UE-CI-FDD-Band20-B200') - } - } - post { - always { - script { - finalizeSlaveJob('UE-CI-FDD-Band20-B200') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } - stage ("Test OAI UE - OAI eNB - FDD - Band 7 - B200") { - when { - expression {doFullTestsuite} - } - steps { - script { - // Delayed trigger on slave job, so it is always the last one to run - sh "sleep 240" - triggerSlaveJob ('eNB-UE-CI-MONO-FDD-Band7-B200', 'Test-eNB-OAI-UE-FDD-Band7') - } - } - post { - always { - script { - finalizeSlaveJob('eNB-UE-CI-MONO-FDD-Band7-B200') - } - } - failure { - script { - currentBuild.result = 'FAILURE' - } - } - } - } } post { always { @@ -560,68 +411,3 @@ OAI CI Team''', } } } - -// ---- Slave Job functions - -def triggerSlaveJob (jobName, gitlabStatusName) { - // Workaround for the "cancelled" GitLab pipeline notification - // The slave job is triggered with the propagate false so the following commands are executed - // Its status is now PASS/SUCCESS from a stage pipeline point of view - // localStatus variable MUST be analyzed to properly assess the status - localStatus = build job: jobName, - parameters: [ - string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)), - string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)), - string(name: 'eNB_CommitID', value: String.valueOf(env.gitlabMergeRequestLastCommit)), - booleanParam(name: 'eNB_mergeRequest', value: "MERGE".equals(env.gitlabActionType)), - string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch)) - ], propagate: false - localResult = localStatus.getResult() - echo "${jobName} Slave Job status is ${localResult}" - gitlabCommitStatus(name: gitlabStatusName) { - if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) { - echo "${jobName} Slave Job is OK" - } else { - echo "${jobName} Slave Job is KO" - sh "ci-scripts/fail.sh" - } - } -} - -def triggerSlaveJobNoGitLab (jobName) { - // Workaround for the "cancelled" GitLab pipeline notification - // The slave job is triggered with the propagate false so the following commands are executed - // Its status is now PASS/SUCCESS from a stage pipeline point of view - // localStatus variable MUST be analyzed to properly assess the status - localStatus = build job: jobName, - parameters: [ - string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)), - string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)), - string(name: 'eNB_CommitID', value: String.valueOf(env.gitlabMergeRequestLastCommit)), - booleanParam(name: 'eNB_mergeRequest', value: "MERGE".equals(env.gitlabActionType)), - string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch)) - ], propagate: false - localResult = localStatus.getResult() - echo "${jobName} Slave Job status is ${localResult}" - if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) { - echo "${jobName} Slave Job is OK" - } else { - echo "${jobName} Slave Job is KO" - sh "ci-scripts/fail.sh" - } -} - -def finalizeSlaveJob(jobName) { - // In case of any non-success, we are retrieving the HTML report of the last completed - // slave job. The only drop-back is that we may retrieve the HTML report of a previous build - fileName = "test_results-${jobName}.html" - if (!fileExists(fileName)) { - copyArtifacts(projectName: jobName, - filter: 'test_results*.html', - selector: lastCompleted()) - if (fileExists(fileName)) { - sh "sed -i -e 's#TEMPLATE_BUILD_TIME#${JOB_TIMESTAMP}#' ${fileName}" - archiveArtifacts artifacts: fileName - } - } -} diff --git a/ci-scripts/args_parse.py b/ci-scripts/args_parse.py index c0203a4c98..01e3eba465 100644 --- a/ci-scripts/args_parse.py +++ b/ci-scripts/args_parse.py @@ -41,7 +41,7 @@ import constants as CONST #----------------------------------------------------------- -def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): +def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUSTER): py_param_file_present = False @@ -82,6 +82,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): CONTAINERS.ranRepository=matchReg.group(1) SCA.ranRepository=matchReg.group(1) PHYSIM.ranRepository=matchReg.group(1) + CLUSTER.ranRepository=matchReg.group(1) elif re.match('^\-\-eNB_AllowMerge=(.+)$|^\-\-ranAllowMerge=(.+)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNB_AllowMerge=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB_AllowMerge=(.+)$', myArgv, re.IGNORECASE) @@ -96,6 +97,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): CONTAINERS.ranAllowMerge=True SCA.ranAllowMerge=True PHYSIM.ranAllowMerge=True + CLUSTER.ranAllowMerge=True elif re.match('^\-\-eNBBranch=(.+)$|^\-\-ranBranch=(.+)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE) @@ -108,6 +110,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): CONTAINERS.ranBranch=matchReg.group(1) SCA.ranBranch=matchReg.group(1) PHYSIM.ranBranch=matchReg.group(1) + CLUSTER.ranBranch=matchReg.group(1) elif re.match('^\-\-eNBCommitID=(.*)$|^\-\-ranCommitID=(.*)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE) @@ -120,6 +123,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): CONTAINERS.ranCommitID=matchReg.group(1) SCA.ranCommitID=matchReg.group(1) PHYSIM.ranCommitID=matchReg.group(1) + CLUSTER.ranCommitID=matchReg.group(1) elif re.match('^\-\-eNBTargetBranch=(.*)$|^\-\-ranTargetBranch=(.*)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBTargetBranch=(.*)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBTargetBranch=(.*)$', myArgv, re.IGNORECASE) @@ -132,6 +136,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): CONTAINERS.ranTargetBranch=matchReg.group(1) SCA.ranTargetBranch=matchReg.group(1) PHYSIM.ranTargetBranch=matchReg.group(1) + CLUSTER.ranTargetBranch=matchReg.group(1) elif re.match('^\-\-eNBIPAddress=(.+)$|^\-\-eNB[1-2]IPAddress=(.+)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBIPAddress=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBIPAddress=(.+)$', myArgv, re.IGNORECASE) @@ -140,6 +145,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): CONTAINERS.eNBIPAddress=matchReg.group(1) SCA.eNBIPAddress=matchReg.group(1) PHYSIM.eNBIPAddress=matchReg.group(1) + CLUSTER.eNBIPAddress=matchReg.group(1) elif re.match('^\-\-eNB1IPAddress=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1IPAddress=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1IPAddress=matchReg.group(1) @@ -156,6 +162,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): CONTAINERS.eNBUserName=matchReg.group(1) SCA.eNBUserName=matchReg.group(1) PHYSIM.eNBUserName=matchReg.group(1) + CLUSTER.eNBUserName=matchReg.group(1) elif re.match('^\-\-eNB1UserName=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1UserName=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1UserName=matchReg.group(1) @@ -172,6 +179,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): CONTAINERS.eNBPassword=matchReg.group(1) SCA.eNBPassword=matchReg.group(1) PHYSIM.eNBPassword=matchReg.group(1) + CLUSTER.eNBPassword=matchReg.group(1) elif re.match('^\-\-eNB1Password=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1Password=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1Password=matchReg.group(1) @@ -188,6 +196,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): CONTAINERS.eNBSourceCodePath=matchReg.group(1) SCA.eNBSourceCodePath=matchReg.group(1) PHYSIM.eNBSourceCodePath=matchReg.group(1) + CLUSTER.eNBSourceCodePath=matchReg.group(1) elif re.match('^\-\-eNB1SourceCodePath=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1SourceCodePath=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1SourceCodePath=matchReg.group(1) @@ -260,12 +269,21 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): elif re.match('^\-\-OCUserName=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-OCUserName=(.+)$', myArgv, re.IGNORECASE) PHYSIM.OCUserName = matchReg.group(1) + CLUSTER.OCUserName = matchReg.group(1) elif re.match('^\-\-OCPassword=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-OCPassword=(.+)$', myArgv, re.IGNORECASE) PHYSIM.OCPassword = matchReg.group(1) + CLUSTER.OCPassword = matchReg.group(1) elif re.match('^\-\-OCProjectName=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-OCProjectName=(.+)$', myArgv, re.IGNORECASE) PHYSIM.OCProjectName = matchReg.group(1) + CLUSTER.OCProjectName = matchReg.group(1) + elif re.match('^\-\-OCUrl=(.+)$', myArgv, re.IGNORECASE): + matchReg = re.match('^\-\-OCUrl=(.+)$', myArgv, re.IGNORECASE) + CLUSTER.OCUrl = matchReg.group(1) + elif re.match('^\-\-OCRegistry=(.+)$', myArgv, re.IGNORECASE): + matchReg = re.match('^\-\-OCRegistry=(.+)$', myArgv, re.IGNORECASE) + CLUSTER.OCRegistry = matchReg.group(1) elif re.match('^\-\-BuildId=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-BuildId=(.+)$', myArgv, re.IGNORECASE) RAN.BuildId = matchReg.group(1) diff --git a/ci-scripts/astyle-options.txt b/ci-scripts/astyle-options.txt deleted file mode 100644 index 81c4d68ace..0000000000 --- a/ci-scripts/astyle-options.txt +++ /dev/null @@ -1,26 +0,0 @@ -# OAI is using a style that is similar to the Google style ---style=google -# long options can be written without the preceding '--' -# Convert tabs to spaces -convert-tabs -# Indentation is 2 spaces -indent=spaces=2 -# Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block. -indent-switches -# Indent preprocessor blocks at bracket level 0. -indent-preproc-block -# Indent multi-line preprocessor #define statements. -indent-preproc-define -# Indent C++ comments beginning in column one. -indent-col1-comments -# Pad empty lines around header blocks -break-blocks -delete-empty-lines -# Attach a pointer or reference operator (*, &, or ^) to the variable name (right) -align-pointer=name -# The code line length is 200 characters/columns (this is the maximum allowed by astyle) -max-code-length=200 -# If the line contains logical conditionals they will be placed first on the new line. -break-after-logical -# Force use of the linux end of line -lineend=linux diff --git a/ci-scripts/checkCodingFormattingRules.sh b/ci-scripts/checkCodingFormattingRules.sh index c29941cade..ffe978d30d 100755 --- a/ci-scripts/checkCodingFormattingRules.sh +++ b/ci-scripts/checkCodingFormattingRules.sh @@ -24,8 +24,6 @@ function usage { echo "OAI Coding / Formatting Guideline Check script" echo " Original Author: Raphael Defosseux" echo "" - echo " Requirement: astyle shall be installed" - echo "" echo " By default (no options) the complete repository will be checked" echo " In case of merge request, provided source and target branch," echo " the script will check only the modified files" @@ -57,11 +55,10 @@ fi if [ $# -eq 0 ] then - echo " ---- Checking the whole repository ----" - echo "" - NB_FILES_TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt --recursive --exclude=ci-scripts --exclude=cmake_targets *.c *.h | grep -c Formatted || true` - echo "Nb Files that do NOT follow OAI rules: $NB_FILES_TO_FORMAT" - echo $NB_FILES_TO_FORMAT > ./oai_rules_result.txt + # in this file we previously had a list of files that were not properly + # formatted. At the time of this MR, the Jenkinsfile expects this file, so + # we simply produce an empty one + touch ./oai_rules_result.txt # Testing Circular Dependencies protection awk '/#[ \t]*ifndef/ { gsub("^.*ifndef *",""); if (names[$1]!="") print "files with same {define ", FILENAME, names[$1]; names[$1]=FILENAME } /#[ \t]*define/ { gsub("^.*define *",""); if(names[$1]!=FILENAME) print "error in declaration", FILENAME, $1, names[$1]; nextfile }' `find openair* common targets executables -name *.h |grep -v LFDS` > header-files-w-incorrect-define.txt @@ -77,7 +74,7 @@ then IS_NFAPI=`echo $FILE | egrep -c "nfapi/open-nFAPI|nfapi/oai_integration/vendor_ext" || true` IS_OAI_LICENCE_PRESENT=`egrep -c "OAI Public License" $FILE || true` IS_BSD_LICENCE_PRESENT=`egrep -c "the terms of the BSD Licence|License-Identifier: BSD-2-Clause" $FILE || true` - IS_EXCEPTION=`echo $FILE | egrep -c "common/utils/collection/tree.h|common/utils/collection/queue.h|common/utils/itti_analyzer/common/queue.h|openair3/UTILS/tree.h|openair3/UTILS/queue.h|openair3/GTPV1-U/nw-gtpv1u|openair2/UTIL/OPT/ws_|openair2/UTIL/OPT/packet-rohc.h|openair3/NAS/COMMON/milenage.h|openair1/PHY/CODING/crc|openair1/PHY/CODING/types.h" || true` + IS_EXCEPTION=`echo $FILE | egrep -c "common/utils/collection/tree.h|common/utils/collection/queue.h|openair2/UTIL/OPT/packet-rohc.h|openair3/NAS/COMMON/milenage.h|openair1/PHY/CODING/crc.h|openair1/PHY/CODING/crcext.h|openair1/PHY/CODING/types.h|openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c|openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_offload.h" || true` if [ $IS_OAI_LICENCE_PRESENT -eq 0 ] && [ $IS_BSD_LICENCE_PRESENT -eq 0 ] then if [ $IS_NFAPI -eq 0 ] && [ $IS_EXCEPTION -eq 0 ] @@ -151,10 +148,6 @@ echo "" # Retrieve the list of modified files since the latest develop commit MODIFIED_FILES=`git log $TARGET_INIT_COMMIT..$MERGE_COMMMIT --oneline --name-status | egrep "^M|^A" | sed -e "s@^M\t*@@" -e "s@^A\t*@@" | sort | uniq` NB_TO_FORMAT=0 -if [ -f oai_rules_result_list.txt ] -then - rm -f oai_rules_result_list.txt -fi if [ -f header-files-w-incorrect-define.txt ] then rm -f header-files-w-incorrect-define.txt @@ -178,13 +171,6 @@ do EXT="${filename##*.}" if [ $EXT = "c" ] || [ $EXT = "h" ] || [ $EXT = "cpp" ] || [ $EXT = "hpp" ] then - TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt $FULLFILE | grep -c Formatted || true` - NB_TO_FORMAT=$((NB_TO_FORMAT + TO_FORMAT)) - if [ $TO_FORMAT -ne 0 ] - then - echo $FULLFILE - echo $FULLFILE >> ./oai_rules_result_list.txt - fi # Testing if explicit GNU GPL license banner GNU_EXCEPTION=`echo $FULLFILE | egrep -c "openair3/NAS/COMMON/milenage.h" || true` if [ $GNU_EXCEPTION -eq 0 ] @@ -198,7 +184,7 @@ do IS_NFAPI=`echo $FULLFILE | egrep -c "nfapi/open-nFAPI|nfapi/oai_integration/vendor_ext" || true` IS_OAI_LICENCE_PRESENT=`egrep -c "OAI Public License" $FULLFILE || true` IS_BSD_LICENCE_PRESENT=`egrep -c "the terms of the BSD Licence|License-Identifier: BSD-2-Clause" $FULLFILE || true` - IS_EXCEPTION=`echo $FULLFILE | egrep -c "common/utils/collection/tree.h|common/utils/collection/queue.h|common/utils/itti_analyzer/common/queue.h|openair3/UTILS/tree.h|openair3/UTILS/queue.h|openair3/GTPV1-U/nw-gtpv1u|openair2/UTIL/OPT/ws_|openair2/UTIL/OPT/packet-rohc.h|openair3/NAS/COMMON/milenage.h|openair1/PHY/CODING/crc|openair1/PHY/CODING/types.h" || true` + IS_EXCEPTION=`echo $FULLFILE | egrep -c "common/utils/collection/tree.h|common/utils/collection/queue.h|openair2/UTIL/OPT/packet-rohc.h|openair3/NAS/COMMON/milenage.h|openair1/PHY/CODING/crc.h|openair1/PHY/CODING/crcext.h|openair1/PHY/CODING/types.h|openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c|openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_offload.h" || true` if [ $IS_OAI_LICENCE_PRESENT -eq 0 ] && [ $IS_BSD_LICENCE_PRESENT -eq 0 ] then if [ $IS_NFAPI -eq 0 ] && [ $IS_EXCEPTION -eq 0 ] @@ -215,9 +201,10 @@ do fi done rm -f header-files-w-incorrect-define-tmp.txt -echo "" -echo " ----------------------------------------------------------" -echo "Nb Files that do NOT follow OAI rules: $NB_TO_FORMAT" -echo $NB_TO_FORMAT > ./oai_rules_result.txt + +# in this script we previously produced a list of files that were not properly +# formatted. At the time of this MR, the Jenkinsfile expects this file, so +# we simply produce an empty file +touch ./oai_rules_result.txt exit 0 diff --git a/ci-scripts/cls_cluster.py b/ci-scripts/cls_cluster.py new file mode 100644 index 0000000000..210191ce66 --- /dev/null +++ b/ci-scripts/cls_cluster.py @@ -0,0 +1,377 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# Python for CI of OAI-eNB + COTS-UE +# +# Required Python Version +# Python 3.x +# +# Required Python Package +# pexpect +#--------------------------------------------------------------------- + +#----------------------------------------------------------- +# Import +#----------------------------------------------------------- +import logging +import sshconnection as SSH +import cls_oai_html +#import os +import re +import time +#import subprocess +import sys +import constants as CONST +import helpreadme as HELP +import cls_containerize + +class Cluster: + def __init__(self): + self.eNBIPAddress = "" + self.eNBSourceCodePath = "" + self.forcedWorkspaceCleanup = False + self.OCUserName = "" + self.OCPassword = "" + self.OCProjectName = "" + self.OCUrl = "https://api.oai.cs.eurecom.fr:6443" + self.OCRegistry = "default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/" + self.ranRepository = "" + self.ranBranch = "" + self.ranCommitID = "" + self.ranAllowMerge = False + self.ranTargetBranch = "" + + def _recreate_entitlements(self, sshSession): + # recreating entitlements, don't care if deletion fails + sshSession.command('oc delete secret etc-pki-entitlement', '\$', 5) + if re.search(r"not found", sshSession.getBefore()): + logging.warning("no secrets etc-pki-entitlement found, recreating") + sshSession.command('ls /etc/pki/entitlement/???????????????????.pem | tail -1', '\$', 5, silent=True) + regres1 = re.search(r"/etc/pki/entitlement/[0-9]+.pem", sshSession.getBefore()) + sshSession.command('ls /etc/pki/entitlement/???????????????????-key.pem | tail -1', '\$', 5, silent=True) + regres2 = re.search(r"/etc/pki/entitlement/[0-9]+-key.pem", sshSession.getBefore()) + if regres1 is None or regres2 is None: + logging.error("could not find entitlements") + return false + file1 = regres1.group(0) + file2 = regres2.group(0) + sshSession.command(f'oc create secret generic etc-pki-entitlement --from-file {file1} --from-file {file2}', '\$', 5) + regres = re.search(r"secret/etc-pki-entitlement created", sshSession.getBefore()) + if regres is None: + logging.error("could not create secret/etc-pki-entitlement") + return False + return True + + def _recreate_bc(self, sshSession, name, newTag, filename): + self._retag_image_statement(sshSession, name, name, newTag, filename) + sshSession.command(f'oc delete -f {filename}', '\$', 5) + sshSession.command(f'oc create -f {filename}', '\$', 5) + before = sshSession.getBefore() + if re.search('buildconfig.build.openshift.io/[a-zA-Z\-0-9]+ created', before) is not None: + return True + logging.error('error while creating buildconfig: ' + sshSession.getBefore()) + return False + + def _recreate_is_tag(self, sshSession, name, newTag, filename): + sshSession.command(f'oc describe is {name}', '\$', 5) + if sshSession.getBefore().count('NotFound') > 0: + sshSession.command(f'oc create -f {filename}', '\$', 5) + before = sshSession.getBefore() + if re.search(f'imagestream.image.openshift.io/{name} created', before) is None: + logging.error('error while creating imagestream: ' + sshSession.getBefore()) + return False + else: + logging.debug(f'-> imagestream {name} found') + image = f'{name}:{newTag}' + sshSession.command(f'oc delete istag {image}', '\$', 5) # we don't care if this fails, e.g., if it is missing + sshSession.command(f'oc create istag {image}', '\$', 5) + before = sshSession.getBefore() + if re.search(f'imagestreamtag.image.openshift.io/{image} created', before) is not None: + return True + logging.error('error while creating imagestreamtag: ' + sshSession.getBefore()) + return False + + def _start_build(self, sshSession, name): + # will return "immediately" but build runs in background + # if multiple builds are started at the same time, this can take some time, however + ret = sshSession.command(f'oc start-build {name} --from-file={self.eNBSourceCodePath}', '\$', 300) + before = sshSession.getBefore() + regres = re.search(r'build.build.openshift.io/(?P[a-zA-Z0-9\-]+) started', str(before)) + if ret != 0 or before.count('Uploading finished') != 1 or regres is None: + logging.error("error during oc start-build: " + sshSession.getBefore()) + self._delete_pod(sshSession, name) + return None + return regres.group('jobname') + '-build' + + def _delete_pod(self, sshSession, shortName): + sshSession.command(f"oc get pods | grep {shortName}", '\$', 5) + regres = re.search(rf'{shortName}-[0-9]+-build', sshSession.getBefore()) + if regres is not None: + sshSession.command(f"oc delete pod {regres.group(0)}", '\$', 5) + else: + logging.warning(f"no pod found with name {shortName}") + + def _wait_build_end(self, sshSession, jobs, timeout_sec, check_interval_sec = 5): + logging.debug(f"waiting for jobs {jobs} to finish building") + while timeout_sec > 0: + # check status + for j in jobs: + sshSession.command(f'oc get pods | grep {j}', '\$', 10, silent = True) + if sshSession.getBefore().count('Completed') > 0: jobs.remove(j) + if sshSession.getBefore().count('Error') > 0: + logging.error(f'error for job {j}: ' + sshSession.getBefore()) + return False + if jobs == []: + logging.debug('all jobs completed') + return True + time.sleep(check_interval_sec) + timeout_sec -= check_interval_sec + logging.error(f"timeout while waiting for end of build of {jobs}") + return False + + def _retag_image_statement(self, sshSession, oldImage, newImage, newTag, filename): + sshSession.command(f'sed -i -e "s#{oldImage}:latest#{newImage}:{newTag}#" {filename}', '\$', 5) + + def _get_image_size(self, sshSession, image, tag): + # get the SHA of the image we built using the image name and its tag + sshSession.command(f'oc describe is {image} | grep -A4 {tag}', '\$', 5) + result = re.search(f'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/(?P{image}@sha256:[a-f0-9]+)', sshSession.getBefore()) + if result is None: + return -1 + imageSha = result.group("imageSha") + + # retrieve the size + sshSession.command(f'oc get -o json isimage {imageSha} | jq -Mc "{{dockerImageSize: .image.dockerImageMetadata.Size}}"', '\$', 5) + result = re.search('{"dockerImageSize":(?P[0-9]+)}', str(sshSession.getBefore())) + if result is None: + return -1 + return int(result.group("size")) + + def _deploy_pod(self, sshSession, filename, timeout = 30): + sshSession.command(f'oc create -f {filename}', '\$', 10) + result = re.search(f'pod/(?P[a-zA-Z0-9_\-]+) created', sshSession.getBefore()) + if result is None: + logging.error(f'could not deploy pod: {sshSession.getBefore()}') + return None + pod = result.group("pod") + logging.debug(f'checking if pod {pod} is in Running state') + while timeout > 0: + sshSession.command(f'oc get pod {pod} -o json | jq -Mc .status.phase', '\$', 5, silent=True) + if re.search('"Running"', sshSession.getBefore()) is not None: return pod + timeout -= 1 + time.sleep(1) + logging.error(f'pod {pod} did not reach Running state') + self._undeploy_pod(sshSession, filename) + return None + + def _undeploy_pod(self, sshSession, filename): + # to save time we start this in the background and trust that oc stops correctly + sshSession.command(f'oc delete -f {filename} &', '\$', 5) + + def BuildClusterImage(self, HTML): + if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': + HELP.GenericHelp(CONST.Version) + sys.exit(f'Insufficient Parameter: ranRepository {self.ranRepository} ranBranch {ranBranch} ranCommitID {self.ranCommitID}') + + lIpAddr = self.eNBIPAddress + lSourcePath = self.eNBSourceCodePath + if lIpAddr == '' or lSourcePath == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter: no SSH Credentials') + ocUserName = self.OCUserName + ocPassword = self.OCPassword + ocProjectName = self.OCProjectName + if ocUserName == '' or ocPassword == '' or ocProjectName == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter: no OC Credentials') + if self.OCRegistry.startswith("http") and not self.OCRegistry.endswith("/"): + sys.exit(f'ocRegistry {self.OCRegistry} should not start with http:// or https:// and end on a slash /') + + logging.debug(f'Building on cluster triggered from server: {lIpAddr}') + mySSH = SSH.SSHConnection() + mySSH.open(lIpAddr, "oaicicd", "SHOULD NOT BE NECESSARY") + + self.testCase_id = HTML.testCase_id + + # Workaround for some servers, we need to erase completely the workspace + if self.forcedWorkspaceCleanup: + mySSH.command(f'rm -Rf {lSourcePath}', '\$', 15) + cls_containerize.CreateWorkspace(mySSH, lSourcePath, self.ranRepository, self.ranCommitID, self.ranTargetBranch, self.ranAllowMerge) + + # we don't necessarily need a forced workspace cleanup, but in + # order to reduce the amount of data send to OpenShift, we + # manually delete all generated files in the workspace + mySSH.command(f'rm -rf {lSourcePath}/cmake_targets/ran_build', '\$', 30); + + baseTag = 'develop' + forceBaseImageBuild = False + imageTag = 'develop' + if self.ranAllowMerge: # merging MR branch into develop -> temporary image + imageTag = 'ci-temp' + if self.ranTargetBranch == 'develop': + mySSH.command(f'git diff HEAD..origin/develop -- cmake_targets/build_oai cmake_targets/tools/build_helper docker/Dockerfile.base.rhel8.2 | grep --colour=never -i INDEX', '\$', 5) + result = re.search('index', mySSH.getBefore()) + if result is not None: + forceBaseImageBuild = True + baseTag = 'ci-temp' + else: + forceBaseImageBuild = True + + # logging to OC Cluster and then switch to corresponding project + mySSH.command(f'oc login -u {ocUserName} -p {ocPassword} --server {self.OCUrl}', '\$', 31) + if mySSH.getBefore().count('Login successful.') == 0: + logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m') + mySSH.close() + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL) + return False + + mySSH.command(f'oc project {ocProjectName}', '\$', 30) + if mySSH.getBefore().count(f'Already on project "{ocProjectName}"') == 0 and mySSH.getBefore().count(f'Now using project "{self.OCProjectName}"') == 0: + logging.error(f'\u001B[1mUnable to access OC project {ocProjectName}\u001B[0m') + mySSH.command('oc logout', '\$', 30) + mySSH.close() + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PROJECT_FAIL) + return False + + self._recreate_entitlements(mySSH) + + status = True # flag to abandon compiling if any image fails + attemptedImages = [] + if forceBaseImageBuild: + self._recreate_is_tag(mySSH, 'ran-base', baseTag, 'openshift/ran-base-is.yaml') + self._recreate_bc(mySSH, 'ran-base', baseTag, 'openshift/ran-base-bc.yaml') + ranbase_job = self._start_build(mySSH, 'ran-base') + attemptedImages += ['ran-base'] + status = ranbase_job is not None and self._wait_build_end(mySSH, [ranbase_job], 600) + if not status: logging.error('failure during build of ran-base') + mySSH.command(f'oc logs {ranbase_job} > cmake_targets/log/ran-base.log', '\$', 10) + # recover logs by mounting image + self._retag_image_statement(mySSH, 'ran-base', 'ran-base', baseTag, 'openshift/ran-base-log-retrieval.yaml') + pod = self._deploy_pod(mySSH, 'openshift/ran-base-log-retrieval.yaml') + if pod is not None: + mySSH.command(f'mkdir -p cmake_targets/log/ran-base', '\$', 5) + mySSH.command(f'oc rsync {pod}:/oai-ran/cmake_targets/log/ cmake_targets/log/ran-base', '\$', 5) + self._undeploy_pod(mySSH, 'openshift/ran-base-log-retrieval.yaml') + else: + status = False + + if status: + self._recreate_is_tag(mySSH, 'oai-physim', imageTag, 'openshift/oai-physim-is.yaml') + self._recreate_bc(mySSH, 'oai-physim', imageTag, 'openshift/oai-physim-bc.yaml') + self._retag_image_statement(mySSH, 'ran-base', 'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/ran-base', baseTag, 'docker/Dockerfile.phySim.rhel8.2') + physim_job = self._start_build(mySSH, 'oai-physim') + attemptedImages += ['oai-physim'] + + self._recreate_is_tag(mySSH, 'ran-build', imageTag, 'openshift/ran-build-is.yaml') + self._recreate_bc(mySSH, 'ran-build', imageTag, 'openshift/ran-build-bc.yaml') + self._retag_image_statement(mySSH, 'ran-base', 'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/ran-base', baseTag, 'docker/Dockerfile.build.rhel8.2') + ranbuild_job = self._start_build(mySSH, 'ran-build') + attemptedImages += ['ran-build'] + + wait = ranbuild_job is not None and physim_job is not None and self._wait_build_end(mySSH, [ranbuild_job, physim_job], 1200) + if not wait: logging.error('error during build of ranbuild_job or physim_job') + status = status and wait + mySSH.command(f'oc logs {ranbuild_job} > cmake_targets/log/ran-build.log', '\$', 10) + mySSH.command(f'oc logs {physim_job} > cmake_targets/log/oai-physim.log', '\$', 10) + + if status: + self._recreate_is_tag(mySSH, 'oai-enb', imageTag, 'openshift/oai-enb-is.yaml') + self._recreate_bc(mySSH, 'oai-enb', imageTag, 'openshift/oai-enb-bc.yaml') + self._retag_image_statement(mySSH, 'ran-base', 'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/ran-base', baseTag, 'docker/Dockerfile.eNB.rhel8.2') + self._retag_image_statement(mySSH, 'ran-build', 'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/ran-build', imageTag, 'docker/Dockerfile.eNB.rhel8.2') + enb_job = self._start_build(mySSH, 'oai-enb') + attemptedImages += ['oai-enb'] + + self._recreate_is_tag(mySSH, 'oai-gnb', imageTag, 'openshift/oai-gnb-is.yaml') + self._recreate_bc(mySSH, 'oai-gnb', imageTag, 'openshift/oai-gnb-bc.yaml') + self._retag_image_statement(mySSH, 'ran-base', 'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/ran-base', baseTag, 'docker/Dockerfile.gNB.rhel8.2') + self._retag_image_statement(mySSH, 'ran-build', 'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/ran-build', imageTag, 'docker/Dockerfile.gNB.rhel8.2') + gnb_job = self._start_build(mySSH, 'oai-gnb') + attemptedImages += ['oai-gnb'] + + self._recreate_is_tag(mySSH, 'oai-lte-ue', imageTag, 'openshift/oai-lte-ue-is.yaml') + self._recreate_bc(mySSH, 'oai-lte-ue', imageTag, 'openshift/oai-lte-ue-bc.yaml') + self._retag_image_statement(mySSH, 'ran-base', 'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/ran-base', baseTag, 'docker/Dockerfile.lteUE.rhel8.2') + self._retag_image_statement(mySSH, 'ran-build', 'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/ran-build', imageTag, 'docker/Dockerfile.lteUE.rhel8.2') + lteue_job = self._start_build(mySSH, 'oai-lte-ue') + attemptedImages += ['oai-lte-ue'] + + self._recreate_is_tag(mySSH, 'oai-nr-ue', imageTag, 'openshift/oai-nr-ue-is.yaml') + self._recreate_bc(mySSH, 'oai-nr-ue', imageTag, 'openshift/oai-nr-ue-bc.yaml') + self._retag_image_statement(mySSH, 'ran-base', 'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/ran-base', baseTag, 'docker/Dockerfile.nrUE.rhel8.2') + self._retag_image_statement(mySSH, 'ran-build', 'image-registry.openshift-image-registry.svc:5000/oaicicd-ran/ran-build', imageTag, 'docker/Dockerfile.nrUE.rhel8.2') + nrue_job = self._start_build(mySSH, 'oai-nr-ue') + attemptedImages += ['oai-nr-ue'] + + wait = enb_job is not None and gnb_job is not None and lteue_job is not None and nrue_job is not None and self._wait_build_end(mySSH, [enb_job, gnb_job, lteue_job, nrue_job], 600) + if not wait: logging.error('error during build of eNB/gNB/lteUE/nrUE') + status = status and wait + # recover logs + mySSH.command(f'oc logs {enb_job} > cmake_targets/log/oai-enb.log', '\$', 10) + mySSH.command(f'oc logs {gnb_job} > cmake_targets/log/oai-gnb.log', '\$', 10) + mySSH.command(f'oc logs {lteue_job} > cmake_targets/log/oai-lte-ue.log', '\$', 10) + mySSH.command(f'oc logs {nrue_job} > cmake_targets/log/oai-nr-ue.log', '\$', 10) + + # split and analyze logs + imageSize = {} + for image in attemptedImages: + mySSH.command(f'mkdir -p cmake_targets/log/{image}', '\$', 5) + mySSH.command(f'python3 ci-scripts/docker_log_split.py --logfilename=cmake_targets/log/{image}.log', '\$', 5) + tag = imageTag if image != 'ran-base' else baseTag + size = self._get_image_size(mySSH, image, tag) + if size <= 0: + imageSize[image] = 'unknown -- BUILD FAILED' + status = False + else: + sizeMb = float(size) / 1000000 + imageSize[image] = f'{sizeMb:.1f} Mbytes (uncompressed: ~{sizeMb*2.5:.1f} Mbytes)' + logging.info(f'\u001B[1m{image} size is {imageSize[image]}\u001B[0m') + + grep_exp = "\|".join(attemptedImages) + mySSH.command(f'oc get images | grep -e \'{grep_exp}\' > cmake_targets/log/image_registry.log', '\$', 10); + + build_log_name = f'build_log_{self.testCase_id}' + cls_containerize.CopyLogsToExecutor(mySSH, lSourcePath, build_log_name, lIpAddr, 'oaicicd', CONST.CI_NO_PASSWORD) + + mySSH.command('for pod in $(oc get pods | tail -n +2 | awk \'{print $1}\'); do oc delete pod ${pod}; done', '\$', 60) + + # logout will return eventually, but we don't care when -> start in background + mySSH.command('oc logout &', '\$', 5) + mySSH.close() + + # Analyze the logs + collectInfo = cls_containerize.AnalyzeBuildLogs(build_log_name, attemptedImages, status) + for img in collectInfo: + for f in collectInfo[img]: + status = status and collectInfo[img][f]['status'] + if not status: + logging.debug(collectInfo) + + if status: + logging.info('\u001B[1m Building OAI Image(s) Pass\u001B[0m') + HTML.CreateHtmlTestRow('all', 'OK', CONST.ALL_PROCESSES_OK) + else: + logging.error('\u001B[1m Building OAI Images Failed\u001B[0m') + HTML.CreateHtmlTestRow('all', 'KO', CONST.ALL_PROCESSES_OK) + + HTML.CreateHtmlNextTabHeaderTestRow(collectInfo, imageSize) + + return status diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 9570610cd8..6197cc7e4f 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -48,6 +48,107 @@ import sshconnection as SSH import helpreadme as HELP import constants as CONST +#----------------------------------------------------------- +# Helper functions used here and in other classes +# (e.g., cls_cluster.py) +#----------------------------------------------------------- +def CreateWorkspace(sshSession, sourcePath, ranRepository, ranCommitID, ranTargetBranch, ranAllowMerge): + # on RedHat/CentOS .git extension is mandatory + result = re.search('([a-zA-Z0-9\:\-\.\/])+\.git', ranRepository) + if result is not None: + full_ran_repo_name = ranRepository.replace('git/', 'git') + else: + full_ran_repo_name = ranRepository + '.git' + sshSession.command('mkdir -p ' + sourcePath, '\$', 5) + sshSession.command('cd ' + sourcePath, '\$', 5) + sshSession.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + full_ran_repo_name + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600) + if sshSession.getBefore().count('done.') == 0: + logging.warning('did not find \'done.\' in git output while cloning/fetching, was not successful?') + sshSession.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) + sshSession.command('git config user.name "OAI Jenkins"', '\$', 5) + + sshSession.command('git clean -x -d -ff', '\$', 30) + sshSession.command('mkdir -p cmake_targets/log', '\$', 5) + # if the commit ID is provided use it to point to it + if ranCommitID != '': + sshSession.command('git checkout -f ' + ranCommitID, '\$', 30) + # if the branch is not develop, then it is a merge request and we need to do + # the potential merge. Note that merge conflicts should already been checked earlier + if ranAllowMerge: + if ranTargetBranch == '': + sshSession.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5) + else: + logging.debug('Merging with the target branch: ' + ranTargetBranch) + sshSession.command('git merge --ff origin/' + ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) + +def CopyLogsToExecutor(sshSession, sourcePath, log_name, scpIp, scpUser, scpPw): + sshSession.command(f'cd {sourcePath}/cmake_targets', '\$', 5) + sshSession.command(f'rm -f {log_name}.zip', '\$', 5) + sshSession.command(f'mkdir -p {log_name}', '\$', 5) + sshSession.command(f'mv log/* {log_name}', '\$', 5) + sshSession.command(f'zip -r -qq {log_name}.zip {log_name}', '\$', 5) + + # copy zip to executor for analysis + if (os.path.isfile(f'./{log_name}.zip')): + os.remove(f'./{log_name}.zip') + if (os.path.isdir(f'./{log_name}')): + shutil.rmtree(f'./{log_name}') + sshSession.copyin(scpIp, scpUser, scpPw, f'{sourcePath}/cmake_targets/{log_name}.zip', '.') + sshSession.command(f'rm -f {log_name}.zip','\$', 5) + ZipFile(f'{log_name}.zip').extractall('.') + +def AnalyzeBuildLogs(buildRoot, images, globalStatus): + collectInfo = {} + for image in images: + files = {} + file_list = [f for f in os.listdir(f'{buildRoot}/{image}') if os.path.isfile(os.path.join(f'{buildRoot}/{image}', f)) and f.endswith('.txt')] + # Analyze the "sub-logs" of every target image + for fil in file_list: + errorandwarnings = {} + warningsNo = 0 + errorsNo = 0 + with open(f'{buildRoot}/{image}/{fil}', mode='r') as inputfile: + for line in inputfile: + result = re.search(' ERROR ', str(line)) + if result is not None: + errorsNo += 1 + result = re.search(' error:', str(line)) + if result is not None: + errorsNo += 1 + result = re.search(' WARNING ', str(line)) + if result is not None: + warningsNo += 1 + result = re.search(' warning:', str(line)) + if result is not None: + warningsNo += 1 + errorandwarnings['errors'] = errorsNo + errorandwarnings['warnings'] = warningsNo + errorandwarnings['status'] = globalStatus + files[fil] = errorandwarnings + # Analyze the target image + if os.path.isfile(f'{buildRoot}/{image}.log'): + errorandwarnings = {} + committed = False + tagged = False + with open(f'{buildRoot}/{image}.log', mode='r') as inputfile: + startOfTargetImageCreation = False # check for tagged/committed only after image created + for line in inputfile: + result = re.search(f'FROM .* [aA][sS] {image}$', str(line)) + if result is not None: + startOfTargetImageCreation = True + if startOfTargetImageCreation: + lineHasTag = re.search(f'Successfully tagged {image}:', str(line)) is not None + tagged = tagged or lineHasTag + # the OpenShift Cluster builder prepends image registry URL + lineHasCommit = re.search(f'COMMIT [a-zA-Z0-9\.:/\-]*{image}', str(line)) is not None + committed = committed or lineHasCommit + errorandwarnings['errors'] = 0 if committed or tagged else 1 + errorandwarnings['warnings'] = 0 + errorandwarnings['status'] = committed or tagged + files['Target Image Creation'] = errorandwarnings + collectInfo[image] = files + return collectInfo + #----------------------------------------------------------- # Class Declaration #----------------------------------------------------------- @@ -91,8 +192,6 @@ class Containerize(): self.cliBuildOptions = '' self.dockerfileprefix = '' self.host = '' - self.allImagesSize = {} - self.collectInfo = {} self.deployedContainers = [] self.tsharkStarted = False @@ -115,35 +214,6 @@ class Containerize(): # Container management functions #----------------------------------------------------------- - def _createWorkspace(self, sshSession, password, sourcePath): - # on RedHat/CentOS .git extension is mandatory - result = re.search('([a-zA-Z0-9\:\-\.\/])+\.git', self.ranRepository) - if result is not None: - full_ran_repo_name = self.ranRepository.replace('git/', 'git') - else: - full_ran_repo_name = self.ranRepository + '.git' - sshSession.command('mkdir -p ' + sourcePath, '\$', 5) - sshSession.command('cd ' + sourcePath, '\$', 5) - sshSession.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + full_ran_repo_name + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600) - # Raphael: here add a check if git clone or git fetch went smoothly - sshSession.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) - sshSession.command('git config user.name "OAI Jenkins"', '\$', 5) - - sshSession.command('echo ' + password + ' | sudo -S git clean -x -d -ff', '\$', 30) - sshSession.command('mkdir -p cmake_targets/log', '\$', 5) - # if the commit ID is provided use it to point to it - if self.ranCommitID != '': - sshSession.command('git checkout -f ' + self.ranCommitID, '\$', 30) - # if the branch is not develop, then it is a merge request and we need to do - # the potential merge. Note that merge conflicts should already been checked earlier - if (self.ranAllowMerge): - if self.ranTargetBranch == '': - if (self.ranBranch != 'develop') and (self.ranBranch != 'origin/develop'): - sshSession.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5) - else: - logging.debug('Merging with the target branch: ' + self.ranTargetBranch) - sshSession.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) - def BuildImage(self, HTML): if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': HELP.GenericHelp(CONST.Version) @@ -211,13 +281,14 @@ class Containerize(): self.testCase_id = HTML.testCase_id - self._createWorkspace(mySSH, lPassWord, lSourcePath) + CreateWorkspace(mySSH, lSourcePath, self.ranRepository, self.ranCommitID, self.ranTargetBranch, self.ranAllowMerge) # if asterix, copy the entitlement and subscription manager configurations if self.host == 'Red Hat': - mySSH.command('mkdir -p tmp/ca/ tmp/entitlement/', '\$', 5) - mySSH.command('sudo cp /etc/rhsm/ca/redhat-uep.pem tmp/ca/', '\$', 5) - mySSH.command('sudo cp /etc/pki/entitlement/*.pem tmp/entitlement/', '\$', 5) + mySSH.command('mkdir -p ./etc-pki-entitlement ./rhsm-conf ./rhsm-ca', '\$', 5) + mySSH.command('sudo cp /etc/rhsm/rhsm.conf ./rhsm-conf/', '\$', 5) + mySSH.command('sudo cp /etc/rhsm/ca/redhat-uep.pem ./rhsm-ca/', '\$', 5) + mySSH.command('sudo cp /etc/pki/entitlement/*.pem ./etc-pki-entitlement/', '\$', 5) baseImage = 'ran-base' baseTag = 'develop' @@ -246,32 +317,10 @@ class Containerize(): if forceBaseImageBuild: mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + baseImage + ' --tag ' + baseImage + ':' + baseTag + ' --file docker/Dockerfile.base' + self.dockerfileprefix + ' . > cmake_targets/log/ran-base.log 2>&1', '\$', 1600) # First verify if the base image was properly created. - status = True mySSH.command(self.cli + ' image inspect --format=\'Size = {{.Size}} bytes\' ' + baseImage + ':' + baseTag, '\$', 5) + allImagesSize = {} if mySSH.getBefore().count('o such image') != 0: logging.error('\u001B[1m Could not build properly ran-base\u001B[0m') - status = False - else: - result = re.search('Size *= *(?P[0-9\-]+) *bytes', mySSH.getBefore()) - if result is not None: - imageSize = float(result.group('size')) - imageSize = imageSize / 1000 - if imageSize < 1000: - logging.debug('\u001B[1m ran-base size is ' + ('%.0f' % imageSize) + ' kbytes\u001B[0m') - self.allImagesSize['ran-base'] = str(round(imageSize,1)) + ' kbytes' - else: - imageSize = imageSize / 1000 - if imageSize < 1000: - logging.debug('\u001B[1m ran-base size is ' + ('%.0f' % imageSize) + ' Mbytes\u001B[0m') - self.allImagesSize['ran-base'] = str(round(imageSize,1)) + ' Mbytes' - else: - imageSize = imageSize / 1000 - logging.debug('\u001B[1m ran-base size is ' + ('%.3f' % imageSize) + ' Gbytes\u001B[0m') - self.allImagesSize['ran-base'] = str(round(imageSize,1)) + ' Gbytes' - else: - logging.debug('ran-base size is unknown') - # If the base image failed, no need to continue - if not status: # Recover the name of the failed container? mySSH.command(self.cli + ' ps --quiet --filter "status=exited" -n1 | xargs ' + self.cli + ' rm -f', '\$', 5) mySSH.command(self.cli + ' image prune --force', '\$', 30) @@ -281,20 +330,32 @@ class Containerize(): HTML.CreateHtmlTabFooter(False) sys.exit(1) else: - # Recover build logs, for the moment only possible when build is successful - mySSH.command(self.cli + ' create --name test ' + baseImage + ':' + baseTag, '\$', 5) - mySSH.command('mkdir -p cmake_targets/log/ran-base', '\$', 5) - mySSH.command(self.cli + ' cp test:/oai-ran/cmake_targets/log/. cmake_targets/log/ran-base', '\$', 5) - mySSH.command(self.cli + ' rm -f test', '\$', 5) + result = re.search('Size *= *(?P[0-9\-]+) *bytes', mySSH.getBefore()) + if result is not None: + size = float(result.group("size")) / 1000000 + imageSizeStr = f'{size:.1f}' + logging.debug(f'\u001B[1m ran-base size is {imageSizeStr} Mbytes\u001B[0m') + allImagesSize['ran-base'] = f'{imageSizeStr} Mbytes' + else: + logging.debug('ran-base size is unknown') + + # Recover build logs, for the moment only possible when build is successful + mySSH.command(self.cli + ' create --name test ' + baseImage + ':' + baseTag, '\$', 5) + mySSH.command('mkdir -p cmake_targets/log/ran-base', '\$', 5) + mySSH.command(self.cli + ' cp test:/oai-ran/cmake_targets/log/. cmake_targets/log/ran-base', '\$', 5) + mySSH.command(self.cli + ' rm -f test', '\$', 5) # Build the target image(s) + status = True + attemptedImages = ['ran-base'] for image,pattern in imageNames: + attemptedImages += [image] # the archived Dockerfiles have "ran-base:latest" as base image # we need to update them with proper tag - mySSH.command('sed -i -e "s#' + baseImage + ':latest#' + baseImage + ':' + baseTag + '#" docker/Dockerfile.' + pattern + self.dockerfileprefix, '\$', 5) + mySSH.command(f'sed -i -e "s#{baseImage}:latest#{baseImage}:{baseTag}#" docker/Dockerfile.{pattern}{self.dockerfileprefix}', '\$', 5) if image != 'ran-build': - mySSH.command('sed -i -e "s#' + "ran-build" + ':latest#' + "ran-build" + ':' + imageTag + '#" docker/Dockerfile.' + pattern + self.dockerfileprefix, '\$', 5) - mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + image + ' --tag ' + image + ':' + imageTag + ' --file docker/Dockerfile.' + pattern + self.dockerfileprefix + ' . > cmake_targets/log/' + image + '.log 2>&1', '\$', 1200) + mySSH.command(f'sed -i -e "s#ran-build:latest#ran-build:{imageTag}#" docker/Dockerfile.{pattern}{self.dockerfileprefix}', '\$', 5) + mySSH.command(f'{self.cli} build {self.cliBuildOptions} --target {image} --tag {image}:{imageTag} --file docker/Dockerfile.{pattern}{self.dockerfileprefix} . > cmake_targets/log/{image}.log 2>&1', '\$', 1200) # Flatten Image if image != 'ran-build': mySSH.command('python3 ./ci-scripts/flatten_image.py --tag ' + image + ':' + imageTag, '\$', 300) @@ -308,117 +369,43 @@ class Containerize(): status = False # Here we should check if the last container corresponds to a failed command and destroy it mySSH.command(self.cli + ' ps --quiet --filter "status=exited" -n1 | xargs ' + self.cli + ' rm -f', '\$', 5) - self.allImagesSize[image] = 'N/A -- Build Failed' + allImagesSize[image] = 'N/A -- Build Failed' + break else: result = re.search('Size *= *(?P[0-9\-]+) *bytes', mySSH.getBefore()) if result is not None: - imageSize = float(result.group('size')) - imageSize = imageSize / 1000 - if imageSize < 1000: - logging.debug('\u001B[1m ' + image + ' size is ' + ('%.0f' % imageSize) + ' kbytes\u001B[0m') - self.allImagesSize[image] = str(round(imageSize,1)) + ' kbytes' - else: - imageSize = imageSize / 1000 - if imageSize < 1000: - logging.debug('\u001B[1m ' + image + ' size is ' + ('%.0f' % imageSize) + ' Mbytes\u001B[0m') - self.allImagesSize[image] = str(round(imageSize,1)) + ' Mbytes' - else: - imageSize = imageSize / 1000 - logging.debug('\u001B[1m ' + image + ' size is ' + ('%.3f' % imageSize) + ' Gbytes\u001B[0m') - self.allImagesSize[image] = str(round(imageSize,1)) + ' Gbytes' + size = float(result.group("size")) / 1000000 + imageSizeStr = f'{size:.1f}' + logging.debug(f'\u001B[1m {image} size is {imageSizeStr} Mbytes\u001B[0m') + allImagesSize[image] = f'{imageSizeStr} Mbytes' else: - logging.debug('ran-base size is unknown') - self.allImagesSize[image] = 'unknown' + logging.debug(f'{image} size is unknown') + allImagesSize[image] = 'unknown' # Now pruning dangling images in between target builds mySSH.command(self.cli + ' image prune --force', '\$', 30) - # Analyzing the logs - mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) - mySSH.command('mkdir -p build_log_' + self.testCase_id, '\$', 5) - mySSH.command('mv log/* ' + 'build_log_' + self.testCase_id, '\$', 5) - - mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) - mySSH.command('rm -f build_log_' + self.testCase_id + '.zip || true', '\$', 5) - if (os.path.isfile('./build_log_' + self.testCase_id + '.zip')): - os.remove('./build_log_' + self.testCase_id + '.zip') - if (os.path.isdir('./build_log_' + self.testCase_id)): - shutil.rmtree('./build_log_' + self.testCase_id) - mySSH.command('zip -r -qq build_log_' + self.testCase_id + '.zip build_log_' + self.testCase_id, '\$', 5) - mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/build_log_' + self.testCase_id + '.zip', '.') - mySSH.command('rm -f build_log_' + self.testCase_id + '.zip','\$', 5) - # Remove all intermediate build images + # Remove all intermediate build images and clean up if self.ranAllowMerge and forceBaseImageBuild: - mySSH.command(self.cli + ' image rm ' + baseImage + ':' + baseTag + ' || true', '\$', 30) - mySSH.command(self.cli + ' image rm ran-build:' + imageTag + ' || true','\$', 30) - # Cleaning any created tmp volume - mySSH.command(self.cli + ' volume prune --force || true','\$', 15) - mySSH.close() - ZipFile('build_log_' + self.testCase_id + '.zip').extractall('.') + mySSH.command(f'{self.cli} image rm {baseImage}:{baseTag} || true', '\$', 30) + mySSH.command(f'{self.cli} image rm ran-build:{imageTag}','\$', 30) + mySSH.command(f'{self.cli} volume prune --force','\$', 15) - #Trying to identify the errors and warnings for each built images - imageNames1 = imageNames - base = ('ran-base','ran') - imageNames1.insert(0, base) - for image,pattern in imageNames1: - files = {} - file_list = [f for f in os.listdir('build_log_' + self.testCase_id + '/' + image) if os.path.isfile(os.path.join('build_log_' + self.testCase_id + '/' + image, f)) and f.endswith('.txt')] - for fil in file_list: - errorandwarnings = {} - warningsNo = 0 - errorsNo = 0 - with open('build_log_{}/{}/{}'.format(self.testCase_id,image,fil), mode='r') as inputfile: - for line in inputfile: - result = re.search(' ERROR ', str(line)) - if result is not None: - errorsNo += 1 - result = re.search(' error:', str(line)) - if result is not None: - errorsNo += 1 - result = re.search(' WARNING ', str(line)) - if result is not None: - warningsNo += 1 - result = re.search(' warning:', str(line)) - if result is not None: - warningsNo += 1 - errorandwarnings['errors'] = errorsNo - errorandwarnings['warnings'] = warningsNo - errorandwarnings['status'] = status - files[fil] = errorandwarnings - # Let analyze the target image creation part - if os.path.isfile('build_log_{}/{}.log'.format(self.testCase_id,image)): - errorandwarnings = {} - with open('build_log_{}/{}.log'.format(self.testCase_id,image), mode='r') as inputfile: - startOfTargetImageCreation = False - buildStatus = False - for line in inputfile: - result = re.search('FROM .* [aA][sS] ' + image + '$', str(line)) - if result is not None: - startOfTargetImageCreation = True - if startOfTargetImageCreation: - result = re.search('Successfully tagged ' + image + ':', str(line)) - if result is not None: - buildStatus = True - result = re.search('COMMIT ' + image + ':', str(line)) - if result is not None: - buildStatus = True - inputfile.close() - if buildStatus: - errorandwarnings['errors'] = 0 - else: - errorandwarnings['errors'] = 1 - errorandwarnings['warnings'] = 0 - errorandwarnings['status'] = buildStatus - files['Target Image Creation'] = errorandwarnings - self.collectInfo[image] = files + # create a zip with all logs + build_log_name = f'build_log_{self.testCase_id}' + CopyLogsToExecutor(mySSH, lSourcePath, build_log_name, lIpAddr, lUserName, lPassWord) + mySSH.close() + + # Analyze the logs + collectInfo = AnalyzeBuildLogs(build_log_name, attemptedImages, status) if status: logging.info('\u001B[1m Building OAI Image(s) Pass\u001B[0m') HTML.CreateHtmlTestRow(self.imageKind, 'OK', CONST.ALL_PROCESSES_OK) - HTML.CreateHtmlNextTabHeaderTestRow(self.collectInfo, self.allImagesSize) + HTML.CreateHtmlNextTabHeaderTestRow(collectInfo, allImagesSize) else: logging.error('\u001B[1m Building OAI Images Failed\u001B[0m') HTML.CreateHtmlTestRow(self.imageKind, 'KO', CONST.ALL_PROCESSES_OK) - HTML.CreateHtmlNextTabHeaderTestRow(self.collectInfo, self.allImagesSize) + HTML.CreateHtmlNextTabHeaderTestRow(collectInfo, allImagesSize) HTML.CreateHtmlTabFooter(False) sys.exit(1) @@ -473,7 +460,7 @@ class Containerize(): self.ranCommitID = self.proxyCommit self.ranRepository = 'https://github.com/EpiSci/oai-lte-5g-multi-ue-proxy.git' self.ranAllowMerge = False - self._createWorkspace(mySSH, lPassWord, lSourcePath) + CreateWorkspace(mySSH, lSourcePath, self.ranRepository, self.ranCommitID, self.ranTargetBranch, self.ranAllowMerge) # to prevent accidentally overwriting data that might be used later self.ranCommitID = oldRanCommidID self.ranRepository = oldRanRepository @@ -540,16 +527,18 @@ class Containerize(): errorandwarnings['warnings'] = 0 errorandwarnings['status'] = True files['Target Image Creation'] = errorandwarnings - self.collectInfo['proxy'] = files + collectInfo = {} + collectInfo['proxy'] = files mySSH.command('docker image inspect --format=\'Size = {{.Size}} bytes\' proxy:' + tag, '\$', 5) result = re.search('Size *= *(?P[0-9\-]+) *bytes', mySSH.getBefore()) + allImagesSize = {} if result is not None: imageSize = float(result.group('size')) / 1000000 logging.debug('\u001B[1m proxy size is ' + ('%.0f' % imageSize) + ' Mbytes\u001B[0m') - self.allImagesSize['proxy'] = str(round(imageSize,1)) + ' Mbytes' + allImagesSize['proxy'] = str(round(imageSize,1)) + ' Mbytes' else: logging.debug('proxy size is unknown') - self.allImagesSize['proxy'] = 'unknown' + allImagesSize['proxy'] = 'unknown' # Cleaning any created tmp volume mySSH.command(self.cli + ' volume prune --force || true','\$', 15) @@ -557,7 +546,7 @@ class Containerize(): logging.info('\u001B[1m Building L2sim Proxy Image Pass\u001B[0m') HTML.CreateHtmlTestRow('commit ' + tag, 'OK', CONST.ALL_PROCESSES_OK) - HTML.CreateHtmlNextTabHeaderTestRow(self.collectInfo, self.allImagesSize) + HTML.CreateHtmlNextTabHeaderTestRow(collectInfo, allImagesSize) def Copy_Image_to_Test_Server(self, HTML): imageTag = 'develop' @@ -579,9 +568,17 @@ class Containerize(): lUserName = self.eNB2UserName lPassWord = self.eNB2Password lSsh.open(lIpAddr, lUserName, lPassWord) - lSsh.command('docker save ' + self.imageToCopy + ':' + imageTag + ' | gzip > ' + self.imageToCopy + '-' + imageTag + '.tar.gz', '\$', 60) - lSsh.copyin(lIpAddr, lUserName, lPassWord, '~/' + self.imageToCopy + '-' + imageTag + '.tar.gz', '.') + lSsh.command('docker save ' + self.imageToCopy + ':' + imageTag + ' | gzip --fast > ' + self.imageToCopy + '-' + imageTag + '.tar.gz', '\$', 60) + ret = lSsh.copyin(lIpAddr, lUserName, lPassWord, '~/' + self.imageToCopy + '-' + imageTag + '.tar.gz', '.') + if ret != 0: + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ALL_PROCESSES_OK) + self.exitStatus = 1 + return False lSsh.command('rm ' + self.imageToCopy + '-' + imageTag + '.tar.gz', '\$', 60) + if lSsh.getBefore().count('cannot remove'): + HTML.CreateHtmlTestRow('file not created by docker save', 'KO', CONST.ALL_PROCESSES_OK) + self.exitStatus = 1 + return False lSsh.close() # Going to the Test Server @@ -599,15 +596,26 @@ class Containerize(): lPassWord = self.eNB2Password lSsh.open(lIpAddr, lUserName, lPassWord) lSsh.copyout(lIpAddr, lUserName, lPassWord, './' + self.imageToCopy + '-' + imageTag + '.tar.gz', '~') + # copyout has no return code and will quit if something fails lSsh.command('docker rmi ' + self.imageToCopy + ':' + imageTag, '\$', 10) lSsh.command('docker load < ' + self.imageToCopy + '-' + imageTag + '.tar.gz', '\$', 60) + if lSsh.getBefore().count('o such file') or lSsh.getBefore().count('invalid tar header'): + logging.debug(lSsh.getBefore()) + HTML.CreateHtmlTestRow('problem during docker load', 'KO', CONST.ALL_PROCESSES_OK) + self.exitStatus = 1 + return False lSsh.command('rm ' + self.imageToCopy + '-' + imageTag + '.tar.gz', '\$', 60) + if lSsh.getBefore().count('cannot remove'): + HTML.CreateHtmlTestRow('file not copied during scp?', 'KO', CONST.ALL_PROCESSES_OK) + self.exitStatus = 1 + return False lSsh.close() if os.path.isfile('./' + self.imageToCopy + '-' + imageTag + '.tar.gz'): os.remove('./' + self.imageToCopy + '-' + imageTag + '.tar.gz') HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) + return True def DeployObject(self, HTML, EPC): if self.eNB_serverId[self.eNB_instance] == '0': @@ -633,7 +641,7 @@ class Containerize(): mySSH = SSH.SSHConnection() mySSH.open(lIpAddr, lUserName, lPassWord) - self._createWorkspace(mySSH, lPassWord, lSourcePath) + CreateWorkspace(mySSH, lSourcePath, self.ranRepository, self.ranCommitID, self.ranTargetBranch, self.ranAllowMerge) mySSH.command('cd ' + lSourcePath + '/' + self.yamlPath[self.eNB_instance], '\$', 5) mySSH.command('cp docker-compose.yml ci-docker-compose.yml', '\$', 5) @@ -656,7 +664,7 @@ class Containerize(): result = re.search('service=(?P[a-zA-Z0-9\_]+)', mySSH.getBefore()) if result is not None: svcName = result.group('svc_name') - mySSH.command('docker-compose --file ci-docker-compose.yml up -d ' + svcName, '\$', 10) + mySSH.command('docker-compose --file ci-docker-compose.yml up -d ' + svcName, '\$', 15) # Checking Status mySSH.command('docker-compose --file ci-docker-compose.yml config', '\$', 5) @@ -683,6 +691,9 @@ class Containerize(): logging.debug(' -- ' + str(unhealthyNb) + ' unhealthy container(s)') logging.debug(' -- ' + str(startingNb) + ' still starting container(s)') + self.testCase_id = HTML.testCase_id + self.eNB_logFile[self.eNB_instance] = 'enb_' + self.testCase_id + '.log' + status = False if healthyNb == 1: cnt = 0 @@ -697,11 +708,12 @@ class Containerize(): status = True logging.info('\u001B[1m Deploying OAI object Pass\u001B[0m') time.sleep(10) + else: + # containers are unhealthy, so we won't start. However, logs are stored at the end + # in UndeployObject so we here store the logs of the unhealthy container to report it + mySSH.command('docker logs ' + containerName + ' > ' + lSourcePath + '/cmake_targets/' + self.eNB_logFile[self.eNB_instance], '\$', 30) mySSH.close() - self.testCase_id = HTML.testCase_id - self.eNB_logFile[self.eNB_instance] = 'enb_' + self.testCase_id + '.log' - if status: HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) else: diff --git a/ci-scripts/cls_oai_html.py b/ci-scripts/cls_oai_html.py index 13a1ab8691..536f2ff49e 100644 --- a/ci-scripts/cls_oai_html.py +++ b/ci-scripts/cls_oai_html.py @@ -453,13 +453,11 @@ class HTMLManagement(): self.htmlFile.write(' ' + str(parameters['warnings']) + '\n') elif (parameters['warnings'] == 0): self.htmlFile.write(' ' + str(parameters['warnings']) + '\n') - elif ((parameters['warnings'] > 0) and (parameters['warnings'] <= 20)): - self.htmlFile.write(' ' + str(parameters['warnings']) + '\n') else: - self.htmlFile.write(' ' + str(parameters['warnings']) + '\n') + self.htmlFile.write(' ' + str(parameters['warnings']) + '\n') if (parameters['errors'] == 0) and (parameters['warnings'] == 0): self.htmlFile.write(' OK \n') - elif (parameters['errors'] == 0) and ((parameters['warnings'] > 0) and (parameters['warnings'] <= 20)): + elif (parameters['errors'] == 0): self.htmlFile.write(' OK \n') else: self.htmlFile.write(' NOT OK \n') diff --git a/ci-scripts/cls_physim.py b/ci-scripts/cls_physim.py index 0342333c06..14abd9116e 100644 --- a/ci-scripts/cls_physim.py +++ b/ci-scripts/cls_physim.py @@ -56,7 +56,6 @@ class PhySim: self.__workSpacePath='' self.__buildLogFile='compile_phy_sim.log' self.__runLogFile='' - self.__runResults=[] self.__runLogPath='phy_sim_logs' @@ -64,20 +63,20 @@ class PhySim: #PRIVATE Methods #----------------- - def __CheckResults_PhySim(self,HTML,CONST,testcase_id): + def __CheckResults_LDPCTest(self,HTML,CONST,testcase_id): mySSH = sshconnection.SSHConnection() mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) #retrieve run log file and store it locally$ mySSH.copyin(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord, self.__workSpacePath+self.__runLogFile, '.') mySSH.close() #parse results looking for Encoding and Decoding mean values - self.__runResults=[] + runResults=[] with open(self.__runLogFile) as f: for line in f: if 'mean' in line: - self.__runResults.append(line) + runResults.append(line) #the values are appended for each mean value (2), so we take these 2 values from the list - info=self.__runResults[0]+self.__runResults[1] + info = runResults[0] + runResults[1] #once parsed move the local logfile to its folder for tidiness os.system('mv '+self.__runLogFile+' '+ self.__runLogPath+'/.') @@ -89,6 +88,38 @@ class PhySim: HTML.CreateHtmlTestRowQueue(self.runargs, 'OK', 1, html_queue) return HTML + def __CheckResults_NRulsimTest(self, HTML, CONST, testcase_id): + html_queue = SimpleQueue() + #retrieve run log file and store it locally + mySSH = sshconnection.SSHConnection() + filename = self.__workSpacePath + self.__runLogFile + ret = mySSH.copyin(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord, filename, '.') + if ret != 0: + error_msg = f'could not recover test result file {filename}' + logging.error(error_msg) + html_queue.put(f'
{error_msg}
') + HTML.CreateHtmlTestRowQueue("could not recover results", 'KO', 1, html_queue) + self.exitStatus = 1 + return HTML + + PUSCH_OK = False + with open(self.__runLogFile) as f: + PUSCH_OK = 'PUSCH test OK' in f.read() + + # once parsed move the local logfile to its folder for tidiness + os.system(f'mv {self.__runLogFile} {self.__runLogPath}/.') + + #updating the HTML with results + if PUSCH_OK: + html_queue.put('
succeeded
') + HTML.CreateHtmlTestRowQueue(self.runargs, 'OK', 1, html_queue) + else: + error_msg = 'error: no "PUSCH test OK"' + logging.error(error_msg) + html_queue.put(f'
{error_msg}
') + HTML.CreateHtmlTestRowQueue(self.runargs, 'KO', 1, html_queue) + self.exitStatus = 1 + return HTML def __CheckBuild_PhySim(self, HTML, CONST): self.__workSpacePath=self.eNBSourceCodePath+'/cmake_targets/' @@ -100,21 +131,16 @@ class PhySim: mySSH.command('rm ' + self.__workSpacePath+self.__runLogFile, '\$', 5) mySSH.close() #check build result from local compile log file - buildStatus=False with open(self.__buildLogFile) as f: - #nr_prachsim is the last compile step - if 'nr_prachsim compiled' in f.read(): - buildStatus=True - #update HTML based on build status - if buildStatus: - HTML.CreateHtmlTestRow(self.buildargs, 'OK', CONST.ALL_PROCESSES_OK, 'LDPC') - self.exitStatus=0 - else: - logging.error('\u001B[1m Building Physical Simulators Failed\u001B[0m') - HTML.CreateHtmlTestRow(self.buildargs, 'KO', CONST.ALL_PROCESSES_OK, 'LDPC') - HTML.CreateHtmlTabFooter(False) - #exitStatus=1 will do a sys.exit in main - self.exitStatus=1 + if 'BUILD SHOULD BE SUCCESSFUL' in f.read(): + HTML.CreateHtmlTestRow(self.buildargs, 'OK', CONST.ALL_PROCESSES_OK, 'PhySim') + self.exitStatus=0 + return HTML + logging.error('\u001B[1m Building Physical Simulators Failed\u001B[0m') + HTML.CreateHtmlTestRow(self.buildargs, 'KO', CONST.ALL_PROCESSES_OK, 'LDPC') + HTML.CreateHtmlTabFooter(False) + #exitStatus=1 will do a sys.exit in main + self.exitStatus = 1 return HTML @@ -163,8 +189,7 @@ class PhySim: mySSH.command('source oaienv', '\$', 5) mySSH.command('cd cmake_targets', '\$', 5) mySSH.command('mkdir -p log', '\$', 5) - mySSH.command('chmod 777 log', '\$', 5) - mySSH.command('stdbuf -o0 ./build_oai ' + self.buildargs + ' 2>&1 | stdbuf -o0 tee ' + self.__buildLogFile, 'Bypassing the Tests|build have failed', 1500) + mySSH.command(f'./build_oai {self.buildargs} 2>&1 | tee {self.__buildLogFile}', '\$', 1500) mySSH.close() #check build status and update HTML object @@ -173,7 +198,8 @@ class PhySim: return lHTML - def Run_PhySim(self,htmlObj,constObj,testcase_id): + def Run_LDPCTest(self,htmlObj,constObj,testcase_id): + self.__workSpacePath = self.eNBSourceCodePath+'/cmake_targets/' #create run logs folder locally os.system('mkdir -p ./'+self.__runLogPath) #log file is tc_.log remotely @@ -187,5 +213,18 @@ class PhySim: mySSH.close() #return updated HTML to main lHTML = cls_oai_html.HTMLManagement() - lHTML=self.__CheckResults_PhySim(htmlObj,constObj,testcase_id) + lHTML=self.__CheckResults_LDPCTest(htmlObj,constObj,testcase_id) + return lHTML + + def Run_NRulsimTest(self, htmlObj, constObj, testcase_id): + self.__workSpacePath=self.eNBSourceCodePath+'/cmake_targets/' + os.system(f'mkdir -p ./{self.__runLogPath}') + self.__runLogFile = f'physim_{testcase_id}.log' + mySSH = sshconnection.SSHConnection() + mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) + mySSH.command(f'cd {self.__workSpacePath}', '\$', 5) + mySSH.command(f'sudo {self.__workSpacePath}ran_build/build/nr_ulsim {self.runargs} > {self.__runLogFile} 2>&1', '\$', 30) + mySSH.close() + #return updated HTML to main + lHTML = self.__CheckResults_NRulsimTest(htmlObj, constObj, testcase_id) return lHTML diff --git a/ci-scripts/cls_physim1.py b/ci-scripts/cls_physim1.py index 3907fc2a34..56934fcd22 100644 --- a/ci-scripts/cls_physim1.py +++ b/ci-scripts/cls_physim1.py @@ -115,33 +115,9 @@ class PhySim: mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) else: imageTag = "develop" - # Check if image is exist on the Red Hat server, before pushing it to OC cluster - mySSH.command('sudo podman image inspect --format="Size = {{.Size}} bytes" oai-physim:' + imageTag, '\$', 60) - if mySSH.getBefore().count('no such image') != 0: - logging.error('\u001B[1m No such image oai-physim\u001B[0m') - mySSH.close() - HTML.CreateHtmlTestRow('N/A', 'KO', CONST.PHYSIM_IMAGE_ABSENT) - RAN.prematureExit = True - return - else: - result = re.search('Size *= *(?P[0-9\-]+) *bytes', mySSH.getBefore()) - if result is not None: - imageSize = float(result.group('size')) - imageSize = imageSize / 1000 - if imageSize < 1000: - logging.debug('\u001B[1m oai-physim size is ' + ('%.0f' % imageSize) + ' kbytes\u001B[0m') - else: - imageSize = imageSize / 1000 - if imageSize < 1000: - logging.debug('\u001B[1m oai-physim size is ' + ('%.0f' % imageSize) + ' Mbytes\u001B[0m') - else: - imageSize = imageSize / 1000 - logging.debug('\u001B[1m oai-physim is ' + ('%.3f' % imageSize) + ' Gbytes\u001B[0m') - else: - logging.debug('oai-physim size is unknown') # logging to OC Cluster and then switch to corresponding project - mySSH.command(f'oc login -u {ocUserName} -p {ocPassword}', '\$', 30) + mySSH.command(f'oc login -u {ocUserName} -p {ocPassword} --server https://api.oai.cs.eurecom.fr:6443', '\$', 30) if mySSH.getBefore().count('Login successful.') == 0: logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m') mySSH.close() @@ -161,46 +137,7 @@ class PhySim: else: logging.debug(f'\u001B[1m Now using project {ocProjectName}\u001B[0m') - # Tag the image and push to the OC cluster - mySSH.command('oc whoami -t | sudo podman login -u ' + ocUserName + ' --password-stdin https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/ --tls-verify=false', '\$', 30) - if mySSH.getBefore().count('Login Succeeded!') == 0: - logging.error('\u001B[1m Podman Login to OC Cluster Registry Failed\u001B[0m') - mySSH.command('oc logout', '\$', 30) - mySSH.close() - HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL) - RAN.prematureExit = True - return - else: - logging.debug('\u001B[1m Podman Login to OC Cluster Registry Successfully\u001B[0m') - time.sleep(2) - mySSH.command('oc create -f openshift/oai-physim-image-stream.yml || true', '\$', 30) - if mySSH.getBefore().count('(AlreadyExists):') == 0 and mySSH.getBefore().count('created') == 0: - logging.error(f'\u001B[1m Image Stream "oai-physim" Creation Failed on OC Cluster {ocProjectName}\u001B[0m') - mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6) - mySSH.command('oc logout', '\$', 30) - mySSH.close() - HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_IS_FAIL) - RAN.prematureExit = True - return - else: - logging.debug(f'\u001B[1m Image Stream "oai-physim" created on OC project {ocProjectName}\u001B[0m') - time.sleep(2) - mySSH.command(f'sudo podman tag oai-physim:{imageTag} default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 30) - time.sleep(2) - mySSH.command(f'sudo podman push default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag} --tls-verify=false', '\$', 180) - if mySSH.getBefore().count('Storing signatures') == 0: - logging.error('\u001B[1m Image "oai-physim" push to OC Cluster Registry Failed\u001B[0m') - mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6) - mySSH.command('oc logout', '\$', 30) - mySSH.close() - HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_IS_FAIL) - RAN.prematureExit = True - return - else: - logging.debug('\u001B[1m Image "oai-physim" push to OC Cluster Registry Successfully\u001B[0m') - # Using helm charts deployment - time.sleep(5) mySSH.command(f'grep -rl OAICICD_PROJECT ./charts/ | xargs sed -i -e "s#OAICICD_PROJECT#{ocProjectName}#"', '\$', 30) mySSH.command(f'sed -i -e "s#TAG#{imageTag}#g" ./charts/physims/values.yaml', '\$', 6) mySSH.command('helm install physim ./charts/physims/ 2>&1 | tee -a cmake_targets/log/physim_helm_summary.txt', '\$', 30) @@ -213,9 +150,6 @@ class PhySim: mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6, resync=True) if re.search('No resources found', mySSH.getBefore()): isFinished1 = True - mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 30) - mySSH.command('oc delete is oai-physim', '\$', 30) - mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6) mySSH.command('oc logout', '\$', 30) mySSH.close() self.AnalyzeLogFile_phySim(HTML) @@ -244,9 +178,6 @@ class PhySim: mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6, resync=True) if re.search('No resources found', mySSH.getBefore()): isFinished1 = True - mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6) - mySSH.command('oc delete is oai-physim', '\$', 6) - mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6) mySSH.command('oc logout', '\$', 30) HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PHYSIM_DEPLOY_FAIL) HTML.CreateHtmlTestRowPhySimTestResult(self.testSummary,self.testResult) @@ -304,10 +235,6 @@ class PhySim: isFinished1 = True if isFinished1 == True: logging.debug('\u001B[1m UnDeployed PhySim Successfully on OC Cluster\u001B[0m') - mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6) - mySSH.command('oc delete is oai-physim', '\$', 6) - logging.debug('\u001B[1m Deleted the Image and ImageStream\u001B[0m') - mySSH.command('sudo podman logout https://default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/', '\$', 6) mySSH.command('oc logout', '\$', 6) mySSH.close() self.AnalyzeLogFile_phySim(HTML) diff --git a/ci-scripts/cls_static_code_analysis.py b/ci-scripts/cls_static_code_analysis.py index 5b45b48ba6..131f2d72bc 100644 --- a/ci-scripts/cls_static_code_analysis.py +++ b/ci-scripts/cls_static_code_analysis.py @@ -321,20 +321,6 @@ class StaticCodeAnalysis(): if ret is not None: analyzed = True if analyzed: - ret = re.search('Nb Files that do NOT follow OAI rules: (?P[0-9\.]+)', str(line)) - if ret is not None: - nbFilesNotFormatted = int(ret.group('nb_errors')) - - if re.search('=== Files not properly formatted ===', str(line)) is not None: - listFiles = True - if listFiles: - if re.search('Removing intermediate container', str(line)) is not None: - listFiles = False - elif re.search('Running in|Files not properly formatted', str(line)) is not None: - pass - else: - listFilesNotFormatted.append(str(line).strip()) - if re.search('=== Files with incorrect define protection ===', str(line)) is not None: circularHeaderDependency = True if circularHeaderDependency: diff --git a/ci-scripts/conf_files/benetel-5g.conf b/ci-scripts/conf_files/benetel-5g.conf index 3b872e56e9..cae4ec0b25 100644 --- a/ci-scripts/conf_files/benetel-5g.conf +++ b/ci-scripts/conf_files/benetel-5g.conf @@ -214,7 +214,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; } ); diff --git a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf index e92585b5fe..016f1e9b1f 100644 --- a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -11,22 +11,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 40960; - plmn_list = ({ - mcc = 208; - mnc = 95; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 95; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; diff --git a/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf index 7b6e045ffc..50dba38a51 100644 --- a/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/episci/proxy_gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -11,22 +11,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; diff --git a/ci-scripts/conf_files/gNB_SA_CU.conf b/ci-scripts/conf_files/gNB_SA_CU.conf index f6d3e8575a..27b079d026 100644 --- a/ci-scripts/conf_files/gNB_SA_CU.conf +++ b/ci-scripts/conf_files/gNB_SA_CU.conf @@ -15,22 +15,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; diff --git a/ci-scripts/conf_files/gNB_SA_DU.conf b/ci-scripts/conf_files/gNB_SA_DU.conf index 4309c13dd3..5a96090b36 100644 --- a/ci-scripts/conf_files/gNB_SA_DU.conf +++ b/ci-scripts/conf_files/gNB_SA_DU.conf @@ -14,22 +14,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; @@ -204,8 +189,7 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; - prach_dtx_threshold = 120; + prach_dtx_threshold = 200; pucch0_dtx_threshold = 150; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } diff --git a/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf b/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf index 49383072ed..f0dbbcaf06 100644 --- a/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf +++ b/ci-scripts/conf_files/gNB_SA_n78_106PRB.2x2_usrpn310.conf @@ -15,21 +15,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L @@ -231,7 +217,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; prach_dtx_threshold = 120; pucch0_dtx_threshold = 150; } diff --git a/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf b/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf index 610485fc92..ff5e804f19 100644 --- a/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf +++ b/ci-scripts/conf_files/gNB_SA_n78_133PRB.2x2_usrpn310.conf @@ -16,21 +16,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L @@ -228,7 +214,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; prach_dtx_threshold = 120; } ); diff --git a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf index 24ec8f17f8..eeb562b4a4 100644 --- a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf @@ -211,7 +211,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf index b3c7d7d1da..f4f65fe8dc 100644 --- a/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf @@ -181,7 +181,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf index c668601c06..b8cc0de15e 100644 --- a/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.nsa_2x2.106PRB.usrpn310.conf @@ -210,7 +210,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; prach_dtx_threshold = 120; pucch0_dtx_threshold = 80; } diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf index 92c3a7a2e9..5f2e43fbf1 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.asue.conf @@ -15,25 +15,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 97; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - }); + plmn_list = ({ mcc = 208; mnc = 97; mnc_length = 2; snssaiList = ({ sst = 1, sd = 0x010203 }) }); nr_cellid = 12345678L @@ -237,7 +219,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; prach_dtx_threshold = 120; # pucch0_dtx_threshold = 150; } diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf index 672713d504..ffe5234a21 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf @@ -15,21 +15,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 97; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - }); + plmn_list = ({ mcc = 208; mnc = 97; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L @@ -234,7 +220,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; prach_dtx_threshold = 120; # pucch0_dtx_threshold = 150; } diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf index 5bd8b26e05..2ca4471c61 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.ddsuu.2x2.usrpn310.conf @@ -15,21 +15,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 97; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - }); + plmn_list = ({ mcc = 208; mnc = 97; mnc_length = 2; snssaiList = ({ sst = 1, sd = 0x010203 }) }); nr_cellid = 12345678L @@ -233,7 +219,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; prach_dtx_threshold = 120; # pucch0_dtx_threshold = 150; } diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf index e1264bd069..3b2226eb6b 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -15,21 +15,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 97; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - }); + plmn_list = ({ mcc = 208; mnc = 97; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L @@ -237,7 +223,7 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - prach_dtx_threshold = 120; + prach_dtx_threshold = 200; # pucch0_dtx_threshold = 150; } ); diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf index f92242138c..256dfd5dc8 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf @@ -15,21 +15,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 97; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - }); + plmn_list = ({ mcc = 208; mnc = 97; mnc_length = 2; snssaiList = ({ sst = 1, sd = 0x010203 }) }); nr_cellid = 12345678L @@ -235,7 +221,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; prach_dtx_threshold = 120; # pucch0_dtx_threshold = 150; } diff --git a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf index 9334f2cf59..61bb39329e 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf @@ -194,7 +194,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; } ); diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf index cd3ab6278e..92362ebdc9 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf @@ -210,7 +210,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 6; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf index 371753eccc..361cee72e6 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf @@ -211,7 +211,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 6; } ); diff --git a/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf index 6b7122341d..787701fc9c 100644 --- a/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.sa.band66.fr1.106PRB.usrpn300.conf @@ -11,22 +11,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 95; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - }, - { - sst = 2; - sd = 2; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 95; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; @@ -218,6 +203,7 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; pusch_proc_threads = 8; + prach_dtx_threshold = 200; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/ci-scripts/conf_files/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.sa.band78.fr1.106PRB.usrpb210.conf index 2a6053ab46..3ec265f12c 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.fr1.106PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.fr1.106PRB.usrpb210.conf @@ -11,18 +11,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 222; - mnc = 01; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - #sd = 0x1; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 222; mnc = 01; mnc_length = 2; snssaiList = ({ sst = 1; }) }); nr_cellid = 12345678L; diff --git a/ci-scripts/conf_files/gnb.sa.band78.fr1.24PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.sa.band78.fr1.24PRB.usrpb210.conf index ad1471339a..1defbf91ed 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.fr1.24PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.fr1.24PRB.usrpb210.conf @@ -11,22 +11,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; diff --git a/ci-scripts/conf_files/nr-ue-sim.conf b/ci-scripts/conf_files/nr-ue-sim.conf index 05ac825db4..884430bf39 100644 --- a/ci-scripts/conf_files/nr-ue-sim.conf +++ b/ci-scripts/conf_files/nr-ue-sim.conf @@ -4,5 +4,4 @@ uicc0 = { opc= "@OPC@"; dnn= "@DNN@"; nssai_sst=@NSSAI_SST@; - nssai_sd=@NSSAI_SD@; } diff --git a/ci-scripts/constants.py b/ci-scripts/constants.py index a7ce01615e..17a4ea33fa 100644 --- a/ci-scripts/constants.py +++ b/ci-scripts/constants.py @@ -79,3 +79,7 @@ X2_HO_REQ_STATE__TARGET_RECEIVES_REQ = 1 X2_HO_REQ_STATE__TARGET_RRC_RECFG_COMPLETE = 2 X2_HO_REQ_STATE__TARGET_SENDS_SWITCH_REQ = 3 X2_HO_REQ_STATE__SOURCE_RECEIVES_REQ_ACK = 10 + +# placeholder for a "don't care" password to gradually transition to +# passwordless CI +CI_NO_PASSWORD = "CIPASSWORDDONTCARE" diff --git a/ci-scripts/docker/Dockerfile.formatting.bionic b/ci-scripts/docker/Dockerfile.formatting.bionic index 01417a3bdb..47fd2a08d0 100644 --- a/ci-scripts/docker/Dockerfile.formatting.bionic +++ b/ci-scripts/docker/Dockerfile.formatting.bionic @@ -8,7 +8,6 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \ - astyle \ gawk \ git @@ -18,9 +17,6 @@ COPY . . RUN /bin/bash -c "if [[ -v MERGE_REQUEST ]]; then echo 'Source Branch = $SRC_BRANCH'; echo 'Target Branch = $TARGET_BRANCH'; else echo 'Push to develop'; fi" RUN /bin/bash -c "if [[ -v MERGE_REQUEST ]]; then ./ci-scripts/checkCodingFormattingRules.sh --src-branch $SRC_BRANCH --target-branch $TARGET_BRANCH; else ./ci-scripts/checkCodingFormattingRules.sh; fi" -RUN echo "=== Files not properly formatted ===" && \ - /bin/bash -c "if [[ -f oai_rules_result_list.txt ]]; then cat oai_rules_result_list.txt; fi" - RUN echo "=== Files with incorrect define protection ===" && \ /bin/bash -c "if [[ -f header-files-w-incorrect-define.txt ]]; then cat header-files-w-incorrect-define.txt; fi" diff --git a/ci-scripts/epc.py b/ci-scripts/epc.py index 9113d29ac9..a636bf9433 100644 --- a/ci-scripts/epc.py +++ b/ci-scripts/epc.py @@ -253,7 +253,7 @@ class EPCManagement(): logging.debug('Starting OAI CN5G') mySSH.command('if [ -d ' + self.SourceCodePath + '/scripts ]; then echo ' + self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath + '/scripts ; fi', '\$', 5) mySSH.command('mkdir -p ' + self.SourceCodePath + '/scripts', '\$', 5) - mySSH.command('cd /opt/oai-cn5g-fed-v1.3/docker-compose', '\$', 5) + mySSH.command('cd /opt/oai-cn5g-fed-v1.4/docker-compose', '\$', 5) mySSH.command('python3 ./core-network.py '+self.cfgDeploy, '\$', 60) if re.search('start-mini-as-ue', self.cfgDeploy): dFile = 'docker-compose-mini-nrf-asue.yaml' @@ -537,7 +537,7 @@ class EPCManagement(): mySSH.command('docker logs ' + c + ' > ' + self.SourceCodePath + '/logs/' + c + '.log', '\$', 5) logging.debug('Terminating OAI CN5G') - mySSH.command('cd /opt/oai-cn5g-fed-v1.3/docker-compose', '\$', 5) + mySSH.command('cd /opt/oai-cn5g-fed-v1.4/docker-compose', '\$', 5) mySSH.command('python3 ./core-network.py '+self.cfgUnDeploy, '\$', 60) mySSH.command('docker volume prune --force || true', '\$', 60) time.sleep(2) diff --git a/ci-scripts/main.py b/ci-scripts/main.py index baed6a6011..b5d0ef2d97 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -45,6 +45,7 @@ import cls_containerize #class Containerize for all container-based oper import cls_static_code_analysis #class for static code analysis import cls_ci_ueinfra #class defining the multi Ue infrastrucure import cls_physim1 #class PhySim for physical simulators deploy and run +import cls_cluster # class for building/deploying on cluster import sshconnection import epc @@ -102,20 +103,17 @@ def AssignParams(params_dict): def GetParametersFromXML(action): - if action == 'Build_eNB' or action == 'Build_Image' or action == 'Build_Proxy': + if action == 'Build_eNB' or action == 'Build_Image' or action == 'Build_Proxy' or action == "Build_Cluster_Image": RAN.Build_eNB_args=test.findtext('Build_eNB_args') CONTAINERS.imageKind=test.findtext('kind') forced_workspace_cleanup = test.findtext('forced_workspace_cleanup') - if (forced_workspace_cleanup is None): - RAN.Build_eNB_forced_workspace_cleanup=False - CONTAINERS.forcedWorkspaceCleanup=False - else: - if re.match('true', forced_workspace_cleanup, re.IGNORECASE): - RAN.Build_eNB_forced_workspace_cleanup=True - CONTAINERS.forcedWorkspaceCleanup=True - else: - RAN.Build_eNB_forced_workspace_cleanup=True - CONTAINERS.forcedWorkspaceCleanup=False + RAN.Build_eNB_forced_workspace_cleanup=False + CONTAINERS.forcedWorkspaceCleanup=False + CLUSTER.forcedWorkspaceCleanup = False + if forced_workspace_cleanup is not None and re.match('true', forced_workspace_cleanup, re.IGNORECASE): + RAN.Build_eNB_forced_workspace_cleanup = True + CONTAINERS.forcedWorkspaceCleanup = True + CLUSTER.forcedWorkspaceCleanup = True eNB_instance=test.findtext('eNB_instance') if (eNB_instance is None): RAN.eNB_instance=0 @@ -457,9 +455,18 @@ def GetParametersFromXML(action): if (string_field is not None): CONTAINERS.testSvrId = string_field - else: # ie action == 'Run_PhySim': + elif action == 'Run_LDPCTest' or action == 'Run_NRulsimTest': ldpc.runargs = test.findtext('physim_run_args') - + + elif action == 'LicenceAndFormattingCheck': + pass + + elif action == 'Cppcheck_Analysis': + pass + + else: + logging.error(f"unknown action {action}") + #check if given test is in list #it is in list if one of the strings in 'list' is at the beginning of 'test' @@ -525,6 +532,7 @@ HTML = cls_oai_html.HTMLManagement() CONTAINERS = cls_containerize.Containerize() SCA = cls_static_code_analysis.StaticCodeAnalysis() PHYSIM = cls_physim1.PhySim() +CLUSTER = cls_cluster.Cluster() ldpc=cls_physim.PhySim() #create an instance for LDPC test using GPU or CPU build @@ -534,7 +542,7 @@ ldpc=cls_physim.PhySim() #create an instance for LDPC test using GPU or CPU b #----------------------------------------------------------- import args_parse -py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM) +py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM,CLUSTER) @@ -914,14 +922,25 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re HTML=ldpc.Build_PhySim(HTML,CONST) if ldpc.exitStatus==1: RAN.prematureExit = True - elif action == 'Run_PhySim': - HTML=ldpc.Run_PhySim(HTML,CONST,id) + elif action == 'Run_LDPCTest': + HTML=ldpc.Run_LDPCTest(HTML,CONST,id) + if ldpc.exitStatus==1: + RAN.prematureExit = True + elif action == 'Run_NRulsimTest': + HTML=ldpc.Run_NRulsimTest(HTML,CONST,id) + if ldpc.exitStatus==1: + RAN.prematureExit = True + elif action == 'Build_Cluster_Image': + if not CLUSTER.BuildClusterImage(HTML): + RAN.prematureExit = True elif action == 'Build_Image': CONTAINERS.BuildImage(HTML) elif action == 'Build_Proxy': CONTAINERS.BuildProxy(HTML) elif action == 'Copy_Image_to_Test': - CONTAINERS.Copy_Image_to_Test_Server(HTML) + success = CONTAINERS.Copy_Image_to_Test_Server(HTML) + if not success: + RAN.prematureExit = True elif action == 'Deploy_Object': CONTAINERS.DeployObject(HTML, EPC) if CONTAINERS.exitStatus==1: diff --git a/ci-scripts/reportBuildLocally.sh b/ci-scripts/reportBuildLocally.sh index bcd3e2f7fe..894eb85be1 100755 --- a/ci-scripts/reportBuildLocally.sh +++ b/ci-scripts/reportBuildLocally.sh @@ -463,106 +463,75 @@ function report_build { echo " " >> ./build_results.html echo "

Build Summary

" >> ./build_results.html - if [ -f ./oai_rules_result.txt ] + echo "

OAI Coding / Formatting Guidelines Check

" >> ./build_results.html + if [ -f ./header-files-w-incorrect-define.txt ] then - echo "

OAI Coding / Formatting Guidelines Check

" >> ./build_results.html - NB_FILES=`cat ./oai_rules_result.txt` - if [ $NB_FILES = "0" ] - then + NB_FILES_IN_ERROR=`wc -l ./header-files-w-incorrect-define.txt | sed -e "s@ .*@@"` + if [ $NB_FILES_IN_ERROR -eq 0 ] + then echo "
" >> ./build_results.html - if [ $PU_TRIG -eq 1 ]; then echo " All files in repository follow OAI rules. " >> ./build_results.html; fi - if [ $MR_TRIG -eq 1 ]; then echo " All modified files in Merge-Request follow OAI rules. " >> ./build_results.html; fi + if [ $MR_TRIG -eq 1 ]; then echo " No Issue for CIRCULAR DEPENDENCY PROTECTION in modified files" >> ./build_results.html; fi + if [ $PU_TRIG -eq 1 ]; then echo " No Issue for CIRCULAR DEPENDENCY PROTECTION in the whole repository" >> ./build_results.html; fi echo "
" >> ./build_results.html else echo "
" >> ./build_results.html - if [ $PU_TRIG -eq 1 ]; then echo " $NB_FILES files in repository DO NOT follow OAI rules. " >> ./build_results.html; fi - if [ $MR_TRIG -eq 1 ]; then echo " $NB_FILES modified files in Merge-Request DO NOT follow OAI rules. " >> ./build_results.html; fi + if [ $MR_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} modified files MAY NOT HAVE CIRCULAR DEPENDENCY PROTECTION" >> ./build_results.html; fi + if [ $PU_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} files in repository MAY NOT HAVE CIRCULAR DEPENDENCY PROTECTION in the whole repository" >> ./build_results.html; fi echo "
" >> ./build_results.html - fi - if [ -f ./oai_rules_result_list.txt ] - then - echo " " >> ./build_results.html - echo "
" >> ./build_results.html - echo "

Please apply the following command to this(ese) file(s):

" >> ./build_results.html - echo "

astyle --options=ci-scripts/astyle-options.txt filename(s)

" >> ./build_results.html + echo " " >> ./build_results.html + echo "
" >> ./build_results.html echo " " >> ./build_results.html echo " " >> ./build_results.html - echo " " >> ./build_results.html + echo " " >> ./build_results.html + echo " " >> ./build_results.html + echo " " >> ./build_results.html echo " " >> ./build_results.html - awk '{print " "}' ./oai_rules_result_list.txt >> ./build_results.html + awk '{if($0 ~/error in/){print " "};if($0 ~/files with same/){print " "}}' ./header-files-w-incorrect-define.txt >> ./build_results.html echo "
FilenamePotential IssueImpacted FileIncorrect Macro
"$1"
error in declaration"$4""$5"
files with same #define"$5""$6"
" >> ./build_results.html echo "
" >> ./build_results.html echo "
" >> ./build_results.html fi - if [ -f ./header-files-w-incorrect-define.txt ] + fi + if [ -f ./files-w-gnu-gpl-license-banner.txt ] + then + NB_FILES_IN_ERROR=`wc -l ./files-w-gnu-gpl-license-banner.txt | sed -e "s@ .*@@"` + if [ $NB_FILES_IN_ERROR -ne 0 ] then - NB_FILES_IN_ERROR=`wc -l ./header-files-w-incorrect-define.txt | sed -e "s@ .*@@"` - if [ $NB_FILES_IN_ERROR -eq 0 ] - then - echo "
" >> ./build_results.html - if [ $MR_TRIG -eq 1 ]; then echo " No Issue for CIRCULAR DEPENDENCY PROTECTION in modified files" >> ./build_results.html; fi - if [ $PU_TRIG -eq 1 ]; then echo " No Issue for CIRCULAR DEPENDENCY PROTECTION in the whole repository" >> ./build_results.html; fi - echo "
" >> ./build_results.html - else - echo "
" >> ./build_results.html - if [ $MR_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} modified files MAY NOT HAVE CIRCULAR DEPENDENCY PROTECTION" >> ./build_results.html; fi - if [ $PU_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} files in repository MAY NOT HAVE CIRCULAR DEPENDENCY PROTECTION in the whole repository" >> ./build_results.html; fi - echo "
" >> ./build_results.html - echo " " >> ./build_results.html - echo "
" >> ./build_results.html - echo " " >> ./build_results.html - echo " " >> ./build_results.html - echo " " >> ./build_results.html - echo " " >> ./build_results.html - echo " " >> ./build_results.html - echo " " >> ./build_results.html - awk '{if($0 ~/error in/){print " "};if($0 ~/files with same/){print " "}}' ./header-files-w-incorrect-define.txt >> ./build_results.html - echo "
Potential IssueImpacted FileIncorrect Macro
error in declaration"$4""$5"
files with same #define"$5""$6"
" >> ./build_results.html - echo "
" >> ./build_results.html - echo "
" >> ./build_results.html - fi + echo "
" >> ./build_results.html + if [ $MR_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} modified files HAVE a GNU GPL license banner" >> ./build_results.html; fi + if [ $PU_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} files in repository HAVE a GNU GPL license banner" >> ./build_results.html; fi + echo "
" >> ./build_results.html + echo " " >> ./build_results.html + echo "
" >> ./build_results.html + echo " " >> ./build_results.html + echo " " >> ./build_results.html + echo " " >> ./build_results.html + echo " " >> ./build_results.html + awk '{print " "}' ./files-w-gnu-gpl-license-banner.txt >> ./build_results.html + echo "
Filename
"$1"
" >> ./build_results.html + echo "
" >> ./build_results.html + echo "
" >> ./build_results.html fi - if [ -f ./files-w-gnu-gpl-license-banner.txt ] + fi + if [ -f ./files-w-suspect-banner.txt ] + then + NB_FILES_IN_ERROR=`wc -l ./files-w-suspect-banner.txt | sed -e "s@ .*@@"` + if [ $NB_FILES_IN_ERROR -ne 0 ] then - NB_FILES_IN_ERROR=`wc -l ./files-w-gnu-gpl-license-banner.txt | sed -e "s@ .*@@"` - if [ $NB_FILES_IN_ERROR -ne 0 ] - then - echo "
" >> ./build_results.html - if [ $MR_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} modified files HAVE a GNU GPL license banner" >> ./build_results.html; fi - if [ $PU_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} files in repository HAVE a GNU GPL license banner" >> ./build_results.html; fi - echo "
" >> ./build_results.html - echo " " >> ./build_results.html - echo "
" >> ./build_results.html - echo " " >> ./build_results.html - echo " " >> ./build_results.html - echo " " >> ./build_results.html - echo " " >> ./build_results.html - awk '{print " "}' ./files-w-gnu-gpl-license-banner.txt >> ./build_results.html - echo "
Filename
"$1"
" >> ./build_results.html - echo "
" >> ./build_results.html - echo "
" >> ./build_results.html - fi - fi - if [ -f ./files-w-suspect-banner.txt ] - then - NB_FILES_IN_ERROR=`wc -l ./files-w-suspect-banner.txt | sed -e "s@ .*@@"` - if [ $NB_FILES_IN_ERROR -ne 0 ] - then - echo "
" >> ./build_results.html - if [ $MR_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} modified files HAVE a suspect license banner" >> ./build_results.html; fi - if [ $PU_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} files in repository HAVE a suspect license banner" >> ./build_results.html; fi - echo "
" >> ./build_results.html - echo " " >> ./build_results.html - echo "
" >> ./build_results.html - echo " " >> ./build_results.html - echo " " >> ./build_results.html - echo " " >> ./build_results.html - echo " " >> ./build_results.html - awk '{print " "}' ././files-w-suspect-banner.txt >> ./build_results.html - echo "
Filename
"$1"
" >> ./build_results.html - echo "
" >> ./build_results.html - echo "
" >> ./build_results.html - fi + echo "
" >> ./build_results.html + if [ $MR_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} modified files HAVE a suspect license banner" >> ./build_results.html; fi + if [ $PU_TRIG -eq 1 ]; then echo " ${NB_FILES_IN_ERROR} files in repository HAVE a suspect license banner" >> ./build_results.html; fi + echo "
" >> ./build_results.html + echo " " >> ./build_results.html + echo "
" >> ./build_results.html + echo " " >> ./build_results.html + echo " " >> ./build_results.html + echo " " >> ./build_results.html + echo " " >> ./build_results.html + awk '{print " "}' ././files-w-suspect-banner.txt >> ./build_results.html + echo "
Filename
"$1"
" >> ./build_results.html + echo "
" >> ./build_results.html + echo "
" >> ./build_results.html fi fi diff --git a/ci-scripts/xml_class_list.yml b/ci-scripts/xml_class_list.yml index 2c5f04b11f..6497fd3020 100755 --- a/ci-scripts/xml_class_list.yml +++ b/ci-scripts/xml_class_list.yml @@ -1,6 +1,8 @@ - Build_Proxy + - Build_Cluster_Image - Build_PhySim - - Run_PhySim + - Run_LDPCTest + - Run_NRulsimTest - Build_eNB - WaitEndBuild_eNB - Initialize_eNB diff --git a/ci-scripts/xml_files/benetel_nsa_quectel.xml b/ci-scripts/xml_files/benetel_nsa_quectel.xml index 8c284b6673..5da8322f22 100644 --- a/ci-scripts/xml_files/benetel_nsa_quectel.xml +++ b/ci-scripts/xml_files/benetel_nsa_quectel.xml @@ -24,7 +24,7 @@ TEST-NSA-FR1-TM1 NSA Ping DL UL with QUECTEL tasks - 3 + 1 030000 040000 diff --git a/ci-scripts/xml_files/benetel_nsa_quectel_longrun.xml b/ci-scripts/xml_files/benetel_nsa_quectel_longrun.xml index 2e4494c819..3173e6315a 100644 --- a/ci-scripts/xml_files/benetel_nsa_quectel_longrun.xml +++ b/ci-scripts/xml_files/benetel_nsa_quectel_longrun.xml @@ -24,7 +24,7 @@ TEST-NSA-FR1-TM1 NSA Ping DL UL with QUECTEL tasks - 3 + 1 030000 040000 diff --git a/ci-scripts/xml_files/cluster_image_build.xml b/ci-scripts/xml_files/cluster_image_build.xml new file mode 100644 index 0000000000..057d49da86 --- /dev/null +++ b/ci-scripts/xml_files/cluster_image_build.xml @@ -0,0 +1,35 @@ + + + + build-tab + Build Images on Cluster + wrench + 000001 + + + + Build_Cluster_Image + Build Images on OpenShift Cluster + + + diff --git a/ci-scripts/xml_files/container_4g_l2sim_tdd.xml b/ci-scripts/xml_files/container_4g_l2sim_tdd.xml index 5298d01ef3..3ac32e1989 100644 --- a/ci-scripts/xml_files/container_4g_l2sim_tdd.xml +++ b/ci-scripts/xml_files/container_4g_l2sim_tdd.xml @@ -24,7 +24,7 @@ l2sim-4glte-tdd Testing 4G LTE L2 sim - FDD eNB wrench - 2 + 1 100001 000000 diff --git a/ci-scripts/xml_files/container_4g_rfsim_tdd_05MHz.xml b/ci-scripts/xml_files/container_4g_rfsim_tdd_05MHz.xml index aa70db1fed..7a29e50f39 100644 --- a/ci-scripts/xml_files/container_4g_rfsim_tdd_05MHz.xml +++ b/ci-scripts/xml_files/container_4g_rfsim_tdd_05MHz.xml @@ -24,7 +24,7 @@ rfsim-4glte-tdd05mhz Monolithic eNB - TDD 05MHz wrench - 2 + 1 100011 000011 diff --git a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml index 9564b24b35..578d5f221f 100644 --- a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml @@ -24,7 +24,7 @@ rfsim-5gnr-fdd Monolithic FDD gNB with SDAP wrench - 4 + 1 100011 000010 diff --git a/ci-scripts/xml_files/container_5g_l2sim_tdd.xml b/ci-scripts/xml_files/container_5g_l2sim_tdd.xml index be6b789b6b..cc3c1ae391 100644 --- a/ci-scripts/xml_files/container_5g_l2sim_tdd.xml +++ b/ci-scripts/xml_files/container_5g_l2sim_tdd.xml @@ -24,7 +24,7 @@ l2sim-5gnr-tdd Testing 5G NR L2 sim - TDD gNB wrench - 2 + 1 100001 000000 diff --git a/ci-scripts/xml_files/container_5g_rfsim.xml b/ci-scripts/xml_files/container_5g_rfsim.xml index 653e1e6513..5ad400ecc1 100644 --- a/ci-scripts/xml_files/container_5g_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_rfsim.xml @@ -24,7 +24,7 @@ rfsim-5gnr-tdd Monolithic TDD gNB wrench - 4 + 1 100001 000000 diff --git a/ci-scripts/xml_files/enb_ocp_usrp210_band7_test_05mhz_tm1.xml b/ci-scripts/xml_files/enb_ocp_usrp210_band7_test_05mhz_tm1.xml index d330d826bf..eebe62b3b5 100644 --- a/ci-scripts/xml_files/enb_ocp_usrp210_band7_test_05mhz_tm1.xml +++ b/ci-scripts/xml_files/enb_ocp_usrp210_band7_test_05mhz_tm1.xml @@ -24,7 +24,7 @@ test-05-tm1 Test-05MHz-TM1 tasks - 4 + 1 030201 040101 diff --git a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml index 48ce2f298f..723956fe60 100644 --- a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml +++ b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml @@ -24,7 +24,7 @@ test-05-tm1-nos1-tunnel Test-05MHz-TM1-noS1-tunnel tasks - 4 + 1 030201 090109 030101 000001 090101 000002 040501 040502 000001 040601 040602 040641 040642 000001 090109 030201 diff --git a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_fembms_no_s1.xml b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_fembms_no_s1.xml index fb66ce0c66..cf090379df 100644 --- a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_fembms_no_s1.xml +++ b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_fembms_no_s1.xml @@ -24,7 +24,7 @@ test-05-tm1-fembms-nos1-tunnel Test-05MHz-FEMBMS-TM1-noS1-tunnel tasks - 2 + 1 030201 090109 030104 000001 090104 000002 040605 000001 090109 030201 diff --git a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_mbms_no_s1.xml b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_mbms_no_s1.xml index 234f6639ce..c778b43eb5 100644 --- a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_mbms_no_s1.xml +++ b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_mbms_no_s1.xml @@ -24,7 +24,7 @@ test-05-tm1-mbms-nos1-tunnel Test-05MHz-MBMS-TM1-noS1-tunnel tasks - 2 + 1 030201 090109 030103 000001 090103 000002 040605 000001 090109 030201 diff --git a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_s1.xml b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_s1.xml index 791d32eec0..07e3a4135a 100644 --- a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_s1.xml +++ b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1_s1.xml @@ -24,7 +24,7 @@ test-05-tm1-tunnel Test-05MHz-TM1-tunnel tasks - 2 + 1 030201 090109 030102 000001 090102 000002 040503 000001 040603 040604 040643 040644 000001 090109 030201 diff --git a/ci-scripts/xml_files/enb_usrp210_band40_test_05mhz_tm2.xml b/ci-scripts/xml_files/enb_usrp210_band40_test_05mhz_tm2.xml index 2e7da714b0..9295306f23 100644 --- a/ci-scripts/xml_files/enb_usrp210_band40_test_05mhz_tm2.xml +++ b/ci-scripts/xml_files/enb_usrp210_band40_test_05mhz_tm2.xml @@ -25,7 +25,7 @@ test-05-tm2 Test-05MHz-TM2 tasks - 2 + 1 True 040608 diff --git a/ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1.xml b/ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1.xml index ef9fee0dca..1b32b873ca 100644 --- a/ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1.xml +++ b/ci-scripts/xml_files/enb_usrp210_band40_test_20mhz_tm1.xml @@ -24,7 +24,7 @@ test-20-tm1 Test-20MHz-TM1 tasks - 4 + 1 True 040623 diff --git a/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1_rrc_inactivity_no_flexran.xml b/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1_rrc_inactivity_no_flexran.xml index aedd980c34..90d54a2c82 100644 --- a/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1_rrc_inactivity_no_flexran.xml +++ b/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1_rrc_inactivity_no_flexran.xml @@ -24,7 +24,7 @@ test-05-tm1-rrc-no-flex Test-05MHz-TM1-RRC-Inactivity tasks - 2 + 1 030201 040101 diff --git a/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1_rrc_inactivity_w_flexran.xml b/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1_rrc_inactivity_w_flexran.xml index b488637483..1667e94f71 100644 --- a/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1_rrc_inactivity_w_flexran.xml +++ b/ci-scripts/xml_files/enb_usrp210_band7_test_05mhz_tm1_rrc_inactivity_w_flexran.xml @@ -24,7 +24,7 @@ test-05-tm1-rrc-w-flex Test-05MHz-TM1-RRC-Inactivity-FlexRan tasks - 2 + 1 030201 040101 diff --git a/ci-scripts/xml_files/enb_usrp210_band7_test_10mhz_tm1_cdrx.xml b/ci-scripts/xml_files/enb_usrp210_band7_test_10mhz_tm1_cdrx.xml index 82e0a32f6a..28140305db 100644 --- a/ci-scripts/xml_files/enb_usrp210_band7_test_10mhz_tm1_cdrx.xml +++ b/ci-scripts/xml_files/enb_usrp210_band7_test_10mhz_tm1_cdrx.xml @@ -24,7 +24,7 @@ test-10-cdrx-tm1 Test-10MHz-CDRX-TM1 tasks - 4 + 1 030201 040101 diff --git a/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml b/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml index a74dd26137..dd2b15a4f2 100644 --- a/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml +++ b/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml @@ -24,7 +24,7 @@ run-oai-gnb-nr-ue Run-gNB-and-NR-UE tasks - 2 + 1 090101 000001 090102 000002 090108 090109 @@ -52,7 +52,7 @@ Initialize_OAI_UE Initialize NR UE USRP - --phy-test --usrp-args "addr=192.168.30.2,second_addr=192.168.50.2,clock_source=external,time_source=external" --ue-rxgain 50 --rrc_config_path . --dlsch-parallel 4 --log_config.global_log_options level,nocolor,time + --phy-test --usrp-args "addr=192.168.30.2,second_addr=192.168.50.2,clock_source=external,time_source=external" --ue-rxgain 50 --rrc_config_path . --log_config.global_log_options level,nocolor,time NR diff --git a/ci-scripts/xml_files/gnb_nr_ue_usrp_run_multi_thread.xml b/ci-scripts/xml_files/gnb_nr_ue_usrp_run_multi_thread.xml index f91077aacf..7c9d689e44 100644 --- a/ci-scripts/xml_files/gnb_nr_ue_usrp_run_multi_thread.xml +++ b/ci-scripts/xml_files/gnb_nr_ue_usrp_run_multi_thread.xml @@ -24,7 +24,7 @@ run-oai-gnb-nr-ue-tx-write-thread Run-gNB-and-NR-UE-TX-Write-Thread tasks - 2 + 1 090103 000001 090104 000002 090108 090109 @@ -52,7 +52,7 @@ Initialize_OAI_UE Initialize NR UE USRP - --phy-test --usrp-args "addr=192.168.30.2,second_addr=192.168.50.2,clock_source=external,time_source=external" --ue-rxgain 75 --rrc_config_path . --dlsch-parallel 4 --log_config.global_log_options level,nocolor,time + --phy-test --usrp-args "addr=192.168.30.2,second_addr=192.168.50.2,clock_source=external,time_source=external" --ue-rxgain 75 --rrc_config_path . --log_config.global_log_options level,nocolor,time NR diff --git a/ci-scripts/xml_files/gnb_usrp_build.xml b/ci-scripts/xml_files/gnb_usrp_build.xml index 81c7d4e24e..f8ec797646 100644 --- a/ci-scripts/xml_files/gnb_usrp_build.xml +++ b/ci-scripts/xml_files/gnb_usrp_build.xml @@ -24,7 +24,7 @@ gnb-build-tab Build-gNB wrench - 4 + 1 010101 diff --git a/ci-scripts/xml_files/if4p5_usrp210_band40_test_10mhz.xml b/ci-scripts/xml_files/if4p5_usrp210_band40_test_10mhz.xml index f755a7ec96..b7c2622283 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band40_test_10mhz.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band40_test_10mhz.xml @@ -24,7 +24,7 @@ test-10 Test-10MHz tasks - 2 + 1 True 040612 diff --git a/ci-scripts/xml_files/if4p5_usrp210_band40_test_20mhz.xml b/ci-scripts/xml_files/if4p5_usrp210_band40_test_20mhz.xml index 4e84c47faf..287f75c59f 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band40_test_20mhz.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band40_test_20mhz.xml @@ -24,7 +24,7 @@ test-20 Test-20MHz tasks - 2 + 1 030201 040101 diff --git a/ci-scripts/xml_files/inria/enb_ue_usrp210_band7_test_05mhz_tm1.xml b/ci-scripts/xml_files/inria/enb_ue_usrp210_band7_test_05mhz_tm1.xml index c2fb2e8e2e..cd9ed8809e 100644 --- a/ci-scripts/xml_files/inria/enb_ue_usrp210_band7_test_05mhz_tm1.xml +++ b/ci-scripts/xml_files/inria/enb_ue_usrp210_band7_test_05mhz_tm1.xml @@ -24,7 +24,7 @@ test-05-tm1-oai-ue Test-05MHz-TM1-OAI-UE tasks - 4 + 1 030201 090109 030102 000001 090102 000002 040503 000002 040603 040604 040643 040644 000002 090109 000001 030201 diff --git a/ci-scripts/xml_files/inria/enb_ue_usrp210_band7_test_05mhz_tm1_nos1.xml b/ci-scripts/xml_files/inria/enb_ue_usrp210_band7_test_05mhz_tm1_nos1.xml index d5bdc5a42d..16cc4b9a41 100644 --- a/ci-scripts/xml_files/inria/enb_ue_usrp210_band7_test_05mhz_tm1_nos1.xml +++ b/ci-scripts/xml_files/inria/enb_ue_usrp210_band7_test_05mhz_tm1_nos1.xml @@ -24,7 +24,7 @@ test-05-tm1-nos1-tunnel Test-05MHz-TM1-noS1-tunnel tasks - 4 + 1 030201 090109 030101 000001 090101 000002 040501 040502 000001 040601 040602 040641 040642 000001 090109 030201 diff --git a/ci-scripts/xml_files/inria/enb_usrp210_band7_x2_ho_test_05Mhz_tm1.xml b/ci-scripts/xml_files/inria/enb_usrp210_band7_x2_ho_test_05Mhz_tm1.xml index b4b20c1239..36c4e2c1a8 100644 --- a/ci-scripts/xml_files/inria/enb_usrp210_band7_x2_ho_test_05Mhz_tm1.xml +++ b/ci-scripts/xml_files/inria/enb_usrp210_band7_x2_ho_test_05Mhz_tm1.xml @@ -24,7 +24,7 @@ test-x2-ho-05-tm1 Test-X2-Handover-05MHz-TM1 tasks - 2 + 1 040101 030201 030202 050102 diff --git a/ci-scripts/xml_files/ldpc_gpu_test.xml b/ci-scripts/xml_files/ldpc_gpu_test.xml index c17bc082d5..85bdc0bff8 100644 --- a/ci-scripts/xml_files/ldpc_gpu_test.xml +++ b/ci-scripts/xml_files/ldpc_gpu_test.xml @@ -26,132 +26,125 @@ Test-ldpc-GPU tasks 1 - 000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 000013 000014 000015 000016 000017 000018 000019 000020 000021 + 000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 000013 000014 000015 000016 000017 000018 000019 000020 000021 - - Build_PhySim - Build for physical simulator - --phy_simulators --ninja --noavx512 - FALSE - - - Run_PhySim + Run_LDPCTest Run LDPC Test with CPU -l 3872 -s10 -n100 - Run_PhySim + Run_LDPCTest Run LDPC Test with GPU -l 3872 -s10 -n100 -G 1 - Run_PhySim + Run_LDPCTest Run LDPC Test with CPU -l 4224 -s10 -n100 - Run_PhySim + Run_LDPCTest Run LDPC Test with GPU -l 4224 -s10 -n100 -G 1 - Run_PhySim + Run_LDPCTest Run LDPC Test with CPU -l 4576 -s10 -n100 - Run_PhySim + Run_LDPCTest Run LDPC Test with GPU -l 4576 -s10 -n100 -G 1 - Run_PhySim + Run_LDPCTest Run LDPC Test with CPU -l 4928 -s10 -n100 - Run_PhySim + Run_LDPCTest Run LDPC Test with GPU -l 4928 -s10 -n100 -G 1 - Run_PhySim + Run_LDPCTest Run LDPC Test with CPU -l 5280 -s10 -n100 - Run_PhySim + Run_LDPCTest Run LDPC Test with GPU -l 5280 -s10 -n100 -G 1 - Run_PhySim + Run_LDPCTest Run LDPC Test with CPU -l 5632 -s10 -n100 - Run_PhySim + Run_LDPCTest Run LDPC Test with GPU -l 5632 -s10 -n100 -G 1 - Run_PhySim + Run_LDPCTest Run LDPC Test with CPU -l 6336 -s10 -n100 - Run_PhySim + Run_LDPCTest Run LDPC Test with GPU -l 6336 -s10 -n100 -G 1 - Run_PhySim + Run_LDPCTest Run LDPC Test with CPU -l 7040 -s10 -n100 - Run_PhySim + Run_LDPCTest Run LDPC Test with GPU -l 7040 -s10 -n100 -G 1 - Run_PhySim + Run_LDPCTest Run LDPC Test with CPU -l 7744 -s10 -n100 - Run_PhySim + Run_LDPCTest Run LDPC Test with GPU -l 7744 -s10 -n100 -G 1 - Run_PhySim + Run_LDPCTest Run LDPC Test with CPU -l 8448 -s10 -n100 - Run_PhySim + Run_LDPCTest Run LDPC Test with GPU -l 8448 -s10 -n100 -G 1 diff --git a/ci-scripts/xml_files/multi_rru_band38_test_10mhz_tm1.xml b/ci-scripts/xml_files/multi_rru_band38_test_10mhz_tm1.xml index 3875a3df03..fdde60bd4c 100644 --- a/ci-scripts/xml_files/multi_rru_band38_test_10mhz_tm1.xml +++ b/ci-scripts/xml_files/multi_rru_band38_test_10mhz_tm1.xml @@ -24,7 +24,7 @@ test-multi-rru-10 Test-Multi-RRU-10MHz tasks - 2 + 1 030211 030212 030213 030111 030112 030113 diff --git a/ci-scripts/xml_files/nr_ue_usrp_build.xml b/ci-scripts/xml_files/nr_ue_usrp_build.xml index bc04efdb4b..dd3a10f2f5 100644 --- a/ci-scripts/xml_files/nr_ue_usrp_build.xml +++ b/ci-scripts/xml_files/nr_ue_usrp_build.xml @@ -24,7 +24,7 @@ nr-ue-build-tab Build-NR-UE wrench - 2 + 1 010102 diff --git a/ci-scripts/xml_files/physim_build_source.xml b/ci-scripts/xml_files/physim_build_source.xml new file mode 100644 index 0000000000..f062ca53ce --- /dev/null +++ b/ci-scripts/xml_files/physim_build_source.xml @@ -0,0 +1,36 @@ + + + + build-offload + Build physical simulators + tasks + 1 + 000001 + + + + Build_PhySim + Build physical simulators + --phy_simulators --ninja --noavx512 + FALSE + + diff --git a/ci-scripts/xml_files/t1_offload_test.xml b/ci-scripts/xml_files/t1_offload_test.xml new file mode 100644 index 0000000000..9abea4c977 --- /dev/null +++ b/ci-scripts/xml_files/t1_offload_test.xml @@ -0,0 +1,54 @@ + + + + test-t1-offload + Test T1 Offload + tasks + 1 + 000001 000002 000003 000004 + + + + Run_NRulsimTest + Run T1 Offload nr_ulsim + -n2 -s30 -m9 -r50 -R106 -o + + + + Run_NRulsimTest + Run T1 Offload nr_ulsim + -n2 -s30 -m9 -r106 -R106 -o + + + + Run_NRulsimTest + Run T1 Offload nr_ulsim + -n2 -s30 -m16 -r106 -R106 -o + + + + Run_NRulsimTest + Run T1 Offload nr_ulsim + -n2 -s30 -m9 -r273 -R273 -o + + + diff --git a/ci-scripts/xml_files/ue_band20_test_10mhz_orange.xml b/ci-scripts/xml_files/ue_band20_test_10mhz_orange.xml index 49ccfbca14..eba64191f0 100644 --- a/ci-scripts/xml_files/ue_band20_test_10mhz_orange.xml +++ b/ci-scripts/xml_files/ue_band20_test_10mhz_orange.xml @@ -24,7 +24,7 @@ test-10mhz-orange Test-10Mhz-Orange tasks - 4 + 1 090109 090110 000001 090109 diff --git a/ci-scripts/xml_files/ue_band20_test_10mhz_sfr.xml b/ci-scripts/xml_files/ue_band20_test_10mhz_sfr.xml index fdc70a9bdd..359fca1a11 100644 --- a/ci-scripts/xml_files/ue_band20_test_10mhz_sfr.xml +++ b/ci-scripts/xml_files/ue_band20_test_10mhz_sfr.xml @@ -24,7 +24,7 @@ test-10mHz-sfr Test-10MHz-SFR tasks - 4 + 1 090109 090111 000001 090109 diff --git a/ci-scripts/xml_files/x2ho_enb_usrp210_band13_test_05mhz_tm1.xml b/ci-scripts/xml_files/x2ho_enb_usrp210_band13_test_05mhz_tm1.xml index 14872c9f8f..e7a2c42cd6 100644 --- a/ci-scripts/xml_files/x2ho_enb_usrp210_band13_test_05mhz_tm1.xml +++ b/ci-scripts/xml_files/x2ho_enb_usrp210_band13_test_05mhz_tm1.xml @@ -25,7 +25,7 @@ test-x2-ho-05-tm1 Test-X2-HO-FDD-05MHz-TM1 tasks - 2 + 1 True 030201 030202 diff --git a/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml index d52b228ec6..952732f22d 100644 --- a/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_f1_rfsimulator/docker-compose.yaml @@ -2,7 +2,7 @@ version: '3.8' services: oai-nrf: container_name: "rfsim5g-oai-nrf" - image: oai-nrf:latest + image: oai-nrf:august-dev environment: - NRF_INTERFACE_NAME_FOR_SBI=eth0 - NRF_INTERFACE_PORT_FOR_SBI=80 @@ -42,7 +42,7 @@ services: ipv4_address: 192.168.71.131 oai-amf: container_name: "rfsim5g-oai-amf" - image: oai-amf:latest + image: oai-amf:august-dev environment: - TZ=Europe/paris - INSTANCE=0 @@ -63,9 +63,9 @@ services: - PLMN_SUPPORT_MNC=99 - PLMN_SUPPORT_TAC=0x0001 - SST_0=1 - - SD_0=1 + - SD_0=0xffffff - SST_1=1 - - SD_1=12 + - SD_1=1 - AMF_INTERFACE_NAME_FOR_NGAP=eth0 - AMF_INTERFACE_NAME_FOR_N11=eth0 - SMF_INSTANCE_ID_0=1 @@ -110,7 +110,7 @@ services: ipv4_address: 192.168.71.132 oai-smf: container_name: "rfsim5g-oai-smf" - image: oai-smf:latest + image: oai-smf:august-dev environment: - TZ=Europe/Paris - INSTANCE=0 @@ -140,6 +140,12 @@ services: - DISCOVER_UPF=yes - USE_FQDN_DNS=yes - DNN_NI0=oai + - TYPE0=IPv4 + - DNN_RANGE0=12.1.1.2 - 12.1.1.127 + - NSSAI_SST0=1 + - NSSAI_SD0=0xFFFFFF + - SESSION_AMBR_UL0=200Mbps + - SESSION_AMBR_DL0=400Mbps - DNN_NI2=oai.ipv4 depends_on: - oai-nrf @@ -156,7 +162,7 @@ services: ipv4_address: 192.168.71.133 oai-spgwu: container_name: "rfsim5g-oai-spgwu" - image: oai-spgwu-tiny:latest + image: oai-spgwu-tiny:august-dev environment: - TZ=Europe/Paris - PID_DIRECTORY=/var/run @@ -183,7 +189,7 @@ services: - NRF_API_VERSION=v1 - NRF_FQDN=oai-nrf - NSSAI_SST_0=1 - - NSSAI_SD_0=1 + - NSSAI_SD_0=0xffffff - DNN_0=oai depends_on: - oai-nrf @@ -237,8 +243,6 @@ services: MNC: '99' MNC_LENGTH: 2 NSSAI_SST: 1 - NSSAI_SD0: 1 - NSSAI_SD1: 112233 AMF_IP_ADDRESS: 192.168.71.132 GNB_NGA_IF_NAME: eth0 GNB_NGA_IP_ADDRESS: 192.168.71.140 @@ -273,8 +277,6 @@ services: MNC: '99' MNC_LENGTH: 2 NSSAI_SST: 1 - NSSAI_SD0: 1 - NSSAI_SD1: 112233 AMF_IP_ADDRESS: 192.168.71.132 GNB_NGA_IF_NAME: eth0 GNB_NGA_IP_ADDRESS: 192.168.71.142 @@ -307,7 +309,6 @@ services: OPC: 'C42449363BBAD02B66D16BC975D77CC1' DNN: oai NSSAI_SST: 1 - NSSAI_SD: 1 USE_ADDITIONAL_OPTIONS: --sa --rfsim -r 106 --numerology 1 -C 3619200000 --nokrnmod --log_config.global_log_options level,nocolor,time depends_on: - oai-du diff --git a/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml index 7758c39592..b9db6fe7d5 100644 --- a/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_fdd_rfsimulator/docker-compose.yaml @@ -2,7 +2,7 @@ version: '3.8' services: oai-nrf: container_name: "rfsim5g-oai-nrf" - image: oai-nrf:latest + image: oai-nrf:august-dev environment: - NRF_INTERFACE_NAME_FOR_SBI=eth0 - NRF_INTERFACE_PORT_FOR_SBI=80 @@ -42,7 +42,7 @@ services: ipv4_address: 192.168.71.131 oai-amf: container_name: "rfsim5g-oai-amf" - image: oai-amf:latest + image: oai-amf:august-dev environment: - TZ=Europe/paris - INSTANCE=0 @@ -63,9 +63,9 @@ services: - PLMN_SUPPORT_MNC=99 - PLMN_SUPPORT_TAC=0x0001 - SST_0=1 - - SD_0=1 + - SD_0=0xffffff - SST_1=1 - - SD_1=12 + - SD_1=1 - AMF_INTERFACE_NAME_FOR_NGAP=eth0 - AMF_INTERFACE_NAME_FOR_N11=eth0 - SMF_INSTANCE_ID_0=1 @@ -110,7 +110,7 @@ services: ipv4_address: 192.168.71.132 oai-smf: container_name: "rfsim5g-oai-smf" - image: oai-smf:latest + image: oai-smf:august-dev environment: - TZ=Europe/Paris - INSTANCE=0 @@ -140,6 +140,12 @@ services: - DISCOVER_UPF=yes - USE_FQDN_DNS=yes - DNN_NI0=oai + - TYPE0=IPv4 + - DNN_RANGE0=12.1.1.2 - 12.1.1.127 + - NSSAI_SST0=1 + - NSSAI_SD0=0xFFFFFF + - SESSION_AMBR_UL0=200Mbps + - SESSION_AMBR_DL0=400Mbps - DNN_NI2=oai.ipv4 depends_on: - oai-nrf @@ -156,7 +162,7 @@ services: ipv4_address: 192.168.71.133 oai-spgwu: container_name: "rfsim5g-oai-spgwu" - image: oai-spgwu-tiny:latest + image: oai-spgwu-tiny:august-dev environment: - TZ=Europe/Paris - PID_DIRECTORY=/var/run @@ -183,7 +189,7 @@ services: - NRF_API_VERSION=v1 - NRF_FQDN=oai-nrf - NSSAI_SST_0=1 - - NSSAI_SD_0=1 + - NSSAI_SD_0=0xffffff - DNN_0=oai depends_on: - oai-nrf @@ -237,8 +243,6 @@ services: MNC: '99' MNC_LENGTH: 2 NSSAI_SST: 1 - NSSAI_SD0: 1 - NSSAI_SD1: 112233 AMF_IP_ADDRESS: 192.168.71.132 GNB_NGA_IF_NAME: eth0 GNB_NGA_IP_ADDRESS: 192.168.71.140 @@ -266,7 +270,6 @@ services: OPC: 'C42449363BBAD02B66D16BC975D77CC1' DNN: oai NSSAI_SST: 1 - NSSAI_SD: 1 USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 --band 66 -C 2169080000 --CO -400000000 -s 396 --nokrnmod --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb diff --git a/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml b/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml index a28b640e1a..9ece49da74 100644 --- a/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_l2sim_tdd/docker-compose.yaml @@ -2,7 +2,7 @@ version: '3.8' services: oai-nrf: container_name: "l2sim-oai-nrf" - image: oai-nrf:latest + image: oai-nrf:august-dev environment: - NRF_INTERFACE_NAME_FOR_SBI=eth0 - NRF_INTERFACE_PORT_FOR_SBI=80 @@ -42,7 +42,7 @@ services: ipv4_address: 192.168.71.131 oai-amf: container_name: "l2sim-oai-amf" - image: oai-amf:latest + image: oai-amf:august-dev environment: - TZ=Europe/paris - INSTANCE=0 @@ -63,9 +63,9 @@ services: - PLMN_SUPPORT_MNC=99 - PLMN_SUPPORT_TAC=0x0001 - SST_0=1 - - SD_0=1 + - SD_0=0xffffff - SST_1=1 - - SD_1=12 + - SD_1=1 - AMF_INTERFACE_NAME_FOR_NGAP=eth0 - AMF_INTERFACE_NAME_FOR_N11=eth0 - SMF_INSTANCE_ID_0=1 @@ -110,7 +110,7 @@ services: ipv4_address: 192.168.71.132 oai-smf: container_name: "l2sim-oai-smf" - image: oai-smf:latest + image: oai-smf:august-dev environment: - TZ=Europe/Paris - INSTANCE=0 @@ -140,6 +140,12 @@ services: - DISCOVER_UPF=yes - USE_FQDN_DNS=yes - DNN_NI0=oai + - TYPE0=IPv4 + - DNN_RANGE0=12.1.1.2 - 12.1.1.127 + - NSSAI_SST0=1 + - NSSAI_SD0=0xFFFFFF + - SESSION_AMBR_UL0=200Mbps + - SESSION_AMBR_DL0=400Mbps - DNN_NI2=oai.ipv4 depends_on: - oai-nrf @@ -156,7 +162,7 @@ services: ipv4_address: 192.168.71.133 oai-spgwu: container_name: "l2sim-oai-spgwu" - image: oai-spgwu-tiny:latest + image: oai-spgwu-tiny:august-dev environment: - TZ=Europe/Paris - PID_DIRECTORY=/var/run @@ -183,7 +189,7 @@ services: - NRF_API_VERSION=v1 - NRF_FQDN=oai-nrf - NSSAI_SST_0=1 - - NSSAI_SD_0=1 + - NSSAI_SD_0=0xffffff - DNN_0=oai depends_on: - oai-nrf @@ -237,8 +243,6 @@ services: MNC: '99' MNC_LENGTH: 2 NSSAI_SST: 1 - NSSAI_SD0: 1 - NSSAI_SD1: 112233 AMF_IP_ADDRESS: 192.168.71.132 GNB_NGA_IF_NAME: eno1 GNB_NGA_IP_ADDRESS: 172.21.16.128 @@ -287,7 +291,7 @@ services: OPC: 'C42449363BBAD02B66D16BC975D77CC1' DNN: oai NSSAI_SST: 1 - NSSAI_SD: 1 + NSSAI_SD: 0xffffff NR_UE_NFAPI_IF_NAME: eno1 GNB_IP_ADDRESS: 127.0.0.1 NR_UE_IP_ADDRESS: 127.0.0.1 diff --git a/ci-scripts/yaml_files/5g_rfsimulator/README.md b/ci-scripts/yaml_files/5g_rfsimulator/README.md index aa18571776..36169dca8b 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/README.md +++ b/ci-scripts/yaml_files/5g_rfsimulator/README.md @@ -274,7 +274,6 @@ Create entry for Second UE in docker-compose.yaml file as follows: OPC: 'C42449363BBAD02B66D16BC975D77CC1' DNN: oai NSSAI_SST: 1 - NSSAI_SD: 1 USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 -C 3619200000 --nokrnmod --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb diff --git a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml index 696d8c6698..183d184977 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator/docker-compose.yaml @@ -2,7 +2,7 @@ version: '3.8' services: oai-nrf: container_name: "rfsim5g-oai-nrf" - image: oai-nrf:latest + image: oai-nrf:august-dev environment: - NRF_INTERFACE_NAME_FOR_SBI=eth0 - NRF_INTERFACE_PORT_FOR_SBI=80 @@ -42,7 +42,7 @@ services: ipv4_address: 192.168.71.131 oai-amf: container_name: "rfsim5g-oai-amf" - image: oai-amf:latest + image: oai-amf:august-dev environment: - TZ=Europe/paris - INSTANCE=0 @@ -63,9 +63,9 @@ services: - PLMN_SUPPORT_MNC=99 - PLMN_SUPPORT_TAC=0x0001 - SST_0=1 - - SD_0=1 + - SD_0=0xffffff - SST_1=1 - - SD_1=12 + - SD_1=1 - AMF_INTERFACE_NAME_FOR_NGAP=eth0 - AMF_INTERFACE_NAME_FOR_N11=eth0 - SMF_INSTANCE_ID_0=1 @@ -110,7 +110,7 @@ services: ipv4_address: 192.168.71.132 oai-smf: container_name: "rfsim5g-oai-smf" - image: oai-smf:latest + image: oai-smf:august-dev environment: - TZ=Europe/Paris - INSTANCE=0 @@ -140,6 +140,12 @@ services: - DISCOVER_UPF=yes - USE_FQDN_DNS=yes - DNN_NI0=oai + - TYPE0=IPv4 + - DNN_RANGE0=12.1.1.2 - 12.1.1.127 + - NSSAI_SST0=1 + - NSSAI_SD0=0xFFFFFF + - SESSION_AMBR_UL0=200Mbps + - SESSION_AMBR_DL0=400Mbps - DNN_NI2=oai.ipv4 depends_on: - oai-nrf @@ -156,7 +162,7 @@ services: ipv4_address: 192.168.71.133 oai-spgwu: container_name: "rfsim5g-oai-spgwu" - image: oai-spgwu-tiny:latest + image: oai-spgwu-tiny:august-dev environment: - TZ=Europe/Paris - PID_DIRECTORY=/var/run @@ -183,7 +189,7 @@ services: - NRF_API_VERSION=v1 - NRF_FQDN=oai-nrf - NSSAI_SST_0=1 - - NSSAI_SD_0=1 + - NSSAI_SD_0=0xffffff - DNN_0=oai depends_on: - oai-nrf @@ -237,8 +243,6 @@ services: MNC: '99' MNC_LENGTH: 2 NSSAI_SST: 1 - NSSAI_SD0: 1 - NSSAI_SD1: 112233 AMF_IP_ADDRESS: 192.168.71.132 GNB_NGA_IF_NAME: eth0 GNB_NGA_IP_ADDRESS: 192.168.71.140 @@ -266,7 +270,6 @@ services: OPC: 'C42449363BBAD02B66D16BC975D77CC1' DNN: oai NSSAI_SST: 1 - NSSAI_SD: 1 USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 -C 3619200000 --nokrnmod --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb @@ -290,7 +293,6 @@ services: OPC: 'C42449363BBAD02B66D16BC975D77CC1' DNN: oai NSSAI_SST: 1 - NSSAI_SD: 1 USE_ADDITIONAL_OPTIONS: -E --sa --rfsim -r 106 --numerology 1 -C 3619200000 --nokrnmod --log_config.global_log_options level,nocolor,time depends_on: - oai-gnb diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 6db2c28ac3..e9b589bab6 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -828,6 +828,31 @@ TARGET_LINK_LIBRARIES(benetel_5g pthread dl rt m numa) ########################################################## +# LDPC offload library +########################################################## + +# there is no generic way to test for T1 Offload, it simply comes with the +# shared object +if (EXISTS "/usr/local/lib64/librte_pmd_hpac_sdfec_pmd.so") + set(T1_OFFLOAD_FOUND TRUE) +else() + set(T1_OFFLOAD_FOUND FALSE) +endif() + +if(T1_OFFLOAD_FOUND) + message(STATUS "T1 Offload support detected") + set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib64/pkgconfig/") + pkg_search_module(LIBDPDK REQUIRED libdpdk=20.05.0) + add_library(ldpc_offload MODULE ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c) + set_target_properties(ldpc_offload PROPERTIES COMPILE_FLAGS "-DALLOW_EXPERIMENTAL_API") + target_compile_options(ldpc_offload PRIVATE ${LIBDPDK_CFLAGS}) + target_link_libraries(ldpc_offload ${LIBDPDK_LDFLAGS} rte_pmd_hpac_sdfec_pmd "-Wl,-rpath /usr/local/lib64") +else() + message(STATUS "No T1 Offload support detected") +endif () + +########################################################## + include_directories ("${OPENAIR_TARGETS}/ARCH/COMMON") Message("DEADLINE_SCHEDULER flag is ${DEADLINE_SCHEDULER}") @@ -1216,6 +1241,7 @@ add_library(UTIL ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/time_meas.c + ${OPENAIR_DIR}/common/utils/time_stat.c ) set(SECU_OSA_SRC @@ -2771,7 +2797,11 @@ target_link_libraries (nr-softmodem pthread m CONFIG_LIB rt crypt ${CRYPTO_LIBRA target_link_libraries (nr-softmodem ${LIB_LMS_LIBRARIES}) target_link_libraries (nr-softmodem ${T_LIB}) -add_dependencies( nr-softmodem ldpc_orig ldpc_optim ldpc_optim8seg ldpc ) +add_dependencies( nr-softmodem ldpc_orig ldpc_optim ldpc_optim8seg ldpc) + +if(T1_OFFLOAD_FOUND) +add_dependencies( nr-softmodem ldpc_offload) +endif () # nr-uesoftmodem is UE implementation ####################################### @@ -2817,6 +2847,7 @@ if (CUDA_FOUND) add_dependencies( nr-uesoftmodem ldpc_cuda) add_dependencies( nr-softmodem ldpc_cuda) endif (CUDA_FOUND) + ###################################" # Addexecutables for tests #################################### @@ -2980,6 +3011,11 @@ add_executable(nr_ulsim ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) + +if(T1_OFFLOAD_FOUND) +add_dependencies( nr_ulsim ldpc_offload) +endif () + target_link_libraries(nr_ulsim -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_LTE_NR L2_NR HASHTABLE X2AP_ENB X2AP_LIB SECU_CN NGAP_GNB NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -lz -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ITTI ${OPENSSL_LIBRARIES} dl diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index d35f90fcce..608ace0486 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -237,8 +237,9 @@ compilations() { echo_error "$2 compilation failed" exit 1 fi - if [ -s $3 ] ; then - cp $3 $4 + if [ -s "$3" ] ; then + rm -f "$4" + ln -s "$PWD/$3" "$4" echo_success "$2 compiled" check_warnings "$dlog/$2.$REL.txt" else diff --git a/cmake_targets/tools/indent_source_code b/cmake_targets/tools/indent_source_code deleted file mode 100755 index a16914a91d..0000000000 --- a/cmake_targets/tools/indent_source_code +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ - -# file indent_source_code -# brief -# author Lionel Gauthier -# company Eurecom -# email: lionel.gauthier@eurecom.fr -# -################################ -# include helper functions -################################ -THIS_SCRIPT_PATH=$(dirname $(readlink -f $0)) -source $THIS_SCRIPT_PATH/build_helper - -function main() -{ - local MAX_CODE_LENGTH=200 - local INDENT_SPACES=2 -set_openair_env - - - # remove trailing white spaces - #find $OPENAIR_DIR/openair1 -type f \( -name '*.c' -o -name '*.h' \) -exec sed --in-place 's/[[:space:]]\+$//' {} \+ - #find $OPENAIR_DIR/openair2 -type f \( -name '*.c' -o -name '*.h' \) -exec sed --in-place 's/[[:space:]]\+$//' {} \+ - #find $OPENAIR_DIR/openair3 -type f \( -name '*.c' -o -name '*.h' \) -exec sed --in-place 's/[[:space:]]\+$//' {} \+ - #find $OPENAIR_DIR/openair3 -type f \( -name '*.c' -o -name '*.h' \) -exec sed --in-place 's/[[:space:]]\+$//' {} \+ - #find $OPENAIR_DIR/targets -type f \( -name '*.c' -o -name '*.h' \) -exec sed --in-place 's/[[:space:]]\+$//' {} \+ - -# Style google not available on 14.04 - - exit 0 - # will use indent - command -v astyle >/dev/null 2>&1 || { echo >&2 "astyle required but it's not installed."; sudo apt-get install astyle; } - astyle --recursive --convert-tabs --indent=spaces=$INDENT_SPACES --style=kr --indent-col1-comments --max-code-length=$MAX_CODE_LENGTH \ - $OPENAIR_DIR/openair1/*.h \ - $OPENAIR_DIR/openair1/*.c \ - $OPENAIR_DIR/openair2/*.h \ - $OPENAIR_DIR/openair2/*.c \ - $OPENAIR_DIR/openair3/*.h \ - $OPENAIR_DIR/openair3/*.c \ - $OPENAIR_DIR/openair3/*.h \ - $OPENAIR_DIR/openair3/*.c \ - $OPENAIR_DIR/targets/*.h \ - $OPENAIR_DIR/targets/*.c -} - - -main "$@" diff --git a/common/config/config_userapi.c b/common/config/config_userapi.c index 9725c15845..78a6a1b2c9 100644 --- a/common/config/config_userapi.c +++ b/common/config/config_userapi.c @@ -113,7 +113,7 @@ void config_check_valptr(paramdef_t *cfgoptions, int elt_sz, int nb_elt) { sz=managed_ptr_sz(*cfgoptions->strptr); else sz=managed_ptr_sz(cfgoptions->voidptr); - if ( sz != -1) { + if ( sz == -1) { CONFIG_PRINTF_ERROR("[CONFIG] %s NOT SUPPORTED not NULL pointer with array types", cfgoptions->optname); return ; } diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 4605df06e0..043631d706 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -48,6 +48,10 @@ // main log variables +// Fixme: a better place to be shure it is called +void read_cpu_hardware (void) __attribute__ ((constructor)); +void read_cpu_hardware (void) {__builtin_cpu_init(); } + log_mem_cnt_t log_mem_d[2]; int log_mem_flag=0; int log_mem_multi=1; diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index a1b70c7503..509c4581a9 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -366,6 +366,7 @@ typedef struct { #define MATLAB_CSHORT_BRACKET3 15 int32_t write_file_matlab(const char *fname, const char *vname, void *data, int length, int dec, unsigned int format, int multiVec); +#define write_output(a, b, c, d, e, f) write_file_matlab(a, b, c, d, e, f, 0) /*----------------macro definitions for reading log configuration from the config module */ #define CONFIG_STRING_LOG_PREFIX "log_config" diff --git a/common/utils/T/tracer/packet-mac-lte.h b/common/utils/T/tracer/packet-mac-lte.h index 60181987a9..715bbb68d9 100644 --- a/common/utils/T/tracer/packet-mac-lte.h +++ b/common/utils/T/tracer/packet-mac-lte.h @@ -17,8 +17,6 @@ #ifndef __COMMON_UTILS_T_TRACER_PACKET_MAC_LTE__H__ #define __COMMON_UTILS_T_TRACER_PACKET_MAC_LTE__H__ -//#include "ws_symbol_export.h" - /* radioType */ #define FDD_RADIO 1 #define TDD_RADIO 2 diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index 0fb4824d42..465679d002 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -724,3 +724,4 @@ void SLIV2SL(int SLIV,int *S,int *L) { *S=13-SLIVmod14; } } + diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h index 946e06dd62..893dcba701 100644 --- a/common/utils/nr/nr_common.h +++ b/common/utils/nr/nr_common.h @@ -56,10 +56,9 @@ typedef enum frequency_range_e { } frequency_range_t; extern const nr_bandentry_t nr_bandtable[]; + static inline int get_num_dmrs(uint16_t dmrs_mask ) { - int num_dmrs=0; - for (int i=0;i<16;i++) num_dmrs+=((dmrs_mask>>i)&1); return(num_dmrs); } diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index 4613cd5c1b..fe43dde319 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -45,9 +45,7 @@ extern "C" { std::vector message_queue; std::map timer_map; uint64_t next_timer=UINT64_MAX; - struct epoll_event *events =NULL; int nb_fd_epoll=0; - int nb_events=0; int epoll_fd=-1; int sem_fd=-1; } task_list_t; @@ -167,14 +165,14 @@ extern "C" { struct epoll_event event; task_list_t *t=tasks[task_id]; t->nb_fd_epoll++; - t->events = (struct epoll_event *)realloc((void *)t->events, - t->nb_fd_epoll * sizeof(struct epoll_event)); event.events = EPOLLIN | EPOLLERR; event.data.u64 = 0; event.data.fd = fd; AssertFatal(epoll_ctl(t->epoll_fd, EPOLL_CTL_ADD, fd, &event) == 0, "epoll_ctl (EPOLL_CTL_ADD) failed for task %s, fd %d: %s!\n", itti_get_task_name(task_id), fd, strerror(errno)); + eventfd_t sem_counter = 1; + AssertFatal ( sizeof(sem_counter) == write(t->sem_fd, &sem_counter, sizeof(sem_counter)), ""); } void itti_unsubscribe_event_fd(task_id_t task_id, int fd) { @@ -185,10 +183,10 @@ extern "C" { t->nb_fd_epoll--; } - static inline int itti_get_events_locked(task_id_t task_id, struct epoll_event **events) { + static inline int itti_get_events_locked(task_id_t task_id, struct epoll_event *events, int max_events) { task_list_t *t=tasks[task_id]; uint64_t current_time=0; - + int nb_events; do { if ( t->next_timer != UINT64_MAX ) { struct timespec tp; @@ -234,40 +232,41 @@ extern "C" { pthread_mutex_unlock(&t->queue_cond_lock); LOG_D(ITTI,"enter blocking wait for %s, timeout: %d ms\n", itti_get_task_name(task_id), epoll_timeout); - t->nb_events = epoll_wait(t->epoll_fd,t->events,t->nb_fd_epoll, epoll_timeout); + nb_events = epoll_wait(t->epoll_fd, events, max_events, epoll_timeout); - if ( t->nb_events < 0 && (errno == EINTR || errno == EAGAIN ) ) + if ( nb_events < 0 && (errno == EINTR || errno == EAGAIN ) ) pthread_mutex_lock(&t->queue_cond_lock); - } while (t->nb_events < 0 && (errno == EINTR || errno == EAGAIN ) ); + } while (nb_events < 0 && (errno == EINTR || errno == EAGAIN ) ); - AssertFatal (t->nb_events >=0, + AssertFatal (nb_events >=0, "epoll_wait failed for task %s, nb fds %d, timeout %lu: %s!\n", - itti_get_task_name(task_id), t->nb_fd_epoll, t->next_timer != UINT64_MAX ? t->next_timer-current_time : -1, strerror(errno)); - LOG_D(ITTI,"receive on %d descriptors for %s\n", t->nb_events, itti_get_task_name(task_id)); + itti_get_task_name(task_id), t->nb_fd_epoll, + t->next_timer != UINT64_MAX ? t->next_timer-current_time : -1, + strerror(errno)); + LOG_D(ITTI,"receive on %d descriptors for %s\n", nb_events, itti_get_task_name(task_id)); - if (t->nb_events == 0) + if (nb_events == 0) /* No data to read -> return */ return 0; - for (int i = 0; i < t->nb_events; i++) { + for (int i = 0; i < nb_events; i++) { /* Check if there is an event for ITTI for the event fd */ - if ((t->events[i].events & EPOLLIN) && - (t->events[i].data.fd == t->sem_fd)) { + if ((events[i].events & EPOLLIN) && + (events[i].data.fd == t->sem_fd)) { eventfd_t sem_counter; /* Read will always return 1 */ AssertFatal( sizeof(sem_counter) == read (t->sem_fd, &sem_counter, sizeof(sem_counter)), ""); /* Mark that the event has been processed */ - t->events[i].events &= ~EPOLLIN; + events[i].events &= ~EPOLLIN; } } - *events = t->events; - return t->nb_events; + return nb_events; } - int itti_get_events(task_id_t task_id, struct epoll_event **events) { + int itti_get_events(task_id_t task_id, struct epoll_event *events, int nb_evts) { pthread_mutex_lock(&tasks[task_id]->queue_cond_lock); - return itti_get_events_locked(task_id, events); + return itti_get_events_locked(task_id, events, nb_evts); } void itti_receive_msg(task_id_t task_id, MessageDef **received_msg) { @@ -275,17 +274,14 @@ extern "C" { task_list_t *t=tasks[task_id]; pthread_mutex_lock(&t->queue_cond_lock); + struct epoll_event events[t->nb_fd_epoll]; // Weird condition to deal with crap legacy itti interface - if ( t->nb_fd_epoll == 1 ) { - while (t->message_queue.empty()) { - itti_get_events_locked(task_id, &t->events); - pthread_mutex_lock(&t->queue_cond_lock); - } - } else { - if (t->message_queue.empty()) { - itti_get_events_locked(task_id, &t->events); + if (t->message_queue.empty()) { + do { + itti_get_events_locked(task_id, events, t->nb_fd_epoll); pthread_mutex_lock(&t->queue_cond_lock); } + while (t->message_queue.empty() && t->nb_fd_epoll == 1); } // Legacy design: we return even if we have no message diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index 3a03e380a1..9f1fcd1741 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -479,7 +479,7 @@ void itti_unsubscribe_event_fd(task_id_t task_id, int fd); \param events events list @returns number of events to handle **/ -int itti_get_events(task_id_t task_id, struct epoll_event **events); + int itti_get_events(task_id_t task_id, struct epoll_event *events, int nb_max_evts); /** \brief Retrieves a message in the queue associated to task_id. If the queue is empty, the thread is blocked till a new message arrives. diff --git a/common/utils/threadPool/thread-pool.c b/common/utils/threadPool/thread-pool.c index d1af56b477..75252a9143 100644 --- a/common/utils/threadPool/thread-pool.c +++ b/common/utils/threadPool/thread-pool.c @@ -111,7 +111,7 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name if (measr) { mkfifo(measr,0666); - AssertFatal(-1 != (pool->dummyTraceFd= + AssertFatal(-1 != (pool->dummyKeepReadingTraceFd= open(measr, O_RDONLY| O_NONBLOCK)),""); AssertFatal(-1 != (pool->traceFd= open(measr, O_WRONLY|O_APPEND|O_NOATIME|O_NONBLOCK)),""); @@ -130,6 +130,7 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name int c=toupper(curptr[0]); switch (c) { + case 'N': pool->activated=false; break; @@ -161,6 +162,17 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name } } +void initFloatingCoresTpool(int nbThreads,tpool_t *pool, bool performanceMeas, char *name) { + char threads[1024] = "n"; + if (nbThreads) { + strcpy(threads,"-1"); + for (int i=1; i < nbThreads; i++) + strncat(threads,",-1", sizeof(threads-1)); + } + threads[sizeof(threads-1)]=0; + initNamedTpool(threads, pool, performanceMeas, name); +} + #ifdef TEST_THREAD_POOL volatile int oai_exit=0; diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h index 0e4630117d..81eef5d7e7 100644 --- a/common/utils/threadPool/thread-pool.h +++ b/common/utils/threadPool/thread-pool.h @@ -256,9 +256,8 @@ typedef struct thread_pool { bool activated; bool measurePerf; int traceFd; - int dummyTraceFd; + int dummyKeepReadingTraceFd; uint64_t cpuCyclesMicroSec; - uint64_t startProcessingUE; int nbThreads; notifiedFIFO_t incomingFifo; struct one_thread *allthreads; @@ -389,5 +388,6 @@ static inline int abortTpool(tpool_t *t) { return nbRemoved; } void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name); +void initFloatingCoresTpool(int nbThreads,tpool_t *pool, bool performanceMeas, char *name); #define initTpool(PARAMPTR,TPOOLPTR, MEASURFLAG) initNamedTpool(PARAMPTR,TPOOLPTR, MEASURFLAG, NULL) #endif diff --git a/common/utils/time_meas.c b/common/utils/time_meas.c index ba5862dacb..9577968bc4 100644 --- a/common/utils/time_meas.c +++ b/common/utils/time_meas.c @@ -39,14 +39,14 @@ notifiedFIFO_t measur_fifo; double get_cpu_freq_GHz(void) { if (cpu_freq_GHz <1 ) { - time_stats_t ts = {0}; - reset_meas(&ts); - ts.trials++; - ts.in = rdtsc_oai(); - sleep(1); - ts.diff = (rdtsc_oai()-ts.in); - cpu_freq_GHz = (double)ts.diff/1000000000; - printf("CPU Freq is %f \n", cpu_freq_GHz); + time_stats_t ts = {0}; + reset_meas(&ts); + ts.trials++; + ts.in = rdtsc_oai(); + sleep(1); + ts.diff = (rdtsc_oai()-ts.in); + cpu_freq_GHz = (double)ts.diff/1000000000; + printf("CPU Freq is %f \n", cpu_freq_GHz); } return cpu_freq_GHz; } diff --git a/common/utils/time_stat.c b/common/utils/time_stat.c new file mode 100644 index 0000000000..dd648e1639 --- /dev/null +++ b/common/utils/time_stat.c @@ -0,0 +1,136 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "time_stat.h" + +#include +#include +#include + +#include "common/utils/LOG/log.h" + +time_average_t *time_average_new(int duration, int initial_size) +{ + time_average_t *ret; + + /* let's only accept power of two initial_size */ + if (initial_size & (initial_size - 1)) { + LOG_E(UTIL, "time_average_new: illegal initial_size %d, use power of two\n", initial_size); + exit(1); + } + + ret = calloc(1, sizeof(time_average_t)); + if (ret == NULL) { + LOG_E(UTIL, "out of memory\n"); + exit(1); + } + + ret->duration = duration; + ret->r.head = initial_size - 1; + ret->r.maxsize = initial_size; + ret->r.buffer = calloc(initial_size, sizeof(time_value_t)); + if (ret->r.buffer == NULL) { + LOG_E(UTIL, "out of memory\n"); + exit(1); + } + + return ret; +} + +void time_average_free(time_average_t *t) +{ + free(t->r.buffer); + free(t); +} + +void time_average_reset(time_average_t *t) +{ + t->r.head = t->r.maxsize - 1; + t->r.tail = 0; + t->r.size = 0; + t->accumulated_value = 0; +} + +static void remove_old(time_average_t *t, uint64_t time) +{ + /* remove old events */ + while (t->r.size && t->r.buffer[t->r.tail].time < time - t->duration) { + t->accumulated_value -= t->r.buffer[t->r.tail].value; + t->r.size--; + t->r.tail++; + t->r.tail %= t->r.maxsize; + } +} + +void time_average_add(time_average_t *t, uint64_t time, uint64_t value) +{ + remove_old(t, time); + + if (t->r.size == t->r.maxsize) { + t->r.maxsize *= 2; + t->r.buffer = realloc(t->r.buffer, t->r.maxsize * sizeof(time_value_t)); + if (t->r.buffer == NULL) { + LOG_E(UTIL, "out of memory\n"); + exit(1); + } + if (t->r.head < t->r.tail) { + memcpy(&t->r.buffer[t->r.size], &t->r.buffer[0], (t->r.head + 1) * sizeof(time_value_t)); + t->r.head += t->r.size; + } + } + + t->r.head++; + t->r.head %= t->r.maxsize; + t->r.buffer[t->r.head].time = time; + t->r.buffer[t->r.head].value = value; + + t->r.size++; + + t->accumulated_value += value; +} + +double time_average_get_average(time_average_t *t, uint64_t time) +{ + remove_old(t, time); + + if (t->r.size == 0) + return 0; + + return (double)t->accumulated_value / t->r.size; +} + +uint64_t time_average_now(void) +{ + struct timespec t; + uint64_t ret; + + if (clock_gettime(CLOCK_REALTIME, &t)) { + LOG_E(UTIL, "clock_gettime failed\n"); + exit(1); + } + + ret = (uint64_t)t.tv_sec * (uint64_t)1000000 + t.tv_nsec / 1000; + /* round up if necessary */ + if (t.tv_nsec % 1000 >= 500) + ret++; + + return ret; +} diff --git a/common/utils/time_stat.h b/common/utils/time_stat.h new file mode 100644 index 0000000000..d7508f5df0 --- /dev/null +++ b/common/utils/time_stat.h @@ -0,0 +1,64 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef _COMMON_UTIL_TIME_STAT_H_ +#define _COMMON_UTIL_TIME_STAT_H_ + +#include + +typedef struct { + uint64_t time; /* unit: microsecond */ + uint64_t value; /* unit: microsecond */ +} time_value_t; + +typedef struct { + int head; + int tail; + time_value_t *buffer; + int maxsize; + int size; +} time_ring_t; + +typedef struct { + int duration; /* unit: microsecond */ + time_ring_t r; + uint64_t accumulated_value; +} time_average_t; + +/* 'duration' is in unit microsecond */ +time_average_t *time_average_new(int duration, int initial_size); +void time_average_free(time_average_t *t); +void time_average_reset(time_average_t *t); + +/* add a value tagged with time 'time' unit microsecond (it also modifies 't', + * removing all data with time < 'time' - t->duration) + */ +void time_average_add(time_average_t *t, uint64_t time, uint64_t value); + +/* get the average for time 'time' (it also modifies 't', removing all + * data with time < 'time' - t->duration) + */ +double time_average_get_average(time_average_t *t, uint64_t time); + +/* unit microsecond */ +uint64_t time_average_now(void); + +#endif /* _COMMON_UTIL_TIME_STAT_H_ */ diff --git a/doc/GET_SOURCES.md b/doc/GET_SOURCES.md index 854ff3b504..f594ba1747 100644 --- a/doc/GET_SOURCES.md +++ b/doc/GET_SOURCES.md @@ -1,41 +1,20 @@ - - - - - -
- - - - - - The OpenAirInterface repository: the sources -
- The OpenAirInterface software can be obtained from our gitLab server. You will need a git client to get the sources. The repository is currently used for main developments. # Prerequisites -You need to install the subversion/git using the following commands: +You need to install git using the following commands: ```shell sudo apt-get update -sudo apt-get install subversion git +sudo apt-get install git ``` # Using EURECOM Gitlab The [openairinterface5g repository](https://gitlab.eurecom.fr/oai/openairinterface5g.git) -holds the source code for (eNB RAN + UE RAN). - -For legal issues (licenses), the core network (EPC) source code is now moved away from -the above openairinterface5g git repository. - -* A more recent version is available under our GitHub domain: - * [OAI GitHub openair-cn domain](https://github.com/OPENAIRINTERFACE) - * Check its wiki pages for more details +holds the source code for the RAN (4G and 5G). Configure git with your name/email address (only important if you are developer and want to contribute/push code to Git Repository): @@ -44,18 +23,6 @@ git config --global user.name "Your Name" git config --global user.email "Your email address" ``` -- Add a certificate from gitlab.eurecom.fr to your Ubuntu 14.04 installation: - -```shell -echo -n | openssl s_client -showcerts -connect gitlab.eurecom.fr:443 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt -``` - -- Disable certificate check completely if you do not have root access to /etc/ssl directory - -```shell -git config --global http.sslverify false -``` - ## In order to clone the Git repository (for OAI Users without login to gitlab server) Cloning RAN repository (eNB RAN + UE RAN): @@ -70,13 +37,6 @@ Please send email to [contact@openairinterface.org](mailto:contact@openairinterf as a developer (only important for users who want to commit code to the repository). If you do not have account on gitlab.eurecom.fr, please register yourself to gitlab.eurecom.fr and provide the identifiant in the email. -* Clone with using ssh keys: - * You will need to put your ssh keys in https://gitlab.eurecom.fr/profile/keys - to access to the git repo. Once that is done, clone the git repository using: - * `git clone git@gitlab.eurecom.fr:oai/openairinterface5g.git` -* Clone with user name/password prompt: - * `git clone https://YOUR_USERNAME@gitlab.eurecom.fr/oai/openairinterface5g.git` - # Which branch to checkout? On the RAN side: @@ -84,15 +44,15 @@ On the RAN side: * **master**: This branch is targeted for the user community. Since January 2019, it is also subject to a Continuous Integration process. The update frequency is about once every 2-3 months. We are also performing bug fixes on this branch. * **develop**: This branch contains recent commits that are tested on our CI test bench. The update frequency is about once a week. -Please see the work flow and policies page : +Please see the work flow and policies page: https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/oai-policies-home -you can find the latest stable tag release here : +you can find the latest stable tag release here: https://gitlab.eurecom.fr/oai/openairinterface5g/tags -The tag naming conventions are : +The tag naming conventions are: - On `master` branch: **v1.`x`.`y`** where * `x` is the minor release number, incremented every 2-3 months when we are merging `develop` into `master` branch. diff --git a/doc/TESTBenches.md b/doc/TESTBenches.md index c9a9870953..dd14817863 100644 --- a/doc/TESTBenches.md +++ b/doc/TESTBenches.md @@ -105,8 +105,9 @@ Webhook - [RAN-RF-Sim-Test-5G](https://jenkins-oai.eurecom.fr/job/RAN-RF-Sim-Test-5G/) - obelix (gNB, 2x UE, OAI 5GC) - uses RFsimulator, TDD 40MHz, FDD 40MHz, F1 split -- [RAN-RHEL8-Image-Builder](https://jenkins-oai.eurecom.fr/job/RAN-RHEL8-Image-Builder/) - - asterix: RHEL 8 image build using podman +- [RAN-RHEL8-Cluster-Image-Builder](https://jenkins-oai.eurecom.fr/job/RAN-RHEL8-Cluster-Image-Builder/) + - asterix (`Asterix-OC-oaicicd-session` resource): RHEL 8 image build using + the OpenShift in Eurecom - [RAN-Ubuntu18-Image-Builder](https://jenkins-oai.eurecom.fr/job/RAN-Ubuntu18-Image-Builder/) - obelix: Ubuntu 18 image build using docker diff --git a/doc/TESTING_5GSA_setup.md b/doc/TESTING_5GSA_setup.md index 5251d82eb7..1e27e1616d 100644 --- a/doc/TESTING_5GSA_setup.md +++ b/doc/TESTING_5GSA_setup.md @@ -68,21 +68,7 @@ In the following, we highlight the fields of the file that have to be configured ```bash // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); ``` Then, the source and destination IP interfaces for the communication with the Core Network also need to be set as shown below. diff --git a/doc/clang-format.md b/doc/clang-format.md new file mode 100644 index 0000000000..fa751b303d --- /dev/null +++ b/doc/clang-format.md @@ -0,0 +1,66 @@ +We use [clang-format](https://clang.llvm.org/docs/ClangFormat.html) to format our code. + +# Integration into editors + +Integration into various editors (`vim`, `emacs`, `VSCode`, `CLion`) is on the +[clang-format project page](https://clang.llvm.org/docs/ClangFormat.html). + +There is also an [eclipse plugin](https://github.com/wangzw/CppStyle). + +# Integration into git + +## Short version + +See below for a more detailed explanation. In short: Add this to `~/.gitconfig`: +``` +[clangFormat] + binary = clang-format-12 + style = file +``` +Now stage files for reformatting, then run `git clang-format`. It will reformat +only the code that is staged, and you can view reformatted code with `git +diff`. To add modified lines to your commit, stage them as well, then commit. + +There is also a pre-commit hook that you can install. To install it, copy it +`pre-commit-clang` to `.git/hooks/pre-commit`, and make it executable. + +## Long version + +In order to integrate `clang-format` into `git`, follow these steps: + +1) Copy `pre-commit-clang` to `.git/hooks/pre-commit` and make it executable. + +2) Install clang-format-12 (needs at least Ubuntu 20, remove anything else) + ```bash + $ sudo apt-get remove clang-format* + $ sudo apt-get install clang-format-12 + ``` + +3) Configure `git` (set correct executable, set mode, provide more convenient alias) + ```bash + $ git config --global clangFormat.binary clang-format-12 + $ git config --global clangFormat.style file + $ git config --global alias.clang-format clang-format-12 + ``` + +When this is done, you are set up. How to use: + +4) When committing new code, add the code to commit into the staging (`git add + -p` or `git add `) _and stash the rest_ (e.g., `git stash -p`, this is + quite important or reformatting might not work properly, or you don't know + what has been reformatted) + +5) Run git clang-format. The staged code will be reformatted. After this, you + still have your changes in the staging area, and the formatted code appears + as additional modification. Thus, your changes can be seen with + ```bash + $ git diff --staged + ``` + while the modifications of clang-format with + ```bash + $ git diff + ``` + So now, you can add all or parts of reformatted code to the staging area + +6) Commit. It won't work if code is not properly formatted due to the + pre-commit hook. Force committing with `git commit --no-verify` diff --git a/doc/tutorial_resources/docker-compose-basic-nrf.yaml b/doc/tutorial_resources/docker-compose-basic-nrf.yaml index cd1e957ad8..1c78bf37f9 100644 --- a/doc/tutorial_resources/docker-compose-basic-nrf.yaml +++ b/doc/tutorial_resources/docker-compose-basic-nrf.yaml @@ -314,7 +314,7 @@ services: - NRF_API_VERSION=v1 - NRF_FQDN=oai-nrf - NSSAI_SST_0=1 - - NSSAI_SD_0=0x1 + - NSSAI_SD_0=0xffffff - DNN_0=oai depends_on: - oai-nrf diff --git a/docker/Dockerfile.base.rhel8.2 b/docker/Dockerfile.base.rhel8.2 index 3050f09849..5f897bd0e2 100644 --- a/docker/Dockerfile.base.rhel8.2 +++ b/docker/Dockerfile.base.rhel8.2 @@ -32,8 +32,12 @@ ENV TZ=Europe/Paris ENV BUILD_UHD_FROM_SOURCE=True ENV UHD_VERSION=3.15.0.0 -COPY tmp/ca/redhat-uep.pem /etc/rhsm/ca -COPY tmp/entitlement/*.pem /etc/pki/entitlement +# Copy the entitlements +COPY ./etc-pki-entitlement /etc/pki/entitlement + +# Copy the subscription manager configurations +COPY ./rhsm-conf /etc/rhsm +COPY ./rhsm-ca /etc/rhsm/ca #install developers pkg/repo RUN rm -f /etc/rhsm-host && \ diff --git a/docker/Dockerfile.build.rhel8.2 b/docker/Dockerfile.build.rhel8.2 index 2664096a9b..6fc2598276 100644 --- a/docker/Dockerfile.build.rhel8.2 +++ b/docker/Dockerfile.build.rhel8.2 @@ -35,4 +35,4 @@ COPY . . RUN /bin/sh oaienv && \ cd cmake_targets && \ mkdir -p log && \ - ./build_oai --eNB --gNB --RU --UE --nrUE --ninja --build-lib all -w USRP --verbose-ci --noavx512 + ./build_oai --eNB --gNB --RU --UE --nrUE --ninja --build-lib all -w USRP --verbose-ci --noavx512 -c diff --git a/docker/Dockerfile.build.ubuntu18 b/docker/Dockerfile.build.ubuntu18 index 7809d56216..8c1ea3556d 100644 --- a/docker/Dockerfile.build.ubuntu18 +++ b/docker/Dockerfile.build.ubuntu18 @@ -35,4 +35,4 @@ COPY . . RUN /bin/sh oaienv && \ cd cmake_targets && \ mkdir -p log && \ - ./build_oai --eNB --gNB --RU --UE --nrUE --ninja --build-lib all -w USRP --verbose-ci --noavx512 + ./build_oai --eNB --gNB --RU --UE --nrUE --ninja --build-lib all -w USRP --verbose-ci --noavx512 -c diff --git a/docker/Dockerfile.eNB.rhel7.oc4-4 b/docker/Dockerfile.eNB.rhel7.oc4-4 deleted file mode 100644 index 85c2a17ead..0000000000 --- a/docker/Dockerfile.eNB.rhel7.oc4-4 +++ /dev/null @@ -1,83 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -# Dockerfile for the Open-Air-Interface BUILD service -# Valid for RHEL7 in the OpenShift context (v4.4) -# -#--------------------------------------------------------------------- - -FROM image-registry.openshift-image-registry.svc:5000/oai/oai-ran:latest AS enb-build - - -WORKDIR /oai-enb -COPY . . - -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --eNB - - -#start from scratch for target executable -FROM registry.access.redhat.com/ubi7/ubi:latest as oai-enb - -# Entitlements and RHSM configurations are Open-Shift Secret and ConfigMaps -# It is pre-requisite -RUN rm -Rf /etc/rhsm/ca /etc/pki/entitlement -# Copy the entitlements -COPY ./etc-pki-entitlement /etc/pki/entitlement -# Copy the subscription manager configurations -COPY ./rhsm-conf /etc/rhsm -COPY ./rhsm-ca /etc/rhsm/ca - - -#install developers pkg/repo -RUN rm /etc/rhsm-host && \ - # Initialize /etc/yum.repos.d/redhat.repo - # See https://access.redhat.com/solutions/1443553 - yum repolist --disablerepo=* && \ - yum-config-manager --enable rhel-7-server-optional-rpms rhel-server-rhscl-7-rpms && \ - yum update -y && \ - yum install -y \ - lksctp-tools \ - protobuf-c \ - nettle \ - libyaml && \ - echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf - - -WORKDIR /opt/oai-enb/bin -COPY --from=enb-build /oai-enb/targets/bin/lte-softmodem.Rel15 . - -RUN ldd lte-softmodem.Rel15 - -#EXPOSE 2152/udp # S1U, GTP/UDP -#EXPOSE 22100/tcp # ? -#EXPOSE 36412/udp # S1C, SCTP/UDP -#EXPOSE 36422/udp # X2C, SCTP/UDP -#EXPOSE 50000/udp # IF5 / ORI (control) -#EXPOSE 50001/udp # IF5 / ECPRI (data) - -#CMD ["/opt/oai-enb/bin/lte-softmodem", "-O", "/opt/oai-enb/etc/enb.conf"] -#ENTRYPOINT ["/opt/oai-enb/bin/entrypoint.sh"] - diff --git a/docker/Dockerfile.eNB.rhel8.2 b/docker/Dockerfile.eNB.rhel8.2 index 5296ac2172..23afb5f38d 100644 --- a/docker/Dockerfile.eNB.rhel8.2 +++ b/docker/Dockerfile.eNB.rhel8.2 @@ -43,6 +43,7 @@ RUN yum update -y && \ tzdata \ procps-ng \ atlas \ + gdb \ python3 \ python3-pip \ net-tools \ diff --git a/docker/Dockerfile.eNB.rhel8.2.oc4-4 b/docker/Dockerfile.eNB.rhel8.2.oc4-4 deleted file mode 100644 index 03f6ec8e45..0000000000 --- a/docker/Dockerfile.eNB.rhel8.2.oc4-4 +++ /dev/null @@ -1,124 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -# Dockerfile for the Open-Air-Interface BUILD service -# Valid for RHEL8 in the OpenShift context (v4.4) -# -#--------------------------------------------------------------------- - -FROM image-registry.openshift-image-registry.svc:5000/oai/oai-ran:rhel8-latest AS enb-build - - -WORKDIR /oai-ran - -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - rm -Rf log && \ - mkdir -p log && \ - ./build_oai --eNB --ninja -w USRP - -# debug -#RUN ldconfig -v && ldd /oai-ran/targets/bin/lte-softmodem.Rel15 -#RUN ls -ls /oai-ran/targets/bin -#RUN ls -ls /oai-ran/cmake_targets/ran_build/build/*.so - -#start from scratch for target executable -FROM registry.access.redhat.com/ubi8/ubi:latest as oai-enb - -RUN yum update -y && \ - yum install -y --enablerepo="ubi-8-codeready-builder" \ - lksctp-tools \ - nettle \ - atlas \ - net-tools \ - iproute \ - iputils \ - libyaml && \ - echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ - echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf - -WORKDIR /opt/oai-enb/bin -COPY --from=enb-build /oai-ran/targets/bin/lte-softmodem.Rel15 . - -WORKDIR /usr/local/lib/ -COPY --from=enb-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . -COPY --from=enb-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . -COPY --from=enb-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . -COPY --from=enb-build /oai-ran/targets/bin/libcoding.so . -COPY --from=enb-build /oai-ran/targets/bin/libparams_libconfig.so . -COPY --from=enb-build /oai-ran/cmake_targets/ran_build/build/libdfts.so . -COPY --from=enb-build /oai-ran/cmake_targets/ran_build/build/liboai_iqplayer.so . -RUN /bin/bash -c "ln -s /usr/local/lib/liboai_eth_transpro.so.Rel15 /usr/local/lib/liboai_transpro.so" -RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/liboai_device.so" -RUN /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/librfsimulator.so" - -COPY --from=enb-build /usr/local/lib/libprotobuf-c.so.1 . - -COPY --from=enb-build /lib64/libconfig.so.9 /lib64 -COPY --from=enb-build /lib64/libblas.so.3 /lib64 -COPY --from=enb-build /lib64/liblapack.so.3 /lib64 -COPY --from=enb-build /lib64/liblapacke.so.3 /lib64 -COPY --from=enb-build /lib64/libboost_chrono.so.1.66.0 /lib64 -COPY --from=enb-build /lib64/libboost_date_time.so.1.66.0 /lib64 -COPY --from=enb-build /lib64/libboost_filesystem.so.1.66.0 /lib64 -COPY --from=enb-build /lib64/libboost_program_options.so.1.66.0 /lib64 -COPY --from=enb-build /lib64/libboost_serialization.so.1.66.0 /lib64 -COPY --from=enb-build /lib64/libboost_thread.so.1.66.0 /lib64 -COPY --from=enb-build /lib64/libboost_system.so.1.66.0 /lib64 -COPY --from=enb-build /lib64/libboost_unit_test_framework.so.1.66.0 /lib64 -COPY --from=enb-build /lib64/libboost_atomic.so.1.66.0 /lib64 -COPY --from=enb-build /lib64/libboost_timer.so.1.66.0 /lib64 -COPY --from=enb-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 - -RUN ldconfig - -#debug -RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -RUN ldd /usr/local/lib/librfsimulator.so.Rel15 -RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 -RUN ldd /usr/local/lib/libcoding.so -RUN ldd /usr/local/lib/libparams_libconfig.so -RUN ldd /usr/local/lib/libdfts.so -RUN ldd /usr/local/lib/liboai_iqplayer.so -RUN ldd /opt/oai-enb/bin/lte-softmodem.Rel15 - -# Copy the relevant configuration files for eNB -WORKDIR /opt/oai-enb/etc -COPY --from=enb-build /oai-ran/ci-scripts/conf_files/enb.* . -COPY --from=enb-build /oai-ran/ci-scripts/conf_files/rcc.* . -COPY --from=enb-build /oai-ran/ci-scripts/conf_files/cu.* . -COPY --from=enb-build /oai-ran/ci-scripts/conf_files/du.* . -COPY --from=enb-build /oai-ran/ci-scripts/conf_files/rru.* . - -WORKDIR /opt/oai-enb - -#EXPOSE 2152/udp # S1U, GTP/UDP -#EXPOSE 22100/tcp # ? -#EXPOSE 36412/udp # S1C, SCTP/UDP -#EXPOSE 36422/udp # X2C, SCTP/UDP -#EXPOSE 50000/udp # IF5 / ORI (control) -#EXPOSE 50001/udp # IF5 / ECPRI (data) - -#CMD ["/opt/oai-enb/bin/lte-softmodem", "-O", "/opt/oai-enb/etc/enb.conf"] -#ENTRYPOINT ["/opt/oai-enb/bin/entrypoint.sh"] -CMD ["sleep", "infinity"] diff --git a/docker/Dockerfile.eNB.ubuntu18 b/docker/Dockerfile.eNB.ubuntu18 index f95a03398a..2b50dcadfb 100644 --- a/docker/Dockerfile.eNB.ubuntu18 +++ b/docker/Dockerfile.eNB.ubuntu18 @@ -53,6 +53,7 @@ RUN apt-get update && \ iputils-ping \ iproute2 \ iperf \ + gdb \ python \ python3 \ python3-six \ diff --git a/docker/Dockerfile.gNB.rhel7.oc4-4 b/docker/Dockerfile.gNB.rhel7.oc4-4 deleted file mode 100644 index 5165dd9715..0000000000 --- a/docker/Dockerfile.gNB.rhel7.oc4-4 +++ /dev/null @@ -1,89 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -# Dockerfile for the Open-Air-Interface BUILD service -# Valid for RHEL7 in the OpenShift context (v4.4) -# -#--------------------------------------------------------------------- - -FROM image-registry.openshift-image-registry.svc:5000/oai/oai-ran:latest AS gnb-build - - -WORKDIR /oai-gnb -COPY . . - -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai --gNB - - -#start from scratch for target executable -FROM registry.access.redhat.com/ubi7/ubi:latest as oai-gnb - -# Entitlements and RHSM configurations are Open-Shift Secret and ConfigMaps -# It is pre-requisite -RUN rm -Rf /etc/rhsm/ca /etc/pki/entitlement -# Copy the entitlements -COPY ./etc-pki-entitlement /etc/pki/entitlement -# Copy the subscription manager configurations -COPY ./rhsm-conf /etc/rhsm -COPY ./rhsm-ca /etc/rhsm/ca - - -#install developers pkg/repo -RUN rm /etc/rhsm-host && \ - # Initialize /etc/yum.repos.d/redhat.repo - # See https://access.redhat.com/solutions/1443553 - yum repolist --disablerepo=* && \ - yum-config-manager --enable rhel-7-server-optional-rpms rhel-server-rhscl-7-rpms && \ - yum update -y && \ - yum install -y \ - libXpm \ - libX11 \ - atlas \ - blas \ - lapack \ - lksctp-tools \ - protobuf-c \ - nettle \ - libyaml && \ - echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf - -WORKDIR /opt/oai-gnb/bin -COPY --from=gnb-build /oai-gnb/targets/bin/nr-softmodem.Rel15 . -WORKDIR /lib64 -COPY --from=gnb-build /lib64/libforms.so.2 . - -RUN ldd /opt/oai-gnb/bin/nr-softmodem.Rel15 - -#EXPOSE 2152/udp # S1U, GTP/UDP -#EXPOSE 22100/tcp # ? -#EXPOSE 36412/udp # S1C, SCTP/UDP -#EXPOSE 36422/udp # X2C, SCTP/UDP -#EXPOSE 50000/udp # IF5 / ORI (control) -#EXPOSE 50001/udp # IF5 / ECPRI (data) - -#CMD ["/opt/oai-gnb/bin/nr-softmodem", "-O", "/opt/oai-gnb/etc/gnb.conf"] -#ENTRYPOINT ["/opt/oai-gnb/bin/entrypoint.sh"] - diff --git a/docker/Dockerfile.gNB.rhel8.2 b/docker/Dockerfile.gNB.rhel8.2 index 9ec7ee7556..f782384f58 100644 --- a/docker/Dockerfile.gNB.rhel8.2 +++ b/docker/Dockerfile.gNB.rhel8.2 @@ -46,6 +46,7 @@ RUN yum repolist --disablerepo=* && \ lksctp-tools \ nettle \ tzdata \ + gdb \ python3 \ python3-pip \ net-tools \ diff --git a/docker/Dockerfile.gNB.rhel8.2.oc4-4 b/docker/Dockerfile.gNB.rhel8.2.oc4-4 deleted file mode 100644 index 6c88d3ad8e..0000000000 --- a/docker/Dockerfile.gNB.rhel8.2.oc4-4 +++ /dev/null @@ -1,128 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -# Dockerfile for the Open-Air-Interface BUILD service -# Valid for RHEL8 in the OpenShift context (v4.4) -# -#--------------------------------------------------------------------- - -FROM image-registry.openshift-image-registry.svc:5000/oai/oai-ran:rhel8-latest AS gnb-build - - -WORKDIR /oai-ran - -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - rm -Rf log && \ - mkdir -p log && \ - ./build_oai --gNB --ninja -w USRP - -#debug -#RUN ldconfig -v -#RUN ldd /oai-ran/targets/bin/nr-softmodem.Rel15 -#RUN ls -lst /oai-ran/targets/bin -#RUN ls -lst /oai-ran/cmake_targets/ran_build/build/*.so - -#start from scratch for target executable -FROM registry.access.redhat.com/ubi8/ubi:latest as oai-gnb - -RUN yum repolist --disablerepo=* && \ - yum update -y && \ - yum install -y --enablerepo="ubi-8-codeready-builder" \ - libXpm \ - libX11 \ - atlas \ - lksctp-tools \ - nettle \ - net-tools \ - iputils \ - libyaml && \ - echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ - echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf - -WORKDIR /opt/oai-gnb/bin -COPY --from=gnb-build /oai-ran/targets/bin/nr-softmodem.Rel15 . - -WORKDIR /usr/local/lib/ -COPY --from=gnb-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . -COPY --from=gnb-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . -COPY --from=gnb-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . -COPY --from=gnb-build /oai-ran/targets/bin/libcoding.so . -COPY --from=gnb-build /oai-ran/targets/bin/libparams_libconfig.so . -COPY --from=gnb-build /oai-ran/cmake_targets/ran_build/build/libdfts.so . -COPY --from=gnb-build /oai-ran/cmake_targets/ran_build/build/libldpc.so . -COPY --from=gnb-build /oai-ran/cmake_targets/ran_build/build/libldpc_optim.so . -COPY --from=gnb-build /oai-ran/cmake_targets/ran_build/build/libldpc_optim8seg.so . -COPY --from=gnb-build /oai-ran/cmake_targets/ran_build/build/libldpc_orig.so . - -RUN /bin/bash -c "ln -s /usr/local/lib/liboai_eth_transpro.so.Rel15 /usr/local/lib/liboai_transpro.so" -RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/liboai_device.so" -RUN /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/librfsimulator.so" -COPY --from=gnb-build /usr/local/lib/libprotobuf-c.so.1 . - -COPY --from=gnb-build /lib64/libconfig.so.9 /lib64 -COPY --from=gnb-build /lib64/libforms.so.2 /lib64 -COPY --from=gnb-build /lib64/libblas.so.3 /lib64 -COPY --from=gnb-build /lib64/liblapack.so.3 /lib64 -COPY --from=gnb-build /lib64/liblapacke.so.3 /lib64 -COPY --from=gnb-build /lib64/libboost_chrono.so.1.66.0 /lib64 -COPY --from=gnb-build /lib64/libboost_date_time.so.1.66.0 /lib64 -COPY --from=gnb-build /lib64/libboost_filesystem.so.1.66.0 /lib64 -COPY --from=gnb-build /lib64/libboost_program_options.so.1.66.0 /lib64 -COPY --from=gnb-build /lib64/libboost_serialization.so.1.66.0 /lib64 -COPY --from=gnb-build /lib64/libboost_thread.so.1.66.0 /lib64 -COPY --from=gnb-build /lib64/libboost_system.so.1.66.0 /lib64 -COPY --from=gnb-build /lib64/libboost_unit_test_framework.so.1.66.0 /lib64 -COPY --from=gnb-build /lib64/libboost_atomic.so.1.66.0 /lib64 -COPY --from=gnb-build /lib64/libboost_timer.so.1.66.0 /lib64 -COPY --from=gnb-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 - -RUN ldconfig -#debug -RUN ldd /opt/oai-gnb/bin/nr-softmodem.Rel15 -RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -RUN ldd /usr/local/lib/librfsimulator.so.Rel15 -RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 -RUN ldd /usr/local/lib/libcoding.so -RUN ldd /usr/local/lib/libparams_libconfig.so -RUN ldd /usr/local/lib/libdfts.so -RUN ldd /usr/local/lib/libldpc.so -RUN ldd /usr/local/lib/libldpc_optim.so -RUN ldd /usr/local/lib/libldpc_optim8seg.so -RUN ldd /usr/local/lib/libldpc_orig.so - -# Copy the relevant configuration files for gNB -WORKDIR /opt/oai-gnb/etc -COPY --from=gnb-build /oai-ran/ci-scripts/conf_files/gnb.* . - -WORKDIR /opt/oai-gnb -#EXPOSE 2152/udp # S1U, GTP/UDP -#EXPOSE 22100/tcp # ? -#EXPOSE 36412/udp # S1C, SCTP/UDP -#EXPOSE 36422/udp # X2C, SCTP/UDP -#EXPOSE 50000/udp # IF5 / ORI (control) -#EXPOSE 50001/udp # IF5 / ECPRI (data) - -#CMD ["/opt/oai-gnb/bin/nr-softmodem", "-O", "/opt/oai-gnb/etc/gnb.conf"] -#ENTRYPOINT ["/opt/oai-gnb/bin/entrypoint.sh"] -CMD ["sleep", "infinity"] diff --git a/docker/Dockerfile.gNB.ubuntu18 b/docker/Dockerfile.gNB.ubuntu18 index 6a98c8d3ce..11669c2af4 100644 --- a/docker/Dockerfile.gNB.ubuntu18 +++ b/docker/Dockerfile.gNB.ubuntu18 @@ -52,6 +52,7 @@ RUN apt-get update && \ net-tools \ iproute2 \ iputils-ping \ + gdb \ python \ python3 \ python3-six \ diff --git a/docker/Dockerfile.lteRU.rhel8.2 b/docker/Dockerfile.lteRU.rhel8.2 index b41aee36dc..f20910ff51 100644 --- a/docker/Dockerfile.lteRU.rhel8.2 +++ b/docker/Dockerfile.lteRU.rhel8.2 @@ -41,6 +41,7 @@ RUN yum update -y && \ tzdata \ procps-ng \ atlas \ + gdb \ python3 \ python3-pip \ net-tools \ diff --git a/docker/Dockerfile.lteRU.ubuntu18 b/docker/Dockerfile.lteRU.ubuntu18 index 1810afb621..157a5a615a 100644 --- a/docker/Dockerfile.lteRU.ubuntu18 +++ b/docker/Dockerfile.lteRU.ubuntu18 @@ -47,6 +47,7 @@ RUN apt-get update && \ libatlas3-base \ libconfig9 \ net-tools \ + gdb \ python \ python3 \ python3-six \ diff --git a/docker/Dockerfile.lteUE.rhel8.2 b/docker/Dockerfile.lteUE.rhel8.2 index ab7d224939..303394ea27 100644 --- a/docker/Dockerfile.lteUE.rhel8.2 +++ b/docker/Dockerfile.lteUE.rhel8.2 @@ -44,6 +44,7 @@ RUN yum update -y && \ nettle \ tzdata \ atlas \ + gdb \ python3 \ python3-pip \ iproute \ diff --git a/docker/Dockerfile.lteUE.rhel8.2.oc4-4 b/docker/Dockerfile.lteUE.rhel8.2.oc4-4 deleted file mode 100644 index cc492882f5..0000000000 --- a/docker/Dockerfile.lteUE.rhel8.2.oc4-4 +++ /dev/null @@ -1,122 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -# Dockerfile for the Open-Air-Interface BUILD service -# Valid for RHEL8 in the OpenShift context (v4.4) -# -#--------------------------------------------------------------------- - -FROM image-registry.openshift-image-registry.svc:5000/oai/oai-ran:rhel8-latest AS lte-ue-build - - -WORKDIR /oai-ran - -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - rm -Rf log && \ - mkdir -p log && \ - ./build_oai --UE --ninja -w USRP - -# debug -#RUN ldconfig -v && ldd /oai-ran/targets/bin/lte-uesoftmodem.Rel15 -#RUN ls -lst /oai-ran/targets/bin -#RUN ls -lst /oai-ran/cmake_targets/ran_build/build/*.so - -#start from scratch for target executable -FROM registry.access.redhat.com/ubi8/ubi:latest as oai-lte-ue - -RUN yum update -y && \ - yum install -y --enablerepo="ubi-8-codeready-builder" \ - lksctp-tools \ - nettle \ - atlas \ - iproute \ - net-tools \ - iputils \ - libyaml && \ - echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ - echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf - -WORKDIR /opt/oai-lte-ue/bin -COPY --from=lte-ue-build /oai-ran/targets/bin/lte-uesoftmodem.Rel15 . -COPY --from=lte-ue-build /oai-ran/targets/bin/conf2uedata . -COPY --from=lte-ue-build /oai-ran/targets/bin/nvram . -COPY --from=lte-ue-build /oai-ran/targets/bin/usim . -COPY --from=lte-ue-build /oai-ran/targets/bin/.ue_emm.nvram0 . -COPY --from=lte-ue-build /oai-ran/targets/bin/.ue.nvram0 . -COPY --from=lte-ue-build /oai-ran/targets/bin/.usim.nvram0 . - -WORKDIR /usr/local/lib/ -COPY --from=lte-ue-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . -COPY --from=lte-ue-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . -COPY --from=lte-ue-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . -COPY --from=lte-ue-build /oai-ran/targets/bin/libcoding.so . -COPY --from=lte-ue-build /oai-ran/targets/bin/libparams_libconfig.so . -COPY --from=lte-ue-build /oai-ran/cmake_targets/ran_build/build/libSIMU.so . -COPY --from=lte-ue-build /oai-ran/cmake_targets/ran_build/build/libdfts.so . -RUN /bin/bash -c "ln -s /usr/local/lib/liboai_eth_transpro.so.Rel15 /usr/local/lib/liboai_transpro.so" -RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/liboai_device.so" -RUN /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/librfsimulator.so" - -COPY --from=lte-ue-build /usr/local/lib/libprotobuf-c.so.1 . - -COPY --from=lte-ue-build /lib64/libconfig.so.9 /lib64 -COPY --from=lte-ue-build /lib64/libblas.so.3 /lib64 -COPY --from=lte-ue-build /lib64/liblapack.so.3 /lib64 -COPY --from=lte-ue-build /lib64/liblapacke.so.3 /lib64 -COPY --from=lte-ue-build /lib64/libboost_chrono.so.1.66.0 /lib64 -COPY --from=lte-ue-build /lib64/libboost_date_time.so.1.66.0 /lib64 -COPY --from=lte-ue-build /lib64/libboost_filesystem.so.1.66.0 /lib64 -COPY --from=lte-ue-build /lib64/libboost_program_options.so.1.66.0 /lib64 -COPY --from=lte-ue-build /lib64/libboost_serialization.so.1.66.0 /lib64 -COPY --from=lte-ue-build /lib64/libboost_thread.so.1.66.0 /lib64 -COPY --from=lte-ue-build /lib64/libboost_system.so.1.66.0 /lib64 -COPY --from=lte-ue-build /lib64/libboost_unit_test_framework.so.1.66.0 /lib64 -COPY --from=lte-ue-build /lib64/libboost_atomic.so.1.66.0 /lib64 -COPY --from=lte-ue-build /lib64/libboost_timer.so.1.66.0 /lib64 -COPY --from=lte-ue-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 - -RUN ldconfig - -#debug -RUN ldd /opt/oai-lte-ue/bin/lte-uesoftmodem.Rel15 -RUN ldd /opt/oai-lte-ue/bin/conf2uedata -RUN ldd /opt/oai-lte-ue/bin/nvram -RUN ldd /opt/oai-lte-ue/bin/usim -RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -RUN ldd /usr/local/lib/librfsimulator.so.Rel15 -RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 -RUN ldd /usr/local/lib/libcoding.so -RUN ldd /usr/local/lib/libparams_libconfig.so -RUN ldd /usr/local/lib/libSIMU.so -RUN ldd /usr/local/lib/libdfts.so - -# Copy the relevant configuration files for eNB -WORKDIR /opt/oai-lte-ue/etc -COPY --from=lte-ue-build /oai-ran/ci-scripts/conf_files/ue.* . -COPY --from=lte-ue-build /oai-ran/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf ./ue_usim.conf - -WORKDIR /opt/oai-lte-ue -#CMD ["/opt/oai-lte-ue/bin/lte-uesoftmodem", "-O", "/opt/oai-lte-ue/etc/enb.conf"] -#ENTRYPOINT ["/opt/oai-lte-ue/bin/entrypoint.sh"] -CMD ["sleep", "infinity"] diff --git a/docker/Dockerfile.nrUE.rhel8.2 b/docker/Dockerfile.nrUE.rhel8.2 index dfb28cfd1d..3ee93ed5d2 100644 --- a/docker/Dockerfile.nrUE.rhel8.2 +++ b/docker/Dockerfile.nrUE.rhel8.2 @@ -46,6 +46,7 @@ RUN yum update -y && \ iputils \ iproute \ atlas \ + gdb \ python3 \ python3-pip \ libXpm \ diff --git a/docker/Dockerfile.nrUE.rhel8.2.oc4-4 b/docker/Dockerfile.nrUE.rhel8.2.oc4-4 deleted file mode 100644 index 2d018c96af..0000000000 --- a/docker/Dockerfile.nrUE.rhel8.2.oc4-4 +++ /dev/null @@ -1,119 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -# Dockerfile for the Open-Air-Interface BUILD service -# Valid for RHEL8 in the OpenShift context (v4.4) -# -#--------------------------------------------------------------------- - -FROM image-registry.openshift-image-registry.svc:5000/oai/oai-ran:rhel8-latest AS nr-ue-build - - -WORKDIR /oai-ran - -#run build_oai to build the target image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - rm -Rf log && \ - mkdir -p log && \ - ./build_oai --nrUE --ninja -w USRP - -# debug -#RUN ldconfig -v -#RUN ldd /oai-ran/targets/bin/nr-uesoftmodem.Rel15 -#RUN ls -lst /oai-ran/targets/bin -#RUN ls -lst /oai-ran/cmake_targets/ran_build/build/*.so - -#start from scratch for target executable -FROM registry.access.redhat.com/ubi8/ubi:latest as oai-nr-ue - -RUN yum update -y && \ - yum install -y --enablerepo="ubi-8-codeready-builder" \ - lksctp-tools \ - nettle \ - net-tools \ - iputils \ - atlas \ - libXpm \ - libX11 \ - libyaml && \ - echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ - echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf - -WORKDIR /opt/oai-nr-ue/bin -COPY --from=nr-ue-build /oai-ran/targets/bin/nr-uesoftmodem.Rel15 . - -WORKDIR /usr/local/lib/ -COPY --from=nr-ue-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . -COPY --from=nr-ue-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . -COPY --from=nr-ue-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . -COPY --from=nr-ue-build /oai-ran/targets/bin/libcoding.so . -COPY --from=nr-ue-build /oai-ran/targets/bin/libparams_libconfig.so . -COPY --from=nr-ue-build /oai-ran/cmake_targets/ran_build/build/libdfts.so . -COPY --from=nr-ue-build /oai-ran/cmake_targets/ran_build/build/libldpc.so . -COPY --from=nr-ue-build /oai-ran/cmake_targets/ran_build/build/libldpc_optim.so . -COPY --from=nr-ue-build /oai-ran/cmake_targets/ran_build/build/libldpc_optim8seg.so . -COPY --from=nr-ue-build /oai-ran/cmake_targets/ran_build/build/libldpc_orig.so . -RUN /bin/bash -c "ln -s /usr/local/lib/liboai_eth_transpro.so.Rel15 /usr/local/lib/liboai_transpro.so" -RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/liboai_device.so" -RUN /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/librfsimulator.so" - -COPY --from=nr-ue-build /usr/local/lib/libprotobuf-c.so.1 . - -COPY --from=nr-ue-build /lib64/libconfig.so.9 /lib64 -COPY --from=nr-ue-build /lib64/libblas.so.3 /lib64 -COPY --from=nr-ue-build /lib64/liblapack.so.3 /lib64 -COPY --from=nr-ue-build /lib64/liblapacke.so.3 /lib64 -COPY --from=nr-ue-build /lib64/libforms.so.2 /lib64 -COPY --from=nr-ue-build /lib64/libboost_chrono.so.1.66.0 /lib64 -COPY --from=nr-ue-build /lib64/libboost_date_time.so.1.66.0 /lib64 -COPY --from=nr-ue-build /lib64/libboost_filesystem.so.1.66.0 /lib64 -COPY --from=nr-ue-build /lib64/libboost_program_options.so.1.66.0 /lib64 -COPY --from=nr-ue-build /lib64/libboost_serialization.so.1.66.0 /lib64 -COPY --from=nr-ue-build /lib64/libboost_thread.so.1.66.0 /lib64 -COPY --from=nr-ue-build /lib64/libboost_system.so.1.66.0 /lib64 -COPY --from=nr-ue-build /lib64/libboost_unit_test_framework.so.1.66.0 /lib64 -COPY --from=nr-ue-build /lib64/libboost_atomic.so.1.66.0 /lib64 -COPY --from=nr-ue-build /lib64/libboost_timer.so.1.66.0 /lib64 -COPY --from=nr-ue-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 - -RUN ldconfig -RUN ldd /opt/oai-nr-ue/bin/nr-uesoftmodem.Rel15 -RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -RUN ldd /usr/local/lib/librfsimulator.so.Rel15 -RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 -RUN ldd /usr/local/lib/libcoding.so -RUN ldd /usr/local/lib/libparams_libconfig.so -RUN ldd /usr/local/lib/libdfts.so -RUN ldd /usr/local/lib/libldpc.so -RUN ldd /usr/local/lib/libldpc_optim.so -RUN ldd /usr/local/lib/libldpc_optim8seg.so -RUN ldd /usr/local/lib/libldpc_orig.so - -# Copy the relevant configuration files for eNB -WORKDIR /opt/oai-nr-ue/etc -COPY --from=nr-ue-build /oai-ran/ci-scripts/conf_files/ue.* . - -WORKDIR /opt/oai-nr-ue -#CMD ["/opt/oai-nr-ue/bin/nr-uesoftmodem", "-O", "/opt/oai-nr-ue/etc/enb.conf"] -#ENTRYPOINT ["/opt/oai-nr-ue/bin/entrypoint.sh"] -CMD ["sleep", "infinity"] diff --git a/docker/Dockerfile.nrUE.ubuntu18 b/docker/Dockerfile.nrUE.ubuntu18 index 9f68b947cd..0997783b8b 100644 --- a/docker/Dockerfile.nrUE.ubuntu18 +++ b/docker/Dockerfile.nrUE.ubuntu18 @@ -50,6 +50,7 @@ RUN apt-get update && \ libconfig9 \ openssl \ net-tools \ + gdb \ python \ python3 \ python3-six \ diff --git a/docker/Dockerfile.phySim.rhel8.2 b/docker/Dockerfile.phySim.rhel8.2 index b4eb9a1eeb..507b56f18d 100644 --- a/docker/Dockerfile.phySim.rhel8.2 +++ b/docker/Dockerfile.phySim.rhel8.2 @@ -38,7 +38,7 @@ RUN yum install -y libasan RUN /bin/sh oaienv && \ cd cmake_targets && \ mkdir -p log && \ - ./build_oai --phy_simulators --ninja --verbose-ci --sanitize-address --noavx512 + ./build_oai --phy_simulators --ninja --verbose-ci --sanitize-address --noavx512 -c #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-physim diff --git a/docker/Dockerfile.ran.rhel7.oc4-4 b/docker/Dockerfile.ran.rhel7.oc4-4 deleted file mode 100644 index 2f0423801a..0000000000 --- a/docker/Dockerfile.ran.rhel7.oc4-4 +++ /dev/null @@ -1,74 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -# Dockerfile for the Open-Air-Interface BUILD service -# Valid for RHEL7 in the OpenShift context (v4.4) -# -#--------------------------------------------------------------------- - - -FROM registry.access.redhat.com/ubi7/ubi:latest AS ran-base - -# Entitlements and RHSM configurations are Open-Shift Secret and ConfigMaps -# It is pre-requisite -RUN rm -Rf /etc/rhsm/ca /etc/pki/entitlement -# Copy the entitlements -COPY ./etc-pki-entitlement /etc/pki/entitlement -# Copy the subscription manager configurations -COPY ./rhsm-conf /etc/rhsm -COPY ./rhsm-ca /etc/rhsm/ca - - -#install developers pkg/repo -RUN rm /etc/rhsm-host && \ - # Initialize /etc/yum.repos.d/redhat.repo - # See https://access.redhat.com/solutions/1443553 - yum repolist --disablerepo=* && \ - yum-config-manager --enable rhel-7-server-optional-rpms rhel-server-rhscl-7-rpms && \ - yum update -y && \ - yum install -y \ - #gcc needed for build_oai - gcc gcc-c++ \ - diffutils \ - file \ - psmisc \ - git \ - #unzip is needed for protobuf - unzip && \ - echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf - -# In some network environments, GIT proxy is required -RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi" - -#create the WORKDIR -WORKDIR /oai-ran -COPY . . - -#run build_oai -I to get the builder image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai -I - -#as the image is public, we need to remove the subscription manager configurations -#RUN rm -Rf /etc/rhsm /etc/pki/entitlement - diff --git a/docker/Dockerfile.ran.rhel8.2.oc4-4 b/docker/Dockerfile.ran.rhel8.2.oc4-4 deleted file mode 100644 index 93af2b0e37..0000000000 --- a/docker/Dockerfile.ran.rhel8.2.oc4-4 +++ /dev/null @@ -1,74 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -# Dockerfile for the Open-Air-Interface BUILD service -# Valid for RHEL8 in the OpenShift context (v4.4) -# -#--------------------------------------------------------------------- - - -FROM registry.access.redhat.com/ubi8/ubi:latest AS ran-base - -# Entitlements and RHSM configurations are Open-Shift Secret and ConfigMaps -# It is pre-requisite -RUN rm -Rf /etc/rhsm/ca /etc/pki/entitlement -# Copy the entitlements -COPY ./etc-pki-entitlement /etc/pki/entitlement -# Copy the subscription manager configurations -COPY ./rhsm-conf /etc/rhsm -COPY ./rhsm-ca /etc/rhsm/ca - -#install developers pkg/repo -RUN rm /etc/rhsm-host && \ - # Initialize /etc/yum.repos.d/redhat.repo - # See https://access.redhat.com/solutions/1443553 - yum repolist --disablerepo=* && \ - subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms && \ - yum update -y && \ - yum install -y \ - #gcc needed for build_oai - gcc gcc-c++ \ - diffutils \ - file \ - psmisc \ - git \ - #unzip is needed for protobuf - unzip && \ - echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ - echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf - -# In some network environments, GIT proxy is required -RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi" - -#create the WORKDIR -WORKDIR /oai-ran -COPY . . - -#run build_oai -I to get the builder image -RUN /bin/sh oaienv && \ - cd cmake_targets && \ - mkdir -p log && \ - ./build_oai -I -w USRP - -#as the image is public, we need to remove the subscription certificates -RUN rm -Rf /etc/pki/entitlement/*.pem - diff --git a/docker/README.md b/docker/README.md index 85f553c721..7844b46bce 100644 --- a/docker/README.md +++ b/docker/README.md @@ -78,9 +78,7 @@ The currently-supported OS are: The currently-supported cluster version is: -- `rhel8.2.oc4-4` - -We have also `rhel7.oc4-4` support but it will be discontinued soon. +- `rhel8.2.oc4-9` For more details in build within a Openshift Cluster, see [OpenShift README](../openshift/README.md) for more details. diff --git a/docker/scripts/enb_entrypoint.sh b/docker/scripts/enb_entrypoint.sh index 825dfd73c1..2d49a0ed20 100755 --- a/docker/scripts/enb_entrypoint.sh +++ b/docker/scripts/enb_entrypoint.sh @@ -51,9 +51,15 @@ for c in ${CONFIG_FILES}; do # render template and inline replace config file sed -i "${EXPRESSIONS}" ${c} + + echo "==================================" + echo "== Configuration file: ${c}" + cat ${c} done # Load the USRP binaries +echo "==================================" +echo "== Load USRP binaries" if [[ -v USE_B2XX ]]; then $PREFIX/bin/uhd_images_downloader.py -t b2xx elif [[ -v USE_X3XX ]]; then @@ -62,6 +68,9 @@ elif [[ -v USE_N3XX ]]; then $PREFIX/bin/uhd_images_downloader.py -t n3xx fi +# enable printing of stack traces on assert +export gdbStacks=1 + echo "==================================" echo "== Starting eNB soft modem" if [[ -v USE_ADDITIONAL_OPTIONS ]]; then diff --git a/docker/scripts/enb_parameters.yaml b/docker/scripts/enb_parameters.yaml index 69baaebb3d..b3cd02e941 100644 --- a/docker/scripts/enb_parameters.yaml +++ b/docker/scripts/enb_parameters.yaml @@ -32,11 +32,12 @@ env: "@ENB_NAME@" - key: eNB_name env: "@ENB_NAME@" - - key: plmn_list - env: - mcc: "@MCC@" - mnc: "@MNC@" - mnc_length: "@MNC_LENGTH@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" - key: tracking_area_code env: "@TAC@" - key: local_s_if_name @@ -75,11 +76,12 @@ env: "@ENB_NAME@" - key: eNB_name env: "@ENB_NAME@" - - key: plmn_list - env: - mcc: "@MCC@" - mnc: "@MNC@" - mnc_length: "@MNC_LENGTH@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" - key: tracking_area_code env: "@TAC@" - key: local_n_if_name @@ -136,11 +138,12 @@ env: "@ENB_NAME@" - key: eNB_name env: "@ENB_NAME@" - - key: plmn_list - env: - mcc: "@MCC@" - mnc: "@MNC@" - mnc_length: "@MNC_LENGTH@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" - key: tracking_area_code env: "@TAC@" - key: eutra_band @@ -187,11 +190,12 @@ env: "@ENB_NAME@" - key: eNB_name env: "@ENB_NAME@" - - key: plmn_list - env: - mcc: "@MCC@" - mnc: "@MNC@" - mnc_length: "@MNC_LENGTH@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" - key: tracking_area_code env: "@TAC@" - key: eutra_band @@ -226,11 +230,12 @@ env: "@ENB_NAME@" - key: eNB_name env: "@ENB_NAME@" - - key: plmn_list - env: - mcc: "@MCC@" - mnc: "@MNC@" - mnc_length: "@MNC_LENGTH@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" - key: tracking_area_code env: "@TAC@" - key: local_s_if_name @@ -271,11 +276,12 @@ env: "@ENB_NAME@" - key: eNB_name env: "@ENB_NAME@" - - key: plmn_list - env: - mcc: "@MCC@" - mnc: "@MNC@" - mnc_length: "@MNC_LENGTH@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" - key: tracking_area_code env: "@TAC@" - key: eutra_band @@ -316,11 +322,12 @@ env: "@ENB_NAME@" - key: eNB_name env: "@ENB_NAME@" - - key: plmn_list - env: - mcc: "@MCC@" - mnc: "@MNC@" - mnc_length: "@MNC_LENGTH@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" - key: tracking_area_code env: "@TAC@" - key: eutra_band @@ -361,11 +368,12 @@ env: "@ENB_NAME@" - key: eNB_name env: "@ENB_NAME@" - - key: plmn_list - env: - mcc: "@MCC@" - mnc: "@MNC@" - mnc_length: "@MNC_LENGTH@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" - key: tracking_area_code env: "@TAC@" - key: eutra_band diff --git a/docker/scripts/generateTemplate.py b/docker/scripts/generateTemplate.py index 723bf86070..b79d25f8f3 100644 --- a/docker/scripts/generateTemplate.py +++ b/docker/scripts/generateTemplate.py @@ -82,47 +82,32 @@ def main(): with open(f'{inputfile}', mode='r') as inputfile, \ open(outputfile1, mode='w') as outputfile: for line in inputfile: - count = 0 if re.search(r'EHPLMN_LIST', line): outputfile.write(line) continue - if re.search(r'sd = 0x1;', line): - templine = re.sub(r'sd = 0x1;', 'sd = 0x@NSSAI_SD0@;', line) - outputfile.write(templine) - continue - if re.search(r'sd = 0x010203;', line): - templine = re.sub(r'sd = 0x010203;', 'sd = 0x@NSSAI_SD0@;', line) - outputfile.write(templine) - continue - if re.search(r'sd = 0x112233;', line): - templine = re.sub(r'sd = 0x112233;', 'sd = 0x@NSSAI_SD1@;', line) - outputfile.write(templine) - continue + templine = line for key in config["config"]: - if line.find(key["key"]) >= 0: - count += 1 - if re.search(r'preference', line): - templine = line - elif re.search(r'mnc_length', line) and key["key"] == "mnc": + if templine.find(key["key"]) >= 0: + if re.search(r'preference', templine): # false positive + continue + if re.search(r'sdr_addrs', templine): # false positive continue - elif re.search(r'plmn_list', line): - templine = re.sub(r'[0-9]+', '""', line) - templine = re.sub(r'\"\"', key["env"]["mcc"], templine, 1) - templine = re.sub(r'\"\"', key["env"]["mnc"], templine, 1) - templine = re.sub(r'\"\"', key["env"]["mnc_length"], templine, 1) elif re.search('downlink_frequency', line): templine = re.sub(r'[0-9]+', key["env"], line) elif re.search('uplink_frequency_offset', line): templine = re.sub(r'[0-9]+', key["env"], line) - - elif re.search(r'"(.*?)"', line): - templine = re.sub(r'(?<=")[^"]*(?=")', key["env"], line) - elif re.search(r'[0-9]', line): - templine = re.sub(r'\d+', key["env"], line) - outputfile.write(templine) - - if count == 0: - outputfile.write(line) - + # next: matches key = ( "SOMETHING" ) or key = [ "SOMETHING" ] + elif re.search(key["key"] + "\s*=\s*[\(\[]\s*\"[0-9.a-zA-Z:_-]+\"\s*[\)\]]", templine): + templine = re.sub("(" + key["key"] + "\s*=\s*[\(\[]\s*\")[0-9.a-zA-Z:_-]+(\"[\)\]])", + r'\1' + key["env"] + r"\2", templine) + # next: matches key = "SOMETHING" or key = [SOMETHING], + elif re.search(key["key"] + "\s*=\s*[\"\[][0-9.a-zA-Z:_/-]+[\"\]]", templine): + templine = re.sub("(" + key["key"] + "\s*=\s*[\"\[])[0-9.a-zA-Z:_/-]+([\"\]])", + r'\1' + key["env"] + r"\2", templine) + # next: matches key = NUMBER + elif re.search(key["key"] + "\s*=\s*[x0-9]+", templine): # x for "0x" hex start + templine = re.sub("(" + key["key"] + "\s*=\s*(?:0x)?)[x0-9]+", r"\1" + key["env"], templine) + outputfile.write(templine) + if __name__ == "__main__": main() diff --git a/docker/scripts/gnb_entrypoint.sh b/docker/scripts/gnb_entrypoint.sh index 6deff8da10..4e8983599e 100755 --- a/docker/scripts/gnb_entrypoint.sh +++ b/docker/scripts/gnb_entrypoint.sh @@ -51,9 +51,15 @@ for c in ${CONFIG_FILES}; do # render template and inline replace config file sed -i "${EXPRESSIONS}" ${c} + + echo "==================================" + echo "== Configuration file: ${c}" + cat ${c} done # Load the USRP binaries +echo "==================================" +echo "== Load USRP binaries" if [[ -v USE_B2XX ]]; then $PREFIX/bin/uhd_images_downloader.py -t b2xx elif [[ -v USE_X3XX ]]; then @@ -62,6 +68,9 @@ elif [[ -v USE_N3XX ]]; then $PREFIX/bin/uhd_images_downloader.py -t n3xx fi +# enable printing of stack traces on assert +export gdbStacks=1 + echo "==================================" echo "== Starting gNB soft modem" if [[ -v USE_ADDITIONAL_OPTIONS ]]; then diff --git a/docker/scripts/gnb_parameters.yaml b/docker/scripts/gnb_parameters.yaml index 420559ff3f..a7539daa69 100644 --- a/docker/scripts/gnb_parameters.yaml +++ b/docker/scripts/gnb_parameters.yaml @@ -32,11 +32,16 @@ env: "@GNB_NAME@" - key: gNB_name env: "@GNB_NAME@" - - key: plmn_list - env: - mcc: "@MCC@" - mnc: "@MNC@" - mnc_length: "@MNC_LENGTH@" + - key: mcc + env: "@MCC@" + - key: mnc + env: "@MNC@" + - key: mnc_length + env: "@MNC_LENGTH@" + - key: sst + env: "@NSSAI_SST@" + - key: sd + env: "@NSSAI_SD@" - key: tracking_area_code env: "@TAC@" - key: enable_x2 @@ -81,6 +86,8 @@ env: "@TAC@" - key: sst env: "@NSSAI_SST@" + - key: sd + env: "@NSSAI_SD@" - key: ipv4 env: "@AMF_IP_ADDRESS@" - key: GNB_INTERFACE_NAME_FOR_NG_AMF @@ -141,6 +148,8 @@ env: "@TAC@" - key: sst env: "@NSSAI_SST@" + - key: sd + env: "@NSSAI_SD@" - key: ipv4 env: "@AMF_IP_ADDRESS@" - key: GNB_INTERFACE_NAME_FOR_NG_AMF @@ -171,6 +180,8 @@ env: "@TAC@" - key: sst env: "@NSSAI_SST@" + - key: sd + env: "@NSSAI_SD@" - key: ipv4 env: "@AMF_IP_ADDRESS@" - key: GNB_INTERFACE_NAME_FOR_NG_AMF @@ -209,6 +220,8 @@ env: "@TAC@" - key: sst env: "@NSSAI_SST@" + - key: sd + env: "@NSSAI_SD@" - key: ipv4 env: "@AMF_IP_ADDRESS@" - key: GNB_INTERFACE_NAME_FOR_NG_AMF @@ -249,6 +262,8 @@ env: "@TAC@" - key: sst env: "@NSSAI_SST@" + - key: sd + env: "@NSSAI_SD@" - key: ipv4 env: "@AMF_IP_ADDRESS@" - key: GNB_INTERFACE_NAME_FOR_NG_AMF diff --git a/docker/scripts/lte_ru_entrypoint.sh b/docker/scripts/lte_ru_entrypoint.sh index 297e437ac0..746efb30b3 100755 --- a/docker/scripts/lte_ru_entrypoint.sh +++ b/docker/scripts/lte_ru_entrypoint.sh @@ -31,9 +31,15 @@ for c in ${CONFIG_FILES}; do # render template and inline replace config file sed -i "${EXPRESSIONS}" ${c} + + echo "==================================" + echo "== Configuration file: ${c}" + cat ${c} done # Load the USRP binaries +echo "==================================" +echo "== Load USRP binaries" if [[ -v USE_B2XX ]]; then $PREFIX/bin/uhd_images_downloader.py -t b2xx elif [[ -v USE_X3XX ]]; then @@ -42,6 +48,9 @@ elif [[ -v USE_N3XX ]]; then $PREFIX/bin/uhd_images_downloader.py -t n3xx fi +# enable printing of stack traces on assert +export gdbStacks=1 + echo "==================================" echo "== Starting eNB soft modem" if [[ -v USE_ADDITIONAL_OPTIONS ]]; then diff --git a/docker/scripts/lte_ue_entrypoint.sh b/docker/scripts/lte_ue_entrypoint.sh index 82e96dd07f..2bdcb873c9 100755 --- a/docker/scripts/lte_ue_entrypoint.sh +++ b/docker/scripts/lte_ue_entrypoint.sh @@ -30,6 +30,10 @@ for c in ${CONFIG_FILES}; do # render template and inline replace config file sed -i "${EXPRESSIONS}" ${c} + + echo "==================================" + echo "== Configuration file: ${c}" + cat ${c} done #now generate USIM files @@ -38,6 +42,8 @@ cd $PREFIX $PREFIX/bin/conf2uedata -c $PREFIX/etc/ue_usim.conf -o $PREFIX # Load the USRP binaries +echo "==================================" +echo "== Load USRP binaries" if [[ -v USE_B2XX ]]; then $PREFIX/bin/uhd_images_downloader.py -t b2xx elif [[ -v USE_X3XX ]]; then @@ -57,6 +63,9 @@ if [[ -v USE_NFAPI ]]; then new_args+=("$PREFIX/etc/ue.conf") fi +# enable printing of stack traces on assert +export gdbStacks=1 + echo "==================================" echo "== Starting LTE UE soft modem" if [[ -v USE_ADDITIONAL_OPTIONS ]]; then diff --git a/docker/scripts/nr_ue_entrypoint.sh b/docker/scripts/nr_ue_entrypoint.sh index 38b080a41b..616d71b555 100755 --- a/docker/scripts/nr_ue_entrypoint.sh +++ b/docker/scripts/nr_ue_entrypoint.sh @@ -40,9 +40,15 @@ for c in ${CONFIG_FILES}; do # render template and inline replace config file sed -i "${EXPRESSIONS}" ${c} + + echo "==================================" + echo "== Configuration file: ${c}" + cat ${c} done # Load the USRP binaries +echo "==================================" +echo "== Load USRP binaries" if [[ -v USE_B2XX ]]; then $PREFIX/bin/uhd_images_downloader.py -t b2xx elif [[ -v USE_X3XX ]]; then @@ -58,6 +64,9 @@ while [[ $# -gt 0 ]]; do shift done +# enable printing of stack traces on assert +export gdbStacks=1 + echo "==================================" echo "== Starting NR UE soft modem" if [[ -v USE_ADDITIONAL_OPTIONS ]]; then diff --git a/executables/main-ocp.c b/executables/main-ocp.c index 3a1ad6ec19..d05b683f39 100644 --- a/executables/main-ocp.c +++ b/executables/main-ocp.c @@ -1273,11 +1273,7 @@ int main ( int argc, char **argv ) { L1proc->respEncode=(notifiedFIFO_t *) malloc(sizeof(notifiedFIFO_t)); L1proc->respDecode=(notifiedFIFO_t *) malloc(sizeof(notifiedFIFO_t)); - if ( strlen(get_softmodem_params()->threadPoolConfig) > 0 ) - initTpool(get_softmodem_params()->threadPoolConfig, L1proc->threadPool, true); - else - initTpool("n", L1proc->threadPool, true); - + initTpool(get_softmodem_params()->threadPoolConfig, L1proc->threadPool,cpumeas(CPUMEAS_GETSTATE)); initNotifiedFIFO(L1proc->respEncode); initNotifiedFIFO(L1proc->respDecode); } diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 6158765511..176bd640bc 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -233,8 +233,7 @@ void rx_func(void *param) { gNB->common_vars.rxdataF[aa], slot_rx, 0, - gNB->frame_parms.Ncp==EXTENDED?12:14, - gNB->frame_parms.ofdm_symbol_size); + gNB->frame_parms.Ncp==EXTENDED?12:14); } phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx); } @@ -446,20 +445,8 @@ void init_gNB_Tpool(int inst) { gNB = RC.gNB[inst]; gNB_L1_proc_t *proc = &gNB->proc; - int numCPU = sysconf(_SC_NPROCESSORS_ONLN); - LOG_I(PHY,"Number of threads requested in config file: %d, Number of threads available on this machine: %d\n",gNB->thread_pool_size,numCPU); - int threadCnt = min(numCPU, gNB->thread_pool_size); - if (threadCnt < 2) LOG_E(PHY,"Number of threads for gNB should be more than 1. Allocated only %d\n",threadCnt); - char pool[80]; - sprintf(pool,"-1"); - int s_offset = 0; - for (int icpu=1; icputhreadPool, cpumeas(CPUMEAS_GETSTATE)); + // ULSCH decoding threadpool + initTpool(get_softmodem_params()->threadPoolConfig, &gNB->threadPool, cpumeas(CPUMEAS_GETSTATE)); // ULSCH decoder result FIFO initNotifiedFIFO(&gNB->respDecode); @@ -555,7 +542,9 @@ void init_eNB_afterRU(void) { RC.nb_nr_inst = 1; for (inst=0; instldpc_offload_flag = ldpc_offload_flag; phy_init_nr_gNB(gNB,0,0); diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index e4e4eee8ce..e0114b8d14 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -97,7 +97,7 @@ #define CONFIG_HLP_WORKER_CMD "two option for worker 'WORKER_DISABLE' or 'WORKER_ENABLE'\n" #define CONFIG_HLP_USRP_THREAD "having extra thead for usrp tx\n" #define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n" - +#define CONFIG_HLP_LDPC_OFFLOAD "enable LDPC offload\n" #define CONFIG_HLP_USRP_ARGS "set the arguments to identify USRP (same syntax as in UHD)\n" #define CONFIG_HLP_FLOG "Enable online log \n" diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h index fa51b62b35..546fe7bee0 100644 --- a/executables/nr-softmodem.h +++ b/executables/nr-softmodem.h @@ -29,6 +29,7 @@ {"D" , CONFIG_HLP_DLBM_PHYTEST,0, u64ptr:&dlsch_slot_bitmap, defintval:0, TYPE_UINT64, 0}, \ {"U" , CONFIG_HLP_ULBM_PHYTEST,0, u64ptr:&ulsch_slot_bitmap, defintval:0, TYPE_UINT64, 0}, \ {"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, iptr:&usrp_tx_thread, defstrval:0, TYPE_INT, 0}, \ + {"ldpc-offload-enable", CONFIG_HLP_LDPC_OFFLOAD, 0, iptr:&ldpc_offload_flag, defstrval:0, TYPE_INT, 0}, \ {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \ {"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \ } @@ -44,6 +45,7 @@ extern uint32_t target_ul_bw; extern uint64_t dlsch_slot_bitmap; extern uint64_t ulsch_slot_bitmap; extern char *uecap_file; +extern int ldpc_offload_flag; // In nr-gnb.c extern void init_gNB(int single_thread_flag,int wait_for_sync); diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 821325f5f1..08cb7de7e5 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -678,7 +678,7 @@ void processSlotRX(void *arg) { phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, no_relay, NULL ); #else uint64_t a=rdtsc_oai(); - phy_procedures_nrUE_RX(UE, proc, gNB_id, get_nrUE_params()->nr_dlsch_parallel, &phy_pdcch_config, &rxtxD->txFifo); + phy_procedures_nrUE_RX(UE, proc, gNB_id, &phy_pdcch_config, &rxtxD->txFifo); LOG_D(PHY, "In %s: slot %d, time %llu\n", __FUNCTION__, proc->nr_slot_rx, (rdtsc_oai()-a)/3500); #endif diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 92dab90014..d4b0156843 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -243,20 +243,7 @@ uint64_t set_nrUE_optmask(uint64_t bitmask) { nrUE_params_t *get_nrUE_params(void) { return &nrUE_params; } -/* initialie thread pools used for NRUE processing paralleliation */ -void init_tpools(uint8_t nun_dlsch_threads) { - char params[NR_RX_NB_TH*NR_NB_TH_SLOT*3+1]={0}; - for (int i=0; ithreadPoolConfig, &(nrUE_params.Tpool), cpumeas(CPUMEAS_GETSTATE)); //randominit (0); set_taus_seed (0); @@ -447,7 +434,7 @@ int main( int argc, char **argv ) { init_opt() ; load_nrLDPClib(NULL); - + if (ouput_vcd) { vcd_signal_dumper_init("/tmp/openair_dump_nrUE.vcd"); } @@ -518,8 +505,6 @@ int main( int argc, char **argv ) { *mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]); } - init_symbol_rotation(&UE[CC_id]->frame_parms); - init_timeshift_rotation(&UE[CC_id]->frame_parms); init_nr_ue_vars(UE[CC_id], 0, abstraction_flag); } diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index c118db5483..77e7d9e053 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -31,7 +31,7 @@ #define CMDLINE_NRUEPARAMS_DESC { \ {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:&usrp_args, defstrval:"type=b200", TYPE_STRING, 0}, \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ - {"dlsch-parallel", CONFIG_HLP_DLSCH_PARA, 0, u8ptr:&nrUE_params.nr_dlsch_parallel, defintval:0, TYPE_UINT8, 0}, \ + {"dlsch-parallel", CONFIG_HLP_DLSCH_PARA, 0, u8ptr:NULL, defintval:0, TYPE_UINT8, 0}, \ {"offset-divisor", CONFIG_HLP_OFFSET_DIV, 0, uptr:&nrUE_params.ofdm_offset_divisor, defuintval:8, TYPE_UINT32, 0}, \ {"max-ldpc-iterations", CONFIG_HLP_MAX_LDPC_ITERATIONS, 0, u8ptr:&nrUE_params.max_ldpc_iterations, defuintval:5, TYPE_UINT8, 0}, \ {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ @@ -78,7 +78,6 @@ typedef struct { uint64_t optmask; //mask to store boolean config options uint32_t ofdm_offset_divisor; // Divisor for sample offset computation for each OFDM symbol - uint8_t nr_dlsch_parallel; // number of threads for dlsch decoding, 0 means no parallelization uint8_t max_ldpc_iterations; // number of maximum LDPC iterations tpool_t Tpool; // thread pool } nrUE_params_t; diff --git a/executables/softmodem-common.c b/executables/softmodem-common.c index bf30cab847..d42c46a895 100644 --- a/executables/softmodem-common.c +++ b/executables/softmodem-common.c @@ -46,7 +46,7 @@ static softmodem_params_t softmodem_params; char *parallel_config=NULL; char *worker_config=NULL; int usrp_tx_thread = 0; - +int ldpc_offload_flag=0; uint8_t nfapi_mode=0; static mapping softmodem_funcs[] = MAPPING_SOFTMODEM_FUNCTIONS; diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index 8a898c69b8..f0e60f54aa 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -139,7 +139,7 @@ extern int usrp_tx_thread; #define CMDLINE_PARAMS_DESC { \ {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:&RF_CONFIG_FILE, defstrval:NULL, TYPE_STRING, 0},\ {"split73", CONFIG_HLP_SPLIT73, 0, strptr:&SPLIT73, defstrval:NULL, TYPE_STRING, 0}, \ - {"thread-pool", CONFIG_HLP_TPOOL, 0, strptr:&TP_CONFIG, defstrval:"n", TYPE_STRING, 0}, \ + {"thread-pool", CONFIG_HLP_TPOOL, 0, strptr:&TP_CONFIG, defstrval:"-1,-1,-1,-1,-1,-1,-1,-1", TYPE_STRING, 0}, \ {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&PHY_TEST, defintval:0, TYPE_INT, 0}, \ {"do-ra", CONFIG_HLP_DORA, PARAMFLAG_BOOL, iptr:&DO_RA, defintval:0, TYPE_INT, 0}, \ {"sa", CONFIG_HLP_SA, PARAMFLAG_BOOL, iptr:&SA, defintval:0, TYPE_INT, 0}, \ @@ -283,6 +283,7 @@ extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; extern int usrp_tx_thread; extern uint16_t sl_ahead; extern uint16_t sf_ahead; +extern int ldpc_offload_flag; extern int oai_exit; void tx_func(void *param); diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index a28762d1ff..7c91b06962 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -333,6 +333,7 @@ typedef struct //Resource Allocation in time domain uint8_t start_symbol_index; uint8_t nr_of_symbols; + uint32_t tbslbrm; //Optional Data only included if indicated in pduBitmap nfapi_nr_ue_pusch_data_t pusch_data; nfapi_nr_ue_pusch_uci_t pusch_uci; diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h index 5f64d0f006..205e107bf9 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h @@ -777,6 +777,7 @@ typedef struct { } nfapi_nr_dl_tti_pdcch_pdu_rel15_t; typedef struct { + uint8_t ldpcBaseGraph; uint32_t tbSizeLbrmBytes; }nfapi_v3_pdsch_maintenance_parameters_t; @@ -1193,6 +1194,7 @@ typedef struct #define PUSCH_PDU_BITMAP_DFTS_OFDM 0x8 typedef struct { + uint8_t ldpcBaseGraph; uint32_t tbSizeLbrmBytes; }nfapi_v3_pusch_maintenance_parameters_t; @@ -1290,42 +1292,33 @@ typedef struct } nfapi_nr_pucch_pdu_t; -//for srs_pdu: - -typedef struct -{ - uint16_t rnti;//UE RNTI - uint32_t handle;//An opaque handling returned in the SRS.indication - //BWP - uint16_t bwp_size; - uint16_t bwp_start; - uint8_t subcarrier_spacing; - uint8_t cyclic_prefix; - - uint8_t num_ant_ports; - uint8_t num_symbols; - uint8_t num_repetitions; - uint8_t time_start_position;//Starting position in the time domain l0; Note: the MAC undertakes the translation from startPosition to 𝑙0 - uint8_t config_index; - uint16_t sequence_id; - uint8_t bandwidth_index; - uint8_t comb_size; - uint8_t comb_offset;//Transmission comb offset 𝑘 ̄ TC [TS38.211, Sec 6.4.1.4.3] Value: 0 → 1 (combSize = 0) Value: 0 → 3 (combSize = 1) - uint8_t cyclic_shift; - uint8_t frequency_position; - uint16_t frequency_shift; - uint8_t frequency_hopping; - uint8_t group_or_sequence_hopping;//Group or sequence hopping configuration (RRC parameter groupOrSequenceHopping in SRS-Resource - uint8_t resource_type;//Type of SRS resource allocation - uint16_t t_srs;//SRS-Periodicity in slots [TS38.211 Sec 6.4.1.4.4] Value: 1,2,3,4,5,8,10,16,20,32,40,64,80,160,320,640,1280,2560 - uint16_t t_offset;//Slot offset value [TS38.211, Sec 6.4.1.4.3] Value:0->2559 - +typedef struct { + uint16_t rnti; // UE RNTI, Value: 1->65535 + uint32_t handle; // An opaque handling returned in the SRS.indication + uint16_t bwp_size; // Bandwidth part size [3GPP TS 38.213, sec 12]. Number of contiguous PRBs allocated to the BWP, Value: 1->275 + uint16_t bwp_start; // Bandwidth part start RB index from reference CRB [3GPP TS 38.213, sec 12], Value: 0->274 + uint8_t subcarrier_spacing; // subcarrierSpacing [3GPP TS 38.211, sec 4.2], Value:0->4 + uint8_t cyclic_prefix; // Cyclic prefix type [3GPP TS 38.211, sec 4.2], 0: Normal; 1: Extended + uint8_t num_ant_ports; // Number of antenna ports N_SRS_ap [3GPP TS 38.211, Sec 6.4.1.4.1], Value: 0 = 1 port, 1 = 2 ports, 2 = 4 ports + uint8_t num_symbols; // Number of symbols N_SRS_symb [3GPP TS 38.211, Sec 6.4.1.4.1], Value: 0 = 1 symbol, 1 = 2 symbols, 2 = 4 symbols + uint8_t num_repetitions; // Repetition factor R [3GPP TS 38.211, Sec 6.4.1.4.3], Value: 0 = 1, 1 = 2, 2 = 4 + uint8_t time_start_position; // Starting position in the time domain l_0 [3GPP TS 38.211, Sec 6.4.1.4.1], Note: the MAC undertakes the translation from startPosition to l_0, Value: 0 --> 13 + uint8_t config_index; // SRS bandwidth config index C_SRS [3GPP TS 38.211, Sec 6.4.1.4.3], Value: 0 --> 63 + uint16_t sequence_id; // SRS sequence ID n_SRS_ID [3GPP TS 38.211, Sec 6.4.1.4.2], Value: 0 --> 1023 + uint8_t bandwidth_index; // SRS bandwidth index B_SRS [3GPP TS 38.211, Sec 6.4.1.4.3], Value: 0 --> 3 + uint8_t comb_size; // Transmission comb size K_TC [3GPP TS 38.211, Sec 6.4.1.4.2], Value: 0 = comb size 2, 1 = comb size 4, 2 = comb size 8 (Rel16) + uint8_t comb_offset; // Transmission comb offset K'_TC[3GPP TS 38.211, Sec 6.4.1.4.3], Value: 0 --> 1 (combSize = 0), Value: 0 --> 3 (combSize = 1), Value: 0 --> 7 (combSize = 2) + uint8_t cyclic_shift; // Cyclic shift n_CS_SRS [3GPP TS 38.211, Sec 6.4.1.4.2], Value: 0 --> 7 (combSize = 0), Value: 0 --> 11 (combSize = 1), Value: 0 --> 5 (combSize = 2) + uint8_t frequency_position; // Frequency domain position n_RRC [3GPP TS 38.211, Sec 6.4.1.4.3], Value: 0 --> 67 + uint16_t frequency_shift; // Frequency domain shift n_shift [3GPP TS 38.211, Sec 6.4.1.4.3], Value: 0 --> 268 + uint8_t frequency_hopping; // Frequency hopping b_hop [3GPP TS 38.211, Sec 6.4.1.4.3], Value: 0 --> 3 + uint8_t group_or_sequence_hopping; // Group or sequence hopping configuration (RRC parameter groupOrSequenceHopping in SRSResource IE), Value: 0 = No hopping, 1 = Group hopping groupOrSequenceHopping, 2 = Sequence hopping + uint8_t resource_type; // Type of SRS resource allocation [3GPP TS 38.211, Sec 6.4.1.4.3], Value: 0: aperiodic, 1: semi-persistent, 2: periodic + uint16_t t_srs; // SRS-Periodicity in slots [3GPP TS 38.211, Sec 6.4.1.4.4], Value: 1,2,3,4,5,8,10,16,20,32,40,64,80,160,320,640,1280,2560 + uint16_t t_offset; // Slot offset value [3GPP TS 38.211, Sec 6.4.1.4.3], Value:0->2559 nfapi_nr_ul_beamforming_t beamforming; - } nfapi_nr_srs_pdu_t; -// - typedef enum { NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE = 0, NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE = 1, diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c new file mode 100644 index 0000000000..a523e960e2 --- /dev/null +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c @@ -0,0 +1,1656 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Intel Corporation + */ + +/*!\file nrLDPC_decoder_offload.c + * \brief Defines the LDPC decoder + * \author openairinterface + * \date 12-06-2021 + * \version 1.0 + * \note: based on testbbdev test_bbdev_perf.c functions. Harq buffer offset added. + * \mbuf and mempool allocated at the init step, LDPC parameters updated from OAI. + * \warning + */ + +#include +#include +#include "nrLDPCdecoder_defs.h" +#include "nrLDPC_types.h" +#include "nrLDPC_init.h" +#include "nrLDPC_mPass.h" +#include "nrLDPC_cnProc.h" +#include "nrLDPC_bnProc.h" +#include +#define NR_LDPC_ENABLE_PARITY_CHECK + +#ifdef NR_LDPC_DEBUG_MODE +#include "nrLDPC_tools/nrLDPC_debug.h" +#endif + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include "nrLDPC_offload.h" + +#include + +#include +#include +#include +#include +#include +#include +#include + +#define GET_SOCKET(socket_id) (((socket_id) == SOCKET_ID_ANY) ? 0 : (socket_id)) + +#define MAX_QUEUES RTE_MAX_LCORE +#define TEST_REPETITIONS 1 + +#ifdef RTE_LIBRTE_PMD_BBDEV_FPGA_LTE_FEC +#include +#define FPGA_LTE_PF_DRIVER_NAME ("intel_fpga_lte_fec_pf") +#define FPGA_LTE_VF_DRIVER_NAME ("intel_fpga_lte_fec_vf") +#define VF_UL_4G_QUEUE_VALUE 4 +#define VF_DL_4G_QUEUE_VALUE 4 +#define UL_4G_BANDWIDTH 3 +#define DL_4G_BANDWIDTH 3 +#define UL_4G_LOAD_BALANCE 128 +#define DL_4G_LOAD_BALANCE 128 +#define FLR_4G_TIMEOUT 610 +#endif + +#ifdef RTE_LIBRTE_PMD_BBDEV_FPGA_5GNR_FEC +#include +#define FPGA_5GNR_PF_DRIVER_NAME ("intel_fpga_5gnr_fec_pf") +#define FPGA_5GNR_VF_DRIVER_NAME ("intel_fpga_5gnr_fec_vf") +#define VF_UL_5G_QUEUE_VALUE 4 +#define VF_DL_5G_QUEUE_VALUE 4 +#define UL_5G_BANDWIDTH 3 +#define DL_5G_BANDWIDTH 3 +#define UL_5G_LOAD_BALANCE 128 +#define DL_5G_LOAD_BALANCE 128 +#define FLR_5G_TIMEOUT 610 +#endif + +#define OPS_CACHE_SIZE 256U +#define OPS_POOL_SIZE_MIN 511U /* 0.5K per queue */ + +#define SYNC_WAIT 0 +#define SYNC_START 1 +#define INVALID_OPAQUE -1 + +#define INVALID_QUEUE_ID -1 +/* Increment for next code block in external HARQ memory */ +#define HARQ_INCR 32768 +/* Headroom for filler LLRs insertion in HARQ buffer */ +#define FILLER_HEADROOM 1024 + +/* Switch between PMD and Interrupt for throughput TC */ +static bool intr_enabled; + +/* Represents tested active devices */ +struct active_device { + const char *driver_name; + uint8_t dev_id; + uint16_t supported_ops; + uint16_t queue_ids[MAX_QUEUES]; + uint16_t nb_queues; + struct rte_mempool *ops_mempool; + struct rte_mempool *in_mbuf_pool; + struct rte_mempool *hard_out_mbuf_pool; + struct rte_mempool *soft_out_mbuf_pool; + struct rte_mempool *harq_in_mbuf_pool; + struct rte_mempool *harq_out_mbuf_pool; +} active_devs[RTE_BBDEV_MAX_DEVS]; + +static uint8_t nb_active_devs; + +/* Data buffers used by BBDEV ops */ +struct test_buffers { + struct rte_bbdev_op_data *inputs; + struct rte_bbdev_op_data *hard_outputs; + struct rte_bbdev_op_data *soft_outputs; + struct rte_bbdev_op_data *harq_inputs; + struct rte_bbdev_op_data *harq_outputs; +}; + +/* Operation parameters specific for given test case */ +struct test_op_params { + struct rte_mempool *mp; + struct rte_bbdev_dec_op *ref_dec_op; + struct rte_bbdev_enc_op *ref_enc_op; + uint16_t burst_sz; + uint16_t num_to_process; + uint16_t num_lcores; + int vector_mask; + rte_atomic16_t sync; + struct test_buffers q_bufs[RTE_MAX_NUMA_NODES][MAX_QUEUES]; +}; + +/* Contains per lcore params */ +struct thread_params { + uint8_t dev_id; + uint16_t queue_id; + uint32_t lcore_id; + uint64_t start_time; + double ops_per_sec; + double mbps; + uint8_t iter_count; + double iter_average; + double bler; + struct nrLDPCoffload_params *p_offloadParams; + int8_t* p_out; + uint8_t r; + uint8_t harq_pid; + uint8_t ulsch_id; + rte_atomic16_t nb_dequeued; + rte_atomic16_t processing_status; + rte_atomic16_t burst_sz; + struct test_op_params *op_params; + struct rte_bbdev_dec_op *dec_ops[MAX_BURST]; + struct rte_bbdev_enc_op *enc_ops[MAX_BURST]; +}; + +#ifdef RTE_BBDEV_OFFLOAD_COST +/* Stores time statistics */ +struct test_time_stats { + /* Stores software enqueue total working time */ + uint64_t enq_sw_total_time; + /* Stores minimum value of software enqueue working time */ + uint64_t enq_sw_min_time; + /* Stores maximum value of software enqueue working time */ + uint64_t enq_sw_max_time; + /* Stores turbo enqueue total working time */ + uint64_t enq_acc_total_time; + /* Stores minimum value of accelerator enqueue working time */ + uint64_t enq_acc_min_time; + /* Stores maximum value of accelerator enqueue working time */ + uint64_t enq_acc_max_time; + /* Stores dequeue total working time */ + uint64_t deq_total_time; + /* Stores minimum value of dequeue working time */ + uint64_t deq_min_time; + /* Stores maximum value of dequeue working time */ + uint64_t deq_max_time; +}; +#endif + +typedef int (test_case_function)(struct active_device *ad, + struct test_op_params *op_params); + +static inline void +mbuf_reset(struct rte_mbuf *m) +{ + m->pkt_len = 0; + + do { + m->data_len = 0; + m = m->next; + } while (m != NULL); +} + +/* Read flag value 0/1 from bitmap */ +static inline bool +check_bit(uint32_t bitmap, uint32_t bitmask) +{ + return bitmap & bitmask; +} + +static inline void +set_avail_op(struct active_device *ad, enum rte_bbdev_op_type op_type) +{ + ad->supported_ops |= (1 << op_type); +} + +static inline bool +is_avail_op(struct active_device *ad, enum rte_bbdev_op_type op_type) +{ + return ad->supported_ops & (1 << op_type); +} + +static inline bool +flags_match(uint32_t flags_req, uint32_t flags_present) +{ + return (flags_req & flags_present) == flags_req; +} + + +static int +check_dev_cap(const struct rte_bbdev_info *dev_info) +{ + unsigned int i; + const struct rte_bbdev_op_cap *op_cap = dev_info->drv.capabilities; + + for (i = 0; op_cap->type != RTE_BBDEV_OP_NONE; ++i, ++op_cap) { + if (op_cap->type != RTE_BBDEV_OP_LDPC_DEC) + continue; + + if (op_cap->type == RTE_BBDEV_OP_LDPC_DEC) { + const struct rte_bbdev_op_cap_ldpc_dec *cap = + &op_cap->cap.ldpc_dec; + + if (!flags_match(RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE, + cap->capability_flags)){ + printf("Flag Mismatch\n"); + return TEST_FAILED; + } + return TEST_SUCCESS; + } + } + + return TEST_FAILED; +} + +/* calculates optimal mempool size not smaller than the val */ +static unsigned int +optimal_mempool_size(unsigned int val) +{ + return rte_align32pow2(val + 1) - 1; +} + +/* allocates mbuf mempool for inputs and outputs */ +static struct rte_mempool * +create_mbuf_pool(uint32_t length, uint8_t dev_id, + int socket_id, unsigned int mbuf_pool_size, + const char *op_type_str) +{ + uint32_t max_seg_sz = 0; + char pool_name[RTE_MEMPOOL_NAMESIZE]; + + /* find max input segment size */ + //for (i = 0; i < entries->nb_segments; ++i) + if (length > max_seg_sz) + max_seg_sz = length; + + snprintf(pool_name, sizeof(pool_name), "%s_pool_%u", op_type_str, + dev_id); + return rte_pktmbuf_pool_create(pool_name, mbuf_pool_size, 0, 0, + RTE_MAX(max_seg_sz + RTE_PKTMBUF_HEADROOM + + FILLER_HEADROOM, + (unsigned int)RTE_MBUF_DEFAULT_BUF_SIZE), socket_id); +} + +static int +create_mempools(struct active_device *ad, int socket_id, + enum rte_bbdev_op_type org_op_type, uint16_t num_ops, t_nrLDPCoffload_params *p_offloadParams) +{ + struct rte_mempool *mp; + unsigned int ops_pool_size, mbuf_pool_size = 0; + char pool_name[RTE_MEMPOOL_NAMESIZE]; + const char *op_type_str; + enum rte_bbdev_op_type op_type = org_op_type; + uint8_t nb_segments = 1; + uint32_t data_len; + + /* allocate ops mempool */ + ops_pool_size = optimal_mempool_size(RTE_MAX( + /* Ops used plus 1 reference op */ + RTE_MAX((unsigned int)(ad->nb_queues * num_ops + 1), + /* Minimal cache size plus 1 reference op */ + (unsigned int)(1.5 * rte_lcore_count() * + OPS_CACHE_SIZE + 1)), + OPS_POOL_SIZE_MIN)); + + if (org_op_type == RTE_BBDEV_OP_NONE) + op_type = RTE_BBDEV_OP_TURBO_ENC; + + op_type_str = rte_bbdev_op_type_str(op_type); + TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u", op_type); + + snprintf(pool_name, sizeof(pool_name), "%s_pool_%u", op_type_str, + ad->dev_id); + mp = rte_bbdev_op_pool_create(pool_name, op_type, + ops_pool_size, OPS_CACHE_SIZE, socket_id); + TEST_ASSERT_NOT_NULL(mp, + "ERROR Failed to create %u items ops pool for dev %u on socket %u.", + ops_pool_size, + ad->dev_id, + socket_id); + ad->ops_mempool = mp; + + /* Do not create inputs and outputs mbufs for BaseBand Null Device */ + if (org_op_type == RTE_BBDEV_OP_NONE) + return TEST_SUCCESS; + data_len = (p_offloadParams->BG==1)?(22*p_offloadParams->Z):(10*p_offloadParams->Z); + /* Inputs */ + if (nb_segments > 0) { + mbuf_pool_size = optimal_mempool_size(ops_pool_size * + nb_segments); + mp = create_mbuf_pool(p_offloadParams->E, ad->dev_id, socket_id, + mbuf_pool_size, "in"); + TEST_ASSERT_NOT_NULL(mp, + "ERROR Failed to create %u items input pktmbuf pool for dev %u on socket %u.", + mbuf_pool_size, + ad->dev_id, + socket_id); + ad->in_mbuf_pool = mp; + } + /* Hard outputs */ + if (nb_segments > 0) { + mbuf_pool_size = optimal_mempool_size(ops_pool_size * + nb_segments); + mp = create_mbuf_pool(data_len, ad->dev_id, socket_id, + mbuf_pool_size, + "hard_out"); + TEST_ASSERT_NOT_NULL(mp, + "ERROR Failed to create %u items hard output pktmbuf pool for dev %u on socket %u.", + mbuf_pool_size, + ad->dev_id, + socket_id); + ad->hard_out_mbuf_pool = mp; + } + + return TEST_SUCCESS; +} + +static int +add_dev(uint8_t dev_id, struct rte_bbdev_info *info) +{ + int ret; + unsigned int queue_id; + struct rte_bbdev_queue_conf qconf; + struct active_device *ad = &active_devs[nb_active_devs]; + unsigned int nb_queues; + enum rte_bbdev_op_type op_type = RTE_BBDEV_OP_LDPC_DEC; + +/* Configure fpga lte fec with PF & VF values + * if '-i' flag is set and using fpga device + */ +#ifdef RTE_LIBRTE_PMD_BBDEV_FPGA_LTE_FEC + if ((get_init_device() == true) && + (!strcmp(info->drv.driver_name, FPGA_LTE_PF_DRIVER_NAME))) { + struct fpga_lte_fec_conf conf; + unsigned int i; + + printf("Configure FPGA LTE FEC Driver %s with default values\n", + info->drv.driver_name); + + /* clear default configuration before initialization */ + memset(&conf, 0, sizeof(struct fpga_lte_fec_conf)); + + /* Set PF mode : + * true if PF is used for data plane + * false for VFs + */ + conf.pf_mode_en = true; + + for (i = 0; i < FPGA_LTE_FEC_NUM_VFS; ++i) { + /* Number of UL queues per VF (fpga supports 8 VFs) */ + conf.vf_ul_queues_number[i] = VF_UL_4G_QUEUE_VALUE; + /* Number of DL queues per VF (fpga supports 8 VFs) */ + conf.vf_dl_queues_number[i] = VF_DL_4G_QUEUE_VALUE; + } + + /* UL bandwidth. Needed for schedule algorithm */ + conf.ul_bandwidth = UL_4G_BANDWIDTH; + /* DL bandwidth */ + conf.dl_bandwidth = DL_4G_BANDWIDTH; + + /* UL & DL load Balance Factor to 64 */ + conf.ul_load_balance = UL_4G_LOAD_BALANCE; + conf.dl_load_balance = DL_4G_LOAD_BALANCE; + + /**< FLR timeout value */ + conf.flr_time_out = FLR_4G_TIMEOUT; + + /* setup FPGA PF with configuration information */ + ret = fpga_lte_fec_configure(info->dev_name, &conf); + TEST_ASSERT_SUCCESS(ret, + "Failed to configure 4G FPGA PF for bbdev %s", + info->dev_name); + } +#endif +#ifdef RTE_LIBRTE_PMD_BBDEV_FPGA_5GNR_FEC + if ((get_init_device() == true) && + (!strcmp(info->drv.driver_name, FPGA_5GNR_PF_DRIVER_NAME))) { + struct fpga_5gnr_fec_conf conf; + unsigned int i; + + printf("Configure FPGA 5GNR FEC Driver %s with default values\n", + info->drv.driver_name); + + /* clear default configuration before initialization */ + memset(&conf, 0, sizeof(struct fpga_5gnr_fec_conf)); + + /* Set PF mode : + * true if PF is used for data plane + * false for VFs + */ + conf.pf_mode_en = true; + + for (i = 0; i < FPGA_5GNR_FEC_NUM_VFS; ++i) { + /* Number of UL queues per VF (fpga supports 8 VFs) */ + conf.vf_ul_queues_number[i] = VF_UL_5G_QUEUE_VALUE; + /* Number of DL queues per VF (fpga supports 8 VFs) */ + conf.vf_dl_queues_number[i] = VF_DL_5G_QUEUE_VALUE; + } + + /* UL bandwidth. Needed for schedule algorithm */ + conf.ul_bandwidth = UL_5G_BANDWIDTH; + /* DL bandwidth */ + conf.dl_bandwidth = DL_5G_BANDWIDTH; + + /* UL & DL load Balance Factor to 64 */ + conf.ul_load_balance = UL_5G_LOAD_BALANCE; + conf.dl_load_balance = DL_5G_LOAD_BALANCE; + + /**< FLR timeout value */ + conf.flr_time_out = FLR_5G_TIMEOUT; + + /* setup FPGA PF with configuration information */ + ret = fpga_5gnr_fec_configure(info->dev_name, &conf); + TEST_ASSERT_SUCCESS(ret, + "Failed to configure 5G FPGA PF for bbdev %s", + info->dev_name); + } +#endif + nb_queues = RTE_MIN(rte_lcore_count(), info->drv.max_num_queues); + nb_queues = RTE_MIN(nb_queues, (unsigned int) MAX_QUEUES); + + /* setup device */ + ret = rte_bbdev_setup_queues(dev_id, nb_queues, info->socket_id); + if (ret < 0) { + printf("rte_bbdev_setup_queues(%u, %u, %d) ret %i\n", + dev_id, nb_queues, info->socket_id, ret); + return TEST_FAILED; + } + + /* configure interrupts if needed */ + if (intr_enabled) { + ret = rte_bbdev_intr_enable(dev_id); + if (ret < 0) { + printf("rte_bbdev_intr_enable(%u) ret %i\n", dev_id, + ret); + return TEST_FAILED; + } + } + + /* setup device queues */ + qconf.socket = info->socket_id; + qconf.queue_size = info->drv.default_queue_conf.queue_size; + qconf.priority = 0; + qconf.deferred_start = 0; + qconf.op_type = op_type; + + for (queue_id = 0; queue_id < nb_queues; ++queue_id) { + ret = rte_bbdev_queue_configure(dev_id, queue_id, &qconf); + if (ret != 0) { + printf( + "Allocated all queues (id=%u) at prio%u on dev%u\n", + queue_id, qconf.priority, dev_id); + qconf.priority++; + ret = rte_bbdev_queue_configure(ad->dev_id, queue_id, + &qconf); + } + if (ret != 0) { + printf("All queues on dev %u allocated: %u\n", + dev_id, queue_id); + break; + } + ad->queue_ids[queue_id] = queue_id; + } + TEST_ASSERT(queue_id != 0, + "ERROR Failed to configure any queues on dev %u", + dev_id); + ad->nb_queues = queue_id; + + set_avail_op(ad, op_type); + + return TEST_SUCCESS; +} + +static int +add_active_device(uint8_t dev_id, struct rte_bbdev_info *info) +{ + int ret; + + active_devs[nb_active_devs].driver_name = info->drv.driver_name; + active_devs[nb_active_devs].dev_id = dev_id; + + ret = add_dev(dev_id, info); + if (ret == TEST_SUCCESS) + ++nb_active_devs; + return ret; +} + +static uint8_t +populate_active_devices(void) +{ + int ret; + uint8_t dev_id; + uint8_t nb_devs_added = 0; + struct rte_bbdev_info info; + + RTE_BBDEV_FOREACH(dev_id) { + rte_bbdev_info_get(dev_id, &info); + + if (check_dev_cap(&info)) { + printf( + "Device %d (%s) does not support specified capabilities\n", + dev_id, info.dev_name); + continue; + } + ret = add_active_device(dev_id, &info); + if (ret != 0) { + printf("Adding active bbdev %s skipped\n", + info.dev_name); + continue; + } + nb_devs_added++; + } + + return nb_devs_added; +} + +static int +device_setup(void) +{ + if (populate_active_devices() == 0) { + printf("No suitable devices found!\n"); + return TEST_SKIPPED; + } + return TEST_SUCCESS; +} + + +static void +testsuite_teardown(void) +{ + uint8_t dev_id; + /* Unconfigure devices */ + RTE_BBDEV_FOREACH(dev_id) + rte_bbdev_close(dev_id); + + /* Clear active devices structs. */ + memset(active_devs, 0, sizeof(active_devs)); + nb_active_devs = 0; + + /* Disable interrupts */ + intr_enabled = false; +} + +static int +ut_setup(void) +{ + uint8_t i, dev_id; + + for (i = 0; i < nb_active_devs; i++) { + dev_id = active_devs[i].dev_id; + /* reset bbdev stats */ + TEST_ASSERT_SUCCESS(rte_bbdev_stats_reset(dev_id), + "Failed to reset stats of bbdev %u", dev_id); + /* start the device */ + TEST_ASSERT_SUCCESS(rte_bbdev_start(dev_id), + "Failed to start bbdev %u", dev_id); + } + + return TEST_SUCCESS; +} + +static void +ut_teardown(void) +{ + uint8_t i, dev_id; + struct rte_bbdev_stats stats; + + for (i = 0; i < nb_active_devs; i++) { + dev_id = active_devs[i].dev_id; + /* read stats and print */ + rte_bbdev_stats_get(dev_id, &stats); + /* Stop the device */ + rte_bbdev_stop(dev_id); + } +} + +static int +init_op_data_objs(struct rte_bbdev_op_data *bufs, + int8_t* p_llr, uint32_t data_len, + struct rte_mbuf *m_head, + struct rte_mempool *mbuf_pool, const uint16_t n, + enum op_data_type op_type, uint16_t min_alignment) +{ + int ret; + unsigned int i, j; + bool large_input = false; + uint8_t nb_segments = 1; + //uint64_t start_time=rte_rdtsc_precise(); + //uint64_t start_time1; //=rte_rdtsc_precise(); + //uint64_t total_time=0, total_time1=0; + + for (i = 0; i < n; ++i) { + char *data; + + if (data_len > RTE_BBDEV_LDPC_E_MAX_MBUF) { + /* + * Special case when DPDK mbuf cannot handle + * the required input size + */ + printf("Warning: Larger input size than DPDK mbuf %d\n", + data_len); + large_input = true; + } + bufs[i].data = m_head; + bufs[i].offset = 0; + bufs[i].length = 0; + + if ((op_type == DATA_INPUT) || (op_type == DATA_HARQ_INPUT)) { + if ((op_type == DATA_INPUT) && large_input) { + /* Allocate a fake overused mbuf */ + data = rte_malloc(NULL, data_len, 0); + memcpy(data, p_llr, data_len); + m_head->buf_addr = data; + m_head->buf_iova = rte_malloc_virt2iova(data); + m_head->data_off = 0; + m_head->data_len = data_len; + } else { + + rte_pktmbuf_reset(m_head); + data = rte_pktmbuf_append(m_head, data_len); + + /*total_time = rte_rdtsc_precise() - start_time; + + if (total_time > 10*3000) + LOG_E(PHY," init op first: %u\n",(uint) (total_time/3000)); + + start_time1 = rte_rdtsc_precise(); + + */ + TEST_ASSERT_NOT_NULL(data, + "Couldn't append %u bytes to mbuf from %d data type mbuf pool", + data_len, op_type); + + TEST_ASSERT(data == RTE_PTR_ALIGN( + data, min_alignment), + "Data addr in mbuf (%p) is not aligned to device min alignment (%u)", + data, min_alignment); + rte_memcpy(data, p_llr, data_len); + /*total_time1 = rte_rdtsc_precise() - start_time; + if (total_time1 > 10*3000) + LOG_E(PHY,"init op second: %u\n",(uint) (total_time1/3000));*/ + } + + bufs[i].length += data_len; + + for (j = 1; j < nb_segments; ++j) { + struct rte_mbuf *m_tail = + rte_pktmbuf_alloc(mbuf_pool); + TEST_ASSERT_NOT_NULL(m_tail, + "Not enough mbufs in %d data type mbuf pool (needed %u, available %u)", + op_type, + n * nb_segments, + mbuf_pool->size); + //seg += 1; + + data = rte_pktmbuf_append(m_tail, data_len); + TEST_ASSERT_NOT_NULL(data, + "Couldn't append %u bytes to mbuf from %d data type mbuf pool", + data_len, op_type); + + TEST_ASSERT(data == RTE_PTR_ALIGN(data, + min_alignment), + "Data addr in mbuf (%p) is not aligned to device min alignment (%u)", + data, min_alignment); + rte_memcpy(data, p_llr, data_len); + bufs[i].length += data_len; + + ret = rte_pktmbuf_chain(m_head, m_tail); + TEST_ASSERT_SUCCESS(ret, + "Couldn't chain mbufs from %d data type mbuf pool", + op_type); + } + } else { + + /* allocate chained-mbuf for output buffer */ + /*for (j = 1; j < nb_segments; ++j) { + struct rte_mbuf *m_tail = + rte_pktmbuf_alloc(mbuf_pool); + TEST_ASSERT_NOT_NULL(m_tail, + "Not enough mbufs in %d data type mbuf pool (needed %u, available %u)", + op_type, + n * nb_segments, + mbuf_pool->size); + + ret = rte_pktmbuf_chain(m_head, m_tail); + TEST_ASSERT_SUCCESS(ret, + "Couldn't chain mbufs from %d data type mbuf pool", + op_type); + }*/ + } + } + + return 0; +} + +static int +allocate_buffers_on_socket(struct rte_bbdev_op_data **buffers, const int len, + const int socket) +{ + int i; + + *buffers = rte_zmalloc_socket(NULL, len, 0, socket); + if (*buffers == NULL) { + printf("WARNING: Failed to allocate op_data on socket %d\n", + socket); + /* try to allocate memory on other detected sockets */ + for (i = 0; i < socket; i++) { + *buffers = rte_zmalloc_socket(NULL, len, 0, i); + if (*buffers != NULL) + break; + } + } + + return (*buffers == NULL) ? TEST_FAILED : TEST_SUCCESS; +} + + + +static void +free_buffers(struct active_device *ad, struct test_op_params *op_params) +{ + unsigned int i, j; + + rte_mempool_free(ad->ops_mempool); + rte_mempool_free(ad->in_mbuf_pool); + rte_mempool_free(ad->hard_out_mbuf_pool); + rte_mempool_free(ad->soft_out_mbuf_pool); + rte_mempool_free(ad->harq_in_mbuf_pool); + rte_mempool_free(ad->harq_out_mbuf_pool); + + for (i = 0; i < rte_lcore_count(); ++i) { + for (j = 0; j < RTE_MAX_NUMA_NODES; ++j) { + rte_free(op_params->q_bufs[j][i].inputs); + rte_free(op_params->q_bufs[j][i].hard_outputs); + rte_free(op_params->q_bufs[j][i].soft_outputs); + rte_free(op_params->q_bufs[j][i].harq_inputs); + rte_free(op_params->q_bufs[j][i].harq_outputs); + } + } +} + + + +static inline double +maxstar(double A, double B) +{ + if (fabs(A - B) > 5) + return RTE_MAX(A, B); + else + return RTE_MAX(A, B) + log1p(exp(-fabs(A - B))); +} + +static void +set_ldpc_dec_op(struct rte_bbdev_dec_op **ops, unsigned int n, + unsigned int start_idx, + struct rte_bbdev_op_data *inputs, + struct rte_bbdev_op_data *hard_outputs, + struct rte_bbdev_op_data *soft_outputs, + struct rte_bbdev_op_data *harq_inputs, + struct rte_bbdev_op_data *harq_outputs, + struct rte_bbdev_dec_op *ref_op, + uint8_t r, + uint8_t harq_pid, + uint8_t ulsch_id, + t_nrLDPCoffload_params *p_offloadParams) +{ + unsigned int i; + //struct rte_bbdev_op_ldpc_dec *ldpc_dec = &ref_op->ldpc_dec; + for (i = 0; i < n; ++i) { + /* if (ldpc_dec->code_block_mode == 0) { + ops[i]->ldpc_dec.tb_params.ea = + ldpc_dec->tb_params.ea; + ops[i]->ldpc_dec.tb_params.eb = + ldpc_dec->tb_params.eb; + ops[i]->ldpc_dec.tb_params.c = + ldpc_dec->tb_params.c; + ops[i]->ldpc_dec.tb_params.cab = + ldpc_dec->tb_params.cab; + ops[i]->ldpc_dec.tb_params.r = + ldpc_dec->tb_params.r; + printf("code block ea %d eb %d c %d cab %d r %d\n",ldpc_dec->tb_params.ea,ldpc_dec->tb_params.eb,ldpc_dec->tb_params.c, ldpc_dec->tb_params.cab, ldpc_dec->tb_params.r); + } else { */ + ops[i]->ldpc_dec.cb_params.e = p_offloadParams->E; + //} + + ops[i]->ldpc_dec.basegraph = p_offloadParams->BG; + ops[i]->ldpc_dec.z_c = p_offloadParams->Z; + ops[i]->ldpc_dec.q_m = p_offloadParams->Qm; + ops[i]->ldpc_dec.n_filler = p_offloadParams->F; + ops[i]->ldpc_dec.n_cb = p_offloadParams->n_cb; + ops[i]->ldpc_dec.iter_max = 20; + ops[i]->ldpc_dec.rv_index = p_offloadParams->rv; + ops[i]->ldpc_dec.op_flags = RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE; //|RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP; + ops[i]->ldpc_dec.code_block_mode = 1; //ldpc_dec->code_block_mode; + //printf("set ldpc ulsch_id %d\n",ulsch_id); + ops[i]->ldpc_dec.harq_combined_input.offset = ulsch_id*(32*1024*1024)+harq_pid*(2*1024*1024)+r*(1024*32); + ops[i]->ldpc_dec.harq_combined_output.offset = ulsch_id*(32*1024*1024)+harq_pid*(2*1024*1024)+r*(1024*32); + + + if (hard_outputs != NULL) + ops[i]->ldpc_dec.hard_output = + hard_outputs[start_idx + i]; + if (inputs != NULL) + ops[i]->ldpc_dec.input = + inputs[start_idx + i]; + if (soft_outputs != NULL) + ops[i]->ldpc_dec.soft_output = + soft_outputs[start_idx + i]; + if (harq_inputs != NULL) + ops[i]->ldpc_dec.harq_combined_input = + harq_inputs[start_idx + i]; + if (harq_outputs != NULL) + ops[i]->ldpc_dec.harq_combined_output = + harq_outputs[start_idx + i]; + + } +} + + + +/*static int +check_dec_status_and_ordering(struct rte_bbdev_dec_op *op, + unsigned int order_idx, const int expected_status) +{ + int status = op->status; + if (get_iter_max() >= 10) { + if (!(expected_status & (1 << RTE_BBDEV_SYNDROME_ERROR)) && + (status & (1 << RTE_BBDEV_SYNDROME_ERROR))) { + printf("WARNING: Ignore Syndrome Check mismatch\n"); + status -= (1 << RTE_BBDEV_SYNDROME_ERROR); + } + if ((expected_status & (1 << RTE_BBDEV_SYNDROME_ERROR)) && + !(status & (1 << RTE_BBDEV_SYNDROME_ERROR))) { + printf("WARNING: Ignore Syndrome Check mismatch\n"); + status += (1 << RTE_BBDEV_SYNDROME_ERROR); + } + } + + TEST_ASSERT(status == expected_status, + "op_status (%d) != expected_status (%d)", + op->status, expected_status); + + TEST_ASSERT((void *)(uintptr_t)order_idx == op->opaque_data, + "Ordering error, expected %p, got %p", + (void *)(uintptr_t)order_idx, op->opaque_data); + + return TEST_SUCCESS; +} + +static int +check_enc_status_and_ordering(struct rte_bbdev_enc_op *op, + unsigned int order_idx, const int expected_status) +{ + TEST_ASSERT(op->status == expected_status, + "op_status (%d) != expected_status (%d)", + op->status, expected_status); + + if (op->opaque_data != (void *)(uintptr_t)INVALID_OPAQUE) + TEST_ASSERT((void *)(uintptr_t)order_idx == op->opaque_data, + "Ordering error, expected %p, got %p", + (void *)(uintptr_t)order_idx, op->opaque_data); + + return TEST_SUCCESS; +} +*/ + +static int +retrieve_ldpc_dec_op(struct rte_bbdev_dec_op **ops, const uint16_t n, + struct rte_bbdev_dec_op *ref_op, const int vector_mask, + int8_t* p_out) +{ + unsigned int i; + //int ret; + struct rte_bbdev_op_ldpc_dec *ops_td; + struct rte_bbdev_op_data *hard_output; + //struct rte_bbdev_op_ldpc_dec *ref_td = &ref_op->ldpc_dec; + struct rte_mbuf *m; + char *data; + + for (i = 0; i < n; ++i) { + ops_td = &ops[i]->ldpc_dec; + hard_output = &ops_td->hard_output; + m = hard_output->data; + /* ret = check_dec_status_and_ordering(ops[i], i, ref_op->status); + TEST_ASSERT_SUCCESS(ret, + "Checking status and ordering for decoder failed"); + if (vector_mask & TEST_BBDEV_VF_EXPECTED_ITER_COUNT) + TEST_ASSERT(ops_td->iter_count <= ref_td->iter_count, + "Returned iter_count (%d) > expected iter_count (%d)", + ops_td->iter_count, ref_td->iter_count); + */ + uint16_t offset = hard_output->offset; + uint16_t data_len = rte_pktmbuf_data_len(m) - offset; + + data = m->buf_addr; + memcpy(p_out, data+m->data_off, data_len); + + } + + return TEST_SUCCESS; +} + + +/*static int +validate_ldpc_enc_op(struct rte_bbdev_enc_op **ops, const uint16_t n, + struct rte_bbdev_enc_op *ref_op) +{ + unsigned int i; + int ret; + struct op_data_entries *hard_data_orig = + &test_vector.entries[DATA_HARD_OUTPUT]; + + for (i = 0; i < n; ++i) { + ret = check_enc_status_and_ordering(ops[i], i, ref_op->status); + TEST_ASSERT_SUCCESS(ret, + "Checking status and ordering for encoder failed"); + TEST_ASSERT_SUCCESS(validate_op_chain( + &ops[i]->ldpc_enc.output, + hard_data_orig), + "Output buffers (CB=%u) are not equal", + i); + } + + return TEST_SUCCESS; +} +*/ + +static void +create_reference_ldpc_dec_op(struct rte_bbdev_dec_op *op, t_nrLDPCoffload_params *p_offloadParams) +{ +// unsigned int i; + + //for (i = 0; i < entry->nb_segments; ++i) + op->ldpc_dec.input.length = p_offloadParams->E; + op->ldpc_dec.basegraph = p_offloadParams->BG; + op->ldpc_dec.z_c = p_offloadParams->Z; + op->ldpc_dec.n_filler = p_offloadParams->F; + op->ldpc_dec.code_block_mode = 1; + op->ldpc_dec.op_flags = RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE|RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP; +} + + + +/* +static uint32_t +calc_ldpc_dec_TB_size(struct rte_bbdev_dec_op *op) +{ + uint8_t i; + uint32_t c, r, tb_size = 0; + uint16_t sys_cols = (op->ldpc_dec.basegraph == 1) ? 22 : 10; + + if (op->ldpc_dec.code_block_mode) { + tb_size = sys_cols * op->ldpc_dec.z_c - op->ldpc_dec.n_filler; + //printf("calc tb sys cols %d tb_size %d\n",sys_cols,tb_size); + + } else { + c = op->ldpc_dec.tb_params.c; + r = op->ldpc_dec.tb_params.r; + for (i = 0; i < c-r; i++) + tb_size += sys_cols * op->ldpc_dec.z_c + - op->ldpc_dec.n_filler; + printf("calc tb c %d r %d sys cols %d tb_size %d\n",c,r,sys_cols,tb_size); + } + return tb_size; +} +*/ + +static int +init_test_op_params(struct test_op_params *op_params, + enum rte_bbdev_op_type op_type, const int expected_status, + const int vector_mask, struct rte_mempool *ops_mp, + uint16_t burst_sz, uint16_t num_to_process, uint16_t num_lcores) +{ + int ret = 0; + if (op_type == RTE_BBDEV_OP_TURBO_DEC || + op_type == RTE_BBDEV_OP_LDPC_DEC) + ret = rte_bbdev_dec_op_alloc_bulk(ops_mp, + &op_params->ref_dec_op, 1); + else + ret = rte_bbdev_enc_op_alloc_bulk(ops_mp, + &op_params->ref_enc_op, 1); + + TEST_ASSERT_SUCCESS(ret, "rte_bbdev_op_alloc_bulk() failed"); + + op_params->mp = ops_mp; + op_params->burst_sz = burst_sz; + op_params->num_to_process = num_to_process; + op_params->num_lcores = num_lcores; + op_params->vector_mask = vector_mask; + if (op_type == RTE_BBDEV_OP_TURBO_DEC || + op_type == RTE_BBDEV_OP_LDPC_DEC) + op_params->ref_dec_op->status = expected_status; + else if (op_type == RTE_BBDEV_OP_TURBO_ENC + || op_type == RTE_BBDEV_OP_LDPC_ENC) + op_params->ref_enc_op->status = expected_status; + return 0; +} + +static int +pmd_lcore_ldpc_dec(void *arg) +{ + struct thread_params *tp = arg; + uint16_t enq, deq; + //uint64_t total_time = 0, start_time; + const uint16_t queue_id = tp->queue_id; + const uint16_t burst_sz = tp->op_params->burst_sz; + const uint16_t num_ops = tp->op_params->num_to_process; + struct rte_bbdev_dec_op *ops_enq[num_ops]; + struct rte_bbdev_dec_op *ops_deq[num_ops]; + struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op; + uint8_t r= tp->r; + uint8_t harq_pid = tp->harq_pid; + uint8_t ulsch_id = tp->ulsch_id; + struct test_buffers *bufs = NULL; + int i, j, ret; + struct rte_bbdev_info info; + uint16_t num_to_enq; + int8_t *p_out = tp->p_out; + t_nrLDPCoffload_params *p_offloadParams = tp->p_offloadParams; + + //struct rte_bbdev_op_data *hard_output; + + //bool extDdr = check_bit(ldpc_cap_flags, + // RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE); + //start_time = rte_rdtsc_precise(); + bool loopback = check_bit(ref_op->ldpc_dec.op_flags, + RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK); + bool hc_out = check_bit(ref_op->ldpc_dec.op_flags, + RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE); + + TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST), + "BURST_SIZE should be <= %u", MAX_BURST); + + rte_bbdev_info_get(tp->dev_id, &info); + + TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim), + "NUM_OPS cannot exceed %u for this device", + info.drv.queue_size_lim); + + bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id]; + + while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT) + rte_pause(); + + ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops); + TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops); + + /* For throughput tests we need to disable early termination */ + if (check_bit(ref_op->ldpc_dec.op_flags, + RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE)) + ref_op->ldpc_dec.op_flags -= + RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE; + ref_op->ldpc_dec.iter_max = get_iter_max(); + ref_op->ldpc_dec.iter_count = ref_op->ldpc_dec.iter_max; + + set_ldpc_dec_op(ops_enq, num_ops, 0, bufs->inputs, + bufs->hard_outputs, bufs->soft_outputs, + bufs->harq_inputs, bufs->harq_outputs, ref_op, r, harq_pid, ulsch_id, p_offloadParams); + + /* Set counter to validate the ordering */ + for (j = 0; j < num_ops; ++j) + ops_enq[j]->opaque_data = (void *)(uintptr_t)j; + + for (i = 0; i < TEST_REPETITIONS; ++i) { + for (j = 0; j < num_ops; ++j) { + if (!loopback) + mbuf_reset( + ops_enq[j]->ldpc_dec.hard_output.data); + if (hc_out || loopback) + mbuf_reset( + ops_enq[j]->ldpc_dec.harq_combined_output.data); + } + // start_time = rte_rdtsc_precise(); + + for (enq = 0, deq = 0; enq < num_ops;) { + num_to_enq = burst_sz; + + if (unlikely(num_ops - enq < num_to_enq)) + num_to_enq = num_ops - enq; + + enq += rte_bbdev_enqueue_ldpc_dec_ops(tp->dev_id, + queue_id, &ops_enq[enq], num_to_enq); + + deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id, + queue_id, &ops_deq[deq], enq - deq); + + //printf("enq %d, deq %d\n",enq,deq); + + } + + /* dequeue the remaining */ + //int trials=0; + while (deq < enq) { + deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id, + queue_id, &ops_deq[deq], enq - deq); + /*usleep(10); + trials++; + if (trials>=100) { + printf("aborting decoding after 100 dequeue tries\n"); + break; + }*/ + } + + //total_time += rte_rdtsc_precise() - start_time; + } + //total_time = rte_rdtsc_precise() - start_time; + if (deq==enq) { + tp->iter_count = 0; + /* get the max of iter_count for all dequeued ops */ + for (i = 0; i < num_ops; ++i) { + tp->iter_count = RTE_MAX(ops_enq[i]->ldpc_dec.iter_count, + tp->iter_count); + } + + ret = retrieve_ldpc_dec_op(ops_deq, num_ops, ref_op, + tp->op_params->vector_mask, p_out); + TEST_ASSERT_SUCCESS(ret, "Validation failed!"); + } + else { + ret = TEST_FAILED; + } + + rte_bbdev_dec_op_free_bulk(ops_enq, num_ops); + + /*total_time = rte_rdtsc_precise() - start_time; + + if (total_time > 100*3000) + LOG_E(PHY," pmd lcore: %u\n",(uint) (total_time/3000)); + + double tb_len_bits = calc_ldpc_dec_TB_size(ref_op); + + tp->ops_per_sec = ((double)total_time / (double)rte_get_tsc_hz()); + //tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) / + // ((double)total_time / (double)rte_get_tsc_hz()); + tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits)) / + 1000000.0) / ((double)total_time / + (double)rte_get_tsc_hz()); + */ + return ret; +} + + +/* Aggregate the performance results over the number of cores used */ +static void +print_dec_throughput(struct thread_params *t_params, unsigned int used_cores) +{ + unsigned int core_idx = 0; + double total_mops = 0, total_mbps = 0; + uint8_t iter_count = 0; + + for (core_idx = 0; core_idx < used_cores; core_idx++) { + printf( + "Throughput for core (%u): %.8lg Ops/s, %.8lg Mbps @ max %u iterations\n", + t_params[core_idx].lcore_id, + t_params[core_idx].ops_per_sec, + t_params[core_idx].mbps, + t_params[core_idx].iter_count); + total_mops += t_params[core_idx].ops_per_sec; + total_mbps += t_params[core_idx].mbps; + iter_count = RTE_MAX(iter_count, + t_params[core_idx].iter_count); + } + printf( + "\nTotal throughput for %u cores: %.8lg MOPS, %.8lg Mbps @ max %u iterations\n", + used_cores, total_mops, total_mbps, iter_count); +} + + +/* + * Test function that determines how long an enqueue + dequeue of a burst + * takes on available lcores. + */ +int +start_pmd_dec(struct active_device *ad, + struct test_op_params *op_params, + struct thread_params *t_params, + t_nrLDPCoffload_params *p_offloadParams, + uint8_t r, + uint8_t harq_pid, + uint8_t ulsch_id, + int8_t* p_out) +{ + int ret; + unsigned int lcore_id, used_cores = 0; + struct thread_params *tp; + //struct rte_bbdev_info info; + uint16_t num_lcores; + //uint64_t start_time, start_time1 ; //= rte_rdtsc_precise(); + //uint64_t total_time=0, total_time1=0; + //rte_bbdev_info_get(ad->dev_id, &info); + //start_time = rte_rdtsc_precise(); + /*printf("+ ------------------------------------------------------- +\n"); + printf("== start pmd dec\ndev: %s, nb_queues: %u, burst size: %u, num ops: %u, num_lcores: %u, itr mode: %s, GHz: %lg\n", + info.dev_name, ad->nb_queues, op_params->burst_sz, + op_params->num_to_process, op_params->num_lcores, + intr_enabled ? "Interrupt mode" : "PMD mode", + (double)rte_get_tsc_hz() / 1000000000.0); + */ + /* Set number of lcores */ + num_lcores = (ad->nb_queues < (op_params->num_lcores)) + ? ad->nb_queues + : op_params->num_lcores; + + /* Allocate memory for thread parameters structure */ + /*t_params = rte_zmalloc(NULL, num_lcores * sizeof(struct thread_params), + RTE_CACHE_LINE_SIZE); + TEST_ASSERT_NOT_NULL(t_params, "Failed to alloc %zuB for t_params", + RTE_ALIGN(sizeof(struct thread_params) * num_lcores, + RTE_CACHE_LINE_SIZE)); + */ + //total_time = rte_rdtsc_precise() - start_time; + rte_atomic16_set(&op_params->sync, SYNC_WAIT); + + /* Master core is set at first entry */ + t_params[0].dev_id = ad->dev_id; + t_params[0].lcore_id = rte_lcore_id(); + t_params[0].op_params = op_params; + t_params[0].queue_id = ad->queue_ids[used_cores++]; + t_params[0].iter_count = 0; + t_params[0].p_out = p_out; + t_params[0].p_offloadParams = p_offloadParams; + t_params[0].r = r; + t_params[0].harq_pid = harq_pid; + t_params[0].ulsch_id = ulsch_id; + + RTE_LCORE_FOREACH_SLAVE(lcore_id) { + if (used_cores >= num_lcores) + break; + t_params[used_cores].dev_id = ad->dev_id; + t_params[used_cores].lcore_id = lcore_id; + t_params[used_cores].op_params = op_params; + t_params[used_cores].queue_id = ad->queue_ids[used_cores]; + t_params[used_cores].iter_count = 0; + t_params[used_cores].p_out = p_out; + t_params[used_cores].p_offloadParams = p_offloadParams; + t_params[used_cores].r = r; + t_params[used_cores].harq_pid = harq_pid; + t_params[used_cores].ulsch_id = ulsch_id; + + rte_eal_remote_launch(pmd_lcore_ldpc_dec, + &t_params[used_cores++], lcore_id); + } + + rte_atomic16_set(&op_params->sync, SYNC_START); + + //total_time = rte_rdtsc_precise() - start_time; + + //if (total_time > 100*3000) + //LOG_E(PHY," start pmd 1st: %u\n",(uint) (total_time/3000)); + + ret = pmd_lcore_ldpc_dec(&t_params[0]); + //start_time1 = rte_rdtsc_precise(); + + /* Master core is always used */ + //for (used_cores = 1; used_cores < num_lcores; used_cores++) + // ret |= rte_eal_wait_lcore(t_params[used_cores].lcore_id); + + /* Return if test failed */ + if (ret) { + rte_free(t_params); + return ret; + } + + /* Print throughput if interrupts are disabled and test passed */ + if (!intr_enabled) { + ///print_dec_throughput(t_params, num_lcores); + //rte_free(t_params); + // total_time1 = rte_rdtsc_precise() - start_time1; + + // if (total_time1 > 10*3000) + // LOG_E(PHY," start pmd 2nd: %u\n",(uint) (total_time1/3000)); + // rte_free(t_params); + return ret; + } + /* In interrupt TC we need to wait for the interrupt callback to deqeue + * all pending operations. Skip waiting for queues which reported an + * error using processing_status variable. + * Wait for master lcore operations. + */ + tp = &t_params[0]; + while ((rte_atomic16_read(&tp->nb_dequeued) < + op_params->num_to_process) && + (rte_atomic16_read(&tp->processing_status) != + TEST_FAILED)) + rte_pause(); + + tp->ops_per_sec /= TEST_REPETITIONS; + tp->mbps /= TEST_REPETITIONS; + ret |= (int)rte_atomic16_read(&tp->processing_status); + + for (used_cores = 1; used_cores < num_lcores; used_cores++) { + tp = &t_params[used_cores]; + + while ((rte_atomic16_read(&tp->nb_dequeued) < + op_params->num_to_process) && + (rte_atomic16_read(&tp->processing_status) != + TEST_FAILED)) + rte_pause(); + + tp->ops_per_sec /= TEST_REPETITIONS; + tp->mbps /= TEST_REPETITIONS; + ret |= (int)rte_atomic16_read(&tp->processing_status); + } + + /* Print throughput if test passed */ + if (!ret) { + print_dec_throughput(t_params, num_lcores); + } + + rte_free(t_params); + + return ret; +} + + +/* Declare structure for command line test parameters and options */ +static struct test_params { + struct test_command *test_to_run[8]; + unsigned int num_tests; + unsigned int num_ops; + unsigned int burst_sz; + unsigned int num_lcores; + double snr; + unsigned int iter_max; + char test_vector_filename[PATH_MAX]; + bool init_device; +} test_params; + +unsigned int +get_num_ops(void) +{ + return test_params.num_ops; +} + +unsigned int +get_burst_sz(void) +{ + return test_params.burst_sz; +} + +unsigned int +get_num_lcores(void) +{ + return test_params.num_lcores; +} + +double +get_snr(void) +{ + return test_params.snr; +} + +unsigned int +get_iter_max(void) +{ + return test_params.iter_max; +} + +bool +get_init_device(void) +{ + return test_params.init_device; +} + +struct test_op_params op_params_e; +struct test_op_params *op_params = &op_params_e; + +struct rte_mbuf *m_head[DATA_NUM_TYPES]; + +struct thread_params *t_params; + + +int32_t nrLDPC_decod_offload(t_nrLDPC_dec_params* p_decParams, uint8_t harq_pid, uint8_t ulsch_id, uint8_t C, uint8_t rv, uint16_t F, + uint32_t E, uint8_t Qm, int8_t* p_llr, int8_t* p_out, uint8_t mode) +{ + t_nrLDPCoffload_params offloadParams; + t_nrLDPCoffload_params* p_offloadParams = &offloadParams; + uint64_t start=rte_rdtsc_precise(); + /*uint64_t start_time;//=rte_rdtsc_precise(); + uint64_t start_time1; //=rte_rdtsc_precise(); + uint64_t total_time=0, total_time1=0;*/ + uint32_t numIter = 0; + int ret; + /*uint64_t start_time_init; + uint64_t total_time_init=0;*/ + + /* + int argc_re=2; + char *argv_re[2]; + argv_re[0] = "/home/eurecom/hongzhi/dpdk-20.05orig/build/app/testbbdev"; + argv_re[1] = "--"; + */ + + int argc_re=7; + char *argv_re[7]; + argv_re[0] = "/home/eurecom/hongzhi/dpdk-20.05orig/build/app/testbbdev"; + argv_re[1] = "-l"; + argv_re[2] = "31"; + argv_re[3] = "-w"; + argv_re[4] = "81:00.0"; + argv_re[5] = "--file-prefix=b6"; + argv_re[6] = "--"; + + test_params.num_ops=1; + test_params.burst_sz=1; + test_params.num_lcores=1; + test_params.num_tests = 1; + struct active_device *ad; + ad = &active_devs[0]; + + int socket_id=0; + int i,f_ret; + struct rte_bbdev_info info; + enum rte_bbdev_op_type op_type = RTE_BBDEV_OP_LDPC_DEC; + + switch (mode) { + case 0: + ret = rte_eal_init(argc_re, argv_re); + if (ret<0) { + printf("Could not init EAL, ret %d\n",ret); + return(-1); + } + ret = device_setup(); + if (ret != TEST_SUCCESS) { + printf("Couldn't setup device"); + return(-1); + } + ret=ut_setup(); + if (ret != TEST_SUCCESS) { + printf("Couldn't setup ut"); + return(-1); + } + + p_offloadParams->E = E; + p_offloadParams->n_cb = (p_decParams->BG==1)?(66*p_decParams->Z):(50*p_decParams->Z); + p_offloadParams->BG = p_decParams->BG; + p_offloadParams->Z = p_decParams->Z; + p_offloadParams->rv = rv; + p_offloadParams->F = F; + p_offloadParams->Qm = Qm; + + op_params = rte_zmalloc(NULL, + sizeof(struct test_op_params), RTE_CACHE_LINE_SIZE); + TEST_ASSERT_NOT_NULL(op_params, "Failed to alloc %zuB for op_params", + RTE_ALIGN(sizeof(struct test_op_params), + RTE_CACHE_LINE_SIZE)); + + rte_bbdev_info_get(ad->dev_id, &info); + socket_id = GET_SOCKET(info.socket_id); + f_ret = create_mempools(ad, socket_id, op_type, + get_num_ops(),p_offloadParams); + if (f_ret != TEST_SUCCESS) { + printf("Couldn't create mempools"); + } + f_ret = init_test_op_params(op_params, op_type, + 0, + 0, + ad->ops_mempool, + 1, + get_num_ops(), + get_num_lcores()); + if (f_ret != TEST_SUCCESS) { + printf("Couldn't init test op params"); + } + + //const struct rte_bbdev_op_cap *capabilities = NULL; + rte_bbdev_info_get(ad->dev_id, &info); + socket_id = GET_SOCKET(info.socket_id); + //enum rte_bbdev_op_type op_type = RTE_BBDEV_OP_LDPC_DEC; + /*const struct rte_bbdev_op_cap *cap = info.drv.capabilities; + + for (i = 0; i < RTE_BBDEV_OP_TYPE_COUNT; i++) { + if (cap->type == op_type) { + capabilities = cap; + break; + } + cap++; + }*/ + ad->nb_queues = 1; + enum op_data_type type; + + for (i = 0; i < ad->nb_queues; ++i) { + + const uint16_t n = op_params->num_to_process; + + struct rte_mempool *in_mp = ad->in_mbuf_pool; + struct rte_mempool *hard_out_mp = ad->hard_out_mbuf_pool; + struct rte_mempool *soft_out_mp = ad->soft_out_mbuf_pool; + struct rte_mempool *harq_in_mp = ad->harq_in_mbuf_pool; + struct rte_mempool *harq_out_mp = ad->harq_out_mbuf_pool; + + struct rte_mempool *mbuf_pools[DATA_NUM_TYPES] = { + in_mp, + soft_out_mp, + hard_out_mp, + harq_in_mp, + harq_out_mp, + }; + + uint8_t queue_id =ad->queue_ids[i]; + struct rte_bbdev_op_data **queue_ops[DATA_NUM_TYPES] = { + &op_params->q_bufs[socket_id][queue_id].inputs, + &op_params->q_bufs[socket_id][queue_id].soft_outputs, + &op_params->q_bufs[socket_id][queue_id].hard_outputs, + &op_params->q_bufs[socket_id][queue_id].harq_inputs, + &op_params->q_bufs[socket_id][queue_id].harq_outputs, + }; + + for (type = DATA_INPUT; type < 3; type+=2) { + + ret = allocate_buffers_on_socket(queue_ops[type], + n * sizeof(struct rte_bbdev_op_data), + socket_id); + TEST_ASSERT_SUCCESS(ret, + "Couldn't allocate memory for rte_bbdev_op_data structs"); + + m_head[type] = rte_pktmbuf_alloc(mbuf_pools[type]); + + TEST_ASSERT_NOT_NULL(m_head[type], + "Not enough mbufs in %d data type mbuf pool (needed %u, available %u)", + op_type, 1, + mbuf_pools[type]->size); + + } + + /* Allocate memory for thread parameters structure */ + t_params = rte_zmalloc(NULL, sizeof(struct thread_params), + RTE_CACHE_LINE_SIZE); + TEST_ASSERT_NOT_NULL(t_params, "Failed to alloc %zuB for t_params", + RTE_ALIGN(sizeof(struct thread_params), + RTE_CACHE_LINE_SIZE)); + } + + break; + case 1: + //printf("offload param E %d BG %d F %d Z %d Qm %d rv %d\n", E,p_decParams->BG, F,p_decParams->Z, Qm,rv); + //uint64_t start_time_init; + //uint64_t total_time_init=0; + + //start_time_init = rte_rdtsc_precise(); + p_offloadParams->E = E; + p_offloadParams->n_cb = (p_decParams->BG==1)?(66*p_decParams->Z):(50*p_decParams->Z); + p_offloadParams->BG = p_decParams->BG; + p_offloadParams->Z = p_decParams->Z; + p_offloadParams->rv = rv; + p_offloadParams->F = F; + p_offloadParams->Qm = Qm; + + rte_bbdev_info_get(ad->dev_id, &info); + socket_id = GET_SOCKET(info.socket_id); + + create_reference_ldpc_dec_op(op_params->ref_dec_op, p_offloadParams); + + struct rte_mempool *in_mp = ad->in_mbuf_pool; + struct rte_mempool *hard_out_mp = ad->hard_out_mbuf_pool; + struct rte_mempool *soft_out_mp = ad->soft_out_mbuf_pool; + struct rte_mempool *harq_in_mp = ad->harq_in_mbuf_pool; + struct rte_mempool *harq_out_mp = ad->harq_out_mbuf_pool; + + struct rte_mempool *mbuf_pools[DATA_NUM_TYPES] = { + in_mp, + soft_out_mp, + hard_out_mp, + harq_in_mp, + harq_out_mp, + }; + + uint8_t queue_id =ad->queue_ids[0]; + struct rte_bbdev_op_data **queue_ops[DATA_NUM_TYPES] = { + &op_params->q_bufs[socket_id][queue_id].inputs, + &op_params->q_bufs[socket_id][queue_id].soft_outputs, + &op_params->q_bufs[socket_id][queue_id].hard_outputs, + &op_params->q_bufs[socket_id][queue_id].harq_inputs, + &op_params->q_bufs[socket_id][queue_id].harq_outputs, + }; + //start_time1 = rte_rdtsc_precise(); + for (type = DATA_INPUT; type < 3; type+=2) { + + ret = init_op_data_objs(*queue_ops[type], p_llr, p_offloadParams->E, + m_head[type], mbuf_pools[type], 1, type, info.drv.min_alignment); + TEST_ASSERT_SUCCESS(ret, + "Couldn't init rte_bbdev_op_data structs"); + + } + /*total_time_init = rte_rdtsc_precise() - start_time_init; + + if (total_time_init > 100*3000) + LOG_E(PHY," ldpc decoder mode 1 first: %u\n",(uint) (total_time_init/3000)); + + start_time1 = rte_rdtsc_precise();*/ + ret = start_pmd_dec(ad, op_params, t_params, p_offloadParams, C, harq_pid, ulsch_id, p_out); + if (ret<0) { + printf("Couldn't start pmd dec"); + return(-1); + } + /*total_time1 = rte_rdtsc_precise() - start_time1; + if (total_time1 > 100*3000) + LOG_E(PHY," ldpc decoder mode 1 second: %u\n",(uint) (total_time1/3000));*/ + break; + case 2: + + free_buffers(ad, op_params); + rte_free(op_params); + rte_free(t_params); + ut_teardown(); + testsuite_teardown(); + break; + default: + printf("Unknown mode: %d\n", mode); + return(-1); + } + /*uint64_t end=rte_rdtsc_precise(); + + if (end - start > 200*3000) + LOG_E(PHY," ldpc decode: %u\n",(uint) ((end - start)/3000)); + */ + return numIter; +} + diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_offload.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_offload.h new file mode 100644 index 0000000000..80a9395d0b --- /dev/null +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_offload.h @@ -0,0 +1,135 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Intel Corporation + */ + +#ifndef _MAIN_H_ +#define _MAIN_H_ + +#include +#include + +#include +#include +#include + +#define TEST_SUCCESS 0 +#define TEST_FAILED -1 +#define TEST_SKIPPED 1 + +#define MAX_BURST 512U +#define DEFAULT_BURST 32U +#define DEFAULT_OPS 64U +#define DEFAULT_ITER 6U + +enum op_data_type { + DATA_INPUT = 0, + DATA_SOFT_OUTPUT, + DATA_HARD_OUTPUT, + DATA_HARQ_INPUT, + DATA_HARQ_OUTPUT, + DATA_NUM_TYPES, +}; + +#define TEST_ASSERT(cond, msg, ...) do { \ + if (!(cond)) { \ + printf("TestCase %s() line %d failed: " \ + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ + return TEST_FAILED; \ + } \ +} while (0) + +/* Compare two buffers (length in bytes) */ +#define TEST_ASSERT_BUFFERS_ARE_EQUAL(a, b, len, msg, ...) do { \ + if (memcmp((a), (b), len)) { \ + printf("TestCase %s() line %d failed: " \ + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ + rte_memdump(stdout, "Buffer A", (a), len); \ + rte_memdump(stdout, "Buffer B", (b), len); \ + return TEST_FAILED; \ + } \ +} while (0) + +#define TEST_ASSERT_SUCCESS(val, msg, ...) do { \ + typeof(val) _val = (val); \ + if (!(_val == 0)) { \ + printf("TestCase %s() line %d failed (err %d): " \ + msg "\n", __func__, __LINE__, _val, \ + ##__VA_ARGS__); \ + return TEST_FAILED; \ + } \ +} while (0) + +#define TEST_ASSERT_FAIL(val, msg, ...) \ + TEST_ASSERT_SUCCESS(!(val), msg, ##__VA_ARGS__) + +#define TEST_ASSERT_NOT_NULL(val, msg, ...) do { \ + if ((val) == NULL) { \ + printf("TestCase %s() line %d failed (null): " \ + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ + return TEST_FAILED; \ + } \ +} while (0) + +struct unit_test_case { + int (*setup)(void); + void (*teardown)(void); + int (*testcase)(void); + const char *name; +}; + +#define TEST_CASE(testcase) {NULL, NULL, testcase, #testcase} + +#define TEST_CASE_ST(setup, teardown, testcase) \ + {setup, teardown, testcase, #testcase} + +#define TEST_CASES_END() {NULL, NULL, NULL, NULL} + +struct unit_test_suite { + const char *suite_name; + int (*setup)(void); + void (*teardown)(void); + struct unit_test_case unit_test_cases[]; +}; + +int unit_test_suite_runner(struct unit_test_suite *suite); + +typedef int (test_callback)(void); +TAILQ_HEAD(test_commands_list, test_command); +struct test_command { + TAILQ_ENTRY(test_command) next; + const char *command; + test_callback *callback; +}; + +void add_test_command(struct test_command *t); + +/* Register a test function */ +#define REGISTER_TEST_COMMAND(name, testsuite) \ + static int test_func_##name(void) \ + { \ + return unit_test_suite_runner(&testsuite); \ + } \ + static struct test_command test_struct_##name = { \ + .command = RTE_STR(name), \ + .callback = test_func_##name, \ + }; \ + RTE_INIT(test_register_##name) \ + { \ + add_test_command(&test_struct_##name); \ + } + +const char *get_vector_filename(void); + +unsigned int get_num_ops(void); + +unsigned int get_burst_sz(void); + +unsigned int get_num_lcores(void); + +double get_snr(void); + +unsigned int get_iter_max(void); + +bool get_init_device(void); + +#endif diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h index fb52c5b428..226af8017e 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h @@ -75,6 +75,20 @@ typedef struct nrLDPC_dec_params { e_nrLDPC_outMode outMode; /**< Output format */ } t_nrLDPC_dec_params; +/** + Structure containing LDPC decoder parameters. + */ +typedef struct nrLDPCoffload_params { + uint8_t BG; /**< Base graph */ + uint16_t Z; + uint16_t Kr; + uint8_t rv; + uint32_t E; + uint16_t n_cb; + uint16_t F; /**< Filler bits */ + uint8_t Qm; /**< Modulation */ +} t_nrLDPCoffload_params; + /** Structure containing LDPC decoder processing time statistics. */ diff --git a/openair1/PHY/CODING/nrLDPC_defs.h b/openair1/PHY/CODING/nrLDPC_defs.h index 0c9c78c3ac..1aab887640 100644 --- a/openair1/PHY/CODING/nrLDPC_defs.h +++ b/openair1/PHY/CODING/nrLDPC_defs.h @@ -24,6 +24,7 @@ #define __NRLDPC_DEFS__H__ #include #include "openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h" + /** \brief LDPC encoder \param 1 input @@ -71,5 +72,9 @@ typedef int(*nrLDPC_encoderfunc_t)(unsigned char **,unsigned char **,int,int,sho \param p_llrOut Output vector \param p_profiler LDPC profiler statistics */ + typedef int32_t(*nrLDPC_decoderfunc_t)(t_nrLDPC_dec_params* , int8_t*, int8_t* , t_nrLDPC_time_stats* ); +typedef int32_t(*nrLDPC_decoffloadfunc_t)(t_nrLDPC_dec_params* , uint8_t, uint8_t, uint8_t , uint8_t, uint16_t, uint32_t, uint8_t, int8_t*, int8_t* ,uint8_t); +typedef int32_t(*nrLDPC_dectopfunc_t)(void); + #endif diff --git a/openair1/PHY/CODING/nrLDPC_extern.h b/openair1/PHY/CODING/nrLDPC_extern.h index b358119408..e4e4032681 100644 --- a/openair1/PHY/CODING/nrLDPC_extern.h +++ b/openair1/PHY/CODING/nrLDPC_extern.h @@ -24,14 +24,22 @@ nrLDPC_decoderfunc_t nrLDPC_decoder; nrLDPC_encoderfunc_t nrLDPC_encoder; nrLDPC_initcallfunc_t nrLDPC_initcall; +nrLDPC_decoffloadfunc_t nrLDPC_decoder_offload; +nrLDPC_dectopfunc_t top_testsuite; #else /* functions to load the LDPC shared lib, implemented in openair1/PHY/CODING/nrLDPC_load.c */ extern int load_nrLDPClib(char *version) ; +extern int load_nrLDPClib_offload(void) ; +extern int free_nrLDPClib_offload(void) ; extern int load_nrLDPClib_ref(char *libversion, nrLDPC_encoderfunc_t * nrLDPC_encoder_ptr); // for ldpctest /* ldpc coder/decoder functions, as loaded by load_nrLDPClib(). */ extern nrLDPC_initcallfunc_t nrLDPC_initcall; extern nrLDPC_decoderfunc_t nrLDPC_decoder; extern nrLDPC_encoderfunc_t nrLDPC_encoder; +extern nrLDPC_decoffloadfunc_t nrLDPC_decoder_offload; + +extern nrLDPC_dectopfunc_t top_testsuite; + // inline functions: #endif diff --git a/openair1/PHY/CODING/nrLDPC_load.c b/openair1/PHY/CODING/nrLDPC_load.c index 3049070cd6..49ca9bf0de 100644 --- a/openair1/PHY/CODING/nrLDPC_load.c +++ b/openair1/PHY/CODING/nrLDPC_load.c @@ -71,6 +71,56 @@ int load_nrLDPClib(char *version) { return 0; } +int load_nrLDPClib_offload(void) { + loader_shlibfunc_t shlib_decoffload_fdesc; + + shlib_decoffload_fdesc.fname = "nrLDPC_decod_offload"; + int ret=load_module_shlib("ldpc_offload",&shlib_decoffload_fdesc,1,NULL); + AssertFatal( (ret >= 0),"Error loading ldpc decoder offload"); + nrLDPC_decoder_offload = (nrLDPC_decoffloadfunc_t)shlib_decoffload_fdesc.fptr; + + t_nrLDPC_dec_params decParams; + t_nrLDPC_dec_params* p_decParams = &decParams; + int8_t l[68*384]; + int8_t llrProcBuf[22*384]; + + p_decParams->Z = 384; + p_decParams->BG = 1; + + AssertFatal(nrLDPC_decoder_offload(p_decParams,0, 0, + 1, + 0, + 0, + 25344, + 8, + l, + llrProcBuf, 0)>=0, + "error loading LDPC decoder offload library\n"); + + + return 0; +} + +int free_nrLDPClib_offload(void) { +t_nrLDPC_dec_params decParams; + t_nrLDPC_dec_params* p_decParams = &decParams; + int8_t l[68*384]; + int8_t llrProcBuf[22*384]; + + p_decParams->Z = 384; + p_decParams->BG = 1; + + nrLDPC_decoder_offload(p_decParams,0,0, + 1, + 0, + 0, + 25344, + 8, + l, + llrProcBuf, 2); +return 0; +} + int load_nrLDPClib_ref(char *libversion, nrLDPC_encoderfunc_t * nrLDPC_encoder_ptr) { loader_shlibfunc_t shlib_encoder_fdesc; diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c index 06dfcaa4a9..c99bd02fb2 100644 --- a/openair1/PHY/CODING/nr_rate_matching.c +++ b/openair1/PHY/CODING/nr_rate_matching.c @@ -497,10 +497,10 @@ int nr_rate_matching_ldpc_rx(uint32_t Tbslbrm, N = (BG==1)?(66*Z):(50*Z); if (Tbslbrm == 0) - Ncb = N; + Ncb = N; else { - Nref = (3*Tbslbrm/(2*C)); //R_LBRM = 2/3 - Ncb = min(N, Nref); + Nref = (3*Tbslbrm/(2*C)); //R_LBRM = 2/3 + Ncb = min(N, Nref); } ind = (index_k0[BG-1][rvidx]*Ncb/N)*Z; @@ -564,7 +564,6 @@ int nr_rate_matching_ldpc_rx(uint32_t Tbslbrm, } } - return 0; } diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index c92d926a8f..8e351a15f2 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -475,9 +475,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, srs_vars[srs_id].srs = (int32_t *) malloc16_clear (2 * fp->ofdm_symbol_size * sizeof (int32_t)); } - LOG_I(PHY,"PRACH allocation\n"); // PRACH - prach_vars->prachF = (int16_t *) malloc16_clear (1024 * 2 * sizeof (int16_t)); // assume maximum of 64 RX antennas for PRACH receiver prach_vars->prach_ifft[0] = (int32_t **) malloc16_clear (64 * sizeof (int32_t *)); @@ -485,8 +483,6 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, prach_vars->prach_ifft[0][i] = (int32_t *) malloc16_clear (1024 * 2 * sizeof (int32_t)); prach_vars->rxsigF[0] = (int16_t **) malloc16_clear (64 * sizeof (int16_t *)); - // PRACH BR - prach_vars_br->prachF = (int16_t *)malloc16_clear( 1024*2*sizeof(int32_t) ); // assume maximum of 64 RX antennas for PRACH receiver for (int ce_level = 0; ce_level < 4; ce_level++) { @@ -576,8 +572,6 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) { for (UE_id=0; UE_idprachF); - for (i = 0; i < 64; i++) free_and_zero(prach_vars->prach_ifft[0][i]); free_and_zero(prach_vars->prach_ifft[0]); @@ -589,7 +583,6 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) { free_and_zero(prach_vars->rxsigF[ce_level]); } - free_and_zero(prach_vars_br->prachF); free_and_zero(prach_vars->rxsigF[0]); for (int ULSCH_id=0; ULSCH_idcommon_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id][idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_tti*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) ); - common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id][idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 ); + common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id][idx] = (int32_t *)malloc16_clear( sizeof(int32_t)* + max(fp->symbols_per_tti*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH),6144) ); + common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id][idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*max(fp->ofdm_symbol_size*2,6144) ); } } } diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 6b984f53db..55599b7cc3 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -508,8 +508,12 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, crcTableInit(); init_scrambling_luts(); init_pucch2_luts(); + load_nrLDPClib(NULL); + if (gNB->ldpc_offload_flag) + load_nrLDPClib_offload(); + init_codebook_gNB(gNB); // PBCH DMRS gold sequences generation @@ -613,6 +617,10 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, for (int id=0; idnr_srs_info[id] = (nr_srs_info_t *)malloc16_clear(sizeof(nr_srs_info_t)); + gNB->nr_srs_info[id]->srs_generated_signal = (int32_t**)malloc16_clear(MAX_NUM_NR_SRS_AP*sizeof(int32_t*)); + for(int ap=0; apnr_srs_info[id]->srs_generated_signal[ap] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t)); + } } generate_ul_reference_signal_sequences(SHRT_MAX); @@ -767,6 +775,10 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) free_and_zero(gNB->nr_csi_info); for (int id = 0; id < NUMBER_OF_NR_SRS_MAX; id++) { + for(int i=0; inr_srs_info[id]->srs_generated_signal[i]); + } + free_and_zero(gNB->nr_srs_info[id]->srs_generated_signal); free_and_zero(gNB->nr_srs_info[id]); } @@ -905,7 +917,11 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB, gNB_config->carrier_config.dl_bandwidth.value = config_bandwidth(mu, N_RB_DL, fp->nr_band); nr_init_frame_parms(gNB_config, fp); + fp->ofdm_offset_divisor = UINT_MAX; + init_symbol_rotation(fp); + init_timeshift_rotation(fp); + gNB->configured = 1; LOG_I(PHY,"gNB configured\n"); } diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index e396651133..64bbed571c 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -376,6 +376,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) init_nr_prach_tables(839); init_symbol_rotation(fp); + init_timeshift_rotation(fp); + return 0; } diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c index 9327fe9fe8..45c25b59ea 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c @@ -106,9 +106,9 @@ int32_t lte_ul_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms, #ifdef DEBUG_CH if (Ns==0) - LOG_M("drs_seq0.m","drsseq0",ul_ref_sigs_rx[u][v][Msc_RS_idx],2*Msc_RS,2,1); + LOG_M("drs_seq0.m","drsseq0",ul_ref_sigs_rx[u][v][Msc_RS_idx],2*Msc_RS,2,0); else - LOG_M("drs_seq1.m","drsseq1",ul_ref_sigs_rx[u][v][Msc_RS_idx],2*Msc_RS,2,1); + LOG_M("drs_seq1.m","drsseq1",ul_ref_sigs_rx[u][v][Msc_RS_idx],2*Msc_RS,2,0); #endif @@ -311,7 +311,7 @@ int32_t lte_ul_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms, // alpha = (int16_t) (((int32_t) SCALE * (int32_t) (pilot_pos2-k))/(pilot_pos2-pilot_pos1)); // beta = (int16_t) (((int32_t) SCALE * (int32_t) (k-pilot_pos1))/(pilot_pos2-pilot_pos1)); #ifdef DEBUG_CH - LOG_D(PHY,"lte_ul_channel_estimation: k=%d, alpha = %d, beta = %d\n",k,alpha,beta); + LOG_D(PHY,"lte_ul_channel_estimation: k=%d\n",k); #endif //symbol_offset_subframe = frame_parms->N_RB_UL*12*k; @@ -436,9 +436,9 @@ int32_t lte_ul_channel_estimation_RRU(LTE_DL_FRAME_PARMS *frame_parms, #ifdef DEBUG_CH if (l==pilot_pos1) - write_output("drs_seq0.m","drsseq0",ul_ref_sigs_rx[u][v][Msc_RS_idx],Msc_RS,1,1); + write_output("drs_seq0.m","drsseq0",ul_ref_sigs_rx[u][v][Msc_RS_idx],Msc_RS,1,0); else - write_output("drs_seq1.m","drsseq1",ul_ref_sigs_rx[u][v][Msc_RS_idx],Msc_RS,1,1); + write_output("drs_seq1.m","drsseq1",ul_ref_sigs_rx[u][v][Msc_RS_idx],Msc_RS,1,0); #endif symbol_offset = frame_parms->N_RB_UL*12*l; diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index 1725588f4c..944e8fe18f 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -74,7 +74,8 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, uint32_t subframe_offset=((frame_parms->Ncp==0)?14:12)*frame_parms->ofdm_symbol_size*subframe; memset(d,0,24*sizeof(int16_t)); - + const int nushift=frame_parms->nushift; + if (frame_parms->nb_antenna_ports_eNB==1) gain_lin_QPSK = (int16_t)(((int32_t)amp*ONE_OVER_SQRT2_Q15)>>15); else @@ -245,7 +246,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, y1_16[7] = -y0_16[5]; for (i=0,j=0,m=0; i<6; i++,j+=2) { - if ((i!=(frame_parms->nushift))&&(i!=(frame_parms->nushift+3))) { + if ((i!=(nushift))&&(i!=((nushift+3)%6))) { y0[j] += y0_16[m]; y1[j] += y1_16[m++]; y0[j+1] += y0_16[m]; @@ -287,7 +288,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, y1_16[7] = -y0_16[5]; for (i=0,j=0,m=0; i<6; i++,j+=2) { - if ((i!=(frame_parms->nushift))&&(i!=(frame_parms->nushift+3))) { + if ((i!=(nushift))&&(i!=((nushift+3)%6))) { y0[j] += y0_16[m]; y1[j] += y1_16[m++]; y0[j+1] += y0_16[m]; @@ -329,7 +330,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, y1_16[7] = -y0_16[5]; for (i=0,j=0,m=0; i<6; i++,j+=2) { - if ((i!=(frame_parms->nushift))&&(i!=(frame_parms->nushift+3))) { + if ((i!=(nushift))&&(i!=((nushift+3)%6))) { y0[j] += y0_16[m]; y1[j] += y1_16[m++]; y0[j+1] += y0_16[m]; @@ -360,7 +361,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, y0_16[7] = d[7]*gain_lin_QPSK; for (i=0,j=0,m=0; i<6; i++,j+=2) { - if ((i!=(frame_parms->nushift))&&(i!=(frame_parms->nushift+3))) { + if ((i!=(nushift))&&(i!=((nushift+3)%6))) { y0[j] += y0_16[m++]; y0[j+1] += y0_16[m++]; } @@ -385,7 +386,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, y0_16[7] = d[15]*gain_lin_QPSK; for (i=0,j=0,m=0; i<6; i++,j+=2) { - if ((i!=(frame_parms->nushift))&&(i!=(frame_parms->nushift+3))) { + if ((i!=(nushift))&&(i!=((nushift+3)%6))) { y0[j] += y0_16[m++]; y0[j+1] += y0_16[m++]; } @@ -410,7 +411,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, y0_16[7] = d[23]*gain_lin_QPSK; for (i=0,j=0,m=0; i<6; i++,j+=2) { - if ((i!=(frame_parms->nushift))&&(i!=(frame_parms->nushift+3))) { + if ((i!=(nushift))&&(i!=((nushift+3)%6))) { y0[j] += y0_16[m++]; y0[j+1] += y0_16[m++]; } @@ -533,7 +534,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, y1_16[7] = -y0_16[5]; for (i=0,j=0,m=0; i<6; i++,j+=2) { - if ((i!=(frame_parms->nushift))&&(i!=(frame_parms->nushift+3))) { + if ((i!=(nushift))&&(i!=((nushift+3)%6))) { y0[j] += y0_16[m]; y1[j] += y1_16[m++]; y0[j+1] += y0_16[m]; @@ -644,7 +645,7 @@ void generate_phich(LTE_DL_FRAME_PARMS *frame_parms, y0_16[7] = d[7]*gain_lin_QPSK; for (i=0,j=0,m=0; i<6; i++,j+=2) { - if ((i!=(frame_parms->nushift))&&(i!=(frame_parms->nushift+3))) { + if ((i!=(nushift))&&(i!=((nushift+3)%6))) { y0[j] += y0_16[m++]; y0[j+1] += y0_16[m++]; } diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index 91c419ebe3..6a989edc4d 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -62,9 +62,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, uint8_t Ncs_config; uint8_t restricted_set; uint8_t n_ra_prb; - int16_t *prachF=NULL; int16_t **rxsigF=NULL; - int16_t *prach2; uint8_t preamble_index; uint16_t NCS,NCS2; uint16_t preamble_offset=0,preamble_offset_old; @@ -77,12 +75,10 @@ void rx_prach0(PHY_VARS_eNB *eNB, uint8_t not_found; int k=0; uint16_t u; - int16_t *Xu=0; - uint16_t offset; + c16_t *Xu=0; int16_t Ncp; uint16_t first_nonzero_root_idx=0; uint8_t new_dft=0; - uint8_t aa; int32_t lev; int16_t levdB; int fft_size=0,log2_ifft_size; @@ -130,14 +126,11 @@ void rx_prach0(PHY_VARS_eNB *eNB, tdd_mapindex,Nf); } - int16_t *prach[nb_rx]; uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); uint16_t N_ZC = (prach_fmt <4)?839:139; - if (eNB) { if (br_flag == 1) { prach_ifftp = eNB->prach_vars_br.prach_ifft[ce_level]; - prachF = eNB->prach_vars_br.prachF; rxsigF = eNB->prach_vars_br.rxsigF[ce_level]; if (LOG_DEBUGFLAG(PRACH)) { @@ -151,7 +144,6 @@ void rx_prach0(PHY_VARS_eNB *eNB, } } else { prach_ifftp = eNB->prach_vars.prach_ifft[0]; - prachF = eNB->prach_vars.prachF; rxsigF = eNB->prach_vars.rxsigF[0]; //if (LOG_DEBUGFLAG(PRACH)) { @@ -179,7 +171,8 @@ void rx_prach0(PHY_VARS_eNB *eNB, AssertFatal(ru!=NULL,"ru is null\n"); int8_t dBEn0=0; - for (aa=0; aaif_south == LOCAL_RF || ru->function == NGFI_RAU_IF5) { // set the time-domain signal if we have to use it in this node // DJP - indexing below in subframe zero takes us off the beginning of the array??? prach[aa] = (int16_t *)&ru->common.rxdata[aa][(subframe*fp->samples_per_tti)-ru->N_TA_offset]; @@ -291,9 +284,9 @@ void rx_prach0(PHY_VARS_eNB *eNB, LOG_D(PHY,"rx_prach: Doing FFT for N_RB_UL %d nb_rx:%d Ncp:%d\n",fp->N_RB_UL, nb_rx, Ncp); } - for (aa=0; aaN_RB_UL) { @@ -562,37 +555,38 @@ void rx_prach0(PHY_VARS_eNB *eNB, if (new_dft == 1) { new_dft = 0; - + if (br_flag == 1) { - Xu=(int16_t *)eNB->X_u_br[ce_level][preamble_offset-first_nonzero_root_idx]; + Xu=(c16_t *)eNB->X_u_br[ce_level][preamble_offset-first_nonzero_root_idx]; prach_ifft = prach_ifftp[prach_ifft_cnt++]; - + if (eNB->prach_vars_br.repetition_number[ce_level]==1) memset(prach_ifft,0,((N_ZC==839)?2048:256)*sizeof(int32_t)); } else { - Xu=(int16_t *)eNB->X_u[preamble_offset-first_nonzero_root_idx]; + Xu=(c16_t *)eNB->X_u[preamble_offset-first_nonzero_root_idx]; prach_ifft = prach_ifftp[0]; memset(prach_ifft,0,((N_ZC==839) ? 2048 : 256)*sizeof(int32_t)); } - - memset(prachF, 0, sizeof(int16_t)*2*1024 ); - - if (LOG_DUMPFLAG(PRACH)) { - if (prach[0]!= NULL) LOG_M("prach_rx0.m","prach_rx0",prach[0],6144+792,1,1); - - LOG_M("prach_rx1.m","prach_rx1",prach[1],6144+792,1,1); - LOG_M("prach_rxF0.m","prach_rxF0",rxsigF[0],12288,1,1); - LOG_M("prach_rxF1.m","prach_rxF1",rxsigF[1],12288,1,1); - } - - for (aa=0; aa>15); - prachF[offset+1] = (int16_t)(((int32_t)Xu[offset]*rxsigF[aa][k+1] - (int32_t)Xu[offset+1]*rxsigF[aa][k])>>15); + + for (int offset=0; offset>15); + prachF[offset].i = (int16_t)(((int32_t)Xu[offset].r*rxsigF[aa][k+1] - (int32_t)Xu[offset].i*rxsigF[aa][k])>>15); k+=2; - + if (k==(12*2*fp->ofdm_symbol_size)) k=0; } @@ -600,13 +594,13 @@ void rx_prach0(PHY_VARS_eNB *eNB, // Now do IFFT of size 1024 (N_ZC=839) or 256 (N_ZC=139) if (N_ZC == 839) { log2_ifft_size = 10; - idft(IDFT_1024,prachF,prach_ifft_tmp,1); + idft(IDFT_1024,(int16_t*)prachF,prach_ifft_tmp,1); // compute energy and accumulate over receive antennas and repetitions for BR for (i=0; i<2048; i++) prach_ifft[i] += (prach_ifft_tmp[i<<1]*prach_ifft_tmp[i<<1] + prach_ifft_tmp[1+(i<<1)]*prach_ifft_tmp[1+(i<<1)])>>9; } else { - idft(IDFT_256,prachF,prach_ifft_tmp,1); + idft(IDFT_256,(int16_t*)prachF,prach_ifft_tmp,1); log2_ifft_size = 8; // compute energy and accumulate over receive antennas and repetitions for BR @@ -674,14 +668,12 @@ void rx_prach0(PHY_VARS_eNB *eNB, if (br_flag == 0) { LOG_M("rxsigF.m","prach_rxF",&rxsigF[0][0],12288,1,1); - LOG_M("prach_rxF_comp0.m","prach_rxF_comp0",prachF,1024,1,1); LOG_M("Xu.m","xu",Xu,N_ZC,1,1); LOG_M("prach_ifft0.m","prach_t0",prach_ifft,1024,1,1); LOG_M("SF2_3.m","sf2_3",&ru->common.rxdata[0][2*fp->samples_per_tti],2*fp->samples_per_tti,1,1); } else { LOG_E(PHY,"Dumping prach (br_flag %d), k = %d (n_ra_prb %d)\n",br_flag,k,n_ra_prb); LOG_M("rxsigF_br.m","prach_rxF_br",&rxsigF[0][0],12288,1,1); - LOG_M("prach_rxF_comp0_br.m","prach_rxF_comp0_br",prachF,1024,1,1); LOG_M("Xu_br.m","xu_br",Xu,N_ZC,1,1); LOG_M("prach_ifft0_br.m","prach_t0_br",prach_ifft,1024,1,1); } diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index a6dde08a2c..f71ca76b71 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -335,7 +335,10 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc, } union turboReqUnion id= {.s={ulsch->rnti,proc->frame_rx,proc->subframe_rx,0,0}}; - notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(turboDecode_t), id.p, proc->respDecode, processULSegment); + notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(turboDecode_t), + id.p, + proc->respDecode, + processULSegment); turboDecode_t * rdata=(turboDecode_t *) NotifiedFifoData(req); rdata->eNB=eNB; diff --git a/openair1/PHY/MODULATION/nr_modulation.h b/openair1/PHY/MODULATION/nr_modulation.h index 88a4cfefed..435251868e 100644 --- a/openair1/PHY/MODULATION/nr_modulation.h +++ b/openair1/PHY/MODULATION/nr_modulation.h @@ -112,8 +112,7 @@ void apply_nr_rotation(NR_DL_FRAME_PARMS *fp, int16_t* txdata, int slot, int first_symbol, - int nsymb, - int length); + int nsymb); void init_symbol_rotation(NR_DL_FRAME_PARMS *fp); @@ -123,8 +122,7 @@ void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms, int32_t *rxdataF, int slot, int first_symbol, - int nsymb, - int length); + int nsymb); /*! \brief Perform NR precoding. TS 38.211 V15.4.0 subclause 6.3.1.5 @param[in] datatx_F_precoding, Pointer to n_layers*re data array diff --git a/openair1/PHY/MODULATION/ofdm_mod.c b/openair1/PHY/MODULATION/ofdm_mod.c index 0b8f22a094..0f79c4532b 100644 --- a/openair1/PHY/MODULATION/ofdm_mod.c +++ b/openair1/PHY/MODULATION/ofdm_mod.c @@ -341,30 +341,41 @@ void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t ne } void apply_nr_rotation(NR_DL_FRAME_PARMS *fp, - int16_t* trxdata, + int16_t* txdataF, int slot, int first_symbol, - int nsymb, - int length) { + int nsymb) +{ int symb_offset = (slot%fp->slots_per_subframe)*fp->symbols_per_slot; - c16_t *symbol_rotation = fp->symbol_rotation[0]; + c16_t *symbol_rotation = fp->symbol_rotation[0] + symb_offset; - for (int sidx=0;sidxofdm_symbol_size; - LOG_D(PHY,"Rotating symbol %d, slot %d, symbol_subframe_index %d, length %d (%d,%d)\n", - first_symbol + sidx, + LOG_D(PHY,"Rotating symbol %d, slot %d, symbol_subframe_index %d (%d,%d)\n", + sidx, slot, - sidx + first_symbol + symb_offset, - length, - symbol_rotation[sidx + first_symbol + symb_offset].r, - symbol_rotation[sidx + first_symbol + symb_offset].i); + sidx + symb_offset, + this_rotation->r, + this_rotation->i); - rotate_cpx_vector(((c16_t*) trxdata) + sidx * length, - symbol_rotation + sidx + first_symbol + symb_offset, - ((c16_t*) trxdata) + sidx * length, - length, - 15); + if (fp->N_RB_DL & 1) { + rotate_cpx_vector(this_symbol, this_rotation, this_symbol, + (fp->N_RB_DL + 1) * 6, 15); + rotate_cpx_vector(this_symbol + fp->first_carrier_offset - 6, + this_rotation, + this_symbol + fp->first_carrier_offset - 6, + (fp->N_RB_DL + 1) * 6, 15); + } else { + rotate_cpx_vector(this_symbol, this_rotation, this_symbol, + fp->N_RB_DL * 6, 15); + rotate_cpx_vector(this_symbol + fp->first_carrier_offset, + this_rotation, + this_symbol + fp->first_carrier_offset, + fp->N_RB_DL * 6, 15); + } } } diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c index 548db21878..71be5ba6ed 100644 --- a/openair1/PHY/MODULATION/slot_fep_nr.c +++ b/openair1/PHY/MODULATION/slot_fep_nr.c @@ -107,20 +107,36 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, symbol+symb_offset,rot2.r,rot2.i); #endif - rotate_cpx_vector((c16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], - &rot2, - (c16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], - frame_parms->ofdm_symbol_size, - 15); - c16_t *shift_rot = frame_parms->timeshift_symbol_rotation; + c16_t *this_symbol = (c16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol]; - multadd_cpx_vector((int16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], - (int16_t *)shift_rot, - (int16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], - 1, - frame_parms->ofdm_symbol_size, - 15); + if (frame_parms->N_RB_DL & 1) { + rotate_cpx_vector(this_symbol, &rot2, this_symbol, + (frame_parms->N_RB_DL + 1) * 6, 15); + rotate_cpx_vector(this_symbol + frame_parms->first_carrier_offset - 6, + &rot2, + this_symbol + frame_parms->first_carrier_offset - 6, + (frame_parms->N_RB_DL + 1) * 6, 15); + multadd_cpx_vector((int16_t *)this_symbol, (int16_t *)shift_rot, (int16_t *)this_symbol, + 1, (frame_parms->N_RB_DL + 1) * 6, 15); + multadd_cpx_vector((int16_t *)(this_symbol + frame_parms->first_carrier_offset - 6), + (int16_t *)(shift_rot + frame_parms->first_carrier_offset - 6), + (int16_t *)(this_symbol + frame_parms->first_carrier_offset - 6), + 1, (frame_parms->N_RB_DL + 1) * 6, 15); + } else { + rotate_cpx_vector(this_symbol, &rot2, this_symbol, + frame_parms->N_RB_DL * 6, 15); + rotate_cpx_vector(this_symbol + frame_parms->first_carrier_offset, + &rot2, + this_symbol + frame_parms->first_carrier_offset, + frame_parms->N_RB_DL * 6, 15); + multadd_cpx_vector((int16_t *)this_symbol, (int16_t *)shift_rot, (int16_t *)this_symbol, + 1, frame_parms->N_RB_DL * 6, 15); + multadd_cpx_vector((int16_t *)(this_symbol + frame_parms->first_carrier_offset), + (int16_t *)(shift_rot + frame_parms->first_carrier_offset), + (int16_t *)(this_symbol + frame_parms->first_carrier_offset), + 1, frame_parms->N_RB_DL * 6, 15); + } } #ifdef DEBUG_FEP @@ -223,11 +239,8 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue, symbol+symb_offset,rot2.r,rot2.i); #endif - rotate_cpx_vector((c16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], - &rot2, - (c16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol], - frame_parms->ofdm_symbol_size, - 15); + c16_t *this_symbol = (c16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol]; + rotate_cpx_vector(this_symbol, &rot2, this_symbol, frame_parms->ofdm_symbol_size, 15); } #ifdef DEBUG_FEP @@ -301,10 +314,8 @@ void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms, int32_t *rxdataF, int slot, int first_symbol, - int nsymb, - int length) { - - + int nsymb) +{ int symb_offset = (slot%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot; int soffset = (slot&3)*frame_parms->symbols_per_slot*frame_parms->ofdm_symbol_size; @@ -313,19 +324,36 @@ void apply_nr_rotation_ul(NR_DL_FRAME_PARMS *frame_parms, c16_t rot2 = frame_parms->symbol_rotation[1][symbol + symb_offset]; rot2.i=-rot2.i; LOG_D(PHY,"slot %d, symb_offset %d rotating by %d.%d\n",slot,symb_offset,rot2.r,rot2.i); - rotate_cpx_vector((c16_t *)&rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)], - &rot2, - (c16_t *)&rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)], - length, - 15); c16_t *shift_rot = frame_parms->timeshift_symbol_rotation; + c16_t *this_symbol = (c16_t *)&rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)]; - multadd_cpx_vector((int16_t *)&rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)], - (int16_t *)shift_rot, - (int16_t *)&rxdataF[soffset+(frame_parms->ofdm_symbol_size*symbol)], - 1, - length, - 15); + if (frame_parms->N_RB_UL & 1) { + rotate_cpx_vector(this_symbol, &rot2, this_symbol, + (frame_parms->N_RB_UL + 1) * 6, 15); + rotate_cpx_vector(this_symbol + frame_parms->first_carrier_offset - 6, + &rot2, + this_symbol + frame_parms->first_carrier_offset - 6, + (frame_parms->N_RB_UL + 1) * 6, 15); + multadd_cpx_vector((int16_t *)this_symbol, (int16_t *)shift_rot, (int16_t *)this_symbol, + 1, (frame_parms->N_RB_UL+1) * 6, 15); + multadd_cpx_vector((int16_t *)(this_symbol + frame_parms->first_carrier_offset - 6), + (int16_t *)(shift_rot + frame_parms->first_carrier_offset - 6), + (int16_t *)(this_symbol + frame_parms->first_carrier_offset - 6), + 1, (frame_parms->N_RB_UL+1) * 6, 15); + } else { + rotate_cpx_vector(this_symbol, &rot2, this_symbol, + frame_parms->N_RB_UL * 6, 15); + rotate_cpx_vector(this_symbol + frame_parms->first_carrier_offset, + &rot2, + this_symbol + frame_parms->first_carrier_offset, + frame_parms->N_RB_UL * 6, 15); + multadd_cpx_vector((int16_t *)this_symbol, (int16_t *)shift_rot, (int16_t *)this_symbol, + 1, frame_parms->N_RB_UL * 6, 15); + multadd_cpx_vector((int16_t *)(this_symbol + frame_parms->first_carrier_offset), + (int16_t *)(shift_rot + frame_parms->first_carrier_offset), + (int16_t *)(this_symbol + frame_parms->first_carrier_offset), + 1, frame_parms->N_RB_UL * 6, 15); + } } } diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index c527c3fc9d..d8cf2fdc1b 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -67,7 +67,7 @@ int nr_est_timing_advance_pusch(PHY_VARS_gNB* gNB, int UE_id) return max_pos - sync_pos; } -int nr_est_timing_advance_srs(const NR_DL_FRAME_PARMS *frame_parms, +int nr_est_timing_advance_srs(const NR_DL_FRAME_PARMS *frame_parms, const int32_t srs_estimated_channel_time[][frame_parms->ofdm_symbol_size]) { int timing_advance = 0; int max_val = 0; diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 2dc368fdb0..4133875139 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -28,6 +28,7 @@ #include "PHY/NR_REFSIG/dmrs_nr.h" #include "PHY/NR_REFSIG/ptrs_nr.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" +#include "PHY/NR_UE_TRANSPORT/srs_modulation_nr.h" #include "PHY/NR_UE_ESTIMATION/filt16a_32.h" #include "PHY/NR_REFSIG/ul_ref_seq_nr.h" @@ -76,6 +77,29 @@ void freq2time(uint16_t ofdm_symbol_size, } } + +__attribute__((always_inline)) inline c16_t c32x16cumulVectVectWithSteps(c16_t *in1, + int *offset1, + const int step1, + c16_t *in2, + int *offset2, + const int step2, + const int modulo2, + const int N) { + + int localOffset1=*offset1; + int localOffset2=*offset2; + c32_t cumul={0}; + for (int i=0; ipusch_vars[ul_id]->ul_ch_estimates_time; - int chest_freq = gNB->chest_freq; - __m128i *ul_ch_128; + + const int chest_freq = gNB->chest_freq; #ifdef DEBUG_CH FILE *debug_ch_est; debug_ch_est = fopen("debug_ch_est.txt","w"); #endif - //uint16_t Nid_cell = (eNB_offset == 0) ? gNB->frame_parms.Nid_cell : gNB->measurements.adj_cell_id[eNB_offset-1]; - - uint8_t nushift; - int **ul_ch_estimates = gNB->pusch_vars[ul_id]->ul_ch_estimates; - int **rxdataF = gNB->common_vars.rxdataF; - int soffset = (Ns&3)*gNB->frame_parms.symbols_per_slot*gNB->frame_parms.ofdm_symbol_size; - nushift = (p>>1)&1; + c16_t **ul_ch_estimates = (c16_t **) gNB->pusch_vars[ul_id]->ul_ch_estimates; + const int symbolSize = gNB->frame_parms.ofdm_symbol_size; + const int soffset = (Ns&3)*gNB->frame_parms.symbols_per_slot*symbolSize; + const int nushift = (p>>1)&1; gNB->frame_parms.nushift = nushift; + int ch_offset = symbolSize*symbol; + const int symbol_offset = symbolSize*symbol; - ch_offset = gNB->frame_parms.ofdm_symbol_size*symbol; - - symbol_offset = gNB->frame_parms.ofdm_symbol_size*symbol; - - k0 = bwp_start_subcarrier; - int re_offset; - - uint16_t nb_rb_pusch = pusch_pdu->rb_size; + const int k0 = bwp_start_subcarrier; + const int nb_rb_pusch = pusch_pdu->rb_size; LOG_D(PHY, "In %s: ch_offset %d, soffset %d, symbol_offset %d, OFDM size %d, Ns = %d, k0 = %d, symbol %d\n", __FUNCTION__, ch_offset, soffset, symbol_offset, - gNB->frame_parms.ofdm_symbol_size, + symbolSize, Ns, k0, symbol); switch (nushift) { - case 0: - fl = filt8_l0; - fm = filt8_m0; - fr = filt8_r0; - fmm = filt8_mm0; - fml = filt8_m0; - fmr = filt8_mr0; - fdcl = filt8_dcl0; - fdcr = filt8_dcr0; - fdclh = filt8_dcl0_h; - fdcrh = filt8_dcr0_h; - break; + case 0: + fl = filt8_l0; + fm = filt8_m0; + fr = filt8_r0; + fmm = filt8_mm0; + fml = filt8_m0; + fmr = filt8_mr0; + fdcl = filt8_dcl0; + fdcr = filt8_dcr0; + fdclh = filt8_dcl0_h; + fdcrh = filt8_dcr0_h; + break; - case 1: - fl = filt8_l1; - fm = filt8_m1; - fr = filt8_r1; - fmm = filt8_mm1; - fml = filt8_ml1; - fmr = filt8_mm1; - fdcl = filt8_dcl1; - fdcr = filt8_dcr1; - fdclh = filt8_dcl1_h; - fdcrh = filt8_dcr1_h; - break; + case 1: + fl = filt8_l1; + fm = filt8_m1; + fr = filt8_r1; + fmm = filt8_mm1; + fml = filt8_ml1; + fmr = filt8_mm1; + fdcl = filt8_dcl1; + fdcr = filt8_dcr1; + fdclh = filt8_dcl1_h; + fdcrh = filt8_dcr1_h; + break; - default: + default: #ifdef DEBUG_CH if (debug_ch_est) fclose(debug_ch_est); #endif - return(-1); - break; - } + return(-1); + break; + } //------------------generate DMRS------------------// @@ -170,656 +180,402 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, gNB->pusch_gold_init[pusch_pdu->scid] = pusch_pdu->ul_dmrs_scrambling_id; nr_gold_pusch(gNB, pusch_pdu->scid, pusch_pdu->ul_dmrs_scrambling_id); } + if (pusch_pdu->transform_precoding == transformPrecoder_disabled) { - nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], &pilot[0], (1000+p), 0, nb_rb_pusch, + nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], (int32_t *)pilot, (1000+p), 0, nb_rb_pusch, (pusch_pdu->bwp_start + pusch_pdu->rb_start)*NR_NB_SC_PER_RB, pusch_pdu->dmrs_config_type); - } - else { // if transform precoding or SC-FDMA is enabled in Uplink - + } else { // if transform precoding or SC-FDMA is enabled in Uplink // NR_SC_FDMA supports type1 DMRS so only 6 DMRS REs per RB possible - uint16_t index = get_index_for_dmrs_lowpapr_seq(nb_rb_pusch * (NR_NB_SC_PER_RB/2)); - uint8_t u = pusch_pdu->dfts_ofdm.low_papr_group_number; - uint8_t v = pusch_pdu->dfts_ofdm.low_papr_sequence_number; + const uint16_t index = get_index_for_dmrs_lowpapr_seq(nb_rb_pusch * (NR_NB_SC_PER_RB/2)); + const uint8_t u = pusch_pdu->dfts_ofdm.low_papr_group_number; + const uint8_t v = pusch_pdu->dfts_ofdm.low_papr_sequence_number; int16_t *dmrs_seq = gNB_dmrs_lowpaprtype1_sequence[u][v][index]; - AssertFatal(index >= 0, "Num RBs not configured according to 3GPP 38.211 section 6.3.1.4. For PUSCH with transform precoding, num RBs cannot be multiple of any other primenumber other than 2,3,5\n"); AssertFatal(dmrs_seq != NULL, "DMRS low PAPR seq not found, check if DMRS sequences are generated"); - LOG_D(PHY,"Transform Precoding params. u: %d, v: %d, index for dmrsseq: %d\n", u, v, index); - - nr_pusch_lowpaprtype1_dmrs_rx(gNB, Ns, dmrs_seq, &pilot[0], 1000, 0, nb_rb_pusch, 0, pusch_pdu->dmrs_config_type); - - #ifdef DEBUG_PUSCH - printf ("NR_UL_CHANNEL_EST: index %d, u %d,v %d\n", index, u, v); - LOG_M("gNb_DMRS_SEQ.m","gNb_DMRS_SEQ", dmrs_seq,6*nb_rb_pusch,1,1); - #endif - + nr_pusch_lowpaprtype1_dmrs_rx(gNB, Ns, dmrs_seq, (int32_t *)pilot, 1000, 0, nb_rb_pusch, 0, pusch_pdu->dmrs_config_type); +#ifdef DEBUG_PUSCH + printf ("NR_UL_CHANNEL_EST: index %d, u %d,v %d\n", index, u, v); + LOG_M("gNb_DMRS_SEQ.m","gNb_DMRS_SEQ", dmrs_seq,6*nb_rb_pusch,1,1); +#endif } //------------------------------------------------// - #ifdef DEBUG_PUSCH + for (int i = 0; i < (6 * nb_rb_pusch); i++) { - LOG_I(PHY, "In %s: %d + j*(%d)\n", - __FUNCTION__, - ((int16_t*)pilot)[2 * i], - ((int16_t*)pilot)[1 + (2 * i)]); + LOG_I(PHY, "In %s: %d + j*(%d)\n", __FUNCTION__, pilot[i].r,pilot[i].i); } + #endif + const uint8_t b_shift = pusch_pdu->nrOfLayers == 1; + + for (int aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { + c16_t *rxdataF = (c16_t *)&gNB->common_vars.rxdataF[aarx][symbol_offset]; + c16_t *ul_ch = &ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; - uint8_t b_shift = pusch_pdu->nrOfLayers == 1; - - for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { - - pil = (int16_t *)&pilot[0]; - rxF = (int16_t *)&rxdataF[aarx][(soffset + symbol_offset + k0 + nushift)]; - ul_ch = (int16_t *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; - re_offset = k0; - - memset(ul_ch,0,4*(gNB->frame_parms.ofdm_symbol_size)); - + memset(ul_ch,0,sizeof(*ul_ch)*symbolSize); #ifdef DEBUG_PUSCH LOG_I(PHY, "In %s symbol_offset %d, nushift %d\n", __FUNCTION__, symbol_offset, nushift); - LOG_I(PHY, "In %s ch est pilot addr %p, N_RB_UL %d\n", __FUNCTION__, &pilot[0], gNB->frame_parms.N_RB_UL); + LOG_I(PHY, "In %s ch est pilot, N_RB_UL %d\n", __FUNCTION__, gNB->frame_parms.N_RB_UL); LOG_I(PHY, "In %s bwp_start_subcarrier %d, k0 %d, first_carrier %d, nb_rb_pusch %d\n", __FUNCTION__, bwp_start_subcarrier, k0, gNB->frame_parms.first_carrier_offset, nb_rb_pusch); - LOG_I(PHY, "In %s rxF addr %p p %d\n", __FUNCTION__, rxF, p); LOG_I(PHY, "In %s ul_ch addr %p nushift %d\n", __FUNCTION__, ul_ch, nushift); #endif - - if (pusch_pdu->dmrs_config_type == pusch_dmrs_type1 && chest_freq == 0){ + + if (pusch_pdu->dmrs_config_type == pusch_dmrs_type1 && chest_freq == 0) { + c16_t *pil = pilot; + int re_offset = k0; LOG_D(PHY,"PUSCH estimation DMRS type 1, Freq-domain interpolation"); - // For configuration type 1: k = 4*n + 2*k' + delta, // where k' is 0 or 1, and delta is in Table 6.4.1.1.3-1 from TS 38.211 - - pilot_cnt = 0; + int pilot_cnt = 0; int delta = nr_pusch_dmrs_delta(pusch_dmrs_type1, p); - + for (int n = 0; n < 3*nb_rb_pusch; n++) { - // LS estimation - ch[0] = 0; - ch[1] = 0; + c32_t ch = {0}; + for (int k_line = 0; k_line <= 1; k_line++) { - re_offset = (k0 + (n << 2) + (k_line << 1) + delta) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *) &rxdataF[aarx][(soffset + symbol_offset + re_offset)]; - ch[0] += (int16_t) (((int32_t) pil[0] * rxF[0] - (int32_t) pil[1] * rxF[1]) >> (15+b_shift)); - ch[1] += (int16_t) (((int32_t) pil[0] * rxF[1] + (int32_t) pil[1] * rxF[0]) >> (15+b_shift)); - pil += 2; + re_offset = (k0 + (n << 2) + (k_line << 1) + delta) % symbolSize; + ch=c32x16maddShift(*pil, + rxdataF[soffset + re_offset], + ch, + 15+b_shift); + pil++; } - + + c16_t ch16= {.r=(int16_t)ch.r, .i=(int16_t)ch.i}; + // Channel interpolation for (int k_line = 0; k_line <= 1; k_line++) { #ifdef DEBUG_PUSCH - re_offset = (k0 + (n << 2) + (k_line << 1)) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *) &rxdataF[aarx][(soffset + symbol_offset + re_offset)]; + re_offset = (k0 + (n << 2) + (k_line << 1)) % symbolSize; + c16_t *rxF = &rxdataF[soffset + re_offset]; printf("pilot %4u: pil -> (%6d,%6d), rxF -> (%4d,%4d), ch -> (%4d,%4d)\n", - pilot_cnt, pil[0], pil[1], rxF[0], rxF[1], ch[0], ch[1]); - //printf("data %4u: rxF -> (%4d,%4d) (%2d)\n",pilot_cnt, rxF[2], rxF[3], dBc(rxF[2], rxF[3])); + pilot_cnt, pil->r, pil->i, rxF->r, rxF->i, ch.r, ch.i); #endif + if (pilot_cnt == 0) { - multadd_real_vector_complex_scalar(fl, ch, ul_ch, 8); + c16multaddVectRealComplex(fl, &ch16, ul_ch, 8); } else if (pilot_cnt == 1) { - multadd_real_vector_complex_scalar(fml, ch, ul_ch, 8); + c16multaddVectRealComplex(fml, &ch16, ul_ch, 8); } else if (pilot_cnt == (6*nb_rb_pusch-2)) { - multadd_real_vector_complex_scalar(fmr, ch, ul_ch, 8); - ul_ch+=8; + c16multaddVectRealComplex(fmr, &ch16, ul_ch, 8); + ul_ch+=4; } else if (pilot_cnt == (6*nb_rb_pusch-1)) { - multadd_real_vector_complex_scalar(fr, ch, ul_ch, 8); + c16multaddVectRealComplex(fr, &ch16, ul_ch, 8); } else if (pilot_cnt%2 == 0) { - multadd_real_vector_complex_scalar(fmm, ch, ul_ch, 8); - ul_ch+=8; + c16multaddVectRealComplex(fmm, &ch16, ul_ch, 8); + ul_ch+=4; } else { - multadd_real_vector_complex_scalar(fm, ch, ul_ch, 8); + c16multaddVectRealComplex(fm, &ch16, ul_ch, 8); } + pilot_cnt++; } } // check if PRB crosses DC and improve estimates around DC - if ((bwp_start_subcarrier < gNB->frame_parms.ofdm_symbol_size) && (bwp_start_subcarrier+nb_rb_pusch*12 >= gNB->frame_parms.ofdm_symbol_size)) { - ul_ch = (int16_t *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; - uint16_t idxDC = 2*(gNB->frame_parms.ofdm_symbol_size - bwp_start_subcarrier); - uint16_t idxPil = idxDC/2; + if ((bwp_start_subcarrier < symbolSize) && (bwp_start_subcarrier+nb_rb_pusch*12 >= symbolSize)) { + ul_ch = &ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; + const uint16_t idxDC = symbolSize - bwp_start_subcarrier; re_offset = k0; - pil = (int16_t *)&pilot[0]; - pil += (idxPil-2); - ul_ch += (idxDC-4); - ul_ch = memset(ul_ch, 0, sizeof(int16_t)*10); - re_offset = (re_offset+idxDC/2-2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; - ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); + pil = pilot + idxDC / 2 - 1; + ul_ch += idxDC - 2 ; + ul_ch = memset(ul_ch, 0, sizeof(*ul_ch)*5); + re_offset = (re_offset + idxDC - 2) % symbolSize; + const c16_t ch=c16mulShift(*pil, + rxdataF[soffset+nushift+re_offset], + 15); - // for proper allignment of SIMD vectors + // for proper alignment of SIMD vectors if((gNB->frame_parms.N_RB_UL&1)==0) { - - multadd_real_vector_complex_scalar(fdcl, ch, ul_ch-4, 8); - - pil += 4; - re_offset = (re_offset+4) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - - multadd_real_vector_complex_scalar(fdcr, ch, ul_ch-4, 8); - + c16multaddVectRealComplex(fdcl, &ch, ul_ch-2, 8); + pil += 2; + re_offset = (re_offset+4) % symbolSize; + const c16_t ch_tmp=c16mulShift(*pil, + rxdataF[nushift+re_offset], + 15); + c16multaddVectRealComplex(fdcr, &ch_tmp, ul_ch-2, 8); } else { - - multadd_real_vector_complex_scalar(fdclh, ch, ul_ch, 8); - - pil += 4; - re_offset = (re_offset+4) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; - ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - - multadd_real_vector_complex_scalar(fdcrh, ch, ul_ch, 8); + c16multaddVectRealComplex(fdclh, &ch, ul_ch, 8); + pil += 2; + re_offset = (re_offset+4) % symbolSize; + const c16_t ch_tmp=c16mulShift(*pil, + rxdataF[soffset+nushift+re_offset], + 15); + c16multaddVectRealComplex(fdcrh, &ch_tmp, ul_ch, 8); } } #ifdef DEBUG_PUSCH - ul_ch = (int16_t *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; + ul_ch = &ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; + for(uint16_t idxP=0; idxPdmrs_config_type == pusch_dmrs_type2 && chest_freq == 0) { //pusch_dmrs_type2 |p_r,p_l,d,d,d,d,p_r,p_l,d,d,d,d| + +#endif + } else if (pusch_pdu->dmrs_config_type == pusch_dmrs_type2 && chest_freq == 0) { //pusch_dmrs_type2 |p_r,p_l,d,d,d,d,p_r,p_l,d,d,d,d| LOG_D(PHY,"PUSCH estimation DMRS type 2, Freq-domain interpolation"); + c16_t *pil = pilot; + int re_offset = k0; // Treat first DMRS specially (left edge) + *ul_ch=c16mulShift(*pil, + rxdataF[soffset+nushift+re_offset], + 15); + pil++; + ul_ch++; + re_offset = (re_offset + 1)%symbolSize; + ch_offset++; - rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; - - ul_ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ul_ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - - pil += 2; - ul_ch += 2; - re_offset = (re_offset + 1)%gNB->frame_parms.ofdm_symbol_size; + // TO verify: used after the loop, likely a piece of code is missing for ch_r + c16_t ch_r; + for (int re_cnt = 1; re_cnt < (nb_rb_pusch*NR_NB_SC_PER_RB) - 5; re_cnt += 6) { + c16_t ch_l=c16mulShift(*pil, + rxdataF[soffset+nushift+re_offset], + 15); + *ul_ch = ch_l; + pil++; + ul_ch++; ch_offset++; - - for (re_cnt = 1; re_cnt < (nb_rb_pusch*NR_NB_SC_PER_RB) - 5; re_cnt += 6){ - - rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; - - ch_l[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch_l[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - - ul_ch[0] = ch_l[0]; - ul_ch[1] = ch_l[1]; - - pil += 2; - ul_ch += 2; - ch_offset++; - - multadd_real_four_symbols_vector_complex_scalar(filt8_ml2, - ch_l, - ul_ch); - - re_offset = (re_offset+5)%gNB->frame_parms.ofdm_symbol_size; - - rxF = (int16_t *)&rxdataF[aarx][soffset+symbol_offset+nushift+re_offset]; - - ch_r[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch_r[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - - - multadd_real_four_symbols_vector_complex_scalar(filt8_mr2, - ch_r, - ul_ch); - - //for (int re_idx = 0; re_idx < 8; re_idx += 2) - //printf("ul_ch = %d + j*%d\n", ul_ch[re_idx], ul_ch[re_idx+1]); - - ul_ch += 8; - ch_offset += 4; - - ul_ch[0] = ch_r[0]; - ul_ch[1] = ch_r[1]; - - pil += 2; - ul_ch += 2; - ch_offset++; - re_offset = (re_offset + 1)%gNB->frame_parms.ofdm_symbol_size; - - } - - // Treat last pilot specially (right edge) - - rxF = (int16_t *)&rxdataF[aarx][soffset+(symbol_offset+nushift+re_offset)]; - - ch_l[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); - ch_l[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); - - ul_ch[0] = ch_l[0]; - ul_ch[1] = ch_l[1]; - - ul_ch += 2; + multadd_real_four_symbols_vector_complex_scalar(filt8_ml2, + &ch_l, + ul_ch); + re_offset = (re_offset+5)%symbolSize; + ch_r=c16mulShift(*pil, + rxdataF[soffset+nushift+re_offset], + 15); + multadd_real_four_symbols_vector_complex_scalar(filt8_mr2, + &ch_r, + ul_ch); + //for (int re_idx = 0; re_idx < 8; re_idx += 2) + //printf("ul_ch = %d + j*%d\n", ul_ch[re_idx], ul_ch[re_idx+1]); + ul_ch += 4; + ch_offset += 4; + *ul_ch = ch_r; + pil++; + ul_ch++; ch_offset++; + re_offset = (re_offset + 1)%symbolSize; + } + + // Treat last pilot specially (right edge) + c16_t ch_l=c16mulShift(*pil, + rxdataF[soffset+nushift+re_offset], + 15); + *ul_ch = ch_l; + ul_ch++; + ch_offset++; + multadd_real_four_symbols_vector_complex_scalar(filt8_rr1, + &ch_l, + ul_ch); + multadd_real_four_symbols_vector_complex_scalar(filt8_rr2, + &ch_r, + ul_ch); + __m128i *ul_ch_128 = (__m128i *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; + ul_ch_128[0] = _mm_slli_epi16 (ul_ch_128[0], 2); + } - multadd_real_four_symbols_vector_complex_scalar(filt8_rr1, - ch_l, - ul_ch); - - multadd_real_four_symbols_vector_complex_scalar(filt8_rr2, - ch_r, - ul_ch); - - ul_ch_128 = (__m128i *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; - - ul_ch_128[0] = _mm_slli_epi16 (ul_ch_128[0], 2); - } - - else if (pusch_pdu->dmrs_config_type == pusch_dmrs_type1) {// this is case without frequency-domain linear interpolation, just take average of LS channel estimates of 6 DMRS REs and use a common value for the whole PRB - LOG_D(PHY,"PUSCH estimation DMRS type 1, no Freq-domain interpolation"); - int32_t ch_0, ch_1; + else if (pusch_pdu->dmrs_config_type == pusch_dmrs_type1) { // this is case without frequency-domain linear interpolation, just take average of LS channel estimates of 6 DMRS REs and use a common value for the whole PRB + LOG_D(PHY,"PUSCH estimation DMRS type 1, no Freq-domain interpolation\n"); + c16_t *rxF = &rxdataF[soffset + nushift]; + int pil_offset = 0; + int re_offset = k0; + c16_t ch; + // First PRB - ch_0 = ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 = ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch[0] = ch_0 / 6; - ch[1] = ch_1 / 6; - - - + ch=c32x16cumulVectVectWithSteps(pilot, &pil_offset, 1, rxF, &re_offset, 2, symbolSize, 6); #if NO_INTERP - for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; - ul_ch+=24; + for (c16_t *end=ul_ch+12; ul_ch>15; - ch_1 = ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch[0] = ch_0 / 6; - ch[1] = ch_1 / 6; + for (int pilot_cnt=6; pilot_cnt<6*(nb_rb_pusch-1); pilot_cnt += 6) { + ch=c32x16cumulVectVectWithSteps(pilot, &pil_offset, 1, rxF, &re_offset, 2, symbolSize, 6); #if NO_INTERP - for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; - ul_ch+=24; + for (c16_t *end=ul_ch+12; ul_ch>15; // 1/12*16384 - ul_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 + ul_ch[3].r += (ch.r * 1365)>>15; // 1/12*16384 + ul_ch[3].i += (ch.i * 1365)>>15; // 1/12*16384 + + ul_ch += 4; + multadd_real_vector_complex_scalar(filt8_avlip3, ch, ul_ch, 8); ul_ch += 8; - multadd_real_vector_complex_scalar(filt8_avlip3, - ch, - ul_ch, - 8); + multadd_real_vector_complex_scalar(filt8_avlip4, ch, ul_ch, 8); - ul_ch += 16; - multadd_real_vector_complex_scalar(filt8_avlip4, - ch, - ul_ch, - 8); - - ul_ch += 16; - multadd_real_vector_complex_scalar(filt8_avlip5, - ch, - ul_ch, - 8); - ul_ch -= 16; + ul_ch += 8; + multadd_real_vector_complex_scalar(filt8_avlip5, ch, ul_ch, 8); + ul_ch -= 8; #endif } // Last PRB - ch_0 = ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 = ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch[0] = ch_0 / 6; - ch[1] = ch_1 / 6; - + ch=c32x16cumulVectVectWithSteps(pilot, &pil_offset, 1, rxF, &re_offset, 2, symbolSize, 6); + #if NO_INTERP - for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; - ul_ch+=24; + for (c16_t *end=ul_ch+12; ul_ch>15; // 1/12*16384 - ul_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 - - ul_ch += 8; - multadd_real_vector_complex_scalar(filt8_avlip3, + ul_ch[3].r += (ch.r * 1365)>>15; // 1/12*16384 + ul_ch[3].i += (ch.i * 1365)>>15; // 1/12*16384 + + ul_ch += 4; + c16multaddVectRealComplex(filt8_avlip3, ch, ul_ch, 8); - - ul_ch += 16; - multadd_real_vector_complex_scalar(filt8_avlip6, + + ul_ch += 8; + c16multaddVectRealComplex(filt8_avlip6, ch, ul_ch, 8); #endif - } - else { // this is case without frequency-domain linear interpolation, just take average of LS channel estimates of 4 DMRS REs and use a common value for the whole PRB + } else { // this is case without frequency-domain linear interpolation, just take average of LS channel estimates of 4 DMRS REs and use a common value for the whole PRB LOG_D(PHY,"PUSCH estimation DMRS type 2, no Freq-domain interpolation"); - int32_t ch_0, ch_1; + c16_t *pil = pilot; + int re_offset = k0; + c32_t ch0={0}; //First PRB - ch_0 = ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 = ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+1) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+5) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+1) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+5) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch[0] = ch_0 / 4; - ch[1] = ch_1 / 4; + ch0=c32x16mulShift(*pil, + rxdataF[soffset + nushift + re_offset], + 15); + pil++; + re_offset = (re_offset+1) % symbolSize; + ch0=c32x16maddShift(*pil, + rxdataF[nushift+re_offset], + ch0, + 15); + pil++; + re_offset = (re_offset+5) % symbolSize; + ch0=c32x16maddShift(*pil, + rxdataF[nushift+re_offset], + ch0, + 15); + re_offset = (re_offset+1) % symbolSize; + ch0=c32x16maddShift(*pil, + rxdataF[nushift+re_offset], + ch0, + 15); + pil++; + re_offset = (re_offset+5) % symbolSize; + c16_t ch=c16x32div(ch0, 4); #if NO_INTERP - for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; - ul_ch+=24; + for (c16_t *end=ul_ch+12; ul_ch>15; - ch_1 = ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; + ch0=c32x16maddShift(*pil, rxdataF[nushift+re_offset], ch0, 15); + pil++; + re_offset = (re_offset+5) % symbolSize; - pil += 2; - re_offset = (re_offset+1) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + ch0=c32x16maddShift(*pil, rxdataF[nushift+re_offset], ch0, 15); + pil++; + re_offset = (re_offset+1) % symbolSize; - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; + ch0=c32x16maddShift(*pil, rxdataF[nushift+re_offset], ch0, 15); + pil++; + re_offset = (re_offset+5) % symbolSize; - pil += 2; - re_offset = (re_offset+5) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+1) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+5) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch[0] = ch_0 / 4; - ch[1] = ch_1 / 4; + ch=c16x32div(ch0, 4); #if NO_INTERP - for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; - ul_ch+=24; + for (c16_t *end=ul_ch+12; ul_ch>15; // 1/12*16384 - ul_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 - + ul_ch[3]=c16maddShift(ch,(c16_t) {1365,1365},15); // 1365 = 1/12*16384 (full range is +/- 32768) + ul_ch += 4; + c16multaddVectRealComplex(filt8_avlip3, &ch, ul_ch, 8); ul_ch += 8; - multadd_real_vector_complex_scalar(filt8_avlip3, - ch, - ul_ch, - 8); - - ul_ch += 16; - multadd_real_vector_complex_scalar(filt8_avlip4, - ch, - ul_ch, - 8); - - ul_ch += 16; - multadd_real_vector_complex_scalar(filt8_avlip5, - ch, - ul_ch, - 8); - ul_ch -= 16; + c16multaddVectRealComplex(filt8_avlip4, &ch, ul_ch, 8); + ul_ch += 8; + c16multaddVectRealComplex(filt8_avlip5, &ch, ul_ch, 8); + ul_ch -= 8; #endif } + // Last PRB - ch_0 = ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 = ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+1) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+5) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+1) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch_0 += ((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15; - ch_1 += ((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15; - - pil += 2; - re_offset = (re_offset+5) % gNB->frame_parms.ofdm_symbol_size; - rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; - - ch[0] = ch_0 / 4; - ch[1] = ch_1 / 4; - + ch0=c32x16mulShift(*pil, rxdataF[nushift+re_offset], 15); + pil++; + re_offset = (re_offset+1) % symbolSize; + + ch0=c32x16maddShift(*pil, rxdataF[nushift+re_offset], ch0, 15); + pil++; + re_offset = (re_offset+5) % symbolSize; + + ch0=c32x16maddShift(*pil, rxdataF[nushift+re_offset], ch0, 15); + pil++; + re_offset = (re_offset+1) % symbolSize; + + ch0=c32x16maddShift(*pil, rxdataF[nushift+re_offset], ch0, 15); + pil++; + re_offset = (re_offset+5) % symbolSize; + + ch=c16x32div(ch0, 4); #if NO_INTERP - for (int i=0;i<12;i++) ((int32_t*)ul_ch)[i] = *(int32_t*)ch; - ul_ch+=24; + for (c16_t *end=ul_ch+12; ul_ch>15; // 1/12*16384 - ul_ch[7] += (ch[1] * 1365)>>15; // 1/12*16384 - + ul_ch[3]=c16maddShift(ch, c16_t {1365,1365},15);// 1365 = 1/12*16384 (full range is +/- 32768) + ul_ch += 4; + c16multaddVectRealComplex(filt8_avlip3, &ch, ul_ch, 8); ul_ch += 8; - multadd_real_vector_complex_scalar(filt8_avlip3, - ch, - ul_ch, - 8); - - ul_ch += 16; - multadd_real_vector_complex_scalar(filt8_avlip6, - ch, - ul_ch, - 8); + c16multaddVectRealComplex(filt8_avlip6, &ch, ul_ch, 8); #endif } + #ifdef DEBUG_PUSCH - ul_ch = (int16_t *)&ul_ch_estimates[p*gNB->frame_parms.nb_antennas_rx+aarx][ch_offset]; - for(uint16_t idxP=0; idxPframe_parms.nb_antennas_rx+aarx][ch_offset]; + + for(int idxP=0; idxPframe_parms.ofdm_symbol_size, - (int16_t*) &ul_ch_estimates[aarx][symbol_offset], - (int16_t*) ul_ch_estimates_time[aarx]); + freq2time(symbolSize, + (int16_t *) &ul_ch_estimates[aarx][symbol_offset], + (int16_t *) gNB->pusch_vars[ul_id]->ul_ch_estimates_time[aarx]); } #ifdef DEBUG_CH fclose(debug_ch_est); #endif - return(0); } @@ -851,12 +607,10 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, uint8_t ulsch_id, uint8_t nr_tti_rx, unsigned char symbol, - uint32_t nb_re_pusch) -{ + uint32_t nb_re_pusch) { //#define DEBUG_UL_PTRS 1 int32_t *ptrs_re_symbol = NULL; int8_t ret = 0; - uint8_t symbInSlot = rel15_ul->start_symbol_index + rel15_ul->nr_of_symbols; uint8_t *startSymbIndex = &rel15_ul->start_symbol_index; uint8_t *nbSymb = &rel15_ul->nr_of_symbols; @@ -868,6 +622,7 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, uint8_t *dmrsConfigType = &rel15_ul->dmrs_config_type; uint16_t *nb_rb = &rel15_ul->rb_size; uint8_t *ptrsReOffset = &rel15_ul->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset; + /* loop over antennas */ for (int aarx=0; aarxnb_antennas_rx; aarx++) { c16_t *phase_per_symbol = (c16_t*)gNB->pusch_vars[ulsch_id]->ptrs_phase_per_slot[aarx]; @@ -894,8 +649,10 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, 1<< *L_ptrs, *dmrsSymbPos); } + /* if not PTRS symbol set current ptrs symbol index to zero*/ *ptrsSymbIdx = 0; + /* Check if current symbol contains PTRS */ if(is_ptrs_symbol(symbol, *ptrsSymbPos)) { *ptrsSymbIdx = symbol; @@ -906,11 +663,12 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, rel15_ul->rnti, nr_tti_rx, symbol,frame_parms->ofdm_symbol_size, - (int16_t*)&gNB->pusch_vars[ulsch_id]->rxdataF_comp[aarx][(symbol * nb_re_pusch)], + (int16_t *)&gNB->pusch_vars[ulsch_id]->rxdataF_comp[aarx][(symbol * nb_re_pusch)], gNB->nr_gold_pusch_dmrs[rel15_ul->scid][nr_tti_rx][symbol], (int16_t*)&phase_per_symbol[symbol], ptrs_re_symbol); } + /* For last OFDM symbol at each antenna perform interpolation and compensation for the slot*/ if(symbol == (symbInSlot -1)) { /*------------------------------------------------------------------------------------------------------- */ @@ -923,16 +681,18 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, LOG_W(PHY,"[PTRS] Compensation is skipped due to error in PTRS slot processing !!\n"); } } + #ifdef DEBUG_UL_PTRS LOG_M("ptrsEstUl.m","est",gNB->pusch_vars[ulsch_id]->ptrs_phase_per_slot[aarx],frame_parms->symbols_per_slot,1,1 ); LOG_M("rxdataF_bf_ptrs_comp_ul.m","bf_ptrs_cmp", &gNB->pusch_vars[0]->rxdataF_comp[aarx][rel15_ul->start_symbol_index * NR_NB_SC_PER_RB * rel15_ul->rb_size], rel15_ul->nr_of_symbols * NR_NB_SC_PER_RB * rel15_ul->rb_size,1,1); #endif + /*------------------------------------------------------------------------------------------------------- */ /* 3) Compensated DMRS based estimated signal with PTRS estimation */ /*--------------------------------------------------------------------------------------------------------*/ - for(uint8_t i = *startSymbIndex; i< symbInSlot ;i++) { + for(uint8_t i = *startSymbIndex; i< symbInSlot ; i++) { /* DMRS Symbol has 0 phase so no need to rotate the respective symbol */ /* Skip rotation if the slot processing is wrong */ if((!is_dmrs_symbol(i,*dmrsSymbPos)) && (ret == 0)) { @@ -956,6 +716,7 @@ uint32_t calc_power(const int16_t *x, const uint32_t size) { sum_x = sum_x + x[k]; sum_x2 = sum_x2 + x[k]*x[k]; } + return sum_x2/size - (sum_x/size)*(sum_x/size); } @@ -964,153 +725,238 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, const int slot, const nfapi_nr_srs_pdu_t *srs_pdu, const nr_srs_info_t *nr_srs_info, - const int32_t *srs_generated_signal, + const int32_t **srs_generated_signal, int32_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)], - int32_t srs_ls_estimated_channel[][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)], - int32_t srs_estimated_channel_freq[][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)], - int32_t srs_estimated_channel_time[][gNB->frame_parms.ofdm_symbol_size], - int32_t srs_estimated_channel_time_shifted[][gNB->frame_parms.ofdm_symbol_size], + int32_t srs_ls_estimated_channel[][1<num_ant_ports][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)], + int32_t srs_estimated_channel_freq[][1<num_ant_ports][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)], + int32_t srs_estimated_channel_time[][1<num_ant_ports][gNB->frame_parms.ofdm_symbol_size], + int32_t srs_estimated_channel_time_shifted[][1<num_ant_ports][gNB->frame_parms.ofdm_symbol_size], uint32_t *signal_power, uint32_t *noise_power_per_rb, uint32_t *noise_power, int8_t *snr_per_rb, int8_t *snr) { - if(nr_srs_info->sc_list_length == 0) { - LOG_E(NR_PHY, "(%d.%d) nr_srs_info was not generated yet!\n", frame, slot); - return -1; - } +#ifdef SRS_DEBUG + LOG_I(NR_PHY,"Calling %s function\n", __FUNCTION__); +#endif const NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; + const uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*NR_NB_SC_PER_RB; - int16_t ch_real[frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length]; - int16_t ch_imag[frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length]; - int16_t noise_real[frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length]; - int16_t noise_imag[frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length]; + const uint8_t N_ap = 1<num_ant_ports; + const uint8_t K_TC = 2<comb_size; + const uint16_t m_SRS_b = srs_bandwidth_config[srs_pdu->config_index][srs_pdu->bandwidth_index][0]; + const uint16_t M_sc_b_SRS = m_SRS_b * NR_NB_SC_PER_RB/K_TC; + uint8_t fd_cdm = N_ap; + if (N_ap == 4 && ((K_TC == 2 && srs_pdu->cyclic_shift >= 4) || (K_TC == 4 && srs_pdu->cyclic_shift >= 6))) { + fd_cdm = 2; + } + + int16_t ch_real[frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS]; + int16_t ch_imag[frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS]; + int16_t noise_real[frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS]; + int16_t noise_imag[frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS]; int16_t ls_estimated[2]; - uint8_t mem_offset = 0; - while(((long)&srs_estimated_channel_freq[0][nr_srs_info->sc_list[0] + mem_offset] & 0xF) != 0) { - mem_offset++; - } - int32_t srs_est[frame_parms->ofdm_symbol_size*(1<num_symbols) + mem_offset] __attribute__ ((aligned(32))); + uint8_t mem_offset = ((16 - ((long)&srs_estimated_channel_freq[0][0][subcarrier_offset + nr_srs_info->k_0_p[0][0]])) & 0xF) >> 2; // >> 2 <=> /sizeof(int32_t) + + // filt16_end is {4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0} + // The End of OFDM symbol corresponds to the position of last 16384 in the filter + // The multadd_real_vector_complex_scalar applies the remaining 8 zeros of filter, therefore, to avoid a buffer overflow, + // we added 8 in the array size + int32_t srs_est[frame_parms->ofdm_symbol_size*(1<num_symbols) + mem_offset + 8] __attribute__ ((aligned(32))); for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { - memset(srs_ls_estimated_channel[ant], 0, frame_parms->ofdm_symbol_size*(1<num_symbols)*sizeof(int32_t)); - memset(srs_est, 0, (frame_parms->ofdm_symbol_size*(1<num_symbols) + mem_offset)*sizeof(int32_t)); + for (int p_index = 0; p_index < N_ap; p_index++) { - int16_t *srs_estimated_channel16 = (int16_t *)&srs_est[nr_srs_info->sc_list[0] + mem_offset]; + memset(srs_ls_estimated_channel[ant][p_index], 0, frame_parms->ofdm_symbol_size*(1<num_symbols)*sizeof(int32_t)); + memset(srs_est, 0, (frame_parms->ofdm_symbol_size*(1<num_symbols) + mem_offset)*sizeof(int32_t)); - for(int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) { +#ifdef SRS_DEBUG + LOG_I(NR_PHY,"====================== UE port %d --> gNB Rx antenna %i ======================\n", p_index, ant); +#endif - int16_t generated_real = ((c16_t*)srs_generated_signal)[nr_srs_info->sc_list[sc_idx]].r; - int16_t generated_imag = ((c16_t*)srs_generated_signal)[nr_srs_info->sc_list[sc_idx]].i; + uint16_t subcarrier = subcarrier_offset + nr_srs_info->k_0_p[p_index][0]; + if (subcarrier>frame_parms->ofdm_symbol_size) { + subcarrier -= frame_parms->ofdm_symbol_size; + } - int16_t received_real = ((c16_t*)srs_received_signal[ant])[nr_srs_info->sc_list[sc_idx]].r; - int16_t received_imag = ((c16_t*)srs_received_signal[ant])[nr_srs_info->sc_list[sc_idx]].i; + int16_t *srs_estimated_channel16 = (int16_t *)&srs_est[subcarrier + mem_offset]; - // We know that nr_srs_info->srs_generated_signal_bits bits are enough to represent the generated_real and generated_imag. - // So we only need a nr_srs_info->srs_generated_signal_bits shift to ensure that the result fits into 16 bits. - ls_estimated[0] = (int16_t)(((int32_t)generated_real*received_real + (int32_t)generated_imag*received_imag)>>nr_srs_info->srs_generated_signal_bits); - ls_estimated[1] = (int16_t)(((int32_t)generated_real*received_imag - (int32_t)generated_imag*received_real)>>nr_srs_info->srs_generated_signal_bits); - srs_ls_estimated_channel[ant][nr_srs_info->sc_list[sc_idx]] = ls_estimated[0] + (((int32_t)ls_estimated[1] << 16) & 0xFFFF0000); + for (int k = 0; k < M_sc_b_SRS; k++) { - const uint16_t sc_idx_offset = nr_srs_info->sc_list[sc_idx] + mem_offset; + if (k%fd_cdm==0) { - // Channel interpolation - if(srs_pdu->comb_size == 0) { - if(sc_idx == 0) { // First subcarrier case - // filt8_start is {12288,8192,4096,0,0,0,0,0} - multadd_real_vector_complex_scalar(filt8_start, ls_estimated, srs_estimated_channel16, 8); - } else if(nr_srs_info->sc_list[sc_idx] < nr_srs_info->sc_list[sc_idx - 1]) { // Start of OFDM symbol case - // filt8_start is {12288,8192,4096,0,0,0,0,0} - srs_estimated_channel16 = (int16_t *)&srs_est[nr_srs_info->sc_list[sc_idx]]; - short *filter = mem_offset==0 ? filt8_start:filt8_start_shift2; - multadd_real_vector_complex_scalar(filter, ls_estimated, srs_estimated_channel16, 8); - } else if((sc_idx < (nr_srs_info->sc_list_length - 1) && nr_srs_info->sc_list[sc_idx + 1] < nr_srs_info->sc_list[sc_idx]) - || (sc_idx == (nr_srs_info->sc_list_length - 1))) { // End of OFDM symbol or last subcarrier cases - // filt8_end is {4096,8192,12288,16384,0,0,0,0} - short *filter = mem_offset==0 || sc_idx == (nr_srs_info->sc_list_length - 1) ? filt8_end:filt8_end_shift2; - multadd_real_vector_complex_scalar(filter, ls_estimated, srs_estimated_channel16, 8); - } else if(sc_idx%2 == 1) { // 1st middle case - // filt8_middle2 is {4096,8192,8192,8192,4096,0,0,0} - multadd_real_vector_complex_scalar(filt8_middle2, ls_estimated, srs_estimated_channel16, 8); - } else if(sc_idx%2 == 0) { // 2nd middle case - // filt8_middle4 is {0,0,4096,8192,8192,8192,4096,0} - multadd_real_vector_complex_scalar(filt8_middle4, ls_estimated, srs_estimated_channel16, 8); - srs_estimated_channel16 = (int16_t *)&srs_est[sc_idx_offset]; + ls_estimated[0] = 0; + ls_estimated[1] = 0; + uint16_t subcarrier_cdm = subcarrier; + + for (int cdm_idx = 0; cdm_idx < fd_cdm; cdm_idx++) { + + int16_t generated_real = ((c16_t*)srs_generated_signal[p_index])[subcarrier_cdm].r; + int16_t generated_imag = ((c16_t*)srs_generated_signal[p_index])[subcarrier_cdm].i; + + int16_t received_real = ((c16_t*)srs_received_signal[ant])[subcarrier_cdm].r; + int16_t received_imag = ((c16_t*)srs_received_signal[ant])[subcarrier_cdm].i; + + // We know that nr_srs_info->srs_generated_signal_bits bits are enough to represent the generated_real and generated_imag. + // So we only need a nr_srs_info->srs_generated_signal_bits shift to ensure that the result fits into 16 bits. + ls_estimated[0] += (int16_t)(((int32_t)generated_real*received_real + (int32_t)generated_imag*received_imag)>>nr_srs_info->srs_generated_signal_bits); + ls_estimated[1] += (int16_t)(((int32_t)generated_real*received_imag - (int32_t)generated_imag*received_real)>>nr_srs_info->srs_generated_signal_bits); + + // Subcarrier increment + subcarrier_cdm += K_TC; + if (subcarrier_cdm >= frame_parms->ofdm_symbol_size) { + subcarrier_cdm=subcarrier_cdm-frame_parms->ofdm_symbol_size; + } + } } - } else { - if(sc_idx == 0) { // First subcarrier case - // filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0} - multadd_real_vector_complex_scalar(filt16_start, ls_estimated, srs_estimated_channel16, 16); - } else if(nr_srs_info->sc_list[sc_idx] < nr_srs_info->sc_list[sc_idx - 1]) { // Start of OFDM symbol case - srs_estimated_channel16 = (int16_t *)&srs_est[sc_idx_offset]; - // filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0} - multadd_real_vector_complex_scalar(filt16_start, ls_estimated, srs_estimated_channel16, 16); - } else if((sc_idx < (nr_srs_info->sc_list_length - 1) && nr_srs_info->sc_list[sc_idx + 1] < nr_srs_info->sc_list[sc_idx]) - || (sc_idx == (nr_srs_info->sc_list_length - 1))) { // End of OFDM symbol or last subcarrier cases - // filt16_end is {4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0} - multadd_real_vector_complex_scalar(filt16_end, ls_estimated, srs_estimated_channel16, 16); - } else { // Middle case - // filt16_middle4 is {4096,8192,8192,8192,8192,8192,8192,8192,4096,0,0,0,0,0,0,0} - multadd_real_vector_complex_scalar(filt16_middle4, ls_estimated, srs_estimated_channel16, 16); - srs_estimated_channel16 = (int16_t *)&srs_est[sc_idx_offset]; + + srs_ls_estimated_channel[ant][p_index][subcarrier] = ls_estimated[0] + (((int32_t)ls_estimated[1] << 16) & 0xFFFF0000); + +#ifdef SRS_DEBUG + int subcarrier_log = subcarrier-subcarrier_offset; + if(subcarrier_log < 0) { + subcarrier_log = subcarrier_log + frame_parms->ofdm_symbol_size; + } + if(subcarrier_log%12 == 0) { + LOG_I(NR_PHY,"------------------------------------ %d ------------------------------------\n", subcarrier_log/12); + LOG_I(NR_PHY,"\t __genRe________genIm__|____rxRe_________rxIm__|____lsRe________lsIm_\n"); + } + LOG_I(NR_PHY,"(%4i) %6i\t%6i | %6i\t%6i | %6i\t%6i\n", + subcarrier_log, + (int16_t)(srs_generated_signal[p_index][subcarrier] & 0xFFFF), (int16_t)((srs_generated_signal[p_index][subcarrier] >> 16) & 0xFFFF), + (int16_t)(srs_received_signal[ant][subcarrier] & 0xFFFF), (int16_t)((srs_received_signal[ant][subcarrier] >> 16) & 0xFFFF), + ls_estimated[0], ls_estimated[1]); +#endif + + const uint16_t sc_offset = subcarrier + mem_offset; + + // Channel interpolation + if(srs_pdu->comb_size == 0) { + if(k == 0) { // First subcarrier case + // filt8_start is {12288,8192,4096,0,0,0,0,0} + multadd_real_vector_complex_scalar(filt8_start, ls_estimated, srs_estimated_channel16, 8); + } else if(subcarrier < K_TC) { // Start of OFDM symbol case + // filt8_start is {12288,8192,4096,0,0,0,0,0} + srs_estimated_channel16 = (int16_t *)&srs_est[subcarrier]; + short *filter = mem_offset==0 ? filt8_start:filt8_start_shift2; + multadd_real_vector_complex_scalar(filter, ls_estimated, srs_estimated_channel16, 8); + } else if((subcarrier+K_TC)>=frame_parms->ofdm_symbol_size || k == (M_sc_b_SRS-1)) { // End of OFDM symbol or last subcarrier cases + // filt8_end is {4096,8192,12288,16384,0,0,0,0} + short *filter = mem_offset==0 || k == (M_sc_b_SRS-1) ? filt8_end:filt8_end_shift2; + multadd_real_vector_complex_scalar(filter, ls_estimated, srs_estimated_channel16, 8); + } else if(k%2 == 1) { // 1st middle case + // filt8_middle2 is {4096,8192,8192,8192,4096,0,0,0} + multadd_real_vector_complex_scalar(filt8_middle2, ls_estimated, srs_estimated_channel16, 8); + } else if(k%2 == 0) { // 2nd middle case + // filt8_middle4 is {0,0,4096,8192,8192,8192,4096,0} + multadd_real_vector_complex_scalar(filt8_middle4, ls_estimated, srs_estimated_channel16, 8); + srs_estimated_channel16 = (int16_t *)&srs_est[sc_offset]; + } + } else { + if(k == 0) { // First subcarrier case + // filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0} + multadd_real_vector_complex_scalar(filt16_start, ls_estimated, srs_estimated_channel16, 16); + } else if(subcarrier < K_TC) { // Start of OFDM symbol case + srs_estimated_channel16 = (int16_t *)&srs_est[sc_offset]; + // filt16_start is {12288,8192,8192,8192,4096,0,0,0,0,0,0,0,0,0,0,0} + multadd_real_vector_complex_scalar(filt16_start, ls_estimated, srs_estimated_channel16, 16); + } else if((subcarrier+K_TC)>=frame_parms->ofdm_symbol_size || k == (M_sc_b_SRS-1)) { // End of OFDM symbol or last subcarrier cases + // filt16_end is {4096,8192,8192,8192,12288,16384,16384,16384,0,0,0,0,0,0,0,0} + multadd_real_vector_complex_scalar(filt16_end, ls_estimated, srs_estimated_channel16, 16); + } else { // Middle case + // filt16_middle4 is {4096,8192,8192,8192,8192,8192,8192,8192,4096,0,0,0,0,0,0,0} + multadd_real_vector_complex_scalar(filt16_middle4, ls_estimated, srs_estimated_channel16, 16); + srs_estimated_channel16 = (int16_t *)&srs_est[sc_offset]; + } + } + + // Subcarrier increment + subcarrier += K_TC; + if (subcarrier >= frame_parms->ofdm_symbol_size) { + subcarrier=subcarrier-frame_parms->ofdm_symbol_size; + } + + } // for (int k = 0; k < M_sc_b_SRS; k++) + + memcpy(&srs_estimated_channel_freq[ant][p_index][0], + &srs_est[mem_offset], + (frame_parms->ofdm_symbol_size*(1<num_symbols))*sizeof(int32_t)); + + // Compute noise + subcarrier = subcarrier_offset + nr_srs_info->k_0_p[p_index][0]; + if (subcarrier>frame_parms->ofdm_symbol_size) { + subcarrier -= frame_parms->ofdm_symbol_size; + } + uint16_t base_idx = ant*N_ap*M_sc_b_SRS + p_index*M_sc_b_SRS; + for (int k = 0; k < M_sc_b_SRS; k++) { + ch_real[base_idx+k] = ((c16_t*)srs_estimated_channel_freq[ant][p_index])[subcarrier].r; + ch_imag[base_idx+k] = ((c16_t*)srs_estimated_channel_freq[ant][p_index])[subcarrier].i; + noise_real[base_idx+k] = abs(((c16_t*)srs_ls_estimated_channel[ant][p_index])[subcarrier].r - ch_real[base_idx+k]); + noise_imag[base_idx+k] = abs(((c16_t*)srs_ls_estimated_channel[ant][p_index])[subcarrier].i - ch_imag[base_idx+k]); + subcarrier += K_TC; + if (subcarrier >= frame_parms->ofdm_symbol_size) { + subcarrier=subcarrier-frame_parms->ofdm_symbol_size; } } #ifdef SRS_DEBUG - uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*12; - int subcarrier_log = nr_srs_info->sc_list[sc_idx]-subcarrier_offset; - if(subcarrier_log < 0) { - subcarrier_log = subcarrier_log + frame_parms->ofdm_symbol_size; + subcarrier = subcarrier_offset + nr_srs_info->k_0_p[p_index][0]; + if (subcarrier>frame_parms->ofdm_symbol_size) { + subcarrier -= frame_parms->ofdm_symbol_size; } - if(sc_idx == 0) { - LOG_I(NR_PHY,"______________________________ Rx antenna %i _______________________________\n", ant); + + for (int k = 0; k < K_TC*M_sc_b_SRS; k++) { + + int subcarrier_log = subcarrier-subcarrier_offset; + if(subcarrier_log < 0) { + subcarrier_log = subcarrier_log + frame_parms->ofdm_symbol_size; + } + + if(subcarrier_log%12 == 0) { + LOG_I(NR_PHY,"------------------------------------- %d -------------------------------------\n", subcarrier_log/12); + LOG_I(NR_PHY,"\t __lsRe__________lsIm__|____intRe_______intIm__|____noiRe_______noiIm__\n"); + } + + LOG_I(NR_PHY,"(%4i) %6i\t%6i | %6i\t%6i | %6i\t%6i\n", + subcarrier_log, + (int16_t)(srs_ls_estimated_channel[ant][p_index][subcarrier]&0xFFFF), + (int16_t)((srs_ls_estimated_channel[ant][p_index][subcarrier]>>16)&0xFFFF), + (int16_t)(srs_estimated_channel_freq[ant][p_index][subcarrier]&0xFFFF), + (int16_t)((srs_estimated_channel_freq[ant][p_index][subcarrier]>>16)&0xFFFF), + noise_real[base_idx+(k/K_TC)], noise_imag[base_idx+(k/K_TC)]); + + // Subcarrier increment + subcarrier++; + if (subcarrier >= frame_parms->ofdm_symbol_size) { + subcarrier=subcarrier-frame_parms->ofdm_symbol_size; + } } - if(subcarrier_log%12 == 0) { - LOG_I(NR_PHY,":::::::::::::::::::::::::::::::::::: %i ::::::::::::::::::::::::::::::::::::\n", subcarrier_log/12); - LOG_I(NR_PHY,"\t __genRe________genIm__|____rxRe_________rxIm__|____lsRe________lsIm_\n"); - } - LOG_I(NR_PHY,"(%4i) %6i\t%6i | %6i\t%6i | %6i\t%6i\n", - subcarrier_log, - generated_real, generated_imag, - received_real, received_imag, - ls_estimated[0], ls_estimated[1]); #endif - } - memcpy(&srs_estimated_channel_freq[ant][0], - &srs_est[mem_offset], - (frame_parms->ofdm_symbol_size*(1<num_symbols))*sizeof(int32_t)); + // Convert to time domain + freq2time(gNB->frame_parms.ofdm_symbol_size, + (int16_t*) srs_estimated_channel_freq[ant][p_index], + (int16_t*) srs_estimated_channel_time[ant][p_index]); - // Compute noise - for(int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) { - ch_real[ant*nr_srs_info->sc_list_length + sc_idx] = ((c16_t*)srs_estimated_channel_freq[ant])[nr_srs_info->sc_list[sc_idx]].r; - ch_imag[ant*nr_srs_info->sc_list_length + sc_idx] = ((c16_t*)srs_estimated_channel_freq[ant])[nr_srs_info->sc_list[sc_idx]].i; - noise_real[ant*nr_srs_info->sc_list_length + sc_idx] = abs(((c16_t*)srs_ls_estimated_channel[ant])[nr_srs_info->sc_list[sc_idx]].r - ch_real[ant*nr_srs_info->sc_list_length + sc_idx]); - noise_imag[ant*nr_srs_info->sc_list_length + sc_idx] = abs(((c16_t*)srs_ls_estimated_channel[ant])[nr_srs_info->sc_list[sc_idx]].i - ch_imag[ant*nr_srs_info->sc_list_length + sc_idx]); - } + memcpy(&srs_estimated_channel_time_shifted[ant][p_index][0], + &srs_estimated_channel_time[ant][p_index][gNB->frame_parms.ofdm_symbol_size>>1], + (gNB->frame_parms.ofdm_symbol_size>>1)*sizeof(int32_t)); - // Convert to time domain - freq2time(gNB->frame_parms.ofdm_symbol_size, - (int16_t*) srs_estimated_channel_freq[ant], - (int16_t*) srs_estimated_channel_time[ant]); + memcpy(&srs_estimated_channel_time_shifted[ant][p_index][gNB->frame_parms.ofdm_symbol_size>>1], + &srs_estimated_channel_time[ant][p_index][0], + (gNB->frame_parms.ofdm_symbol_size>>1)*sizeof(int32_t)); - memcpy(&srs_estimated_channel_time_shifted[ant][0], - &srs_estimated_channel_time[ant][gNB->frame_parms.ofdm_symbol_size>>1], - (gNB->frame_parms.ofdm_symbol_size>>1)*sizeof(int32_t)); - - memcpy(&srs_estimated_channel_time_shifted[ant][gNB->frame_parms.ofdm_symbol_size>>1], - &srs_estimated_channel_time[ant][0], - (gNB->frame_parms.ofdm_symbol_size>>1)*sizeof(int32_t)); - } + } // for (int p_index = 0; p_index < N_ap; p_index++) + } // for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) // Compute signal power - *signal_power = calc_power(ch_real,frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length) - + calc_power(ch_imag,frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length); + *signal_power = calc_power(ch_real,frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS) + + calc_power(ch_imag,frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS); #ifdef SRS_DEBUG LOG_I(NR_PHY,"signal_power = %u\n", *signal_power); @@ -1127,84 +973,48 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, const uint8_t factor_bits = signal_power_bits < 32 ? 32 - signal_power_bits : 0; // 32 due to input of dB_fixed(uint32_t x) const int32_t factor_dB = dB_fixed(1<first_carrier_offset + srs_pdu->bwp_start*12; const uint8_t srs_symbols_per_rb = srs_pdu->comb_size == 0 ? 6 : 3; - const uint8_t n_noise_est = frame_parms->nb_antennas_rx * srs_symbols_per_rb; - uint8_t count_estimates = 0; + const uint8_t n_noise_est = frame_parms->nb_antennas_rx*N_ap*srs_symbols_per_rb; uint64_t sum_re = 0; uint64_t sum_re2 = 0; uint64_t sum_im = 0; uint64_t sum_im2 = 0; - for (int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) { + for (int rb = 0; rb < m_SRS_b; rb++) { - int subcarrier0 = nr_srs_info->sc_list[sc_idx]-subcarrier_offset; - if(subcarrier0 < 0) { - subcarrier0 = subcarrier0 + frame_parms->ofdm_symbol_size; - } - int rb = subcarrier0/NR_NB_SC_PER_RB; + sum_re = 0; + sum_re2 = 0; + sum_im = 0; + sum_im2 = 0; for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { + for (int p_index = 0; p_index < N_ap; p_index++) { + uint16_t base_idx = ant*N_ap*M_sc_b_SRS + p_index*M_sc_b_SRS + rb*srs_symbols_per_rb; + for (int srs_symb = 0; srs_symb < srs_symbols_per_rb; srs_symb++) { + sum_re = sum_re + noise_real[base_idx+srs_symb]; + sum_re2 = sum_re2 + noise_real[base_idx+srs_symb]*noise_real[base_idx+srs_symb]; + sum_im = sum_im + noise_imag[base_idx+srs_symb]; + sum_im2 = sum_im2 + noise_imag[base_idx+srs_symb]*noise_imag[base_idx+srs_symb]; + } // for (int srs_symb = 0; srs_symb < srs_symbols_per_rb; srs_symb++) + } // for (int p_index = 0; p_index < N_ap; p_index++) + } // for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) - sum_re = sum_re + noise_real[ant*nr_srs_info->sc_list_length+sc_idx]; - sum_re2 = sum_re2 + noise_real[ant*nr_srs_info->sc_list_length+sc_idx]*noise_real[ant*nr_srs_info->sc_list_length+sc_idx]; - sum_im = sum_im + noise_imag[ant*nr_srs_info->sc_list_length+sc_idx]; - sum_im2 = sum_im2 + noise_imag[ant*nr_srs_info->sc_list_length+sc_idx]*noise_imag[ant*nr_srs_info->sc_list_length+sc_idx]; - - count_estimates++; - if (count_estimates == n_noise_est) { - noise_power_per_rb[rb] = max(sum_re2 / n_noise_est - (sum_re / n_noise_est) * (sum_re / n_noise_est) + - sum_im2 / n_noise_est - (sum_im / n_noise_est) * (sum_im / n_noise_est), 1); - snr_per_rb[rb] = dB_fixed((int32_t)((*signal_power<nb_antennas_rx*nr_srs_info->sc_list_length) - + calc_power(noise_imag,frame_parms->nb_antennas_rx*nr_srs_info->sc_list_length); + *noise_power = max(calc_power(noise_real,frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS) + + calc_power(noise_imag,frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS), 1); - *snr = dB_fixed((int32_t)((*signal_power<comb_size == 0 ? 2 : 4; - for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) { - for(int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) { - int subcarrier_log = nr_srs_info->sc_list[sc_idx]-subcarrier_offset; - if(subcarrier_log < 0) { - subcarrier_log = subcarrier_log + frame_parms->ofdm_symbol_size; - } - if(sc_idx == 0) { - LOG_I(NR_PHY,"______________________________ Rx antenna %i _______________________________\n", ant); - } - if(subcarrier_log%12 == 0) { - LOG_I(NR_PHY,":::::::::::::::::::::::::::::::::::: %i ::::::::::::::::::::::::::::::::::::\n", subcarrier_log/12); - LOG_I(NR_PHY,"\t __lsRe__________lsIm__|____intRe_______intIm__|____noiRe_______noiIm_\n"); - } - for(int r = 0; rsc_list[sc_idx] + r >= frame_parms->ofdm_symbol_size) - continue; - LOG_I(NR_PHY,"(%4i) %6i\t%6i | %6i\t%6i | %6i\t%6i\n", - subcarrier_log+r, - (int16_t)(srs_ls_estimated_channel[ant][nr_srs_info->sc_list[sc_idx]+r]&0xFFFF), - (int16_t)((srs_ls_estimated_channel[ant][nr_srs_info->sc_list[sc_idx]+r]>>16)&0xFFFF), - (int16_t)(srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]+r]&0xFFFF), - (int16_t)((srs_estimated_channel_freq[ant][nr_srs_info->sc_list[sc_idx]+r]>>16)&0xFFFF), - noise_real[ant*nr_srs_info->sc_list_length+sc_idx], - noise_imag[ant*nr_srs_info->sc_list_length+sc_idx]); - } - - } - } LOG_I(NR_PHY,"noise_power = %u, SNR = %i dB\n", *noise_power, *snr); #endif diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h index b0ed3662ea..f00db212f7 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h @@ -71,12 +71,12 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, const int slot, const nfapi_nr_srs_pdu_t *srs_pdu, const nr_srs_info_t *nr_srs_info, - const int32_t *srs_generated_signal, + const int32_t **srs_generated_signal, int32_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)], - int32_t srs_ls_estimated_channel[][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)], - int32_t srs_estimated_channel_freq[][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)], - int32_t srs_estimated_channel_time[][gNB->frame_parms.ofdm_symbol_size], - int32_t srs_estimated_channel_time_shifted[][gNB->frame_parms.ofdm_symbol_size], + int32_t srs_ls_estimated_channel[][1<num_ant_ports][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)], + int32_t srs_estimated_channel_freq[][1<num_ant_ports][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)], + int32_t srs_estimated_channel_time[][1<num_ant_ports][gNB->frame_parms.ofdm_symbol_size], + int32_t srs_estimated_channel_time_shifted[][1<num_ant_ports][gNB->frame_parms.ofdm_symbol_size], uint32_t *signal_power, uint32_t *noise_power_per_rb, uint32_t *noise_power, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index dc1ed47e0f..c8b5af6ea5 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -198,10 +198,10 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, int8_t cce_idx = reg_list_order[cce_count]; - for (int reg_in_cce_idx = 0; reg_in_cce_idx < NR_NB_REG_PER_CCE; reg_in_cce_idx+=pdcch_pdu_rel15->DurationSymbols) { + for (int reg_in_cce_idx = symbol_idx; reg_in_cce_idx < NR_NB_REG_PER_CCE; reg_in_cce_idx+=pdcch_pdu_rel15->DurationSymbols) { k = cset_start_sc + cce_list[d][cce_idx].reg_list[reg_in_cce_idx].start_sc_idx; - LOG_D(PHY,"CCE %d REG %d k %d\n",cce_idx,reg_in_cce_idx+symbol_idx,k); + LOG_D(PHY,"CCE %d REG %d k %d\n",cce_idx,reg_in_cce_idx,k); if (k >= frame_parms->ofdm_symbol_size) k -= frame_parms->ofdm_symbol_size; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index e9d3010ce7..3d166fd87d 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -80,15 +80,15 @@ void nr_fill_cce_list(nr_cce_t cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL] LOG_D(PHY, "cce_idx %d\n", cce->cce_idx); uint8_t j = cce->cce_idx; - for (int k=6*j/bsize; k<(6*j/bsize+6/bsize); k++) { // loop over REG bundles - + for (uint8_t bundle_idx=0; bundle_idxreg_list[reg_idx]; + reg = &cce->reg_list[bundle_idx*bsize+reg_idx]; reg->reg_idx = bsize*f + reg_idx; reg->start_sc_idx = (reg->reg_idx/dur) * NR_NB_SC_PER_RB; - reg->symb_idx = reg_idx%dur; + reg->symb_idx = reg->reg_idx%dur; LOG_D(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); } } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 07445b698e..658bae243f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -376,14 +376,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, memcpy(harq->b, a, (A / 8) + 3); // using 3 bytes to mimic the case of 24 bit crc } - // target_code_rate is in 0.1 units - float Coderate = (float) rel15->targetCodeRate[0] / 10240.0f; - LOG_D(PHY,"DLSCH Coderate %f\n",Coderate); - - if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) - impp.BG = 2; - else - impp.BG = 1; + impp.BG = rel15->maintenance_parms_v3.ldpcBaseGraph; start_meas(dlsch_segmentation_stats); impp.Kb = nr_segmentation(harq->b, harq->c, harq->B, &impp.n_segments, &impp.K, impp.Zc, &impp.F, impp.BG); diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 5437a9bb81..e5b043c395 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -315,19 +315,19 @@ int nr_find_pucch(uint16_t rnti, NR_gNB_SRS_t *new_gNB_srs(void); void free_gNB_srs(NR_gNB_SRS_t *srs); -int nr_find_srs(uint16_t rnti, - int frame, - int slot, +int nr_find_srs(rnti_t rnti, + frame_t frame, + slot_t slot, PHY_VARS_gNB *gNB); void nr_fill_srs(PHY_VARS_gNB *gNB, - int frame, - int slot, + frame_t frame, + slot_t slot, nfapi_nr_srs_pdu_t *srs_pdu); int nr_get_srs_signal(PHY_VARS_gNB *gNB, - int frame, - int slot, + frame_t frame, + slot_t slot, nfapi_nr_srs_pdu_t *srs_pdu, nr_srs_info_t *nr_srs_info, int32_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)]); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 57b0602c7e..e9038f25d8 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -42,6 +42,7 @@ #include "PHY/NR_TRANSPORT/nr_ulsch.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "SCHED_NR/sched_nr.h" +#include "SCHED_NR/fapi_nr_l1.h" #include "defs.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "common/utils/LOG/log.h" @@ -379,8 +380,24 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint32_t r; uint32_t r_offset; uint32_t offset; - int kc; int E; + int8_t llrProcBuf[22*384]; + int ret = 0; + int i,j; + int8_t enable_ldpc_offload = phy_vars_gNB->ldpc_offload_flag; + int16_t z_ol [68*384]; + int8_t l_ol [68*384]; + __m128i *pv_ol128 = (__m128i*)&z_ol; + __m128i *pl_ol128 = (__m128i*)&l_ol; + int no_iteration_ldpc = 2; + int length_dec; + uint8_t crc_type; + int K_bits_F; + int16_t z [68*384 + 16] __attribute__ ((aligned(16))); + int8_t l [68*384 + 16] __attribute__ ((aligned(16))); + + __m128i *pv = (__m128i*)&z; + __m128i *pl = (__m128i*)&l; #ifdef PRINT_CRC_CHECK prnt_crc_cnt++; @@ -395,7 +412,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, LOG_E(PHY,"ulsch_decoding.c: NULL harq_process pointer\n"); return 1; } - + uint8_t dtx_det = 0; t_nrLDPC_dec_params decParams; t_nrLDPC_dec_params* p_decParams = &decParams; @@ -422,6 +439,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, harq_process->round = nr_rv_to_round(pusch_pdu->pusch_data.rv_index); harq_process->new_rx = false; // flag to indicate if this is a new reception for this harq (initialized to false) + dtx_det = 0; if (harq_process->round == 0) { harq_process->new_rx = true; harq_process->ndi = pusch_pdu->pusch_data.new_data_indicator; @@ -431,6 +449,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (harq_process->ndi != pusch_pdu->pusch_data.new_data_indicator) { harq_process->new_rx = true; harq_process->ndi = pusch_pdu->pusch_data.new_data_indicator; + LOG_D(PHY,"Missed ULSCH detection. NDI toggled but rv %d does not correspond to first reception\n",pusch_pdu->pusch_data.rv_index); } @@ -442,8 +461,9 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d\n", harq_pid, A, G, mcs, n_layers, nb_rb, Qm, Coderate, pusch_pdu->pusch_data.rv_index, harq_process->round); - if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ - p_decParams->BG = 2; + p_decParams->BG = pusch_pdu->maintenance_parms_v3.ldpcBaseGraph; + int kc; + if (p_decParams->BG == 2){ kc = 52; if (Coderate < 0.3333) { p_decParams->R = 15; @@ -455,7 +475,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, p_decParams->R = 23; } } else { - p_decParams->BG = 1; kc = 68; if (Coderate < 0.6667) { p_decParams->R = 13; @@ -546,12 +565,179 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, Kr = harq_process->K; Kr_bytes = Kr>>3; offset = 0; + + //if ((enable_ldpc_offload)&& (dtx_det==0)) + if (enable_ldpc_offload){ + // if (dtx_det==0) { + + if (harq_process->C == 1) { + if (A > 3824) + crc_type = CRC24_A; + else + crc_type = CRC16; + + length_dec = harq_process->B; + } + else { + crc_type = CRC24_B; + length_dec = (harq_process->B+24*harq_process->C)/harq_process->C; + } + + for (r=0; rC; r++) { + E = nr_get_E(G, harq_process->C, Qm, n_layers, r); + memset(harq_process->c[r],0,Kr_bytes); + + if ((dtx_det==0)&&(pusch_pdu->pusch_data.rv_index==0)){ + //if (dtx_det==0){ + if (mcs >9){ + memcpy((&z_ol[0]),ulsch_llr+r_offset,E*sizeof(short)); + + for (i=0, j=0; j < ((kc*harq_process->Z)>>4)+1; i+=2, j++) + { + pl_ol128[j] = _mm_packs_epi16(pv_ol128[i],pv_ol128[i+1]); + } + + ret = nrLDPC_decoder_offload(p_decParams, harq_pid, + ULSCH_id,r, + pusch_pdu->pusch_data.rv_index, + harq_process->F, + E, + Qm, + (int8_t*)&pl_ol128[0], + llrProcBuf, 1); + if (ret<0) { + LOG_E(PHY,"ulsch_decoding.c: Problem in LDPC decoder offload\n"); + no_iteration_ldpc = ulsch->max_ldpc_iterations + 1; + return 1; + } + } + else{ + K_bits_F = Kr-harq_process->F; + + t_nrLDPC_time_stats procTime = {0}; + t_nrLDPC_time_stats* p_procTime = &procTime ; + /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) + int16_t harq_e[3*8448]; + + nr_deinterleaving_ldpc(E, + Qm, + harq_e, + ulsch_llr+r_offset); + + if (nr_rate_matching_ldpc_rx(pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes, + p_decParams->BG, + p_decParams->Z, + harq_process->d[r], + harq_e, + harq_process->C, + pusch_pdu->pusch_data.rv_index, + harq_process->new_rx, + E, + harq_process->F, + Kr-harq_process->F-2*(p_decParams->Z))==-1) { + + LOG_E(PHY,"ulsch_decoding.c: Problem in rate_matching\n"); + no_iteration_ldpc = ulsch->max_ldpc_iterations + 1; + return 1; + } + + //set first 2*Z_c bits to zeros + memset(&z[0],0,2*harq_process->Z*sizeof(int16_t)); + //set Filler bits + memset((&z[0]+K_bits_F),127,harq_process->F*sizeof(int16_t)); + //Move coded bits before filler bits + memcpy((&z[0]+2*harq_process->Z),harq_process->d[r],(K_bits_F-2*harq_process->Z)*sizeof(int16_t)); + //skip filler bits + memcpy((&z[0]+Kr),harq_process->d[r]+(Kr-2*harq_process->Z),(kc*harq_process->Z-Kr)*sizeof(int16_t)); + //Saturate coded bits before decoding into 8 bits values + for (i=0, j=0; j < ((kc*harq_process->Z)>>4)+1; i+=2, j++) + { + pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); + } + + no_iteration_ldpc = nrLDPC_decoder(p_decParams, + (int8_t*)&pl[0], + llrProcBuf, + p_procTime); + + } + + for (int m=0; m < Kr>>3; m ++) { + harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; + } + + if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { +#ifdef PRINT_CRC_CHECK + LOG_I(PHY, "Segment %d CRC OK\n",r); +#endif + no_iteration_ldpc = 2; + } else { +#ifdef PRINT_CRC_CHECK + LOG_I(PHY, "segment %d CRC NOK\n",r); +#endif + no_iteration_ldpc = ulsch->max_ldpc_iterations + 1; + } + //} + + r_offset += E; + + /*for (int k=0;k<8;k++) + { + printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); + printf("llrprocbuf [%d] = %x adr %p\n", k, llrProcBuf[k], llrProcBuf+k); + } + */ + } + else{ + dtx_det = 0; + no_iteration_ldpc = ulsch->max_ldpc_iterations+1; + } + bool decodeSuccess = (no_iteration_ldpc <= ulsch->max_ldpc_iterations); + if (decodeSuccess) { + memcpy(harq_process->b+offset, + harq_process->c[r], + Kr_bytes - (harq_process->F>>3) -((harq_process->C>1)?3:0)); + offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); + harq_process->processedSegments++; + } + else { + LOG_D(PHY,"uplink segment error %d/%d\n",r,harq_process->C); + LOG_D(PHY, "ULSCH %d in error\n",ULSCH_id); + break; //don't even attempt to decode other segments + } + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,0); + + if ((harq_process->processedSegments==(harq_process->C))) { + LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for slot %d TBS %d\n", + phy_vars_gNB->Mod_id,harq_process->slot,harq_process->TBS); + harq_process->status = SCH_IDLE; + harq_process->round = 0; + ulsch->harq_mask &= ~(1 << harq_pid); + + LOG_D(PHY, "ULSCH received ok \n"); + nr_fill_indication(phy_vars_gNB,harq_process->frame, harq_process->slot, ULSCH_id, harq_pid, 0,0); + + } else { + LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) r %d\n", + phy_vars_gNB->Mod_id, harq_process->frame, harq_process->slot, + harq_pid,harq_process->status, harq_process->round,harq_process->TBS,r); + harq_process->handled = 1; + no_iteration_ldpc = ulsch->max_ldpc_iterations + 1; + LOG_D(PHY, "ULSCH %d in error\n",ULSCH_id); + nr_fill_indication(phy_vars_gNB,harq_process->frame, harq_process->slot, ULSCH_id, harq_pid, 1,0); + } + ulsch->last_iteration_cnt = no_iteration_ldpc; + } + + else { + dtx_det = 0; void (*nr_processULSegment_ptr)(void*) = &nr_processULSegment; for (r=0; rC; r++) { E = nr_get_E(G, harq_process->C, Qm, n_layers, r); - union ldpcReqUnion id = {.s={ulsch->rnti,frame,nr_tti_rx,0,0}}; notifiedFIFO_elt_t *req = newNotifiedFIFO_elt(sizeof(ldpcDecode_t), id.p, &phy_vars_gNB->respDecode, nr_processULSegment_ptr); ldpcDecode_t * rdata=(ldpcDecode_t *) NotifiedFifoData(req); @@ -581,5 +767,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); ////////////////////////////////////////////////////////////////////////////////////////// } + } return 1; } diff --git a/openair1/PHY/NR_TRANSPORT/srs_rx.c b/openair1/PHY/NR_TRANSPORT/srs_rx.c index 39c3846db5..ba95b9ac44 100644 --- a/openair1/PHY/NR_TRANSPORT/srs_rx.c +++ b/openair1/PHY/NR_TRANSPORT/srs_rx.c @@ -30,10 +30,12 @@ #include #include +#include "PHY/INIT/phy_init.h" #include "PHY/impl_defs_nr.h" #include "PHY/defs_nr_common.h" #include "PHY/defs_gNB.h" -#include +#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h" +#include "PHY/NR_UE_TRANSPORT/srs_modulation_nr.h" #include "common/utils/LOG/log.h" #include "nfapi/oai_integration/vendor_ext.h" @@ -54,9 +56,9 @@ void free_gNB_srs(NR_gNB_SRS_t *srs) free_and_zero(srs); } -int nr_find_srs(uint16_t rnti, - int frame, - int slot, +int nr_find_srs(rnti_t rnti, + frame_t frame, + slot_t slot, PHY_VARS_gNB *gNB) { AssertFatal(gNB!=NULL,"gNB is null\n"); @@ -78,8 +80,8 @@ int nr_find_srs(uint16_t rnti, } void nr_fill_srs(PHY_VARS_gNB *gNB, - int frame, - int slot, + frame_t frame, + slot_t slot, nfapi_nr_srs_pdu_t *srs_pdu) { int id = nr_find_srs(srs_pdu->rnti,frame,slot,gNB); @@ -94,23 +96,28 @@ void nr_fill_srs(PHY_VARS_gNB *gNB, } int nr_get_srs_signal(PHY_VARS_gNB *gNB, - int frame, - int slot, + frame_t frame, + slot_t slot, nfapi_nr_srs_pdu_t *srs_pdu, nr_srs_info_t *nr_srs_info, int32_t srs_received_signal[][gNB->frame_parms.ofdm_symbol_size*(1<num_symbols)]) { - if(nr_srs_info->sc_list_length == 0) { - LOG_E(NR_PHY, "(%d.%d) nr_srs_info was not generated yet!\n", frame, slot); - return -1; - } +#ifdef SRS_DEBUG + LOG_I(NR_PHY,"Calling %s function\n", __FUNCTION__); +#endif int32_t **rxdataF = gNB->common_vars.rxdataF; - NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; + const NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; - uint16_t n_symbols = (slot&3)*frame_parms->symbols_per_slot; // number of symbols until this slot - uint8_t l0 = frame_parms->symbols_per_slot - 1 - srs_pdu->time_start_position; // starting symbol in this slot - uint64_t symbol_offset = (n_symbols+l0)*frame_parms->ofdm_symbol_size; + const uint16_t n_symbols = (slot&3)*frame_parms->symbols_per_slot; // number of symbols until this slot + const uint8_t l0 = frame_parms->symbols_per_slot - 1 - srs_pdu->time_start_position; // starting symbol in this slot + const uint64_t symbol_offset = (n_symbols+l0)*frame_parms->ofdm_symbol_size; + const uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*NR_NB_SC_PER_RB; + + const uint8_t N_ap = 1<num_ant_ports; + const uint8_t N_symb_SRS = 1<num_symbols; + const uint8_t K_TC = 2<comb_size; + const uint16_t M_sc_b_SRS = srs_bandwidth_config[srs_pdu->config_index][srs_pdu->bandwidth_index][0] * NR_NB_SC_PER_RB/K_TC; int32_t *rx_signal; bool no_srs_signal = true; @@ -119,32 +126,56 @@ int nr_get_srs_signal(PHY_VARS_gNB *gNB, memset(srs_received_signal[ant], 0, frame_parms->ofdm_symbol_size*sizeof(int32_t)); rx_signal = &rxdataF[ant][symbol_offset]; - for(int sc_idx = 0; sc_idx < nr_srs_info->sc_list_length; sc_idx++) { - srs_received_signal[ant][nr_srs_info->sc_list[sc_idx]] = rx_signal[nr_srs_info->sc_list[sc_idx]]; - - if (rx_signal[nr_srs_info->sc_list[sc_idx]] != 0) { - no_srs_signal = false; - } + for (int p_index = 0; p_index < N_ap; p_index++) { #ifdef SRS_DEBUG - uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_pdu->bwp_start*12; - int subcarrier_log = nr_srs_info->sc_list[sc_idx]-subcarrier_offset; - if(subcarrier_log < 0) { - subcarrier_log = subcarrier_log + frame_parms->ofdm_symbol_size; - } - if(sc_idx == 0) { - LOG_I(NR_PHY,"________ Rx antenna %i ________\n", ant); - } - if(subcarrier_log%12 == 0) { - LOG_I(NR_PHY,"::::::::::::: %i :::::::::::::\n", subcarrier_log/12); - } - LOG_I(NR_PHY,"(%i) \t%i\t%i\n", - subcarrier_log, - (int16_t)(srs_received_signal[ant][nr_srs_info->sc_list[sc_idx]]&0xFFFF), - (int16_t)((srs_received_signal[ant][nr_srs_info->sc_list[sc_idx]]>>16)&0xFFFF)); + LOG_I(NR_PHY,"===== UE port %d --> gNB Rx antenna %i =====\n", p_index, ant); #endif - } - } + + for (int l_line = 0; l_line < N_symb_SRS; l_line++) { + +#ifdef SRS_DEBUG + LOG_I(NR_PHY,":::::::: OFDM symbol %d ::::::::\n", l0+l_line); +#endif + + uint16_t subcarrier = subcarrier_offset + nr_srs_info->k_0_p[p_index][l_line]; + if (subcarrier>frame_parms->ofdm_symbol_size) { + subcarrier -= frame_parms->ofdm_symbol_size; + } + uint16_t l_line_offset = l_line*frame_parms->ofdm_symbol_size; + + for (int k = 0; k < M_sc_b_SRS; k++) { + + srs_received_signal[ant][l_line_offset+subcarrier] = rx_signal[l_line_offset+subcarrier]; + + if (rx_signal[l_line_offset+subcarrier] != 0) { + no_srs_signal = false; + } + +#ifdef SRS_DEBUG + int subcarrier_log = subcarrier-subcarrier_offset; + if(subcarrier_log < 0) { + subcarrier_log = subcarrier_log + frame_parms->ofdm_symbol_size; + } + if(subcarrier_log%12 == 0) { + LOG_I(NR_PHY,"------------ %d ------------\n", subcarrier_log/12); + } + LOG_I(NR_PHY,"(%i) \t%i\t%i\n", + subcarrier_log, + (int16_t)(srs_received_signal[ant][l_line_offset+subcarrier]&0xFFFF), + (int16_t)((srs_received_signal[ant][l_line_offset+subcarrier]>>16)&0xFFFF)); +#endif + + // Subcarrier increment + subcarrier += K_TC; + if (subcarrier >= frame_parms->ofdm_symbol_size) { + subcarrier=subcarrier-frame_parms->ofdm_symbol_size; + } + + } // for (int k = 0; k < M_sc_b_SRS; k++) + } // for (int l_line = 0; l_line < N_symb_SRS; l_line++) + } // for (int p_index = 0; p_index < N_ap; p_index++) + } // for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) if (no_srs_signal) { LOG_W(NR_PHY, "No SRS signal\n"); @@ -152,4 +183,4 @@ int nr_get_srs_signal(PHY_VARS_gNB *gNB, } else { return 0; } -} \ No newline at end of file +} diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 43944b2fa8..ae8b733301 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -261,19 +261,20 @@ int nr_get_csi_rs_signal(const PHY_VARS_NR_UE *ue, return 0; } -uint32_t calc_power_csirs(const uint16_t *x, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu) { +uint32_t calc_power_csirs(const uint16_t *x, const fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu) +{ uint64_t sum_x = 0; uint64_t sum_x2 = 0; uint16_t size = 0; - for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { - if (csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != (rb % 2)) { + for (int rb = 0; rb < csirs_config_pdu->nr_of_rbs; rb++) { + if (csirs_config_pdu->freq_density <= 1 && csirs_config_pdu->freq_density != ((rb + csirs_config_pdu->start_rb) % 2)) { continue; } - sum_x = sum_x + x[rb-csirs_config_pdu->start_rb]; - sum_x2 = sum_x2 + x[rb]*x[rb-csirs_config_pdu->start_rb]; + sum_x = sum_x + x[rb]; + sum_x2 = sum_x2 + x[rb] * x[rb]; size++; } - return sum_x2/size - (sum_x/size)*(sum_x/size); + return sum_x2 / size - (sum_x / size) * (sum_x / size); } int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index e6833c4cb4..0087a307ef 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -57,29 +57,6 @@ notifiedFIFO_t freeBlocks_dl; notifiedFIFO_elt_t *msgToPush_dl; int nbDlProcessing =0; - -static tpool_t pool_dl; -//extern double cpuf; - -void init_dlsch_tpool(uint8_t num_dlsch_threads) { - char *params = NULL; - - if( num_dlsch_threads==0) { - params = calloc(1,2); - memcpy(params,"N",1); - } - else { - params = calloc(1,(num_dlsch_threads*3)+1); - for (int i=0; ikey); + int nb=abortTpoolJob(&get_nrUE_params()->Tpool, req->key); nb+=abortNotifiedFIFOJob(nf_p, req->key); LOG_D(PHY,"downlink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); LOG_D(PHY, "DLSCH %d in error\n",rdata->dlsch_id); @@ -259,7 +236,6 @@ void nr_processDLSegment(void* arg) { int length_dec; int no_iteration_ldpc; int Kr; - int Kr_bytes; int K_bits_F; uint8_t crc_type; int i; @@ -282,8 +258,7 @@ void nr_processDLSegment(void* arg) { __m128i *pv = (__m128i*)&z; __m128i *pl = (__m128i*)&l; - Kr = harq_process->K; // [hna] overwrites this line "Kr = p_decParams->Z*kb" - Kr_bytes = Kr>>3; + Kr = harq_process->K; K_bits_F = Kr-harq_process->F; t_nrLDPC_time_stats procTime = {0}; @@ -293,8 +268,7 @@ void nr_processDLSegment(void* arg) { start_meas(&rdata->ts_deinterleave); //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_IN); - int16_t w[E]; - memset(w, 0, sizeof(w)); + int16_t w[E]; nr_deinterleaving_ldpc(E, Qm, w, // [hna] w is e @@ -321,7 +295,7 @@ void nr_processDLSegment(void* arg) { w, harq_process->C, harq_process->rvidx, - (harq_process->first_rx==1)?1:0, + harq_process->first_rx, E, harq_process->F, Kr-harq_process->F-2*(p_decoderParms->Z))==-1) { @@ -333,8 +307,6 @@ void nr_processDLSegment(void* arg) { } stop_meas(&rdata->ts_rate_unmatch); - r_offset += E; - if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD)) { LOG_D(PHY,"decoder input(segment %u) :",r); @@ -344,8 +316,6 @@ void nr_processDLSegment(void* arg) { LOG_D(PHY,"\n"); } - memset(harq_process->c[r],0,Kr_bytes); - if (harq_process->C == 1) { if (A > NR_MAX_PDSCH_TBS) crc_type = CRC24_A; @@ -383,21 +353,23 @@ void nr_processDLSegment(void* arg) { &procTime); //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_OUT); + LOG_D(PHY,"no_iteration_ldpc = %d\n", no_iteration_ldpc); // Fixme: correct type is unsigned, but nrLDPC_decoder and all called behind use signed int if (check_crc((uint8_t *)llrProcBuf,length_dec,harq_process->F,crc_type)) { LOG_D(PHY,"Segment %u CRC OK\n",r); - - if (r==0) { - for (int i=0; i<10; i++) LOG_D(PHY,"byte %d : %x\n",i,((uint8_t *)llrProcBuf)[i]); - } - - //Temporary hack - no_iteration_ldpc = dlsch->max_ldpc_iterations; - rdata->decodeIterations = no_iteration_ldpc; + if (no_iteration_ldpc > dlsch->max_ldpc_iterations) + no_iteration_ldpc = dlsch->max_ldpc_iterations; } else { LOG_D(PHY,"CRC NOT OK\n"); + no_iteration_ldpc = dlsch->max_ldpc_iterations + 1; } + if (r==0) { + for (int i=0; i<10; i++) LOG_D(PHY,"byte %d : %x\n",i,((uint8_t *)llrProcBuf)[i]); + } + + rdata->decodeIterations = no_iteration_ldpc; + nb_total_decod++; if (no_iteration_ldpc > dlsch->max_ldpc_iterations) { @@ -547,7 +519,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD) && (!frame%100)) - LOG_I(PHY,"K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl); + LOG_I(PHY,"K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, harq_process->Z, harq_process->Nl); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_SEGMENTATION, VCD_FUNCTION_OUT); @@ -606,7 +578,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, reset_meas(&rdata->ts_deinterleave); reset_meas(&rdata->ts_rate_unmatch); reset_meas(&rdata->ts_ldpc_decode); - pushTpool(&(pool_dl),req); + pushTpool(&get_nrUE_params()->Tpool,req); nbDecode++; LOG_D(PHY,"Added a block to decode, in pipe: %d\n",nbDecode); r_offset += E; @@ -614,7 +586,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ////////////////////////////////////////////////////////////////////////////////////////// } for (r=0; rTpool); if (req == NULL) break; // Tpool has been stopped bool last = false; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 6728f0260c..88cc419dc1 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -480,45 +480,45 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, nbSymb = dlsch1_harq->nb_symbols; pduBitmap = dlsch1_harq->pduBitmap; } - + /* Check for PTRS bitmap and process it respectively */ if((pduBitmap & 0x1) && (type == PDSCH)) { nr_pdsch_ptrs_processing(ue, - pdsch_vars, - frame_parms, - dlsch0_harq, - dlsch1_harq, - gNB_id, - nr_slot_rx, - symbol, - (nb_rb_pdsch*12), - dlsch[0]->rnti,rx_type); + pdsch_vars, + frame_parms, + dlsch0_harq, + dlsch1_harq, + gNB_id, + nr_slot_rx, + symbol, + (nb_rb_pdsch*12), + dlsch[0]->rnti,rx_type); pdsch_vars[gNB_id]->dl_valid_re[symbol-1] -= pdsch_vars[gNB_id]->ptrs_re_per_slot[0][symbol]; } - + /* at last symbol in a slot calculate LLR's for whole slot */ if(symbol == (startSymbIdx + nbSymb -1)) { for(uint8_t i =startSymbIdx; i < (startSymbIdx+nbSymb);i++) { /* re evaluating the first symbol flag as LLR's are done in symbol loop */ if(i == startSymbIdx && i < 3) { - first_symbol_flag =1; + first_symbol_flag =1; } else { - first_symbol_flag=0; + first_symbol_flag=0; } /* Calculate LLR's for each symbol */ nr_dlsch_llr(pdsch_vars, frame_parms, - rxdataF_comp_ptr, dl_ch_mag_ptr, - dlsch0_harq, dlsch1_harq, - rx_type, harq_pid, - gNB_id, gNB_id_i, - first_symbol_flag, - i, nb_rb_pdsch, - codeword_TB0, codeword_TB1, - pdsch_vars[gNB_id]->dl_valid_re[i-1], - nr_slot_rx, beamforming_mode); + rxdataF_comp_ptr, dl_ch_mag_ptr, + dlsch0_harq, dlsch1_harq, + rx_type, harq_pid, + gNB_id, gNB_id_i, + first_symbol_flag, + i, nb_rb_pdsch, + codeword_TB0, codeword_TB1, + pdsch_vars[gNB_id]->dl_valid_re[i-1], + nr_slot_rx, beamforming_mode); } - + int dmrs_type = dlsch[0]->harq_processes[harq_pid]->dmrsConfigType; uint8_t nb_re_dmrs; uint16_t dmrs_len = get_num_dmrs(dlsch[0]->harq_processes[harq_pid]->dlDmrsSymbPos); @@ -528,29 +528,29 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, nb_re_dmrs = 4*dlsch[0]->harq_processes[harq_pid]->n_dmrs_cdm_groups; } dlsch[0]->harq_processes[harq_pid]->G = nr_get_G(dlsch[0]->harq_processes[harq_pid]->nb_rb, - dlsch[0]->harq_processes[harq_pid]->nb_symbols, - nb_re_dmrs, - dmrs_len, - dlsch[0]->harq_processes[harq_pid]->Qm, - dlsch[0]->harq_processes[harq_pid]->Nl); + dlsch[0]->harq_processes[harq_pid]->nb_symbols, + nb_re_dmrs, + dmrs_len, + dlsch[0]->harq_processes[harq_pid]->Qm, + dlsch[0]->harq_processes[harq_pid]->Nl); nr_dlsch_layer_demapping(pdsch_vars[gNB_id]->llr, - dlsch[0]->harq_processes[harq_pid]->Nl, - dlsch[0]->harq_processes[harq_pid]->Qm, - dlsch[0]->harq_processes[harq_pid]->G, - codeword_TB0, - codeword_TB1, - pdsch_vars[gNB_id]->layer_llr); + dlsch[0]->harq_processes[harq_pid]->Nl, + dlsch[0]->harq_processes[harq_pid]->Qm, + dlsch[0]->harq_processes[harq_pid]->G, + codeword_TB0, + codeword_TB1, + pdsch_vars[gNB_id]->layer_llr); } - + stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]); if (cpumeas(CPUMEAS_GETSTATE)) LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0)); - + // Please keep it: useful for debugging #ifdef DEBUG_PDSCH_RX char filename[50]; uint8_t aa = 0; - + snprintf(filename, 50, "rxdataF0_symb_%d_nr_slot_rx_%d.m", symbol, nr_slot_rx); write_output(filename, "rxdataF0", &common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[0][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 064d4db1af..aa2d617112 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -207,7 +207,6 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, { int32_t sync_pos, sync_pos_frame; // k_ssb, N_ssb_crb, sync_pos2, - int32_t accumulated_freq_offset = 0; int32_t metric_tdd_ncp=0; uint8_t phase_tdd_ncp; double im, re; @@ -258,8 +257,6 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, LOG_I(PHY,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset); #endif - accumulated_freq_offset += ue->common_vars.freq_offset; - // digital compensation of FFO for SSB symbols if (ue->UE_fo_compensation){ double s_time = 1/(1.0e3*fp->samples_per_subframe); // sampling time @@ -310,8 +307,6 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, int freq_offset_sss = 0; ret = rx_sss_nr(ue, proc, &metric_tdd_ncp, &phase_tdd_ncp, &freq_offset_sss); - accumulated_freq_offset += freq_offset_sss; - // digital compensation of FFO for SSB symbols if (ue->UE_fo_compensation){ double s_time = 1/(1.0e3*fp->samples_per_subframe); // sampling time @@ -334,6 +329,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, ((short *)ue->common_vars.rxdata[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle))); } } + + ue->common_vars.freq_offset += freq_offset_sss; } if (ret==0) { //we got sss channel @@ -603,8 +600,6 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, } if (dec == false) // sib1 not decoded ret = -1; - - ue->common_vars.freq_offset = accumulated_freq_offset; } // exit_fun("debug exit"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_INITIAL_UE_SYNC, VCD_FUNCTION_OUT); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index ef952b0152..0ff5d0a2eb 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -381,7 +381,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RATE_MATCHING_LDPC, VCD_FUNCTION_IN); start_meas(&ue->ulsch_rate_matching_stats); - if (nr_rate_matching_ldpc(0, + if (nr_rate_matching_ldpc(harq_process->pusch_pdu.tbslbrm, harq_process->BG, *pz, harq_process->d[r], diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index eaeffd0809..dba1fd194d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -597,17 +597,28 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, int symb_offset = (slot%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot; for(ap = 0; ap < n_antenna_ports; ap++) { for (int s=0;ssymbol_rotation[1])[s + symb_offset]; + c16_t *this_symbol = (c16_t *)&txdataF[ap][frame_parms->ofdm_symbol_size * s]; + c16_t rot=frame_parms->symbol_rotation[1][s + symb_offset]; LOG_D(PHY,"rotating txdataF symbol %d (%d) => (%d.%d)\n", s, s + symb_offset, rot.r, rot.i); - rotate_cpx_vector((c16_t *)&txdataF[ap][frame_parms->ofdm_symbol_size * s], - &rot, - (c16_t *)&txdataF[ap][frame_parms->ofdm_symbol_size * s], - frame_parms->ofdm_symbol_size, - 15); + if (frame_parms->N_RB_UL & 1) { + rotate_cpx_vector(this_symbol, &rot, this_symbol, + (frame_parms->N_RB_UL + 1) * 6, 15); + rotate_cpx_vector(this_symbol + frame_parms->first_carrier_offset - 6, + &rot, + this_symbol + frame_parms->first_carrier_offset - 6, + (frame_parms->N_RB_UL + 1) * 6, 15); + } else { + rotate_cpx_vector(this_symbol, &rot, this_symbol, + frame_parms->N_RB_UL * 6, 15); + rotate_cpx_vector(this_symbol + frame_parms->first_carrier_offset, + &rot, + this_symbol + frame_parms->first_carrier_offset, + frame_parms->N_RB_UL * 6, 15); + } } } diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c index f3a953c9a8..55669ba322 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c @@ -48,9 +48,129 @@ //#define SRS_DEBUG -/******************************************************************* + +uint16_t group_number_hopping(int slot_number, + uint8_t n_ID_SRS, + uint8_t l0, + uint8_t l_line) { + + // Pseudo-random sequence c(i) defined by TS 38.211 - Section 5.2.1 + uint32_t cinit = n_ID_SRS; + uint8_t c_last_index = 8 * (slot_number * N_SYMB_SLOT + l0 + l_line) + 7; + uint32_t *c_sequence = calloc(c_last_index+1, sizeof(uint32_t)); + pseudo_random_sequence(c_last_index+1, c_sequence, cinit); + + // TS 38.211 - 6.4.1.4.2 Sequence generation + uint32_t f_gh = 0; + for (int m = 0; m <= 7; m++) { + f_gh += c_sequence[8 * (slot_number * N_SYMB_SLOT + l0 + l_line) + m] << m; + } + f_gh = f_gh%30; + uint8_t u = (f_gh + n_ID_SRS)%U_GROUP_NUMBER; + + free(c_sequence); + return u; +} + +uint16_t sequence_number_hopping(int slot_number, + uint8_t n_ID_SRS, + uint16_t M_sc_b_SRS, + uint8_t l0, + uint8_t l_line) { + uint16_t v = 0; + if (M_sc_b_SRS > 6 * NR_NB_SC_PER_RB) { + // Pseudo-random sequence c(i) defined by TS 38.211 - Section 5.2.1 + uint32_t cinit = n_ID_SRS; + uint8_t c_last_index = (slot_number * N_SYMB_SLOT + l0 + l_line); + uint32_t *c_sequence = calloc(c_last_index+1, sizeof(uint32_t)); + pseudo_random_sequence(c_last_index+1, c_sequence, cinit); + // TS 38.211 - 6.4.1.4.2 Sequence generation + v = c_sequence[c_last_index]; + free(c_sequence); + } + return v; +} + +uint16_t compute_F_b(frame_t frame_number, + slot_t slot_number, + uint16_t slots_per_frame, + uint8_t N_symb_SRS, + uint8_t B_SRS, + uint8_t C_SRS, + uint8_t b_hop, + uint8_t R, + uint16_t T_offset, + uint16_t T_SRS, + resourceType_t resource_type, + uint8_t l_line, + uint8_t b) { + + // Compute the number of SRS transmissions + uint16_t n_SRS = 0; + if (resource_type == aperiodic) { + n_SRS = l_line / R; + } else { + n_SRS = ((slots_per_frame*frame_number + slot_number - T_offset)/T_SRS)*(N_symb_SRS/R)+(l_line / R); + } + + uint16_t product_N_b = 1; + for (unsigned int b_prime = b_hop; b_prime < B_SRS; b_prime++) { + if (b_prime != b_hop) { + product_N_b *= srs_bandwidth_config[C_SRS][b_prime][1]; + } + } + + uint16_t F_b = 0; + uint8_t N_b = srs_bandwidth_config[C_SRS][b][1]; + if (N_b & 1) { // Nb odd + F_b = (N_b/2)*(n_SRS/product_N_b); + } else { // Nb even + uint16_t product_N_b_B_SRS = product_N_b; + product_N_b_B_SRS *= srs_bandwidth_config[C_SRS][B_SRS][1]; /* product for b_hop to b */ + F_b = (N_b/2)*((n_SRS%product_N_b_B_SRS)/product_N_b) + ((n_SRS%product_N_b_B_SRS)/2*product_N_b); + } + + return F_b; +} + +uint16_t compute_n_b(frame_t frame_number, + slot_t slot_number, + uint16_t slots_per_frame, + uint8_t N_symb_SRS, + uint8_t B_SRS, + uint8_t C_SRS, + uint8_t b_hop, + uint8_t n_RRC, + uint8_t R, + uint16_t T_offset, + uint16_t T_SRS, + resourceType_t resource_type, + uint8_t l_line, + uint8_t b) { + + uint8_t N_b = srs_bandwidth_config[C_SRS][b][1]; + uint16_t m_SRS_b = srs_bandwidth_config[C_SRS][B_SRS][0]; + + uint16_t n_b = 0; + if (b_hop >= B_SRS) { + n_b = (4 * n_RRC/m_SRS_b)%N_b; + } else { + if (b <= b_hop) { + n_b = (4 * n_RRC/m_SRS_b)%N_b; + } else { + // Compute the hopping offset Fb + uint16_t F_b = compute_F_b(frame_number, slot_number, slots_per_frame, N_symb_SRS, B_SRS, C_SRS, b_hop, R, + T_offset, T_SRS, resource_type, l_line, b); + n_b = (F_b + (4 * n_RRC/m_SRS_b))%N_b; + } + } + + return n_b; +} + +/************************************************************************* * -* NAME : generate_srs +* NAME : generate_srs_nr * * PARAMETERS : pointer to srs config pdu * pointer to transmit buffer @@ -60,68 +180,43 @@ * -1 if sequence can not be properly generated * * DESCRIPTION : generate/map srs symbol into transmit buffer -* see TS 38211 6.4.1.4 Sounding reference signal +* See TS 38.211 - Section 6.4.1.4 Sounding reference signal * -* FFS_TODO_NR -* Current supported configuration: -* - single resource per resource set -* - single port antenna -* - 1 symbol for SRS -* - no symbol offset -* - periodic mode -* - no hopping -* - no carrier switching -* - no antenna switching* -* -*********************************************************************/ +***************************************************************************/ int generate_srs_nr(nfapi_nr_srs_pdu_t *srs_config_pdu, NR_DL_FRAME_PARMS *frame_parms, - int32_t *txptr, + int32_t **txdataF, + uint16_t symbol_offset, nr_srs_info_t *nr_srs_info, int16_t amp, - int frame_number, - int slot_number) -{ - uint8_t n_SRS_cs_max; - uint8_t u; - uint8_t v_nu; - uint32_t f_gh = 0; - uint16_t n_SRS; - uint16_t n_SRS_cs_i; - double alpha_i; - uint8_t K_TC_p; - uint16_t n_b[B_SRS_NUMBER]; - uint16_t F_b; - uint16_t subcarrier; - uint8_t N_b; - uint8_t k_0_overbar_p; + frame_t frame_number, + slot_t slot_number) { - // get parameters from srs_config_pdu - uint8_t B_SRS = srs_config_pdu->bandwidth_index; - uint8_t C_SRS = srs_config_pdu->config_index; +#ifdef SRS_DEBUG + LOG_I(NR_PHY,"Calling %s function\n", __FUNCTION__); +#endif + + // SRS config parameters + uint8_t B_SRS = srs_config_pdu->bandwidth_index; + uint8_t C_SRS = srs_config_pdu->config_index; uint8_t b_hop = srs_config_pdu->frequency_hopping; uint8_t K_TC = 2<comb_size; - uint8_t K_TC_overbar = srs_config_pdu->comb_offset; // FFS_TODO_NR is this parameter for K_TC_overbar ?? + uint8_t K_TC_overbar = srs_config_pdu->comb_offset; uint8_t n_SRS_cs = srs_config_pdu->cyclic_shift; uint8_t n_ID_SRS = srs_config_pdu->sequence_id; - uint8_t n_shift = srs_config_pdu->frequency_position; // it adjusts the SRS allocation to align with the common resource block grid in multiples of four + uint8_t n_shift = srs_config_pdu->frequency_position; // It adjusts the SRS allocation to align with the common resource block grid in multiples of four uint8_t n_RRC = srs_config_pdu->frequency_shift; uint8_t groupOrSequenceHopping = srs_config_pdu->group_or_sequence_hopping; uint8_t l_offset = srs_config_pdu->time_start_position; uint16_t T_SRS = srs_config_pdu->t_srs; - uint16_t T_offset = srs_config_pdu->t_offset; // FFS_TODO_NR to check interface with RRC + uint16_t T_offset = srs_config_pdu->t_offset; uint8_t R = 1<num_repetitions; - uint8_t N_ap = 1<num_ant_ports; // antenna port for transmission - uint8_t N_symb_SRS = 1<num_symbols; // consecutive OFDM symbols - uint8_t l0 = frame_parms->symbols_per_slot - 1 - l_offset; // starting position in the time domain - uint8_t k_0_p; // frequency domain starting position - - uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_config_pdu->bwp_start*N_SC_RB; - - if(nr_srs_info) { - nr_srs_info->sc_list_length = 0; - nr_srs_info->srs_generated_signal_bits = log2_approx(amp); - } + uint8_t N_ap = 1<num_ant_ports; // Number of antenna port for transmission + uint8_t N_symb_SRS = 1<num_symbols; // Number of consecutive OFDM symbols + uint8_t l0 = frame_parms->symbols_per_slot - 1 - l_offset; // Starting symbol position in the time domain + uint8_t n_SRS_cs_max = srs_max_number_cs[srs_config_pdu->comb_size]; + uint16_t m_SRS_b = srs_bandwidth_config[C_SRS][B_SRS][0]; // Number of resource blocks + uint16_t M_sc_b_SRS = m_SRS_b * NR_NB_SC_PER_RB/K_TC; // Length of the SRS sequence #ifdef SRS_DEBUG LOG_I(NR_PHY,"Frame = %i, slot = %i\n", frame_number, slot_number); @@ -142,265 +237,185 @@ int generate_srs_nr(nfapi_nr_srs_pdu_t *srs_config_pdu, LOG_I(NR_PHY,"N_ap = %i\n", N_ap); LOG_I(NR_PHY,"N_symb_SRS = %i\n", N_symb_SRS); LOG_I(NR_PHY,"l0 = %i\n", l0); + LOG_I(NR_PHY,"n_SRS_cs_max = %i\n", n_SRS_cs_max); + LOG_I(NR_PHY,"m_SRS_b = %i\n", m_SRS_b); + LOG_I(NR_PHY,"M_sc_b_SRS = %i\n", M_sc_b_SRS); #endif - if (N_ap != port1) { - LOG_E(NR_PHY, "generate_srs: this number of antenna ports %d is not yet supported!\n", N_ap); - return (-1); - } - if (N_symb_SRS != 1) { - LOG_E(NR_PHY, "generate_srs: this number of srs symbol %d is not yet supported!\n", N_symb_SRS); - return (-1); - } - if (groupOrSequenceHopping != neitherHopping) { - LOG_E(NR_PHY, "generate_srs: sequence hopping is not yet supported!\n"); - return (-1); - } + // Validation of SRS config parameters + if (R == 0) { LOG_E(NR_PHY, "generate_srs: this parameter repetition factor %d is not consistent !\n", R); - return (-1); - } - else if (R > N_symb_SRS) { + return -1; + } else if (R > N_symb_SRS) { LOG_E(NR_PHY, "generate_srs: R %d can not be greater than N_symb_SRS %d !\n", R, N_symb_SRS); - return (-1); - } - /* see 38211 6.4.1.4.2 Sequence generation */ - if (K_TC == 4) { - n_SRS_cs_max = 12; - // delta = 2; /* delta = log2(K_TC) */ - } - else if (K_TC == 2) { - n_SRS_cs_max = 8; - // delta = 1; /* delta = log2(K_TC) */ - } - else { - LOG_E(NR_PHY, "generate_srs: SRS unknown value for K_TC %d !\n", K_TC); - return (-1); + return -1; } + if (n_SRS_cs >= n_SRS_cs_max) { LOG_E(NR_PHY, "generate_srs: inconsistent parameter n_SRS_cs %d >= n_SRS_cs_max %d !\n", n_SRS_cs, n_SRS_cs_max); - return (-1); + return -1; } + if (T_SRS == 0) { LOG_E(NR_PHY, "generate_srs: inconsistent parameter T_SRS %d can not be equal to zero !\n", T_SRS); - return (-1); - } - else - { + return -1; + } else { int index = 0; while (srs_periodicity[index] != T_SRS) { index++; if (index == SRS_PERIODICITY) { LOG_E(NR_PHY, "generate_srs: inconsistent parameter T_SRS %d not specified !\n", T_SRS); - return (-1); + return -1; } } } - uint16_t m_SRS_b = srs_bandwidth_config[C_SRS][B_SRS][0]; /* m_SRS_b is given by TS 38211 clause 6.4.1.4.3 */ - uint16_t M_sc_b_SRS = m_SRS_b * N_SC_RB/K_TC; /* length of the sounding reference signal sequence */ + // Variable initialization + if(nr_srs_info) { + nr_srs_info->srs_generated_signal_bits = log2_approx(amp); + } + uint64_t subcarrier_offset = frame_parms->first_carrier_offset + srs_config_pdu->bwp_start*NR_NB_SC_PER_RB; + double sqrt_N_ap = sqrt(N_ap); + uint16_t n_b[B_SRS_NUMBER]; - /* for each antenna ports for transmission */ + // Find index of table which is for this SRS length + uint16_t M_sc_b_SRS_index = 0; + while((ul_allocated_re[M_sc_b_SRS_index] != M_sc_b_SRS) && (M_sc_b_SRS_index < SRS_SB_CONF)){ + M_sc_b_SRS_index++; + } + + // SRS sequence generation and mapping, TS 38.211 - Section 6.4.1.4 for (int p_index = 0; p_index < N_ap; p_index++) { - /* see TS 38.211 6.4.1.4.2 Sequence generation */ - - n_SRS_cs_i = (n_SRS_cs + (n_SRS_cs_max * (SRS_antenna_port[p_index] - 1000)/N_ap))%n_SRS_cs_max; - alpha_i = 2 * M_PI * ((double)n_SRS_cs_i / (double)n_SRS_cs_max); - - /* for each SRS symbol which should be managed by SRS configuration */ - /* from TS 38.214 6.2.1.1 UE SRS frequency hopping procedure */ - /* A UE may be configured to transmit an SRS resource on adjacent symbols within the last six symbols of a slot, */ - /* where all antenna ports of the SRS resource are mapped to each symbol of the resource */ - - uint8_t l = p_index; - if (l >= N_symb_SRS) { - LOG_E(NR_PHY, "generate_srs: number of antenna ports %d and number of srs symbols %d are different !\n", N_ap, N_symb_SRS); - } - - switch(groupOrSequenceHopping) { - case neitherHopping: - { - f_gh = 0; - v_nu = 0; - break; - } - case groupHopping: - { - uint8_t c_last_index = 8 * (slot_number * N_SYMB_SLOT + l0 + l) + 7; /* compute maximum value of the random sequence */ - uint32_t *c_sequence = calloc(c_last_index+1, sizeof(uint32_t)); - uint32_t cinit = n_ID_SRS/30; - pseudo_random_sequence(c_last_index+1, c_sequence, cinit); - for (int m = 0; m < 8; m++) { - f_gh += c_sequence[8 * (slot_number * N_SYMB_SLOT + l0 + l) + m]< 6 * N_SC_RB) { - uint8_t c_last_index = (slot_number * N_SYMB_SLOT + l0 + l); /* compute maximum value of the random sequence */ - uint32_t *c_sequence = calloc(c_last_index+1, sizeof(uint32_t)); - uint32_t cinit = n_ID_SRS; - pseudo_random_sequence(c_last_index+1, c_sequence, cinit); - v_nu = c_sequence[c_last_index]; - free(c_sequence); - } - else { - v_nu = 0; - } - break; - } - default: - { - LOG_E(NR_PHY, "generate_srs: unknown hopping setting %d !\n", groupOrSequenceHopping); - return (-1); - } - } - - /* u is the sequence-group number defined in section 6.4.1.4.1 */ - u = (f_gh + n_ID_SRS)%U_GROUP_NUMBER; /* 30 */ - - /* TS 38.211 6.4.1.4.3 Mapping to physical resources */ - - if((n_SRS_cs >= n_SRS_cs_max/2)&&(n_SRS_cs < n_SRS_cs_max)&&(N_ap == 4) && ((SRS_antenna_port[p_index] == 1001) || (SRS_antenna_port[p_index] == 1003))) { - K_TC_p = (K_TC_overbar + K_TC/2)%K_TC; - } - else { - K_TC_p = K_TC_overbar; - } - - for (int b = 0; b <= B_SRS; b++) { - N_b = srs_bandwidth_config[C_SRS][b][1]; - if (b_hop >= B_SRS) { - n_b[b] = (4 * n_RRC/m_SRS_b)%N_b; /* frequency hopping is disabled and the frequency position index n_b remains constant */ - } - else { - if (b == b_hop) { - N_b = 1; - } - /* periodicity and offset */ - if (srs_config_pdu->resource_type == aperiodic) { - n_SRS = l/R; - } - else { - int8_t N_slot_frame = frame_parms->slots_per_frame; - n_SRS = ((N_slot_frame*frame_number + slot_number - T_offset)/T_SRS)*(N_symb_SRS/R)+(l/R); - } - - uint16_t product_N_b = 1; /* for b_hop to b-1 */ - for (unsigned int b_prime = b_hop; b_prime < B_SRS; b_prime++) { /* product for b_hop to b-1 */ - if (b_prime != b_hop) { - product_N_b *= srs_bandwidth_config[C_SRS][b_prime][1]; - } - } - - if (N_b & 1) { /* Nb odd */ - F_b = (N_b/2)*(n_SRS/product_N_b); - } - else { /* Nb even */ - uint16_t product_N_b_B_SRS = product_N_b; - product_N_b_B_SRS *= srs_bandwidth_config[C_SRS][B_SRS][1]; /* product for b_hop to b */ - F_b = (N_b/2)*((n_SRS%product_N_b_B_SRS)/product_N_b) + ((n_SRS%product_N_b_B_SRS)/2*product_N_b); - } - - if (b <= b_hop) { - n_b[b] = (4 * n_RRC/m_SRS_b)%N_b; - } - else { - n_b[b] = (F_b + (4 * n_RRC/m_SRS_b))%N_b; - } - } - } - - k_0_overbar_p = n_shift * N_SC_RB + K_TC_p; - - k_0_p = k_0_overbar_p; /* it is the frequency-domain starting position */ - - for (int b = 0; b <= B_SRS; b++) { - k_0_p += K_TC * M_sc_b_SRS * n_b[b]; - } - - subcarrier = subcarrier_offset + k_0_p; - if (subcarrier>frame_parms->ofdm_symbol_size) { - subcarrier -= frame_parms->ofdm_symbol_size; - } - - /* find index of table which is for this srs length */ - unsigned int M_sc_b_SRS_index = 0; - while((ul_allocated_re[M_sc_b_SRS_index] != M_sc_b_SRS) && (M_sc_b_SRS_index < SRS_SB_CONF)){ - M_sc_b_SRS_index++; - } - - if (ul_allocated_re[M_sc_b_SRS_index] != M_sc_b_SRS) { - LOG_E(NR_PHY, "generate_srs: srs uplink allocation %d can not be found! \n", M_sc_b_SRS); - return (-1); - } - -#if 0 - - char output_file[255]; - char sequence_name[255]; - sprintf(output_file, "rv_seq_%d_%d_%d.m", u, v_nu, ul_allocated_re[M_sc_b_SRS_index]); - sprintf(sequence_name, "rv_seq_%d_%d_%d", u, v_nu, ul_allocated_re[M_sc_b_SRS_index]); - write_output(output_file, sequence_name, rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index], ul_allocated_re[M_sc_b_SRS_index], 1, 1); - +#ifdef SRS_DEBUG + LOG_I(NR_PHY,"============ port %d ============\n", p_index); #endif - for (int k=0; k < M_sc_b_SRS; k++) { + uint16_t n_SRS_cs_i = (n_SRS_cs + (n_SRS_cs_max * (SRS_antenna_port[p_index] - 1000)/N_ap))%n_SRS_cs_max; + double alpha_i = 2 * M_PI * ((double)n_SRS_cs_i / (double)n_SRS_cs_max); - double real_shift = cos(alpha_i*k); - double imag_shift = sin(alpha_i*k); - - /* cos(x + y) = cos(x)cos(y) - sin(x)sin(y) */ - double real = ((real_shift*rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k]) - (imag_shift*rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k+1]))/sqrt(N_ap); - /* sin(x + y) = sin(x)cos(y) + cos(x)sin(y) */ - double imag = ((imag_shift*rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k]) + (real_shift*rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k+1]))/sqrt(N_ap); - - int32_t real_amp = ((int32_t)round((double) amp * real)) >> 15; - int32_t imag_amp = ((int32_t)round((double) amp * imag)) >> 15; - -#if 0 - printf("subcarrier %5d srs[%3d] r: %4d i: %4d reference[%d][%d][%d] r: %6d i: %6d\n", subcarrier, k, real_amp, imag_amp, - u, v_nu, M_sc_b_SRS_index, - rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k], - rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k+1]); +#ifdef SRS_DEBUG + LOG_I(NR_PHY,"n_SRS_cs_i = %i\n", n_SRS_cs_i); + LOG_I(NR_PHY,"alpha_i = %f\n", alpha_i); #endif - txptr[subcarrier] = (real_amp & 0xFFFF) + ((imag_amp<<16)&0xFFFF0000); + for (int l_line = 0; l_line < N_symb_SRS; l_line++) { - if(nr_srs_info) { - nr_srs_info->sc_list[nr_srs_info->sc_list_length] = subcarrier; - nr_srs_info->sc_list_length++; +#ifdef SRS_DEBUG + LOG_I(NR_PHY,":::::::: OFDM symbol %d ::::::::\n", l0+l_line); +#endif + + // Set group and sequence numbers (u,v) per OFDM symbol + uint16_t u = 0; + uint16_t v = 0; + switch(groupOrSequenceHopping) { + case neitherHopping: + u = n_ID_SRS%U_GROUP_NUMBER; + v = 0; + break; + case groupHopping: + u = group_number_hopping(slot_number, n_ID_SRS, l0, l_line); + v = 0; + break; + case sequenceHopping: + u = n_ID_SRS%U_GROUP_NUMBER; + v = sequence_number_hopping(slot_number, n_ID_SRS, M_sc_b_SRS, l0, l_line); + break; + default: + LOG_E(NR_PHY, "generate_srs: unknown hopping setting %d !\n", groupOrSequenceHopping); + return -1; } #ifdef SRS_DEBUG - int subcarrier_log = subcarrier-subcarrier_offset; - if(subcarrier_log < 0) { - subcarrier_log = subcarrier_log + frame_parms->ofdm_symbol_size; - } - if( subcarrier_log%12 == 0 ) { - LOG_I(NR_PHY,"------------ %d ------------\n", subcarrier_log/12); - } - LOG_I(NR_PHY,"(%d) \t%i\t%i\n", subcarrier_log, (int16_t)(real_amp&0xFFFF), (int16_t)(imag_amp&0xFFFF)); + LOG_I(NR_PHY,"u = %i\n", u); + LOG_I(NR_PHY,"v = %i\n", v); #endif - subcarrier += (K_TC); /* subcarrier increment */ + // Compute the frequency position index n_b + uint16_t sum_n_b = 0; + for (int b = 0; b <= B_SRS; b++) { + n_b[b] = compute_n_b(frame_number, slot_number, frame_parms->slots_per_frame, N_symb_SRS, B_SRS, + C_SRS, b_hop, n_RRC, R, T_offset, T_SRS, srs_config_pdu->resource_type, l_line, b); + + sum_n_b += n_b[b]; + +#ifdef SRS_DEBUG + LOG_I(NR_PHY,"n_b[%i] = %i\n", b, n_b[b]); +#endif - if (subcarrier >= frame_parms->ofdm_symbol_size) { - subcarrier=subcarrier-frame_parms->ofdm_symbol_size; } - } - /* process next symbol */ - //txptr = txptr + frame_parms->ofdm_symbol_size; - } +#ifdef SRS_DEBUG + LOG_I(NR_PHY,"sum_n_b = %i\n", sum_n_b); +#endif - return (0); + // Compute the frequency-domain starting position + uint8_t K_TC_p = 0; + if((n_SRS_cs >= n_SRS_cs_max/2)&&(n_SRS_cs < n_SRS_cs_max)&&(N_ap == 4) && ((SRS_antenna_port[p_index] == 1001) || (SRS_antenna_port[p_index] == 1003))) { + K_TC_p = (K_TC_overbar + K_TC/2)%K_TC; + } else { + K_TC_p = K_TC_overbar; + } + uint8_t k_l_offset = 0; // If the SRS is configured by the IE SRS-PosResource-r16, the quantity k_l_offset is + // given by TS 38.211 - Table 6.4.1.4.3-2, otherwise k_l_offset = 0. + uint8_t k_0_overbar_p = (n_shift*NR_NB_SC_PER_RB + (K_TC_p+k_l_offset))%K_TC; + uint8_t k_0_p = k_0_overbar_p + K_TC*M_sc_b_SRS*sum_n_b; + nr_srs_info->k_0_p[p_index][l_line] = k_0_p; + +#ifdef SRS_DEBUG + LOG_I(NR_PHY,"K_TC_p = %i\n", K_TC_p); + LOG_I(NR_PHY,"k_0_overbar_p = %i\n", k_0_overbar_p); + LOG_I(NR_PHY,"k_0_p = %i\n", k_0_p); +#endif + + uint16_t subcarrier = subcarrier_offset + k_0_p; + if (subcarrier>frame_parms->ofdm_symbol_size) { + subcarrier -= frame_parms->ofdm_symbol_size; + } + uint16_t l_line_offset = l_line*frame_parms->ofdm_symbol_size; + + // For each port, and for each OFDM symbol, here it is computed and mapped an SRS sequence with M_sc_b_SRS symbols + for (int k = 0; k < M_sc_b_SRS; k++) { + + double shift_real = cos(alpha_i * k); + double shift_imag = sin(alpha_i * k); + int16_t r_overbar_real = rv_ul_ref_sig[u][v][M_sc_b_SRS_index][k<<1]; + int16_t r_overbar_imag = rv_ul_ref_sig[u][v][M_sc_b_SRS_index][(k<<1)+1]; + + // cos(x+y) = cos(x)cos(y) - sin(x)sin(y) + double r_real = (shift_real*r_overbar_real - shift_imag*r_overbar_imag) / sqrt_N_ap; + + // sin(x+y) = sin(x)cos(y) + cos(x)sin(y) + double r_imag = (shift_imag*r_overbar_real + shift_real*r_overbar_imag) / sqrt_N_ap; + + int32_t r_real_amp = ((int32_t) round((double) amp * r_real)) >> 15; + int32_t r_imag_amp = ((int32_t) round((double) amp * r_imag)) >> 15; + +#ifdef SRS_DEBUG + int subcarrier_log = subcarrier-subcarrier_offset; + if(subcarrier_log < 0) { + subcarrier_log = subcarrier_log + frame_parms->ofdm_symbol_size; + } + if(subcarrier_log%12 == 0) { + LOG_I(NR_PHY,"------------ %d ------------\n", subcarrier_log/12); + } + LOG_I(NR_PHY,"(%d) \t%i\t%i\n", subcarrier_log, (int16_t)(r_real_amp&0xFFFF), (int16_t)(r_imag_amp&0xFFFF)); +#endif + + txdataF[p_index][symbol_offset+l_line_offset+subcarrier] = (r_real_amp & 0xFFFF) + ((r_imag_amp<<16)&0xFFFF0000); + + // Subcarrier increment + subcarrier += K_TC; + if (subcarrier >= frame_parms->ofdm_symbol_size) { + subcarrier=subcarrier-frame_parms->ofdm_symbol_size; + } + + } // for (int k = 0; k < M_sc_b_SRS; k++) + } // for (int l_line = 0; l_line < N_symb_SRS; l_line++) + } // for (int p_index = 0; p_index < N_ap; p_index++) + + return 0; } /******************************************************************* @@ -457,7 +472,7 @@ int ue_srs_procedures_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gN NR_DL_FRAME_PARMS *frame_parms = &(ue->frame_parms); uint16_t symbol_offset = (frame_parms->symbols_per_slot - 1 - srs_config_pdu->time_start_position)*frame_parms->ofdm_symbol_size; - if (generate_srs_nr(srs_config_pdu, frame_parms, &ue->common_vars.txdataF[gNB_id][symbol_offset], ue->nr_srs_info, + if (generate_srs_nr(srs_config_pdu, frame_parms, ue->common_vars.txdataF, symbol_offset, ue->nr_srs_info, AMP, proc->frame_tx, proc->nr_slot_tx) == 0) { return 0; } else { diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h index e43bbe4934..2c3d6d266c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h +++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h @@ -131,11 +131,19 @@ EXTERN const uint16_t srs_periodicity[SRS_PERIODICITY] #endif ; +// TS 38.211 - Table 6.4.1.4.2-1 +EXTERN const uint16_t srs_max_number_cs[3] +#ifdef INIT_VARIABLES_SRS_MODULATION_NR_H + = {8, 12, 6} +#endif +; + /*************** FUNCTIONS *****************************************/ /** \brief This function generates the sounding reference symbol (SRS) for the uplink according to 38.211 6.4.1.4 Sounding reference signal @param frame_parms NR DL Frame parameters @param txdataF pointer to the frequency domain TX signal + @param symbol_offset symbol offset added in txdataF @param nr_srs_info pointer to the srs info structure @param amp amplitude of generated signal @param frame_number frame number @@ -144,11 +152,12 @@ EXTERN const uint16_t srs_periodicity[SRS_PERIODICITY] int generate_srs_nr(nfapi_nr_srs_pdu_t *srs_config_pdu, NR_DL_FRAME_PARMS *frame_parms, - int32_t *txptr, + int32_t **txdataF, + uint16_t symbol_offset, nr_srs_info_t *nr_srs_info, int16_t amp, - int frame_number, - int slot_number); + frame_t frame_number, + slot_t slot_number); /** \brief This function checks for periodic srs if srs should be transmitted in this slot * @param p_SRS_Resource pointer to active resource diff --git a/openair1/PHY/TOOLS/8bit_rxdemux.c b/openair1/PHY/TOOLS/8bit_rxdemux.c deleted file mode 100644 index 030be47b5d..0000000000 --- a/openair1/PHY/TOOLS/8bit_rxdemux.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - - -void bit8_rxdemux(int length,int offset) -{ - - int i; - short *rx1_ptr = (short *)&PHY_vars->rx_vars[1].RX_DMA_BUFFER[offset]; - short *rx0_ptr = (short *)&PHY_vars->rx_vars[0].RX_DMA_BUFFER[offset]; - char *rx0_ptr2 = (char *)(&PHY_vars->rx_vars[0].RX_DMA_BUFFER[offset]); - // short tmp; - short r0,i0,r1,i1; - - // printf("demuxing: %d,%d\n",length,offset); - - // printf("%x %x\n",PHY_vars->chsch_data[0].CHSCH_f_sync[0], PHY_vars->chsch_data[0].CHSCH_f_sync[1]); - - for (i=0; ichsch_data[0].CHSCH_f_sync[0], PHY_vars->chsch_data[0].CHSCH_f_sync[1]); - -} diff --git a/openair1/PHY/TOOLS/8bit_txmux.c b/openair1/PHY/TOOLS/8bit_txmux.c deleted file mode 100644 index b103bc9c5c..0000000000 --- a/openair1/PHY/TOOLS/8bit_txmux.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "PHY/types.h" -#include "PHY/defs.h" -#include "PHY/extern.h" - - -void bit8_txmux(int length,int offset) -{ - - int i; - short *dest,*dest2; - - - - - for (i=0; itx_vars[0].TX_DMA_BUFFER[i+offset]; - dest2 = (short *)&PHY_vars->tx_vars[1].TX_DMA_BUFFER[i+offset]; - - ((char *)dest)[0] = (char)(dest[0]>>BIT8_TX_SHIFT); - ((char *)dest)[1] = (char)(dest[1]>>BIT8_TX_SHIFT); - ((char *)dest)[2] = (char)(dest2[0]>>BIT8_TX_SHIFT); - ((char *)dest)[3] = (char)(dest2[1]>>BIT8_TX_SHIFT); - } - - -} diff --git a/openair1/PHY/TOOLS/cadd_sv.c b/openair1/PHY/TOOLS/cadd_sv.c deleted file mode 100644 index 56dcb71847..0000000000 --- a/openair1/PHY/TOOLS/cadd_sv.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "defs.h" - -static __m128i alpha_128 __attribute__ ((aligned(16))); -static __m128i shift __attribute__ ((aligned(16))); - -int add_cpx_vector(short *x, - short *alpha, - short *y, - unsigned int N) -{ - unsigned int i; // loop counter - - __m128i *x_128; - __m128i *y_128; - - x_128 = (__m128i *)&x[0]; - y_128 = (__m128i *)&y[0]; - - alpha_128 = _mm_set1_epi32(*((int*)alpha)); - - // we compute 4 cpx multiply for each loop - for(i=0; i<(N>>3); i++) { - y_128[0] = _mm_adds_epi16(alpha_128, x_128[0]); - y_128[1] = _mm_adds_epi16(alpha_128, x_128[1]); - y_128[2] = _mm_adds_epi16(alpha_128, x_128[2]); - y_128[3] = _mm_adds_epi16(alpha_128, x_128[3]); - - - x_128+=4; - y_128 +=4; - - } - - return (0); -} - -int add_vector32_scalar(short *x, - int alpha, - short *y, - unsigned int N) -{ - unsigned int i; // loop counter - - __m128i *x_128; - __m128i *y_128; - - x_128 = (__m128i *)&x[0]; - y_128 = (__m128i *)&y[0]; - - alpha_128 = _mm_setr_epi32(alpha,0,alpha,0); - - // we compute 4 cpx multiply for each loop - for(i=0; i<(N>>3); i++) { - y_128[0] = _mm_add_epi32(alpha_128, x_128[0]); - y_128[1] = _mm_add_epi32(alpha_128, x_128[1]); - y_128[2] = _mm_add_epi32(alpha_128, x_128[2]); - y_128[3] = _mm_add_epi32(alpha_128, x_128[3]); - - - x_128+=4; - y_128 +=4; - - } - - return (0); -} - - -int add_real_vector64_scalar(short *x, - long long int a, - short *y, - unsigned int N) -{ - unsigned int i; // loop counter - - __m128i *x_128; - __m128i *y_128; - - x_128 = (__m128i *)&x[0]; - y_128 = (__m128i *)&y[0]; - - alpha_128 = _mm_set1_epi64((__m64) a); - - // we compute 4 cpx multiply for each loop - for(i=0; i<(N>>3); i++) { - y_128[0] = _mm_add_epi64(alpha_128, x_128[0]); - y_128[1] = _mm_add_epi64(alpha_128, x_128[1]); - y_128[2] = _mm_add_epi64(alpha_128, x_128[2]); - y_128[3] = _mm_add_epi64(alpha_128, x_128[3]); - - - x_128+=4; - y_128+=4; - - } - - return(0); -} - - -#ifdef MAIN -#include - -main () -{ - - short input[256] __attribute__((aligned(16))); - short output[256] __attribute__((aligned(16))); - - int i; - c16_t alpha; - - Zero_Buffer(output,256*2); - - input[0] = 100; - input[1] = 200; - input[2] = 100; - input[3] = 200; - input[4] = 1234; - input[5] = -1234; - input[6] = 1234; - input[7] = -1234; - input[8] = 100; - input[9] = 200; - input[10] = 100; - input[11] = 200; - input[12] = 1000; - input[13] = 2000; - input[14] = 1000; - input[15] = 2000; - - alpha.r = 10; - alpha.i = -10; - - add_cpx_vector(input,(short*) &alpha,input,8); - - for (i=0; i<16; i+=2) - printf("output[%d] = %d + %d i\n",i,input[i],input[i+1]); - -} - -#endif //MAIN diff --git a/openair1/PHY/TOOLS/cadd_vv.c b/openair1/PHY/TOOLS/cadd_vv.c index 08bf514cb3..88a2bd9814 100644 --- a/openair1/PHY/TOOLS/cadd_vv.c +++ b/openair1/PHY/TOOLS/cadd_vv.c @@ -23,153 +23,6 @@ #include "tools_defs.h" -int add_vector16(short *x, - short *y, - short *z, - unsigned int N) -{ - unsigned int i; // loop counter - - __m128i *x_128; - __m128i *y_128; - __m128i *z_128; - - x_128 = (__m128i *)&x[0]; - y_128 = (__m128i *)&y[0]; - z_128 = (__m128i *)&z[0]; - - - for(i=0; i<(N>>5); i++) { - /* - printf("i = %d\n",i); - print_shorts(x_128[0],"x[0]="); - print_shorts(y_128[0],"y[0]="); - */ - - z_128[0] = _mm_adds_epi16(x_128[0],y_128[0]); - /* - print_shorts(z_128[0],"z[0]="); - - print_shorts(x_128[1],"x[1]="); - print_shorts(y_128[1],"y[1]="); - */ - - z_128[1] = _mm_adds_epi16(x_128[1],y_128[1]); - /* - print_shorts(z_128[1],"z[1]="); - - print_shorts(x_128[2],"x[2]="); - print_shorts(y_128[2],"y[2]="); - */ - - z_128[2] = _mm_adds_epi16(x_128[2],y_128[2]); - /* - print_shorts(z_128[2],"z[2]="); - - print_shorts(x_128[3],"x[3]="); - print_shorts(y_128[3],"y[3]="); - */ - - z_128[3] = _mm_adds_epi16(x_128[3],y_128[3]); - /* - print_shorts(z_128[3],"z[3]="); - */ - - - - - - x_128 +=4; - y_128 +=4; - z_128 +=4; - - } - - _mm_empty(); - _m_empty(); - - return(0); -} - -/* -print_shorts64(__m64 x,char *s) { - - printf("%s ",s); - printf("%d %d %d %d\n",((short *)&x)[0],((short *)&x)[1],((short *)&x)[2],((short *)&x)[3]); - -} -*/ - -int add_vector16_64(short *x, - short *y, - short *z, - unsigned int N) -{ - unsigned int i; // loop counter - - __m64 *x_64; - __m64 *y_64; - __m64 *z_64; - - x_64 = (__m64 *)&x[0]; - y_64 = (__m64 *)&y[0]; - z_64 = (__m64 *)&z[0]; - - - for(i=0; i<(N>>2); i++) { - /* - printf("i = %d\n",i); - print_shorts64(x_64[i],"x[i]="); - print_shorts64(y_64[i],"y[i]="); - */ - - z_64[i] = _mm_adds_pi16(x_64[i],y_64[i]); - /* - print_shorts64(z_64[i],"z[i]="); - */ - - - } - - _mm_empty(); - _m_empty(); - return(0); -} - -int add_cpx_vector32(short *x, - short *y, - short *z, - unsigned int N) -{ - unsigned int i; // loop counter - - __m128i *x_128; - __m128i *y_128; - __m128i *z_128; - - x_128 = (__m128i *)&x[0]; - y_128 = (__m128i *)&y[0]; - z_128 = (__m128i *)&z[0]; - - - for(i=0; i<(N>>3); i++) { - z_128[0] = _mm_add_epi32(x_128[0],y_128[0]); - z_128[1] = _mm_add_epi32(x_128[1],y_128[1]); - z_128[2] = _mm_add_epi32(x_128[2],y_128[2]); - z_128[3] = _mm_add_epi32(x_128[3],y_128[3]); - - - x_128+=4; - y_128 +=4; - z_128 +=4; - - } - - _mm_empty(); - _m_empty(); - return(0); -} - int32_t sub_cpx_vector16(int16_t *x, int16_t *y, int16_t *z, @@ -201,73 +54,6 @@ int32_t sub_cpx_vector16(int16_t *x, -int add_real_vector64(short *x, - short* y, - short *z, - unsigned int N) -{ - unsigned int i; // loop counter - - __m128i *x_128; - __m128i *y_128; - __m128i *z_128; - - x_128 = (__m128i *)&x[0]; - y_128 = (__m128i *)&y[0]; - z_128 = (__m128i *)&z[0]; - - for(i=0; i<(N>>3); i++) { - z_128[0] = _mm_add_epi64(x_128[0], y_128[0]); - z_128[1] = _mm_add_epi64(x_128[1], y_128[1]); - z_128[2] = _mm_add_epi64(x_128[2], y_128[2]); - z_128[3] = _mm_add_epi64(x_128[3], y_128[3]); - - - x_128+=4; - y_128+=4; - z_128+=4; - - } - - _mm_empty(); - _m_empty(); - return(0); -} - -int sub_real_vector64(short *x, - short* y, - short *z, - unsigned int N) -{ - unsigned int i; // loop counter - - __m128i *x_128; - __m128i *y_128; - __m128i *z_128; - - x_128 = (__m128i *)&x[0]; - y_128 = (__m128i *)&y[0]; - z_128 = (__m128i *)&z[0]; - - for(i=0; i<(N>>3); i++) { - z_128[0] = _mm_sub_epi64(x_128[0], y_128[0]); - z_128[1] = _mm_sub_epi64(x_128[1], y_128[1]); - z_128[2] = _mm_sub_epi64(x_128[2], y_128[2]); - z_128[3] = _mm_sub_epi64(x_128[3], y_128[3]); - - - x_128+=4; - y_128+=4; - z_128+=4; - - } - - _mm_empty(); - _m_empty(); - return(0); -} - - #ifdef MAIN #include @@ -280,7 +66,7 @@ main () int i; c16_t alpha; - Zero_Buffer(output,256*2); + memset(output,0,256*2); input[0] = 100; input[1] = 200; diff --git a/openair1/PHY/TOOLS/cmult_sv.c b/openair1/PHY/TOOLS/cmult_sv.c index a9d502b9eb..a596446a44 100644 --- a/openair1/PHY/TOOLS/cmult_sv.c +++ b/openair1/PHY/TOOLS/cmult_sv.c @@ -22,28 +22,6 @@ #include "PHY/sse_intrin.h" #include "tools_defs.h" -#if defined(__x86_64__) || defined(__i386__) -#define simd_q15_t __m128i -#define simdshort_q15_t __m64 -#define shiftright_int16(a,shift) _mm_srai_epi16(a,shift) -#define set1_int16(a) _mm_set1_epi16(a) -#define mulhi_int16(a,b) _mm_slli_epi16(_mm_mulhi_epi16(a,b),1) -#define mulhi_s1_int16(a,b) _mm_slli_epi16(_mm_mulhi_epi16(a,b),2) -#define adds_int16(a,b) _mm_adds_epi16(a,b) -#define mullo_int16(a,b) _mm_mullo_epi16(a,b) -#elif defined(__arm__) -#define simd_q15_t int16x8_t -#define simdshort_q15_t int16x4_t -#define shiftright_int16(a,shift) vshrq_n_s16(a,shift) -#define set1_int16(a) vdupq_n_s16(a) -#define mulhi_int16(a,b) vqdmulhq_s16(a,b) -#define mulhi_s1_int16(a,b) vshlq_n_s16(vqdmulhq_s16(a,b),1) -#define adds_int16(a,b) vqaddq_s16(a,b) -#define mullo_int16(a,b) vmulq_s16(a,b) -#define _mm_empty() -#define _m_empty() -#endif - void multadd_complex_vector_real_scalar(int16_t *x, int16_t alpha, @@ -85,250 +63,163 @@ void multadd_real_vector_complex_scalar(int16_t *x, uint32_t i; // do 8 multiplications at a time - simd_q15_t alpha_r_128,alpha_i_128,yr,yi,*x_128=(simd_q15_t*)x,*y_128=(simd_q15_t*)y; - int j; + simd_q15_t alpha_r_128, alpha_i_128, yr, yi, *x_128 = (simd_q15_t *)x, *y_128 = (simd_q15_t *)y; // printf("alpha = %d,%d\n",alpha[0],alpha[1]); alpha_r_128 = set1_int16(alpha[0]); alpha_i_128 = set1_int16(alpha[1]); - - j=0; - for (i=0; i>3; i++) { yr = mulhi_s1_int16(alpha_r_128,x_128[i]); yi = mulhi_s1_int16(alpha_i_128,x_128[i]); #if defined(__x86_64__) || defined(__i386__) - y_128[j] = _mm_adds_epi16(y_128[j],_mm_unpacklo_epi16(yr,yi)); - j++; - y_128[j] = _mm_adds_epi16(y_128[j],_mm_unpackhi_epi16(yr,yi)); - j++; + const simd_q15_t tmp = _mm_loadu_si128(y_128); + _mm_storeu_si128(y_128++, _mm_adds_epi16(tmp, _mm_unpacklo_epi16(yr, yi))); + const simd_q15_t tmp2 = _mm_loadu_si128(y_128); + _mm_storeu_si128(y_128++, _mm_adds_epi16(tmp2, _mm_unpackhi_epi16(yr, yi))); #elif defined(__arm__) int16x8x2_t yint; yint = vzipq_s16(yr,yi); - y_128[j] = adds_int16(y_128[j],yint.val[0]); + *y_128 = adds_int16(*y_128, yint.val[0]); j++; - y_128[j] = adds_int16(y_128[j],yint.val[1]); - + *y_128 = adds_int16(*y_128, yint.val[1]); + j++; #endif } - - _mm_empty(); - _m_empty(); - } -void multadd_real_four_symbols_vector_complex_scalar(int16_t *x, - int16_t *alpha, - int16_t *y) -{ - // do 8 multiplications at a time - simd_q15_t alpha_r_128,alpha_i_128,yr,yi,*x_128=(simd_q15_t*)x; - simd_q15_t y_128; - y_128 = _mm_loadu_si128((simd_q15_t*)y); - - alpha_r_128 = set1_int16(alpha[0]); - alpha_i_128 = set1_int16(alpha[1]); - - - yr = mulhi_s1_int16(alpha_r_128,x_128[0]); - yi = mulhi_s1_int16(alpha_i_128,x_128[0]); - y_128 = _mm_adds_epi16(y_128,_mm_unpacklo_epi16(yr,yi)); - y_128 = _mm_adds_epi16(y_128,_mm_unpackhi_epi16(yr,yi)); - - _mm_storeu_si128((simd_q15_t*)y, y_128); - - _mm_empty(); - _m_empty(); - -} -#ifdef __AVX2__ void rotate_cpx_vector(c16_t *x, - c16_t *alpha, - c16_t *y, - uint32_t N, - uint16_t output_shift) + c16_t *alpha, + c16_t *y, + uint32_t N, + uint16_t output_shift) { - // Multiply elementwise two complex vectors of N elements - // x - input 1 in the format |Re0 Im0 |,......,|Re(N-1) Im(N-1)| - // We assume x1 with a dynamic of 15 bit maximum - // - // alpha - input 2 in the format |Re0 Im0| - // We assume x2 with a dynamic of 15 bit maximum - // - // y - output in the format |Re0 Im0|,......,|Re(N-1) Im(N-1)| - // - // N - the size f the vectors (this function does N cpx mpy. WARNING: N>=4; - // - // log2_amp - increase the output amplitude by a factor 2^log2_amp (default is 0) - // WARNING: log2_amp>0 can cause overflow!! - - uint32_t i; // loop counter - - - simd_q15_t *y_128,alpha_128; - int32_t *xd=(int32_t *)x; - -#if defined(__x86_64__) || defined(__i386__) - __m128i shift = _mm_cvtsi32_si128(output_shift); - register simd_q15_t m0,m1,m2,m3; - - ((int16_t *)&alpha_128)[0] = alpha->r; - ((int16_t *)&alpha_128)[1] = -alpha->i; - ((int16_t *)&alpha_128)[2] = alpha->i; - ((int16_t *)&alpha_128)[3] = alpha->r; - ((int16_t *)&alpha_128)[4] = alpha->r; - ((int16_t *)&alpha_128)[5] = -alpha->i; - ((int16_t *)&alpha_128)[6] = alpha->i; - ((int16_t *)&alpha_128)[7] = alpha->r; -#elif defined(__arm__) - int32x4_t shift; - int32x4_t ab_re0,ab_re1,ab_im0,ab_im1,re32,im32; - int16_t reflip[8] __attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; - int32x4x2_t xtmp; - - ((int16_t *)&alpha_128)[0] = alpha->r; - ((int16_t *)&alpha_128)[1] = alpha->i; - ((int16_t *)&alpha_128)[2] = alpha->r; - ((int16_t *)&alpha_128)[3] = alpha->i; - ((int16_t *)&alpha_128)[4] = alpha->r; - ((int16_t *)&alpha_128)[5] = alpha->i; - ((int16_t *)&alpha_128)[6] = alpha->r; - ((int16_t *)&alpha_128)[7] = alpha->i; - int16x8_t bflip = vrev32q_s16(alpha_128); - int16x8_t bconj = vmulq_s16(alpha_128,*(int16x8_t *)reflip); - shift = vdupq_n_s32(-output_shift); + // multiply a complex vector with a complex value (alpha) + // stores result in y + // N is the number of complex numbers + // output_shift reduces the result of the multiplication by this number of bits + //AssertFatal(N%8==0, "To be developped"); +#ifdef __AVX2__ + if ( (intptr_t)x%32 == 0 && !(intptr_t)y%32 == 0 && __builtin_cpu_supports("avx2")) { + // output is 32 bytes aligned, but not the input + + const c16_t for_re={alpha->r, -alpha->i}; + __m256i const alpha_for_real = _mm256_set1_epi32(*(uint32_t*)&for_re); + const c16_t for_im={alpha->i, alpha->r}; + __m256i const alpha_for_im= _mm256_set1_epi32(*(uint32_t*)&for_im); + __m256i const perm_mask = + _mm256_set_epi8(31,30,23,22,29,28,21,20,27,26,19,18,25,24,17,16, + 15,14,7,6,13,12,5,4,11,10,3,2,9,8,1,0); + __m256i* xd= (__m256i*)x; + const __m256i *end=xd+N/8; + for( __m256i* yd = (__m256i *)y; xd=4; + // + // log2_amp - increase the output amplitude by a factor 2^log2_amp (default is 0) + // WARNING: log2_amp>0 can cause overflow!! + + uint32_t i; // loop counter - for(i=0; i>2; i++) { + simd_q15_t *y_128,alpha_128; + int32_t *xd=(int32_t *)x; + #if defined(__x86_64__) || defined(__i386__) - m0 = _mm_setr_epi32(xd[0],xd[0],xd[1],xd[1]); - m1 = _mm_setr_epi32(xd[2],xd[2],xd[3],xd[3]); - m2 = _mm_madd_epi16(m0,alpha_128); //complex multiply. result is 32bit [Re Im Re Im] - m3 = _mm_madd_epi16(m1,alpha_128); //complex multiply. result is 32bit [Re Im Re Im] - m2 = _mm_sra_epi32(m2,shift); // shift right by shift in order to compensate for the input amplitude - m3 = _mm_sra_epi32(m3,shift); // shift right by shift in order to compensate for the input amplitude + __m128i shift = _mm_cvtsi32_si128(output_shift); + register simd_q15_t m0,m1,m2,m3; - y_128[0] = _mm_packs_epi32(m2,m3); // pack in 16bit integers with saturation [re im re im re im re im] - //print_ints("y_128[0]=", &y_128[0]); + ((int16_t *)&alpha_128)[0] = alpha->r; + ((int16_t *)&alpha_128)[1] = -alpha->i; + ((int16_t *)&alpha_128)[2] = alpha->i; + ((int16_t *)&alpha_128)[3] = alpha->r; + ((int16_t *)&alpha_128)[4] = alpha->r; + ((int16_t *)&alpha_128)[5] = -alpha->i; + ((int16_t *)&alpha_128)[6] = alpha->i; + ((int16_t *)&alpha_128)[7] = alpha->r; +#elif defined(__arm__) + int32x4_t shift; + int32x4_t ab_re0,ab_re1,ab_im0,ab_im1,re32,im32; + int16_t reflip[8] __attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; + int32x4x2_t xtmp; + + ((int16_t *)&alpha_128)[0] = alpha->r; + ((int16_t *)&alpha_128)[1] = alpha->i; + ((int16_t *)&alpha_128)[2] = alpha->r; + ((int16_t *)&alpha_128)[3] = alpha->i; + ((int16_t *)&alpha_128)[4] = alpha->r; + ((int16_t *)&alpha_128)[5] = alpha->i; + ((int16_t *)&alpha_128)[6] = alpha->r; + ((int16_t *)&alpha_128)[7] = alpha->i; + int16x8_t bflip = vrev32q_s16(alpha_128); + int16x8_t bconj = vmulq_s16(alpha_128,*(int16x8_t *)reflip); + shift = vdupq_n_s32(-output_shift); +#endif + y_128 = (simd_q15_t *) y; + + + for(i=0; i>2; i++) { +#if defined(__x86_64__) || defined(__i386__) + m0 = _mm_setr_epi32(xd[0],xd[0],xd[1],xd[1]); + m1 = _mm_setr_epi32(xd[2],xd[2],xd[3],xd[3]); + m2 = _mm_madd_epi16(m0,alpha_128); //complex multiply. result is 32bit [Re Im Re Im] + m3 = _mm_madd_epi16(m1,alpha_128); //complex multiply. result is 32bit [Re Im Re Im] + m2 = _mm_sra_epi32(m2,shift); // shift right by shift in order to compensate for the input amplitude + m3 = _mm_sra_epi32(m3,shift); // shift right by shift in order to compensate for the input amplitude + + y_128[0] = _mm_packs_epi32(m2,m3); // pack in 16bit integers with saturation [re im re im re im re im] + //print_ints("y_128[0]=", &y_128[0]); #elif defined(__arm__) - ab_re0 = vmull_s16(((int16x4_t*)xd)[0],((int16x4_t*)&bconj)[0]); - ab_re1 = vmull_s16(((int16x4_t*)xd)[1],((int16x4_t*)&bconj)[1]); - ab_im0 = vmull_s16(((int16x4_t*)xd)[0],((int16x4_t*)&bflip)[0]); - ab_im1 = vmull_s16(((int16x4_t*)xd)[1],((int16x4_t*)&bflip)[1]); - re32 = vshlq_s32(vcombine_s32(vpadd_s32(((int32x2_t*)&ab_re0)[0],((int32x2_t*)&ab_re0)[1]), - vpadd_s32(((int32x2_t*)&ab_re1)[0],((int32x2_t*)&ab_re1)[1])), - shift); - im32 = vshlq_s32(vcombine_s32(vpadd_s32(((int32x2_t*)&ab_im0)[0],((int32x2_t*)&ab_im0)[1]), - vpadd_s32(((int32x2_t*)&ab_im1)[0],((int32x2_t*)&ab_im1)[1])), - shift); + ab_re0 = vmull_s16(((int16x4_t*)xd)[0],((int16x4_t*)&bconj)[0]); + ab_re1 = vmull_s16(((int16x4_t*)xd)[1],((int16x4_t*)&bconj)[1]); + ab_im0 = vmull_s16(((int16x4_t*)xd)[0],((int16x4_t*)&bflip)[0]); + ab_im1 = vmull_s16(((int16x4_t*)xd)[1],((int16x4_t*)&bflip)[1]); + re32 = vshlq_s32(vcombine_s32(vpadd_s32(((int32x2_t*)&ab_re0)[0],((int32x2_t*)&ab_re0)[1]), + vpadd_s32(((int32x2_t*)&ab_re1)[0],((int32x2_t*)&ab_re1)[1])), + shift); + im32 = vshlq_s32(vcombine_s32(vpadd_s32(((int32x2_t*)&ab_im0)[0],((int32x2_t*)&ab_im0)[1]), + vpadd_s32(((int32x2_t*)&ab_im1)[0],((int32x2_t*)&ab_im1)[1])), + shift); - xtmp = vzipq_s32(re32,im32); + xtmp = vzipq_s32(re32,im32); - y_128[0] = vcombine_s16(vmovn_s32(xtmp.val[0]),vmovn_s32(xtmp.val[1])); + y_128[0] = vcombine_s16(vmovn_s32(xtmp.val[0]),vmovn_s32(xtmp.val[1])); #endif - xd+=4; - y_128+=1; + xd+=4; + y_128+=1; + } } - - - _mm_empty(); - _m_empty(); - - return; } -#endif -/* -int mult_vector32_scalar(int16_t *x1, - int x2, - int16_t *y, - uint32_t N) - -{ - // Multiply elementwise two real vectors of N elements - // x1 - input 1 in the format |Re(0) xxx Re(1) xxx|,......,|Re(N-2) xxx Re(N-1) xxx| - // We assume x1 with a dinamic of 31 bit maximum - // - // x1 - input 2 - // - // y - output in the format |Re0 (64bit) |,......,|Re(N-1) (64bit)| - // - // N - the size f the vectors (this function does N cpx mpy. WARNING: N>=4; - // - - uint32_t i; // loop counter - - __m128i *x1_128; - __m128i x2_128; - __m128i *y_128; - - - x1_128 = (__m128i *)&x1[0]; - x2_128 = _mm_setr_epi32(x2,0,x2,0); - y_128 = (__m128i *)&y[0]; - - - // we compute 4 cpx multiply for each loop - for(i=0; i<(N>>3); i++) { - y_128[0] = _mm_mul_epu32(x1_128[0],x2_128); - y_128[1] = _mm_mul_epu32(x1_128[1],x2_128); - y_128[2] = _mm_mul_epu32(x1_128[2],x2_128); - y_128[3] = _mm_mul_epu32(x1_128[3],x2_128); - - - x1_128+=4; - y_128 +=4; - } - - - _mm_empty(); - _m_empty(); - - return(0); -} -*/ - -int complex_conjugate(int16_t *x1, - int16_t *y, - uint32_t N) - -{ - uint32_t i; // loop counter - - simd_q15_t *x1_128; - simd_q15_t *y_128; - int16_t x2[8] __attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; - simd_q15_t *x2_128 = (simd_q15_t*)&x2[0]; - x1_128 = (simd_q15_t *)&x1[0]; - y_128 = (simd_q15_t *)&y[0]; - - - // we compute 4 cpx multiply for each loop - for(i=0; i<(N>>3); i++) { - y_128[0] = mullo_int16(x1_128[0],*x2_128); - y_128[1] = mullo_int16(x1_128[1],*x2_128); - y_128[2] = mullo_int16(x1_128[2],*x2_128); - y_128[3] = mullo_int16(x1_128[3],*x2_128); - - - x1_128+=4; - y_128 +=4; - } - - - _mm_empty(); - _m_empty(); - - return(0); -} - #ifdef MAIN #define L 8 diff --git a/openair1/PHY/TOOLS/memory_routines.c b/openair1/PHY/TOOLS/memory_routines.c deleted file mode 100644 index cef9928988..0000000000 --- a/openair1/PHY/TOOLS/memory_routines.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "PHY/sse_intrin.h" - -void Zero_Buffer(void *buf,unsigned int length) -{ - // zeroes the mmx_t buffer 'buf' starting from buf[0] to buf[length-1] in bytes - int i; - register __m64 mm0; - __m64 *mbuf = (__m64 *)buf; - - // length>>=3; // put length in quadwords - mm0 = _m_pxor(mm0,mm0); // clear the register - - for(i=0; i>3; i++) // for each i - mbuf[i] = mm0; // put 0 in buf[i] - - _mm_empty(); -} - -void mmxcopy(void *dest,void *src,int size) -{ - - // copy size bytes from src to dest - register int i; - register __m64 mm0; - __m64 *mmsrc = (__m64 *)src, *mmdest= (__m64 *)dest; - - - - for (i=0; i>3; i++) { - mm0 = mmsrc[i]; - mmdest[i] = mm0; - } - - _mm_empty(); -} - -void Zero_Buffer_nommx(void *buf,unsigned int length) -{ - - int i; - - for (i=0; i>2; i++) - ((int *)buf)[i] = 0; - -} - diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index d4b28361d2..73f9324570 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -323,7 +323,7 @@ static void timeSignal (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy */ static void timeResponse (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) { - const int len=2*p->gNB->frame_parms.ofdm_symbol_size; + const int len=p->gNB->frame_parms.ofdm_symbol_size; float *values, *time; oai_xygraph_getbuff(graph, &time, &values, len, 0); const int ant=0; // display antenna 0 for each UE @@ -363,8 +363,10 @@ static void frequencyResponse (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU */ static void puschLLR (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) { - //int Qm = 2; - int coded_bits_per_codeword =3*8*6144+12; // (8*((3*8*6144)+12)); // frame_parms->N_RB_UL*12*Qm*frame_parms->symbols_per_tti; + NR_DL_FRAME_PARMS *frame_parms=&p->gNB->frame_parms; + int num_re = frame_parms->N_RB_UL*12*frame_parms->symbols_per_slot; + int Qm = 2; + int coded_bits_per_codeword = num_re*Qm; for (int ue=0; uegNB->pusch_vars && diff --git a/openair1/PHY/TOOLS/oai_dfts.c b/openair1/PHY/TOOLS/oai_dfts.c index c2b6a55210..cbedfd815a 100644 --- a/openair1/PHY/TOOLS/oai_dfts.c +++ b/openair1/PHY/TOOLS/oai_dfts.c @@ -2575,7 +2575,6 @@ const static int16_t tw64c[96] __attribute__((aligned(32))) = { #define simd_q15_t __m128i #define simdshort_q15_t __m64 #define shiftright_int16(a,shift) _mm_srai_epi16(a,shift) -#define set1_int16(a) _mm_set1_epi16(a); #define mulhi_int16(a,b) _mm_mulhrs_epi16 (a,b) #ifdef __AVX2__ #define simd256_q15_t __m256i diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h index c471978f46..6b81575fee 100644 --- a/openair1/PHY/TOOLS/tools_defs.h +++ b/openair1/PHY/TOOLS/tools_defs.h @@ -29,46 +29,199 @@ */ -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include #include "PHY/sse_intrin.h" #include "common/utils/assertions.h" +#if defined(__x86_64__) || defined(__i386__) +#define simd_q15_t __m128i +#define simdshort_q15_t __m64 +#define shiftright_int16(a,shift) _mm_srai_epi16(a,shift) +#define set1_int16(a) _mm_set1_epi16(a) +#define mulhi_int16(a,b) _mm_mulhrs_epi16 (a,b) +#define mulhi_s1_int16(a,b) _mm_slli_epi16(_mm_mulhi_epi16(a,b),2) +#define adds_int16(a,b) _mm_adds_epi16(a,b) +#define mullo_int16(a,b) _mm_mullo_epi16(a,b) +#elif defined(__arm__) +#define simd_q15_t int16x8_t +#define simdshort_q15_t int16x4_t +#define shiftright_int16(a,shift) vshrq_n_s16(a,shift) +#define set1_int16(a) vdupq_n_s16(a) +#define mulhi_int16(a,b) vqdmulhq_s16(a,b) +#define mulhi_s1_int16(a,b) vshlq_n_s16(vqdmulhq_s16(a,b),1) +#define adds_int16(a,b) vqaddq_s16(a,b) +#define mullo_int16(a,b) vmulq_s16(a,b) +#define _mm_empty() +#define _m_empty() +#endif + +#ifdef __cplusplus +extern "C" { +#endif + #define CEILIDIV(a,b) ((a+b-1)/b) #define ROUNDIDIV(a,b) (((a<<1)+b)/(b<<1)) -typedef struct complexd { - double r; - double i; -} cd_t; + typedef struct complexd { + double r; + double i; + } cd_t; -typedef struct complexf { - float r; - float i; -} cf_t; + typedef struct complexf { + float r; + float i; + } cf_t; -typedef struct complex16 { - int16_t r; - int16_t i; -} c16_t; + typedef struct complex16 { + int16_t r; + int16_t i; + } c16_t; -typedef struct complex32 { - int32_t r; - int32_t i; -} c32_t; + typedef struct complex32 { + int32_t r; + int32_t i; + } c32_t; + + typedef struct complex64 { + int64_t r; + int64_t i; + } c64_t; + +#define squaredMod(a) ((a).r*(a).r + (a).i*(a).i) +#define csum(res, i1, i2) (res).r = (i1).r + (i2).r ; (res).i = (i1).i + (i2).i + + __attribute__((always_inline)) inline c16_t c16mulShift(const c16_t a, const c16_t b, const int Shift) { + return (c16_t) { + .r = (int16_t)((a.r * b.r - a.i * b.i) >> Shift), + .i = (int16_t)((a.r * b.i + a.i * b.r) >> Shift) + }; + } -typedef struct complex64 { - int64_t r; - int64_t i; -} c64_t; + __attribute__((always_inline)) inline c16_t c16divShift(const c16_t a, const c16_t b, const int Shift) { + return (c16_t) { + .r = (int16_t)((a.r * b.r + a.i * b.i) >> Shift), + .i = (int16_t)((a.r * b.i - a.i * b.r) >> Shift) + }; + } + + __attribute__((always_inline)) inline c16_t c16maddShift(const c16_t a, const c16_t b, c16_t c, const int Shift) { + return (c16_t) { + .r = (int16_t)(((a.r * b.r - a.i * b.i ) >> Shift) + c.r), + .i = (int16_t)(((a.r * b.i + a.i * b.r ) >> Shift) + c.i) + }; + } -#define squaredMod(a) ((a).r*(a).r+(a).i*(a).i) -#define csum(res, i1, i2) (res).r=(i1).r+(i2).r ; (res).i=(i1).i+(i2).i + __attribute__((always_inline)) inline c32_t c32x16mulShift(const c16_t a, const c16_t b, const int Shift) { + return (c32_t) { + .r = (a.r * b.r - a.i * b.i) >> Shift, + .i = (a.r * b.i + a.i * b.r) >> Shift + }; + } + + __attribute__((always_inline)) inline c32_t c32x16maddShift(const c16_t a, const c16_t b, const c32_t c, const int Shift) { + return (c32_t) { + .r = ((a.r * b.r - a.i * b.i) >> Shift) + c.r, + .i = ((a.r * b.i + a.i * b.r) >> Shift) + c.i + }; + } + + __attribute__((always_inline)) inline c16_t c16x32div(const c32_t a, const int div) { + return (c16_t) { + .r = (int16_t)(a.r / div), + .i = (int16_t)(a.i / div) + }; + } + + + // On N complex numbers + // y.r += (x * alpha.r) >> 14 + // y.i += (x * alpha.i) >> 14 + // See regular C implementation at the end + __attribute__((always_inline)) inline void c16multaddVectRealComplex(const int16_t *x, + const c16_t *alpha, + c16_t *y, + const int N) { +#ifdef __AVX2__ + const int8_t makePairs[32] __attribute__((aligned(32)))={ + 0,1,0+16,1+16, + 2,3,2+16,3+16, + 4,5,4+16,5+16, + 6,7,6+16,7+16, + 8,9,8+16,9+16, + 10,11,10+16,11+16, + 12,13,12+16,13+16, + 14,15,14+16,15+16}; + + __m256i alpha256= _mm256_set1_epi32(*(int32_t *)alpha); + __m128i *x128=(__m128i *)x; + __m128i *y128=(__m128i *)y; + AssertFatal(N%8==0,"Not implemented\n"); + for (int i=0; ir); + alpha_i_128 = set1_int16(alpha->i); + + j=0; + + for (i=0; i>3; i++) { + + yr = mulhi_s1_int16(alpha_r_128,x_128[i]); + yi = mulhi_s1_int16(alpha_i_128,x_128[i]); +#if defined(__x86_64__) || defined(__i386__) + y_128[j] = _mm_adds_epi16(y_128[j],_mm_unpacklo_epi16(yr,yi)); + j++; + y_128[j] = _mm_adds_epi16(y_128[j],_mm_unpackhi_epi16(yr,yi)); + j++; +#elif defined(__arm__) + int16x8x2_t yint; + yint = vzipq_s16(yr,yi); + y_128[j] = adds_int16(y_128[j],yint.val[0]); + j++; + y_128[j] = adds_int16(y_128[j],yint.val[1]); + + j++; +#endif + } + +#else + for (int i=0; ir)>>14); + if (tmpr>INT16_MAX) + tmpr=INT16_MAX; + if (tmpri)>>14); + if (tmpi>INT16_MAX) + tmpi=INT16_MAX; + if (tmpir); + alpha_i_128 = set1_int16(alpha->i); + + + yr = mulhi_s1_int16(alpha_r_128,x_128[0]); + yi = mulhi_s1_int16(alpha_i_128,x_128[0]); + y_128 = _mm_adds_epi16(y_128,_mm_unpacklo_epi16(yr,yi)); + y_128 = _mm_adds_epi16(y_128,_mm_unpackhi_epi16(yr,yi)); + + _mm_storeu_si128((simd_q15_t*)y, y_128); + +} + /*!\fn void multadd_complex_vector_real_scalar(int16_t *x,int16_t alpha,int16_t *y,uint8_t zero_flag,uint32_t N) This function performs componentwise multiplication and accumulation of a real scalar and a complex vector. @param x Vector input (Q1.15) in the format |Re0 Im0|Re1 Im 1| ... @@ -114,7 +286,7 @@ void multadd_complex_vector_real_scalar(int16_t *x, //cmult_vv.c /*! - Multiply elementwise the complex conjugate of x1 with x2. + Multiply elementwise the complex conjugate of x1 with x2. @param x1 - input 1 in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)| We assume x1 with a dinamic of 15 bit maximum @param x2 - input 2 in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)| @@ -364,8 +536,8 @@ dft_size_idx_t get_dft(int ofdm_symbol_size) printf("function get_dft : unsupported ofdm symbol size \n"); assert(0); break; - } - return DFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function; + } + return DFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function; } typedef enum idft_size_idx { @@ -448,8 +620,8 @@ idft_size_idx_t get_idft(int ofdm_symbol_size) printf("function get_idft : unsupported ofdm symbol size \n"); assert(0); break; - } - return IDFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function + } + return IDFT_SIZE_IDXTABLESIZE; // never reached and will trigger assertion in idft function } @@ -491,58 +663,6 @@ int32_t sub_cpx_vector16(int16_t *x, int16_t *z, uint32_t N); -int32_t add_cpx_vector32(int16_t *x, - int16_t *y, - int16_t *z, - uint32_t N); - -int32_t add_real_vector64(int16_t *x, - int16_t *y, - int16_t *z, - uint32_t N); - -int32_t sub_real_vector64(int16_t *x, - int16_t *y, - int16_t *z, - uint32_t N); - -int32_t add_real_vector64_scalar(int16_t *x, - long long int a, - int16_t *y, - uint32_t N); - -/*!\fn int32_t add_vector16(int16_t *x,int16_t *y,int16_t *z,uint32_t N) -This function performs componentwise addition of two vectors with Q1.15 components. -@param x Vector input (Q1.15) -@param y Scalar input (Q1.15) -@param z Scalar output (Q1.15) -@param N Length of x WARNING: N must be a multiple of 32 - -The function implemented is : \f$\mathbf{z} = \mathbf{x} + \mathbf{y}\f$ -*/ -int32_t add_vector16(int16_t *x, - int16_t *y, - int16_t *z, - uint32_t N); - -int32_t add_vector16_64(int16_t *x, - int16_t *y, - int16_t *z, - uint32_t N); - -int32_t complex_conjugate(int16_t *x1, - int16_t *y, - uint32_t N); - -void bit8_txmux(int32_t length,int32_t offset); - -void bit8_rxdemux(int32_t length,int32_t offset); - -void Zero_Buffer(void *,uint32_t); -void Zero_Buffer_nommx(void *buf,uint32_t length); - -void mmxcopy(void *dest,void *src,int size); - /*!\fn int32_t signal_energy(int *,uint32_t); \brief Computes the signal energy per subcarrier */ @@ -631,7 +751,6 @@ int64_t dot_product64(int16_t *x, double interp(double x, double *xs, double *ys, int count); -int write_output(const char *fname,const char *vname,void *data,int length,int dec,char format); #ifdef __cplusplus } diff --git a/openair1/PHY/defs_eNB.h b/openair1/PHY/defs_eNB.h index 3a48dc51d6..d5ad705f4e 100644 --- a/openair1/PHY/defs_eNB.h +++ b/openair1/PHY/defs_eNB.h @@ -181,9 +181,6 @@ typedef struct { typedef struct { - /// \brief ?. - /// first index: ? [0..1023] (hard coded) - int16_t *prachF; /// \brief ?. /// first index: ce_level [0..3] /// second index: rx antenna [0..63] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx. diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 474620c2fb..5e75120ba0 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -808,7 +808,7 @@ typedef struct PHY_VARS_gNB_s { double N0; unsigned char first_run_I0_measurements; - + int ldpc_offload_flag; unsigned char is_secondary_gNB; // primary by default unsigned char is_init_sync; /// Flag to tell if initial synchronization is performed. This affects how often the secondary eNB will listen to the PSS from the primary system. @@ -895,7 +895,6 @@ typedef struct PHY_VARS_gNB_s { notifiedFIFO_t resp_RU_tx; tpool_t threadPool; int nbDecode; - uint8_t thread_pool_size; int number_of_nr_dlsch_max; int number_of_nr_ulsch_max; void * scopeData; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 33451944ef..c8a063fe19 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -97,6 +97,7 @@ #define MAX_NUM_NR_RE (4*14*273*12) #define MAX_NUM_NR_SRS_SYMBOLS 4 +#define MAX_NUM_NR_SRS_AP 4 #define NR_RX_NB_TH 1 #define NR_NB_TH_SLOT 2 @@ -241,10 +242,9 @@ typedef struct { } NR_PRACH_RESOURCES_t; typedef struct { - uint16_t sc_list_length; - uint16_t sc_list[6*273]; + uint8_t k_0_p[MAX_NUM_NR_SRS_AP][MAX_NUM_NR_SRS_SYMBOLS]; uint8_t srs_generated_signal_bits; - int32_t srs_generated_signal[OFDM_SYMBOL_SIZE_SAMPLES_MAX * MAX_NUM_NR_SRS_SYMBOLS]; + int32_t **srs_generated_signal; } nr_srs_info_t; typedef struct { diff --git a/openair1/SCHED/prach_procedures.c b/openair1/SCHED/prach_procedures.c index 805354ce1b..fd78ed4bfb 100644 --- a/openair1/SCHED/prach_procedures.c +++ b/openair1/SCHED/prach_procedures.c @@ -49,7 +49,7 @@ extern int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); void prach_procedures(PHY_VARS_eNB *eNB, int br_flag ) { - uint16_t max_preamble[4],max_preamble_energy[4],max_preamble_delay[4],avg_preamble_energy[4]; + uint16_t max_preamble[4]={0},max_preamble_energy[4]={0},max_preamble_delay[4]={0},avg_preamble_energy[4]={0}; uint16_t i; int frame,subframe; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 7c6a2eb998..b204a9e427 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -181,7 +181,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, //apply the OFDM symbol rotation here for (aa=0; aacarrier_config.num_tx_ant.value; aa++) { - apply_nr_rotation(fp,(int16_t*) &gNB->common_vars.txdataF[aa][txdataF_offset],slot,0,fp->Ncp==EXTENDED?12:14,fp->ofdm_symbol_size); + apply_nr_rotation(fp,(int16_t*) &gNB->common_vars.txdataF[aa][txdataF_offset],slot,0,fp->Ncp==EXTENDED?12:14); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_TX+offset,0); @@ -296,7 +296,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH uint8_t l, number_dmrs_symbols = 0; uint32_t G; uint16_t start_symbol, number_symbols, nb_re_dmrs; - + uint8_t enable_ldpc_offload = gNB->ldpc_offload_flag; start_symbol = pusch_pdu->start_symbol_index; number_symbols = pusch_pdu->nr_of_symbols; @@ -361,14 +361,15 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH slot_rx, harq_pid, G); - - while (gNB->nbDecode > 0) { - notifiedFIFO_elt_t *req = pullTpool(&gNB->respDecode, &gNB->threadPool); - if (req == NULL) - break; // Tpool has been stopped - nr_postDecode(gNB, req); - delNotifiedFIFO_elt(req); - } + if (enable_ldpc_offload ==0) { + while (gNB->nbDecode > 0) { + notifiedFIFO_elt_t *req = pullTpool(&gNB->respDecode, &gNB->threadPool); + if (req == NULL) + break; // Tpool has been stopped + nr_postDecode(gNB, req); + delNotifiedFIFO_elt(req); + } + } stop_meas(&gNB->ulsch_decoding_stats); } @@ -493,6 +494,7 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, gNB->UL_INFO.rx_ind.number_of_pdus++; pthread_mutex_unlock(&gNB->UL_INFO_mutex); + } // Function to fill UL RB mask to be used for N0 measurements @@ -779,8 +781,6 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot), dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot),gNB->pusch_thres); - - gNB->pusch_vars[ULSCH_id]->DTX=0; } stop_meas(&gNB->rx_pusch_stats); @@ -807,10 +807,10 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { nfapi_nr_srs_pdu_t *srs_pdu = &srs->srs_pdu; uint8_t N_symb_SRS = 1<num_symbols; int32_t srs_received_signal[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size*N_symb_SRS]; - int32_t srs_ls_estimated_channel[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size*N_symb_SRS]; - int32_t srs_estimated_channel_freq[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size*N_symb_SRS] __attribute__ ((aligned(32))); - int32_t srs_estimated_channel_time[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size] __attribute__ ((aligned(32))); - int32_t srs_estimated_channel_time_shifted[frame_parms->nb_antennas_rx][frame_parms->ofdm_symbol_size]; + int32_t srs_ls_estimated_channel[frame_parms->nb_antennas_rx][1<num_ant_ports][frame_parms->ofdm_symbol_size*N_symb_SRS]; + int32_t srs_estimated_channel_freq[frame_parms->nb_antennas_rx][1<num_ant_ports][frame_parms->ofdm_symbol_size*N_symb_SRS] __attribute__ ((aligned(32))); + int32_t srs_estimated_channel_time[frame_parms->nb_antennas_rx][1<num_ant_ports][frame_parms->ofdm_symbol_size] __attribute__ ((aligned(32))); + int32_t srs_estimated_channel_time_shifted[frame_parms->nb_antennas_rx][1<num_ant_ports][frame_parms->ofdm_symbol_size]; uint32_t noise_power_per_rb[srs_pdu->bwp_size]; int8_t snr_per_rb[srs_pdu->bwp_size]; uint32_t signal_power; @@ -818,8 +818,8 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { int8_t snr; // At least currently, the configuration is constant, so it is enough to generate the sequence just once. - if(gNB->nr_srs_info[i]->sc_list_length == 0) { - generate_srs_nr(srs_pdu, frame_parms, gNB->nr_srs_info[i]->srs_generated_signal, gNB->nr_srs_info[i], AMP, frame_rx, slot_rx); + if(gNB->nr_srs_info[i]->srs_generated_signal_bits == 0) { + generate_srs_nr(srs_pdu, frame_parms, gNB->nr_srs_info[i]->srs_generated_signal, 0, gNB->nr_srs_info[i], AMP, frame_rx, slot_rx); } const int srs_est = nr_get_srs_signal(gNB,frame_rx,slot_rx, srs_pdu, gNB->nr_srs_info[i], srs_received_signal); @@ -830,7 +830,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { slot_rx, srs_pdu, gNB->nr_srs_info[i], - gNB->nr_srs_info[i]->srs_generated_signal, + (const int32_t **) gNB->nr_srs_info[i]->srs_generated_signal, srs_received_signal, srs_ls_estimated_channel, srs_estimated_channel_freq, @@ -844,10 +844,10 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { } T(T_GNB_PHY_UL_FREQ_CHANNEL_ESTIMATE, T_INT(0), T_INT(srs_pdu->rnti), T_INT(frame_rx), T_INT(0), T_INT(0), - T_BUFFER(srs_estimated_channel_freq[0], frame_parms->ofdm_symbol_size*sizeof(int32_t))); + T_BUFFER(srs_estimated_channel_freq[0][0], frame_parms->ofdm_symbol_size*sizeof(int32_t))); T(T_GNB_PHY_UL_TIME_CHANNEL_ESTIMATE, T_INT(0), T_INT(srs_pdu->rnti), T_INT(frame_rx), T_INT(0), T_INT(0), - T_BUFFER(srs_estimated_channel_time_shifted[0], frame_parms->ofdm_symbol_size*sizeof(int32_t))); + T_BUFFER(srs_estimated_channel_time_shifted[0][0], frame_parms->ofdm_symbol_size*sizeof(int32_t))); const uint16_t num_srs = gNB->UL_INFO.srs_ind.number_of_pdus; gNB->UL_INFO.srs_ind.pdu_list = &gNB->srs_pdu_list[0]; @@ -856,7 +856,7 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { gNB->srs_pdu_list[num_srs].handle = srs_pdu->handle; gNB->srs_pdu_list[num_srs].rnti = srs_pdu->rnti; gNB->srs_pdu_list[num_srs].timing_advance = srs_est >= 0 ? nr_est_timing_advance_srs(frame_parms, - srs_estimated_channel_time) : 0xFFFF; + srs_estimated_channel_time[0]) : 0xFFFF; gNB->srs_pdu_list[num_srs].num_symbols = 1<num_symbols; gNB->srs_pdu_list[num_srs].wide_band_snr = srs_est >= 0 ? (snr + 64)<<1 : 0xFF; // 0xFF will be set if this field is invalid gNB->srs_pdu_list[num_srs].num_reported_symbols = 1<num_symbols; diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index fa354d2284..c4436341fc 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -126,7 +126,6 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, - uint8_t dlsch_parallel, NR_UE_PDCCH_CONFIG *phy_pdcch_config, notifiedFIFO_t *txFifo); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 4a76608dc0..c68702fa3f 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1325,7 +1325,6 @@ void *UE_thread_slot1_dl_processing(void *arg) { int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, - uint8_t dlsch_parallel, NR_UE_PDCCH_CONFIG *phy_pdcch_config, notifiedFIFO_t *txFifo) { diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index f718aad9f0..f429409d5a 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -48,6 +48,7 @@ #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" #include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h" +#include "executables/nr-uesoftmodem.h" //#define DEBUG_NR_DLSCHSIM @@ -65,7 +66,8 @@ double cpuf; uint16_t NB_UE_INST = 1; uint8_t const nr_rv_round_map[4] = {0, 2, 3, 1}; - +const short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; +const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; // needed for some functions PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } }; uint16_t n_rnti = 0x1234; @@ -73,47 +75,54 @@ openair0_config_t openair0_cfg[MAX_CARDS]; void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {} + +nrUE_params_t nrUE_params={0}; + +nrUE_params_t *get_nrUE_params(void) { + return &nrUE_params; +} + int main(int argc, char **argv) { - char c; - int i; //,j,l,aa; - double SNR, SNR_lin, snr0 = -2.0, snr1 = 2.0; - double snr_step = 0.1; - uint8_t snr1set = 0; - int **txdata; - double **s_re, **s_im, **r_re, **r_im; - // int sync_pos, sync_pos_slot; - // FILE *rx_frame_file; - FILE *output_fd = NULL; - //uint8_t write_output_file = 0; - // int subframe_offset; - // char fname[40], vname[40]; - int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; - uint8_t n_tx = 1, n_rx = 1; - //uint8_t transmission_mode = 1; - uint16_t Nid_cell = 0; - channel_desc_t *gNB2UE; - uint8_t extended_prefix_flag = 0; - //int8_t interf1 = -21, interf2 = -21; - FILE *input_fd = NULL, *pbch_file_fd = NULL; - //char input_val_str[50],input_val_str2[50]; - //uint16_t NB_RB=25; - SCM_t channel_model = AWGN; //Rayleigh1_anticorr; - uint16_t N_RB_DL = 106, mu = 1; - //unsigned char frame_type = 0; - unsigned char pbch_phase = 0; - int frame = 0, slot = 0; - int frame_length_complex_samples; - //int frame_length_complex_samples_no_prefix; - NR_DL_FRAME_PARMS *frame_parms; - uint8_t Kmimo = 0; - uint32_t Nsoft = 0; - double sigma; - unsigned char qbits = 8; - int ret; - //int run_initial_sync=0; - int loglvl = OAILOG_WARNING; - uint8_t dlsch_threads = 0; + char c; + int i; //,j,l,aa; + double SNR, SNR_lin, snr0 = -2.0, snr1 = 2.0; + double snr_step = 0.1; + uint8_t snr1set = 0; + int **txdata; + double **s_re, **s_im, **r_re, **r_im; + // int sync_pos, sync_pos_slot; + // FILE *rx_frame_file; + FILE *output_fd = NULL; + //uint8_t write_output_file = 0; + // int subframe_offset; + // char fname[40], vname[40]; + int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; + uint8_t n_tx = 1, n_rx = 1; + //uint8_t transmission_mode = 1; + uint16_t Nid_cell = 0; + channel_desc_t *gNB2UE; + uint8_t extended_prefix_flag = 0; + //int8_t interf1 = -21, interf2 = -21; + FILE *input_fd = NULL, *pbch_file_fd = NULL; + //char input_val_str[50],input_val_str2[50]; + //uint16_t NB_RB=25; + SCM_t channel_model = AWGN; //Rayleigh1_anticorr; + uint16_t N_RB_DL = 106, mu = 1; + //unsigned char frame_type = 0; + unsigned char pbch_phase = 0; + int frame = 0, slot = 0; + int frame_length_complex_samples; + //int frame_length_complex_samples_no_prefix; + NR_DL_FRAME_PARMS *frame_parms; + uint8_t Kmimo = 0; + uint32_t Nsoft = 0; + double sigma; + unsigned char qbits = 8; + int ret; + //int run_initial_sync=0; + int loglvl = OAILOG_WARNING; + uint8_t dlsch_threads = 0; float target_error_rate = 0.01; uint64_t SSB_positions=0x01; uint16_t nb_symb_sch = 12; @@ -344,7 +353,6 @@ int main(int argc, char **argv) if (snr1set == 0) snr1 = snr0 + 10; - init_dlsch_tpool(dlsch_threads); if (ouput_vcd) vcd_signal_dumper_init("/tmp/openair_dump_nr_dlschsim.vcd"); @@ -363,7 +371,8 @@ int main(int argc, char **argv) RC.gNB = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB[0] = calloc(1, sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0]; - initTpool(gNBthreads, &gNB->threadPool, true); + initNamedTpool(gNBthreads, &gNB->threadPool, true, "gNB-tpool"); + initFloatingCoresTpool(dlsch_threads, &nrUE_params.Tpool, false, "UE-tpool"); //gNB_config = &gNB->gNB_config; frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->nb_antennas_tx = n_tx; @@ -459,6 +468,7 @@ int main(int argc, char **argv) rel15->mcsIndex[0] = Imcs; rel15->numDmrsCdmGrpsNoData = 1; rel15->maintenance_parms_v3.tbSizeLbrmBytes = Tbslbrm; + rel15->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS, rate); double modulated_input[16 * 68 * 384]; // [hna] 16 segments, 68*Zc short channel_output_fixed[16 * 68 * 384]; //unsigned char *estimated_output; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 0f57378946..4836a570f3 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -73,6 +73,7 @@ #include #include +#include const char *__asan_default_options() { @@ -326,6 +327,7 @@ void nr_dlsim_preprocessor(module_id_t module_id, sched_pdsch->rbStart = g_rbStart; sched_pdsch->rbSize = g_rbSize; sched_pdsch->mcs = g_mcsIndex; + sched_pdsch->nrOfLayers = g_nrOfLayers; /* the following might override the table that is mandated by RRC * configuration */ current_BWP->mcsTableIdx = g_mcsTableIdx; @@ -362,12 +364,6 @@ void nr_dlsim_preprocessor(module_id_t module_id, AssertFatal(current_BWP->mcsTableIdx >= 0 && current_BWP->mcsTableIdx <= 2, "invalid mcsTableIdx %d\n", current_BWP->mcsTableIdx); } -typedef struct { - uint64_t optmask; //mask to store boolean config options - uint8_t nr_dlsch_parallel; // number of threads for dlsch decoding, 0 means no parallelization - tpool_t Tpool; // thread pool -} nrUE_params_t; - nrUE_params_t nrUE_params; nrUE_params_t *get_nrUE_params(void) { @@ -475,7 +471,7 @@ int main(int argc, char **argv) FILE *scg_fd=NULL; - while ((c = getopt (argc, argv, "f:hA:pf:g:i:n:s:S:t:x:y:z:M:N:F:GR:dPI:L:Ea:b:d:e:m:w:T:U:q:X:Y")) != -1) { + while ((c = getopt (argc, argv, "f:hA:pf:g:i:n:s:S:t:x:y:z:M:N:F:GR:d:PI:L:Ea:b:e:m:w:T:U:q:X:Y")) != -1) { switch (c) { case 'f': scg_fd = fopen(optarg,"r"); @@ -642,7 +638,7 @@ int main(int argc, char **argv) g_rbSize = atoi(optarg); break; - case 'D': + case 'd': dlsch_threads = atoi(optarg); break; @@ -748,8 +744,6 @@ int main(int argc, char **argv) if (snr1set==0) snr1 = snr0+10; - init_dlsch_tpool(dlsch_threads); - RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB[0] = (PHY_VARS_gNB*) malloc(sizeof(PHY_VARS_gNB )); @@ -1001,7 +995,7 @@ int main(int argc, char **argv) unsigned char *test_input_bit; unsigned int errors_bit = 0; - initTpool("N", &(nrUE_params.Tpool), false); + initFloatingCoresTpool(dlsch_threads, &nrUE_params.Tpool, false, "UE-tpool"); test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); @@ -1042,7 +1036,7 @@ int main(int argc, char **argv) snrRun = 0; int n_errs = 0; - initTpool(gNBthreads, &gNB->threadPool, true); + initNamedTpool(gNBthreads, &gNB->threadPool, true, "gNB-tpool"); initNotifiedFIFO(&gNB->L1_tx_free); initNotifiedFIFO(&gNB->L1_tx_filled); initNotifiedFIFO(&gNB->L1_tx_out); @@ -1268,7 +1262,6 @@ int main(int argc, char **argv) phy_procedures_nrUE_RX(UE, &UE_proc, 0, - dlsch_threads, &phy_pdcch_config, NULL); @@ -1437,6 +1430,7 @@ int main(int argc, char **argv) if (UE->frame_parms.nb_antennas_rx>1) LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1], frame_length_complex_samples, 1, 1); LOG_M("rxF0.m","rxF0", UE->common_vars.common_vars_rx_data_per_thread[UE_proc.thread_id].rxdataF[0], frame_parms->samples_per_slot_wCP, 1, 1); + LOG_M("rxF_ext.m","rxFe",&UE->pdsch_vars[0][0]->rxdataF_ext[0][0],g_rbSize*12*14,1,1); LOG_M("chestF0.m","chF0",&UE->pdsch_vars[0][0]->dl_ch_estimates_ext[0][0],g_rbSize*12*14,1,1); write_output("rxF_comp.m","rxFc",&UE->pdsch_vars[0][0]->rxdataF_comp0[0][0],N_RB_DL*12*14,1,1); LOG_M("rxF_llr.m","rxFllr",UE->pdsch_vars[UE_proc.thread_id][0]->llr[0],available_bits,1,0); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 0e648c945f..8c7bce71f6 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -50,6 +50,7 @@ #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" #include "openair1/PHY/MODULATION/nr_modulation.h" #include +#include //#define DEBUG_NR_PBCHSIM PHY_VARS_gNB *gNB; @@ -72,6 +73,12 @@ softmodem_params_t *get_softmodem_params(void) { return &softmodem_params; } +nrUE_params_t nrUE_params={0}; + +nrUE_params_t *get_nrUE_params(void) { + return &nrUE_params; +} + void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {} int nr_ue_pdcch_procedures(uint8_t gNB_id, @@ -606,6 +613,12 @@ int main(int argc, char **argv) for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { if (cyclic_prefix_type == 1) { + apply_nr_rotation(frame_parms, + (int16_t*)gNB->common_vars.txdataF[aa], + slot, + 0, + 12); + PHY_ofdm_mod(gNB->common_vars.txdataF[aa], &txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)], frame_parms->ofdm_symbol_size, @@ -613,10 +626,17 @@ int main(int argc, char **argv) frame_parms->nb_prefix_samples, CYCLIC_PREFIX); } else { + apply_nr_rotation(frame_parms, + (int16_t*)gNB->common_vars.txdataF[aa], + slot, + 0, + 14); + /*nr_normal_prefix_mod(gNB->common_vars.txdataF[aa], &txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)], 14, frame_parms);*/ + PHY_ofdm_mod(gNB->common_vars.txdataF[aa], (int*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)], frame_parms->ofdm_symbol_size, @@ -624,26 +644,12 @@ int main(int argc, char **argv) frame_parms->nb_prefix_samples0, CYCLIC_PREFIX); - apply_nr_rotation(frame_parms, - (int16_t*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)], - slot, - 0, - 1, - frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples0); - PHY_ofdm_mod(&gNB->common_vars.txdataF[aa][frame_parms->ofdm_symbol_size], (int*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)+frame_parms->nb_prefix_samples0+frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size, 13, frame_parms->nb_prefix_samples, CYCLIC_PREFIX); - - apply_nr_rotation(frame_parms, - (int16_t*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)+frame_parms->nb_prefix_samples0+frame_parms->ofdm_symbol_size], - slot, - 1, - 13, - frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples); } } } diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 76776ce110..3622ba49ba 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -54,6 +54,7 @@ #include //#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" #include +#include "executables/nr-uesoftmodem.h" #define NR_PRACH_DEBUG 1 #define PRACH_WRITE_OUTPUT_DEBUG 1 @@ -223,12 +224,6 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, return 0; } -typedef struct { - uint64_t optmask; //mask to store boolean config options - uint8_t nr_dlsch_parallel; // number of threads for dlsch decoding, 0 means no parallelization - tpool_t Tpool; // thread pool -} nrUE_params_t; - nrUE_params_t nrUE_params; nrUE_params_t *get_nrUE_params(void) { diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 1d1d2f8fa5..cabe87ef01 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -47,6 +47,7 @@ #include "openair1/SIMULATION/RF/rf.h" #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" +#include "executables/nr-uesoftmodem.h" THREAD_STRUCT thread_struct; PHY_VARS_gNB *gNB; @@ -60,12 +61,20 @@ double cpuf; //uint8_t nfapi_mode = 0; uint16_t NB_UE_INST = 1; uint8_t const nr_rv_round_map[4] = {0, 2, 3, 1}; - +const short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; +const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; // needed for some functions PHY_VARS_NR_UE * PHY_vars_UE_g[1][1]={{NULL}}; void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {} +nrUE_params_t nrUE_params={0}; + +nrUE_params_t *get_nrUE_params(void) { + return &nrUE_params; +} + + int main(int argc, char **argv) { char c; diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 222cd1da7d..6ef8bff116 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -48,6 +48,7 @@ #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" #include "common/utils/threadPool/thread-pool.h" #include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h" +#include "executables/nr-uesoftmodem.h" //#define DEBUG_NR_ULSCHSIM @@ -61,7 +62,8 @@ uint64_t downlink_frequency[MAX_NUM_CCs][4]; void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {} uint8_t const nr_rv_round_map[4] = {0, 2, 3, 1}; - +const short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; +const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; double cpuf; //uint8_t nfapi_mode = 0; uint16_t NB_UE_INST = 1; @@ -109,6 +111,13 @@ int nr_postDecode_sim(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { ulsch->last_iteration_cnt = rdata->decodeIterations; return 0; } + +nrUE_params_t nrUE_params; + +nrUE_params_t *get_nrUE_params(void) { + return &nrUE_params; +} + int main(int argc, char **argv) { char c; @@ -387,8 +396,7 @@ int main(int argc, char **argv) gNB = RC.gNB[0]; //gNB_config = &gNB->gNB_config; - char tp_param[] = "n"; - initTpool(tp_param, &gNB->threadPool, true); + initTpool("n", &gNB->threadPool, true); initNotifiedFIFO(&gNB->respDecode); frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->N_RB_DL = N_RB_DL; @@ -464,6 +472,7 @@ int main(int argc, char **argv) rel15_ul->nrOfLayers = Nl; rel15_ul->target_code_rate = code_rate; rel15_ul->pusch_data.tb_size = TBS>>3; + rel15_ul->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS, code_rate); /////////////////////////////////////////////////// double modulated_input[16 * 68 * 384]; // [hna] 16 segments, 68*Zc diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index f4dece26ff..43ac3fc145 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -67,6 +67,7 @@ #include #include "PHY/NR_REFSIG/ul_ref_seq_nr.h" #include +#include "executables/nr-uesoftmodem.h" //#define DEBUG_ULSIM const char *__asan_default_options() @@ -254,12 +255,6 @@ int nr_derive_key(int alg_type, uint8_t alg_id, return 0; } -typedef struct { - uint64_t optmask; //mask to store boolean config options - uint8_t nr_dlsch_parallel; // number of threads for dlsch decoding, 0 means no parallelization - tpool_t Tpool; // thread pool -} nrUE_params_t; - void processSlotTX(void *arg) {} nrUE_params_t nrUE_params; @@ -275,6 +270,7 @@ channel_desc_t *UE2gNB[NUMBER_OF_UE_MAX][NUMBER_OF_gNB_MAX]; int main(int argc, char **argv) { + char c; int i; double SNR, snr0 = -2.0, snr1 = 2.0; @@ -302,7 +298,6 @@ int main(int argc, char **argv) //unsigned char frame_type = 0; NR_DL_FRAME_PARMS *frame_parms; int loglvl = OAILOG_WARNING; - //uint64_t SSB_positions=0x01; uint16_t nb_symb_sch = 12; int start_symbol = 0; uint16_t nb_rb = 50; @@ -323,6 +318,8 @@ int main(int argc, char **argv) double effTP[100]; float eff_tp_check = 100; uint8_t snrRun; + int ldpc_offload_flag = 0; + uint8_t max_rounds = 4; int chest_type[2] = {0}; int enable_ptrs = 0; @@ -337,6 +334,7 @@ int main(int argc, char **argv) uint8_t transform_precoding = transformPrecoder_disabled; // 0 - ENABLE, 1 - DISABLE uint8_t num_dmrs_cdm_grps_no_data = 1; uint8_t mcs_table = 0; + int ilbrm = 0; UE_nr_rxtx_proc_t UE_proc; FILE *scg_fd=NULL; @@ -358,7 +356,7 @@ int main(int argc, char **argv) /* initialize the sin-cos table */ InitSinLUT(); - while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:kl:m:n:p:q:r:s:t:u:w:y:z:C:F:G:H:I:M:N:PR:S:T:U:L:ZW:")) != -1) { + while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:kl:m:n:op:q:r:s:t:u:v:w:y:z:C:F:G:H:I:M:N:PR:S:T:U:L:ZW:")) != -1) { printf("handling optarg %c\n",c); switch (c) { @@ -375,6 +373,7 @@ int main(int argc, char **argv) nb_symb_sch = atoi(optarg); AssertFatal(nb_symb_sch > 0 && nb_symb_sch < 15,"start_symbol %d is not in 1..14\n",nb_symb_sch); break; + case 'c': n_rnti = atoi(optarg); AssertFatal(n_rnti > 0 && n_rnti<=65535,"Illegal n_rnti %x\n",n_rnti); @@ -476,6 +475,10 @@ int main(int argc, char **argv) case 'n': n_trials = atoi(optarg); break; + + case 'o': + ldpc_offload_flag = 1; + break; case 'p': extended_prefix_flag = 1; @@ -502,6 +505,10 @@ int main(int argc, char **argv) mu = atoi(optarg); break; + case 'v': + max_rounds = atoi(optarg); + break; + case 'w': start_rb = atoi(optarg); break; @@ -561,7 +568,7 @@ int main(int argc, char **argv) break; case 'M': - // SSB_positions = atoi(optarg); + ilbrm = atoi(optarg); break; case 'N': @@ -626,21 +633,22 @@ int main(int argc, char **argv) printf("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n"); printf("-m MCS value\n"); printf("-n Number of trials to simulate\n"); + printf("-o ldpc offload flag\n"); printf("-p Use extended prefix mode\n"); printf("-q MCS table\n"); - printf("-t Delay spread for multipath channel\n"); printf("-u Set the numerology\n"); printf("-w Start PRB for PUSCH\n"); //printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used at UE\n"); printf("-z Number of RX antennas used at gNB\n"); + printf("-v Set the max rounds\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); printf("-G Offset of samples to read from file (0 default)\n"); printf("-L \n"); printf("-I Maximum LDPC decoder iterations\n"); - printf("-M Multiple SSB positions in burst\n"); + printf("-M Use limited buffer rate-matching\n"); printf("-N Nid_cell\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-R N_RB_DL\n"); @@ -666,7 +674,6 @@ int main(int argc, char **argv) get_softmodem_params()->do_ra = 0; get_softmodem_params()->usim_test = 1; - if (snr1set == 0) snr1 = snr0 + 10; @@ -700,18 +707,9 @@ int main(int argc, char **argv) RC.gNB[0] = calloc(1,sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0]; gNB->ofdm_offset_divisor = UINT_MAX; - char tp_param[80]; - if (threadCnt>0) - sprintf(tp_param,"-1"); - else - tp_param[0]='n'; - int s_offset = 0; - for (int icpu=1; icpurespDecode); - initTpool(tp_param, &gNB->threadPool, false); + initFloatingCoresTpool(threadCnt, &gNB->threadPool, false, "gNB-tpool"); initNotifiedFIFO(&gNB->respDecode); initNotifiedFIFO(&gNB->L1_tx_free); initNotifiedFIFO(&gNB->L1_tx_filled); @@ -790,9 +788,12 @@ int main(int argc, char **argv) nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; cfg->carrier_config.num_tx_ant.value = 1; cfg->carrier_config.num_rx_ant.value = n_rx; + // nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,0,0x01); + gNB->ldpc_offload_flag = ldpc_offload_flag; gNB->chest_freq = chest_type[0]; gNB->chest_time = chest_type[1]; + phy_init_nr_gNB(gNB,0,1); /* RU handles rxdataF, and gNB just has a pointer. Here, we don't have an RU, * so we need to allocate that memory as well. */ @@ -858,6 +859,7 @@ int main(int argc, char **argv) unsigned char harq_pid = 0; NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id]; + //nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &ulsch_gNB->harq_processes[harq_pid]->ulsch_pdu; nfapi_nr_ul_tti_request_t *UL_tti_req = malloc(sizeof(*UL_tti_req)); NR_Sched_Rsp_t *Sched_INFO = malloc(sizeof(*Sched_INFO)); @@ -891,7 +893,6 @@ int main(int argc, char **argv) uint16_t n_rb1 = 75; uint16_t pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; // | PUSCH_PDU_BITMAP_PUSCH_PTRS; - uint8_t max_rounds = 4; uint8_t crc_status = 0; unsigned char mod_order = nr_get_Qm_ul(Imcs, mcs_table); @@ -925,6 +926,12 @@ int main(int argc, char **argv) printf("num dmrs sym %d\n",number_dmrs_symbols); uint8_t nb_re_dmrs = (dmrs_config_type == pusch_dmrs_type1) ? 6 : 4; + uint32_t tbslbrm = 0; + if (ilbrm) + tbslbrm = nr_compute_tbslbrm(mcs_table, + N_RB_UL, + precod_nbr_layers); + if ((UE->frame_parms.nb_antennas_tx==4)&&(precod_nbr_layers==4)) num_dmrs_cdm_grps_no_data = 2; @@ -1056,6 +1063,7 @@ int main(int argc, char **argv) double blerStats[4][100]; double berStats[4][100]; double snrStats[100]; + double ldpcDecStats[100] = {0}; memset(errors_scrambling, 0, sizeof(uint32_t)*4*100); memset(n_errors, 0, sizeof(int)*4*100); memset(round_trials, 0, sizeof(int)*4*100); @@ -1127,7 +1135,7 @@ int main(int argc, char **argv) pusch_pdu->bwp_size = abwp_size; } - pusch_pdu->pusch_data.tb_size = TBS/8; + pusch_pdu->pusch_data.tb_size = TBS>>3; pusch_pdu->pdu_bit_map = pdu_bit_map; pusch_pdu->rnti = n_rnti; pusch_pdu->mcs_index = Imcs; @@ -1151,6 +1159,7 @@ int main(int argc, char **argv) pusch_pdu->uplink_frequency_shift_7p5khz = 0; pusch_pdu->start_symbol_index = start_symbol; pusch_pdu->nr_of_symbols = nb_symb_sch; + pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = tbslbrm; pusch_pdu->pusch_data.rv_index = rv_index; pusch_pdu->pusch_data.harq_process_id = 0; pusch_pdu->pusch_data.new_data_indicator = trial & 0x1; @@ -1159,6 +1168,7 @@ int main(int argc, char **argv) pusch_pdu->pusch_ptrs.ptrs_freq_density = ptrs_freq_density; pusch_pdu->pusch_ptrs.ptrs_ports_list = (nfapi_nr_ptrs_ports_t *) malloc(2*sizeof(nfapi_nr_ptrs_ports_t)); pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; + pusch_pdu->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS, code_rate); // if transform precoding is enabled if (transform_precoding == transformPrecoder_enabled) { @@ -1211,6 +1221,7 @@ int main(int argc, char **argv) ul_config.ul_config_list[0].pusch_config_pdu.dmrs_ports = ((1<common_vars.rxdataF[aa], slot, 0, - gNB->frame_parms.Ncp == EXTENDED ? 12 : 14, - gNB->frame_parms.ofdm_symbol_size); + gNB->frame_parms.Ncp == EXTENDED ? 12 : 14); } ul_proc_error = phy_procedures_gNB_uespec_RX(gNB, frame, slot); @@ -1623,6 +1633,8 @@ int main(int argc, char **argv) printf("\n"); } + ldpcDecStats[snrRun] = gNB->ulsch_decoding_stats.trials?inMicroS(gNB->ulsch_decoding_stats.diff/gNB->ulsch_decoding_stats.trials):0; + if(n_trials==1) break; @@ -1669,8 +1681,11 @@ int main(int argc, char **argv) LOG_MM(opStatsFile,"BER_round3",berStats[3],snrRun,1,7); LOG_MM(opStatsFile,"EffRate",effRate,snrRun,1,7); LOG_MM(opStatsFile,"EffTP",effTP,snrRun,1,7); + free(test_input_bit); free(estimated_output_bit); + if (gNB->ldpc_offload_flag) + free_nrLDPClib_offload(); if (output_fd) fclose(output_fd); diff --git a/openair2/GNB_APP/L1_nr_paramdef.h b/openair2/GNB_APP/L1_nr_paramdef.h index 1e5122956e..5fab0f6dfb 100644 --- a/openair2/GNB_APP/L1_nr_paramdef.h +++ b/openair2/GNB_APP/L1_nr_paramdef.h @@ -66,7 +66,7 @@ {CONFIG_STRING_L1_REMOTE_N_PORTC, NULL, 0, uptr:NULL, defintval:50030, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_LOCAL_N_PORTD, NULL, 0, uptr:NULL, defintval:50031, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_REMOTE_N_PORTD, NULL, 0, uptr:NULL, defintval:50031, TYPE_UINT, 0}, \ -{CONFIG_STRING_L1_THREAD_POOL_SIZE, "Maximum number of CPU cores for L1 processing (either max HW CPU cores or this value is used)", 0, uptr:NULL, defintval:4, TYPE_UINT, 0}, \ +{CONFIG_STRING_L1_THREAD_POOL_SIZE, "thread_pool_size paramter removed, please use --thread-pool", 0, uptr:NULL, defintval:2022, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_OFDM_OFFSET_DIVISOR, NULL, 0, uptr:NULL, defuintval:8, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:100, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PRACH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:150, TYPE_UINT, 0}, \ diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 0beba58e8c..25df321b3a 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -725,8 +725,8 @@ void RCconfig_NR_L1(void) { memset(RC.gNB[j],0,sizeof(PHY_VARS_gNB)); RC.gNB[j]->Mod_id = j; } - - RC.gNB[j]->thread_pool_size = *(L1_ParamList.paramarray[j][L1_THREAD_POOL_SIZE].uptr); + AssertFatal(*L1_ParamList.paramarray[j][L1_THREAD_POOL_SIZE].uptr == 2022, + "thread_pool_size removed, please use --thread-pool\n"); RC.gNB[j]->ofdm_offset_divisor = *(L1_ParamList.paramarray[j][L1_OFDM_OFFSET_DIVISOR].uptr); RC.gNB[j]->pucch0_thres = *(L1_ParamList.paramarray[j][L1_PUCCH0_DTX_THRESHOLD].uptr); RC.gNB[j]->prach_thres = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_THRESHOLD].uptr); @@ -1465,9 +1465,10 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { NGAP_REGISTER_GNB_REQ (msg_p).num_nssai[l] = SNSSAIParamList.numelt; for (int s = 0; s < SNSSAIParamList.numelt; ++s) { - NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sST = *SNSSAIParamList.paramarray[s][GNB_SLICE_SERIVE_TYPE_IDX].uptr; + NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sST = *SNSSAIParamList.paramarray[s][GNB_SLICE_SERVICE_TYPE_IDX].uptr; NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sD_flag = 0; - if(*SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr != 0) { + if(SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr != 0 // SD is optional + && *SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr != 0xffffff) { // 0xffffff is "no SD", see 23.003 Sec 28.4.2 NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sD_flag = 1; NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sD[0] = (*SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr & 0xFF0000) >> 16; NGAP_REGISTER_GNB_REQ (msg_p).s_nssai[l][s].sD[1] = (*SNSSAIParamList.paramarray[s][GNB_SLICE_DIFFERENTIATOR_IDX].uptr & 0x00FF00) >> 8; diff --git a/openair2/GNB_APP/gnb_paramdef.h b/openair2/GNB_APP/gnb_paramdef.h index 1298434679..9572d16d8f 100644 --- a/openair2/GNB_APP/gnb_paramdef.h +++ b/openair2/GNB_APP/gnb_paramdef.h @@ -245,23 +245,24 @@ typedef enum { #define GNB_CONFIG_STRING_SNSSAI_LIST "snssaiList" -#define GNB_CONFIG_STRING_SLICE_SERIVE_TYPE "sst" +#define GNB_CONFIG_STRING_SLICE_SERVICE_TYPE "sst" #define GNB_CONFIG_STRING_SLICE_DIFFERENTIATOR "sd" -#define GNB_SLICE_SERIVE_TYPE_IDX 0 +#define GNB_SLICE_SERVICE_TYPE_IDX 0 #define GNB_SLICE_DIFFERENTIATOR_IDX 1 #define GNBSNSSAIPARAMS_DESC { \ -/* optname helpstr paramflags XXXptr def val type numelt */ \ - {GNB_CONFIG_STRING_SLICE_SERIVE_TYPE, "slice serive type", 0, uptr:NULL, defuintval:1, TYPE_UINT, 0}, \ - {GNB_CONFIG_STRING_SLICE_DIFFERENTIATOR, "slice differentiator", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0}, \ +/* optname helpstr paramflags XXXptr def val type numelt */ \ + {GNB_CONFIG_STRING_SLICE_SERVICE_TYPE, "slice service type", 0, uptr:NULL, defuintval:1, TYPE_UINT, 0}, \ + {GNB_CONFIG_STRING_SLICE_DIFFERENTIATOR, "slice differentiator", 0, uptr:NULL, defuintval:0xffffff, TYPE_UINT, 0}, \ } -#define SLICE_SERIVE_TYPE_OKRANGES {1,2,3,4} +#define SLICE_SERVICE_TYPE_OKRANGE {0, 255} +#define SLICE_DIFFERENTIATOR_TYPE_OKRANGE {0, 0xffffff} #define SNSSAIPARAMS_CHECK { \ - { .s1 = { config_check_intval, SLICE_SERIVE_TYPE_OKRANGES, 4 } }, \ - { .s5 = { NULL } }, \ + { .s2 = { config_check_intrange, SLICE_SERVICE_TYPE_OKRANGE } }, \ + { .s2 = { config_check_intrange, SLICE_DIFFERENTIATOR_TYPE_OKRANGE } }, \ } /* AMF configuration parameters section name */ diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 52a9048cd0..91f4197bfe 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -1009,13 +1009,11 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, LOG_I(MAC, "[eNB %d][CONFIG] LTE_MBSFNAreaConfiguration_r9_t(%p) commonSF_AllocPeriod_r9(%d)\n",Mod_idP,mbms_AreaConfig, RC.mac[Mod_idP]->common_channels[0].commonSF_AllocPeriod_r9); for(i=0; i < mbms_AreaConfig->commonSF_Alloc_r9.list.count; i++){ RC.mac[Mod_idP]->common_channels[0].commonSF_Alloc_r9_mbsfn_SubframeConfig[i] = mbms_AreaConfig->commonSF_Alloc_r9.list.array[i]; - LOG_I(RRC,"[eNB %d][CONFIG] MBSFNArea[%d] commonSF_Alloc_r9: radioframeAllocationPeriod(%ldn),radioframeAllocationOffset(%ld), subframeAllocation(%x,%x,%x)\n" + LOG_I(RRC,"[eNB %d][CONFIG] MBSFNArea[%d] commonSF_Alloc_r9: radioframeAllocationPeriod(%ldn),radioframeAllocationOffset(%ld), subframeAllocation(%x)\n" ,Mod_idP,i ,RC.mac[Mod_idP]->common_channels[0].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->radioframeAllocationPeriod ,RC.mac[Mod_idP]->common_channels[0].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->radioframeAllocationOffset - ,RC.mac[Mod_idP]->common_channels[0].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0] - ,RC.mac[Mod_idP]->common_channels[0].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[1] - ,RC.mac[Mod_idP]->common_channels[0].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[2]); + ,RC.mac[Mod_idP]->common_channels[0].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]); } } diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 1269b7bbc0..4b4e1f34b1 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3498,6 +3498,15 @@ void csi_period_offset(NR_CSI_ReportConfig_t *csirep, } } +uint8_t get_BG(uint32_t A, uint16_t R) { + + float code_rate = (float) R / 10240.0f; + if ((A <=292) || ((A<=3824) && (code_rate <= 0.6667)) || code_rate <= 0.25) + return 2; + else + return 1; +} + uint32_t get_Y(NR_SearchSpace_t *ss, int slot, rnti_t rnti) { if(ss->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_common) @@ -3571,7 +3580,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD // type0-pdcch coreset switch( ((int)scs_ssb << 3) | (int)scs_pdcch ){ - case (NR_SubcarrierSpacing_kHz15 << 5) | NR_SubcarrierSpacing_kHz15: + case (NR_SubcarrierSpacing_kHz15 << 3) | NR_SubcarrierSpacing_kHz15: AssertFatal(index_4msb < 15, "38.213 Table 13-1 4 MSB out of range\n"); type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern = 1; type0_PDCCH_CSS_config->num_rbs = table_38213_13_1_c2[index_4msb]; @@ -4128,14 +4137,34 @@ uint16_t compute_pucch_prb_size(uint8_t format, } } -int get_bw_tbslbrm(int scc_bwpsize, - NR_CellGroupConfig_t *cg) { +int get_dlbw_tbslbrm(int scc_bwpsize, + NR_CellGroupConfig_t *cg) { int bw = scc_bwpsize; if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated) { const NR_ServingCellConfig_t *servingCellConfig = cg->spCellConfig->spCellConfigDedicated; if(servingCellConfig->downlinkBWP_ToAddModList) { - struct NR_ServingCellConfig__downlinkBWP_ToAddModList *BWP_list = servingCellConfig->downlinkBWP_ToAddModList; + const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *BWP_list = servingCellConfig->downlinkBWP_ToAddModList; + for (int i=0; ilist.count; i++) { + NR_BWP_t genericParameters = BWP_list->list.array[i]->bwp_Common->genericParameters; + int curr_bw = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (curr_bw > bw) + bw = curr_bw; + } + } + } + return bw; +} + +int get_ulbw_tbslbrm(int scc_bwpsize, + NR_CellGroupConfig_t *cg) { + + int bw = scc_bwpsize; + if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated) { + const NR_ServingCellConfig_t *servingCellConfig = cg->spCellConfig->spCellConfigDedicated; + if (servingCellConfig->uplinkConfig && + servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList) { + const struct NR_UplinkConfig__uplinkBWP_ToAddModList *BWP_list = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; for (int i=0; ilist.count; i++) { NR_BWP_t genericParameters = BWP_list->list.array[i]->bwp_Common->genericParameters; int curr_bw = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 77a44aa183..d45c01b4b0 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -40,6 +40,8 @@ uint32_t get_Y(NR_SearchSpace_t *ss, int slot, rnti_t rnti); +uint8_t get_BG(uint32_t A, uint16_t R); + uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn); uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint8_t scs_index, uint32_t bw); @@ -143,8 +145,11 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset); -int get_bw_tbslbrm(int scc_bwpsize, - NR_CellGroupConfig_t *cg); +int get_dlbw_tbslbrm(int scc_bwpsize, + NR_CellGroupConfig_t *cg); + +int get_ulbw_tbslbrm(int scc_bwpsize, + NR_CellGroupConfig_t *cg); uint32_t nr_compute_tbslbrm(uint16_t table, uint16_t nb_rb, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 1e67617ee7..e525300d36 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -966,13 +966,13 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr NR_BWP_t genericParameters = mac->scc ? mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters : mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; int BWPSize = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - bw_tbslbrm = get_bw_tbslbrm(BWPSize, mac->cg); + bw_tbslbrm = get_dlbw_tbslbrm(BWPSize, mac->cg); } else bw_tbslbrm = dlsch_config_pdu_1_0->BWPSize; dlsch_config_pdu_1_0->tbslbrm = nr_compute_tbslbrm(dlsch_config_pdu_1_0->mcs_table, - bw_tbslbrm, - 1); + bw_tbslbrm, + 1); /* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ dlsch_config_pdu_1_0->ndi = dci->ndi; @@ -1407,7 +1407,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr NR_BWP_t genericParameters = mac->scc ? mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters : mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; int BWPSize = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int bw_tbslbrm = get_bw_tbslbrm(BWPSize, mac->cg); + int bw_tbslbrm = get_dlbw_tbslbrm(BWPSize, mac->cg); dlsch_config_pdu_1_1->tbslbrm = nr_compute_tbslbrm(dlsch_config_pdu_1_1->mcs_table, bw_tbslbrm, nl_tbslbrm); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 065b9b1395..aee3e369cc 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -681,6 +681,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->pusch_data.harq_process_id = 0; pusch_config_pdu->pusch_data.new_data_indicator = 1; // new data pusch_config_pdu->pusch_data.num_cb = 0; + pusch_config_pdu->tbslbrm = 0; } else if (dci) { NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; @@ -864,6 +865,32 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, else N_PRB_oh = 0; + if (mac->cg && + mac->cg->spCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->rateMatching) { + long *maxMIMO_Layers = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers; + if (!maxMIMO_Layers) + maxMIMO_Layers = pusch_Config ? pusch_Config->maxRank : NULL; + AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); + int bw_tbslbrm; + if (mac->scc || mac->scc_SIB || mac->cg) { + NR_BWP_t genericParameters = initialUplinkBWP->genericParameters; + int BWPSize = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + bw_tbslbrm = get_ulbw_tbslbrm(BWPSize, mac->cg); + } + else { + bw_tbslbrm = pusch_config_pdu->bwp_size; + } + pusch_config_pdu->tbslbrm = nr_compute_tbslbrm(pusch_config_pdu->mcs_table, + bw_tbslbrm, + *maxMIMO_Layers); + } + else + pusch_config_pdu->tbslbrm = 0; + /* PTRS */ if (ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] && diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index c87aa68f75..46ffb0b210 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -133,6 +133,9 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, gNB->tdd_beam_association[i] = -1; } + gNB->frame = frame; + gNB->slot = slot; + start_meas(&RC.nrmac[module_idP]->eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 745fc1ae2b..2d8dd574e3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -458,18 +458,18 @@ void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, // slot and frame limit to transmit msg2 according to response window uint8_t slot_limit = (rach_slot + slot_window)%nr_slots_per_frame[mu]; - uint16_t frame_limit = (slot_limit>(rach_slot))? rach_frame : (rach_frame +1); + uint16_t frame_limit = rach_frame + (rach_slot + slot_window)/nr_slots_per_frame[mu]; // computing start of next period - - int FR = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0] >= 257 ? nr_FR2 : nr_FR1; - uint8_t start_next_period = rach_slot-(rach_slot%tdd_period_slot)+tdd_period_slot; int eff_slot = start_next_period + last_dl_slot_period; // initializing scheduling of slot to next mixed (or last dl) slot + // we can't schedule msg2 before sl_ahead since prach while ((eff_slot-rach_slot)<=sl_ahead) { eff_slot += tdd_period_slot; } + + int FR = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0] >= 257 ? nr_FR2 : nr_FR1; if (FR==nr_FR2) { int num_tdd_period = (eff_slot%nr_slots_per_frame[mu])/tdd_period_slot; while((tdd_beam_association[num_tdd_period]!=-1)&&(tdd_beam_association[num_tdd_period]!=beam_index)) { @@ -480,8 +480,9 @@ void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, tdd_beam_association[num_tdd_period] = beam_index; } - *msg2_frame=(rach_frame + eff_slot/nr_slots_per_frame[mu])%1024; - *msg2_slot=eff_slot%nr_slots_per_frame[mu]; + *msg2_frame = rach_frame + eff_slot / nr_slots_per_frame[mu]; + *msg2_slot = eff_slot % nr_slots_per_frame[mu]; + // go to previous slot if the current scheduled slot is beyond the response window // and if the slot is not among the PDCCH monitored ones (38.213 10.1) while (*msg2_frame > frame_limit @@ -490,10 +491,7 @@ void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, if((frame_type == FDD) || ((*msg2_slot%tdd_period_slot) > 0)) { if (*msg2_slot==0) { - if(*msg2_frame != 0) - (*msg2_frame)--; - else - *msg2_frame = 1023; + (*msg2_frame)--; *msg2_slot = nr_slots_per_frame[mu] - 1; } else @@ -502,6 +500,9 @@ void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, else AssertFatal(1==0,"No available DL slot to schedule msg2 has been found"); } + + // calculate frame number considering wrap-around + *msg2_frame = *msg2_frame % 1024; } @@ -1057,6 +1058,8 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, pusch_pdu->mcs_index = mcsindex; pusch_pdu->pusch_data.tb_size = TBS; + pusch_pdu->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS<<3,R); + } } @@ -1072,15 +1075,15 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t return; } - uint16_t *vrb_map_UL = - &RC.nrmac[module_idP]->common_channels[CC_id].vrb_map_UL[ra->Msg3_slot * MAX_BWP_SIZE]; + const uint16_t mask = SL_to_bitmap(ra->msg3_startsymb, ra->msg3_nrsymb); + uint16_t *vrb_map_UL = &RC.nrmac[module_idP]->common_channels[CC_id].vrb_map_UL[ra->Msg3_slot * MAX_BWP_SIZE]; for (int i = 0; i < ra->msg3_nb_rb; ++i) { - AssertFatal(!vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start], + AssertFatal(!(vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start] & mask), "RB %d in %4d.%2d is already taken, cannot allocate Msg3!\n", i + ra->msg3_first_rb, ra->Msg3_frame, ra->Msg3_slot); - vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start] |= SL_to_bitmap(ra->msg3_startsymb, ra->msg3_nrsymb); + vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start] |= mask; } LOG_D(NR_MAC, "[gNB %d][RAPROC] Frame %d, Slot %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", module_idP, frameP, slotP, CC_id, ra->Msg3_frame, ra->Msg3_slot); @@ -1318,10 +1321,11 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int bw_tbslbrm = get_bw_tbslbrm(scc_bwpsize, ra->CellGroup); + int bw_tbslbrm = get_dlbw_tbslbrm(scc_bwpsize, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, bw_tbslbrm, 1); + pdsch_pdu_rel15->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS<<3,R); // Fill PDCCH DL DCI PDU nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci]; @@ -1674,7 +1678,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->NrOfCodewords = 1; int R = nr_get_code_rate_dl(mcsIndex,mcsTableIdx); pdsch_pdu_rel15->targetCodeRate[0] = R; - pdsch_pdu_rel15->qamModOrder[0] = 2; + int Qm = nr_get_Qm_dl(mcsIndex, mcsTableIdx); + pdsch_pdu_rel15->qamModOrder[0] = Qm; pdsch_pdu_rel15->mcsIndex[0] = mcsIndex; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[harq->round%4]; @@ -1699,10 +1704,11 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead, pdsch_pdu_rel15->numDmrsCdmGrpsNoData, tb_scaling); int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int bw_tbslbrm = get_bw_tbslbrm(scc_bwpsize, ra->CellGroup); + int bw_tbslbrm = get_dlbw_tbslbrm(scc_bwpsize, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, bw_tbslbrm, 1); + pdsch_pdu_rel15->maintenance_parms_v3.ldpcBaseGraph = get_BG(harq->tb_size<<3,R); pdsch_pdu_rel15->precodingAndBeamforming.num_prgs=1; pdsch_pdu_rel15->precodingAndBeamforming.prg_size=275; @@ -1829,6 +1835,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra nr_clear_ra_proc(module_idP, CC_id, frameP, ra); UE->Msg3_dcch_dtch = true; UE->Msg4_ACKed = true; + UE->ra_timer = 0; remove_front_nr_list(&sched_ctrl->feedback_dl_harq); harq->feedback_slot = -1; @@ -1867,6 +1874,7 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram if (stats->dl.errors == 0) { LOG_A(NR_MAC, "(UE RNTI 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", ra->rnti); UE->Msg4_ACKed = true; + UE->ra_timer = 0; // Pause scheduling according to: // 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 90d0af946a..3895ffe42c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -433,10 +433,10 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; - pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, 0); - pdsch_pdu_rel15->qamModOrder[0] = 2; + pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, mcsTableIdx); + pdsch_pdu_rel15->qamModOrder[0] = nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, mcsTableIdx); pdsch_pdu_rel15->mcsIndex[0] = gNB_mac->sched_ctrlCommon->sched_pdsch.mcs; - pdsch_pdu_rel15->mcsTable[0] = 0; + pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; pdsch_pdu_rel15->rvIndex[0] = 0; pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; pdsch_pdu_rel15->nrOfLayers = 1; @@ -451,10 +451,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->rbStart = gNB_mac->sched_ctrlCommon->sched_pdsch.rbStart; pdsch_pdu_rel15->rbSize = gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize; pdsch_pdu_rel15->VRBtoPRBMapping = 0; - pdsch_pdu_rel15->qamModOrder[0] = nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, - mcsTableIdx); pdsch_pdu_rel15->TBSize[0] = TBS; - pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; pdsch_pdu_rel15->dlDmrsSymbPos = dlDmrsSymbPos; @@ -465,6 +462,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(0, pdsch_pdu_rel15->BWPSize, 1); + pdsch_pdu_rel15->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS<<3,pdsch_pdu_rel15->targetCodeRate[0]); /* Fill PDCCH DL DCI PDU */ nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index a35c80b95a..597477c3d3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -896,6 +896,7 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; UE->mac_stats.dl.current_bytes = 0; + UE->mac_stats.dl.current_rbs = 0; NR_CellGroupConfig_t *cg = UE->CellGroup; /* update TA and set ta_apply every 10 frames. @@ -1059,15 +1060,18 @@ void nr_schedule_ue_spec(module_id_t module_id, csi_report->codebook_mode); } // TBS_LBRM according to section 5.4.2.1 of 38.212 - long *maxMIMO_Layers = current_BWP->pdsch_servingcellconfig->ext1->maxMIMO_Layers; - AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); - int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; + // TODO: verify the case where pdsch_servingcellconfig is NULL, in which case + // in principle maxMIMO_layers should be given by the maximum number of layers + // for PDSCH supported by the UE for the serving cell (5.4.2.1 of 38.212) + long maxMIMO_Layers = current_BWP->pdsch_servingcellconfig ? *current_BWP->pdsch_servingcellconfig->ext1->maxMIMO_Layers : 1; + const int nl_tbslbrm = min(maxMIMO_Layers, 4); // Maximum number of PRBs across all configured DL BWPs int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int bw_tbslbrm = get_bw_tbslbrm(scc_bwpsize, cg); + int bw_tbslbrm = get_dlbw_tbslbrm(scc_bwpsize, cg); pdsch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(current_BWP->mcsTableIdx, bw_tbslbrm, nl_tbslbrm); + pdsch_pdu->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS<<3,R); NR_PDSCH_Config_t *pdsch_Config = current_BWP->pdsch_Config; @@ -1119,7 +1123,7 @@ void nr_schedule_ue_spec(module_id_t module_id, // as per table 7.3.1.1.2-1 in 38.212 dci_payload.bwp_indicator.val = current_BWP->n_dl_bwp < 4 ? bwp_id : bwp_id - 1; - AssertFatal(pdsch_Config->resourceAllocation == NR_PDSCH_Config__resourceAllocation_resourceAllocationType1, + AssertFatal(pdsch_Config == NULL || pdsch_Config->resourceAllocation == NR_PDSCH_Config__resourceAllocation_resourceAllocationType1, "Only frequency resource allocation type 1 is currently supported\n"); dci_payload.frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu->rbSize, @@ -1193,6 +1197,7 @@ void nr_schedule_ue_spec(module_id_t module_id, current_harq_pid); T(T_GNB_MAC_RETRANSMISSION_DL_PDU_WITH_DATA, T_INT(module_id), T_INT(CC_id), T_INT(rnti), T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_INT(harq->round), T_BUFFER(harq->transportBlock, TBS)); + UE->mac_stats.dl.total_rbs_retx += sched_pdsch->rbSize; } else { /* initial transmission */ LOG_D(NR_MAC, "[%s] Initial HARQ transmission in %d.%d\n", __FUNCTION__, frame, slot); uint8_t *buf = (uint8_t *) harq->transportBlock; @@ -1208,6 +1213,7 @@ void nr_schedule_ue_spec(module_id_t module_id, int dlsch_total_bytes = 0; /* next, get RLC data */ start_meas(&gNB_mac->rlc_data_req); + int sdus = 0; if (sched_ctrl->num_total_bytes > 0) { /* loop over all activated logical channels */ @@ -1259,6 +1265,7 @@ void nr_schedule_ue_spec(module_id_t module_id, buf += len+sizeof(NR_MAC_SUBHEADER_LONG); dlsch_total_bytes += len; lcid_bytes += len; + sdus += 1; } UE->mac_stats.dl.lc_bytes[lcid] += lcid_bytes; @@ -1286,6 +1293,7 @@ void nr_schedule_ue_spec(module_id_t module_id, } for (; buf < bufEnd; buf++) *buf = lrand48() & 0xff; + sdus +=1; } } @@ -1303,6 +1311,10 @@ void nr_schedule_ue_spec(module_id_t module_id, UE->mac_stats.dl.total_bytes += TBS; UE->mac_stats.dl.current_bytes = TBS; + UE->mac_stats.dl.total_rbs += sched_pdsch->rbSize; + UE->mac_stats.dl.num_mac_sdu += sdus; + UE->mac_stats.dl.current_rbs = sched_pdsch->rbSize; + /* save retransmission information */ harq->sched_pdsch = *sched_pdsch; /* save which time allocation has been used, to be used on diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 17f97ba59c..e991c2450a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -65,6 +65,8 @@ #include "common/ran_context.h" +//#define DEBUG_DCI + extern RAN_CONTEXT_t RC; // Note the 2 scs values in the table names represent resp. scs_common and pdcch_scs @@ -212,6 +214,7 @@ uint8_t get_mcs_from_cqi(int mcs_table, int cqi_table, int cqi_idx) return 9; } + void set_dl_dmrs_ports(NR_pdsch_semi_static_t *ps) { //TODO first basic implementation of dmrs port selection @@ -1247,8 +1250,8 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, pucch_pdu->format_type = default_pucch_fmt[rsetindex]; pucch_pdu->initial_cyclic_shift = r_pucch%default_pucch_csset[rsetindex]; if (rsetindex==3||rsetindex==7||rsetindex==11) pucch_pdu->initial_cyclic_shift*=6; - else if (rsetindex==1||rsetindex==2) pucch_pdu->initial_cyclic_shift*=3; - else pucch_pdu->initial_cyclic_shift*=4; + else if (rsetindex==1||rsetindex==2) pucch_pdu->initial_cyclic_shift*=4; + else pucch_pdu->initial_cyclic_shift*=3; pucch_pdu->nr_of_symbols = nr_of_symb; pucch_pdu->start_symbol_index = start_symb; if (pucch_pdu->format_type == 1) pucch_pdu->time_domain_occ_idx = 0; // check this!! @@ -1827,7 +1830,37 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, // UL-SCH indicator pos += 1; *dci_pdu |= ((uint64_t)dci_pdu_rel15->ulsch_indicator & 0x1) << (dci_size - pos); - break; + +#ifdef DEBUG_DCI + LOG_I(NR_MAC,"============= NR_UL_DCI_FORMAT_0_1 =============\n"); + LOG_I(NR_MAC,"dci_size = %i\n", dci_size); + LOG_I(NR_MAC,"dci_pdu_rel15->format_indicator = %i\n", dci_pdu_rel15->format_indicator); + LOG_I(NR_MAC,"dci_pdu_rel15->carrier_indicator.val = %i\n", dci_pdu_rel15->carrier_indicator.val); + LOG_I(NR_MAC,"dci_pdu_rel15->ul_sul_indicator.val = %i\n", dci_pdu_rel15->ul_sul_indicator.val); + LOG_I(NR_MAC,"dci_pdu_rel15->bwp_indicator.val = %i\n", dci_pdu_rel15->bwp_indicator.val); + LOG_I(NR_MAC,"dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); + LOG_I(NR_MAC,"dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); + LOG_I(NR_MAC,"dci_pdu_rel15->frequency_hopping_flag.val = %i\n", dci_pdu_rel15->frequency_hopping_flag.val); + LOG_I(NR_MAC,"dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); + LOG_I(NR_MAC,"dci_pdu_rel15->ndi = %i\n", dci_pdu_rel15->ndi); + LOG_I(NR_MAC,"dci_pdu_rel15->rv= %i\n", dci_pdu_rel15->rv); + LOG_I(NR_MAC,"dci_pdu_rel15->harq_pid = %i\n", dci_pdu_rel15->harq_pid); + LOG_I(NR_MAC,"dci_pdu_rel15->dai[0].val = %i\n", dci_pdu_rel15->dai[0].val); + LOG_I(NR_MAC,"dci_pdu_rel15->dai[1].val = %i\n", dci_pdu_rel15->dai[1].val); + LOG_I(NR_MAC,"dci_pdu_rel15->tpc = %i\n", dci_pdu_rel15->tpc); + LOG_I(NR_MAC,"dci_pdu_rel15->srs_resource_indicator.val = %i\n", dci_pdu_rel15->srs_resource_indicator.val); + LOG_I(NR_MAC,"dci_pdu_rel15->precoding_information.val = %i\n", dci_pdu_rel15->precoding_information.val); + LOG_I(NR_MAC,"dci_pdu_rel15->antenna_ports.val = %i\n", dci_pdu_rel15->antenna_ports.val); + LOG_I(NR_MAC,"dci_pdu_rel15->srs_request.val = %i\n", dci_pdu_rel15->srs_request.val); + LOG_I(NR_MAC,"dci_pdu_rel15->csi_request.val = %i\n", dci_pdu_rel15->csi_request.val); + LOG_I(NR_MAC,"dci_pdu_rel15->cbgti.val = %i\n", dci_pdu_rel15->cbgti.val); + LOG_I(NR_MAC,"dci_pdu_rel15->ptrs_dmrs_association.val = %i\n", dci_pdu_rel15->ptrs_dmrs_association.val); + LOG_I(NR_MAC,"dci_pdu_rel15->beta_offset_indicator.val = %i\n", dci_pdu_rel15->beta_offset_indicator.val); + LOG_I(NR_MAC,"dci_pdu_rel15->dmrs_sequence_initialization.val = %i\n", dci_pdu_rel15->dmrs_sequence_initialization.val); + LOG_I(NR_MAC,"dci_pdu_rel15->ulsch_indicator = %i\n", dci_pdu_rel15->ulsch_indicator); +#endif + + break; } break; @@ -2217,7 +2250,9 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, CellGroup->spCellConfig->spCellConfigDedicated) { const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; - DL_BWP->pdsch_servingcellconfig = servingCellConfig->pdsch_ServingCellConfig? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; + DL_BWP->pdsch_servingcellconfig = servingCellConfig->pdsch_ServingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; + UL_BWP->pusch_servingcellconfig = servingCellConfig->uplinkConfig && servingCellConfig->uplinkConfig->pusch_ServingCellConfig ? + servingCellConfig->uplinkConfig->pusch_ServingCellConfig->choice.setup : NULL; target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; if(UE && UE->Msg3_dcch_dtch) { @@ -2476,6 +2511,10 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf "uplinkBWP_ToAddModList has %d BWP!\n", ul_bwp->n_ul_bwp); + if (get_softmodem_params()->phy_test == 0) { + UE->ra_timer = 12000 << UE->current_DL_BWP.scs; // 12000 ms is arbitrary and found to be a good timeout from experiments + } + /* get Number of HARQ processes for this UE */ // pdsch_servingcellconfig == NULL in SA -> will create default (8) number of HARQ processes create_dl_harq_list(sched_ctrl, dl_bwp->pdsch_servingcellconfig); @@ -2942,6 +2981,15 @@ void nr_mac_update_timers(module_id_t module_id, ups); } } + + // RA timer + if (UE->ra_timer > 0) { + UE->ra_timer--; + if (UE->ra_timer == 0) { + LOG_W(NR_MAC, "Removing UE %04x because RA timer expired\n", UE->rnti); + mac_remove_nr_ue(RC.nrmac[module_id], UE->rnti); + } + } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 1ca9fa067e..082e8dc599 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -53,6 +53,32 @@ const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon return 0; // if FDD or not mixed slot in TDD, for now use default TDA (TODO handle CSI-RS slots) } +int compute_bw_factor(int mu, int rb) { + // 38.213 7.1.1 + return (10 * log10(rb << mu)); +} + +int compute_delta_tf(int tbs_bits, + int rb, + int n_layers, + int n_symbols, + int n_dmrs, + long *deltaMCS) { + + // 38.213 7.1.1 + // if the PUSCH transmission is over more than one layer delta_tf = 0 + if(deltaMCS == NULL || n_layers>1) + return 0; + else + AssertFatal(1==0,"Compute DeltaTF not yet fully supported\n"); + + const int n_re = (NR_NB_SC_PER_RB * n_symbols - n_dmrs) * rb; + const int BPRE = tbs_bits/n_re; //TODO change for PUSCH with CSI + const float f = pow(2, (float) BPRE * 1.25); + const float beta = 1.0f; //TODO change for PUSCH with CSI + return(10 * log10((f - 1) * beta)); +} + // For both UL-SCH except: // - UL-SCH: fixed-size MAC CE(known by LCID) // - UL-SCH: padding @@ -77,317 +103,324 @@ const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon // F: length of L is 0:8 or 1:16 bits wide // R: Reserved bit, set to zero. -int nr_process_mac_pdu( instance_t module_idP, - NR_UE_info_t* UE, - uint8_t CC_id, - frame_t frameP, - sub_frame_t slot, - uint8_t *pduP, - int pdu_len) +int nr_process_mac_pdu(instance_t module_idP, + NR_UE_info_t* UE, + uint8_t CC_id, + frame_t frameP, + sub_frame_t slot, + uint8_t *pduP, + int pdu_len, + const int8_t harq_pid) { + uint8_t done = 0; - uint8_t done = 0; + int sdus = 0; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + if (pduP[0] != UL_SCH_LCID_PADDING) + trace_NRpdu(DIRECTION_UPLINK, pduP, pdu_len, WS_C_RNTI, UE->rnti, frameP, 0, 0, 0); - if ( pduP[0] != UL_SCH_LCID_PADDING ) - trace_NRpdu(DIRECTION_UPLINK, pduP, pdu_len, WS_C_RNTI, UE->rnti, frameP, 0, 0, 0); +#ifdef ENABLE_MAC_PAYLOAD_DEBUG + LOG_I(NR_MAC, "In %s: dumping MAC PDU in %d.%d:\n", __func__, frameP, slot); + log_dump(NR_MAC, pduP, pdu_len, LOG_DUMP_CHAR, "\n"); +#endif - #ifdef ENABLE_MAC_PAYLOAD_DEBUG - LOG_I(NR_MAC, "In %s: dumping MAC PDU in %d.%d:\n", __func__, frameP, slot); - log_dump(NR_MAC, pduP, pdu_len, LOG_DUMP_CHAR, "\n"); - #endif + while (!done && pdu_len > 0){ + uint16_t mac_len=0; + uint16_t mac_subheader_len=sizeof(NR_MAC_SUBHEADER_FIXED); + uint8_t rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID; - while (!done && pdu_len > 0){ - uint16_t mac_len=0; - uint16_t mac_subheader_len=sizeof(NR_MAC_SUBHEADER_FIXED); - uint8_t rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID; + LOG_D(NR_MAC, "In %s: received UL-SCH sub-PDU with LCID 0x%x in %d.%d (remaining PDU length %d)\n", __func__, rx_lcid, frameP, slot, pdu_len); - LOG_D(NR_MAC, "In %s: received UL-SCH sub-PDU with LCID 0x%x in %d.%d (remaining PDU length %d)\n", __func__, rx_lcid, frameP, slot, pdu_len); + unsigned char *ce_ptr; + int n_Lcg = 0; - unsigned char *ce_ptr; - int n_Lcg = 0; - - switch(rx_lcid){ - // MAC CE - - /*#ifdef DEBUG_HEADER_PARSING - LOG_D(NR_MAC, "[UE] LCID %d, PDU length %d\n", ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID, pdu_len); - #endif*/ - case UL_SCH_LCID_RECOMMENDED_BITRATE_QUERY: - // 38.321 Ch6.1.3.20 - mac_len = 2; - break; - case UL_SCH_LCID_CONFIGURED_GRANT_CONFIRMATION: - // 38.321 Ch6.1.3.7 - break; - - case UL_SCH_LCID_S_BSR: - case UL_SCH_LCID_S_TRUNCATED_BSR: - //38.321 section 6.1.3.1 - //fixed length - mac_len =1; - /* Extract short BSR value */ - ce_ptr = &pduP[mac_subheader_len]; - NR_BSR_SHORT *bsr_s = (NR_BSR_SHORT *) ce_ptr; - sched_ctrl->estimated_ul_buffer = 0; - sched_ctrl->estimated_ul_buffer = NR_SHORT_BSR_TABLE[bsr_s->Buffer_size]; - LOG_D(NR_MAC, - "SHORT BSR at %4d.%2d, LCG ID %d, BS Index %d, BS value < %d, est buf %d\n", - frameP, - slot, - bsr_s->LcgID, - bsr_s->Buffer_size, - NR_SHORT_BSR_TABLE[bsr_s->Buffer_size], - sched_ctrl->estimated_ul_buffer); - break; - - case UL_SCH_LCID_L_BSR: - case UL_SCH_LCID_L_TRUNCATED_BSR: - //38.321 section 6.1.3.1 - //variable length - /* Several checks have been added to this function to - ensure that the casting of the pduP is possible. There seems - to be a partial PDU at the end of this buffer, so here - we gracefully ignore that by returning 0. See: - https://gitlab.eurecom.fr/oai/openairinterface5g/-/issues/534 */ - if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) - return 0; - /* Extract long BSR value */ - ce_ptr = &pduP[mac_subheader_len]; - NR_BSR_LONG *bsr_l = (NR_BSR_LONG *) ce_ptr; - sched_ctrl->estimated_ul_buffer = 0; - - n_Lcg = bsr_l->LcgID7 + bsr_l->LcgID6 + bsr_l->LcgID5 + bsr_l->LcgID4 + - bsr_l->LcgID3 + bsr_l->LcgID2 + bsr_l->LcgID1 + bsr_l->LcgID0; - - LOG_D(NR_MAC, "LONG BSR, LCG ID(7-0) %d/%d/%d/%d/%d/%d/%d/%d\n", - bsr_l->LcgID7, bsr_l->LcgID6, bsr_l->LcgID5, bsr_l->LcgID4, - bsr_l->LcgID3, bsr_l->LcgID2, bsr_l->LcgID1, bsr_l->LcgID0); - - for (int n = 0; n < n_Lcg; n++){ - LOG_D(NR_MAC, "LONG BSR, %d/%d (n/n_Lcg), BS Index %d, BS value < %d", - n, n_Lcg, pduP[mac_subheader_len + 1 + n], - NR_LONG_BSR_TABLE[pduP[mac_subheader_len + 1 + n]]); - sched_ctrl->estimated_ul_buffer += - NR_LONG_BSR_TABLE[pduP[mac_subheader_len + 1 + n]]; - LOG_D(NR_MAC, - "LONG BSR at %4d.%2d, %d/%d (n/n_Lcg), BS Index %d, BS value < %d, total %d\n", - frameP, - slot, - n, - n_Lcg, - pduP[mac_subheader_len + 1 + n], - NR_LONG_BSR_TABLE[pduP[mac_subheader_len + 1 + n]], - sched_ctrl->estimated_ul_buffer); - } - - break; - - case UL_SCH_LCID_C_RNTI: - - for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { - NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[i]; - if (ra->state >= WAIT_Msg3 && ra->rnti == UE->rnti) { - ra->crnti = ((pduP[1]&0xFF)<<8)|(pduP[2]&0xFF); - ra->msg3_dcch_dtch = true; - LOG_I(NR_MAC, "Received UL_SCH_LCID_C_RNTI with C-RNTI 0x%04x\n", ra->crnti); - break; - } - } - - //38.321 section 6.1.3.2 - //fixed length - mac_len = 2; - /* Extract CRNTI value */ - break; - - case UL_SCH_LCID_SINGLE_ENTRY_PHR: - //38.321 section 6.1.3.8 - //fixed length - mac_len = 2; - /* Extract SINGLE ENTRY PHR elements for PHR calculation */ - ce_ptr = &pduP[mac_subheader_len]; - NR_SINGLE_ENTRY_PHR_MAC_CE *phr = (NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr; - /* Save the phr info */ - const int PH = phr->PH; - const int PCMAX = phr->PCMAX; - /* 38.133 Table10.1.17.1-1 */ - if (PH < 55) - sched_ctrl->ph = PH - 32; - else - sched_ctrl->ph = PH - 32 + (PH - 54); - /* 38.133 Table10.1.18.1-1 */ - sched_ctrl->pcmax = PCMAX - 29; - LOG_D(NR_MAC, "SINGLE ENTRY PHR R1 %d PH %d (%d dB) R2 %d PCMAX %d (%d dBm)\n", - phr->R1, PH, sched_ctrl->ph, phr->R2, PCMAX, sched_ctrl->pcmax); - break; - - case UL_SCH_LCID_MULTI_ENTRY_PHR_1_OCT: - //38.321 section 6.1.3.9 - // varialbe length - if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) - return 0; - /* Extract MULTI ENTRY PHR elements from single octet bitmap for PHR calculation */ - break; - - case UL_SCH_LCID_MULTI_ENTRY_PHR_4_OCT: - //38.321 section 6.1.3.9 - // varialbe length - if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) - return 0; - /* Extract MULTI ENTRY PHR elements from four octets bitmap for PHR calculation */ - break; - - case UL_SCH_LCID_PADDING: - done = 1; - // end of MAC PDU, can ignore the rest. - break; - - case UL_SCH_LCID_SRB1: - case UL_SCH_LCID_SRB2: - if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) - return 0; - - rnti_t crnti = UE->rnti; - NR_UE_info_t* UE_idx = UE; - for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { - NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[i]; - if (ra->state >= WAIT_Msg3 && ra->rnti == UE->rnti) { - uint8_t *next_subpduP = pduP + mac_subheader_len + mac_len; - if ((pduP[mac_subheader_len+mac_len] & 0x3F) == UL_SCH_LCID_C_RNTI) { - crnti = ((next_subpduP[1]&0xFF)<<8)|(next_subpduP[2]&0xFF); - LOG_W(NR_MAC, " UL_SCH_LCID_SRB for rnti %04x\n", crnti); - UE_idx = find_nr_UE(&RC.nrmac[module_idP]->UE_info, crnti); - break; - } - } - } - - if (UE_idx->CellGroup) { - LOG_D(NR_MAC, "Frame %d : ULSCH -> UL-DCCH %d (gNB %ld, %d bytes), rnti: 0x%04x \n", frameP, rx_lcid, module_idP, mac_len, crnti); - mac_rlc_data_ind(module_idP, - crnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - rx_lcid, - (char *) (pduP + mac_subheader_len), - mac_len, - 1, - NULL); - } else { - AssertFatal(1==0,"[UE %04x] Frame/Slot %d.%d : Received LCID %d which is not configured, dropping packet\n",UE->rnti,frameP,slot,rx_lcid); - } - break; - case UL_SCH_LCID_SRB3: - // todo - break; - - case UL_SCH_LCID_CCCH: - case UL_SCH_LCID_CCCH1: - // fixed length - mac_subheader_len = 1; - - if ( rx_lcid == UL_SCH_LCID_CCCH1 ) { - // RRCResumeRequest1 message includes the full I-RNTI and has a size of 8 bytes - mac_len = 8; - - // Check if it is a valid CCCH1 message, we get all 00's messages very often - int i = 0; - for(i=0; i<(mac_subheader_len+mac_len); i++) { - if(pduP[i] != 0) { - break; - } - } - if (i == (mac_subheader_len+mac_len)) { - LOG_D(NR_MAC, "%s() Invalid CCCH1 message!, pdu_len: %d\n", __func__, pdu_len); - done = 1; - break; - } - } else { - // fixed length of 6 bytes - mac_len = 6; - } - - send_initial_ul_rrc_message(module_idP, - CC_id, - UE, - CCCH, - pduP + mac_subheader_len, - mac_len); - break; - - case UL_SCH_LCID_DTCH ... (UL_SCH_LCID_DTCH + 28): - // check if LCID is valid at current time. - if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) { - return 0; - } - - - LOG_D(NR_MAC, "[UE %04x] %d.%d : ULSCH -> UL-%s %d (gNB %ld, %d bytes)\n", - UE->rnti, - frameP, - slot, - rx_lcid<4?"DCCH":"DTCH", - rx_lcid, - module_idP, - mac_len); - UE->mac_stats.ul.lc_bytes[rx_lcid] += mac_len; - - mac_rlc_data_ind(module_idP, - UE->rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - rx_lcid, - (char *)(pduP + mac_subheader_len), - mac_len, - 1, - NULL); - - /* Updated estimated buffer when receiving data */ - if (sched_ctrl->estimated_ul_buffer >= mac_len) { - sched_ctrl->estimated_ul_buffer -= mac_len; - } else { - sched_ctrl->estimated_ul_buffer = 0; - } - - break; - - default: - LOG_E(NR_MAC, "Received unknown MAC header (LCID = 0x%02x)\n", rx_lcid); - return -1; - break; - } - - #ifdef ENABLE_MAC_PAYLOAD_DEBUG - if (rx_lcid < 45 || rx_lcid == 52 || rx_lcid == 63) { - LOG_I(NR_MAC, "In %s: dumping UL MAC SDU sub-header with length %d (LCID = 0x%02x):\n", __func__, mac_subheader_len, rx_lcid); - log_dump(NR_MAC, pduP, mac_subheader_len, LOG_DUMP_CHAR, "\n"); - LOG_I(NR_MAC, "In %s: dumping UL MAC SDU with length %d (LCID = 0x%02x):\n", __func__, mac_len, rx_lcid); - log_dump(NR_MAC, pduP + mac_subheader_len, mac_len, LOG_DUMP_CHAR, "\n"); - } else { - LOG_I(NR_MAC, "In %s: dumping UL MAC CE with length %d (LCID = 0x%02x):\n", __func__, mac_len, rx_lcid); - log_dump(NR_MAC, pduP + mac_subheader_len + mac_len, mac_len, LOG_DUMP_CHAR, "\n"); - } - #endif - - pduP += ( mac_subheader_len + mac_len ); - pdu_len -= ( mac_subheader_len + mac_len ); - - if (pdu_len < 0) { - LOG_E(NR_MAC, "In %s: residual UL MAC PDU in %d.%d with length < 0!, pdu_len %d \n", __func__, frameP, slot, pdu_len); - LOG_E(NR_MAC, "MAC PDU "); - for (int i = 0; i < 20; i++) // Only printf 1st - 20nd bytes - printf("%02x ", pduP[i]); - printf("\n"); + switch(rx_lcid){ + // MAC CE + /*#ifdef DEBUG_HEADER_PARSING + LOG_D(NR_MAC, "[UE] LCID %d, PDU length %d\n", ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID, pdu_len); + #endif*/ + case UL_SCH_LCID_RECOMMENDED_BITRATE_QUERY: + // 38.321 Ch6.1.3.20 + mac_len = 2; + break; + case UL_SCH_LCID_CONFIGURED_GRANT_CONFIRMATION: + // 38.321 Ch6.1.3.7 + break; + case UL_SCH_LCID_S_BSR: + case UL_SCH_LCID_S_TRUNCATED_BSR: + //38.321 section 6.1.3.1 + //fixed length + mac_len =1; + /* Extract short BSR value */ + ce_ptr = &pduP[mac_subheader_len]; + NR_BSR_SHORT *bsr_s = (NR_BSR_SHORT *) ce_ptr; + sched_ctrl->estimated_ul_buffer = 0; + sched_ctrl->estimated_ul_buffer = NR_SHORT_BSR_TABLE[bsr_s->Buffer_size]; + LOG_D(NR_MAC, + "SHORT BSR at %4d.%2d, LCG ID %d, BS Index %d, BS value < %d, est buf %d\n", + frameP, + slot, + bsr_s->LcgID, + bsr_s->Buffer_size, + NR_SHORT_BSR_TABLE[bsr_s->Buffer_size], + sched_ctrl->estimated_ul_buffer); + break; + case UL_SCH_LCID_L_BSR: + case UL_SCH_LCID_L_TRUNCATED_BSR: + //38.321 section 6.1.3.1 + //variable length + /* Several checks have been added to this function to + ensure that the casting of the pduP is possible. There seems + to be a partial PDU at the end of this buffer, so here + we gracefully ignore that by returning 0. See: + https://gitlab.eurecom.fr/oai/openairinterface5g/-/issues/534 */ + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) return 0; + /* Extract long BSR value */ + ce_ptr = &pduP[mac_subheader_len]; + NR_BSR_LONG *bsr_l = (NR_BSR_LONG *) ce_ptr; + sched_ctrl->estimated_ul_buffer = 0; + + n_Lcg = bsr_l->LcgID7 + bsr_l->LcgID6 + bsr_l->LcgID5 + bsr_l->LcgID4 + + bsr_l->LcgID3 + bsr_l->LcgID2 + bsr_l->LcgID1 + bsr_l->LcgID0; + + LOG_D(NR_MAC, "LONG BSR, LCG ID(7-0) %d/%d/%d/%d/%d/%d/%d/%d\n", + bsr_l->LcgID7, bsr_l->LcgID6, bsr_l->LcgID5, bsr_l->LcgID4, + bsr_l->LcgID3, bsr_l->LcgID2, bsr_l->LcgID1, bsr_l->LcgID0); + + for (int n = 0; n < n_Lcg; n++){ + LOG_D(NR_MAC, "LONG BSR, %d/%d (n/n_Lcg), BS Index %d, BS value < %d", + n, n_Lcg, pduP[mac_subheader_len + 1 + n], + NR_LONG_BSR_TABLE[pduP[mac_subheader_len + 1 + n]]); + sched_ctrl->estimated_ul_buffer += NR_LONG_BSR_TABLE[pduP[mac_subheader_len + 1 + n]]; + LOG_D(NR_MAC, + "LONG BSR at %4d.%2d, %d/%d (n/n_Lcg), BS Index %d, BS value < %d, total %d\n", + frameP, + slot, + n, + n_Lcg, + pduP[mac_subheader_len + 1 + n], + NR_LONG_BSR_TABLE[pduP[mac_subheader_len + 1 + n]], + sched_ctrl->estimated_ul_buffer); } - } + + break; + + case UL_SCH_LCID_C_RNTI: + + for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { + NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[i]; + if (ra->state >= WAIT_Msg3 && ra->rnti == UE->rnti) { + ra->crnti = ((pduP[1]&0xFF)<<8)|(pduP[2]&0xFF); + ra->msg3_dcch_dtch = true; + LOG_I(NR_MAC, "Received UL_SCH_LCID_C_RNTI with C-RNTI 0x%04x\n", ra->crnti); + break; + } + } + + //38.321 section 6.1.3.2 + //fixed length + mac_len = 2; + /* Extract CRNTI value */ + break; + + case UL_SCH_LCID_SINGLE_ENTRY_PHR: + AssertFatal(harq_pid>-1,"Invalid HARQ PID %d\n",harq_pid); + NR_sched_pusch_t *sched_pusch = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch;; + //38.321 section 6.1.3.8 + //fixed length + mac_len = 2; + /* Extract SINGLE ENTRY PHR elements for PHR calculation */ + ce_ptr = &pduP[mac_subheader_len]; + NR_SINGLE_ENTRY_PHR_MAC_CE *phr = (NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr; + /* Save the phr info */ + int PH; + const int PCMAX = phr->PCMAX; + /* 38.133 Table10.1.17.1-1 */ + if (phr->PH < 55) + PH = phr->PH - 32; + else + PH = phr->PH - 32 + (phr->PH - 54); + // in sched_ctrl we set normalized PH wrt MCS and PRBs + long *deltaMCS = ul_bwp->pusch_Config ? ul_bwp->pusch_Config->pusch_PowerControl->deltaMCS : NULL; + sched_ctrl->ph = PH + + compute_bw_factor(sched_pusch->mu, sched_pusch->rbSize) + + compute_delta_tf(sched_pusch->tb_size<<3, + sched_pusch->rbSize, + 0, //n_layers + 0, //n_symbols + 0, //n_dmrs + deltaMCS); + /* 38.133 Table10.1.18.1-1 */ + sched_ctrl->pcmax = PCMAX - 29; + LOG_D(NR_MAC, "SINGLE ENTRY PHR R1 %d PH %d (%d dB) R2 %d PCMAX %d (%d dBm)\n", + phr->R1, PH, sched_ctrl->ph, phr->R2, PCMAX, sched_ctrl->pcmax); + break; + + case UL_SCH_LCID_MULTI_ENTRY_PHR_1_OCT: + //38.321 section 6.1.3.9 + // varialbe length + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) + return 0; + /* Extract MULTI ENTRY PHR elements from single octet bitmap for PHR calculation */ + break; + + case UL_SCH_LCID_MULTI_ENTRY_PHR_4_OCT: + //38.321 section 6.1.3.9 + // varialbe length + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) + return 0; + /* Extract MULTI ENTRY PHR elements from four octets bitmap for PHR calculation */ + break; + + case UL_SCH_LCID_PADDING: + done = 1; + // end of MAC PDU, can ignore the rest. + break; + + case UL_SCH_LCID_SRB1: + case UL_SCH_LCID_SRB2: + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) + return 0; + + rnti_t crnti = UE->rnti; + NR_UE_info_t* UE_idx = UE; + for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { + NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[i]; + if (ra->state >= WAIT_Msg3 && ra->rnti == UE->rnti) { + uint8_t *next_subpduP = pduP + mac_subheader_len + mac_len; + if ((pduP[mac_subheader_len+mac_len] & 0x3F) == UL_SCH_LCID_C_RNTI) { + crnti = ((next_subpduP[1]&0xFF)<<8)|(next_subpduP[2]&0xFF); + LOG_W(NR_MAC, " UL_SCH_LCID_SRB for rnti %04x\n", crnti); + UE_idx = find_nr_UE(&RC.nrmac[module_idP]->UE_info, crnti); + break; + } + } + } + + if (UE_idx->CellGroup) { + LOG_D(NR_MAC, "Frame %d : ULSCH -> UL-DCCH %d (gNB %ld, %d bytes), rnti: 0x%04x \n", frameP, rx_lcid, module_idP, mac_len, crnti); + mac_rlc_data_ind(module_idP, + crnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + rx_lcid, + (char *) (pduP + mac_subheader_len), + mac_len, + 1, + NULL); + } else { + AssertFatal(1==0,"[UE %04x] Frame/Slot %d.%d : Received LCID %d which is not configured, dropping packet\n",UE->rnti,frameP,slot,rx_lcid); + } + break; + + case UL_SCH_LCID_CCCH: + case UL_SCH_LCID_CCCH1: + // fixed length + mac_subheader_len = 1; + + if ( rx_lcid == UL_SCH_LCID_CCCH1 ) { + // RRCResumeRequest1 message includes the full I-RNTI and has a size of 8 bytes + mac_len = 8; + + // Check if it is a valid CCCH1 message, we get all 00's messages very often + int i = 0; + for(i=0; i<(mac_subheader_len+mac_len); i++) { + if(pduP[i] != 0) { + break; + } + } + if (i == (mac_subheader_len+mac_len)) { + LOG_D(NR_MAC, "%s() Invalid CCCH1 message!, pdu_len: %d\n", __func__, pdu_len); + done = 1; + break; + } + } else { + // fixed length of 6 bytes + mac_len = 6; + } + + send_initial_ul_rrc_message(module_idP, + CC_id, + UE, + CCCH, + pduP + mac_subheader_len, + mac_len); + break; + + case UL_SCH_LCID_DTCH ... (UL_SCH_LCID_DTCH + 28): + // check if LCID is valid at current time. + if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len)) + return 0; + + LOG_D(NR_MAC, "[UE %04x] %d.%d : ULSCH -> UL-%s %d (gNB %ld, %d bytes)\n", + UE->rnti, + frameP, + slot, + rx_lcid<4?"DCCH":"DTCH", + rx_lcid, + module_idP, + mac_len); + UE->mac_stats.ul.lc_bytes[rx_lcid] += mac_len; + + mac_rlc_data_ind(module_idP, + UE->rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + rx_lcid, + (char *)(pduP + mac_subheader_len), + mac_len, + 1, + NULL); + + sdus += 1; + /* Updated estimated buffer when receiving data */ + if (sched_ctrl->estimated_ul_buffer >= mac_len) + sched_ctrl->estimated_ul_buffer -= mac_len; + else + sched_ctrl->estimated_ul_buffer = 0; + break; + + default: + LOG_E(NR_MAC, "Received unknown MAC header (LCID = 0x%02x)\n", rx_lcid); + return -1; + break; + } + +#ifdef ENABLE_MAC_PAYLOAD_DEBUG + if (rx_lcid < 45 || rx_lcid == 52 || rx_lcid == 63) { + LOG_I(NR_MAC, "In %s: dumping UL MAC SDU sub-header with length %d (LCID = 0x%02x):\n", __func__, mac_subheader_len, rx_lcid); + log_dump(NR_MAC, pduP, mac_subheader_len, LOG_DUMP_CHAR, "\n"); + LOG_I(NR_MAC, "In %s: dumping UL MAC SDU with length %d (LCID = 0x%02x):\n", __func__, mac_len, rx_lcid); + log_dump(NR_MAC, pduP + mac_subheader_len, mac_len, LOG_DUMP_CHAR, "\n"); + } else { + LOG_I(NR_MAC, "In %s: dumping UL MAC CE with length %d (LCID = 0x%02x):\n", __func__, mac_len, rx_lcid); + log_dump(NR_MAC, pduP + mac_subheader_len + mac_len, mac_len, LOG_DUMP_CHAR, "\n"); + } +#endif + + pduP += ( mac_subheader_len + mac_len ); + pdu_len -= ( mac_subheader_len + mac_len ); + + if (pdu_len < 0) { + LOG_E(NR_MAC, "In %s: residual UL MAC PDU in %d.%d with length < 0!, pdu_len %d \n", __func__, frameP, slot, pdu_len); + LOG_E(NR_MAC, "MAC PDU "); + for (int i = 0; i < 20; i++) // Only printf 1st - 20nd bytes + printf("%02x ", pduP[i]); + printf("\n"); + return 0; + } + } + + UE->mac_stats.ul.num_mac_sdu += sdus; + return 0; } @@ -541,9 +574,9 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, LOG_I(NR_MAC, "Printing received UL MAC payload at gNB side: %d \n"); for (int i = 0; i < sdu_lenP ; i++) { - //harq_process_ul_ue->a[i] = (unsigned char) rand(); - //printf("a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]); - printf("%02x ",(unsigned char)sduP[i]); + //harq_process_ul_ue->a[i] = (unsigned char) rand(); + //printf("a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]); + printf("%02x ",(unsigned char)sduP[i]); } printf("\n"); @@ -558,7 +591,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, if (UE_scheduling_control->sched_ul_bytes < 0) UE_scheduling_control->sched_ul_bytes = 0; - nr_process_mac_pdu(gnb_mod_idP, UE, CC_idP, frameP, slotP, sduP, sdu_lenP); + nr_process_mac_pdu(gnb_mod_idP, UE, CC_idP, frameP, slotP, sduP, sdu_lenP, harq_pid); } else { NR_UE_ul_harq_t *cur_harq = &UE_scheduling_control->ul_harq_processes[harq_pid]; @@ -657,17 +690,18 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, current_rnti, ra->rnti); - NR_UE_sched_ctrl_t *UE_scheduling_control = &UE->UE_sched_ctrl; + NR_UE_sched_ctrl_t *UE_scheduling_control = &UE->UE_sched_ctrl; - UE_scheduling_control->tpc0 = nr_get_tpc(target_snrx10,ul_cqi,30); - if (timing_advance != 0xffff) - UE_scheduling_control->ta_update = timing_advance; - UE_scheduling_control->raw_rssi = rssi; - UE_scheduling_control->pusch_snrx10 = ul_cqi * 5 - 640; - LOG_D(NR_MAC, "[UE %04x] PUSCH TPC %d and TA %d\n",UE->rnti,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); + UE_scheduling_control->tpc0 = nr_get_tpc(target_snrx10,ul_cqi,30); + if (timing_advance != 0xffff) + UE_scheduling_control->ta_update = timing_advance; + UE_scheduling_control->raw_rssi = rssi; + UE_scheduling_control->pusch_snrx10 = ul_cqi * 5 - 640; + LOG_D(NR_MAC, "[UE %04x] PUSCH TPC %d and TA %d\n",UE->rnti,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); if(ra->cfra) { LOG_A(NR_MAC, "(rnti 0x%04x) CFRA procedure succeeded!\n", ra->rnti); + UE->ra_timer = 0; nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); process_CellGroup(ra->CellGroup, UE_scheduling_control); @@ -684,8 +718,9 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, // Store the first 48 bits belonging to the uplink CCCH SDU within Msg3 to fill in Msg4 // First byte corresponds to R/LCID MAC sub-header memcpy(ra->cont_res_id, &sduP[1], sizeof(uint8_t) * 6); - - if (nr_process_mac_pdu(gnb_mod_idP, UE, CC_idP, frameP, slotP, sduP, sdu_lenP) == 0) { + // harq_pid set a non valid value because it is not used in this call + // the function is only called to decode the contention resolution sub-header + if (nr_process_mac_pdu(gnb_mod_idP, UE, CC_idP, frameP, slotP, sduP, sdu_lenP, -1) == 0) { ra->state = Msg4; ra->Msg4_frame = (frameP + 2) % 1024; ra->Msg4_slot = 1; @@ -857,6 +892,65 @@ static bool nr_UE_is_to_be_scheduled(const NR_ServingCellConfigCommon_t *scc, return has_data || sched_ctrl->SR || high_inactivity; } +void update_ul_ue_R_Qm(int mcs, int mcs_table, const NR_PUSCH_Config_t *pusch_Config, uint16_t *R, uint8_t *Qm) +{ + *R = nr_get_code_rate_ul(mcs, mcs_table); + *Qm = nr_get_Qm_ul(mcs, mcs_table); + + if (pusch_Config && pusch_Config->tp_pi2BPSK && ((mcs_table == 3 && mcs < 2) || (mcs_table == 4 && mcs < 6))) { + *R >>= 1; + *Qm <<= 1; + } +} + + +void nr_ue_max_mcs_min_rb(int mu, int ph_limit, NR_pusch_semi_static_t *ps, NR_UE_UL_BWP_t *ul_bwp, uint16_t minRb, uint32_t tbs, uint16_t *Rb, uint8_t *mcs) +{ + AssertFatal(*Rb >= minRb, "illegal Rb %d < minRb %d\n", *Rb, minRb); + AssertFatal(*mcs >= 0 && *mcs <= 28, "illegal MCS %d\n", *mcs); + + const int tbs_bits = tbs << 3; + uint16_t R; + uint8_t Qm; + update_ul_ue_R_Qm(*mcs, ul_bwp->mcs_table, ul_bwp->pusch_Config, &R, &Qm); + + long *deltaMCS = ul_bwp->pusch_Config ? ul_bwp->pusch_Config->pusch_PowerControl->deltaMCS : NULL; + int tx_power = compute_bw_factor(mu, *Rb) + + compute_delta_tf(tbs_bits, + *Rb, + ps->nrOfLayers, + ps->nrOfSymbols, + ps->N_PRB_DMRS*ps->num_dmrs_symb, + deltaMCS); + + while (ph_limit < tx_power && *Rb >= minRb) { + (*Rb)--; + tx_power = compute_bw_factor(mu, *Rb) + + compute_delta_tf(tbs_bits, + *Rb, + ps->nrOfLayers, + ps->nrOfSymbols, + ps->N_PRB_DMRS*ps->num_dmrs_symb, + deltaMCS); + } + + while (ph_limit < tx_power && *mcs > 6) { + (*mcs)--; + update_ul_ue_R_Qm(*mcs, ul_bwp->mcs_table, ul_bwp->pusch_Config, &R, &Qm); + tx_power = compute_bw_factor(mu, *Rb) + + compute_delta_tf(tbs_bits, + *Rb, + ps->nrOfLayers, + ps->nrOfSymbols, + ps->N_PRB_DMRS*ps->num_dmrs_symb, + deltaMCS); + } + + if (ph_limit < tx_power) + LOG_W(NR_MAC, "Normalized power %d based on current resources (RBs %d, MCS %d) exceed reported PHR %d (normalized value)\n", + tx_power, *Rb, *mcs, ph_limit); +} + static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, frame_t frame, sub_frame_t slot, @@ -999,18 +1093,6 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, return true; } -void update_ul_ue_R_Qm(NR_sched_pusch_t *sched_pusch, const NR_PUSCH_Config_t *pusch_Config, const int mcs_table) { - - const int mcs = sched_pusch->mcs; - sched_pusch->R = nr_get_code_rate_ul(mcs, mcs_table); - sched_pusch->Qm = nr_get_Qm_ul(mcs, mcs_table); - - if (pusch_Config && pusch_Config->tp_pi2BPSK && ((mcs_table == 3 && mcs < 2) || (mcs_table == 4 && mcs < 6))) { - sched_pusch->R >>= 1; - sched_pusch->Qm <<= 1; - } -} - uint32_t ul_pf_tbs[3][29]; // pre-computed, approximate TBS values for PF coefficient typedef struct UEsched_s { float coef; @@ -1181,7 +1263,7 @@ void pf_ul(module_id_t module_id, NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; sched_pusch->mcs = min(nrmac->min_grant_mcs, sched_pusch->mcs); - update_ul_ue_R_Qm(sched_pusch, current_BWP->pusch_Config, current_BWP->mcs_table); + update_ul_ue_R_Qm(sched_pusch->mcs, current_BWP->mcs_table, current_BWP->pusch_Config, &sched_pusch->R, &sched_pusch->Qm); sched_pusch->rbStart = rbStart; sched_pusch->rbSize = min_rb; sched_pusch->tb_size = nr_compute_tbs(sched_pusch->Qm, @@ -1267,7 +1349,7 @@ void pf_ul(module_id_t module_id, nrOfLayers, ps); } - update_ul_ue_R_Qm(sched_pusch, current_BWP->pusch_Config, current_BWP->mcs_table); + update_ul_ue_R_Qm(sched_pusch->mcs, current_BWP->mcs_table, current_BWP->pusch_Config, &sched_pusch->R, &sched_pusch->Qm); int rbStart = 0; const uint16_t slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); @@ -1286,8 +1368,17 @@ void pf_ul(module_id_t module_id, else LOG_D(NR_MAC,"allocating UL data for RNTI %04x (rbStsart %d, min_rb %d, bwpSize %d)\n", iterator->UE->rnti,rbStart,min_rb,bwpSize); - /* Calculate the current scheduling bytes and the necessary RBs */ + /* Calculate the current scheduling bytes */ const int B = cmax(sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes, 0); + /* adjust rbSize and MCS according to PHR and BPRE */ + sched_pusch->mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + if(sched_ctrl->pcmax!=0 || + sched_ctrl->ph!=0) // verify if the PHR related parameter have been initialized + nr_ue_max_mcs_min_rb(sched_pusch->mu, sched_ctrl->ph, ps, current_BWP, min_rbSize, B, &max_rbSize, &sched_pusch->mcs); + + if (sched_pusch->mcs < sched_ctrl->ul_bler_stats.mcs) + sched_ctrl->ul_bler_stats.mcs = sched_pusch->mcs; /* force estimated MCS down */ + uint16_t rbSize = 0; uint32_t TBS = 0; @@ -1301,6 +1392,7 @@ void pf_ul(module_id_t module_id, max_rbSize, &TBS, &rbSize); + sched_pusch->rbSize = rbSize; sched_pusch->tb_size = TBS; LOG_D(NR_MAC,"rbSize %d (max_rbSize %d), TBS %d, est buf %d, sched_ul %d, B %d, CCE %d, num_dmrs_symb %d, N_PRB_DMRS %d\n", @@ -1360,18 +1452,6 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t if (!is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot)) return false; - bool is_mixed_slot = false; - const NR_TDD_UL_DL_Pattern_t *tdd = - scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; - - if (tdd) - is_mixed_slot = is_xlsch_in_slot(nr_mac->dlsch_slot_bitmap[sched_slot / 64], sched_slot) && - is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot); - - // FIXME: Avoid mixed slots for initialUplinkBWP - if (current_BWP->bwp_id==0 && is_mixed_slot) - return false; - // Avoid slots with the SRS UE_iterator(nr_mac->UE_info.list, UE) { NR_sched_srs_t sched_srs = UE->UE_sched_ctrl.sched_srs; @@ -1503,6 +1583,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; UE->mac_stats.ul.current_bytes = 0; + UE->mac_stats.ul.current_rbs = 0; /* dynamic PUSCH values (RB alloc, MCS, hence R, Qm, TBS) that change in * every TTI are pre-populated by the preprocessor and used below */ @@ -1557,6 +1638,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) * retransmissions */ cur_harq->sched_pusch.time_domain_allocation = ps->time_domain_allocation; sched_ctrl->sched_ul_bytes += sched_pusch->tb_size; + UE->mac_stats.ul.total_rbs += sched_pusch->rbSize; + } else { LOG_D(NR_MAC, "%d.%2d UL retransmission RNTI %04x sched %d.%2d HARQ PID %d round %d NDI %d\n", @@ -1568,8 +1651,10 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) harq_id, cur_harq->round, cur_harq->ndi); + UE->mac_stats.ul.total_rbs_retx += sched_pusch->rbSize; } UE->mac_stats.ul.current_bytes = sched_pusch->tb_size; + UE->mac_stats.ul.current_rbs = sched_pusch->rbSize; sched_ctrl->last_ul_frame = sched_pusch->frame; sched_ctrl->last_ul_slot = sched_pusch->slot; @@ -1692,7 +1777,22 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->pusch_data.tb_size = sched_pusch->tb_size; pusch_pdu->pusch_data.num_cb = 0; //CBG not supported - pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = 0; + pusch_pdu->maintenance_parms_v3.ldpcBaseGraph = get_BG(sched_pusch->tb_size<<3,sched_pusch->R); + if(current_BWP->pusch_servingcellconfig && + current_BWP->pusch_servingcellconfig->rateMatching) { + // TBS_LBRM according to section 5.4.2.1 of 38.212 + long *maxMIMO_Layers = current_BWP->pusch_servingcellconfig->ext1->maxMIMO_Layers; + if (!maxMIMO_Layers) + maxMIMO_Layers = current_BWP->pusch_Config->maxRank; + AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); + const int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int bw_tbslbrm = get_ulbw_tbslbrm(scc_bwpsize, cg); + pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(current_BWP->mcs_table, + bw_tbslbrm, + *maxMIMO_Layers); + } + else + pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = 0; LOG_D(NR_MAC,"PUSCH PDU : data_scrambling_identity %x, dmrs_scrambling_id %x\n",pusch_pdu->data_scrambling_id,pusch_pdu->ul_dmrs_scrambling_id); /* TRANSFORM PRECODING --------------------------------------------------------*/ diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 674d80a4d4..6a3f778af9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -469,7 +469,6 @@ uint16_t set_pm_index(NR_UE_sched_ctrl_t *sched_ctrl, int codebook_mode); uint8_t get_mcs_from_cqi(int mcs_table, int cqi_table, int cqi_idx); - uint8_t set_dl_nrOfLayers(NR_UE_sched_ctrl_t *sched_ctrl); const int get_dl_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 0543b09e9e..346f1f8516 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -113,6 +113,7 @@ typedef struct NR_UE_UL_BWP { long *cyclicprefix; uint16_t BWPSize; uint16_t BWPStart; + NR_PUSCH_ServingCellConfig_t *pusch_servingcellconfig; NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList; NR_PUSCH_Config_t *pusch_Config; NR_PUCCH_Config_t *pucch_Config; @@ -393,6 +394,7 @@ typedef struct NR_pusch_semi_static_t { typedef struct NR_sched_pusch { int frame; int slot; + int mu; /// RB allocation within active uBWP uint16_t rbSize; @@ -667,6 +669,10 @@ typedef struct NR_mac_dir_stats { uint64_t errors; uint64_t total_bytes; uint32_t current_bytes; + uint32_t total_rbs; + uint32_t total_rbs_retx; + uint32_t num_mac_sdu; + uint32_t current_rbs; } NR_mac_dir_stats_t; typedef struct NR_mac_stats { @@ -709,6 +715,7 @@ typedef struct { uint8_t UE_beam_index; bool Msg3_dcch_dtch; bool Msg4_ACKed; + uint32_t ra_timer; /// Sched CSI-RS: scheduling decisions NR_gNB_UCI_STATS_t uci_statS; float ul_thr_ue; @@ -849,6 +856,10 @@ typedef struct gNB_MAC_INST_s { uint8_t min_grant_mcs; nr_mac_rrc_ul_if_t mac_rrc; + + int16_t frame; + int16_t slot; + } gNB_MAC_INST; #endif /*__LAYER2_NR_MAC_GNB_H__ */ diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c index 480b651593..2c853d8eb6 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c @@ -59,6 +59,9 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, We need to investigate why this hack is neccessary. */ buffer[0] |= 128; } + entity->stats.rxpdu_pkts++; + entity->stats.rxpdu_bytes += size; + if (entity->sn_size == 12) { rcvd_sn = ((buffer[0] & 0xf) << 8) | @@ -70,6 +73,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, buffer[2]; header_size = 3; } + entity->stats.rxpdu_sn = rcvd_sn; /* SRBs always have MAC-I, even if integrity is not active */ if (entity->has_integrity || entity->type == NR_PDCP_SRB) { @@ -80,6 +84,11 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, if (size < header_size + integrity_size + 1) { LOG_E(PDCP, "bad PDU received (size = %d)\n", size); + + entity->stats.rxpdu_dd_pkts++; + entity->stats.rxpdu_dd_bytes += size; + + return; } @@ -109,12 +118,20 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, if (memcmp(integrity, buffer + size - integrity_size, 4) != 0) { LOG_E(PDCP, "discard NR PDU, integrity failed\n"); // return; + entity->stats.rxpdu_dd_pkts++; + entity->stats.rxpdu_dd_bytes += size; + + } } if (rcvd_count < entity->rx_deliv || nr_pdcp_sdu_in_list(entity->rx_list, rcvd_count)) { LOG_W(PDCP, "discard NR PDU rcvd_count=%d, entity->rx_deliv %d,sdu_in_list %d\n", rcvd_count,entity->rx_deliv,nr_pdcp_sdu_in_list(entity->rx_list,rcvd_count)); + entity->stats.rxpdu_dd_pkts++; + entity->stats.rxpdu_dd_bytes += size; + + return; } @@ -139,6 +156,10 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, cur->buffer, cur->size); entity->rx_list = cur->next; entity->rx_size -= cur->size; + entity->stats.txsdu_pkts++; + entity->stats.txsdu_bytes += cur->size; + + nr_pdcp_free_sdu(cur); count++; } @@ -165,6 +186,9 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity, int integrity_size; char buf[size + 3 + 4]; int dc_bit; + entity->stats.rxsdu_pkts++; + entity->stats.rxsdu_bytes += size; + count = entity->tx_next; sn = entity->tx_next & entity->sn_max; @@ -215,6 +239,11 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity, entity->deliver_pdu(entity->deliver_pdu_data, entity, buf, header_size + size + integrity_size, sdu_id); + entity->stats.txpdu_pkts++; + entity->stats.txpdu_bytes += header_size + size + integrity_size; + entity->stats.txpdu_sn = sn; + + } /* may be called several times, take care to clean previous settings */ @@ -346,6 +375,13 @@ void nr_pdcp_entity_delete(nr_pdcp_entity_t *entity) free(entity); } +static void nr_pdcp_entity_get_stats(nr_pdcp_entity_t *entity, + nr_pdcp_statistics_t *out) +{ + *out = entity->stats; +} + + nr_pdcp_entity_t *new_nr_pdcp_entity( nr_pdcp_entity_type_t type, int is_gnb, int rb_id, int pdusession_id,int has_sdap, @@ -381,6 +417,7 @@ nr_pdcp_entity_t *new_nr_pdcp_entity( ret->delete_entity = nr_pdcp_entity_delete; + ret->get_stats = nr_pdcp_entity_get_stats; ret->deliver_sdu = deliver_sdu; ret->deliver_sdu_data = deliver_sdu_data; diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h index 49e9c4142b..19445887f4 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h @@ -32,6 +32,39 @@ typedef enum { NR_PDCP_SRB } nr_pdcp_entity_type_t; +typedef struct { + //nr_pdcp_entity_type_t mode; + /* PDU stats */ + /* TX */ + uint32_t txpdu_pkts; /* aggregated number of tx packets */ + uint32_t txpdu_bytes; /* aggregated bytes of tx packets */ + uint32_t txpdu_sn; /* current sequence number of last tx packet (or TX_NEXT) */ + /* RX */ + uint32_t rxpdu_pkts; /* aggregated number of rx packets */ + uint32_t rxpdu_bytes; /* aggregated bytes of rx packets */ + uint32_t rxpdu_sn; /* current sequence number of last rx packet (or RX_NEXT) */ + /* TODO? */ + uint32_t rxpdu_oo_pkts; /* aggregated number of out-of-order rx pkts (or RX_REORD) */ + /* TODO? */ + uint32_t rxpdu_oo_bytes; /* aggregated amount of out-of-order rx bytes */ + uint32_t rxpdu_dd_pkts; /* aggregated number of duplicated discarded packets (or dropped packets because of other reasons such as integrity failure) (or RX_DELIV) */ + uint32_t rxpdu_dd_bytes; /* aggregated amount of discarded packets' bytes */ + /* TODO? */ + uint32_t rxpdu_ro_count; /* this state variable indicates the COUNT value following the COUNT value associated with the PDCP Data PDU which triggered t-Reordering. (RX_REORD) */ + + /* SDU stats */ + /* TX */ + uint32_t txsdu_pkts; /* number of SDUs delivered */ + uint32_t txsdu_bytes; /* number of bytes of SDUs delivered */ + + /* RX */ + uint32_t rxsdu_pkts; /* number of SDUs received */ + uint32_t rxsdu_bytes; /* number of bytes of SDUs received */ + + uint8_t mode; /* 0: PDCP AM, 1: PDCP UM, 2: PDCP TM */ +} nr_pdcp_statistics_t; + + typedef struct nr_pdcp_entity_t { nr_pdcp_entity_type_t type; @@ -40,6 +73,7 @@ typedef struct nr_pdcp_entity_t { void (*recv_sdu)(struct nr_pdcp_entity_t *entity, char *buffer, int size, int sdu_id); void (*delete_entity)(struct nr_pdcp_entity_t *entity); + void (*get_stats)(struct nr_pdcp_entity_t *entity, nr_pdcp_statistics_t *out); /* set_security: pass -1 to integrity_algorithm / ciphering_algorithm * to keep the current algorithm @@ -114,6 +148,7 @@ typedef struct nr_pdcp_entity_t { nr_pdcp_sdu_t *rx_list; int rx_size; int rx_maxsize; + nr_pdcp_statistics_t stats; } nr_pdcp_entity_t; nr_pdcp_entity_t *new_nr_pdcp_entity( diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 47c630e0c9..ece0b0274d 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -1441,6 +1441,44 @@ void nr_pdcp_tick(int frame, int subframe) /* * For the SDAP API */ -nr_pdcp_ue_manager_t *nr_pdcp_sdap_get_ue_manager(){ - return nr_pdcp_ue_manager; +nr_pdcp_ue_manager_t *nr_pdcp_sdap_get_ue_manager() { + return nr_pdcp_ue_manager; +} + +/* returns false in case of error, true if everything ok */ +const bool nr_pdcp_get_statistics( + int rnti, + int srb_flag, + int rb_id, + nr_pdcp_statistics_t *out) +{ + nr_pdcp_ue_t *ue; + nr_pdcp_entity_t *rb; + bool ret; + + nr_pdcp_manager_lock(nr_pdcp_ue_manager); + ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti); + + if (srb_flag == 1) { + if (rb_id < 1 || rb_id > 2) + rb = NULL; + else + rb = ue->srb[rb_id - 1]; + } else { + if (rb_id < 1 || rb_id > 5) + rb = NULL; + else + rb = ue->drb[rb_id - 1]; + } + + if (rb != NULL) { + rb->get_stats(rb, out); + ret = true; + } else { + ret = false; + } + + nr_pdcp_manager_unlock(nr_pdcp_ue_manager); + + return ret; } diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity.c index 1883bbdd6c..a27cf4f048 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity.c @@ -29,6 +29,21 @@ #include "LOG/log.h" +#include "common/utils/time_stat.h" + +static void nr_rlc_entity_get_stats( + nr_rlc_entity_t *entity, + nr_rlc_statistics_t *out) +{ +// printf("Stats from the RLC entity asked\n"); + *out = entity->stats; + if (entity->avg_time_is_on) + out->txsdu_avg_time_to_tx = time_average_get_average(entity->txsdu_avg_time_to_tx, + time_average_now()); + else + out->txsdu_avg_time_to_tx = 0; +} + nr_rlc_entity_t *new_nr_rlc_entity_am( int rx_maxsize, int tx_maxsize, @@ -86,6 +101,7 @@ nr_rlc_entity_t *new_nr_rlc_entity_am( ret->common.reestablishment = nr_rlc_entity_am_reestablishment; ret->common.delete = nr_rlc_entity_am_delete; ret->common.available_tx_space = nr_rlc_entity_am_available_tx_space; + ret->common.get_stats = nr_rlc_entity_get_stats; ret->common.deliver_sdu = deliver_sdu; ret->common.deliver_sdu_data = deliver_sdu_data; @@ -94,6 +110,13 @@ nr_rlc_entity_t *new_nr_rlc_entity_am( ret->common.max_retx_reached = max_retx_reached; ret->common.max_retx_reached_data = max_retx_reached_data; + ret->common.stats.mode = NR_RLC_AM; + + /* let's take average over the last 100 milliseconds + * initial_size of 1024 is arbitrary + */ + ret->common.txsdu_avg_time_to_tx = time_average_new(100 * 1000, 1024); + return (nr_rlc_entity_t *)ret; } @@ -137,10 +160,18 @@ nr_rlc_entity_t *new_nr_rlc_entity_um( ret->common.reestablishment = nr_rlc_entity_um_reestablishment; ret->common.delete = nr_rlc_entity_um_delete; ret->common.available_tx_space = nr_rlc_entity_um_available_tx_space; + ret->common.get_stats = nr_rlc_entity_get_stats; ret->common.deliver_sdu = deliver_sdu; ret->common.deliver_sdu_data = deliver_sdu_data; + ret->common.stats.mode = NR_RLC_UM; + + /* let's take average over the last 100 milliseconds + * initial_size of 1024 is arbitrary + */ + ret->common.txsdu_avg_time_to_tx = time_average_new(100 * 1000, 1024); + return (nr_rlc_entity_t *)ret; } @@ -169,9 +200,17 @@ nr_rlc_entity_t *new_nr_rlc_entity_tm( ret->common.reestablishment = nr_rlc_entity_tm_reestablishment; ret->common.delete = nr_rlc_entity_tm_delete; ret->common.available_tx_space = nr_rlc_entity_tm_available_tx_space; + ret->common.get_stats = nr_rlc_entity_get_stats; ret->common.deliver_sdu = deliver_sdu; ret->common.deliver_sdu_data = deliver_sdu_data; + ret->common.stats.mode = NR_RLC_TM; + + /* let's take average over the last 100 milliseconds + * initial_size of 1024 is arbitrary + */ + ret->common.txsdu_avg_time_to_tx = time_average_new(100 * 1000, 1024); + return (nr_rlc_entity_t *)ret; } diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity.h b/openair2/LAYER2/nr_rlc/nr_rlc_entity.h index 5cd3bee650..cd26094cf7 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity.h @@ -24,8 +24,79 @@ #include +#include "common/utils/time_stat.h" + #define NR_SDU_MAX 16000 /* max NR PDCP SDU size is 9000, let's take more */ +typedef enum { + NR_RLC_AM, + NR_RLC_UM, + NR_RLC_TM, +} nr_rlc_mode_t; + +typedef struct { + nr_rlc_mode_t mode; /* AM, UM, or TM */ + + /* PDU stats */ + /* TX */ + uint32_t txpdu_pkts; /* aggregated number of transmitted RLC PDUs */ + uint32_t txpdu_bytes; /* aggregated amount of transmitted bytes in RLC PDUs */ + /* TODO? */ + uint32_t txpdu_wt_ms; /* aggregated head-of-line tx packet waiting time to be transmitted (i.e. send to the MAC layer) */ + uint32_t txpdu_dd_pkts; /* aggregated number of dropped or discarded tx packets by RLC */ + uint32_t txpdu_dd_bytes; /* aggregated amount of bytes dropped or discarded tx packets by RLC */ + uint32_t txpdu_retx_pkts; /* aggregated number of tx pdus/pkts to be re-transmitted (only applicable to RLC AM) */ + uint32_t txpdu_retx_bytes; /* aggregated amount of bytes to be re-transmitted (only applicable to RLC AM) */ + uint32_t txpdu_segmented; /* aggregated number of segmentations */ + uint32_t txpdu_status_pkts; /* aggregated number of tx status pdus/pkts (only applicable to RLC AM) */ + uint32_t txpdu_status_bytes; /* aggregated amount of tx status bytes (only applicable to RLC AM) */ + /* TODO? */ + uint32_t txbuf_occ_bytes; /* current tx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */ + /* TODO? */ + uint32_t txbuf_occ_pkts; /* current tx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */ + /* txbuf_wd_ms: the time window for which the txbuf occupancy value is obtained - NOT IMPLEMENTED */ + + /* RX */ + uint32_t rxpdu_pkts; /* aggregated number of received RLC PDUs */ + uint32_t rxpdu_bytes; /* amount of bytes received by the RLC */ + uint32_t rxpdu_dup_pkts; /* aggregated number of duplicate packets */ + uint32_t rxpdu_dup_bytes; /* aggregated amount of duplicated bytes */ + uint32_t rxpdu_dd_pkts; /* aggregated number of rx packets dropped or discarded by RLC */ + uint32_t rxpdu_dd_bytes; /* aggregated amount of rx bytes dropped or discarded by RLC */ + uint32_t rxpdu_ow_pkts; /* aggregated number of out of window received RLC pdu */ + uint32_t rxpdu_ow_bytes; /* aggregated number of out of window bytes received RLC pdu */ + uint32_t rxpdu_status_pkts; /* aggregated number of rx status pdus/pkts (only applicable to RLC AM) */ + uint32_t rxpdu_status_bytes; /* aggregated amount of rx status bytes (only applicable to RLC AM) */ + /* rxpdu_rotout_ms: flag indicating rx reordering timeout in ms - NOT IMPLEMENTED */ + /* rxpdu_potout_ms: flag indicating the poll retransmit time out in ms - NOT IMPLEMENTED */ + /* rxpdu_sptout_ms: flag indicating status prohibit timeout in ms - NOT IMPLEMENTED */ + /* TODO? */ + uint32_t rxbuf_occ_bytes; /* current rx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */ + /* TODO? */ + uint32_t rxbuf_occ_pkts; /* current rx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */ + + /* SDU stats */ + /* TX */ + uint32_t txsdu_pkts; /* number of SDUs delivered */ + uint32_t txsdu_bytes; /* number of bytes of SDUs delivered */ + + /* RX */ + uint32_t rxsdu_pkts; /* number of SDUs received */ + uint32_t rxsdu_bytes; /* number of bytes of SDUs received */ + uint32_t rxsdu_dd_pkts; /* number of dropped or discarded SDUs */ + uint32_t rxsdu_dd_bytes; /* number of bytes of SDUs dropped or discarded */ + + /* Average time for an SDU to be passed to MAC. + * Actually measures the time it takes for any part of an SDU to be + * passed to MAC for the first time, that is: the first TX of (part of) the + * SDU. + * Since the MAC schedules in advance, it does not measure the time of + * transmission over the air, just the time to reach the MAC layer. + */ + double txsdu_avg_time_to_tx; + +} nr_rlc_statistics_t; + typedef struct { int status_size; int tx_size; @@ -52,6 +123,8 @@ typedef struct nr_rlc_entity_t { int (*available_tx_space)(struct nr_rlc_entity_t *entity); + void (*get_stats)(struct nr_rlc_entity_t *entity, nr_rlc_statistics_t *out); + /* callbacks provided to the RLC module */ void (*deliver_sdu)(void *deliver_sdu_data, struct nr_rlc_entity_t *entity, char *buf, int size); @@ -67,6 +140,10 @@ typedef struct nr_rlc_entity_t { void *max_retx_reached_data; /* buffer status computation */ nr_rlc_entity_buffer_status_t bstatus; + + nr_rlc_statistics_t stats; + time_average_t *txsdu_avg_time_to_tx; + int avg_time_is_on; } nr_rlc_entity_t; nr_rlc_entity_t *new_nr_rlc_entity_am( diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c index 91e2bed11a..3789bfad46 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c @@ -27,6 +27,7 @@ #include "nr_rlc_pdu.h" #include "LOG/log.h" +#include "common/utils/time_stat.h" /* for a given SDU/SDU segment, computes the corresponding PDU header size */ static int compute_pdu_header_size(nr_rlc_entity_am_t *entity, @@ -221,6 +222,9 @@ static void reassemble_and_deliver(nr_rlc_entity_am_t *entity, int sn) entity->common.deliver_sdu(entity->common.deliver_sdu_data, (nr_rlc_entity_t *)entity, sdu, so); + + entity->common.stats.txsdu_pkts++; + entity->common.stats.txsdu_bytes += so; } static void reception_actions(nr_rlc_entity_am_t *entity, nr_rlc_pdu_t *pdu) @@ -473,19 +477,18 @@ process_wait_list_head: * if fully acked */ if (sn_compare_tx(entity, cur_wait_list->sdu->sn, ack_sn) < 0) { - nr_rlc_sdu_segment_t *cur = cur_wait_list; - int upper_layer_id = cur->sdu->upper_layer_id; - int sdu_size = cur->sdu->size; - cur_wait_list = cur_wait_list->next; - prev_wait_list->next = cur_wait_list; + int upper_layer_id = cur_wait_list->sdu->upper_layer_id; + int sdu_size = cur_wait_list->sdu->size; + prev_wait_list->next = cur_wait_list->next; if (cur_wait_list == entity->wait_end) end_wait_list = prev_wait_list; - if (nr_rlc_free_sdu_segment(cur)) { + if (nr_rlc_free_sdu_segment(cur_wait_list)) { entity->tx_size -= sdu_size; entity->common.sdu_successful_delivery( entity->common.sdu_successful_delivery_data, (nr_rlc_entity_t *)entity, upper_layer_id); } + cur_wait_list = prev_wait_list->next; goto process_next_pdu; } @@ -594,19 +597,18 @@ nacks_done: /* current segment is acked, free it, indicate successful delivery * if fully acked */ - nr_rlc_sdu_segment_t *cur = cur_wait_list; - int upper_layer_id = cur->sdu->upper_layer_id; - int sdu_size = cur->sdu->size; + int upper_layer_id = cur_wait_list->sdu->upper_layer_id; + int sdu_size = cur_wait_list->sdu->size; prev_wait_list->next = cur_wait_list->next; if (cur_wait_list == entity->wait_end) end_wait_list = prev_wait_list; - cur_wait_list = cur_wait_list->next; - if (nr_rlc_free_sdu_segment(cur)) { + if (nr_rlc_free_sdu_segment(cur_wait_list)) { entity->tx_size -= sdu_size; entity->common.sdu_successful_delivery( entity->common.sdu_successful_delivery_data, (nr_rlc_entity_t *)entity, upper_layer_id); } + cur_wait_list = prev_wait_list->next; } /* deal with retransmit list */ while (cur_retransmit_list != NULL @@ -684,6 +686,9 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, int is_first; int is_last; + entity->common.stats.rxpdu_pkts++; + entity->common.stats.rxpdu_bytes += size; + nr_rlc_pdu_decoder_init(&decoder, buffer, size); dc = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); @@ -733,6 +738,10 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, LOG_D(RLC, "%s:%d:%s: warning: discard PDU, sn out of window (sn %d rx_next %d)\n", __FILE__, __LINE__, __FUNCTION__, sn, entity->rx_next); + + entity->common.stats.rxpdu_ow_pkts++; + entity->common.stats.rxpdu_ow_bytes += size; + goto discard; } @@ -740,6 +749,10 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, if (segment_already_received(entity, sn, so, data_size)) { LOG_D(RLC, "%s:%d:%s: warning: discard PDU, already received\n", __FILE__, __LINE__, __FUNCTION__); + + entity->common.stats.rxpdu_dup_pkts++; + entity->common.stats.rxpdu_dup_bytes += size; + goto discard; } @@ -779,6 +792,9 @@ discard: if (p) entity->status_triggered = 1; + entity->common.stats.rxpdu_dd_pkts++; + entity->common.stats.rxpdu_dd_bytes += size; + #undef R } @@ -1309,6 +1325,11 @@ static int generate_status(nr_rlc_entity_am_t *entity, char *buffer, int size) /* start t_status_prohibit */ entity->t_status_prohibit_start = entity->t_current; + entity->common.stats.txpdu_pkts++; + entity->common.stats.txpdu_bytes += encoder.byte; + entity->common.stats.txpdu_status_pkts++; + entity->common.stats.txpdu_status_bytes += encoder.byte; + return encoder.byte; } @@ -1473,6 +1494,8 @@ static int generate_retx_pdu(nr_rlc_entity_am_t *entity, char *buffer, /* update buffer status */ entity->common.bstatus.retx_size += compute_pdu_header_size(entity, next_sdu) + next_sdu->size; + + entity->common.stats.txpdu_segmented++; } /* put SDU/SDU segment in the wait list */ @@ -1496,7 +1519,14 @@ static int generate_retx_pdu(nr_rlc_entity_am_t *entity, char *buffer, entity->force_poll = 0; } - return serialize_sdu(entity, sdu, buffer, size, p); + int ret_size = serialize_sdu(entity, sdu, buffer, size, p); + entity->common.stats.txpdu_pkts++; + entity->common.stats.txpdu_bytes += ret_size; + entity->common.stats.txpdu_retx_pkts++; + entity->common.stats.txpdu_retx_bytes += ret_size; + + return ret_size; +// return serialize_sdu(entity, sdu, buffer, size, p); } static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size) @@ -1544,6 +1574,8 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size) entity->tx_list = next_sdu; if (entity->tx_end == NULL) entity->tx_end = entity->tx_list; + + entity->common.stats.txpdu_segmented++; /* update buffer status */ entity->common.bstatus.tx_size += compute_pdu_header_size(entity, next_sdu) + next_sdu->size; @@ -1582,8 +1614,21 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size) p = 1; entity->force_poll = 0; } + int ret_size = serialize_sdu(entity, sdu, buffer, size, p); - return serialize_sdu(entity, sdu, buffer, size, p); + entity->common.stats.txpdu_pkts++; + entity->common.stats.txpdu_bytes += ret_size; + + if (sdu->sdu->time_of_arrival) { + uint64_t time_now = time_average_now(); + uint64_t waited_time = time_now - sdu->sdu->time_of_arrival; + /* set time_of_arrival to 0 so as to update stats only once */ + sdu->sdu->time_of_arrival = 0; + time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time); + } + + return ret_size; +// return serialize_sdu(entity, sdu, buffer, size, p); } nr_rlc_entity_buffer_status_t nr_rlc_entity_am_buffer_status( @@ -1635,6 +1680,9 @@ void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *_entity, nr_rlc_entity_am_t *entity = (nr_rlc_entity_am_t *)_entity; nr_rlc_sdu_segment_t *sdu; + entity->common.stats.rxsdu_pkts++; + entity->common.stats.rxsdu_bytes += size; + if (size > NR_SDU_MAX) { LOG_E(RLC, "%s:%d:%s: fatal: SDU size too big (%d bytes)\n", __FILE__, __LINE__, __FUNCTION__, size); @@ -1667,6 +1715,9 @@ void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *_entity, /* update buffer status */ entity->common.bstatus.tx_size += compute_pdu_header_size(entity, sdu) + sdu->size; + + if (entity->common.avg_time_is_on) + sdu->sdu->time_of_arrival = time_average_now(); } /*************************************************************************/ @@ -1908,6 +1959,7 @@ void nr_rlc_entity_am_delete(nr_rlc_entity_t *_entity) { nr_rlc_entity_am_t *entity = (nr_rlc_entity_am_t *)_entity; clear_entity(entity); + time_average_free(entity->common.txsdu_avg_time_to_tx); free(entity); } diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c index f85edbba0f..cfadf43d99 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_tm.c @@ -25,6 +25,7 @@ #include #include "nr_rlc_pdu.h" +#include "common/utils/time_stat.h" #include "LOG/log.h" @@ -36,9 +37,16 @@ void nr_rlc_entity_tm_recv_pdu(nr_rlc_entity_t *_entity, char *buffer, int size) { nr_rlc_entity_tm_t *entity = (nr_rlc_entity_tm_t *)_entity; + + entity->common.stats.rxpdu_pkts++; + entity->common.stats.rxpdu_bytes += size; + entity->common.deliver_sdu(entity->common.deliver_sdu_data, (nr_rlc_entity_t *)entity, buffer, size); + + entity->common.stats.txsdu_pkts++; + entity->common.stats.txsdu_bytes += size; } /*************************************************************************/ @@ -68,6 +76,16 @@ static int generate_tx_pdu(nr_rlc_entity_tm_t *entity, char *buffer, int size) memcpy(buffer, sdu->sdu->data, sdu->size); entity->tx_size -= sdu->size; + entity->common.stats.txpdu_pkts++; + entity->common.stats.txpdu_bytes += size; + + if (sdu->sdu->time_of_arrival) { + uint64_t time_now = time_average_now(); + uint64_t waited_time = time_now - sdu->sdu->time_of_arrival; + /* set time_of_arrival to 0 so as to update stats only once */ + sdu->sdu->time_of_arrival = 0; + time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time); + } /* update buffer status */ entity->common.bstatus.tx_size -= sdu->size; @@ -109,6 +127,9 @@ void nr_rlc_entity_tm_recv_sdu(nr_rlc_entity_t *_entity, nr_rlc_entity_tm_t *entity = (nr_rlc_entity_tm_t *)_entity; nr_rlc_sdu_segment_t *sdu; + entity->common.stats.rxsdu_pkts++; + entity->common.stats.rxsdu_bytes += size; + if (size > NR_SDU_MAX) { LOG_E(RLC, "%s:%d:%s: fatal: SDU size too big (%d bytes)\n", __FILE__, __LINE__, __FUNCTION__, size); @@ -118,6 +139,10 @@ void nr_rlc_entity_tm_recv_sdu(nr_rlc_entity_t *_entity, if (entity->tx_size + size > entity->tx_maxsize) { LOG_D(RLC, "%s:%d:%s: warning: SDU rejected, SDU buffer full\n", __FILE__, __LINE__, __FUNCTION__); + + entity->common.stats.rxsdu_dd_pkts++; + entity->common.stats.rxsdu_dd_bytes += size; + return; } @@ -129,6 +154,9 @@ void nr_rlc_entity_tm_recv_sdu(nr_rlc_entity_t *_entity, /* update buffer status */ entity->common.bstatus.tx_size += sdu->size; + + if (entity->common.avg_time_is_on) + sdu->sdu->time_of_arrival = time_average_now(); } /*************************************************************************/ @@ -172,6 +200,7 @@ void nr_rlc_entity_tm_delete(nr_rlc_entity_t *_entity) { nr_rlc_entity_tm_t *entity = (nr_rlc_entity_tm_t *)_entity; clear_entity(entity); + time_average_free(entity->common.txsdu_avg_time_to_tx); free(entity); } diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c index 5f2fd592a0..43a2189c51 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c @@ -27,6 +27,7 @@ #include "nr_rlc_pdu.h" #include "LOG/log.h" +#include "common/utils/time_stat.h" /* for a given SDU/SDU segment, computes the corresponding PDU header size */ static int compute_pdu_header_size(nr_rlc_entity_um_t *entity, @@ -179,6 +180,9 @@ static void reassemble_and_deliver(nr_rlc_entity_um_t *entity, int sn) entity->common.deliver_sdu(entity->common.deliver_sdu_data, (nr_rlc_entity_t *)entity, sdu, so); + + entity->common.stats.txsdu_pkts++; + entity->common.stats.txsdu_bytes += so; } static void reception_actions(nr_rlc_entity_um_t *entity, nr_rlc_pdu_t *pdu) @@ -208,6 +212,15 @@ static void reception_actions(nr_rlc_entity_um_t *entity, nr_rlc_pdu_t *pdu) nr_rlc_pdu_t *p = entity->rx_list; entity->rx_size -= p->size; entity->rx_list = p->next; + + entity->common.stats.rxpdu_dd_pkts++; + /* we don't count PDU header bytes here, so be it */ + entity->common.stats.rxpdu_dd_bytes += p->size; + + entity->common.stats.rxpdu_ow_pkts++; + /* we don't count PDU header bytes here, so be it */ + entity->common.stats.rxpdu_ow_bytes += p->size; + nr_rlc_free_pdu(p); } @@ -272,6 +285,9 @@ void nr_rlc_entity_um_recv_pdu(nr_rlc_entity_t *_entity, int is_first; int is_last; + entity->common.stats.rxpdu_pkts++; + entity->common.stats.rxpdu_bytes += size; + nr_rlc_pdu_decoder_init(&decoder, buffer, size); si = nr_rlc_pdu_decoder_get_bits(&decoder, 2); R(decoder); @@ -290,6 +306,10 @@ void nr_rlc_entity_um_recv_pdu(nr_rlc_entity_t *_entity, entity->common.deliver_sdu(entity->common.deliver_sdu_data, (nr_rlc_entity_t *)entity, buffer + 1, size - 1); + + entity->common.stats.txsdu_pkts++; + entity->common.stats.txsdu_bytes += size - 1; + return; } @@ -350,6 +370,9 @@ err: goto discard; discard: + entity->common.stats.rxpdu_dd_pkts++; + entity->common.stats.rxpdu_dd_bytes += size; + return; #undef R @@ -434,6 +457,8 @@ static nr_rlc_sdu_segment_t *resegment(nr_rlc_sdu_segment_t *sdu, next->so = sdu->so + sdu->size; next->is_first = 0; + entity->common.stats.txpdu_segmented++; + return next; } @@ -478,6 +503,8 @@ static int generate_tx_pdu(nr_rlc_entity_um_t *entity, char *buffer, int size) entity->tx_list = next_sdu; if (entity->tx_end == NULL) entity->tx_end = entity->tx_list; + + entity->common.stats.txpdu_segmented++; /* update buffer status */ entity->common.bstatus.tx_size += compute_pdu_header_size(entity, next_sdu) + next_sdu->size; @@ -490,6 +517,18 @@ static int generate_tx_pdu(nr_rlc_entity_um_t *entity, char *buffer, int size) ret = serialize_sdu(entity, sdu, buffer, size); entity->tx_size -= sdu->size; + + entity->common.stats.txpdu_pkts++; + entity->common.stats.txpdu_bytes += size; + + if (sdu->sdu->time_of_arrival) { + uint64_t time_now = time_average_now(); + uint64_t waited_time = time_now - sdu->sdu->time_of_arrival; + /* set time_of_arrival to 0 so as to update stats only once */ + sdu->sdu->time_of_arrival = 0; + time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time); + } + nr_rlc_free_sdu_segment(sdu); return ret; @@ -527,6 +566,9 @@ void nr_rlc_entity_um_recv_sdu(nr_rlc_entity_t *_entity, nr_rlc_entity_um_t *entity = (nr_rlc_entity_um_t *)_entity; nr_rlc_sdu_segment_t *sdu; + entity->common.stats.rxsdu_pkts++; + entity->common.stats.rxsdu_bytes += size; + if (size > NR_SDU_MAX) { LOG_E(RLC, "%s:%d:%s: fatal: SDU size too big (%d bytes)\n", __FILE__, __LINE__, __FUNCTION__, size); @@ -536,6 +578,10 @@ void nr_rlc_entity_um_recv_sdu(nr_rlc_entity_t *_entity, if (entity->tx_size + size > entity->tx_maxsize) { LOG_W(RLC, "%s:%d:%s: warning: SDU rejected, SDU buffer full\n", __FILE__, __LINE__, __FUNCTION__); + + entity->common.stats.rxsdu_dd_pkts++; + entity->common.stats.rxsdu_dd_bytes += size; + return; } @@ -548,6 +594,9 @@ void nr_rlc_entity_um_recv_sdu(nr_rlc_entity_t *_entity, /* update buffer status */ entity->common.bstatus.tx_size += compute_pdu_header_size(entity, sdu) + sdu->size; + + if (entity->common.avg_time_is_on) + sdu->sdu->time_of_arrival = time_average_now(); } /*************************************************************************/ @@ -584,6 +633,11 @@ static void check_t_reassembly(nr_rlc_entity_um_t *entity) nr_rlc_pdu_t *p = cur; cur = cur->next; entity->rx_list = cur; + + entity->common.stats.rxpdu_dd_pkts++; + /* we don't count PDU header bytes here, so be it */ + entity->common.stats.rxpdu_dd_bytes += p->size; + nr_rlc_free_pdu(p); } @@ -693,6 +747,7 @@ void nr_rlc_entity_um_delete(nr_rlc_entity_t *_entity) { nr_rlc_entity_um_t *entity = (nr_rlc_entity_um_t *)_entity; clear_entity(entity); + time_average_free(entity->common.txsdu_avg_time_to_tx); free(entity); } diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 4bd4ea75fd..30d1d13baa 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -1110,3 +1110,66 @@ void rlc_tick(int a, int b) __FILE__, __LINE__, __FUNCTION__); exit(1); } + +void nr_rlc_activate_avg_time_to_tx( + const rnti_t rnti, + const logical_chan_id_t channel_id, + const bool is_on) +{ + nr_rlc_ue_t *ue; + nr_rlc_entity_t *rb; + + nr_rlc_manager_lock(nr_rlc_ue_manager); + ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti); + + switch (channel_id) { + case 1 ... 3: rb = ue->srb[channel_id - 1]; break; + case 4 ... 8: rb = ue->drb[channel_id - 4]; break; + default: rb = NULL; break; + } + + if (rb != NULL) { + rb->avg_time_is_on = is_on; + time_average_reset(rb->txsdu_avg_time_to_tx); + } else { + LOG_E(RLC, "[%s] Radio Bearer (channel ID %d) is NULL for UE with rnti %x\n", __FUNCTION__, channel_id, rnti); + } + + nr_rlc_manager_unlock(nr_rlc_ue_manager); +} + +/* returns false in case of error, true if everything ok */ +const bool nr_rlc_get_statistics( + int rnti, + int srb_flag, + int rb_id, + nr_rlc_statistics_t *out) +{ + nr_rlc_ue_t *ue; + nr_rlc_entity_t *rb; + bool ret; + + nr_rlc_manager_lock(nr_rlc_ue_manager); + ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti); + + rb = NULL; + + if (srb_flag) { + if (rb_id >= 1 && rb_id <= 2) + rb = ue->srb[rb_id - 1]; + } else { + if (rb_id >= 1 && rb_id <= 5) + rb = ue->drb[rb_id - 1]; + } + + if (rb != NULL) { + rb->get_stats(rb, out); + ret = true; + } else { + ret = false; + } + + nr_rlc_manager_unlock(nr_rlc_ue_manager); + + return ret; +} diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h index 92fbba9bec..83396f71e8 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h @@ -51,3 +51,8 @@ void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChann int nr_rlc_get_available_tx_space( const rnti_t rntiP, const logical_chan_id_t channel_idP); + +void nr_rlc_activate_avg_time_to_tx( + const rnti_t rnti, + const logical_chan_id_t channel_id, + const bool is_on); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h index 20cc90f185..333b8742c3 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_sdu.h @@ -22,6 +22,8 @@ #ifndef _NR_RLC_SDU_H_ #define _NR_RLC_SDU_H_ +#include + typedef struct nr_rlc_sdu_t { int sn; int upper_layer_id; @@ -34,6 +36,12 @@ typedef struct nr_rlc_sdu_t { * when it equals ref_count we can free the SDU * completely */ + + /* for statistics, will be set to 0 after SDU (or first part of it) has + * been serialized for MAC for the first time so that only the first + * transmission is used for statistics + */ + uint64_t time_of_arrival; /* unit microsecond */ } nr_rlc_sdu_t; typedef struct nr_rlc_sdu_segment_t { diff --git a/openair2/LAYER2/nr_rlc/tests/Makefile b/openair2/LAYER2/nr_rlc/tests/Makefile index 746d61483b..c23726444d 100644 --- a/openair2/LAYER2/nr_rlc/tests/Makefile +++ b/openair2/LAYER2/nr_rlc/tests/Makefile @@ -1,8 +1,8 @@ CC=gcc -CFLAGS=-Wall -g --coverage -I. +CFLAGS=-Wall -g --coverage -I. -I../../../.. LIB=nr_rlc_entity.o nr_rlc_entity_am.o nr_rlc_entity_um.o nr_rlc_entity_tm.o \ - nr_rlc_pdu.o nr_rlc_sdu.o + nr_rlc_pdu.o nr_rlc_sdu.o time_stat.o tests: @./run_tests.sh diff --git a/openair2/LAYER2/nr_rlc/tests/time_stat.c b/openair2/LAYER2/nr_rlc/tests/time_stat.c new file mode 100644 index 0000000000..dfc8a0d014 --- /dev/null +++ b/openair2/LAYER2/nr_rlc/tests/time_stat.c @@ -0,0 +1,25 @@ +#include "../../../../common/utils/time_stat.h" + +time_average_t *time_average_new(int duration, int initial_size) +{ + return (void *)0; +} + +void time_average_free(time_average_t *t) +{ +} + +void time_average_add(time_average_t *t, uint64_t time, uint64_t value) +{ +} + +double time_average_get_average(time_average_t *t, uint64_t time) +{ + return 0; +} + +uint64_t time_average_now(void) +{ + return 0; +} + diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index 577ee3effd..f0a81d9821 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -4768,13 +4768,11 @@ void decode_MBSFNAreaConfiguration( module_id_t ue_mod_idP, uint8_t eNB_index, f // Configure commonSF_Alloc for(i=0; i< UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->commonSF_Alloc_r9.list.count; i++) { - LOG_W(RRC,"[UE %d] Frame %d, commonSF_Alloc_r9: radioframeAllocationPeriod(%ldn),radioframeAllocationOffset(%ld), subframeAllocation(%x,%x,%x)\n", + LOG_W(RRC,"[UE %d] Frame %d, commonSF_Alloc_r9: radioframeAllocationPeriod(%ldn),radioframeAllocationOffset(%ld), subframeAllocation(%x)\n", ue_mod_idP, frameP, UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->commonSF_Alloc_r9.list.array[i]->radioframeAllocationPeriod<<1, UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->commonSF_Alloc_r9.list.array[i]->radioframeAllocationOffset, - UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->commonSF_Alloc_r9.list.array[i]->subframeAllocation.choice.oneFrame.buf[0], - UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->commonSF_Alloc_r9.list.array[i]->subframeAllocation.choice.oneFrame.buf[1], - UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->commonSF_Alloc_r9.list.array[i]->subframeAllocation.choice.oneFrame.buf[2]); + UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->commonSF_Alloc_r9.list.array[i]->subframeAllocation.choice.oneFrame.buf[0]); UE_mac_inst[ue_mod_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i] = UE_rrc_inst[ue_mod_idP].mcch_message[eNB_index]->commonSF_Alloc_r9.list.array[i]; } diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 4c5d11df5a..47b6e38402 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1092,7 +1092,7 @@ void fill_initial_SpCellConfig(int uid, // We are using do_srs = 0 here because the periodic SRS will only be enabled in update_cellGroupConfig() if do_srs == 1 initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); - config_srs(initialUplinkBWP->srs_Config, curr_bwp, uid, 0, 0); + config_srs(initialUplinkBWP->srs_Config, NULL, curr_bwp, uid, 0, 0); scheduling_request_config(scc, pucch_Config); @@ -1596,6 +1596,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config)); } config_srs(SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config, + uecap, curr_bwp, uid, 0, @@ -1620,6 +1621,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_BWP_Uplink_t *ul_bwp = UL_BWP_list->list.array[i]; int bwp_size = NRRIV2BW(ul_bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); config_srs(ul_bwp->bwp_Dedicated->srs_Config, + uecap, bwp_size, uid, i+1, @@ -1662,12 +1664,7 @@ void fill_initial_cellGroupConfig(int uid, tag->tag_Id = 0; tag->timeAlignmentTimer = NR_TimeAlignmentTimer_infinity; ASN_SEQUENCE_ADD(&mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag); - mac_CellGroupConfig->phr_Config = calloc(1, sizeof(*mac_CellGroupConfig->phr_Config)); - mac_CellGroupConfig->phr_Config->present = NR_SetupRelease_PHR_Config_PR_setup; - mac_CellGroupConfig->phr_Config->choice.setup = calloc(1, sizeof(*mac_CellGroupConfig->phr_Config->choice.setup)); - mac_CellGroupConfig->phr_Config->choice.setup->phr_PeriodicTimer = NR_PHR_Config__phr_PeriodicTimer_sf10; - mac_CellGroupConfig->phr_Config->choice.setup->phr_ProhibitTimer = NR_PHR_Config__phr_ProhibitTimer_sf10; - mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = NR_PHR_Config__phr_Tx_PowerFactorChange_dB1; + set_phr_config(mac_CellGroupConfig); mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig)); mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 7e123f6872..deb2c4965e 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -352,6 +352,7 @@ long rrc_get_max_nr_csrs(const uint8_t max_rbs, const long b_SRS) { } void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, + const NR_UE_NR_Capability_t *uecap, const int curr_bwp, const int uid, const int res_id, @@ -418,6 +419,26 @@ void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0)); srs_res0->srs_ResourceId = res_id; srs_res0->nrofSRS_Ports = NR_SRS_Resource__nrofSRS_Ports_port1; + // if (uecap && + // uecap->featureSets && + // uecap->featureSets->featureSetsUplink && + // uecap->featureSets->featureSetsUplink->list.count > 0) { + // NR_FeatureSetUplink_t *ul_feature_setup = uecap->featureSets->featureSetsUplink->list.array[0]; + // switch (ul_feature_setup->supportedSRS_Resources->maxNumberSRS_Ports_PerResource) { + // case NR_SRS_Resources__maxNumberSRS_Ports_PerResource_n1: + // srs_res0->nrofSRS_Ports = NR_SRS_Resource__nrofSRS_Ports_port1; + // break; + // case NR_SRS_Resources__maxNumberSRS_Ports_PerResource_n2: + // srs_res0->nrofSRS_Ports = NR_SRS_Resource__nrofSRS_Ports_ports2; + // break; + // case NR_SRS_Resources__maxNumberSRS_Ports_PerResource_n4: + // srs_res0->nrofSRS_Ports = NR_SRS_Resource__nrofSRS_Ports_ports4; + // break; + // default: + // LOG_E(NR_RRC, "Max Number of SRS Ports Per Resource %ld is invalid!\n", + // ul_feature_setup->supportedSRS_Resources->maxNumberSRS_Ports_PerResource); + // } + // } srs_res0->ptrs_PortIndex = NULL; srs_res0->transmissionComb.present = NR_SRS_Resource__transmissionComb_PR_n2; srs_res0->transmissionComb.choice.n2 = calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2)); @@ -1116,6 +1137,7 @@ void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config)); config_srs(ubwp->bwp_Dedicated->srs_Config, + NULL, curr_bwp, uid, bwp_loop+1, @@ -1125,4 +1147,13 @@ void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL; } +void set_phr_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig) +{ + mac_CellGroupConfig->phr_Config = calloc(1, sizeof(*mac_CellGroupConfig->phr_Config)); + mac_CellGroupConfig->phr_Config->present = NR_SetupRelease_PHR_Config_PR_setup; + mac_CellGroupConfig->phr_Config->choice.setup = calloc(1, sizeof(*mac_CellGroupConfig->phr_Config->choice.setup)); + mac_CellGroupConfig->phr_Config->choice.setup->phr_PeriodicTimer = NR_PHR_Config__phr_PeriodicTimer_sf10; + mac_CellGroupConfig->phr_Config->choice.setup->phr_ProhibitTimer = NR_PHR_Config__phr_ProhibitTimer_sf10; + mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = NR_PHR_Config__phr_Tx_PowerFactorChange_dB1; +} diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 58caa50b80..f8bdc4be53 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -119,6 +119,7 @@ typedef struct physicalcellgroup_s{ long RNTI_Value[MAX_NUM_CCs]; }physicalcellgroup_t; +void set_phr_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig); uint64_t get_ssb_bitmap(const NR_ServingCellConfigCommon_t *scc); void rrc_coreset_config(NR_ControlResourceSet_t *coreset, int bwp_id, @@ -145,6 +146,7 @@ void config_csirs(const NR_ServingCellConfigCommon_t *servingcellconfigcommon, void config_csiim(int do_csirs, int dl_antenna_ports, int curr_bwp, NR_CSI_MeasConfig_t *csi_MeasConfig, int id); void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, + const NR_UE_NR_Capability_t *uecap, const int curr_bwp, const int uid, const int res_id, diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 85aa5e24a9..1dca25b618 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -133,16 +133,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco tag->tag_Id = 0; tag->timeAlignmentTimer = NR_TimeAlignmentTimer_infinity; ASN_SEQUENCE_ADD(&mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag); - mac_CellGroupConfig->phr_Config = calloc(1,sizeof(*mac_CellGroupConfig->phr_Config)); - mac_CellGroupConfig->phr_Config->present = NR_SetupRelease_PHR_Config_PR_setup; - mac_CellGroupConfig->phr_Config->choice.setup = calloc(1,sizeof(*mac_CellGroupConfig->phr_Config->choice.setup)); - mac_CellGroupConfig->phr_Config->choice.setup->phr_PeriodicTimer = NR_PHR_Config__phr_PeriodicTimer_sf20; - mac_CellGroupConfig->phr_Config->choice.setup->phr_ProhibitTimer = NR_PHR_Config__phr_ProhibitTimer_sf0; - mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = NR_PHR_Config__phr_Tx_PowerFactorChange_dB3; - mac_CellGroupConfig->phr_Config->choice.setup->multiplePHR=false; - mac_CellGroupConfig->phr_Config->choice.setup->dummy=false; - mac_CellGroupConfig->phr_Config->choice.setup->phr_Type2OtherCell = false; - mac_CellGroupConfig->phr_Config->choice.setup->phr_ModeOtherCG = NR_PHR_Config__phr_ModeOtherCG_real; + set_phr_config(mac_CellGroupConfig); mac_CellGroupConfig->skipUplinkTxDynamic=false; mac_CellGroupConfig->ext1 = NULL; secondaryCellGroup->physicalCellGroupConfig = calloc(1,sizeof(*secondaryCellGroup->physicalCellGroupConfig)); @@ -489,7 +480,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco int curr_bwp = NRRIV2BW(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config)); - config_srs(initialUplinkBWP->srs_Config, curr_bwp, uid, 0, configuration->do_SRS); + config_srs(initialUplinkBWP->srs_Config, NULL, curr_bwp, uid, 0, configuration->do_SRS); // Downlink BWPs int n_dl_bwp = 1; diff --git a/openair2/UTIL/OPT/ws_compiler_tests.h b/openair2/UTIL/OPT/ws_compiler_tests.h deleted file mode 100644 index 46a4ab6099..0000000000 --- a/openair2/UTIL/OPT/ws_compiler_tests.h +++ /dev/null @@ -1,138 +0,0 @@ -/* ws_compiler_tests.h - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef __WS_COMPILER_TESTS_H__ -#define __WS_COMPILER_TESTS_H__ - -/* - * This was introduced by Clang: - * - * http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute - * - * in some version (which version?); it has been picked up by GCC 5.0. - */ -#ifndef __has_attribute - /* - * It's a macro, so you can check whether it's defined to check - * whether it's supported. - * - * If it's not, define it to always return 0, so that we move on to - * the fallback checks. - */ - #define __has_attribute(x) 0 -#endif - -/* - * Note that the C90 spec's "6.8.1 Conditional inclusion" and the - * C99 spec's and C11 spec's "6.10.1 Conditional inclusion" say: - * - * Prior to evaluation, macro invocations in the list of preprocessing - * tokens that will become the controlling constant expression are - * replaced (except for those macro names modified by the defined unary - * operator), just as in normal text. If the token "defined" is - * generated as a result of this replacement process or use of the - * "defined" unary operator does not match one of the two specified - * forms prior to macro replacement, the behavior is undefined. - * - * so you shouldn't use defined() in a #define that's used in #if or - * #elif. Some versions of Clang, for example, will warn about this. - * - * Instead, we check whether the pre-defined macros for particular - * compilers are defined and, if not, define the "is this version XXX - * or a later version of this compiler" macros as 0. - */ - -/* - * Check whether this is GCC major.minor or a later release, or some - * compiler that claims to be "just like GCC" of that version or a - * later release. - */ - -#if !defined(__GNUC__) - #define WS_IS_AT_LEAST_GNUC_VERSION(major, minor) 0 -#else - #define WS_IS_AT_LEAST_GNUC_VERSION(major, minor) \ - (__GNUC__ > (major) || \ - (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) -#endif - -/* - * Check whether this is Clang major.minor or a later release. - */ - -#if !defined(__clang__) - #define WS_IS_AT_LEAST_CLANG_VERSION(major, minor) 0 -#else - #define WS_IS_AT_LEAST_CLANG_VERSION(major, minor) \ - (__clang_major__ > (major) || \ - (__clang_major__ == (major) && __clang_minor__ >= (minor))) -#endif - -/* - * Check whether this is Sun C/SunPro C/Oracle Studio major.minor - * or a later release. - * - * The version number in __SUNPRO_C is encoded in hex BCD, with the - * uppermost hex digit being the major version number, the next - * one or two hex digits being the minor version number, and - * the last digit being the patch version. - * - * It represents the *compiler* version, not the product version; - * see - * - * https://sourceforge.net/p/predef/wiki/Compilers/ - * - * for a partial mapping, which we assume continues for later - * 12.x product releases. - */ - -#if !defined(__SUNPRO_C) - #define WS_IS_AT_LEAST_SUNC_VERSION(major, minor) 0 -#else - #define WS_SUNPRO_VERSION_TO_BCD(major, minor) \ - (((minor) >= 10) ? \ - (((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \ - (((major) << 8) | ((minor) << 4))) - #define WS_IS_AT_LEAST_SUNC_VERSION(major, minor) \ - (__SUNPRO_C >= WS_SUNPRO_VERSION_TO_BCD((major), (minor))) -#endif - -/* - * Check whether this is IBM XL C major.minor or a later release. - * - * The version number in __xlC__ has the major version in the - * upper 8 bits and the minor version in the lower 8 bits. - */ - -#if !defined(__xlC__) - #define WS_IS_AT_LEAST_XL_C_VERSION(major, minor) 0 -#else - #define WS_IS_AT_LEAST_XL_C_VERSION(major, minor) \ - (__xlC__ >= (((major) << 8) | (minor))) -#endif - -/* - * Check whether this is HP aC++/HP C major.minor or a later release. - * - * The version number in __HP_aCC is encoded in zero-padded decimal BCD, - * with the "A." stripped off, the uppermost two decimal digits being - * the major version number, the next two decimal digits being the minor - * version number, and the last two decimal digits being the patch version. - * (Strip off the A., remove the . between the major and minor version - * number, and add two digits of patch.) - */ - -#if !defined(__HP_aCC) - #define WS_IS_AT_LEAST_HP_C_VERSION(major, minor) 0 -#else - #define WS_IS_AT_LEAST_HP_C_VERSION(major, minor) \ - (__HP_aCC >= ((major)*10000 + (minor)*100)) -#endif - -#endif /* __WS_COMPILER_TESTS_H__ */ diff --git a/openair2/UTIL/OPT/ws_symbol_export.h b/openair2/UTIL/OPT/ws_symbol_export.h deleted file mode 100644 index 4c7a2f710a..0000000000 --- a/openair2/UTIL/OPT/ws_symbol_export.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Cross platform defines for exporting symbols from shared libraries - * - * Wireshark - Network traffic analyzer - * By Balint Reczey - * Copyright 2013 Balint Reczey - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "ws_compiler_tests.h" - -/** Reset symbol export behavior. - * If you {un}define WS_BUILD_DLL on the fly you'll have to define this - * as well. - */ -#ifdef RESET_SYMBOL_EXPORT - -#ifdef SYMBOL_EXPORT_H -#undef SYMBOL_EXPORT_H -#endif - -#ifdef WS_DLL_PUBLIC -#undef WS_DLL_PUBLIC -#endif - -#ifdef WS_DLL_PUBLIC_DEF -#undef WS_DLL_PUBLIC_DEF -#endif - -#ifdef WS_DLL_LOCAL -#undef WS_DLL_LOCAL -#endif - -#endif /* RESET_SYMBOL_EXPORT */ - -#ifndef SYMBOL_EXPORT_H -#define SYMBOL_EXPORT_H - -/* - * NOTE: G_HAVE_GNUC_VISIBILITY is defined only if all of - * - * __attribute__ ((visibility ("hidden"))) - * - * __attribute__ ((visibility ("internal"))) - * - * __attribute__ ((visibility ("protected"))) - * - * __attribute__ ((visibility ("default"))) - * - * are supported, and at least some versions of GCC from Apple support - * "default" and "hidden" but not "internal" or "protected", so it - * shouldn't be used to determine whether "hidden" or "default" is - * supported. - * - * This also means that we shouldn't use G_GNUC_INTERNAL instead of - * WS_DLL_LOCAL, as GLib uses G_HAVE_GNUC_VISIBILITY to determine - * whether to use __attribute__ ((visibility ("hidden"))) for - * G_GNUC_INTERNAL, and that will not use it even with compilers - * that support it. - */ - -/* Originally copied from GCC Wiki at http://gcc.gnu.org/wiki/Visibility */ -#if defined _WIN32 || defined __CYGWIN__ - /* Compiling for Windows, so we use the Windows DLL declarations. */ - #ifdef WS_BUILD_DLL - /* - * Building a DLL; for all definitions, we want dllexport, and - * (presumably so source from DLL and source from a program using the - * DLL can both include a header that declares APIs and exported data - * for the DLL), for declarations, either dllexport or dllimport will - * work (they mean the same thing for a declaration when building a DLL). - */ - #ifdef __GNUC__ - /* GCC */ - #define WS_DLL_PUBLIC_DEF __attribute__ ((dllexport)) - #else /* ! __GNUC__ */ - /* - * Presumably MSVC. - * Note: actually gcc seems to also support this syntax. - */ - #define WS_DLL_PUBLIC_DEF __declspec(dllexport) - #endif /* __GNUC__ */ - #else /* WS_BUILD_DLL */ - /* - * Building a program; we should only see declarations, not definitions, - * with WS_DLL_PUBLIC, and they all represent APIs or data imported - * from a DLL, so use dllimport. - * - * For functions, export shouldn't be necessary; for data, it might - * be necessary, e.g. if what's declared is an array whose size is - * not given in the declaration. - */ - #ifdef __GNUC__ - /* GCC */ - #define WS_DLL_PUBLIC_DEF __attribute__ ((dllimport)) - #elif ! (defined ENABLE_STATIC) /* ! __GNUC__ */ - /* - * Presumably MSVC, and we're not building all-static. - * Note: actually gcc seems to also support this syntax. - */ - #define WS_DLL_PUBLIC_DEF __declspec(dllimport) - #else /* ! __GNUC__ && ENABLE_STATIC */ - /* - * Presumably MSVC, and we're building all-static, so we're - * not building any DLLs. - */ - #define WS_DLL_PUBLIC_DEF - #endif /* __GNUC__ */ - #endif /* WS_BUILD_DLL */ - - /* - * Symbols in a DLL are *not* exported unless they're specifically - * flagged as exported, so, for a non-static but non-exported - * symbol, we don't have to do anything. - */ - #define WS_DLL_LOCAL -#else /* defined _WIN32 || defined __CYGWIN__ */ - /* - * Compiling for UN*X, where the dllimport and dllexport stuff - * is neither necessary nor supported; just specify the - * visibility if we have a compiler that supports doing so. - */ - #if WS_IS_AT_LEAST_GNUC_VERSION(3,4) \ - || WS_IS_AT_LEAST_XL_C_VERSION(12,0) - /* - * GCC 3.4 or later, or some compiler asserting compatibility with - * GCC 3.4 or later, or XL C 13.0 or later, so we have - * __attribute__((visibility()). - */ - - /* - * Symbols exported from libraries. - */ - #define WS_DLL_PUBLIC_DEF __attribute__ ((visibility ("default"))) - - /* - * Non-static symbols *not* exported from libraries. - */ - #define WS_DLL_LOCAL __attribute__ ((visibility ("hidden"))) - #elif WS_IS_AT_LEAST_SUNC_VERSION(5,5) - /* - * Sun C 5.5 or later, so we have __global and __hidden. - * (Sun C 5.9 and later also have __attribute__((visibility()), - * but there's no reason to prefer it with Sun C.) - */ - - /* - * Symbols exported from libraries. - */ - #define WS_DLL_PUBLIC_DEF __global - - /* - * Non-static symbols *not* exported from libraries. - */ - #define WS_DLL_LOCAL __hidden - #else - /* - * We have neither a way to make stuff not explicitly marked as - * visible invisible outside a library nor a way to make stuff - * explicitly marked as local invisible outside the library. - */ - - /* - * Symbols exported from libraries. - */ - #define WS_DLL_PUBLIC_DEF - - /* - * Non-static symbols *not* exported from libraries. - */ - #define WS_DLL_LOCAL - #endif -#endif - -/* - * You *must* use this for exported data *declarations*; if you use - * WS_DLL_PUBLIC_DEF, some compilers, such as MSVC++, will complain - * about array definitions with no size. - * - * You must *not* use this for exported data *definitions*, as that - * will, for some compilers, cause warnings about items being initialized - * and declared extern. - * - * Either can be used for exported *function* declarations and definitions. - */ -#define WS_DLL_PUBLIC WS_DLL_PUBLIC_DEF extern - -#endif /* SYMBOL_EXPORT_H */ - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local Variables: - * c-basic-offset: 2 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=2 tabstop=8 expandtab: - * :indentSize=2:tabSize=8:noTabs=true: - */ diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 43c3b56aa4..2b2d9b08a5 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -733,16 +733,20 @@ static void generatePduSessionEstablishRequest(int Mod_id, uicc_t * uicc, as_nas mm_msg->uplink_nas_transport.pdusessionid = 10; mm_msg->uplink_nas_transport.requesttype = 1; size += 3; - mm_msg->uplink_nas_transport.snssai.length = 4; + const bool has_nssai_sd = uicc->nssai_sd != 0xffffff; // 0xffffff means "no SD", TS 23.003 + const size_t nssai_len = has_nssai_sd ? 4 : 1; + mm_msg->uplink_nas_transport.snssai.length = nssai_len; //Fixme: it seems there are a lot of memory errors in this: this value was on the stack, // but pushed in a itti message to another thread // this kind of error seems in many places in 5G NAS - mm_msg->uplink_nas_transport.snssai.value=calloc(1,4); + mm_msg->uplink_nas_transport.snssai.value = calloc(1, nssai_len); mm_msg->uplink_nas_transport.snssai.value[0] = uicc->nssai_sst; - mm_msg->uplink_nas_transport.snssai.value[1] = (uicc->nssai_sd>>16)&0xFF; - mm_msg->uplink_nas_transport.snssai.value[2] = (uicc->nssai_sd>>8)&0xFF; - mm_msg->uplink_nas_transport.snssai.value[3] = (uicc->nssai_sd)&0xFF; - size += (1+1+4); + if (has_nssai_sd) { + mm_msg->uplink_nas_transport.snssai.value[1] = (uicc->nssai_sd >> 16) & 0xFF; + mm_msg->uplink_nas_transport.snssai.value[2] = (uicc->nssai_sd >> 8) & 0xFF; + mm_msg->uplink_nas_transport.snssai.value[3] = (uicc->nssai_sd) & 0xFF; + } + size += 1 + 1 + nssai_len; int dnnSize=strlen(uicc->dnnStr); mm_msg->uplink_nas_transport.dnn.value=calloc(1,dnnSize+1); mm_msg->uplink_nas_transport.dnn.length = dnnSize + 1; diff --git a/openair3/NAS/UE/nas_ue_task.c b/openair3/NAS/UE/nas_ue_task.c index 34bf6cb3ad..f47af8cb66 100644 --- a/openair3/NAS/UE/nas_ue_task.c +++ b/openair3/NAS/UE/nas_ue_task.c @@ -86,7 +86,6 @@ void nas_user_api_id_initialize(nas_user_t *user) { void *nas_ue_task(void *args_p) { int nb_events; - struct epoll_event *events; MessageDef *msg_p; instance_t instance; unsigned int Mod_id; @@ -306,8 +305,8 @@ void *nas_ue_task(void *args_p) AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); msg_p = NULL; } - - nb_events = itti_get_events(TASK_NAS_UE, &events); + struct epoll_event events[20]; + nb_events = itti_get_events(TASK_NAS_UE, events, 20); if ((nb_events > 0) && (events != NULL)) { if (nas_ue_process_events(users, events, nb_events) == true) { diff --git a/openair3/SCTP/sctp_eNB_task.c b/openair3/SCTP/sctp_eNB_task.c index df6dde0f99..49a0674bdf 100644 --- a/openair3/SCTP/sctp_eNB_task.c +++ b/openair3/SCTP/sctp_eNB_task.c @@ -216,7 +216,7 @@ sctp_eNB_accept_associations_multi( } //------------------------------------------------------------------------------ -void +static void sctp_handle_new_association_req_multi( const instance_t instance, const task_id_t requestor, @@ -355,7 +355,7 @@ sctp_handle_new_association_req_multi( } //------------------------------------------------------------------------------ -void +static void sctp_handle_new_association_req( const instance_t instance, const task_id_t requestor, @@ -617,7 +617,7 @@ sctp_handle_new_association_req( } //------------------------------------------------------------------------------ -void sctp_send_data( +static void sctp_send_data( instance_t instance, task_id_t task_id, sctp_data_req_t *sctp_data_req_p) @@ -1058,16 +1058,12 @@ sctp_eNB_read_from_socket( //------------------------------------------------------------------------------ void -sctp_eNB_flush_sockets( +static sctp_eNB_flush_sockets( struct epoll_event *events, int nb_events) { int i; struct sctp_cnx_list_elm_s *sctp_cnx = NULL; - if (events == NULL) { - return; - } - for (i = 0; i < nb_events; i++) { sctp_cnx = sctp_get_cnx(-1, events[i].data.fd); @@ -1090,7 +1086,7 @@ sctp_eNB_flush_sockets( } //------------------------------------------------------------------------------ -void sctp_eNB_init(void) +static void sctp_eNB_init(void) { SCTP_DEBUG("Starting SCTP layer\n"); @@ -1100,10 +1096,9 @@ void sctp_eNB_init(void) } //------------------------------------------------------------------------------ -void *sctp_eNB_process_itti_msg(void *notUsed) +static void sctp_eNB_process_itti_msg() { int nb_events; - struct epoll_event *events; MessageDef *received_msg = NULL; int result; @@ -1184,12 +1179,12 @@ void *sctp_eNB_process_itti_msg(void *notUsed) AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); received_msg = NULL; } - - nb_events = itti_get_events(TASK_SCTP, &events); + struct epoll_event events[20]; + nb_events = itti_get_events(TASK_SCTP, events, 20); /* Now handle notifications for other sockets */ sctp_eNB_flush_sockets(events, nb_events); - return NULL; + return; } //------------------------------------------------------------------------------ @@ -1198,7 +1193,7 @@ void *sctp_eNB_task(void *arg) sctp_eNB_init(); while (1) { - (void) sctp_eNB_process_itti_msg(NULL); + sctp_eNB_process_itti_msg(); } return NULL; diff --git a/openair3/SCTP/sctp_eNB_task.h b/openair3/SCTP/sctp_eNB_task.h index e23e80675e..31cb683102 100644 --- a/openair3/SCTP/sctp_eNB_task.h +++ b/openair3/SCTP/sctp_eNB_task.h @@ -22,8 +22,6 @@ #ifndef SCTP_ENB_TASK_H_ #define SCTP_ENB_TASK_H_ -void sctp_eNB_init(void); -void *sctp_eNB_process_itti_msg(void *); void *sctp_eNB_task(void *arg); #endif /* SCTP_ENB_TASK_H_ */ diff --git a/openair3/UICC/usim_interface.c b/openair3/UICC/usim_interface.c index 9d6e7c6ccb..78a3f1ee0a 100644 --- a/openair3/UICC/usim_interface.c +++ b/openair3/UICC/usim_interface.c @@ -44,7 +44,7 @@ extern uint16_t NB_UE_INST; {"sqn", "USIM sqn\n", 0, strptr:&uicc->sqnStr, defstrval:"000000", TYPE_STRING, 0 }, \ {"dnn", "UE dnn (apn)\n", 0, strptr:&uicc->dnnStr, defstrval:"oai", TYPE_STRING, 0 }, \ {"nssai_sst", "UE nssai\n", 0, iptr:&uicc->nssai_sst, defintval:1, TYPE_INT, 0 }, \ - {"nssai_sd", "UE nssai\n", 0, iptr:&uicc->nssai_sd, defintval:1, TYPE_INT, 0 }, \ + {"nssai_sd", "UE nssai\n", 0, iptr:&uicc->nssai_sd, defintval:0xffffff, TYPE_INT, 0 }, \ }; static uicc_t** uiccArray=NULL; @@ -73,7 +73,10 @@ uicc_t *init_uicc(char *sectionName) { // key, OPc, sqn, amf don't need to be read from the true USIM int ret = config_get( uicc_params,sizeof(uicc_params)/sizeof(paramdef_t),sectionName); AssertFatal(ret >= 0, "configuration couldn't be performed for uicc name: %s", sectionName); - LOG_I(SIM, "UICC simulation: IMSI=%s, Ki=%s, OPc=%s\n", uicc->imsiStr, uicc->keyStr, uicc->opcStr); + LOG_I(SIM, + "UICC simulation: IMSI=%s, Ki=%s, OPc=%s, DNN=%s, SST=0x%02x, SD=0x%06x\n", + uicc->imsiStr, uicc->keyStr, uicc->opcStr, + uicc->dnnStr, uicc->nssai_sst, uicc->nssai_sd); to_hex(uicc->keyStr,uicc->key, sizeof(uicc->key) ); to_hex(uicc->opcStr,uicc->opc, sizeof(uicc->opc) ); to_hex(uicc->sqnStr,uicc->sqn, sizeof(uicc->sqn) ); diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index afef8ea435..af2a0ee9e8 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -145,7 +145,7 @@ class gtpEndPoints { ~gtpEndPoints() { // automatically close all sockets on quit - for (const auto p : instances) + for (const auto &p : instances) close(p.first); } }; @@ -163,11 +163,46 @@ static teid_t gtpv1uNewTeid(void) { } instance_t legacyInstanceMapping=0; -#define compatInst(a) ((a)==0 || (a)==INSTANCE_DEFAULT?legacyInstanceMapping:a) +#define compatInst(a) ((a)==0 || (a)==INSTANCE_DEFAULT ? legacyInstanceMapping:a) -#define GTPV1U_HEADER_SIZE (8) +#define getInstRetVoid(insT) \ + auto instChk=globGtp.instances.find(compatInst(insT)); \ + if (instChk == globGtp.instances.end()) { \ + LOG_E(GTPU,"try to get a gtp-u not existing output\n"); \ + pthread_mutex_unlock(&globGtp.gtp_lock); \ + return; \ + } \ + gtpEndPoint * inst=&instChk->second; - #define HDR_MAX 256 // 256 is supposed to be larger than any gtp header +#define getInstRetInt(insT) \ + auto instChk=globGtp.instances.find(compatInst(insT)); \ + if (instChk == globGtp.instances.end()) { \ + LOG_E(GTPU,"try to get a gtp-u not existing output\n"); \ + pthread_mutex_unlock(&globGtp.gtp_lock); \ + return GTPNOK; \ + } \ + gtpEndPoint * inst=&instChk->second; + + +#define getRntiRetVoid(insT, RnTi) \ + auto ptrRnti=insT->ue2te_mapping.find(RnTi); \ + \ + if ( ptrRnti==insT->ue2te_mapping.end() ) { \ + LOG_E(GTPU, "[%ld] gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", instance, rnti); \ + pthread_mutex_unlock(&globGtp.gtp_lock); \ + return; \ + } + +#define getRntiRetInt(insT, RnTi) \ + auto ptrRnti=insT->ue2te_mapping.find(RnTi); \ + \ + if ( ptrRnti==insT->ue2te_mapping.end() ) { \ + LOG_E(GTPU, "[%ld] gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", instance, rnti); \ + pthread_mutex_unlock(&globGtp.gtp_lock); \ + return GTPNOK; \ + } + +#define HDR_MAX 256 // 256 is supposed to be larger than any gtp header static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, @@ -196,13 +231,11 @@ static int gtpv1uCreateAndSendMsg(int h, msgHdr->PT=1; msgHdr->version=1; msgHdr->msgType=msgType; - msgHdr->msgLength = htons(msgLen + extensionHeader_length); msgHdr->teid=htonl(teid); curPtr+=sizeof(Gtpv1uMsgHeaderT); if (seqNumFlag || (extHdrType != NO_MORE_EXT_HDRS) || npduNumFlag) { - msgHdr->msgLength += htons(4); *(uint16_t *)curPtr = seqNumFlag ? seqNum : 0x0000; curPtr+=sizeof(uint16_t); *(uint8_t *)curPtr = npduNumFlag ? npduNum : 0x00; @@ -229,9 +262,10 @@ static int gtpv1uCreateAndSendMsg(int h, curPtr+=msgLen; } - AssertFatal(curPtr-(buffer+msgLen) < HDR_MAX, ""); + msgHdr->msgLength = htons(curPtr-(buffer+sizeof(Gtpv1uMsgHeaderT))); + AssertFatal(curPtr-(buffer+msgLen) < HDR_MAX, "fixed max size of all headers too short"); // Fix me: add IPv6 support, using flag ipVersion - static struct sockaddr_in to= {0}; + struct sockaddr_in to= {0}; to.sin_family = AF_INET; to.sin_port = htons(peerPort); to.sin_addr.s_addr = peerIp ; @@ -253,14 +287,8 @@ static void gtpv1uSend(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req, b rnti_t rnti=req->rnti; int rab_id=req->rab_id; pthread_mutex_lock(&globGtp.gtp_lock); - auto inst=&globGtp.instances[compatInst(instance)]; - auto ptrRnti=inst->ue2te_mapping.find(rnti); - - if ( ptrRnti==inst->ue2te_mapping.end() ) { - LOG_E(GTPU, "[%ld] gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", instance, rnti); - pthread_mutex_unlock(&globGtp.gtp_lock); - return; - } + getInstRetVoid(compatInst(instance)); + getRntiRetVoid(inst, rnti); map::iterator ptr2=ptrRnti->second.bearers.find(rab_id); @@ -292,14 +320,8 @@ static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req, rnti_t rnti=req->rnti; int rab_id=req->pdusession_id; pthread_mutex_lock(&globGtp.gtp_lock); - auto inst=&globGtp.instances[compatInst(instance)]; - auto ptrRnti=inst->ue2te_mapping.find(rnti); - - if ( ptrRnti==inst->ue2te_mapping.end() ) { - LOG_E(GTPU, "[%ld] GTP-U gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", instance, rnti); - pthread_mutex_unlock(&globGtp.gtp_lock); - return; - } + getInstRetVoid(compatInst(instance)); + getRntiRetVoid(inst, rnti); map::iterator ptr2=ptrRnti->second.bearers.find(rab_id); @@ -385,14 +407,8 @@ static void gtpv1uSendDlDeliveryStatus(instance_t instance, gtpv1u_DU_buffer_rep rnti_t rnti=req->rnti; int rab_id=req->pdusession_id; pthread_mutex_lock(&globGtp.gtp_lock); - auto inst=&globGtp.instances[compatInst(instance)]; - auto ptrRnti=inst->ue2te_mapping.find(rnti); - - if ( ptrRnti==inst->ue2te_mapping.end() ) { - LOG_E(GTPU, "[%ld] GTP-U gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", instance, rnti); - pthread_mutex_unlock(&globGtp.gtp_lock); - return; - } + getInstRetVoid(compatInst(instance)); + getRntiRetVoid(inst, rnti); map::iterator ptr2=ptrRnti->second.bearers.find(rab_id); @@ -419,14 +435,8 @@ static void gtpv1uEndTunnel(instance_t instance, gtpv1u_enb_tunnel_data_req_t *r rnti_t rnti=req->rnti; int rab_id=req->rab_id; pthread_mutex_lock(&globGtp.gtp_lock); - auto inst=&globGtp.instances[compatInst(instance)]; - auto ptrRnti=inst->ue2te_mapping.find(rnti); - - if ( ptrRnti==inst->ue2te_mapping.end() ) { - LOG_E(GTPU, "[%ld] gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", instance, rnti); - pthread_mutex_unlock(&globGtp.gtp_lock); - return; - } + getInstRetVoid(compatInst(instance)); + getRntiRetVoid(inst, rnti); map::iterator ptr2=ptrRnti->second.bearers.find(rab_id); @@ -571,14 +581,8 @@ instance_t gtpv1Init(openAddr_t context) { void GtpuUpdateTunnelOutgoingTeid(instance_t instance, rnti_t rnti, ebi_t bearer_id, teid_t newOutgoingTeid) { pthread_mutex_lock(&globGtp.gtp_lock); - auto inst=&globGtp.instances[compatInst(instance)]; - auto ptrRnti=inst->ue2te_mapping.find(rnti); - - if ( ptrRnti == inst->ue2te_mapping.end() ) { - LOG_E(GTPU,"[%ld] Update tunnel for a not existing rnti %x\n", instance, rnti); - pthread_mutex_unlock(&globGtp.gtp_lock); - return; - } + getInstRetVoid(compatInst(instance)); + getRntiRetVoid(inst, rnti); map::iterator ptr2=ptrRnti->second.bearers.find(bearer_id); @@ -605,8 +609,7 @@ teid_t newGtpuCreateTunnel(instance_t instance, gtpCallback callBack, gtpCallbackSDAP callBackSDAP) { pthread_mutex_lock(&globGtp.gtp_lock); - instance=compatInst(instance); - auto inst=&globGtp.instances[instance]; + getInstRetInt(compatInst(instance)); auto it=inst->ue2te_mapping.find(rnti); if ( it != inst->ue2te_mapping.end() && it->second.bearers.find(outgoing_bearer_id) != it->second.bearers.end()) { @@ -682,8 +685,14 @@ int gtpv1u_create_s1u_tunnel(instance_t instance, create_tunnel_req->rnti, create_tunnel_req->num_tunnels, create_tunnel_req->sgw_S1u_teid[0]); - tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport(); - + pthread_mutex_lock(&globGtp.gtp_lock); + getInstRetInt(compatInst(instance)); + + tcp_udp_port_t dstport=inst->get_dstport(); + uint8_t addr[inst->foundAddrLen]; + memcpy(addr, inst->foundAddr, inst->foundAddrLen); + pthread_mutex_unlock(&globGtp.gtp_lock); + for (int i = 0; i < create_tunnel_req->num_tunnels; i++) { AssertFatal(create_tunnel_req->eps_bearer_id[i] > 4, "From legacy code not clear, seems impossible (bearer=%d)\n", @@ -704,9 +713,8 @@ int gtpv1u_create_s1u_tunnel(instance_t instance, create_tunnel_resp->num_tunnels=create_tunnel_req->num_tunnels; create_tunnel_resp->enb_S1u_teid[i]=teid; create_tunnel_resp->eps_bearer_id[i] = create_tunnel_req->eps_bearer_id[i]; - memcpy(create_tunnel_resp->enb_addr.buffer,globGtp.instances[compatInst(instance)].foundAddr, - globGtp.instances[compatInst(instance)].foundAddrLen); - create_tunnel_resp->enb_addr.length= globGtp.instances[compatInst(instance)].foundAddrLen; + memcpy(create_tunnel_resp->enb_addr.buffer,addr,sizeof(addr)); + create_tunnel_resp->enb_addr.length= sizeof(addr); } return !GTPNOK; @@ -725,10 +733,11 @@ int gtpv1u_update_s1u_tunnel( create_tunnel_req->sgw_S1u_teid[0], create_tunnel_req->eps_bearer_id[0]); pthread_mutex_lock(&globGtp.gtp_lock); - auto inst=&globGtp.instances[compatInst(instance)]; + getInstRetInt(compatInst(instance)); if ( inst->ue2te_mapping.find(create_tunnel_req->rnti) == inst->ue2te_mapping.end() ) { - LOG_E(GTPU,"[%ld] Update not already existing tunnel (new rnti %x, old rnti %x)\n", instance, create_tunnel_req->rnti, prior_rnti); + LOG_E(GTPU,"[%ld] Update not already existing tunnel (new rnti %x, old rnti %x)\n", + instance, create_tunnel_req->rnti, prior_rnti); } auto it=inst->ue2te_mapping.find(prior_rnti); @@ -755,7 +764,13 @@ int gtpv1u_create_ngu_tunnel( const instance_t instance, create_tunnel_req->rnti, create_tunnel_req->num_tunnels, create_tunnel_req->outgoing_teid[0]); - tcp_udp_port_t dstport = globGtp.instances[compatInst(instance)].get_dstport(); + pthread_mutex_lock(&globGtp.gtp_lock); + getInstRetInt(compatInst(instance)); + + tcp_udp_port_t dstport = inst->get_dstport(); + uint8_t addr[inst->foundAddrLen]; + memcpy(addr, inst->foundAddr, inst->foundAddrLen); + pthread_mutex_unlock(&globGtp.gtp_lock); for (int i = 0; i < create_tunnel_req->num_tunnels; i++) { teid_t teid = newGtpuCreateTunnel(instance, create_tunnel_req->rnti, @@ -771,9 +786,8 @@ int gtpv1u_create_ngu_tunnel( const instance_t instance, create_tunnel_resp->rnti=create_tunnel_req->rnti; create_tunnel_resp->num_tunnels=create_tunnel_req->num_tunnels; create_tunnel_resp->gnb_NGu_teid[i]=teid; - memcpy(create_tunnel_resp->gnb_addr.buffer,globGtp.instances[compatInst(instance)].foundAddr, - globGtp.instances[compatInst(instance)].foundAddrLen); - create_tunnel_resp->gnb_addr.length= globGtp.instances[compatInst(instance)].foundAddrLen; + memcpy(create_tunnel_resp->gnb_addr.buffer,addr,sizeof(addr)); + create_tunnel_resp->gnb_addr.length= sizeof(addr); } return !GTPNOK; @@ -799,25 +813,19 @@ int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti) { LOG_D(GTPU, "[%ld] Start delete tunnels for RNTI %x\n", instance, rnti); pthread_mutex_lock(&globGtp.gtp_lock); - auto inst=&globGtp.instances[compatInst(instance)]; - auto it=inst->ue2te_mapping.find(rnti); - - if ( it == inst->ue2te_mapping.end() ) { - LOG_W(GTPU,"[%ld] Delete GTP tunnels for rnti: %x, but no tunnel exits\n", instance, rnti); - pthread_mutex_unlock(&globGtp.gtp_lock); - return -1; - } + getInstRetInt(compatInst(instance)); + getRntiRetInt(inst, rnti); int nb=0; - for (auto j=it->second.bearers.begin(); - j!=it->second.bearers.end(); + for (auto j=ptrRnti->second.bearers.begin(); + j!=ptrRnti->second.bearers.end(); ++j) { inst->te2ue_mapping.erase(j->second.teid_incoming); nb++; } - inst->ue2te_mapping.erase(it); + inst->ue2te_mapping.erase(ptrRnti); pthread_mutex_unlock(&globGtp.gtp_lock); LOG_I(GTPU, "[%ld] Deleted all tunnels for RNTI %x (%d tunnels deleted)\n", instance, rnti, nb); return !GTPNOK; @@ -834,21 +842,14 @@ int newGtpuDeleteTunnels(instance_t instance, rnti_t rnti, int nbTunnels, pduses LOG_D(GTPU, "[%ld] Start delete tunnels for RNTI %x\n", instance, rnti); pthread_mutex_lock(&globGtp.gtp_lock); - auto inst=&globGtp.instances[compatInst(instance)]; - auto ptrRNTI=inst->ue2te_mapping.find(rnti); - - if ( ptrRNTI == inst->ue2te_mapping.end() ) { - LOG_W(GTPU,"[%ld] Delete GTP tunnels for rnti: %x, but no tunnel exits\n", instance, rnti); - pthread_mutex_unlock(&globGtp.gtp_lock); - return -1; - } - + getInstRetInt(compatInst(instance)); + getRntiRetInt(inst, rnti); int nb=0; for (int i=0; isecond.bearers.find(pdusession_id[i]); + auto ptr2=ptrRnti->second.bearers.find(pdusession_id[i]); - if ( ptr2 == ptrRNTI->second.bearers.end() ) { + if ( ptr2 == ptrRnti->second.bearers.end() ) { LOG_E(GTPU,"[%ld] GTP-U instance: delete of not existing tunnel RNTI:RAB: %x/%x\n", instance, rnti,pdusession_id[i]); } else { inst->te2ue_mapping.erase(ptr2->second.teid_incoming); @@ -856,9 +857,9 @@ int newGtpuDeleteTunnels(instance_t instance, rnti_t rnti, int nbTunnels, pduses } } - if (ptrRNTI->second.bearers.size() == 0 ) + if (ptrRnti->second.bearers.size() == 0 ) // no tunnels on this rnti, erase the ue entry - inst->ue2te_mapping.erase(ptrRNTI); + inst->ue2te_mapping.erase(ptrRnti); pthread_mutex_unlock(&globGtp.gtp_lock); LOG_I(GTPU, "[%ld] Deleted all tunnels for RNTI %x (%d tunnels deleted)\n", instance, rnti, nb); @@ -936,7 +937,8 @@ static int Gtpv1uHandleEndMarker(int h, pthread_mutex_lock(&globGtp.gtp_lock); // the socket Linux file handler is the instance id - auto inst=&globGtp.instances[h]; + getInstRetInt(h); + auto tunnel=inst->te2ue_mapping.find(ntohl(msgHdr->teid)); if ( tunnel == inst->te2ue_mapping.end() ) { @@ -996,7 +998,8 @@ static int Gtpv1uHandleGpdu(int h, pthread_mutex_lock(&globGtp.gtp_lock); // the socket Linux file handler is the instance id - auto inst=&globGtp.instances[h]; + getInstRetInt(h); + auto tunnel=inst->te2ue_mapping.find(ntohl(msgHdr->teid)); if ( tunnel == inst->te2ue_mapping.end() ) { @@ -1007,7 +1010,7 @@ static int Gtpv1uHandleGpdu(int h, /* see TS 29.281 5.1 */ //Minimum length of GTP-U header if non of the optional fields are present - int offset = sizeof(Gtpv1uMsgHeaderT); + unsigned int offset = sizeof(Gtpv1uMsgHeaderT); uint8_t qfi = -1; bool rqi = false; @@ -1025,12 +1028,20 @@ static int Gtpv1uHandleGpdu(int h, extension_header_length = msgBuf[offset]; switch (next_extension_header_type) { case PDU_SESSION_CONTAINER: { + if (offset + sizeof(PDUSessionContainerT) > msgBufLen ) { + LOG_E(GTPU, "gtp-u received header is malformed, ignore gtp packet\n"); + return GTPNOK; + } PDUSessionContainerT *pdusession_cntr = (PDUSessionContainerT *)(msgBuf + offset + 1); qfi = pdusession_cntr->QFI; rqi = pdusession_cntr->Reflective_QoS_activation; break; } case NR_RAN_CONTAINER: { + if (offset + 1 > msgBufLen ) { + LOG_E(GTPU, "gtp-u received header is malformed, ignore gtp packet\n"); + return GTPNOK; + } uint8_t PDU_type = (msgBuf[offset+1]>>4) & 0x0f; if (PDU_type == 0){ //DL USER Data Format int additional_offset = 6; //Additional offset capturing the first non-mandatory octet (TS 38.425, Figure 5.5.2.1-1) @@ -1057,10 +1068,14 @@ static int Gtpv1uHandleGpdu(int h, } default: LOG_W(GTPU, "unhandled extension 0x%2.2x, skipping\n", next_extension_header_type); - break; + break; } offset += extension_header_length * EXT_HDR_LNTH_OCTET_UNITS; + if (offset > msgBufLen ) { + LOG_E(GTPU, "gtp-u received header is malformed, ignore gtp packet\n"); + return GTPNOK; + } next_extension_header_type = msgBuf[offset - 1]; } } @@ -1081,40 +1096,21 @@ static int Gtpv1uHandleGpdu(int h, const rb_id_t rb_id=tunnel->second.incoming_rb_id; const mui_t mui=RLC_MUI_UNDEFINED; const confirm_t confirm=RLC_SDU_CONFIRM_NO; - const sdu_size_t sdu_buffer_size=msgBufLen-offset; + const sdu_size_t sdu_buffer_size = msgBufLen - offset; unsigned char *const sdu_buffer=msgBuf+offset; const pdcp_transmission_mode_t mode=PDCP_TRANSMISSION_MODE_DATA; const uint32_t sourceL2Id=0; const uint32_t destinationL2Id=0; pthread_mutex_unlock(&globGtp.gtp_lock); - if (qfi != -1 && tunnel->second.callBackSDAP) { - if ( !tunnel->second.callBackSDAP(&ctxt, - srb_flag, - rb_id, - mui, - confirm, - sdu_buffer_size, - sdu_buffer, - mode, - &sourceL2Id, - &destinationL2Id, - qfi, - rqi, - tunnel->second.pdusession_id) ) - LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h); - } else { - if ( !tunnel->second.callBack(&ctxt, - srb_flag, - rb_id, - mui, - confirm, - sdu_buffer_size, - sdu_buffer, - mode, - &sourceL2Id, - &destinationL2Id) ) - LOG_E(GTPU,"[%d] down layer refused incoming packet\n", h); + if (sdu_buffer_size > 0) { + if (qfi != -1 && tunnel->second.callBackSDAP) { + if (!tunnel->second.callBackSDAP(&ctxt, srb_flag, rb_id, mui, confirm, sdu_buffer_size, sdu_buffer, mode, &sourceL2Id, &destinationL2Id, qfi, rqi, tunnel->second.pdusession_id)) + LOG_E(GTPU, "[%d] down layer refused incoming packet\n", h); + } else { + if (!tunnel->second.callBack(&ctxt, srb_flag, rb_id, mui, confirm, sdu_buffer_size, sdu_buffer, mode, &sourceL2Id, &destinationL2Id)) + LOG_E(GTPU, "[%d] down layer refused incoming packet\n", h); + } } if(NR_PDCP_PDU_SN > 0 && NR_PDCP_PDU_SN %5 ==0){ @@ -1139,7 +1135,10 @@ static int Gtpv1uHandleGpdu(int h, extensionHeader->buffer[offset] = (NR_PDCP_PDU_SN >> 16) & 0xff; extensionHeader->buffer[offset+1] = (NR_PDCP_PDU_SN >> 8) & 0xff; extensionHeader->buffer[offset+2] = NR_PDCP_PDU_SN & 0xff; - LOG_D(GTPU, "Octets reporting NR_PDCP_PDU_SN, extensionHeader->buffer[offset]: %u, extensionHeader->buffer[offset+1]:%u, extensionHeader->buffer[offset+2]:%u \n", extensionHeader->buffer[offset], extensionHeader->buffer[offset+1],extensionHeader->buffer[offset+2]); + LOG_D(GTPU, "Octets reporting NR_PDCP_PDU_SN, extensionHeader-> %u:%u:%u \n", + extensionHeader->buffer[offset], + extensionHeader->buffer[offset+1], + extensionHeader->buffer[offset+2]); extensionHeader->buffer[offset+3] = 0x00; //Padding octet extensionHeader->buffer[offset+4] = 0x00; //No more extension headers /*Total size of DDD_status PDU = size of mandatory part + @@ -1148,7 +1147,10 @@ static int Gtpv1uHandleGpdu(int h, * according to TS 38.425: Fig. 5.5.2.2-1 and section 5.5.3.24*/ extensionHeader->length = 1+sizeof(DlDataDeliveryStatus_flagsT)+3+1+1; gtpv1uCreateAndSendMsg( - h, peerIp, peerPort, GTP_GPDU, inst->te2ue_mapping[ntohl(msgHdr->teid)].outgoing_teid, NULL, 0, false, false, 0, 0, NR_RAN_CONTAINER, extensionHeader->buffer, extensionHeader->length); + h, peerIp, peerPort, GTP_GPDU, + inst->te2ue_mapping[ntohl(msgHdr->teid)].outgoing_teid, + NULL, 0, false, false, 0, 0, NR_RAN_CONTAINER, + extensionHeader->buffer, extensionHeader->length); } LOG_D(GTPU,"[%d] Received a %d bytes packet for: teid:%x\n", h, @@ -1158,7 +1160,7 @@ static int Gtpv1uHandleGpdu(int h, } void gtpv1uReceiver(int h) { - uint8_t udpData[65536]; + uint8_t udpData[65536]; int udpDataLen; socklen_t from_len; struct sockaddr_in addr; @@ -1172,10 +1174,17 @@ void gtpv1uReceiver(int h) { LOG_W(GTPU, "[%d] Recvfrom returned 0\n", h); return; } else { - uint8_t msgType = *((uint8_t *)(udpData + 1)); - LOG_D(GTPU, "[%d] Received GTP data, msg type: %x\n", h, msgType); - - switch(msgType) { + if ( udpDataLen < (int)sizeof(Gtpv1uMsgHeaderT) ) { + LOG_W(GTPU, "[%d] received malformed gtp packet \n", h); + return; + } + Gtpv1uMsgHeaderT* msg=(Gtpv1uMsgHeaderT*) udpData; + if ( (int)(ntohs(msg->msgLength) + sizeof(Gtpv1uMsgHeaderT)) != udpDataLen ) { + LOG_W(GTPU, "[%d] received malformed gtp packet length\n", h); + return; + } + LOG_D(GTPU, "[%d] Received GTP data, msg type: %x\n", h, msg->msgType); + switch(msg->msgType) { case GTP_ECHO_RSP: break; @@ -1200,7 +1209,7 @@ void gtpv1uReceiver(int h) { break; default: - LOG_E(GTPU, "[%d] Received a GTP packet of unknown type: %d\n", h, msgType); + LOG_E(GTPU, "[%d] Received a GTP packet of unknown type: %d\n", h, msg->msgType); break; } } @@ -1278,9 +1287,8 @@ void *gtpv1uTask(void *args) { AssertFatal(EXIT_SUCCESS==itti_free(TASK_GTPV1_U, message_p), "Failed to free memory!\n"); } - struct epoll_event *events; - - int nb_events = itti_get_events(TASK_GTPV1_U, &events); + struct epoll_event events[20]; + int nb_events = itti_get_events(TASK_GTPV1_U, events, 20); for (int i = 0; i < nb_events; i++) if ((events[i].events&EPOLLIN)) diff --git a/openshift/README.md b/openshift/README.md index b7409ab945..9f0923bd60 100644 --- a/openshift/README.md +++ b/openshift/README.md @@ -12,21 +12,32 @@ ------ +[[_TOC_]] -**CAUTION: this is experimental. Still a lot to be done.** +# 1. Introduction ------ +## General -# 1. Build pre-requisites # +What follows is a tutorial on how to build images on an OpenShift cluster in a three-step process +(base image, build artifact image, target image). Note that all image +streams/build configs assume the OC project/namespace `oaicicd-ran`. -To build our RAN images, we SHALL use the `codeready-builder-for-rhel-8-x86_64-rpms` repository with all the proper development libraries. +If you want to regenerate images from modified sources, you have to rebuild +the ran-build image. If you reinstalled dependencies, you have to restart from +ran-base. +You first need to login. Do: +```bash +oc login -u -p --server +``` + +## RHEL8 Entitlements + +To build the RAN images, we use the `codeready-builder-for-rhel-8-x86_64-rpms` repository with all the proper development libraries. This repository is not directly accessible from the UBI RHEL8 image (`registry.access.redhat.com/ubi8/ubi:latest`). +Therefore, we need to copy certificates and subscription manager configuration files from a registered RHEL8 machine. -So we need to copy from a register RHEL8 machine certificates and subsccription manager configuration files. - -SO on a `RHEL8` physical machine (or a virtual machine) connected to the OpenShift Cluster, recover the entitlement and the RH subscription manager configs: +on a `RHEL8` physical machine (or a virtual machine) connected to the OpenShift Cluster, recover the entitlement and the RH subscription manager configs: ```bash oc create configmap rhsm-conf --from-file /etc/rhsm/rhsm.conf @@ -35,9 +46,10 @@ oc create configmap rhsm-ca --from-file /etc/rhsm/ca/redhat-uep.pem oc create secret generic etc-pki-entitlement --from-file /etc/pki/entitlement/{NUMBER_ON_YOUR_COMPUTER}.pem --from-file /etc/pki/entitlement/{NUMBER_ON_YOUR_COMPUTER}-key.pem ``` -These configmaps and secret will be shared by all the build configs in your OC project. No need to do it each time. - -**CAUTION: these files expire every month or so. If you have done a build on your OC project and try again a few weeks later, you may need to re-copy them**. +These configmaps and secret will be shared by all the build configs in your OC +project. No need to do it each time. However, these files expire every month +or so. If you have done a build on your OC project and try again a few weeks +later, you may need to re-copy them. (The CI recopies them every time.) ```bash oc delete secret etc-pki-entitlement @@ -45,63 +57,78 @@ oc delete cm rhsm-conf oc delete cm rhsm-ca ``` -**LAST POINT: your OC project SHALL be `oai`.** +# 2. Build of `base` shared image -# 2. Build the Builder shared image # - -In our Eurecom/OSA environment we need to pass a GIT proxy. - -2 things are impacted by this situation: - -* In `openshift/oai-ran-rh8-build-config.yml` file - * `httpProxy: http://proxy.eurecom.fr:8080` - * `httpsProxy: https://proxy.eurecom.fr:8080` -* Add a environment variable to the build config +Create an image stream and build config that specify image properties and build parameters, then start the build: ```bash -oc apply -f openshift/oai-ran-rh8-image-stream.yml -oc apply -f openshift/oai-ran-rh8-build-config.yml -oc set env bc/oai-ran-rhel8-build-config NEEDED_GIT_PROXY=http://proxy.eurecom.fr:8080 -oc start-build oai-ran-rhel8-build-config --follow +oc create -f openshift/ran-base-is.yaml +oc create -f openshift/ran-base-bc.yaml +oc start-build ran-base --from-file= --follow ``` -In case you do NOT require a GIT proxy: **you SHALL remove the 2 lines in `openshift/oai-ran-rh8-build-config.yml` file.** +The `--from-file=` uploads the repository (from which the +build is done) as a binary blob. It is therefore possible to make merges or +other (local) modifications and build an image. -And no need to add a `NEEDED_GIT_PROXY` variable to the build config. +# 3. Build of `build` shared image + +The same as for the `base` image. ```bash -oc apply -f openshift/oai-ran-rh8-image-stream.yml -oc apply -f openshift/modified-oai-ran-rh8-build-config.yml -oc start-build oai-ran-rhel8-build-config --follow +oc create -f openshift/ran-build-is.yaml +oc create -f openshift/ran-build-bc.yaml +oc start-build ran-build --from-file= --follow ``` -After a while it should be successful. +# 4. Build of a target image -# 3. Build an OAI target image # - -For the example the eNB: +The same as for the `base` image: ```bash -oc apply -f openshift/oai-enb-rh8-image-stream.yml -oc apply -f openshift/oai-enb-rh8-build-config.yml -oc start-build oai-enb-rh8-build-config --follow +oc create -f openshift/oai-gnb-is.yaml +oc create -f openshift/oai-gnb-bc.yaml +oc start-build oai-gnb --from-file= --follow ``` -**CAUTION: if you are pushing modifications to the branch you are using, it won't be taken into account besides the Dockerfile.** +# 5. Retrieval of Build Container Images and Build Artifacts -**Because the source files are copied during the shared image creation.** +Build artifacts, such as build logs, can be retrieved by checking the logs of +the individual build steps. For example, for the `ran-build` step, you can do: +```bash +oc logs ran-build-1-build +``` +where `ran-build-1-build` is the name of the `ran-build` build (type `oc get +pods` to get a list of all pods). -**Only way to regenerate images w/ modified source code is to re-start from step #2.** +It is also possible to retrieve the build logs from a running pod. Currently, +this is only used for the `ran-base` step (the others using a python script to +scrape it from stdout): +```bash +oc create -f openshift/ran-base-log-retrieval.yaml +oc rsync ran-base-log-retrieval:/oai-ran/cmake_targets/log cmake_targets/log/ran-base +oc delete -f openshift/ran-base-log-retrieval.yaml +``` -# 4. Deployment using HELM charts # +The images are uploaded into the OpenShift image registry. To download, login +using podman, then pull an image: +```bash +oc whoami -t | sudo podman login -u --password-stdin --tls-verify=false +sudo podman pull /oaicicd-ran/: --tls-verify=false +sudo podman logout +``` +The `` could be `oai-gnb`, and the `` `ci-temp`. -**CAUTION: even more experimental.** +# 6. Deployment using HELM Charts -Helm charts are located in another repository: +Helm charts are located under `charts`. Assuming that the image is in the image +registry, the physims could be deployed as shown in the following steps: ```bash -git clone https://github.com/OPENAIRINTERFACE/openair-k8s.git -cd openair-k8s -git checkout helm-deployment-S6a-S1C-S1U-in-network-18-with-enb -helm install mme /path-to-your-cloned/openair-k8s/charts/oai-mme/ +grep -rl OAICICD_PROJECT ./charts/ | xargs sed -i -e "s#OAICICD_PROJECT#oaicicd-ran#" # select the correct project +sed -i -e "s#TAG#ci-temp#g" ./charts/physims/values.yaml # select the correct tag +helm install physim ./charts/physims/ # deploy +oc get pods # get the list of deployed containers +oc logs # inspect the logs of a pod +helm uninstall physim # undeploy ``` diff --git a/openshift/oai-enb-bc.yaml b/openshift/oai-enb-bc.yaml new file mode 100644 index 0000000000..f9973224cc --- /dev/null +++ b/openshift/oai-enb-bc.yaml @@ -0,0 +1,37 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +kind: BuildConfig +apiVersion: build.openshift.io/v1 +metadata: + name: "oai-enb" +spec: + runPolicy: "Serial" + source: + type: "Binary" + strategy: + dockerStrategy: + dockerfilePath: "docker/Dockerfile.eNB.rhel8.2" + output: + to: + kind: "ImageStreamTag" + name: "oai-enb:latest" diff --git a/openshift/oai-enb-build-config.yml b/openshift/oai-enb-build-config.yml deleted file mode 100644 index 3f6875c50d..0000000000 --- a/openshift/oai-enb-build-config.yml +++ /dev/null @@ -1,55 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -kind: BuildConfig -apiVersion: build.openshift.io/v1 -metadata: - name: "oai-enb-build-config" -spec: - runPolicy: "Serial" - source: - #still needed for the target image - git: - uri: "https://gitlab.eurecom.fr/oai/openairinterface5g.git" - ref: "develop" - httpProxy: http://proxy.eurecom.fr:8080 - httpsProxy: https://proxy.eurecom.fr:8080 - secrets: - - secret: - name: etc-pki-entitlement - destinationDir: etc-pki-entitlement - configMaps: - - configMap: - name: rhsm-conf - destinationDir: rhsm-conf - - configMap: - name: rhsm-ca - destinationDir: rhsm-ca - - strategy: - #using both builder image and target image docker - dockerStrategy: - dockerfilePath: "docker/Dockerfile.eNB.rhel7.oc4-4" - output: - to: - kind: "ImageStreamTag" - name: "oai-enb:latest" diff --git a/openshift/oai-enb-image-stream.yml b/openshift/oai-enb-is.yaml similarity index 91% rename from openshift/oai-enb-image-stream.yml rename to openshift/oai-enb-is.yaml index 94ee13e50f..d7467ec37c 100644 --- a/openshift/oai-enb-image-stream.yml +++ b/openshift/oai-enb-is.yaml @@ -19,12 +19,12 @@ # * contact@openairinterface.org # */ #--------------------------------------------------------------------- -# -apiVersion: v1 + +apiVersion: image.openshift.io/v1 kind: ImageStream metadata: name: oai-enb - namespace: oai -status: - tag: latest - + namespace: oaicicd-ran +spec: + lookupPolicy: + local: true diff --git a/openshift/oai-enb-rh8-build-config.yml b/openshift/oai-enb-rh8-build-config.yml deleted file mode 100644 index e715fc5733..0000000000 --- a/openshift/oai-enb-rh8-build-config.yml +++ /dev/null @@ -1,48 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -kind: BuildConfig -apiVersion: build.openshift.io/v1 -metadata: - name: "oai-enb-rh8-build-config" -spec: - runPolicy: "Serial" - source: - #still needed for the target image - git: - uri: "https://gitlab.eurecom.fr/oai/openairinterface5g.git" - ref: "develop" - httpProxy: http://proxy.eurecom.fr:8080 - httpsProxy: https://proxy.eurecom.fr:8080 - strategy: - #using both builder image and target image docker - dockerStrategy: - dockerfilePath: "docker/Dockerfile.eNB.rhel8.2.oc4-4" - nodeSelector: - kubernetes.io/hostname: dedale.5glab.nsa.eurecom.fr - resources: - requests: - ephemeral-storage: "8Gi" - output: - to: - kind: "ImageStreamTag" - name: "oai-enb:rhel8-latest" diff --git a/openshift/oai-enb-rh8-image-stream.yml b/openshift/oai-enb-rh8-image-stream.yml deleted file mode 100644 index 9d1cfebd54..0000000000 --- a/openshift/oai-enb-rh8-image-stream.yml +++ /dev/null @@ -1,30 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -apiVersion: v1 -kind: ImageStream -metadata: - name: oai-enb - namespace: oai -status: - tag: rhel8-latest - diff --git a/openshift/oai-gnb-bc.yaml b/openshift/oai-gnb-bc.yaml new file mode 100644 index 0000000000..78b9248f19 --- /dev/null +++ b/openshift/oai-gnb-bc.yaml @@ -0,0 +1,37 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +kind: BuildConfig +apiVersion: build.openshift.io/v1 +metadata: + name: "oai-gnb" +spec: + runPolicy: "Serial" + source: + type: "Binary" + strategy: + dockerStrategy: + dockerfilePath: "docker/Dockerfile.gNB.rhel8.2" + output: + to: + kind: "ImageStreamTag" + name: "oai-gnb:latest" diff --git a/openshift/oai-gnb-build-config.yml b/openshift/oai-gnb-build-config.yml deleted file mode 100644 index b0c99959d1..0000000000 --- a/openshift/oai-gnb-build-config.yml +++ /dev/null @@ -1,55 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -kind: BuildConfig -apiVersion: build.openshift.io/v1 -metadata: - name: "oai-gnb-build-config" -spec: - runPolicy: "Serial" - source: - #still needed for the target image - git: - uri: "https://gitlab.eurecom.fr/oai/openairinterface5g.git" - ref: "develop" - httpProxy: http://proxy.eurecom.fr:8080 - httpsProxy: https://proxy.eurecom.fr:8080 - secrets: - - secret: - name: etc-pki-entitlement - destinationDir: etc-pki-entitlement - configMaps: - - configMap: - name: rhsm-conf - destinationDir: rhsm-conf - - configMap: - name: rhsm-ca - destinationDir: rhsm-ca - - strategy: - #using both builder image and target image docker - dockerStrategy: - dockerfilePath: "docker/Dockerfile.gNB.rhel7.oc4-4" - output: - to: - kind: "ImageStreamTag" - name: "oai-gnb:latest" diff --git a/openshift/oai-gnb-image-stream.yml b/openshift/oai-gnb-is.yaml similarity index 92% rename from openshift/oai-gnb-image-stream.yml rename to openshift/oai-gnb-is.yaml index 22a6c157d2..553f9f58e9 100644 --- a/openshift/oai-gnb-image-stream.yml +++ b/openshift/oai-gnb-is.yaml @@ -20,11 +20,11 @@ # */ #--------------------------------------------------------------------- # -apiVersion: v1 +apiVersion: image.openshift.io/v1 kind: ImageStream metadata: name: oai-gnb - namespace: oai -status: - tag: latest - + namespace: oaicicd-ran +spec: + lookupPolicy: + local: true diff --git a/openshift/oai-gnb-rh8-build-config.yml b/openshift/oai-gnb-rh8-build-config.yml deleted file mode 100644 index aa3553c1e4..0000000000 --- a/openshift/oai-gnb-rh8-build-config.yml +++ /dev/null @@ -1,48 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -kind: BuildConfig -apiVersion: build.openshift.io/v1 -metadata: - name: "oai-gnb-rh8-build-config" -spec: - runPolicy: "Serial" - source: - #still needed for the target image - git: - uri: "https://gitlab.eurecom.fr/oai/openairinterface5g.git" - ref: "develop" - httpProxy: http://proxy.eurecom.fr:8080 - httpsProxy: https://proxy.eurecom.fr:8080 - strategy: - #using both builder image and target image docker - dockerStrategy: - dockerfilePath: "docker/Dockerfile.gNB.rhel8.2.oc4-4" - nodeSelector: - kubernetes.io/hostname: dedale.5glab.nsa.eurecom.fr - resources: - requests: - ephemeral-storage: "15Gi" - output: - to: - kind: "ImageStreamTag" - name: "oai-gnb:rhel8-latest" diff --git a/openshift/oai-lte-ue-bc.yaml b/openshift/oai-lte-ue-bc.yaml new file mode 100644 index 0000000000..a0dd92e670 --- /dev/null +++ b/openshift/oai-lte-ue-bc.yaml @@ -0,0 +1,37 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +kind: BuildConfig +apiVersion: build.openshift.io/v1 +metadata: + name: "oai-lte-ue" +spec: + runPolicy: "Serial" + source: + type: "Binary" + strategy: + dockerStrategy: + dockerfilePath: "docker/Dockerfile.lteUE.rhel8.2" + output: + to: + kind: "ImageStreamTag" + name: "oai-lte-ue:latest" diff --git a/openshift/oai-lte-ue-rh8-image-stream.yml b/openshift/oai-lte-ue-is.yaml similarity index 91% rename from openshift/oai-lte-ue-rh8-image-stream.yml rename to openshift/oai-lte-ue-is.yaml index 09aeb2a766..93429faf70 100644 --- a/openshift/oai-lte-ue-rh8-image-stream.yml +++ b/openshift/oai-lte-ue-is.yaml @@ -19,12 +19,12 @@ # * contact@openairinterface.org # */ #--------------------------------------------------------------------- -# -apiVersion: v1 + +apiVersion: image.openshift.io/v1 kind: ImageStream metadata: name: oai-lte-ue - namespace: oai -status: - tag: rhel8-latest - + namespace: oaicicd-ran +spec: + lookupPolicy: + local: true diff --git a/openshift/oai-lte-ue-rh8-build-config.yml b/openshift/oai-lte-ue-rh8-build-config.yml deleted file mode 100644 index f077e4cb26..0000000000 --- a/openshift/oai-lte-ue-rh8-build-config.yml +++ /dev/null @@ -1,48 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -kind: BuildConfig -apiVersion: build.openshift.io/v1 -metadata: - name: "oai-lte-ue-rh8-build-config" -spec: - runPolicy: "Serial" - source: - #still needed for the target image - git: - uri: "https://gitlab.eurecom.fr/oai/openairinterface5g.git" - ref: "develop" - httpProxy: http://proxy.eurecom.fr:8080 - httpsProxy: https://proxy.eurecom.fr:8080 - strategy: - #using both builder image and target image docker - dockerStrategy: - dockerfilePath: "docker/Dockerfile.lteUE.rhel8.2.oc4-4" - nodeSelector: - kubernetes.io/hostname: dedale.5glab.nsa.eurecom.fr - resources: - requests: - ephemeral-storage: "8Gi" - output: - to: - kind: "ImageStreamTag" - name: "oai-lte-ue:rhel8-latest" diff --git a/openshift/oai-nr-ue-bc.yaml b/openshift/oai-nr-ue-bc.yaml new file mode 100644 index 0000000000..da9a5e424c --- /dev/null +++ b/openshift/oai-nr-ue-bc.yaml @@ -0,0 +1,37 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +kind: BuildConfig +apiVersion: build.openshift.io/v1 +metadata: + name: "oai-nr-ue" +spec: + runPolicy: "Serial" + source: + type: "Binary" + strategy: + dockerStrategy: + dockerfilePath: "docker/Dockerfile.nrUE.rhel8.2" + output: + to: + kind: "ImageStreamTag" + name: "oai-nr-ue:latest" diff --git a/openshift/oai-nr-ue-rh8-image-stream.yml b/openshift/oai-nr-ue-is.yaml similarity index 91% rename from openshift/oai-nr-ue-rh8-image-stream.yml rename to openshift/oai-nr-ue-is.yaml index e61cc0dfde..111be0d51d 100644 --- a/openshift/oai-nr-ue-rh8-image-stream.yml +++ b/openshift/oai-nr-ue-is.yaml @@ -19,12 +19,12 @@ # * contact@openairinterface.org # */ #--------------------------------------------------------------------- -# -apiVersion: v1 + +apiVersion: image.openshift.io/v1 kind: ImageStream metadata: name: oai-nr-ue - namespace: oai -status: - tag: rhel8-latest - + namespace: oaicicd-ran +spec: + lookupPolicy: + local: true diff --git a/openshift/oai-nr-ue-rh8-build-config.yml b/openshift/oai-nr-ue-rh8-build-config.yml deleted file mode 100644 index b3367f6ab6..0000000000 --- a/openshift/oai-nr-ue-rh8-build-config.yml +++ /dev/null @@ -1,48 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -kind: BuildConfig -apiVersion: build.openshift.io/v1 -metadata: - name: "oai-nr-ue-rh8-build-config" -spec: - runPolicy: "Serial" - source: - #still needed for the target image - git: - uri: "https://gitlab.eurecom.fr/oai/openairinterface5g.git" - ref: "develop" - httpProxy: http://proxy.eurecom.fr:8080 - httpsProxy: https://proxy.eurecom.fr:8080 - strategy: - #using both builder image and target image docker - dockerStrategy: - dockerfilePath: "docker/Dockerfile.nrUE.rhel8.2.oc4-4" - nodeSelector: - kubernetes.io/hostname: dedale.5glab.nsa.eurecom.fr - resources: - requests: - ephemeral-storage: "8Gi" - output: - to: - kind: "ImageStreamTag" - name: "oai-nr-ue:rhel8-latest" diff --git a/openshift/oai-physim-bc.yaml b/openshift/oai-physim-bc.yaml new file mode 100644 index 0000000000..e013a20fd3 --- /dev/null +++ b/openshift/oai-physim-bc.yaml @@ -0,0 +1,37 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- + +kind: BuildConfig +apiVersion: build.openshift.io/v1 +metadata: + name: "oai-physim" +spec: + runPolicy: "Serial" + source: + type: "Binary" + strategy: + dockerStrategy: + dockerfilePath: "docker/Dockerfile.phySim.rhel8.2" + output: + to: + kind: "ImageStreamTag" + name: "oai-physim:latest" diff --git a/openshift/oai-physim-image-stream.yml b/openshift/oai-physim-is.yaml similarity index 98% rename from openshift/oai-physim-image-stream.yml rename to openshift/oai-physim-is.yaml index 9ef338f139..df0545eb61 100644 --- a/openshift/oai-physim-image-stream.yml +++ b/openshift/oai-physim-is.yaml @@ -24,6 +24,7 @@ apiVersion: image.openshift.io/v1 kind: ImageStream metadata: name: oai-physim + namespace: oaicicd-ran spec: lookupPolicy: local: true diff --git a/openshift/oai-ran-rh8-build-config.yml b/openshift/oai-ran-rh8-build-config.yml deleted file mode 100644 index 3d27b7cb5c..0000000000 --- a/openshift/oai-ran-rh8-build-config.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -kind: BuildConfig -apiVersion: build.openshift.io/v1 -metadata: - name: "oai-ran-rhel8-build-config" -spec: - runPolicy: "Serial" - source: - git: - uri: "https://gitlab.eurecom.fr/oai/openairinterface5g.git" - ref: "develop" - httpProxy: http://proxy.eurecom.fr:8080 - httpsProxy: https://proxy.eurecom.fr:8080 - secrets: - - secret: - name: etc-pki-entitlement - destinationDir: etc-pki-entitlement - configMaps: - - configMap: - name: rhsm-conf - destinationDir: rhsm-conf - - configMap: - name: rhsm-ca - destinationDir: rhsm-ca - strategy: - dockerStrategy: - dockerfilePath: "docker/Dockerfile.ran.rhel8.2.oc4-4" - nodeSelector: - kubernetes.io/hostname: dedale.5glab.nsa.eurecom.fr - resources: - requests: - ephemeral-storage: "5Gi" - output: - to: - kind: "ImageStreamTag" - name: "oai-ran:rhel8-latest" diff --git a/openshift/oai-ran-rh8-image-stream.yml b/openshift/oai-ran-rh8-image-stream.yml deleted file mode 100644 index f6f4f8614f..0000000000 --- a/openshift/oai-ran-rh8-image-stream.yml +++ /dev/null @@ -1,30 +0,0 @@ -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# -apiVersion: v1 -kind: ImageStream -metadata: - name: oai-ran - namespace: oai -status: - tag: rhel8-latest - diff --git a/openshift/oai-ran-build-config.yml b/openshift/ran-base-bc.yaml similarity index 82% rename from openshift/oai-ran-build-config.yml rename to openshift/ran-base-bc.yaml index 39d7a40f6d..85247813aa 100644 --- a/openshift/oai-ran-build-config.yml +++ b/openshift/ran-base-bc.yaml @@ -23,15 +23,11 @@ kind: BuildConfig apiVersion: build.openshift.io/v1 metadata: - name: "oai-ran-build-config" + name: "ran-base" spec: runPolicy: "Serial" source: - git: - uri: "https://gitlab.eurecom.fr/oai/openairinterface5g.git" - ref: "develop" - httpProxy: http://proxy.eurecom.fr:8080 - httpsProxy: https://proxy.eurecom.fr:8080 + type: "Binary" secrets: - secret: name: etc-pki-entitlement @@ -45,8 +41,8 @@ spec: destinationDir: rhsm-ca strategy: dockerStrategy: - dockerfilePath: "docker/Dockerfile.ran.rhel7.oc4-4" + dockerfilePath: "docker/Dockerfile.base.rhel8.2" output: to: kind: "ImageStreamTag" - name: "oai-ran:latest" + name: "ran-base:latest" diff --git a/openshift/oai-ran-image-stream.yml b/openshift/ran-base-is.yaml similarity index 88% rename from openshift/oai-ran-image-stream.yml rename to openshift/ran-base-is.yaml index e1ef9d0b31..e551166627 100644 --- a/openshift/oai-ran-image-stream.yml +++ b/openshift/ran-base-is.yaml @@ -18,13 +18,12 @@ # * For more information about the OpenAirInterface (OAI) Software Alliance: # * contact@openairinterface.org # */ -#--------------------------------------------------------------------- -# -apiVersion: v1 + +apiVersion: image.openshift.io/v1 kind: ImageStream metadata: - name: oai-ran - namespace: oai -status: - tag: latest - + name: ran-base + namespace: oaicicd-ran +spec: + lookupPolicy: + local: true diff --git a/openshift/ran-base-log-retrieval.yaml b/openshift/ran-base-log-retrieval.yaml new file mode 100644 index 0000000000..7fc1d78cc6 --- /dev/null +++ b/openshift/ran-base-log-retrieval.yaml @@ -0,0 +1,13 @@ +# Creating a pod to retrieve ran-base logs +apiVersion: v1 +kind: Pod +metadata: + name: ran-base-log-retrieval + namespace: oaicicd-ran +spec: + containers: + - name: logcontainer + image: ran-base:latest + command: ["/bin/sh", "-c"] + args: + ["sleep inf"] diff --git a/openshift/ran-build-bc.yaml b/openshift/ran-build-bc.yaml new file mode 100644 index 0000000000..84b0f9e589 --- /dev/null +++ b/openshift/ran-build-bc.yaml @@ -0,0 +1,37 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +kind: BuildConfig +apiVersion: build.openshift.io/v1 +metadata: + name: "ran-build" +spec: + runPolicy: "Serial" + source: + type: "Binary" + strategy: + dockerStrategy: + dockerfilePath: "docker/Dockerfile.build.rhel8.2" + output: + to: + kind: "ImageStreamTag" + name: "ran-build:latest" diff --git a/openshift/oai-gnb-rh8-image-stream.yml b/openshift/ran-build-is.yaml similarity index 90% rename from openshift/oai-gnb-rh8-image-stream.yml rename to openshift/ran-build-is.yaml index 2e04e94f5b..0538b16478 100644 --- a/openshift/oai-gnb-rh8-image-stream.yml +++ b/openshift/ran-build-is.yaml @@ -20,11 +20,11 @@ # */ #--------------------------------------------------------------------- # -apiVersion: v1 +apiVersion: image.openshift.io/v1 kind: ImageStream metadata: - name: oai-gnb - namespace: oai -status: - tag: rhel8-latest - + name: ran-build + namespace: oaicicd-ran +spec: + lookupPolicy: + local: true diff --git a/pre-commit b/pre-commit deleted file mode 100644 index ab54a821a5..0000000000 --- a/pre-commit +++ /dev/null @@ -1,31 +0,0 @@ - -#!/bin/bash -# Installation: -# cp pre-commit .git/hooks -# chmod +x .git/hooks/pre-commit - -OPTIONS="--options=ci-scripts/astyle-options.txt" - -RETURN=0 -ASTYLE=$(which astyle) -if [ $? -ne 0 ]; then - echo "[!] astyle not installed. Unable to check source file format policy." >&2 - exit 1 -fi - -FILES=`git diff --cached --name-only --diff-filter=ACMR | grep -E "\.(c|cpp|h)$"` -for FILE in $FILES; do - $ASTYLE $OPTIONS < $FILE | cmp -s $FILE - - if [ $? -ne 0 ]; then - echo "[!] $FILE does not respect the agreed coding style." >&2 - RETURN=1 - fi -done - -if [ $RETURN -eq 1 ]; then - echo "" >&2 - echo "Make sure you have run astyle with the following options:" >&2 - echo $OPTIONS >&2 -fi - -exit $RETURN diff --git a/pre-commit-clang b/pre-commit-clang new file mode 100644 index 0000000000..f7b219a7d5 --- /dev/null +++ b/pre-commit-clang @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# +# Runs clang-format on changed regions before commit. +# +# To install this, copy it to .git/hooks/pre-commit in your repo. +# Remaining installation checks/instructions will be printed when you commit. +# + +read -d '' help <<- EOF +This repository requires you to install the clang-format command. This hook has +been tested with clang-format-10, so remove all previous versions and reinstall: +$ sudo apt-get remove clang-format-* +$ sudo apt-get install clang-format-10 +You should now have clang-format-10 installed. Then, update the configuration +as follows: +$ git config --global clangFormat.binary clang-format-10 +$ git config --global clangFormat.style file +$ git config --global alias.clang-format clang-format-10 +EOF + +check_clang_format() { + if hash git clang-format 2>/dev/null; then + return + else + echo "SETUP ERROR: no git clang-format executable found, or it is not executable" + echo "$help" + exit 1 + fi +} + +check_git_config() { + if [[ "$(git config --get clangFormat.binary)" != "clang-format-10" ]]; then + echo "SETUP ERROR: git config clangFormat.binary should be \"clang-format-10\"." + echo "$help" + exit 1 + fi + if [[ "$(git config --get clangFormat.style)" != "file" ]]; then + echo "SETUP ERROR: git config clangFormat.style should be \"file\"." + echo "$help" + exit 1 + fi +} + +check_clang_format +check_git_config + +readonly out=$(git clang-format -v --diff) + +if [[ "$out" == *"no modified files to format"* ]]; then exit 0; fi +if [[ "$out" == *"clang-format did not modify any files"* ]]; then exit 0; fi + +echo "ERROR: the code to be committed is not formatted properly" +echo "you need to run \"git clang-format\" on your commit" +exit 1 diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index 33d0179d8d..fb16796cab 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -465,7 +465,7 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp pthread_mutex_unlock(&Sockmutex); LOG_D(HW,"sent %d samples at time: %ld->%ld, energy in first antenna: %d\n", - nsamps, timestamp, timestamp+nsamps, signal_energy(samplesVoid[0], nsamps) ); + nsamps, timestamp, timestamp+nsamps, signal_energy(samplesVoid[0], nsamps) ); return nsamps; } diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf index c8e109d302..cbad6fe187 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf @@ -216,7 +216,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf index a4c877a7ba..c09f10ea0b 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf @@ -210,7 +210,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf index e5478983cf..44a17612a9 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf @@ -196,7 +196,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf index efa0d3e2fa..716e222d60 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf @@ -192,7 +192,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf index 8a2ce9f63e..78bc1220e8 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf @@ -210,7 +210,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf index 616f86a1cd..ab78dfb950 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf @@ -194,7 +194,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf index 0818fe11d7..8dd080e1c8 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf @@ -17,10 +17,12 @@ gNBs = plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); - tr_s_preference = "local_mac" + tr_s_preference = "local_mac"; ////////// Physical parameters: + min_rxtxtime = 6; + servingCellConfigCommon = ( { #spCellConfigCommon @@ -100,11 +102,11 @@ gNBs = prach_RootSequenceIndex = 1; # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex # - msg1_SubcarrierSpacing = 1, + msg1_SubcarrierSpacing = 1; # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B - restrictedSetConfig = 0, + restrictedSetConfig = 0; msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -132,20 +134,6 @@ gNBs = # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 subcarrierSpacing = 1; - - #tdd-UL-DL-ConfigurationCommon -# subcarrierSpacing -# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - referenceSubcarrierSpacing = 1; - # pattern1 - # dl_UL_TransmissionPeriodicity - # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 - dl_UL_TransmissionPeriodicity = 6; - nrofDownlinkSlots = 7; - nrofDownlinkSymbols = 6; - nrofUplinkSlots = 2; - nrofUplinkSymbols = 4; - ssPBCH_BlockPower = -25; } @@ -193,14 +181,13 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); RUs = ( { - local_rf = "yes" + local_rf = "yes"; nb_tx = 1; nb_rx = 1; att_tx = 0; @@ -218,7 +205,7 @@ RUs = ( ## beamforming 4x4 matrix: #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; sdr_addrs = "type=x300"; - clock_src = "external"; + clock_src = "internal"; # if_freq = 3700000000L; # if_offset = 1000000; } @@ -229,7 +216,7 @@ THREAD_STRUCT = ( #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" - worker_config = "WORKER_ENABLE"; + worker_config = "WORKER_DISABLE"; } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf new file mode 100644 index 0000000000..c74476902b --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf @@ -0,0 +1,251 @@ +Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + + cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-Eurecom-5GNRBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); + + tr_s_preference = "local_mac"; + + ////////// Physical parameters: + + min_rxtxtime = 6; + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 2150 MHz + 12 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 430864; + dl_frequencyBand = 66; + # this is 2150 MHz + dl_absoluteFrequencyPointA = 430000; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 24; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=24 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 6325; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 0; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 66; + ul_absoluteFrequencyPointA = 350000; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 24; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 6325; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -118; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1; + +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0; + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + GNB_INTERFACE_NAME_FOR_S1U = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; + ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 +} +); + +RUs = ( + { + local_rf = "yes"; + nb_tx = 1; + nb_rx = 1; + att_tx = 0; + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + eNB_instances = [0]; + ## beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ## beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + #bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + sdr_addrs = "type=x300"; + clock_src = "internal"; + # if_freq = 3700000000L; + # if_offset = 1000000; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_DISABLE"; + } +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + + log_config : + { + global_log_level ="info"; + hw_log_level ="info"; + phy_log_level ="info"; + mac_log_level ="info"; + rlc_log_level ="info"; + pdcp_log_level ="info"; + rrc_log_level ="info"; + }; + diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf index 022f17e490..f852550bbe 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpn300.conf @@ -132,20 +132,6 @@ gNBs = # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 subcarrierSpacing = 0; - - #tdd-UL-DL-ConfigurationCommon -# subcarrierSpacing -# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - referenceSubcarrierSpacing = 0; - # pattern1 - # dl_UL_TransmissionPeriodicity - # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 - dl_UL_TransmissionPeriodicity = 6; - nrofDownlinkSlots = 7; - nrofDownlinkSymbols = 6; - nrofUplinkSlots = 2; - nrofUplinkSymbols = 4; - ssPBCH_BlockPower = -25; } @@ -193,7 +179,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf new file mode 100644 index 0000000000..ac1dba7e42 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf @@ -0,0 +1,249 @@ +Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + + cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-Eurecom-5GNRBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); + + tr_s_preference = "local_mac"; + + ////////// Physical parameters: + + min_rxtxtime = 6; + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 2150 MHz + 12 PRBs@15kHz SCS (same as initial BWP), points to Subcarrier 0 of RB#10 of SSB block + absoluteFrequencySSB = 430432; + dl_frequencyBand = 66; + # this is 2150 MHz + dl_absoluteFrequencyPointA = 430000; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 0; + dl_carrierBandwidth = 25; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=25 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 6600; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 0; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 0; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 66; + ul_absoluteFrequencyPointA = 350000; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 0; + ul_carrierBandwidth = 25; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 6600; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 0; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -118; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + msg1_SubcarrierSpacing = 0; +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0; + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 0x1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 0; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + GNB_INTERFACE_NAME_FOR_S1U = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + thread_pool_size = 8; + ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 + } +); + +RUs = ( + { + local_rf = "yes"; + nb_tx = 1; + nb_rx = 1; + att_tx = 0; + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + eNB_instances = [0]; + ## beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ## beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + #bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + sdr_addrs = "type=x300"; + clock_src = "internal"; + # if_freq = 3700000000L; + # if_offset = 1000000; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_DISABLE"; + } +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + + log_config : + { + global_log_level ="info"; + hw_log_level ="info"; + phy_log_level ="info"; + mac_log_level ="info"; + rlc_log_level ="info"; + pdcp_log_level ="info"; + rrc_log_level ="info"; + }; + diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf index 812ac8dafb..6666d75de5 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf @@ -209,7 +209,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf index 1450c45eee..807c7cd28b 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf @@ -241,7 +241,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf index 562e2b16ab..a818071029 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf @@ -192,7 +192,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index a8ecb8c4b6..9d4cf054be 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -191,7 +191,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; max_ldpc_iterations = 5; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf index 10122b9eb2..8193e55979 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf @@ -191,7 +191,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf index 20d01c2a00..e951754bf0 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf @@ -208,7 +208,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf index 44f3889eec..80d369beff 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf @@ -193,7 +193,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf index fbafef81b4..f4791448fa 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf @@ -192,7 +192,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf index 38d6ed3c61..34a6f35f11 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf @@ -192,7 +192,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf index b7da7b17f4..c9180420fc 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf @@ -192,7 +192,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf index 9f78716bcc..6aaba26991 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf @@ -193,7 +193,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpx300.conf index 9a0f1cb036..818cd3a0be 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/oaiL1.nfapi.usrpx300.conf @@ -21,7 +21,6 @@ L1s = ( remote_n_portc = 50001; // vnf p5 port local_n_portd = 50010; // pnf p7 port remote_n_portd = 50011; // vnf p7 port - thread_pool_size = 8; } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf index 9a3fe358a5..bbc12027d2 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf @@ -209,7 +209,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf index 9e1ae24d67..6604568be1 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf @@ -210,7 +210,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf index 35778ef705..ed3a3ce385 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_nsa_n310.conf @@ -210,7 +210,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf index a64a4c6022..f0f546208e 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf @@ -15,23 +15,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - - }); - + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf index 4309c13dd3..be42f67d44 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf @@ -14,23 +14,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - - }); - + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; @@ -204,7 +188,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; prach_dtx_threshold = 120; pucch0_dtx_threshold = 150; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gNB_SA_40_2x2.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gNB_SA_40_2x2.conf new file mode 100755 index 0000000000..a050ed6035 --- /dev/null +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gNB_SA_40_2x2.conf @@ -0,0 +1,323 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_CU_ID = 0xe00; + +# cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x010203; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + }); + + nr_cellid = 12345678L + +# tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 2; + min_rxtxtime_pdsch = 2; + ul_prbblacklist = "51,52,53,54" + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 11; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3301.68 MHz + 22*12*30e-3 MHz = 3309.6 + #absoluteFrequencySSB = 620640; + # this is 3300.60 MHz + 53*12*30e-3 MHz = 3319.68 + absoluteFrequencySSB = 621312; + # this is 3503.28 MHz + 22*12*30e-3 MHz = 3511.2 + #absoluteFrequencySSB = 634080; + # this is 3600.48 MHz + #absoluteFrequencySSB = 640032; + #dl_frequencyBand = 78; + # this is 3301.68 MHz + #dl_absoluteFrequencyPointA = 620112; + # this is 3300.60 MHz + dl_absoluteFrequencyPointA = 620040; + # this is 3502.56 MHz + #dl_absoluteFrequencyPointA = 633552; + # this is 3600.48 MHz + #dl_absoluteFrequencyPointA = 640032; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=106 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; + #initialULBWPmappingType + #0=typeA,1=typeB + initialDLBWPmappingType_0 = 0; + #this is SS=1,L=13 + initialDLBWPstartSymbolAndLength_0 = 40; + + initialDLBWPk0_1 = 0; + initialDLBWPmappingType_1 = 0; + #this is SS=1,L=5 + initialDLBWPstartSymbolAndLength_1 = 57; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 106; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 28875; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 12; + preambleReceivedTargetPower = -104; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + # pusch-ConfigCommon (up to 16 elements) + initialULBWPk2_0 = 6; + initialULBWPmappingType_0 = 1 + # this is SS=2 L=13 + initialULBWPstartSymbolAndLength_0 = 41; + + initialULBWPk2_1 = 6; + initialULBWPmappingType_1 = 1; + # this is SS=0 L=4 + initialULBWPstartSymbolAndLength_1 = 52; + + initialULBWPk2_2 = 7; + initialULBWPmappingType_2 = 1; + # this is SS=10 L=4 + initialULBWPstartSymbolAndLength_2 = 52; + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "192.168.69.131"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "em1"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.18.196/24"; + GNB_INTERFACE_NAME_FOR_NGU = "em1"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.18.196/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 200; + pucch_TargetSNRx10 = 200; + ulsch_max_slots_inactivity=10; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + pusch_proc_threads = 3; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 50; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 2 + nb_rx = 2 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ##beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + + sdr_addrs = "addr=192.168.30.2,second_addr=192.168.50.2,clock_source=internal,time_source=internal" + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + f1ap_log_level ="debug"; + f1ap_log_verbosity ="medium"; + }; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf new file mode 100644 index 0000000000..500f2be93e --- /dev/null +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf @@ -0,0 +1,313 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_CU_ID = 0xe00; + +# cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x010203; // 0 false, else true + }, + { + sst = 1; + sd = 0x000001; // 0 false, else true + } + ); + }); + + nr_cellid = 12345678L + +# tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 2; + min_rxtxtime_pdsch = 5; + ul_prbblacklist = "51,52,53,54" + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 11; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3301.68 MHz + 22*12*30e-3 MHz = 3309.6 + #absoluteFrequencySSB = 620640; + # this is 3300.60 MHz + 53*12*30e-3 MHz = 3319.68 + absoluteFrequencySSB = 621312; + # this is 3503.28 MHz + 22*12*30e-3 MHz = 3511.2 + #absoluteFrequencySSB = 634080; + # this is 3600.48 MHz + #absoluteFrequencySSB = 640032; + #dl_frequencyBand = 78; + # this is 3301.68 MHz + #dl_absoluteFrequencyPointA = 620112; + # this is 3300.60 MHz + dl_absoluteFrequencyPointA = 620040; + # this is 3502.56 MHz + #dl_absoluteFrequencyPointA = 633552; + # this is 3600.48 MHz + #dl_absoluteFrequencyPointA = 640032; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=106 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 106; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 28875; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 12; + preambleReceivedTargetPower = -104; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "192.168.70.132"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24"; + GNB_INTERFACE_NAME_FOR_NGU = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; +# pusch_TargetSNRx10 = 200; +# pucch_TargetSNRx10 = 150; + ulsch_max_frame_inactivity = 0; + } +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; + thread_pool_size = 4; +# pucch0_dtx_threshold = 150; +} +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 2 + nb_rx = 2 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ##beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + + sf_extension = 0 + sdr_addrs = "addr=192.168.82.52,second_addr=192.168.83.52,clock_source=internal,time_source=internal" + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_SPLIT"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + f1ap_log_level ="debug"; + f1ap_log_verbosity ="medium"; + }; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf new file mode 100644 index 0000000000..fa3960aec8 --- /dev/null +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf @@ -0,0 +1,316 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_CU_ID = 0xe00; + +# cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x010203; // 0 false, else true + }, + { + sst = 1; + sd = 0x000001; // 0 false, else true + } + ); + }); + + nr_cellid = 12345678L + +# tr_s_preference = "local_mac" + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 2; + #pusch_TargetSNRx10 = 200; + #pucch_TargetSNRx10 = 200; + ul_prbblacklist = "79,80,81,82" + min_rxtxtime = 6; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 11; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3301.68 MHz + 22*12*30e-3 MHz = 3309.6 + #absoluteFrequencySSB = 620640; + # this is 3300.60 MHz + 53*12*30e-3 MHz = 3319.68 + absoluteFrequencySSB = 621312; + # this is 3503.28 MHz + 22*12*30e-3 MHz = 3511.2 + #absoluteFrequencySSB = 634080; + # this is 3600.48 MHz + #absoluteFrequencySSB = 640032; + #dl_frequencyBand = 78; + # this is 3301.68 MHz + #dl_absoluteFrequencyPointA = 620112; + # this is 3300.60 MHz + dl_absoluteFrequencyPointA = 620040; + # this is 3502.56 MHz + #dl_absoluteFrequencyPointA = 633552; + # this is 3600.48 MHz + #dl_absoluteFrequencyPointA = 640032; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 162; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=106 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 31899; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 11; + initialDLBWPsearchSpaceZero = 0; + + + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 162; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 31899; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 12; + preambleReceivedTargetPower = -104; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "192.168.70.132"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24"; + GNB_INTERFACE_NAME_FOR_NGU = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + #pusch_TargetSNRx10 = 200; + #pucch_TargetSNRx10 = 200; + ulsch_max_frame_inactivity = 1; + } +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; + thread_pool_size = 8; +# pucch0_dtx_threshold = 150; +} +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 2 + nb_rx = 2 + att_tx = 0 + att_rx = 0; + bands = [78]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ##beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + sf_extension = 0 + sdr_addrs = "addr=192.168.82.52,second_addr=192.168.83.52,clock_source=internal,time_source=internal" + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_SPLIT"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + f1ap_log_level ="debug"; + f1ap_log_verbosity ="medium"; + }; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf index cb90889b52..66051ef9bc 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.tm1.106PRB.usrpn300.gtp-itti.conf @@ -15,23 +15,8 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 100; - plmn_list = ({ - mcc = 208; - mnc = 93; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x010203; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - - }); - + plmn_list = ({ mcc = 208; mnc = 93; mnc_length = 2; snssaiList = ({ sst = 1 }) }); + tr_s_preference = "local_mac" ////////// Physical parameters: diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf index 42aa555771..ca9f853b69 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf @@ -11,18 +11,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; @@ -339,7 +328,3 @@ log_config : ngap_log_level ="debug"; f1ap_log_level ="debug"; }; -<<<<<<< HEAD -======= - ->>>>>>> origin/develop diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf index 6abf2c19cc..30742d88f4 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpn300.conf @@ -11,22 +11,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.273PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpx300.conf similarity index 74% rename from targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.273PRB.2x2.usrpn300.conf rename to targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpx300.conf index 24090bef85..560febad88 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.273PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpx300.conf @@ -1,4 +1,4 @@ -Active_gNBs = ( "gNB-OAI"); +Active_gNBs = ( "5G-GOA-gNB"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; @@ -7,7 +7,7 @@ gNBs = { ////////// Identification parameters: gNB_ID = 0xe00; - gNB_name = "gNB-OAI"; + gNB_name = "5G-GOA-gNB"; // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; @@ -19,25 +19,27 @@ gNBs = { sst = 1; sd = 0x1; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true } ); + }); nr_cellid = 12345678L; ////////// Physical parameters: - pdsch_AntennaPorts_XP = 1; - pusch_AntennaPorts = 2; - do_CSIRS = 0; - ul_prbblacklist = "135,136,137,138" + min_rxtxtime = 6; - pdcch_ConfigSIB1 = ( + pdcch_ConfigSIB1 = ( { controlResourceSetZero = 12; - searchSpaceZero = 10; + searchSpaceZero = 0; } - ); + ); servingCellConfigCommon = ( { @@ -47,42 +49,43 @@ gNBs = # downlinkConfigCommon #frequencyInfoDL - # this is 3300.24 + 134*12*30e3 = 3348.48 MHz (5G NR GSCN: 7741) - absoluteFrequencySSB = 623232; - dl_frequencyBand = 78; - # this is 3300.24 MHz - dl_absoluteFrequencyPointA = 620016; + # this is 2150 MHz + 61 PRBs@30kHz SCS + absoluteFrequencySSB = 434392; + dl_frequencyBand = 66; + # this is 2150 MHz + dl_absoluteFrequencyPointA = 430000; #scs-SpecificCarrierList - dl_offstToCarrier = 0; + dl_offstToCarrier = 0; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - dl_subcarrierSpacing = 1; - dl_carrierBandwidth = 273; + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; #initialDownlinkBWP #genericParameters - # this is RBstart=0,L=162 (275*(275-L+1))+(274-RBstart)) - initialDLBWPlocationAndBandwidth = 31624; - # + # this is RBstart=0,L=106 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 28875; # 13475 6366 12925 12956 28875 12952 # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - initialDLBWPsubcarrierSpacing = 1; + initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; - initialDLBWPsearchSpaceZero = 10; + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 0; #uplinkConfigCommon #frequencyInfoUL - ul_frequencyBand = 78; + ul_frequencyBand = 66; + # this is 1750 MHz + ul_absoluteFrequencyPointA = 350000; #scs-SpecificCarrierList ul_offstToCarrier = 0; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 ul_subcarrierSpacing = 1; - ul_carrierBandwidth = 273; + ul_carrierBandwidth = 106; pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 31624; + initialULBWPlocationAndBandwidth = 28875; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -93,8 +96,8 @@ gNBs = #0 = one, 1=two, 2=four, 3=eight prach_msg1_FDM = 0; prach_msg1_FrequencyStart = 0; - zeroCorrelationZoneConfig = 12; - preambleReceivedTargetPower = -90; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -118; #preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) preambleTransMax = 6; #powerRampingStep @@ -105,7 +108,7 @@ gNBs = ra_ResponseWindow = 4; #ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR #1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen - ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; #oneHalf (0..15) 4,8,12,16,...60,64 ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; #ra_ContentionResolutionTimer @@ -118,10 +121,10 @@ gNBs = prach_RootSequenceIndex = 1; # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex # - msg1_SubcarrierSpacing = 1, + msg1_SubcarrierSpacing = 1; # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B - restrictedSetConfig = 0, + restrictedSetConfig = 0; msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -131,7 +134,7 @@ gNBs = # 0 = neither, 1= group hopping, 2=sequence hopping pucchGroupHopping = 0; hoppingId = 40; - p0_nominal = -70; + p0_nominal = -90; # ssb_PositionsInBurs_BitmapPR # 1=short, 2=medium, 3=long ssb_PositionsInBurst_PR = 2; @@ -163,45 +166,12 @@ gNBs = nrofUplinkSlots = 2; nrofUplinkSymbols = 4; - ssPBCH_BlockPower = -25; + ssPBCH_BlockPower = -25; } ); -# Dedicated Serving Cell Configuration -servingCellConfigDedicated = ({ - # BWP-Downlink - # BWP 1 Configuration - dl_bwp-Id_1 = 1; - dl_bwp1_locationAndBandwidth = 1099; // RBstart=0, L=273 (100 MHz BW) - # subcarrierSpacing - # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - dl_bwp1_subcarrierSpacing = 1; - - firstActiveDownlinkBWP-Id = 1; #BWP-Id - defaultDownlinkBWP-Id = 1; #BWP-Id - - # bwp-InactivityTimer ENUMERATED {ms2, ms3, ms4, ms5, ms6, ms8, ms10, ms20, ms30, - # ms40,ms50, ms60, ms80,ms100, ms200,ms300, ms500, - # ms750, ms1280, ms1920, ms2560, spare10, spare9, spare8, - # spare7, spare6, spare5, spare4, spare3, spare2, spare1 } - - # UplinkConfig - # BWP-Uplink - # BWP 1 Configuration - ul_bwp-Id_1 = 1; - ul_bwp1_locationAndBandwidth = 1099; // RBstart=0, L=273 (100 MHz BW) - # subcarrierSpacing - # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 - ul_bwp1_subcarrierSpacing = 1; - - firstActiveUplinkBWP-Id = 1; #BWP-Id - } -); - - - # ------- SCTP definitions SCTP : { @@ -212,20 +182,19 @@ servingCellConfigDedicated = ({ ////////// AMF parameters: - amf_ip_address = ( { ipv4 = "192.168.70.132"; + amf_ip_address = ( { ipv4 = "192.168.71.132"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; } ); - NETWORK_INTERFACES : { - GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai"; - GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24"; - GNB_INTERFACE_NAME_FOR_NGU = "demo-oai"; - GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24"; + GNB_INTERFACE_NAME_FOR_NG_AMF = "eno1"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.71.129/26"; + GNB_INTERFACE_NAME_FOR_NGU = "eno1"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.71.129/26"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 }; @@ -239,7 +208,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; - pusch_FailureThres = 1000; ulsch_max_frame_inactivity = 0; } ); @@ -247,36 +215,46 @@ MACRLCs = ( L1s = ( { num_cc = 1; - tr_n_preference = "local_mac"; - prach_dtx_threshold = 120; - pucch0_dtx_threshold = 80; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; + ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); RUs = ( -{ - local_rf = "yes" - nb_tx = 2; - nb_rx = 2; - att_tx = 0; - att_rx = 0; - bands = [78]; - max_pdschReferenceSignalPower = -27; - max_rxgain = 75; - eNB_instances = [0]; - ##beamforming 1x2 matrix: 1 layer x 2 antennas - bf_weights = [0x00007fff, 0x0000]; - #clock_src = "internal"; - sdr_addrs = "mgmt_addr=192.168.10.2,addr=192.168.10.2,clock_source=internal,time_source=internal" -} + { + local_rf = "yes"; + nb_tx = 1; + nb_rx = 1; + att_tx = 0; + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + sf_extension = 0; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ##beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + sdr_addrs = "type=x300"; + clock_src = "internal"; + # if_freq = 3700000000L; + # if_offset = 1000000; + } ); THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_SINGLE_THREAD"; + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" - worker_config = "WORKER_ENABLE"; + worker_config = "WORKER_DISABLE"; } ); @@ -318,3 +296,4 @@ log_config : ngap_log_level ="debug"; f1ap_log_level ="debug"; }; + diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.24PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.24PRB.usrpx300.conf new file mode 100644 index 0000000000..3e7f50f506 --- /dev/null +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.24PRB.usrpx300.conf @@ -0,0 +1,300 @@ +Active_gNBs = ( "5G-GOA-gNB"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + gNB_name = "5G-GOA-gNB"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x1; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + + }); + + nr_cellid = 12345678L; + + ////////// Physical parameters: + + sib1_tda = 5; + min_rxtxtime = 6; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 4; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 2150 MHz + 14 PRBs@30kHz SCS (same as initial BWP), points to Subcarrier 0 of RB#10 of SSB block + absoluteFrequencySSB = 431008; + dl_frequencyBand = 66; + # this is 2150 MHz + dl_absoluteFrequencyPointA = 430000; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 24; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=24 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 6325; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 4; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 66; + # this is 1750 MHz + ul_absoluteFrequencyPointA = 350000; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 24; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 6325; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -118; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1; +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0; + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "192.168.71.132"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + GNB_INTERFACE_NAME_FOR_NG_AMF = "eno1"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.71.129/26"; + GNB_INTERFACE_NAME_FOR_NGU = "eno1"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.71.129/26"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( +{ + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 150; + pucch_TargetSNRx10 = 200; + ulsch_max_frame_inactivity = 0; +} +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; + ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 +} +); + +RUs = ( + { + local_rf = "yes"; + nb_tx = 1; + nb_rx = 1; + att_tx = 0; + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + sf_extension = 0; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ##beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + sdr_addrs = "type=x300"; + clock_src = "internal"; + # if_freq = 3700000000L; + # if_offset = 1000000; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_DISABLE"; + } +); + +rfsimulator : +{ + serveraddr = "server"; + serverport = "4043"; + options = (); #("saviq"); or/and "chanmod" + modelname = "AWGN"; + IQfile = "/tmp/rfsimulator.iqs"; +}; + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + +log_config : +{ + global_log_level ="info"; + hw_log_level ="info"; + phy_log_level ="info"; + mac_log_level ="info"; + rlc_log_level ="info"; + pdcp_log_level ="info"; + rrc_log_level ="info"; + ngap_log_level ="debug"; + f1ap_log_level ="debug"; +}; + diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf new file mode 100644 index 0000000000..dbeb20c23f --- /dev/null +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf @@ -0,0 +1,300 @@ +Active_gNBs = ( "5G-GOA-gNB"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + gNB_name = "5G-GOA-gNB"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x1; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + + }); + + nr_cellid = 12345678L; + + ////////// Physical parameters: + + sib1_tda = 5; + min_rxtxtime = 6; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 2; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 2150 MHz + 14 PRBs@15kHz SCS (same as initial BWP), points to Subcarrier 0 of RB#10 of SSB block + absoluteFrequencySSB = 430504; + dl_frequencyBand = 66; + # this is 2150 MHz + dl_absoluteFrequencyPointA = 430000; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 0; + dl_carrierBandwidth = 25; + #initialDownlinkBWP + #genericParameters + # this is RBstart=0,L=25 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 6600; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 0; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 2; + initialDLBWPsearchSpaceZero = 0; + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 66; + # this is 1750 MHz + ul_absoluteFrequencyPointA = 350000; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 0; + ul_carrierBandwidth = 25; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 6600; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 0; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -118; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 0; +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0; + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 0; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 0; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "192.168.71.132"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + GNB_INTERFACE_NAME_FOR_NG_AMF = "eno1"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.71.129/26"; + GNB_INTERFACE_NAME_FOR_NGU = "eno1"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.71.129/26"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( +{ + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 150; + pucch_TargetSNRx10 = 200; + ulsch_max_frame_inactivity = 0; +} +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 150; + ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 +} +); + +RUs = ( + { + local_rf = "yes"; + nb_tx = 1; + nb_rx = 1; + att_tx = 0; + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + sf_extension = 0; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + ##beamforming 1x4 matrix: 1 layer x 4 antennas + #bf_weights = [0x00007fff, 0x0000,0x0000, 0x0000]; + ## beamforming 2x2 matrix: + # bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff]; + ## beamforming 4x4 matrix: + #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; + sdr_addrs = "type=x300"; + clock_src = "internal"; + # if_freq = 3700000000L; + # if_offset = 1000000; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_DISABLE"; + } +); + +rfsimulator : +{ + serveraddr = "server"; + serverport = "4043"; + options = (); #("saviq"); or/and "chanmod" + modelname = "AWGN"; + IQfile = "/tmp/rfsimulator.iqs"; +}; + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + +log_config : +{ + global_log_level ="info"; + hw_log_level ="info"; + phy_log_level ="info"; + mac_log_level ="info"; + rlc_log_level ="info"; + pdcp_log_level ="info"; + rrc_log_level ="info"; + ngap_log_level ="debug"; + f1ap_log_level ="debug"; +}; + diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf new file mode 100644 index 0000000000..98d901c35e --- /dev/null +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf @@ -0,0 +1,311 @@ +Active_gNBs = ( "gNB-OAI"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = ( +{ + ////////// Identification parameters: + gNB_ID = 0xe00; + gNB_name = "gNB-OAI"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }); }); + + nr_cellid = 12345678L; + + ////////// Physical parameters: + + pdsch_AntennaPorts_XP = 2; + pusch_AntennaPorts = 2; + do_CSIRS = 1; + do_SRS = 0; + ul_prbblacklist = "135,136,137,138" + + pdcch_ConfigSIB1 = ({ + controlResourceSetZero = 12; + searchSpaceZero = 0; + }); + + servingCellConfigCommon = ( + { + # spCellConfigCommon + + physCellId = 0; + + # downlinkConfigCommon + # frequencyInfoDL + # this is 3900.60 MHz + (134 PRBs + 4 SCs)@30kHz SCS (GSCN: 8158) + absoluteFrequencySSB = 663264; + dl_frequencyBand = 77; + # this is 3900.60 MHz + dl_absoluteFrequencyPointA = 660040; + + # scs-SpecificCarrierList + dl_offstToCarrier = 0; + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 273; + + # initialDownlinkBWP + # genericParameters + # this is RBstart=0,L=162 (275*(275-L+1))+(274-RBstart)) + initialDLBWPlocationAndBandwidth = 31624; + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + + # pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 0; + + # uplinkConfigCommon + # frequencyInfoUL + ul_frequencyBand = 77; + # scs-SpecificCarrierList + ul_offstToCarrier = 0; + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 273; + pMax = 20; + + # initialUplinkBWP + # genericParameters + initialULBWPlocationAndBandwidth = 31624; + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + + # rach-ConfigCommon + # rach-ConfigGeneric + prach_ConfigurationIndex = 98; + # prach_msg1_FDM + # 0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 12; + preambleReceivedTargetPower = -90; + # preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; + # powerRampingStep + # 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; + # ra_ReponseWindow + # 1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; + # ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR + # 1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; + # oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; + # ra_ContentionResolutionTimer + # (0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; + # prach-RootSequenceIndex_PR + # 1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + msg1_SubcarrierSpacing = 1, + # restrictedSetConfig + # 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + + # pucch-ConfigCommon + # pucchGroupHopping + # 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -70; + + # dmrs_TypeA_position + # 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + # ssb_PositionsInBurs_BitmapPR + # 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + # ssb_periodicityServingCell + # 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + + #tdd-UL-DL-ConfigurationCommon + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + ); + + + # Dedicated Serving Cell Configuration + servingCellConfigDedicated = ( + { + # BWP-Downlink + # BWP 1 Configuration + dl_bwp-Id_1 = 1; + dl_bwp1_locationAndBandwidth = 1099; // RBstart=0, L=273 (100 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_bwp1_subcarrierSpacing = 1; + + firstActiveDownlinkBWP-Id = 1; #BWP-Id + defaultDownlinkBWP-Id = 1; #BWP-Id + + # bwp-InactivityTimer ENUMERATED {ms2, ms3, ms4, ms5, ms6, ms8, ms10, ms20, ms30, + # ms40,ms50, ms60, ms80,ms100, ms200,ms300, ms500, + # ms750, ms1280, ms1920, ms2560, spare10, spare9, spare8, + # spare7, spare6, spare5, spare4, spare3, spare2, spare1 } + + # UplinkConfig + # BWP-Uplink + # BWP 1 Configuration + ul_bwp-Id_1 = 1; + ul_bwp1_locationAndBandwidth = 1099; // RBstart=0, L=273 (100 MHz BW) + # subcarrierSpacing + # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_bwp1_subcarrierSpacing = 1; + + firstActiveUplinkBWP-Id = 1; #BWP-Id + } + ); + + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// AMF parameters: + amf_ip_address = ( + { + ipv4 = "192.168.70.132"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24"; + GNB_INTERFACE_NAME_FOR_NGU = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + } + +} +); + +MACRLCs = ( +{ + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 300; + pucch_TargetSNRx10 = 200; + pusch_FailureThres = 1000; + ulsch_max_frame_inactivity = 0; + ul_max_mcs = 28; +} +); + +L1s = ( +{ + num_cc = 1; + tr_n_preference = "local_mac"; + prach_dtx_threshold = 120; + pucch0_dtx_threshold = 80; +} +); + +RUs = ( +{ + local_rf = "yes" + nb_tx = 2; + nb_rx = 2; + att_tx = 0; + att_rx = 0; + bands = [77]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 75; + eNB_instances = [0]; + ##beamforming 1x2 matrix: 1 layer x 2 antennas + bf_weights = [0x00007fff, 0x0000]; + #clock_src = "internal"; + sdr_addrs = "mgmt_addr=192.168.10.2,addr=192.168.10.2,clock_source=internal,time_source=internal" +} +); + +THREAD_STRUCT = ( +{ + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; +} +); + +rfsimulator : +{ + serveraddr = "server"; + serverport = "4043"; + options = (); #("saviq"); or/and "chanmod" + modelname = "AWGN"; + IQfile = "/tmp/rfsimulator.iqs"; +}; + +security = { + # preferred ciphering algorithms + # the first one of the list that an UE supports in chosen + # valid values: nea0, nea1, nea2, nea3 + ciphering_algorithms = ( "nea0" ); + + # preferred integrity algorithms + # the first one of the list that an UE supports in chosen + # valid values: nia0, nia1, nia2, nia3 + integrity_algorithms = ( "nia2", "nia0" ); + + # setting 'drb_ciphering' to "no" disables ciphering for DRBs, no matter + # what 'ciphering_algorithms' configures; same thing for 'drb_integrity' + drb_ciphering = "yes"; + drb_integrity = "no"; +}; + +log_config : +{ + global_log_level ="info"; + hw_log_level ="info"; + phy_log_level ="info"; + mac_log_level ="info"; + rlc_log_level ="info"; + pdcp_log_level ="info"; + rrc_log_level ="info"; + ngap_log_level ="debug"; + f1ap_log_level ="debug"; +}; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf index 30be597255..f5f187a736 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf @@ -11,18 +11,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf index 8ff83b5d02..2da02b0353 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.4layer.conf @@ -11,22 +11,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf index 9d00ae20aa..b31569af11 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf @@ -11,24 +11,12 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; ////////// Physical parameters: - min_rxtxtime = 2; do_CSIRS = 1; do_SRS = 1; @@ -283,8 +271,8 @@ RUs = ( local_rf = "yes" nb_tx = 1 nb_rx = 1 - att_tx = 6; - att_rx = 6; + att_tx = 12; + att_rx = 12; bands = [78]; max_pdschReferenceSignalPower = -27; max_rxgain = 114; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf index 6719a5534d..9e4906af0f 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.sabox.conf @@ -13,18 +13,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 450; - mnc = 05; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0xd143a5; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 450; mnc = 05; mnc_length = 2; snssaiList = ({ sst = 1 }) }); tr_s_preference = "local_mac" @@ -225,7 +214,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf index 5f8bf45232..67797a0378 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf @@ -11,31 +11,20 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - } - ); - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; ////////// Physical parameters: - pdsch_AntennaPorts_XP = 1; + pdsch_AntennaPorts_XP = 2; pusch_AntennaPorts = 2; - do_CSIRS = 0; - ul_prbblacklist = "79,80,81,82" + do_CSIRS = 1; pdcch_ConfigSIB1 = ( { controlResourceSetZero = 12; - searchSpaceZero = 10; + searchSpaceZero = 0; } ); @@ -67,7 +56,7 @@ gNBs = initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon initialDLBWPcontrolResourceSetZero = 12; - initialDLBWPsearchSpaceZero = 10; + initialDLBWPsearchSpaceZero = 0; #uplinkConfigCommon #frequencyInfoUL @@ -203,9 +192,11 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; - pusch_TargetSNRx10 = 150; + pusch_TargetSNRx10 = 300; pucch_TargetSNRx10 = 200; + pusch_FailureThres = 1000; ulsch_max_frame_inactivity = 0; + ul_max_mcs = 28; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf index 1f1f64ce3f..513c167a69 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf @@ -11,17 +11,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - } - ); - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf index ad1471339a..1defbf91ed 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf @@ -11,22 +11,7 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({ - mcc = 208; - mnc = 99; - mnc_length = 2; - snssaiList = ( - { - sst = 1; - sd = 0x1; // 0 false, else true - }, - { - sst = 1; - sd = 0x112233; // 0 false, else true - } - ); - - }); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1 }) }); nr_cellid = 12345678L; diff --git a/targets/SCRIPTS/asn1_generate_rrc_messaging_c_code.bash b/targets/SCRIPTS/asn1_generate_rrc_messaging_c_code.bash deleted file mode 100755 index e0832dd8a7..0000000000 --- a/targets/SCRIPTS/asn1_generate_rrc_messaging_c_code.bash +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# generate .c and .h files -which asn1c > /dev/null -if [ $? -eq 0 ] ; then echo "asn1c is installed" ; else echo "Please install asn1c (version 0.9.22 or greater)" ; fi -cd $OPENAIR2_DIR/RRC/LITE/MESSAGES && asn1c -gen-PER -fcompound-names -fnative-types -fskeletons-copy $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions.asn - - -# generate ASN constants - -rm -f $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1_constants.h -cat $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions.asn | grep INTEGER\ \:\: | sed 's/INTEGER ::=//g' | sed 's/--/\/\//g' | sed 's/^/#define /' | sed 's/\-1/_minus_1/g' | sed 's/\-/_/g' > $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1_constants.tmp -rm -f /tmp/EUTRA-RRC-Definitions.tmp -cat $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions.asn | grep --invert-match SEQUENCE | grep INTEGER\ \( | uniq | grep \:\:\= | sed 's/INTEGER\ //g' | sed 's/[()]//g' | tr "." " " | sed 's/\:\:\=//g' | tr '\t' " " > /tmp/EUTRA-RRC-Definitions.tmp -cat /tmp/EUTRA-RRC-Definitions.tmp | sed 's/^ *//g' | sed 's/ \{1,\}/ /g' | cut --complement -d ' ' -f3 | sed 's/^/#define min_val_/' | sed 's/\ -/\ +/g' | sed 's/-/_/g' | sed 's/\ +/\ -/g' >> $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1_constants.tmp -cat /tmp/EUTRA-RRC-Definitions.tmp | sed 's/^ *//g' | sed 's/ \{1,\}/ /g' | cut --complement -d ' ' -f2 | sed 's/^/#define max_val_/' | sed 's/\ -/\ +/g' | sed 's/-/_/g' | sed 's/\ +/\ -/g' >> $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1_constants.tmp; -echo "#ifndef __ASN1_CONSTANTS_H__" > $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1_constants.h -echo "#define __ASN1_CONSTANTS_H__" >> $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1_constants.h -cat $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1_constants.tmp >> $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1_constants.h -echo "#endif " >> $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1_constants.h -rm -f $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1_constants.tmp; diff --git a/targets/SCRIPTS/install_asn1.sh b/targets/SCRIPTS/install_asn1.sh deleted file mode 100644 index 7da7d50b47..0000000000 --- a/targets/SCRIPTS/install_asn1.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -which asn1c > /dev/null -if [ $? -eq 0 ] ; then echo "asn1c is installed" ; else echo "Please install asn1c (version 0.9.22 or greater)" ; fi -cd $OPENAIR2_DIR/RRC/LITE/MESSAGES && asn1c -gen-PER -fcompound-names -fnative-types -fskeletons-copy $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions.asn - - diff --git a/targets/SCRIPTS/install_asn1c_0.9.24.modified.bash b/targets/SCRIPTS/install_asn1c_0.9.24.modified.bash deleted file mode 100755 index 9c4947d479..0000000000 --- a/targets/SCRIPTS/install_asn1c_0.9.24.modified.bash +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -#/* -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -################################################################################ -# Tested on ubuntu 12.04 with updates 07 november 2013 - -$1 rm -Rf /usr/local/src/asn1c-r1516 -$1 svn co https://github.com/vlm/asn1c/trunk /usr/local/src/asn1c-r1516 -r 1516 > /tmp/install_log.txt -cd /usr/local/src/asn1c-r1516 -$1 patch -p0 < $OPENAIR3_DIR/S1AP/MESSAGES/ASN1/asn1cpatch.p0 > /tmp/install_log.txt -$1 ./configure > /tmp/install_log.txt -$1 make > /tmp/install_log.txt -$1 make install > /tmp/install_log.txt diff --git a/targets/SCRIPTS/svn-merge-meld.py b/targets/SCRIPTS/svn-merge-meld.py deleted file mode 100755 index a05d697f2e..0000000000 --- a/targets/SCRIPTS/svn-merge-meld.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python -# svn merge-tool python wrapper for meld -# to use: edit ~/.subversion/config and uncomment the line merge-tool-cmd = -# and set the path to your command - -# Note that when a conflict occurs, you will be prompted what to do with it. You need to type a single 'l' and for svn to run this script. When you've finished your merge, you need to type an 'r' to resolve the conflict and copy the merged version to the working copy. - -import os, sys -import subprocess -import shutil - -try: - # path to meld - meld = "/usr/bin/meld" - - print "Set the file paths for mine, theirs, and merged\n" - print "When you've finished your merge, you need to type an 'r' to resolve the conflict and copy the merged version to the working copy\n" - - # the base or "left" revision version of the file you're merging with - base = sys.argv[1] - - # this is "later" or "right"revision version of the file you're merging with - theirs = sys.argv[2] - - # this is my version, recommandations: sync your copy to the latest version - mine = sys.argv[3] - - #this starts out as a copy of 'mine' (your working copy), and this is where you want the final results of the merge to end up. - merged = sys.argv[4] - - print "Calling meld: the order of the files is (merged, theirs, and mine)" - # all 4 versions: worke right-to-left, reslut being stored in the left file - # cmd = [meld, mine, base, theirs, merged] - # only 3 versions - cmd = [meld, merged, theirs, mine] - - # Call meld, making sure it exits correctly - subprocess.check_call(cmd) -except: - print "Oh, an error!\n" - sys.exit(-1)